PDA

View Full Version : Extra variable for moveto and pathto quest functions


Dibalamin
07-26-2009, 11:52 AM
Would it be possible to have the heading added to these as well as another field that would include whether or not the mob stops and holds at those coordinates? ex: quest::moveto(x,y,z,h,stop(1/0)).

Currently, after a mob uses moveto, it returns to its start point. It requires a lot of work to get that little weasel to stop sometimes and can create a lot of extra grids. This would also allow for more scripting control than using $wp which only fires when a mob leaves a waypoint. You would be able to have say statements appear more fluid with less timer setting required.

trevius
07-27-2009, 06:46 PM
In this thread, Justsomeguy shows how to use quest::moveto and save the new WP after each move fairly easily:

http://www.eqemulator.net/forums/showthread.php?p=175329#post175329


As long as you have this in your script, it will save every WP it gets to as long as the NPC isn't already using a grid:

sub EVENT_WAYPOINT {

$npc->SaveGuardSpot(0);

}

If your NPC is already on a grid, you can just have them do a quest::stop() to make them leave the grid, and you can add a $npc->SaveGuardSpot(0) in after the stop so it will stay at it's current position. Then, if you want to have say messages trigger at certain WPs, you can just use variable settings after you do your moveto command and then set the say message to happen when EVENT_WAYPOINT is triggered if that certain variable is currently set. Something like this:

my $Destination = "None";

sub EVENT_SAY {

if ($text=~/hail/i) {
quest::say("I can [move] if I am in your way.");
}

if ($text=~/move/i) {
#Moves and sets a variable for the waypoint
quest::say("Very well.");
quest::moveto(100, 200, 300);
$Destination = "RoomB"; #Naming this makes it easy to know which point you are dealing with if you have many.
quest::stop(); #only required if the NPC is already on a grid
}
}

sub EVENT_WAYPOINT {

$npc->SaveGuardSpot(0); #this is so npcs don't not walk to waypoint and return immediately

if($Destination eq "RoomB") { #NPC Has Moved
quest::say("That move went well enough.");
}
}

This way isn't too overly complex and you don't need to use timers for say messages unless you want the NPC to say something sometime after it arrives at it's destination.

I do agree that the stop option should definitely be added to the moveto quest command. It would have saved me a bit of work on a script I am currently working on that has quite a bit of moving around in it. Heading probably wouldn't be a bad thing to have as an option either. I might try to look into adding these features if I get some time soon. For now, the above method works pretty well.

trevius
07-30-2009, 05:12 AM
I went ahead and added the 2 new options to quest::moveto. It wasn't hard to get them added using guard spots. Here is the new explanation of the command I updated in the wiki for it:

quest::moveto(x,y,z, [h, saveguardspot?]) - NPC moves to the set coordinates with Heading and saveguardspot being optional. NPC will path back unless saveguardspot is set to 1. Heading of -1 will use existing heading.

Any quests already using this command should still be fine, since the 2 new ones are completely optional. Though, there isn't much use to set the heading field unless you are saving the guard spot as well, as the NPC will just return right away anyway. You can set heading to -1 and that will force the NPC to keep the heading it was using on it's way to the destination. So, you don't have to set headings manually each time unless you really want to use a particular heading at some point.

Here is an example of a quest using all of these options:


sub EVENT_SAY {

my $move = quest::saylink("move and stay there");

if ($text =~/Hail/i)
{
quest::say ("Hello, $name. Would you like me to [$move]?");
}

if ($text =~/move and stay there/i)
{
quest::say ("Ok, I am moving and I won't be back! I might even face South when I get there, if I am feeling crazy!");
#Example loc at the top of the center of Nexus facing South
quest::moveto(5, 5, -31, 127, 1);
}

}
Lemme know if there are any questions or issues with this.

Dibalamin
07-30-2009, 09:15 AM
Thanks! I found that post after I'd posted this though =/. Consequently, when I use stop, the NPC generally takes the absolute straightest route home that it could find, so I generally just used long pauses and a timer with a depop.