NPC not respond if you are away.

OverLord

New member
Messages
168
Points
0
Age
36
Location
Brazil
Emulator
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;}


}
 
- 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.

 
- 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

 
You can set npc max distance from where it start respond

Add at end or your npc script:

Code:
OnInit:    setnpcdistance 3;    end; 
 
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.

 
Back
Top