|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
Quests::Plugins & Mods Completed plugins for public use as well as modifications. |

01-27-2010, 02:05 PM
|
 |
Demi-God
|
|
Join Date: May 2007
Location: b
Posts: 1,449
|
|
Saw you talking on IRC about this, looks good to me. It's highly CPU efficient too, from what you were telling me. Nice.
|
 |
|
 |

01-27-2010, 06:10 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Yeah, I have probably 100+ NPCs running this in the new Hills of Shade zone I am working on currently, and I see no CPU utilization increase when they are active. My CPU stays around 2-3%, so it seems like it could be used pretty freely without much concern.
It might be nice to add something that does this into the source to be set similar to how roam boxes are, so you don't need to add anything to the script. I might try to add something like that in at some point if someone doesn't do it before then.
Anyone with SoF can check this script out in action by starting a char on Storm Haven and going to Temple of Marr, and then using the portal there (walk onto the pad labeled "Hills of Shade Portal"). The zone is under development now, but I am leaving access to it up while it is being developed. There is some actual pathing mobs in the zone, but almost everything other than the Mushroom section of the zone is currently using this plugin to handle pathing. I am pretty impressed with how good it works so far. Instead of having to manually create random grids or roamboxes for a hundred or so spawn points, I was able to add this plugin to them and turn hours of work into a few minutes (not counting the time it took to write this plugin and the new quest Objects, of course!) 
|
 |
|
 |
 |
|
 |

01-28-2010, 09:58 AM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Here is another slightly more complicated plugin similar to the random roam, accept this one will only go in straight lines, North, South, East, or West. It also checks the LoS slightly further than how far it actually plans to move, to help keep NPCs away from walls a little. The main use for this one is indoor areas that line up well with the X Y axis. It still isn't nearly as good as real pathing in indoors, but it can give your NPCs a little life without too much work and without looking too buggy.
To install this plugin, just follow the steps for the previous plugin and name this one's file "straightpath.pl"
Code:
#Usage: plugin::StraightPath(MaxXVariance, MaxYVariance);
sub StraightPath {
my $npc = $_[0];
my $MaxXVariance = $_[1];
my $MaxYVariance = $_[2];
# Don't try to roam if already engaged in combat!
if ($npc->IsEngaged() != 1) {
#my $AtGuardSpot = 0;
#Get needed Locs
my $CurX = $npc->GetX();
my $CurY = $npc->GetY();
#my $CurZ = $npc->GetZ(); #Not currently required by this plugin
my $OrigX = $npc->GetSpawnPointX();
my $OrigY = $npc->GetSpawnPointY();
my $OrigZ = $npc->GetSpawnPointZ();
my $GuardX = $npc->GetGuardPointX();
my $GuardY = $npc->GetGuardPointY();
if ($CurX == $GuardX && $CurY == $GuardY) { #If the NPC has finished walking to the previous given Loc
#$AtGuardSpot = 1;
#Get a random X and Y within the set range
my $RandomX = int(rand($MaxXVariance - 1)) + 1;
my $RandomY = int(rand($MaxYVariance - 1)) + 1;
my $PosX = $OrigX + $RandomX;
my $PosY = $OrigY + $RandomY;
my $NegX = $OrigX - $RandomX;
my $NegY = $OrigY - $RandomY;
my $NewX = quest::ChooseRandom($PosX, $NegX, $OrigX, $OrigX);
if ($NewX == $OrigX) { # If we are using the orignal X, then chose a random Y to go to
if ($CurX == $OrigX) { # If they are moving on the same Axis they are currently on
my $NewY = quest::ChooseRandom($PosY, $NegY);
#Check for LoS and Z issues before moving to the new Loc
my $NewZ = $npc->FindGroundZ($NewX, $NewY, 5) + 1; #Add 1 to the new Z to prevent hopping issue when they arrive
if ($NewZ > -999999 && $OrigZ > ($NewZ - 16) && $OrigZ < ($NewZ + 14)) {
if ($NewY > $OrigY) { # Checking which direction we are moving in
# Adjust the LoS Check to check further than how far we are traveling so we stay away from walls
my $LoS_Check = $npc->CheckLoSToLoc($NewX, $NewY + 2, $NewZ, 5);
#Check LoS to the new random Loc
if ($LoS_Check) {
quest::moveto($NewX, $NewY, $NewZ, -1, 1);
}
}
else {
# Adjust the LoS Check to check further than how far we are traveling so we stay away from walls
my $LoS_Check = $npc->CheckLoSToLoc($NewX, $NewY - 2, $NewZ, 5);
#Check LoS to the new random Loc
if ($LoS_Check) {
quest::moveto($NewX, $NewY, $NewZ, -1, 1);
}
}
}
}
else { # If not moving on the same Axis they are already on, just return them to their Spawn Point
quest::moveto($OrigX, $OrigY, $OrigZ, -1, 1);
}
}
else { # If we are not using the orignal X, then use the original Y instead
if ($CurY == $OrigY) { # If they are moving on the same Axis they are currently on
#Check for LoS and Z issues before moving to the new Loc
my $NewZ = $npc->FindGroundZ($NewX, $OrigY, 5) + 1; #Add 1 to the new Z to prevent hopping issue when they arrive
if ($NewZ > -999999 && $OrigZ > ($NewZ - 16) && $OrigZ < ($NewZ + 14)) {
if ($NewX > $OrigX) { # Checking which direction we are moving in
# Adjust the LoS Check to check further than how far we are traveling so we stay away from walls
my $LoS_Check = $npc->CheckLoSToLoc($NewX + 2, $OrigY, $NewZ, 5);
#Check LoS to the new random Loc
if ($LoS_Check) {
quest::moveto($NewX, $OrigY, $NewZ, -1, 1);
}
}
else {
# Adjust the LoS Check to check further than how far we are traveling so we stay away from walls
my $LoS_Check = $npc->CheckLoSToLoc($NewX - 2, $OrigY, $NewZ, 5);
#Check LoS to the new random Loc
if ($LoS_Check) {
quest::moveto($NewX, $OrigY, $NewZ, -1, 1);
}
}
}
}
else { # If not moving on the same Axis they are already on, just return them to their Spawn Point
quest::moveto($OrigX, $OrigY, $OrigZ, -1, 1);
}
}
}
#Bool Return option to see the result of if the NPC is at it's new loc or not
#return $AtGuardSpot;
}
}
return 1; #This line is required at the end of every plugin file in order to use it
|
 |
|
 |

01-28-2010, 11:41 AM
|
 |
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
This is really top notch work. I added both plugins to PEQ's repo and will play around with it in overthere I think 
|

01-28-2010, 06:01 PM
|
 |
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
Thanks CD, I thought you might like it  I am pretty impressed with how well it works, myself.
I was thinking again about putting something like this into the source, and I think it might be fairly easy. Instead of adding more stuff to NPC settings, I think it makes more sense to just add a command that will automatically create a roambox around an NPC spawn point based on Max X and Y variances from the spawn point. So, you would just target the NPC you want to add a roambox for and type something like "#autoroambox 100 100", and that would set it to update the database for that spawn group to use a roam box with a 100 variance for X and Y.
Unless anyone objects, I can probably just add LoS and Z checks into the roam box code. I don't see any reason not to add it. I haven't really looked into the roam box code much yet, so it might already do it as far as I know, but I doubt it.
|
 |
|
 |

01-28-2010, 06:19 PM
|
Hill Giant
|
|
Join Date: Nov 2007
Posts: 198
|
|
Thank you Trevius!
|
Thread Tools |
|
Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 05:50 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |