| Author | Sticky: Post Working Scripts Here |
| Yeldrig Yar | Posted: Friday, 05 July 06:36PM |
| NAME: ZoneSweeper WHAT: Clears an area of monsters when players leave the area. It only does this if there are no players IN the area when the script is called. NOTES: My world is approaching HUGE size, so in order to preserve computing power, I have most of my dungeons spawn in the monsters only when a player enters. And usually then only just before the player is to encounter the monsters. However, I noticed that occassionally players would enter an area, unknowingly trip triggers that would spawn in mobs ahead of them, then leave. Leaving my monsters sitting there, unoccupied, and eating up processor time. This script goes on the Area's onExit event. It fires whenever a player leaves the area. The first thing it does is to search the Area and look for players. If it finds a player still in the zone, the script does nothing. If it finds no players in the zone, it sweeps through and Destroys any Creatures that are still alive. However, it seems that the *AREA* itself can't do the work, so I drop an invisible object named "ZoneSweeper<NameOfZone>" near the entrance and make it do the work for me (it's oSlave in the script). The reason I use the name of the zone is because when I added this code to my 2nd zone, neither it nor the 1st one cleared out the dungeons! But by giving each dungeon a unique "ZoneSweeper" it works well again. Last note is: If you have monsters that are "plot" or you don't want to kill, give them a unique tag and test for that tag when your sweeping. When it hits the creature with that tag, it'll skip over it.
|
|