From 1ab40ace962d4aa6c346dee829e8a29324d76232 Mon Sep 17 00:00:00 2001 From: Jaysyn904 <68194417+Jaysyn904@users.noreply.github.com> Date: Sun, 26 May 2024 21:42:12 -0400 Subject: [PATCH] Fixed Superior Defense Fixed Superior Defense --- nwn/nwnprc/trunk/scripts/prc_coc.nss | 50 +++++++++++++++++++++++- nwn/nwnprc/trunk/scripts/prc_mithral.nss | 2 +- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/nwn/nwnprc/trunk/scripts/prc_coc.nss b/nwn/nwnprc/trunk/scripts/prc_coc.nss index bd930c8d..c59b5ef5 100644 --- a/nwn/nwnprc/trunk/scripts/prc_coc.nss +++ b/nwn/nwnprc/trunk/scripts/prc_coc.nss @@ -41,6 +41,51 @@ void CritSTR(object oPC, int iEquip) } void SuperiorDefense(object oPC, int nLevel) +{ + object oSkin = GetPCSkin(oPC); + + object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC); + if (oArmor == OBJECT_INVALID) + { + SetLocalInt(oSkin, "SuperiorDefenseDexBonus", 0); + return; + } + + // Determine the base AC value of the armor + int nAC = GetBaseAC(oArmor); + + // Check if the armor is medium or heavy based on its AC value + if (nAC < 4) // Medium armor starts @ 4 AC + { + SetLocalInt(oSkin, "SuperiorDefenseDexBonus", 0); + return; + } + + else + { + // Retrieve the base item type row + int nRow = GetBaseItemType(oArmor); + + // Get the maximum Dexterity bonus from armor.2da + string sBaseDexBonus = Get2DACache("armor", "DEXBONUS", nRow); + int nBaseDexBonus = StringToInt(sBaseDexBonus); + + // Calculate the new Dexterity bonus + int nBonus = 1 + ((nLevel - 3) / 3); + + if(StringToInt(GetStringLeft(GetTag(oArmor), 3)) & 16) + { //mithral armour :P + nBonus += 2; + } + + int nNewDexBonus = nBaseDexBonus + nBonus; + + // Store the new Dex bonus on the character's skin + SetLocalInt(oSkin, "SuperiorDefenseDexBonus", nNewDexBonus); + } +} + +/* void SuperiorDefense(object oPC, int nLevel) { object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC); object oSkin = GetPCSkin(oPC); @@ -52,7 +97,10 @@ void SuperiorDefense(object oPC, int nLevel) else nRed = nPen; if (nRed > 0) SetCompositeBonus(oSkin, "SuperiorDefense", nRed, ITEM_PROPERTY_AC_BONUS); -} + + else + (SetCompositeBonus(oSkin, "SuperiorDefense", 0, ITEM_PROPERTY_AC_BONUS)); +} */ void main() { diff --git a/nwn/nwnprc/trunk/scripts/prc_mithral.nss b/nwn/nwnprc/trunk/scripts/prc_mithral.nss index 4b1d161a..fe29ef51 100644 --- a/nwn/nwnprc/trunk/scripts/prc_mithral.nss +++ b/nwn/nwnprc/trunk/scripts/prc_mithral.nss @@ -75,7 +75,7 @@ void main() nBonus = min(nDexBonus - nMaxDexBonus, nCapIncrease); } } - SetCompositeBonus(GetPCSkin(oPC), "PRC_CRAFT_MITHRAL", nBonus, ITEM_PROPERTY_AC_BONUS); + //SetCompositeBonus(GetPCSkin(oPC), "PRC_CRAFT_MITHRAL", nBonus, ITEM_PROPERTY_AC_BONUS); //:: all of this is already in prc_coc.nss BaneCheck(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC)); BaneCheck(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC));