| Author |
Sticky: Post
Working Scripts Here |
| Morz
|
Posted: Tuesday, 02 July 04:05PM |
This is a script to allow your Mobs to
pick up items in body bags near by them left after another creature
dies. So, it's essentially a Janitor script (since an empty body bag
destroys itself), with the benefits that you don't need a separate
janitor object and it makes a little more thematic sense that mobs would
loot bodies themselves.
The mob does a victory animation when they loot something, and will
equip items they get which are better then what they already have.
One quirk is that mobs can only hold a certain amount of items in
inventory, so after they fill up, while they will keep picking items,
those items will 'go away'. Useful to clear up the trash, but sometimes
they'd lose something they'd want more than the stuff they're filled up
with. Also note that mobs near the PCs which aren't in combat might very
well snatch something for themselves that the PC is trying to get, the
same way a groupmemeber might when they're both looting the same thing.
This is written as a user defined event set to OnHeartbeat.
NWScript: void main()
{
object oBodybag;
int nEvent=(GetUserDefinedEventNumber());
if (nEvent=1001)
{
if (GetDistanceToObject(GetNearestObjectByTag("Body Bag", OBJECT_SELF,1)) > 0.0 && GetDistanceToObject(GetNearestObjectByTag("Body Bag", OBJECT_SELF,1)) < 10.0)
{
oBodybag = GetNearestObjectByTag("Body Bag", OBJECT_SELF,1);
ActionTakeItem(GetFirstItemInInventory(oBodybag), oBodybag);
ActionTakeItem(GetNextItemInInventory(oBodybag), oBodybag);
DelayCommand(2.0,ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1));
ActionEquipMostDamagingRanged();
ActionEquipMostEffectiveArmor();
}
}
}
|
|