//::///////////////////////////////////////////////
//:: DEFAULT OOZE SCRIPT
//:: On UserDefined Script
//:: Originally By: El Magnifico Uno
//:: Modified By: Sir Otus
//:://////////////////////////////////////////////
//::
//:://////////////////////////////////////////////
//:: Originally Created On: January 5, 2003
//:: Based on excellent scripts by Lord Emil & September
//:://////////////////////////////////////////////

int IsMetalItem(object oItem);
void RustAttack(object oPC,object oItem);

void main()
{
  int nUser = GetUserDefinedEventNumber();
  int nInstant = DURATION_TYPE_INSTANT;
  object oSelf = OBJECT_SELF;
  effect eAcidExp = EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_NATURE);

// *************************************************************
// HEARTBEAT -
// *************************************************************
  if(nUser == 1001)
  {
    ActionRandomWalk();
  }

// *************************************************************
// PERCEIVE -
// *************************************************************
  else if(nUser == 1002)
  {
  }

// *************************************************************
// END OF COMBAT -
// *************************************************************
  else if(nUser == 1003)
  {
    int nItemSlot;
    int nHoldsMetal = FALSE;
    object oPC = GetAttackTarget();
    if(oPC == OBJECT_INVALID) oPC = GetAttemptedAttackTarget();

    if(GetDistanceToObject(oPC) < 2.5)
    {
      for(nItemSlot=0;nItemSlot<13;nItemSlot++)
      {
        object oItem = GetItemInSlot(nItemSlot,oPC);
        if(IsMetalItem(oItem))
        {
          RustAttack(oPC,oItem);
          nHoldsMetal = TRUE;
          break;
        }
      }
      if(!nHoldsMetal)
      {
        object oItem = GetFirstItemInInventory(oPC);
        while(oItem != OBJECT_INVALID)
        {
          if(IsMetalItem(oItem))
          {
            RustAttack(oPC,oItem);
            break;
          }
          oItem = GetNextItemInInventory(oPC);
        }
      }
    }
  }


// *************************************************************
// ON CONVERSATION
// *************************************************************
  else if(nUser == 1004)
  {
  }


// *************************************************************
// ON ATTACKED
// *************************************************************
  else if(nUser == 1005)
  {
  }


// *************************************************************
// ON DAMAGED -
// *************************************************************
  else if((nUser == 1006) || (nUser == 1007))
  {
    object oPC = GetLastDamager();
    object oRghtWpn = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
    object oLeftWpn = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
    object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
    object oWeapon;
    int nDmg;
    int nAcidDam;
    effect eAcidDam;

    if(GetDamageDealtByType(DAMAGE_TYPE_SLASHING) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_SLASHING);
    if(GetDamageDealtByType(DAMAGE_TYPE_BLUDGEONING) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_BLUDGEONING);
    if(GetDamageDealtByType(DAMAGE_TYPE_PIERCING) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_PIERCING);
    if(GetDamageDealtByType(DAMAGE_TYPE_ACID) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_ACID);
    if(GetDamageDealtByType(DAMAGE_TYPE_COLD) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_COLD);
    if(GetDamageDealtByType(DAMAGE_TYPE_DIVINE) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_DIVINE);
    if(GetDamageDealtByType(DAMAGE_TYPE_ELECTRICAL) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_ELECTRICAL);
    if(GetDamageDealtByType(DAMAGE_TYPE_FIRE) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_FIRE);
    if(GetDamageDealtByType(DAMAGE_TYPE_MAGICAL) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_MAGICAL);
    if(GetDamageDealtByType(DAMAGE_TYPE_NEGATIVE) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_NEGATIVE);
    if(GetDamageDealtByType(DAMAGE_TYPE_POSITIVE) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_POSITIVE);
    if(GetDamageDealtByType(DAMAGE_TYPE_SONIC) > 0)
      nDmg = nDmg + GetDamageDealtByType(DAMAGE_TYPE_SONIC);

      oWeapon = OBJECT_INVALID;
      if (oArmor != OBJECT_INVALID) oWeapon = oArmor;
      if (oLeftWpn != OBJECT_INVALID) oWeapon = oLeftWpn;
      if (oRghtWpn != OBJECT_INVALID) oWeapon = oRghtWpn;
      string sWeapon = GetName(oWeapon);

      //Determine AC Bonus, Enhance Bonus, and To Hit Bonus
      int iBonus = 0;
      int iAC = 0;
      int iEnhance = 0;
      int iToHit = 0;
      //Resistance as a Function of AC Value
      if (GetItemACValue(oWeapon) > 3) iAC = 1;
      if (GetItemACValue(oWeapon) > 5) iAC = 2;
      if (GetItemACValue(oWeapon) > 7) iAC = 3;
      // Sums across all known ITEM_PROPERTY_ constants
      int iProp = 0;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ABILITY_BONUS) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS) == TRUE)
       {
       iProp+=1;
       iBonus=3;
       }
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_DAMAGE_TYPE) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_SPECIFIC_ALIGNMENT) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS) == TRUE)
       {
       iProp+=1;
       iToHit=3;
       }
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS_VS_SPECIFIC_ALIGNMENT) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_BASE_ITEM_WEIGHT_REDUCTION) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_BONUS_FEAT) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_BONUS_SPELL_SLOT_OF_LEVEL_N) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_CAST_SPELL) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS_VS_SPECIFIC_ALIGNMENT) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_RESISTANCE) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_VULNERABILITY) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DARKVISION) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS) == TRUE)
       {
       iProp+=1;
       iEnhance=3;
       }
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_SPECIFIC_ALIGNEMENT) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_EXTRA_MELEE_DAMAGE_TYPE) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_EXTRA_RANGED_DAMAGE_TYPE) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_FREEDOM_OF_MOVEMENT) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_HASTE) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_HOLY_AVENGER) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_DAMAGE_TYPE) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_MISCELLANEOUS) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_SPECIFIC_SPELL) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_SPELL_SCHOOL) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_SPELLS_BY_LEVEL) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMPROVED_EVASION) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_KEEN) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_LIGHT) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_MASSIVE_CRITICALS) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_MIGHTY) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_MIND_BLANK) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ON_HIT_PROPERTIES) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ONHITCASTSPELL) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_POISON) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_REGENERATION) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_REGENERATION_VAMPIRIC) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SAVING_THROW_BONUS) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SAVING_THROW_BONUS_SPECIFIC) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SKILL_BONUS) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SPELL_RESISTANCE) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_TRUE_SEEING) == TRUE) iProp+=1;
      if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_UNLIMITED_AMMUNITION) == TRUE) iProp+=1;

    //Apply Splash Damage if Damager is in H2H Combat
    if ((GetDistanceToObject(oPC) < 4.5)&&(IsMetalItem(oWeapon)))
    {
    // Determine Saving Throw for oWeapon
    if (ReflexSave(oPC,15-iProp-iBonus-iAC-iEnhance-iToHit))
        {
        FloatingTextStringOnCreature("Your "+sWeapon+" is undamaged by the ooze's acidic secretions!", oPC);
        }
    else
      {
        FloatingTextStringOnCreature("The ooze's acidic secretions have splashed onto your "+sWeapon+"...", oPC);
        FloatingTextStringOnCreature(" ", oPC);
        FloatingTextStringOnCreature("...eating through the "+sWeapon+", rendering it useless!", oPC);
        DestroyObject(oWeapon);
        ApplyEffectToObject(nInstant,eAcidExp,oPC);
      }
    }
  }

// *************************************************************
// ON DEATH -
// *************************************************************
  else if(nUser == 1007)
  {
  }


// *************************************************************
// ON DISTURBED
// *************************************************************
  else if(nUser == 1008)
  {
  }

}


// *************************************************************
// IS METAL ITEM
// *************************************************************
int IsMetalItem(object oItem)
{
  switch (GetBaseItemType(oItem))
  {
    case BASE_ITEM_ARMOR: if(GetItemACValue(oItem) > 0) return TRUE;
      else return FALSE;
      break;
    case BASE_ITEM_HELMET: return TRUE; break;
    case BASE_ITEM_LARGESHIELD: return TRUE; break;
    case BASE_ITEM_SMALLSHIELD: return TRUE; break;
    case BASE_ITEM_TOWERSHIELD: return TRUE; break;

    case BASE_ITEM_AMULET: return TRUE; break;
    case BASE_ITEM_BELT: return TRUE; break;
    case BASE_ITEM_BOOK: return TRUE; break;
    case BASE_ITEM_BOOTS: return TRUE; break;
    case BASE_ITEM_BRACER: return TRUE; break;
    case BASE_ITEM_CLOAK: return TRUE; break;
    case BASE_ITEM_CRAFTMATERIALMED: return TRUE; break;
    case BASE_ITEM_CRAFTMATERIALSML: return TRUE; break;
    case BASE_ITEM_ENCHANTED_POTION: return TRUE; break;
    case BASE_ITEM_ENCHANTED_SCROLL: return TRUE; break;
    case BASE_ITEM_ENCHANTED_WAND: return TRUE; break;
    case BASE_ITEM_GLOVES: return TRUE; break;
    case BASE_ITEM_HEALERSKIT: return TRUE; break;
    case BASE_ITEM_LARGEBOX: return TRUE; break;
    case BASE_ITEM_MAGICROD: return TRUE; break;
    case BASE_ITEM_MAGICSTAFF: return TRUE; break;
    case BASE_ITEM_MAGICWAND: return TRUE; break;
    case BASE_ITEM_POTIONS: return TRUE; break;
    case BASE_ITEM_RING: return TRUE; break;
    case BASE_ITEM_SCROLL: return TRUE; break;
    case BASE_ITEM_SPELLSCROLL: return TRUE; break;
    case BASE_ITEM_THIEVESTOOLS: return TRUE; break;
    case BASE_ITEM_TORCH: return TRUE; break;
    case BASE_ITEM_TRAPKIT: return TRUE; break;

    case BASE_ITEM_ARROW: return TRUE; break;
    case BASE_ITEM_BASTARDSWORD: return TRUE; break;
    case BASE_ITEM_BATTLEAXE: return TRUE; break;
    case BASE_ITEM_BOLT: return TRUE; break;
    case BASE_ITEM_BULLET: return TRUE; break;
    case BASE_ITEM_CBLUDGWEAPON: return TRUE; break;
    case BASE_ITEM_CLUB: return TRUE; break;
    case BASE_ITEM_CPIERCWEAPON: return TRUE; break;
    case BASE_ITEM_CSLASHWEAPON: return TRUE; break;
    case BASE_ITEM_CSLSHPRCWEAP: return TRUE; break;
    case BASE_ITEM_DAGGER: return TRUE; break;
    case BASE_ITEM_DART: return TRUE; break;
    case BASE_ITEM_DIREMACE: return TRUE; break;
    case BASE_ITEM_DOUBLEAXE: return TRUE; break;
    case BASE_ITEM_DWARVENWARAXE: return TRUE; break;
    case BASE_ITEM_GREATAXE: return TRUE; break;
    case BASE_ITEM_GREATSWORD: return TRUE; break;
    case BASE_ITEM_GRENADE: return TRUE; break;
    case BASE_ITEM_HALBERD: return TRUE; break;
    case BASE_ITEM_HANDAXE: return TRUE; break;
    case BASE_ITEM_HEAVYCROSSBOW: return TRUE; break;
    case BASE_ITEM_HEAVYFLAIL: return TRUE; break;
    case BASE_ITEM_KAMA: return TRUE; break;
    case BASE_ITEM_KATANA: return TRUE; break;
    case BASE_ITEM_KUKRI: return TRUE; break;
    case BASE_ITEM_LIGHTCROSSBOW: return TRUE; break;
    case BASE_ITEM_LIGHTFLAIL: return TRUE; break;
    case BASE_ITEM_LIGHTHAMMER: return TRUE; break;
    case BASE_ITEM_LIGHTMACE: return TRUE; break;
    case BASE_ITEM_LONGBOW: return TRUE; break;
    case BASE_ITEM_LONGSWORD: return TRUE; break;
    case BASE_ITEM_MORNINGSTAR: return TRUE; break;
    case BASE_ITEM_QUARTERSTAFF: return TRUE; break;
    case BASE_ITEM_RAPIER: return TRUE; break;
    case BASE_ITEM_SCIMITAR: return TRUE; break;
    case BASE_ITEM_SCYTHE: return TRUE; break;
    case BASE_ITEM_SHORTBOW: return TRUE; break;
    case BASE_ITEM_SHORTSPEAR: return TRUE; break;
    case BASE_ITEM_SHORTSWORD: return TRUE; break;
    case BASE_ITEM_SHURIKEN: return TRUE; break;
    case BASE_ITEM_SICKLE: return TRUE; break;
    case BASE_ITEM_SLING: return TRUE; break;
    case BASE_ITEM_THROWINGAXE: return TRUE; break;
    case BASE_ITEM_TWOBLADEDSWORD: return TRUE; break;
    case BASE_ITEM_WARHAMMER: return TRUE; break;
    case BASE_ITEM_WHIP: return TRUE; break;
  }
  return FALSE;
}

// *************************************************************
// RUST ATTACK
// *************************************************************
void RustAttack(object oPC,object oItem)
{
  int nInstant = DURATION_TYPE_INSTANT;
  effect eAcidExp = EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_NATURE);
  object oRghtWpn = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
  object oLeftWpn = GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
  object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
  object oWeapon = OBJECT_INVALID;

  if (oArmor != OBJECT_INVALID) oWeapon = oArmor;
  if (oRghtWpn != OBJECT_INVALID) oWeapon = oRghtWpn;
  if (oLeftWpn != OBJECT_INVALID) oWeapon = oLeftWpn;

  string sWeapon = GetName(oWeapon);

  //Determine AC Bonus, Enhance Bonus, and To Hit Bonus
  int iBonus = 0;
  int iAC = 0;
  int iEnhance = 0;
  int iToHit = 0;
  //Resistance as a Function of AC Value
  if (GetItemACValue(oWeapon) > 3) iAC = 1;
  if (GetItemACValue(oWeapon) > 5) iAC = 2;
  if (GetItemACValue(oWeapon) > 7) iAC = 3;
  // Sums across all known ITEM_PROPERTY_ constants
  int iProp = 0;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ABILITY_BONUS) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS) == TRUE)
   {
   iProp+=1;
   iBonus=3;
   }
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_DAMAGE_TYPE) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_AC_BONUS_VS_SPECIFIC_ALIGNMENT) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS) == TRUE)
   {
   iProp+=1;
   iToHit=3;
   }
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ATTACK_BONUS_VS_SPECIFIC_ALIGNMENT) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_BASE_ITEM_WEIGHT_REDUCTION) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_BONUS_FEAT) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_BONUS_SPELL_SLOT_OF_LEVEL_N) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_CAST_SPELL) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_BONUS_VS_SPECIFIC_ALIGNMENT) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_RESISTANCE) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DAMAGE_VULNERABILITY) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_DARKVISION) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS) == TRUE)
   {
   iProp+=1;
   iEnhance=3;
   }
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_ALIGNMENT_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_RACIAL_GROUP) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ENHANCEMENT_BONUS_VS_SPECIFIC_ALIGNEMENT) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_EXTRA_MELEE_DAMAGE_TYPE) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_EXTRA_RANGED_DAMAGE_TYPE) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_FREEDOM_OF_MOVEMENT) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_HASTE) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_HOLY_AVENGER) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_DAMAGE_TYPE) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_MISCELLANEOUS) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_SPECIFIC_SPELL) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_SPELL_SCHOOL) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMMUNITY_SPELLS_BY_LEVEL) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_IMPROVED_EVASION) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_KEEN) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_LIGHT) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_MASSIVE_CRITICALS) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_MIGHTY) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_MIND_BLANK) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ON_HIT_PROPERTIES) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_ONHITCASTSPELL) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_POISON) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_REGENERATION) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_REGENERATION_VAMPIRIC) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SAVING_THROW_BONUS) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SAVING_THROW_BONUS_SPECIFIC) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SKILL_BONUS) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_SPELL_RESISTANCE) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_TRUE_SEEING) == TRUE) iProp+=1;
  if (GetItemHasItemProperty(oWeapon, ITEM_PROPERTY_UNLIMITED_AMMUNITION) == TRUE) iProp+=1;

  if(TouchAttackMelee(oPC)&&(IsMetalItem(oWeapon)))
  {
    FloatingTextStringOnCreature("The slime has splashed upon your "+sWeapon+"... ", oPC);
    FloatingTextStringOnCreature(" ", oPC);
    if (ReflexSave(oPC,15-iProp-iBonus-iAC-iEnhance-iToHit))
    FloatingTextStringOnCreature("...but your "+sWeapon+" resists the corrosive effects.", oPC);
      else
      {
      FloatingTextStringOnCreature("...and the slime's acidic secretions destroy your "+sWeapon+"!", oPC);
      DestroyObject(oWeapon);
      ApplyEffectAtLocation(nInstant,eAcidExp,GetLocation(oPC));
      }
  }
}
