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.
NWScript:
void main()
{
int nEvent=(GetUserDefinedEventNumber());
if (nEvent=1001)
{
object oBodybag=GetFirstObjectInShape(SHAPE_SPHERE,15.0,GetLocation(OBJECT_SELF), TRUE,OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_ITEM);
if (!GetIsInCombat()){
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!");
SetLocalInt(oBodybag,"gettinloot",1);
ClearAllActions();
ActionTakeItem(GetFirstItemInInventory(oBodybag), 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));
}
};
}
else if (GetObjectType(oBodybag)==OBJECT_TYPE_ITEM)
{
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));
}
};
}
}
}
}
|