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

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« on: May 18, 2011, 10:15:07 pm »


               A request I've received multiple times is to figure out a way to allow bards to cast spells without a chance of arcane failure while they are wearing Light Armor (as per 3.5 rules). I feel this is appropriate, however I have yet to figure out a successful hak-free way to do this.

I haven't sepnt much time trying, but I've tried applying a reduction to arcane spellcasting to a creature skin and equipping that on a PC, however that doesn't seem to work (not sure why though...?).

Has anyone managed to figure this out or have any scripting ideas to make this possible?
               
               

               
            

Legacy_Ralthis

  • Jr. Member
  • **
  • Posts: 90
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #1 on: May 19, 2011, 06:30:06 pm »


               I'm not sure if this would work, but you could try spellhooking. The spellhook script would run every time a spell was cast, and all you would have to do is check if the PC is a bard and wearing light armour. Then, add a reduced arcane spell failure property to the armour and later remove it in the same script using RemoveItemProperty() (keep in mind that this function only fires AFTER the script has finished). Because of the late firing of RemoveItemProperty(), the script could be sneaky enough to apply the reduce arcane spell failure to their armour until the spell has been cast, after which the spellhook script runs its course and the property is removed. I have no idea if this would work as advertised (there might be some aspects of spellhooking I'm forgetting about), but it might be a good place to start working from.
               
               

               


                     Modifié par Ralthis, 19 mai 2011 - 05:30 .
                     
                  


            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #2 on: May 19, 2011, 11:45:25 pm »


               Could you do this with by adding the Arcane Spell Failure property (of the appropriate amount) to light armors equipped by bards in the module's
OnPlayerEquipItem
/
OnPlayerUnequipItem
scripts? The script could check the character for bard levels and check the item to see that it's light armor. Then, set a local on the armor for the current level of the Arcane Spell Failure property, so that armor that normally has reduced arcane failure doesn't lose it when a bard unequips it. (You might also want to change the level-up script to check if a non-bard character adds a bard level while already wearing light armor...) The property could even be added as temporary to make it clear that it's not normally part fo the armor.

I guess this doesn't work as well if you don't want the player to be able to see that the armor has been modified. And, I don't know if there is a good way to keep bards from cheating merchants out of extra gold by directly selling equipped armor...
               
               

               


                     Modifié par MrZork, 19 mai 2011 - 10:47 .
                     
                  


            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #3 on: May 20, 2011, 01:40:11 pm »


               

MrZork wrote...

Could you do this with by adding the Arcane Spell Failure property (of the appropriate amount) to light armors equipped by bards in the module's

OnPlayerEquipItem
/
OnPlayerUnequipItem
scripts? The script could check the character for bard levels and check the item to see that it's light armor. Then, set a local on the armor for the current level of the Arcane Spell Failure property, so that armor that normally has reduced arcane failure doesn't lose it when a bard unequips it. (You might also want to change the level-up script to check if a non-bard character adds a bard level while already wearing light armor...) The property could even be added as temporary to make it clear that it's not normally part fo the armor.

I guess this doesn't work as well if you don't want the player to be able to see that the armor has been modified. And, I don't know if there is a good way to keep bards from cheating merchants out of extra gold by directly selling equipped armor...


I was thinking along similar lines and would just have the armors set to PLOT (toggled when equipped/unequipped) as well to prevent merchant abuses.
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #4 on: May 20, 2011, 02:40:47 pm »


               Thanks for the replies guys. Rathis, I'll try doing some testing on your idea to see if the spellhook actually gets fired prior to the Arcan Spell Failure checks.

MrZork and kalbern, I had thought of that too - but (other than the potential selling exploit issue) we have Item Level Restrictions turned on. So if someone equips that armor and gets the Arcane Spell Failure added to it it could put it over their level. So then if they logout they wouldn't be able to log back in. I should have mentioned we had ILR to begin with since that does unfortunately futher limit scripted options too.
               
               

               


                     Modifié par Thayan, 20 mai 2011 - 01:46 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #5 on: May 20, 2011, 09:53:16 pm »


               Another way to still use the item properties is to add the properties to the player skin. And if you have CEP(ValueDecrease) or don't mind altering a 2da or 2(AddtionalProperty) you can decrease the value of the skin so that it can bypass your modules ILR even with the property added. Since this would not put the item property directly on the armor then you shoudln't have any problems with selling exploits.

If either of the above are possible you could alter your modules OnPlayerEquip/Unequip to do something kinda like so:

OnPlayerEquip:

void main()
{
    object oPC = GetPCItemLastEquippedBy();
    int iclass = GetLevelByclass(class_TYPE_BARD, oPC);
    if (iclass < 1)return;
    object oArmor = GetPCItemLastEquipped();
    int iType = GetBaseItemType(oArmor);
    if (iType != BASE_ITEM_ARMOR) return;
    int iACVal = GetItemACValue(oArmor);
    itemproperty ipAdd;

    switch (iACVal)
    {
        case 1: ipAdd = ItemPropertyArcaneSpellFailure(-5);break;
        case 2: ipAdd = ItemPropertyArcaneSpellFailure(-10);break;
        case 3: ipAdd = ItemPropertyArcaneSpellFailure(-20);break;
        case 4: ipAdd = ItemPropertyArcaneSpellFailure(-20);break;
        default:return;
    }

    object oSkin = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
    IPSafeAddItemProperty(oSkin, ipAdd, 0.0, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);
}


OnPlayerUnequip:


#include "x2_inc_itemprop"
void main()
{
    object oPC = GetPCItemLastUnequippedBy();
    int iclass = GetLevelByclass(class_TYPE_BARD, oPC);
    if (iclass < 1)return;
    object oArmor = GetPCItemLastUnequipped();
    int iType = GetBaseItemType(oArmor);
    if (iType != BASE_ITEM_ARMOR) return;
    int iACVal = GetItemACValue(oArmor);
    object oSkin = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);

    if (iACVal > 0 && iACVal < 5)
    IPRemoveMatchingItemProperties(oSkin, ITEM_PROPERTY_ARCANE_SPELL_FAILURE, DURATION_TYPE_PERMANENT);
}

Hope it helps and good luck.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #6 on: May 21, 2011, 01:27:39 am »


               You cannot use GetItemACValue because it does return base ac. It will return higher numbers with Armor with magic AC bonuses. Here a link to some functions that might help.

Link nwn.bioware.com/forums/viewtopic.html

Link nwvault.ign.com/View.php
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #7 on: May 21, 2011, 01:53:26 am »


               I appreciate the ideas. Ghost of God - those are excellent scripts. Unfortunately though, I cannot apply an Arcane Spell Failure reduction to a player/creature skin. I suppose this is because even if you try to assign that property in the toolset the normal way, the creature skin does not have the ability to add Arcane Spell Failure reduction to it that way even.

I tested out the possibility of using the module spellhook and the spellhook fires *after* the arcane spell failure check, so it can't be worked around that way either. Murphy's Law is in effect on this one. I'm not sure what else to try unless anyone knows of a way to trick the system (editting .2da's maybe?) to allow Arcane Spell Failure to be applied to creature skins.
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #8 on: May 21, 2011, 02:17:16 am »


               Open ItemProps.2da -- row 84 -- column 13_Hide -- substitute the **** with a 1
This will allow the ArcaneSpellFailure itemproperty to be put on Creature Hide items.

You must restart the Toolset for the change to take place.

-fox
               
               

               


                     Modifié par the.gray.fox, 21 mai 2011 - 01:20 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #9 on: May 21, 2011, 02:21:58 am »


               

Thayan wrote...

 
MrZork and kalbern, I had thought of that too - but (other than the potential selling exploit issue) we have Item Level Restrictions turned on. So if someone equips that armor and gets the Arcane Spell Failure added to it it could put it over their level. So then if they logout they wouldn't be able to log back in. I should have mentioned we had ILR to begin with since that does unfortunately futher limit scripted options too.


So why not check the Armor OnClientLeave and remove the proptrie if they have it.   You would also need to modify any scripts yoou have that export the character to also remove it, just incase of a server crash.
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #10 on: May 21, 2011, 03:22:12 am »


               Lightfoot, I'm not sure, but I don't think you can manipulate the properties on someone's armor as/once they are logging out.

Regardless though, I've been able to make considerable progress on the creature skin idea now that gray fox gave me the hint i needed to tell me what I was doing wrong (restart the Toolset dammit. RESTART!) '<img'>

I need to do a little more testing, but I'm pretty sure with only the server-side modification to the ItemProps.2da I have a working system for this. I will post it after I've tested a bit more and made sure it actually works from client machines that don't have the modification.
               
               

               
            

Legacy_Evelath

  • Full Member
  • ***
  • Posts: 108
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #11 on: May 21, 2011, 03:29:42 am »


               I would love to see the solution for this '<img'>
               
               

               
            

Legacy_Thayan

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


               Well, as much as I'd love to provide detailed commentary on this it is now 2:00 in the morning for me. I can't believe I spent an entire Friday night on this. Anyway though, please take a look at the comments in the mod_onequip_bard script for most of my details. If someone(s) would be willing to try this out and let me know if it works outside my warped mind I would appreciate it. I tested this in a server setup so I can confirm this works with only the server-side changes the details talk about too.

Assuming this works OK for others it might be something I'll toss up on the Vault since it requires making item blueprints and editting that ItemProps.2da.
EDIT: And especially considering it now since the code posted here is one huge mess that I don't feel like cleaning up at the moment since these corums can't handle it nicely.

EDIT: What a disaster. Posting code here simply sucks. No other way to describe it without risking a ban. tried some cleanup but I'm calling it quits for tonight. Hopefully it still works for anyone that attempts to try it.

//mod_onequip_bard
/*
D&D 3.5 Rule - No Arcane Spell Failure for Bards in Light Armor
---------------------------------------------------------------
The purpose of this package is to ensure that when a Bard equips light armor they do not suffer arcane spell failure
as per D&D 3.5 rules. This package will work with Item Level Restrictions turned on, and does not require a hak.

Scripts
-----------------
Place the mod_onequip_bardscript in your module's OnEquip event and place the mod_onunequ_bard script in the
module's OnUnequip event, or merge them both with your existing scripts in those events.

.2da Modification
-----------------
In addition to those scripts, you must edit the ItemProps.2da -- row 84 -- column 13_Hide and substitute the **** with
a 1. Make sure you add three spaces after the 1 so the padding in the .2da remains the same. Then, put the ItemProps.2da
in the override folder on the server. You will need to restart your toolset. Once you do, this change will allow you
to add the Arcane Spell Reduction item property to creature skins which is required in the next section.

Item Blueprints
-----------------
After editing the ItemProps.2da, you must create three custom creature skin blueprints in your module. Give the
first Arcane Spell Reduction -5%, the second Arcane Spell Reduction -10%, and the third Arcane Spell Reduction -20%.
These blueprints are necessary because the IPSafeAddItemProperty() function will not add the Arcane Spell Reduction
item property unless it is copire from another item that has it added from the toolset itself. If anyone figures out
a way to get the IPSafeAddItemProperty() function to work without these blueprints though, please let me know!

Thanks to the guys on the forums who helped provide input, scripts snippets, and the ideas to make this possible:
Ralthis, MrZork, kalbaern, GhostOfGod, ShadowM, Axe Murderer (we miss you buddy!) and the.gray.fox
*/

#include "x2_inc_itemprop"

//::///////////////////////////////////////////////////
// int GetItemACBase( object oItem)
//::///////////////////////////////////////////////////
// Parameters
//  - oItem:        armor to be evaluated
//
// Returns the base AC of oItem or -1 on error
//  * Returns:      base AC of armor (0 - 8)
//  * OnError:      -1 if oItem is invalid or not armor
//::///////////////////////////////////////////////////
int GetItemACBase( object oItem);
int GetItemACBase( object oItem)
{ // if oItem is not armor then return an error
  if( !GetIsObjectValid( oItem) || (GetBaseItemType( oItem) != BASE_ITEM_ARMOR)) return -1;
  // Get the torso model number
  int nTorso = GetItemAppearance( oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
  // Read 2DA for base AC
  // Can also use "parts_chest" which returns it as a "float"
  string sACBase = Get2DAString( "des_crft_appear", "BaseAC", nTorso);
  // return base AC
  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
      string sArcaneSkinResRef = "arcaneskin_20"; //-20% Arcane Spellcasting Reduction for AC 3 and AC 4 armor
      if (iACVal == 2) sArcaneSkinResRef = "arcaneskin_10"; //-10% Arcane Spellcasting Reduction for AC 2 armor
      if (iACVal == 1) sArcaneSkinResRef = "arcaneskin_5"; //-5% Arcane Spellcasting Reduction for AC 1 armor
      object oEquippedSkin = GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC);
      if (oEquippedSkin != OBJECT_INVALID) { //If they already have a creature skin equipped, copy the properties from a dummy arcane skin
        object oArcaneFailureReductionSkin = CreateObject(OBJECT_TYPE_ITEM, sArcaneSkinResRef, GetLocation(oPC));
        itemproperty ipProp = GetFirstItemProperty(oArcaneFailureReductionSkin); //Make sure Arcane Spellcasting Reduction is the ONLY property on the skin
        IPSafeAddItemProperty(oEquippedSkin, ipProp, 0.0, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);
        DestroyObject(oArcaneFailureReductionSkin);
      }
      else { //If they don't have a creatue skin equipped, just create the appropriate arcane skin and equip it on them
        object oArcaneFailureReductionSkin = CreateItemOnObject(sArcaneSkinResRef, oPC);
        SetIdentified(oArcaneFailureReductionSkin, TRUE);
        AssignCommand(oPC, ActionEquipItem(oArcaneFailureReductionSkin,INVENTORY_SLOT_CARMOUR));
      }
      DelayCommand(0.5, SendMessageToPC(oPC, "As a Bard you suffer no increase to Arcane Spell Failure wearing this light armor."));
    }
  }
}



//mod_onunequ_bard
/*
D&D 3.5 Rule - No Arcane Spell Failure for Bards in Light Armor
---------------------------------------------------------------
Place this script in the modules OnUnequip event, or merge it with your existing script. The purpose of this script
is to ensure that when a Bard unequips light armor they the arcane spell failure applied to their creature skin removed.
*/

#include "x2_inc_itemprop"

//::///////////////////////////////////////////////////
// int GetItemACBase( object oItem)
//::///////////////////////////////////////////////////
// Parameters
//  - oItem:        armor to be evaluated
//
// Returns the base AC of oItem or -1 on error
//  * Returns:      base AC of armor (0 - 8)
//  * OnError:      -1 if oItem is invalid or not armor
//::///////////////////////////////////////////////////
int GetItemACBase( object oItem);
int GetItemACBase( object oItem)
{ // if oItem is not armor then return an error
  if( !GetIsObjectValid( oItem) || (GetBaseItemType( oItem) != BASE_ITEM_ARMOR)) return -1;
  // Get the torso model number
  int nTorso = GetItemAppearance( oItem, ITEM_APPR_TYPE_ARMOR_MODEL, ITEM_APPR_ARMOR_MODEL_TORSO);
  // Read 2DA for base AC
  // Can also use "parts_chest" which returns it as a "float"
  string sACBase = Get2DAString( "des_crft_appear", "BaseAC", nTorso);
  // return base AC
  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(GetItemInSlot(INVENTORY_SLOT_CARMOUR, oPC), ITEM_PROPERTY_ARCANE_SPELL_FAILURE, DURATION_TYPE_PERMANENT);
  }
}

Looking forward to any reviews (assuming there are still people left playing NWN and checking these forums after the Rapture takes most of you). 'Posted
               
               

               


                     Modifié par Thayan, 21 mai 2011 - 07:25 .
                     
                  


            

Legacy_Shadooow

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


               I got it implemented in my working module. Im applying the lowered failure on the armor however. Why to mess with skin if you dont have to, right?

My code is a bit messy as I have also few additional thing in code like a check for a new feat Battle Caster which improves this bards ability to medium armor as well as some VFXs when equipped etc. So if you want to see then tell me I can send either here or via PM.
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
No Arcane Spell Failure for Bards in Light Armor
« Reply #14 on: May 21, 2011, 05:49:40 pm »


               

ShaDoOoW wrote...

I got it implemented in my working module. Im applying the lowered failure on the armor however. Why to mess with skin if you dont have to, right?


Granted that often there is more of a way to skin a cat, I like more the idea of the itemproperty on the skin/hide.
Doing so Thayan does not touch the very armor, which upon examination will not state extra properties that are not supposed to be seen by anybody.

Even if the above was unimportant, in any case to have an extra property on the very armor would lead to more trouble, hence more work to address it:

If the property is permanent, it will increase the GP value of the armor (think shopping), which is undesired.

If the property is temporary, instead, at some point you are going to reapply it -- meaning that you have to write some time-based code just to handle that.

-fox