Author Sticky: Post Working Scripts Here
Ithalyan Posted: Saturday, 29 June 04:44AM
Items & Corpse Cleanup in an Area
==================================
Place this on the OnHeartBeat (loathe as I was to use it) event of any Placeable that will never get destroyed (set it to plot), Invisible object is a good one to place it on. Add that Invisible object to your pallete so you can easily use this over and over again.

This will destroy any object that is left on the ground for around 5 minutes. The problem with past 'Janitor' scripts and cleanup scripts is that they treated Loot drops as ITEMS. They are not, they are Placeables with Inventory. In order to have destroyed them, you need to empty them out, which is what this script does. The key was, that all corpse treasure left behind by creatures is labled with the tag 'body bag'.

Without further delay, here ya go

NWScript:
//=============================================

//=============================================

//Automatic Item Decay

//Written by Gary Blauvelt, Ithalyan of

//  Grim's Tavern

//=============================================

//=============================================

void main()

{

//Cleans finds objects that are flagged for decay and counts down the timer

//that should have been placed on them.

    int nDecay;

    object oArea = GetArea(OBJECT_SELF);

    object oItem = GetFirstObjectInArea(oArea);



    while(GetIsObjectValid(oItem))

    {

        if(GetObjectType(oItem)==OBJECT_TYPE_ITEM || (GetObjectType(oItem)==64 && GetTag(oItem) == "Body Bag"))

        {

            if(GetLocalInt(oItem,"DecayFlag")==0)

            {

                //Set Plot Flag Decay here

                //AssignCommand(oItem,ActionSpeakString("Decay Flag Set"));

                SetLocalInt(oItem,"DecayFlag",1);        //Set the flags that aren't set

                SetLocalInt(oItem,"DecayTime",50);

            }

            else        //Count Down

            {

                nDecay = GetLocalInt(oItem,"DecayTime");

                nDecay--;

                if(nDecay < 1)  //DestroyObject the item

                {

                    if (GetObjectType(oItem)==64)

                    {

                        object oInven = GetFirstItemInInventory(oItem);

                        while(GetIsObjectValid(oInven))

                        {

                            DestroyObject(oInven,0.0);

                            oInven = GetNextItemInInventory(oItem);

                        }

                    }

                    else

                    {

                        DestroyObject(oItem,0.0);

                    }

                }

                else

                {

                    //AssignCommand(oItem,ActionSpeakString("Decay Going"));

                    SetLocalInt(oItem,"DecayTime",nDecay);

                }

            }

        }

        oItem = GetNextObjectInArea(oArea);

    }

}



Have a good day. =)

_________________
Ithalyan Grim
[DM Grim] of Grim's Tavern Tales 24/7 PW (when it isn't crashing or Doc isn't blowing out our power to keep cool) =)