Baps 1 Posted February 6, 2020 (edited) 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 ? Edited February 11, 2020 by Baps Quote Share this post Link to post Share on other sites
0 Kenpachi 65 Posted February 6, 2020 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 Quote Share this post Link to post Share on other sites
0 Baps 1 Posted February 7, 2020 Hi, Nice ! I didn't do my research so good .... Thank you, i'll test this :). Quote Share this post Link to post Share on other sites
0 Baps 1 Posted February 8, 2020 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 ;). Quote Share this post Link to post Share on other sites
0 Baps 1 Posted February 8, 2020 Never mind, i found the solution, make a variable for GID and use unitstop and unitwalk. Here is my test who works: 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; } Quote Share this post Link to post Share on other sites
0 Baps 1 Posted February 8, 2020 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 😕 Quote Share this post Link to post Share on other sites
0 Kenpachi 65 Posted February 9, 2020 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 Quote Share this post Link to post Share on other sites
0 Baps 1 Posted February 9, 2020 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 ? Quote Share this post Link to post Share on other sites
0 Kenpachi 65 Posted February 10, 2020 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 Quote Share this post Link to post Share on other sites
0 Baps 1 Posted February 10, 2020 I'll test it and come back to you. Thank you for your script ;). Quote Share this post Link to post Share on other sites
0 Baps 1 Posted February 11, 2020 Hi, Wel well well, your script is awesome ! Congrats for it ! It's so clean and smooth know ! Wow ! Thank you so much ! Quote Share this post Link to post Share on other sites
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 ?
Edited by BapsShare this post
Link to post
Share on other sites