// Thief-boost item
// Purpose of script - to boost thieves damage and attack temporarily
// -Seeker-, 30 / 6 2005 for Alangara
// -Seeker-,  6 / 3 2010 for Alangara - added to hit bonus

void main()
{
   object oPC = GetItemActivator();
   float duration = HoursToSeconds(24); // Alter duration here

   if ( oPC != OBJECT_INVALID && GetIsPC( oPC ) )
   {
      // Check for rogue status
      int monk = GetLevelByClass(CLASS_TYPE_MONK, oPC );
      if ( monk > 0 )
      {
         // Get total of levels
         monk += GetLevelByClass(CLASS_TYPE_ASSASSIN, oPC );
         monk += GetLevelByClass(CLASS_TYPE_HARPER, oPC );
         monk += GetLevelByClass(CLASS_TYPE_SHADOWDANCER, oPC );
         monk += GetLevelByClass(CLASS_TYPE_ROGUE, oPC );

         int dmgBoost = 0;
         int attackBonus = 0;

         if ( monk < 41 )
         {
            dmgBoost = DAMAGE_BONUS_20;
            attackBonus = 20;
         }
         if ( monk < 31 )
         {
            dmgBoost = DAMAGE_BONUS_15;
            attackBonus = 15;
         }
         if ( monk < 21 )
         {
            dmgBoost = DAMAGE_BONUS_10;
            attackBonus = 10;
         }
         if ( monk < 11 )
         {
            dmgBoost = DAMAGE_BONUS_5;
            attackBonus = 5;
         }

         // Create effects
         effect eDmgBoost = EffectDamageIncrease( dmgBoost, DAMAGE_TYPE_MAGICAL );
         effect eAttackIncrease = EffectAttackIncrease (attackBonus);
         // Den version nedenunder goer at vaaben bonusser ikke taeller med.
         // men har fusket selv som du kan se ovenfor og det virker.....
         // hilsen tarashon, hehe

         // effect eAttackIncrease = EffectAttackIncrease ( attackBonus, ATTACK_BONUS_ONHAND );

         // Prohibit stacking
         effect eLoop=GetFirstEffect(oPC);

         while (GetIsEffectValid(eLoop))
         {
            if (GetEffectType(eLoop)==EFFECT_TYPE_DAMAGE_INCREASE && GetEffectDurationType( eLoop ) == DURATION_TYPE_TEMPORARY)
            {
               RemoveEffect(oPC, eLoop);
            }
            else if (GetEffectType(eLoop)== EFFECT_TYPE_ATTACK_INCREASE && GetEffectDurationType( eLoop ) == DURATION_TYPE_TEMPORARY)
            {
               RemoveEffect(oPC, eLoop);
            }

            eLoop=GetNextEffect(oPC);
         }

         // Apply effect to player
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDmgBoost, oPC, duration );
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAttackIncrease, oPC, duration );
      }
      else
      {
         // Can only be used by a rogue
         FloatingTextStringOnCreature( "This item can only be used by a monk", oPC, FALSE );
      }
   }
   else
   {
      // Do nothing
   }
}