UW2_PRC8/_module/nss/removeonhitslay.nss
Jaysyn904 5197ad9a4d Initial upload
Initial upload
2023-09-25 20:24:01 -04:00

54 lines
1.9 KiB
Plaintext

//Created by Guile 4/10/07
//Put this on enter to remove slay from all items in the inventory
//This will not remove it from items in hand.
void MakeItemSafe(object oItem)
{
if (GetLocalInt(oItem, "ITEM_ACCEPTABLE")) return;
itemproperty ipProperty = GetFirstItemProperty(oItem);
while (GetIsItemPropertyValid(ipProperty))
{
if (GetItemPropertyDurationType(ipProperty) == DURATION_TYPE_PERMANENT)
{
int nItemPropertyType = GetItemPropertyType(ipProperty);
switch (nItemPropertyType)
{
case ITEM_PROPERTY_ON_HIT_PROPERTIES:
{
int nSubtype = GetItemPropertySubType(ipProperty);
if ((nSubtype>=21) && (nSubtype<=23))
{
RemoveItemProperty(oItem, ipProperty);
WriteTimestampedLogEntry("Removing OnHit " + GetName(oItem));
}
break;
}
// default, just let it ride
}
}
ipProperty = GetNextItemProperty(oItem);
}
SetLocalInt(oItem, "ITEM_ACCEPTABLE", TRUE);
}
//This is an example how to USE the above function.
//Safest to add the above bit to Module OnAcquire event however, as it will perma-<span class="highlight">remove</span> it, from ANYTHING the PC's get.
//Note: this removes slay by alignment, alignment group, and racial group.
//if you handed out onhit vorpal swords, your <span class="highlight">on</span> your own.
void main()
{
object oPC= GetEnteringObject();
object oItem = GetFirstItemInInventory(oPC);
while(GetIsObjectValid(oItem))
{
MakeItemSafe(oItem);
oItem = GetNextItemInInventory(oPC);
}
int nItem;
for( nItem = 0; nItem < 14; nItem++ )
{
oItem = GetItemInSlot( nItem, oPC );
MakeItemSafe( oItem );
}
}