Page 1 of 1

Mage Armor

Posted: Wed Sep 05, 2018 11:07 pm
by Fionn
Took a look at nw_s0_magearm. Turns out we do allow armor, we just don't allow armor better than AC4 and we have a 20 second loop checking to see if you swapped armor (and an initial check to see if it was >4). I'd need to test with the rest timer disabled, but it seems you can cast naked and have about 3 rounds in Full Plate +4 if you time it right.

Looks like there's also a pre-existing BW exploit that it removes any prior casting before you apply the effects

Code: Select all

RemoveEffectsFromSpell(oTarget, SPELL_MAGE_ARMOR);
Though I imagine if you nerf your friendly Wiz20's buffs you may find yourself all newtly.

Oddly, this code looks backwards to me. I can't imagine we ran with it for years and never noted Scale got X4 the bonus of Padded, but it sure looks like ACValue 4 (default) applies a nACBonus of 4, while ACValue 1 (Padded) only grants a +1.

Code: Select all

    switch (GetItemACValue(oChestItem))
    {
        case 3: nACBonus = 1; // ARMOR_AC_PADDED is equipped
            break;
        case 2: nACBonus = 2; // ARMOR_AC_LEATHER is equipped
            break;
        case 1: nACBonus = 3; // ARMOR_AC_STUDDED_LEATHER or ARMOR_AC_HIDE is equipped
            break;
        default: nACBonus = 4; // ARMOR_AC_CHAIN_SHIRT or ARMOR_AC_SCALE is equipped
            break;
            
        eAC = EffectACIncrease(nACBonus, AC_ARMOUR_ENCHANTMENT_BONUS);
    }

Re: Mage Armor

Posted: Sat Sep 08, 2018 12:34 am
by Gaia_Nostra
In HAKs ahp_4.01 and ahp_4.02 the codelines are identical and the Switch-Case statement reads as follows:

Code: Select all

int GetACBonus(object oChestItem)
{
    int nACBonus;

    // examine and assign the AC bonus that the spell grants depending on the
    // PC's currently equipped chest item's AC
    switch (GetItemACValue(oChestItem))
    {
        case 3: nACBonus = 1; // ARMOR_AC_STUDDED_LEATHER is equipped, so only give +1
            break;
        case 2: nACBonus = 2; // ARMOR_AC_LEATHER is equipped, so only give +2
            break;
        case 1: nACBonus = 3; // ARMOR_AC_PADDED is equipped, so give +3
            break;
        default: nACBonus = 4; // no armor is equipped, so give the full +4
            break;
    }
    return nACBonus;
}
This version is also wrong...just in another way. :wall:

Re: Mage Armor

Posted: Sat Sep 08, 2018 1:20 pm
by valn99
Does GetItemACValue return the base AC value or would it still add any enchantment bonus?
Seems overly complicated!! ;)

return the max of (0, 4-GetItemACValue) seems simpler... you get at best +4, and at worse +0?
Or however it would be coded in NWN Script

Oh if the default clause works the same as I know, that would mean any other value gets +4: no armor as well as a full plate!! ;)

Re: Mage Armor

Posted: Sat Sep 08, 2018 6:10 pm
by ayergo
Yeah, many broken spells. Gaia has been doing a review, I hope to do a big hak update sometime in the next year to correct and consolidate.

Re: Mage Armor

Posted: Sat Sep 22, 2018 12:23 pm
by Cleasor
I'm thinking of taking a level of wizard for possible arcane archer in the future. If I am wearing studded leather +1, does this mean Mage Armor will give no benefit? Take the spell Shield instead?

Re: Mage Armor

Posted: Sun Sep 23, 2018 1:03 am
by Fionn
Cleasor wrote:I'm thinking of taking a level of wizard for possible arcane archer in the future. If I am wearing studded leather +1, does this mean Mage Armor will give no benefit? Take the spell Shield instead?
As I read it, you *may* get +1 until you get the +1 armor. After that, GetItemACValue will return 4, so the spell aborts.

Re: Mage Armor

Posted: Sun Sep 23, 2018 6:17 am
by Senor T
Pretty sure mage armor gives a +1 bonus to some of the variable types of armor, which do not stack. So if you have a +1 to armor, then you won’t get the armor bonus.

Shield should just give you +4. It’s useful even with bonus items, but had a relatively short duration compared to mage armor.

Re: Mage Armor

Posted: Thu Nov 15, 2018 7:28 pm
by Gaia_Nostra
BTW...

I just double checked this codeline and realized that the Default case statement only gets executed if the AC is less than or equal to 4. So the code is fine, but the comment // ARMOR_AC_CHAIN_SHIRT or ARMOR_AC_SCALE is equipped is misleading/wrong.

Code: Select all

    int ARMOR_AC_CHAIN_SHIRT = 4;       // includes ARMOR_AC_SCALE >> this is being used
    
    ...

    if (GetItemACValue(oChestItem) >= ARMOR_AC_CHAIN_SHIRT) // <=====  When AC is 4 or greater...do not adjust AC
    {
        SendMessageToPC(oCaster, GetName(oTarget) + " will not benefit from this spell.");
        return;
    }
    else 
    {
        nACBonus = GetACBonus(oChestItem);
    }
    
 ...
 
 int GetACBonus(object oChestItem)
{
    int nACBonus;

    // examine and assign the AC bonus that the spell grants depending on the
    // PC's currently equipped chest item's AC
    switch (GetItemACValue(oChestItem))
    {
        case 3: nACBonus = 1; // ARMOR_AC_PADDED is equipped
            break;
        case 2: nACBonus = 2; // ARMOR_AC_LEATHER is equipped
            break;
        case 1: nACBonus = 3; // ARMOR_AC_STUDDED_LEATHER or ARMOR_AC_HIDE is equipped
            break;
        default: nACBonus = 4; // ARMOR_AC_CHAIN_SHIRT or ARMOR_AC_SCALE is equipped
            break;
    }
    return nACBonus;
}