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.
|
So Trev, does this plugin work on any zone with mobs that already have designated paths? What about NPCs that are supposed to be static?
|
Thanks Trevius, I'm only running v1048 so will have to update.
Thanks again |
Quote:
If you just try it out using the example I posted, it should be pretty easy to see what is going on and how to use it. |
Here is my latest modifications to these path tools. The main change is that RandomRoam now allows for an optional Z variance setting as well as an optional LoS mob size setting.
Code:
#NOTE: These functions require the globals.pl file for use of the val() plugin |
I added a new plugin to the original post. It is CalcDestFromHeading and basically lets you calculate a destination X and Y based on a heading and distance. It is really nice for projectiles and also handy if you want to surround something with a circle of spawns or whatever.
Here is the description, but for the actual code, see the first post in this thread: #Usage: my @DestArray = plugin::CalcDestFromHeading(Heading, Distance, [Mob, MaxZDiff]); # This plugin calculates the destination X and Y loc based on heading and distance # Heading is the heading you want to calculate destination X Y Z from # Distance is the distance you want for the destination X and Y from the source # Mob is an optional field to allow any mob to be set, but $npc is default # MaxZDiff is the max height difference from the source mob's Z you want to calculate the destination from. # # The output array can be used as follows: # my $DestX = $DestArray[0]; # my $DestY = $DestArray[1]; # my $DestZ = $DestArray[2]; |
I copied the example quest given at the beginning of the thread directly, but I still cannot get the random roaming to work. I have the globals.pl and path_tools.pl in my plugins folder, and I've even tried renaming path_tools to randomroam and RandomRoam. I have my source code up to date and everything, so I'm really not sure why I cannot get this working. Anyone have any thoughts?
|
Nevermind, I found the problem
|
Anyone with a up to date server able to get this plugin to work?
|
We use it on PEQ in crescent reach cause Cavedude was too lazy to go make grids and it appears to still work.
|
Quote:
Roam box is terrible in zones where the Z varies and I hate making grids but guess thats the only thing left to do. /cry Anyways thanks for letting me know its working as is on PEQ. Helps reaffirm that I noobed something up and should just try again until it works. |
Ive had problems with this plugin myself. Mainly when I create a new quest folder for a zone that doesn't already have a folder created. I can zone into Crescent Reach and see the script working correctly on the bears, snakes, spiders etc from the original PEQ quests directly from the SVN. However when I copy the exact same script and move it into a newly created folder for say Elddar Forest, the plugin does not work even though it is working in Crescent Reach.
Other scripts work correctly in the newly created elddar folder, even other plugins, but not the randomroam for some strange reason. Even scripts from the global_player and global_npc work in the zone, just not this particular plugin, yet the plugin does work in other default zone folders that come with the SVN. Hopefully this narrows down the problem. |
Thanks for that feedback Mariomario, it may be the cause of my issue.
I am using zones that are not used yet on peq so I have to create their quest folder. Everything else I am doing is working except this plugin. It's frustrating because I want to be lazy and not create nice pathing via grids. |
Keep in mind that for this plugin to work, you need to have LoS working in the zone! I suspect this is the issue you guys are having with this plugin. This means that you need a map file for the zone, and many of the newer expansion zones don't have map files yet. You can create your own map files using Azone2 for every map up to current, I believe.
You can easily test if LoS is working in your zone by trying to cast a spell on a nearby NPC, or by using the "#los" command if you have access to that command (GMs do). If #los shows you do not have Line of Sight to an NPC you are standing right next to, then you are almost certainly missing the map file for that zone and will need to create one yourself. The zone won't be functional for playing in until you get a map file anyway, as you won't be able to cast detrimental spells in there on targets other than yourself. Also KoS mobs will not have LoS to be able to aggro on anyone as they should. |
As Trevius stated, if you don't have map files for that zone, the plugin will not work correctly because it uses LoS checks based on the map files.
If you want to create your own, azone.exe can be downloaded on the links in the menu to the left of the forums. You would generate a map file by command line and running it against one of your EverQuest client zone files and it will spit out a .map file. Here is an example I just ran: Code:
E:\Software\HoT EQEmu>Azone2.exe elddar |
Oh man I had forgot about the LOS but I swear to god I already made the .map files for all these zones I am using. Oh well better just remake, but Trevius and Akkadius thanks for chiming in and clearing that up.
Server "10" -- wolf "-1" |
Hmm.. tried to do this.. and any time i ran Azone.exe with any zone that OBJ files it would always crash...
I moved out the OBJ file and then it would create the map file correctly |
Nate - I just pulled source and compiled azone and had no issues at all.
|
All times are GMT -4. The time now is 12:36 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.