Author Topic: No Arcane Spell Failure for Bards in Light Armor  (Read 1024 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #15 on: May 21, 2011, 08:01:01 pm »


               yes im doing it temporary, if player relog OnEquip runs again so no worry and the decay is set on 999999.9 so it always stay until restart

skins have more issue - ILR/ELC destroy skin at enter, equipping/unequipping, polymorph, horse system... I got my own skin system covered but if I do something, Im trying to avoid skin solution if possible due to reasons I provided.
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #16 on: May 21, 2011, 08:56:48 pm »


               Well, after going through this again today when I was actually awake I figured out I wasn't passing valid parameters to the IPSafeAddItemProperty which is why that function wasn't working. But going off Shadow's logic/example, I tested that the temp Arcane Spell Failure reduction item property applied to the armor doesn't increase its price at the stores and that a PC can logout with that temp property on the armor and get back in again with ILR turned on the server (which were my main concerns anyway).

So after realizing I really did waste my Friday night on this thing, I put together this much simplified and cleaner version a littel bit ago that doesn't rely on .2da edits or toolset blueprints. Just plugin these scripts to your module OnEquip and OnUnequip and bards in your module will not suffer arcane spell failure while wearing light armor.


//mod_onequip_bard
#include "x2_inc_itemprop"

int GetItemACBase( object oItem)
{
  if( !GetIsObjectValid( oItem) || (GetBaseItemType( oItem) != BASE_ITEM_ARMOR)) return -1;
  int nTorso = GetItemAppearance( oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
  string sACBase = Get2DAString( "des_crft_appear", "BaseAC", nTorso);
  return StringToInt( sACBase);
}

void main()
{
  object oPC = GetPCItemLastEquippedBy();
  object oItem = GetPCItemLastEquipped();

  if (GetLevelByclass(class_TYPE_BARD, oPC) && GetBaseItemType(oItem) == BASE_ITEM_ARMOR) { //Is this a bard equipping armor?
    int iACVal = GetItemACBase(oItem);
    if (iACVal > 0 && iACVal < 5) { //Only apply the Arcane Spellcasting Reduction if they equipped light armor
      itemproperty ipAdd;
      switch (iACVal) {
        case 1: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_5_PERCENT);break;
        case 2: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_10_PERCENT);break;
        case 3: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_20_PERCENT);break;
        case 4: ipAdd = ItemPropertyArcaneSpellFailure(IP_CONST_ARCANE_SPELL_FAILURE_MINUS_20_PERCENT);break;
        default:return;
      }
      IPSafeAddItemProperty(oItem, ipAdd, 999999.9, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);

      DelayCommand(0.5, SendMessageToPC(oPC, "As a Bard you suffer no increase to Arcane Spell Failure wearing this light armor."));
    }
  }
}


//mod_onunequ_bard
#include "x2_inc_itemprop"

int GetItemACBase( object oItem)
{
  if( !GetIsObjectValid( oItem) || (GetBaseItemType( oItem) != BASE_ITEM_ARMOR)) return -1;
  int nTorso = GetItemAppearance( oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
  string sACBase = Get2DAString( "des_crft_appear", "BaseAC", nTorso);
  return StringToInt( sACBase);
}

void main()
{
  object oPC = GetPCItemLastUnequippedBy();
  object oItem = GetPCItemLastUnequipped();

  if (GetLevelByclass(class_TYPE_BARD, oPC) && GetBaseItemType(oItem) == BASE_ITEM_ARMOR) {
    int iACVal = GetItemACBase(oItem);
    if (iACVal > 0 && iACVal < 5)
      IPRemoveMatchingItemProperties(oItem, ITEM_PROPERTY_ARCANE_SPELL_FAILURE, DURATION_TYPE_TEMPORARY);
  }
}

               
               

               


                     Modifié par Thayan, 21 mai 2011 - 08:04 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #17 on: May 22, 2011, 01:23:21 am »


               well done '<img'>
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #18 on: May 22, 2011, 02:56:46 am »


               Ahh you do not need to make it temp. do you? if you put a int on the skin or armor and have a check for that int. to not run again you do not have to worry about log out and log ins. Unless you destroy the skin all the time? Remove the int on unequiping. Just a thought
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #19 on: May 22, 2011, 06:11:38 pm »


               You can do it but only with no-cost ítemproperties, because you can sell equipped items, a plot/stolen workaround is much more ugly than temp
               
               

               
            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #20 on: May 23, 2011, 07:59:52 pm »


               You could do something different to get the armor's base AC.
You could use IPGetWeaponEnhancementBonus to get the AC bonus on the armor (if any) and subtract it from the  total AC value of the armor:

#include "x2_inc_itemprop"

int GetItemACBase(object oItem)
{
    if(!GetIsObjectValid(oItem) || (GetBaseItemType(oItem) != BASE_ITEM_ARMOR))
        return -1; 
    int ac = GetItemACValue(oArmor) - IPGetWeaponEnhancementBonus(oArmor, ITEM_PROPERTY_AC_BONUS);
    return ac;
}

               
               

               


                     Modifié par Khuzadrepa, 23 mai 2011 - 07:50 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #21 on: May 23, 2011, 08:51:36 pm »


               or SetIdentified to FALSE and then check for cost of the item, this is the way I use - faster than both other ways but it doesnt matter now when 1.69 with 2da caching is out and with good server the difference in all three methods is insignificant
               
               

               
            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #22 on: May 23, 2011, 09:33:57 pm »


               

ShaDoOoW wrote...
or SetIdentified to FALSE and then check for cost of the item, this is the way I use

I think that way is also clever, but the one I posted is less code to write, which appeals to me. '<img'>

You're most likely right, though, it's probably a negligible difference as far as resources/speed.
               
               

               


                     Modifié par Khuzadrepa, 23 mai 2011 - 10:22 .
                     
                  


            

Legacy_Artistmonk

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #23 on: May 24, 2011, 03:52:20 am »


               What do you add for it to continue to whatever default or additional scripts you have or has that benn included in code?