Moderator: Event DM
-
Neve
- Prince of Bloated Discourse
- Posts: 192
- Joined: Mon Apr 14, 2003 4:09 pm
- Location: The Netherlands
-
Contact:
Post
by Neve » Wed Sep 03, 2003 11:59 am
This script is useful to prevent low level players from being killed by leftover creatures, spawned by higher lvl players. The script checks the area for players. If there are no players in the area, it will check for players again after 30 seconds. If there are no players at that time, the creatures and their inventory are destroyed. Commoners which are spawned using encounters will not be destroyed.
Code: Select all
/*
September 03, 2003 - Eric Ettes - Raiko - zeiren@hotmail.com
This script checks an area for encounterspawns and removes them
Place this script in the OnExit slot of an area
*/
void RemoveInventory(object oTrash){
object oInventory = GetFirstItemInInventory(oTrash);
while(oInventory != OBJECT_INVALID){
DestroyObject(oInventory);
oInventory = GetNextItemInInventory(oTrash);
}
}
void Despawn(object oArea){
object oTrash = GetFirstObjectInArea(oArea);
SetLocalInt(oArea, "DespawnPending", 0);
while(oTrash != OBJECT_INVALID){
if(GetIsEncounterCreature(oTrash) && !GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oTrash)){
RemoveInventory(oTrash);
DestroyObject(oTrash);
}
oTrash = GetNextObjectInArea(oArea);
}
}
void AttemptDespawning(object oArea){
object oTrash = GetFirstObjectInArea(oArea);
while(oTrash != OBJECT_INVALID){
if(GetIsPC(oTrash)){
DelayCommand(30.0, AttemptDespawning(oArea));
return;
}
oTrash = GetNextObjectInArea(oArea);
}
Despawn(oArea);
}
void main(){
object oArea = GetArea(OBJECT_SELF);
object oTrash = GetFirstObjectInArea(oArea);
while(oTrash != OBJECT_INVALID){
if(GetIsPC(oTrash)) return;
oTrash = GetNextObjectInArea(oArea);
}
oTrash = GetFirstObjectInArea(oArea);
if(!GetLocalInt(oArea, "DespawnPending")){
SetLocalInt(oArea, "DespawnPending", 1);
DelayCommand(30.0, AttemptDespawning(oArea));
}
}
Last edited by
Neve on Wed Sep 03, 2003 12:40 pm, edited 5 times in total.
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
-
Sindol
- Team Member; Retired with Honors
- Posts: 6479
- Joined: Mon Jan 06, 2003 4:23 pm
- Location: Nijmegen - Netherlands (GMT+1)
-
Contact:
Post
by Sindol » Wed Sep 03, 2003 12:10 pm
Hey, that sounds familiar. Judging by your description it must be a lot like the script that Papillon wrote for Avlis.
So much fun,
yet so little time to enjoy it.
- Sindol
-
Dirk Cutlass
- Elder Sage
- Posts: 4691
- Joined: Mon Jan 27, 2003 9:42 am
- Location: GMT
Post
by Dirk Cutlass » Wed Sep 03, 2003 12:18 pm
Shouldn't be using the faction rather than the racial type for GetIsCommoner()? You might have some nasty Dwarven Mercs there - that return true for the GetIsCommoner() test.
Not that I know anything about scripting.

-
Neve
- Prince of Bloated Discourse
- Posts: 192
- Joined: Mon Apr 14, 2003 4:09 pm
- Location: The Netherlands
-
Contact:
Post
by Neve » Wed Sep 03, 2003 12:28 pm
@Sindol : I didn't know Avlis had a script for despawning... I recall putting a script here for Remains removal which got a similiar remark

Then again... I haven't been able to login to Avlis because I haven't acquired SoU yet
@Dirk
Whoops, Good point there Dirk, I fixed it. Thanks =P
It now also runs the script once at a time per area no matter how many times someone walks in and out of it, rather than just starting the script an extra time.
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
-
Sindol
- Team Member; Retired with Honors
- Posts: 6479
- Joined: Mon Jan 06, 2003 4:23 pm
- Location: Nijmegen - Netherlands (GMT+1)
-
Contact:
Post
by Sindol » Wed Sep 03, 2003 12:53 pm
Neve wrote:@Sindol : I didn't know Avlis had a script for despawning... I recall putting a script here for Remains removal which got a similiar remark

Then again... I haven't been able to login to Avlis because I haven't acquired SoU yet
Avlis has a script for despawning. It's been running succesfully for some time now after some minor tweaks in the beginning. Maybe you and Papillon should compare notes as he already did some debugging on his scripts for the same goal.
BTW: It still scares the shit out of me when all commoners on the streest of Elysia suddenly die. Apparently the script doesn't recognize DMs present.
So much fun,
yet so little time to enjoy it.
- Sindol
-
Neve
- Prince of Bloated Discourse
- Posts: 192
- Joined: Mon Apr 14, 2003 4:09 pm
- Location: The Netherlands
-
Contact:
Post
by Neve » Wed Sep 03, 2003 1:00 pm
Hmm, my script doesn't use EffectKill(), which indeed just drops them dead on the floor (And possible inventoryitems will be dropped as loot), the DestroyObject function fades the creatures away

- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
-
Silk
- Co-Founder
- Posts: 6662
- Joined: Fri Sep 14, 2001 6:47 pm
-
Contact:
Post
by Silk » Wed Sep 03, 2003 1:10 pm
hehe, actually I wrote the NPC Despawn Script. Pap enhanced it.
It basically works like this:
When the last player leaves an area, a despawn script fires. If nobody enters the area after a delay, it will despawn all npcs in that area.
The next person that enters will trigger the respawn script.
Rinse, Repeat.
Silk
Member of the MadK@t lover's group.
-
Neve
- Prince of Bloated Discourse
- Posts: 192
- Joined: Mon Apr 14, 2003 4:09 pm
- Location: The Netherlands
-
Contact:
Post
by Neve » Wed Sep 03, 2003 1:18 pm
Yup, that's basically how mine works aswell, mine despawns all hostile NPC's after a delay if there are no players in that area at that time, otherwise it retries after a while etc.
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.