1) LootUp

2) heartbeat script which allows any creature to perform janitor duties.

The creature also equips any weapon or armor it finds better than it's own, and converts excess inventory into gold.

It looks expensive, but I ran it with about 40 orcs at the same time all looting about, and didn't seem to get any lag over rendering.
As it stands, it makes for pretty realistic, loot hungry humanoids, but you can comment out the 'equip best item' functions to make it appropriate for carrion crawler/gelatinous cubes type scavengers.






//////////////////////////////////
//LootUp.nss
//By Morz/Ager Squinteye
//
//onHearbeat script which sets a creature to pick up
//loose items and corpseloot
//Put in the UserDefined handler, uncomment
//the hearbeat event flag in the creature's onSpawn script
//also uncoment the 'set ambient animations' flag in
//the same script if it's a placed monster, and not an encounter spawn
//////////////////////////////////

void main()
{
int nEvent=(GetUserDefinedEventNumber());
if (nEvent=1001)
{
//looks at all placeable objects (which body bags are)
//and items within 15 meters of the guy, limited by line
//of sight. Edit both instances of '15.0' to adjust the radius
object oBodybag=GetFirstObjectInShape(SHAPE_SPHERE,15.0,GetLocation(OBJECT_SELF), TRUE,OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_ITEM);
if (!GetIsInCombat()){ //turns it off if so it doesn't interrupt combat
//cycles through the available things in the area until it finds a loot target, or nothing.
while ((GetIsObjectValid(oBodybag) && !(GetTag(oBodybag)=="Body Bag") && !(GetObjectType(oBodybag)==OBJECT_TYPE_ITEM))||GetLocalInt(oBodybag,"gettinloot")==1)
{
oBodybag=GetNextObjectInShape(SHAPE_SPHERE,15.0,GetLocation(OBJECT_SELF), TRUE,OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_ITEM);
};
if (GetTag(oBodybag)=="Body Bag")
{
SpeakString("I see Loot!"); //this is just a debugging thing, comment it out if you don't like the text
SetLocalInt(oBodybag,"gettinloot",1); //this temporarily 'claims' it, stopping multiple looters from getting jammed up on the same item.
ClearAllActions();//this cuts off the ambient animations any good looter should be running
ActionTakeItem(GetFirstItemInInventory(oBodybag), oBodybag);
ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1);
ActionEquipMostDamagingRanged();//comment out for non-humanoid scavengers
ActionEquipMostEffectiveArmor();//comment out for non-humanoid scavengers
DelayCommand(1.0,SetLocalInt(oBodybag,"gettinloot",0)); //makes it fair game again incase the looter failed. On the off chance you get looters dying before they can reset the status of the loot, modify the delay duration, even just a couple milliseconds of delay should work as the selection process happens independant of the action list
//all this next bit is designed to eliminate
//duplicate items and liquidate them into cash. Monsters
//can't drop more than one screen's worth of loot, so
//inventory beyond that is lost anyway. With this, it's
//keeps the most valuable couple items of a given type
//and 'sells' any other items of that type for 1/4 it's
//base value.
object oGot=GetFirstItemInInventory();
int iGotWhat=GetBaseItemType(oGot);
int iGotWorth=GetGoldPieceValue(oGot);
while (GetIsObjectValid(oGot)){
oGot=GetNextItemInInventory();
int iHaveWhat=GetBaseItemType(oGot);
int iHaveWorth=GetGoldPieceValue(oGot);
if (iGotWhat==iHaveWhat && iGotWorth >= iHaveWorth){
DestroyObject(oGot);
GiveGoldToCreature(OBJECT_SELF,(iHaveWorth/4));
}
};
}
else if (GetObjectType(oBodybag)==OBJECT_TYPE_ITEM) //same thing, but for items laying about loose. All comments above apply here too.
{
SpeakString("I see " + GetName(oBodybag));
SetLocalInt(oBodybag,"gettinloot",1);
ClearAllActions();
ActionPickUpItem(oBodybag);
ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1);
ActionEquipMostDamagingRanged();
ActionEquipMostEffectiveArmor();
DelayCommand(1.0,SetLocalInt(oBodybag,"gettinloot",0));
object oGot=GetFirstItemInInventory();
int iGotWhat=GetBaseItemType(oGot);
int iGotWorth=GetGoldPieceValue(oGot);
while (GetIsObjectValid(oGot)){
oGot=GetNextItemInInventory();
int iHaveWhat=GetBaseItemType(oGot);
int iHaveWorth=GetGoldPieceValue(oGot);
if (iGotWhat==iHaveWhat && iGotWorth >= iHaveWorth){
DestroyObject(oGot);
GiveGoldToCreature(OBJECT_SELF,(iHaveWorth/4));
}
};
}
}
}
}