Jump to content
  • 0
Sign in to follow this  
Baps

[Solved] Possible to move character's player ?

Question

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 Baps

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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 ;).

Share this post


Link to post
Share on other sites
  • 0

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

 

Share this post


Link to post
Share on other sites
  • 0

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 😕

Share this post


Link to post
Share on other sites
  • 0

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

 

Share this post


Link to post
Share on other sites
  • 0

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 ?

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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