Here's a script function we use on the
Eternal Destiny PW Server in the OnDamaged Event of most creatures to facilitate the retrieval of ammo/throwing weapons from the corpses of the creatures you happen to strike. It places a single resref of the item in the creatures inventory and can be retrieved once the creature is killed. No hak or realistic(unrealistic) adjustments to ammo amounts required. All retrievable ammo is logged and there is an included random chance your ammo or throwing weapon either broke on impact(not retrievable) or sunk to deep into the flesh of your opponent to be able to be retrieved.
Things I like about this:
- Only Damaging Hits allow retrieving
- Not all damaging hits are retrievable
- Log-Review Day allows you to see who is getting back what
- Unlimited Ammo Properties Ignore this script
- Easily customized to suit your needs.
void CreateAmmo(object oDamager)
{
object oAmmo;
object oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oDamager);
string sItem = GetName(oItem);
string sDamager = GetName(oDamager);
string sSelf = GetName(OBJECT_SELF);
if (GetWeaponRanged(oItem))
{
if(GetItemHasItemProperty(oItem, ITEM_PROPERTY_UNLIMITED_AMMUNITION)) return;
if(d4(1) <2) // Adjust to allow more or less ammo to be retrieved
{
if (GetBaseItemType(oItem)==BASE_ITEM_LONGBOW || GetBaseItemType(oItem)==BASE_ITEM_SHORTBOW)
{
oAmmo=GetItemInSlot(INVENTORY_SLOT_ARROWS,oDamager);
string sAmmy = GetName(oAmmo);
if(GetBaseItemType(oAmmo) != BASE_ITEM_ARROW) return;
object oAmmy = CreateItemOnObject(GetResRef(oAmmo));
SetDroppableFlag(oAmmy ,TRUE);
SetIdentified(oAmmy, TRUE);
PrintString("************************");
PrintString(" AMMO RETRIEVAL ");
PrintString("PC Name: "+sDamager);
PrintString("Creature: "+sSelf);
PrintString("Weapon: "+sItem);
PrintString("Ammo: "+sAmmy);
PrintString("************************");
return;
}
if (GetBaseItemType(oItem)==BASE_ITEM_LIGHTCROSSBOW || GetBaseItemType(oItem)==BASE_ITEM_HEAVYCROSSBOW)
{
oAmmo=GetItemInSlot(INVENTORY_SLOT_BOLTS,oDamager);
if(GetBaseItemType(oAmmo) != BASE_ITEM_BOLT) return;
object oAmmy = CreateItemOnObject(GetResRef(oAmmo));
string sAmmy = GetName(oAmmo);
SetDroppableFlag(oAmmy ,TRUE);
SetIdentified(oAmmy, TRUE);
PrintString("************************");
PrintString(" AMMO RETRIEVAL ");
PrintString("PC Name: "+sDamager);
PrintString("Creature: "+sSelf);
PrintString("Weapon: "+sItem);
PrintString("Ammo: "+sAmmy);
PrintString("************************");
return;
}
if (GetBaseItemType(oItem)==BASE_ITEM_SLING)
{
oAmmo=GetItemInSlot(INVENTORY_SLOT_BULLETS,oDamager);
string sAmmy = GetName(oAmmo);
if(GetBaseItemType(oAmmo) != BASE_ITEM_BULLET) return;
object oAmmy = CreateItemOnObject(GetResRef(oAmmo));
SetDroppableFlag(oAmmy ,TRUE);
SetIdentified(oAmmy, TRUE);
PrintString("************************");
PrintString(" AMMO RETRIEVAL ");
PrintString("PC Name: "+sDamager);
PrintString("Creature: "+sSelf);
PrintString("Weapon: "+sItem);
PrintString("Ammo: "+sAmmy);
PrintString("************************");
return;
}
if (GetBaseItemType(oItem)== BASE_ITEM_THROWINGAXE || GetBaseItemType(oItem)==BASE_ITEM_SHURIKEN || GetBaseItemType(oItem)==BASE_ITEM_DART)
{
string sAmmy = GetName(oItem);
object oAmmy = CreateItemOnObject(GetResRef(oItem));
SetDroppableFlag(oAmmy ,TRUE);
SetIdentified(oAmmy, TRUE);
PrintString("************************");
PrintString(" AMMO RETRIEVAL ");
PrintString("PC Name: "+sDamager);
PrintString("Creature: "+sSelf);
PrintString("Weapon: "+sItem);
PrintString("Ammo: "+sAmmy);
PrintString("************************");
return;
}
}
}
}
Modifié par Sharona Curves, 22 novembre 2010 - 10:24 .