OverLord 4 Posted January 23, 2015 Where my erro? I want the NPC only run if the player is a minimum 3 cells away. But regardless of the distance he always call the function. - script Ore Mine::oremine 844,{ .@number = 1; getmapxy .@map1$, .@x1, .@y1, 0; getmapxy .@map2$, .@x2, .@y2, 0; set h_run$, strnpcinfo(0); if ( .@map1$ == .@map2$ && distance(.@x1,.@y1,.@x2,.@y2) <= 3 ) { if ( h_run$ == strnpcinfo(0) ) { callfunc("StartMining",.@number); set h_run$, ""; } } else { mes "Far Away"; close;} } Quote Share this post Link to post Share on other sites
0 4144 366 Posted January 23, 2015 You can set npc max distance from where it start respond Add at end or your npc script: OnInit: setnpcdistance 3; end; Quote Share this post Link to post Share on other sites
0 Garr 117 Posted January 23, 2015 - script Ore Mine::oremine 844,{ .@number = 1; getmapxy .@map1$, .@x1, .@y1, 0; getmapxy .@map2$, .@x2, .@y2, 1; set h_run$, strnpcinfo(0); //What' that for? if ( .@map1$ == .@map2$ && distance(.@x1,.@y1,.@x2,.@y2) <= 3 ) { if ( h_run$ == strnpcinfo(0) ) { // Are you scared NPC will change name for some reason? callfunc("StartMining",.@number); set h_run$, ""; } } else { mes "Far Away"; close; }} You were finding distance between character and himself, which is always less than 3 >.> Changed 2nd getmapxy to look for NPC coords, should work now. Quote Share this post Link to post Share on other sites
0 OverLord 4 Posted January 23, 2015 - script Ore Mine::oremine 844,{ .@number = 1; getmapxy .@map1$, .@x1, .@y1, 0; getmapxy .@map2$, .@x2, .@y2, 1; set h_run$, strnpcinfo(0); //What' that for? if ( .@map1$ == .@map2$ && distance(.@x1,.@y1,.@x2,.@y2) <= 3 ) { if ( h_run$ == strnpcinfo(0) ) { // Are you scared NPC will change name for some reason? callfunc("StartMining",.@number); set h_run$, ""; } } else { mes "Far Away"; close; }} You were finding distance between character and himself, which is always less than 3 >.> Changed 2nd getmapxy to look for NPC coords, should work now. Garr, my npc have rand coords. No fix coord Quote Share this post Link to post Share on other sites
0 Garr 117 Posted January 23, 2015 Or that ^ And it doesn't matter, both your getmapxy were getting character position, and since character can't really be 3 cells away from himself... Now one getmapxy gets char coords, other one gets NPC coords, wherever NPC may be. Quote Share this post Link to post Share on other sites
0 OverLord 4 Posted January 23, 2015 You can set npc max distance from where it start respond Add at end or your npc script: OnInit: setnpcdistance 3; end; I love you man! thx!!! Quote Share this post Link to post Share on other sites
Share this post
Link to post
Share on other sites