Jump to content
  • 0

How to Make NPC walk using other npc script


Sunny

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.01
  • Content Count:  26
  • Reputation:   0
  • Joined:  05/28/20
  • Last Seen:  

Good day im here for newbies question again,.

I trying to make my move npc,. and i already did it 
and starting moving already,. but now im trying to put some condition
on in,.

this is my example

ra_temin,167,45,6    script    Introductioners    966,{

mes"Hello Please Follow the guard,.";

mes "He is leading the way,. ";

set walk,1; // this is my condition, so that the player need to talk to this npc first before the guard will move

close;

  
}

ra_temin,165,45,6    script    Guard    966,{

if (walk ==1) {

OnInit:

npcspeed 200;
npcwalkto 177,29;

end;

} 



}

BTW this script is on one .txt files only

PROBLEMS: The guard already move before i talk to the introductioners;

and also can i make the player character move by the script so that he will follow the npc?

thank you so much

-Novice Ace


 

Edited by Mael
Use codebox
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

Here is a better thing to do for your script. I made one myself instead of editing yours..

Anyways, I think you can understand this very clearly..

prontera,150,150,0	script	NPC A	100,{
	mes "Test..";
	close2;
	if ( done_walking ) end; // trigger only once, cannot be triggered twice per character..
	donpcevent "NPC B::OnNPCWalk";
	sleep2 1000; // 1 sec delay before player walks
	unitwalk getcharid(3), 160, 158;
	done_walking = true; // sets done walking here..
	end;
}

prontera,150,152,0	script	NPC B	100,{
	mes "Test";
	close;
OnNPCWalk:
	npcspeed 200;
	npcwalkto 160,160;
	sleep 5000; // pause for 5 sec.. then..
	npcwalkto .x, .y; // walk back to orig position
	end;

OnInit:
	getmapxy .map$, .x, .y, BL_NPC, strnpcinfo(0); // save orig position
	end;
}

 

Edited by Mabuhay
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  215
  • Reputation:   45
  • Joined:  05/03/13
  • Last Seen:  

Hello,

For the guard moving before talking to it, remove the OnInit:

When the player will talk to him it'll move then.

For the character moving by script, I never worked on that.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

*unitwalk <GID>,<x>,<y>{,"<event label>"};
*unitwalkto <GID>,<Target GID>{,"<event label>"};

This command will tell a <GID> to walk to a position, defined either as a set of
coordinates or another object. The command returns a 1 for success and 0 upon failure.

If coordinates are passed, the <GID> will walk to the given x,y coordinates on the
unit's current map. While there is no way to move across an entire map with 1 command
use, this could be used in a loop to move long distances.

If an object ID is passed, the initial <GID> will walk to the <Target GID> (similar to
walking to attack). This is based on the distance from <GID> to <Target ID>. This command
uses a hard walk check, so it will calculate a walk path with obstacles. Sending a bad
target ID will result in an error.

An optional Event Label can be passed as well which will execute when the <GID> has reached
the given coordinates or <Target GID>.

Examples:

// Makes player walk to the coordinates (150,150).
	unitwalk getcharid(3),150,150;

// Performs a conditional check with the command and reports success or failure to the player.
	if (unitwalk(getcharid(3),150,150))
		dispbottom "Walking you there...";
	else
		dispbottom "That's too far away, man.";

// Makes player walk to another character named "WalkToMe".
	unitwalkto getcharid(3),getcharid(3,"WalkToMe");

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.01
  • Content Count:  26
  • Reputation:   0
  • Joined:  05/28/20
  • Last Seen:  

3 hours ago, Kreustoo said:

Hello,

For the guard moving before talking to it, remove the OnInit:

When the player will talk to him it'll move then.

For the character moving by script, I never worked on that.

after removing the OnInit:
the npc wont walk anymore,. T_T

 

 

2 hours ago, Mabuhay said:

*unitwalk <GID>,<x>,<y>{,"<event label>"};
*unitwalkto <GID>,<Target GID>{,"<event label>"};

This command will tell a <GID> to walk to a position, defined either as a set of
coordinates or another object. The command returns a 1 for success and 0 upon failure.

If coordinates are passed, the <GID> will walk to the given x,y coordinates on the
unit's current map. While there is no way to move across an entire map with 1 command
use, this could be used in a loop to move long distances.

If an object ID is passed, the initial <GID> will walk to the <Target GID> (similar to
walking to attack). This is based on the distance from <GID> to <Target ID>. This command
uses a hard walk check, so it will calculate a walk path with obstacles. Sending a bad
target ID will result in an error.

An optional Event Label can be passed as well which will execute when the <GID> has reached
the given coordinates or <Target GID>.

Examples:

// Makes player walk to the coordinates (150,150).
	unitwalk getcharid(3),150,150;

// Performs a conditional check with the command and reports success or failure to the player.
	if (unitwalk(getcharid(3),150,150))
		dispbottom "Walking you there...";
	else
		dispbottom "That's too far away, man.";

// Makes player walk to another character named "WalkToMe".
	unitwalkto getcharid(3),getcharid(3,"WalkToMe");

 

Thank sir, the character now can walk base on my script
thanks,. BTW where can i read something like this information?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  215
  • Reputation:   45
  • Joined:  05/03/13
  • Last Seen:  

31 minutes ago, Sunny said:

after removing the OnInit:
the npc wont walk anymore,. T_T

As I said, you have to talk with the player with the variable set at 1 (talking to the first npc) and your guard should move.

And for the commands:

https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.01
  • Content Count:  26
  • Reputation:   0
  • Joined:  05/28/20
  • Last Seen:  

On 6/16/2020 at 11:52 PM, Kreustoo said:

As I said, you have to talk with the player with the variable set at 1 (talking to the first npc) and your guard should move.

And for the commands:

https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

Thank you,
I fix it by putting some timer ❤️
Thank you very much

my next problem is the guard is now moving together with the first character who click it
but if there is 2 player trying to talk to the npc,. the guard is already missing because he still moving together with the first player
can you give me idea on what should i do with this?

i want to make my script that even there is someone moving with the guard,. the other player can still can do it also? is that possible? 

 

On 6/17/2020 at 12:24 AM, Mabuhay said:

Here is a better thing to do for your script. I made one myself instead of editing yours..

Anyways, I think you can understand this very clearly..


prontera,150,150,0	script	NPC A	100,{
	mes "Test..";
	close2;
	if ( done_walking ) end; // trigger only once, cannot be triggered twice per character..
	donpcevent "NPC B::OnNPCWalk";
	sleep2 1000; // 1 sec delay before player walks
	unitwalk getcharid(3), 160, 158;
	done_walking = true; // sets done walking here..
	end;
}

prontera,150,152,0	script	NPC B	100,{
	mes "Test";
	close;
OnNPCWalk:
	npcspeed 200;
	npcwalkto 160,160;
	sleep 5000; // pause for 5 sec.. then..
	npcwalkto .x, .y; // walk back to orig position
	end;

OnInit:
	getmapxy .map$, .x, .y, BL_NPC, strnpcinfo(0); // save orig position
	end;
}

 

oh my, I wasted your time for this.
thank you this is great. I will use this and dump mine hehehe ty

my next problem is, there is anyway that it can trigger by 2 or more player?
what im thinking is duplicating together with the maps ,.
but there is other solution?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

Here are the options I suggest you do :

  1. Make duplicate of the guard NPC.
  2. Dont make the NPC A interact while guard NPC is still with another player.
  3. Put the player on an instance (unnecessary and complicated)
  4. Duplicate Maps and NPC (just like the default ones when spawning in-game for the first time - unnecessary also)

3 and 4 obviously are out of question but Im still giving you the option.

1 and 2 are your best options.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.01
  • Content Count:  26
  • Reputation:   0
  • Joined:  05/28/20
  • Last Seen:  

On 6/17/2020 at 12:40 AM, Mabuhay said:

Here are the options I suggest you do :

  1. Make duplicate of the guard NPC.
  2. Dont make the NPC A interact while guard NPC is still with another player.
  3. Put the player on an instance (unnecessary and complicated)
  4. Duplicate Maps and NPC (just like the default ones when spawning in-game for the first time - unnecessary also)

3 and 4 obviously are out of question but Im still giving you the option.

1 and 2 are your best options.

Thanks sir, but im doing this script for customize starting point (respawn points of new created  character)
its like a tutorial for the beginners so expected that there is many character doing this interaction.

demo:
When user created new character, they will respawn in my customize map,.
then they need to talk to the Intruductioner, so than the guard will move for the next step of the guide

but because it is a starting point im expecting that there will be more than 1 player at the same time doing this
especially if the server is just open.
------------

i like the idea of duplicating the guard npc but,. i cant think of a way on how it works?
should i line them, then if there is new character enter the first in line will move,. then when another
player enter,. the second in the line will move and so on,. is that possible? hmmm 

Thank you for reading,.

EDIT: I try searching and the best idea i get is making a map instance for it,. Now im searching on how to make one
 

Edited by Sunny
add more information
Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...