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 -
// * 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 -
// * 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).
Modifié par Thayan, 21 mai 2011 - 07:25 .