Plugin::RandomRoam()
For anyone interested, I created a new plugin to play with on my server that I thought others might like to try out. It requires that you are running server code of revision 1175 or later to have access to the new quest objects I recently added.
Here are the steps to add this plugin to your server: 1. Open notepad, or whatever text editor you prefer. 2. Copy and paste the following code into Notepad: Code:
#NOTE: These functions require the globals.pl file for use of the val() plugin 4. Do a #questreload and the new plugin should be ready for use :D What this plugin does is to pick a random location around the NPC's Spawn Point, and if it has LoS to that spot, it will path there. This works similar to the roambox stuff, but it doesn't require that you get actual locs around the NPC(s) that you want to use it. It also does LoS checks, so it knows if it can move there or not. This means that it should work for random roaming just about anywhere. It would be ideal in open outdoor areas, but should technically work indoors as well. Here is an example script of an NPC using the RandomRoam() plugin: Code:
sub EVENT_SPAWN { |
Saw you talking on IRC about this, looks good to me. It's highly CPU efficient too, from what you were telling me. Nice.
|
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!) :) |
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); |
This is really top notch work. I added both plugins to PEQ's repo and will play around with it in overthere I think :)
|
Thanks CD, I thought you might like it :D 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. |
Thank you Trevius!
|
This is phenominal, I'm already using this for a very unique but closer to the beginning part of the project which was kind of a similar situation, except for I dont have to create waypoints. Awesome, thank you once again Trevius.
|
No problem. Glad you guys are liking it :)
After looking into the plugins Shendare created and shared a while back, I see that passing $npc into the plugin is no longer required if you have the globals.pl file by Shendare already. So, for people who already have that file, you can use this version of the roam plugins: Code:
#NOTE: These functions require the globals.pl file for use of the val() plugin The usage on these is simply: Code:
plugin::RandomRoam(100, 100); Code:
plugin::StraightPath(100, 100); |
I added another pathing plugin named RandomSwim.
Usage - plugin::RandomSwim(MaxXVariance, MaxYVariance, WaterSurfaceZ); It works just like the RandomRoam plugin, but won't let the NPC go to any point higher than the water surface Z you put into the plugin command. It will swim to a random X, Y and Z in water. This makes them swim a bit choppy if there isn't a water map for the zone, but if there is, I think they should swim pretty nicely. Here is the current whole path_tools.pl file that I use: Code:
#NOTE: These functions require the globals.pl file for use of the val() plugin |
Trev mucho <3 !
|
I was wondering this is such a monumental idea, would it be possible to have a group of mobs randomly roaming?
Perhaps one mob does the random roam and the other "follow" or something. My thinking is: Pack of Wolves Hunting. Small detachment of soldiers on random partol. Group of Marauding Bandits |
Yeah, it is completely possible, if you know the formation you want them in. Here is a snippet of a script I made that does just that and has 4 NPCs that follow surrounding the boss mob this script is on:
Code:
#Random Roamer Group Script |
I'm getting this error in the zone log when I use this plugin.
Script error: qst67030::EVENT_TIMER - Perl runtime error: Can't locate object method "GetSpawnPointX" via package "NPC" at plugins/randomroam.pl line 16. Using the latest axclassic repack. Any ideas? Perl version? I'm running 5.1.0. (I think) Thanks |
It requires that you are running server code of revision 1175 or later to have access to the new quest objects.
|
All times are GMT -4. The time now is 06:01 AM. |
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.