Jump to content
  • 0
OverLord

NPC not respond if you are away.

Question

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

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
-    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.

Share this post


Link to post
Share on other sites
  • 0

 

-    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

Share this post


Link to post
Share on other sites
  • 0

You can set npc max distance from where it start respond

 

Add at end or your npc script:

 

OnInit:    setnpcdistance 3;    end; 

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

 

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!!! 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.