[Solved] Possible to move character's player ?

Baps

New member
Messages
43
Points
0
Hello everyone,

I'm asking a question in my head right now.

Is it possible to move a character to follow a path with a script or something ? Like NPC who can move to X to Y position on a map, is it possible for a char to force the char to move until a point on a map ?

If yes, how ?

 
Last edited by a moderator:
Hi.

From doc/script_commands.txt

*unitwalk(<GID>, <x>, <y>)
*unitwalk(<GID>, <target_GID>)

This is one command, but can be used in two ways. If only the first
argument is given, the unit whose GID is given will start walking towards
the target whose GID is given.

When 2 arguments are passed, the given unit will walk to the given x,y
coordinates on the map where the unit currently is.

Examples:

//Will move/walk the poring we made to the coordinates 150,150
unitwalk(.GID, 150, 150);

//NPC will move towards the attached player.
unitwalk(.GID, getcharid(CHAR_ID_ACCOUNT));//a player's GID is their account ID




.GID is the character's account ID.

~Kenpachi

 
Hi,

Nice ! I didn't do my research so good ....

Thank you, i'll test this :).

 
Okay i tested it and it works.

Now i have a new question, the character move only if de X and Y position is on sight. However, i want to move at a point on the map that i can't see.

How can i do that ?

I already put to unitwalk one after the other but it's not working.

If you have an idea ;).

 
Never mind, i found the solution, make a variable for GID and use unitstop and unitwalk.

Here is my test who works:

Code:
izlude,124,148,4	script	test#iz	4_F_NURSE,{
	.@GID = getcharid(3);
	unitwalk .@GID,128,124;
	sleep 1000;
	unitstop .@GID;
	sleep 1000;
	unitwalk .@GID,128,109;
	sleep 1000;
	unitstop .@GID;
	sleep 1000;
	unitwalk .@GID,121,98;
	sleep 1000;
	unitstop .@GID;
	sleep 1000;
	unitwalk .@GID,108,97;
end;
}
 
Other question, there is a way to do it without a sleep ?

With 1s each time it's like the character freeze when he starts a new destination 😕

 
Unfortunately the script engine currently provides no command to check if a character is walking or not.

Guess you have to play with the sleep times a bit.

//EDIT:

I wrote a script command to check if a unit is walking: https://github.com/HerculesWS/Hercules/pull/2628

You may add it by yourself, or wait until the PR is merged.

~Kenpachi

 
Last edited by a moderator:
Hi,

Tahnk you for your reply, so if i understand correctly, with your script, the character will not wait 1s and will walk all the way and follow the "point" x/y i give ?

 
Nope. That script command just enables you to check if the character is walking or not.

You can use it to prevent that freeze you mentioned. Your script may could look like this, after you added the script command to your source:

izlude,124,148,4 script test#iz 4_F_NURSE,{
.@GID = getcharid(3);

unitwalk .@GID,128,124;

while (unitiswalking(.@GID) == 1)
sleep2(50);

unitwalk .@GID,128,109;

while (unitiswalking(.@GID) == 1)
sleep2(50);

unitwalk .@GID,121,98;

while (unitiswalking(.@GID) == 1)
sleep2(50);

 unitwalk .@GID,108,97;

end;
}






~Kenpachi

 
Last edited by a moderator:
Hi,

Wel well well, your script is awesome ! Congrats for it !

It's so clean and smooth know ! Wow ! Thank you so much !

 
Back
Top