Aller au contenu

Photo

Stacking bonus


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

I have a custom passive feat that increases saving throws and armor class. Although the saving throws are not stacking the armor class bonus keeps stacking over and over again as game time passes (resetting back to defaults when resting.)  Here is a copy of the script that I am using:

 

void main()
{
   object oPC = GetLastPCRested();
   object oTarget = OBJECT_SELF;
   int iSWhisp = GetLevelByClass(64, OBJECT_SELF);
   int iSWarr = GetLevelByClass(67,OBJECT_SELF);
   int iCaster = iSWhisp+iSWarr;
   int iBonus = (iCaster/10)+1;
   
       if(iBonus >3 )
    {
        iBonus = 3;
    }
else
{
   iBonus = iBonus;
}
 
   effect eEff = EffectSavingThrowIncrease(SAVING_THROW_ALL, iBonus, SAVING_THROW_TYPE_ALL);
   effect eEff1 = EffectACIncrease(iBonus, AC_DODGE_BONUS, AC_VS_DAMAGE_TYPE_ALL, FALSE);
   effect eEffect1 = EffectLinkEffects(eEff, eEff1);
   eEffect1 = SupernaturalEffect(eEffect1);
   ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect1, oTarget, HoursToSeconds(72));
   SetEffectSpellId(eEffect1, 71640);
 
}
 
How do I keep the armor class bonus from stacking? Should I beusing a natural or defelction bonus?


#2
kevL

kevL
  • Members
  • 4 052 messages
// 'lol_bonus'

const int BONUS_ID = 71640;

void main()
{
    object oPC = GetLastPCRested();

    effect eEffect = GetFirstEffect(oPC);
    while (GetIsEffectValid(eEffect))
    {
        if (GetEffectSpellId(eEffect) == BONUS_ID)
        {
            RemoveEffect(oPC, eEffect);
            eEffect = GetFirstEffect(oPC);
        }
        else
            eEffect = GetNextEffect(oPC);
    }

    int iLevel1 = GetLevelByClass(64, oPC);
    int iLevel2 = GetLevelByClass(67, oPC);

    int iBonus = (iLevel1 + iLevel2) / 10 + 1;

    if (iBonus > 3)
        iBonus = 3;

    effect eBonus1 = EffectSavingThrowIncrease(SAVING_THROW_ALL, iBonus, SAVING_THROW_TYPE_ALL);
    effect eBonus2 = EffectACIncrease(iBonus, AC_DODGE_BONUS, AC_VS_DAMAGE_TYPE_ALL, FALSE);

    eEffect = EffectLinkEffects(eBonus1, eBonus2);
    eEffect = SupernaturalEffect(eEffect);

    SetEffectSpellId(eEffect, BONUS_ID);

    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oPC, HoursToSeconds(72));
}

// A good policy is to remove a/the effect before (re)applying it. hope it
// works, I took out oTarget on an assumption ... but the idea of the
// effect-loop near the top is what you're missing, i believe.

How do I keep the armor class bonus from stacking? Should I beusing a natural or defelction bonus?


The problem as i see it, is that while the engine won't allow save-stacking (caveat..) it does allow Dodge Bonus to stack. natural and deflection won't stack, but all-in-all, without removing any previous application first it's just compounding a problem under the hood.

#3
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

Thanks Kevl



#4
Laugh out loud

Laugh out loud
  • Members
  • 109 messages
// 'lol_bonus'

const int BONUS_ID = 71640;

void main()
{
    object oPC = GetLastPCRested();

    effect eEffect = GetFirstEffect(oPC);
    while (GetIsEffectValid(eEffect))
    {
        if (GetEffectSpellId(eEffect) == BONUS_ID)
        {
            RemoveEffect(oPC, eEffect);
            eEffect = GetFirstEffect(oPC);
        }
        else
            eEffect = GetNextEffect(oPC);
    }

    int iLevel1 = GetLevelByClass(64, oPC);
    int iLevel2 = GetLevelByClass(67, oPC);

    int iBonus = (iLevel1 + iLevel2) / 10 + 1;

    if (iBonus > 3)
        iBonus = 3;

    effect eBonus1 = EffectSavingThrowIncrease(SAVING_THROW_ALL, iBonus, SAVING_THROW_TYPE_ALL);
    effect eBonus2 = EffectACIncrease(iBonus, AC_DODGE_BONUS, AC_VS_DAMAGE_TYPE_ALL, FALSE);

    eEffect = EffectLinkEffects(eBonus1, eBonus2);
    eEffect = SupernaturalEffect(eEffect);

    SetEffectSpellId(eEffect, BONUS_ID);

    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oPC, HoursToSeconds(72));
}

// A good policy is to remove a/the effect before (re)applying it. hope it
// works, I took out oTarget on an assumption ... but the idea of the
// effect-loop near the top is what you're missing, i believe.
The problem as i see it, is that while the engine won't allow save-stacking (caveat..) it does allow Dodge Bonus to stack. natural and deflection won't stack, but all-in-all, without removing any previous application first it's just compounding a problem under the hood.

 

Kevl,

I tried your script in game play and even though it works fine in single-character parties.  When I have a multi-character party the feat script is firing on the highlighted character rather than the character who has the passive feat.  Is there something I can do in the feat script or custom rest script so it will recognize which character actually has the feat?



#5
kevL

kevL
  • Members
  • 4 052 messages
basically, right after oPC is defined, loop over faction members

object oFaction = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oFaction))
{
    if (GetHasFeat(FEAT_ID, oFaction, TRUE)) // change FEAT_ID to the row# in Feat.2da of your custom feat.
    {
        //
        // the body of the script goes here.
        // Change all instances of 'oPC' to 'oFaction' ...
        //
        //
        //
    }

    oFaction = GetNextFactionMember(oPC, FALSE);
}
I'm not sure whether the third param of GetHasFeat() should be TRUE or FALSE. (If it's a passive feat that's always active it shouldn't matter, but it should be tested...)


ps. what event fires the script? is it really onPCRested? Or is it a spellscript, that's invoked by the Feat?

#6
kevL

kevL
  • Members
  • 4 052 messages
edit: An even better way that would probably work is simply redefine oPC
 
oPC = GetOwnedCharacter(oPC);
... or a combination of that and checking for the feat w/ GetHasFeat()



edit2: i don't know what you really have going on there, so hopefully you can poke away at it