Browse files

IWDOpcodes: fixed the saving throw penalties to be correct for both s…

…ystems

not just 3ed, one effect was granting the reverse bonus even in normal mode
  • Loading branch information...
1 parent 581a4e2 commit 8397a0ad0087c51f5770c6103126af2f0a443f6b @lynxlynxlynx lynxlynxlynx committed Dec 29, 2013
Showing with 53 additions and 47 deletions.
  1. +53 −47 gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp
View
100 gemrb/plugins/IWDOpcodes/IWDOpcodes.cpp
@@ -837,6 +837,7 @@ int fx_crushing_damage (Scriptable* Owner, Actor* target, Effect* fx)
int fx_save_bonus (Scriptable* /*Owner*/, Actor* target, Effect* fx)
{
if(0) print("fx_save_bonus(%2d): Bonus %d Type: %d", fx->Opcode, fx->Parameter1, fx->Parameter2);
+ // TODO: check that users are passing appropriate values in iwd1 and iwd2!
STAT_MOD( IE_SAVEVSDEATH );
STAT_MOD( IE_SAVEVSWANDS );
STAT_MOD( IE_SAVEVSPOLY );
@@ -995,12 +996,13 @@ int fx_prayer (Scriptable* /*Owner*/, Actor* target, Effect* fx)
}
target->ToHit.HandleFxBonus(value, fx->TimingMode==FX_DURATION_INSTANT_PERMANENT);
- STAT_ADD( IE_SAVEFORTITUDE, value);
- STAT_ADD( IE_SAVEREFLEX, value);
- STAT_ADD( IE_SAVEWILL, value);
+ HandleBonus(target, IE_SAVEFORTITUDE, value, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, value, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, value, fx->TimingMode);
//make it compatible with 2nd edition
- STAT_ADD( IE_SAVEVSBREATH, value);
- STAT_ADD( IE_SAVEVSSPELL, value);
+ HandleBonus(target, IE_SAVEVSBREATH, value, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, value, fx->TimingMode);
+
return FX_APPLIED;
}
//0xf5
@@ -1010,12 +1012,12 @@ int fx_curse (Scriptable* /*Owner*/, Actor* target, Effect* fx)
if (target->SetSpellState(SS_BADPRAYER)) return FX_NOT_APPLIED;
EXTSTATE_SET(EXTSTATE_PRAYER_BAD);
target->ToHit.HandleFxBonus(-1, fx->TimingMode==FX_DURATION_INSTANT_PERMANENT);
- STAT_ADD( IE_SAVEFORTITUDE, -1);
- STAT_ADD( IE_SAVEREFLEX, -1);
- STAT_ADD( IE_SAVEWILL, -1);
+ HandleBonus(target, IE_SAVEFORTITUDE, -1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, -1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, -1, fx->TimingMode);
//make it compatible with 2nd edition
- STAT_ADD( IE_SAVEVSBREATH, -1);
- STAT_ADD( IE_SAVEVSSPELL, -1);
+ HandleBonus(target, IE_SAVEVSBREATH, -1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, -1, fx->TimingMode);
return FX_APPLIED;
}
@@ -1144,12 +1146,12 @@ int fx_recitation (Scriptable* /*Owner*/, Actor* target, Effect* fx)
}
target->ToHit.HandleFxBonus(value, fx->TimingMode==FX_DURATION_INSTANT_PERMANENT);
- STAT_ADD( IE_SAVEFORTITUDE, value);
- STAT_ADD( IE_SAVEREFLEX, value);
- STAT_ADD( IE_SAVEWILL, value);
+ HandleBonus(target, IE_SAVEFORTITUDE, value, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, value, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, value, fx->TimingMode);
//make it compatible with 2nd edition
- STAT_ADD( IE_SAVEVSBREATH, value);
- STAT_ADD( IE_SAVEVSSPELL, value);
+ HandleBonus(target, IE_SAVEVSBREATH, value, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, value, fx->TimingMode);
return FX_APPLIED;
}
//0xfa RecitationBad
@@ -1159,12 +1161,12 @@ int fx_recitation_bad (Scriptable* /*Owner*/, Actor* target, Effect* fx)
if (target->SetSpellState(SS_BADRECIT)) return FX_NOT_APPLIED;
EXTSTATE_SET(EXTSTATE_REC_BAD);
target->ToHit.HandleFxBonus(-2, fx->TimingMode==FX_DURATION_INSTANT_PERMANENT);
- STAT_ADD( IE_SAVEFORTITUDE, -2);
- STAT_ADD( IE_SAVEREFLEX, -2);
- STAT_ADD( IE_SAVEWILL, -2);
+ HandleBonus(target, IE_SAVEFORTITUDE, -2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, -2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, -2, fx->TimingMode);
//make it compatible with 2nd edition
- STAT_ADD( IE_SAVEVSBREATH, -2);
- STAT_ADD( IE_SAVEVSSPELL, -2);
+ HandleBonus(target, IE_SAVEVSBREATH, -2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, -2, fx->TimingMode);
return FX_APPLIED;
}
//0xfb LichTouch (how)
@@ -2492,13 +2494,14 @@ int fx_protection_from_evil (Scriptable* /*Owner*/, Actor* target, Effect* fx)
if (target->SetSpellState( SS_PROTFROMEVIL)) return FX_APPLIED;
target->AddPortraitIcon(PI_PROTFROMEVIL);
//+2 to all saving throws
- STAT_ADD( IE_SAVEFORTITUDE, 2);
- STAT_ADD( IE_SAVEREFLEX, 2);
- STAT_ADD( IE_SAVEWILL, 2);
+ HandleBonus(target, IE_SAVEFORTITUDE, 2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, 2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, 2, fx->TimingMode);
//make it compatible with 2nd edition
- STAT_ADD( IE_SAVEVSBREATH, 2);
- STAT_ADD( IE_SAVEVSSPELL, 2);
- //immune to control
+ HandleBonus(target, IE_SAVEVSBREATH, 2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, 2, fx->TimingMode);
+
+ // immunity to control is handled in fx_control
return FX_APPLIED;
}
@@ -3004,9 +3007,12 @@ int fx_aegis (Scriptable* /*Owner*/, Actor* target, Effect* fx)
STAT_ADD(IE_RESISTMAGIC, 3);
//saving throws
- STAT_ADD(IE_SAVEFORTITUDE, 2);
- STAT_ADD(IE_SAVEWILL, 2);
- STAT_ADD(IE_SAVEREFLEX, 2);
+ HandleBonus(target, IE_SAVEFORTITUDE, 2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, 2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, 2, fx->TimingMode);
+ //make it compatible with 2nd edition
+ HandleBonus(target, IE_SAVEVSBREATH, 2, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, 2, fx->TimingMode);
if (fx->FirstApply) {
fx->Parameter1=8;
@@ -3112,12 +3118,12 @@ int fx_energy_drain (Scriptable* /*Owner*/, Actor* target, Effect* fx)
}
//if there is another energy drain effect (level drain), add them up
STAT_ADD(IE_LEVELDRAIN, fx->Parameter1);
- STAT_SUB(IE_SAVEFORTITUDE, fx->Parameter1);
- STAT_SUB(IE_SAVEREFLEX, fx->Parameter1);
- STAT_SUB(IE_SAVEWILL, fx->Parameter1);
- //these saving throws don't exist in 2nd edition, but to make it portable, we should affect ALL saving throws
- STAT_SUB(IE_SAVEVSBREATH, fx->Parameter1);
- STAT_SUB(IE_SAVEVSSPELL, fx->Parameter1);
+ HandleBonus(target, IE_SAVEFORTITUDE, -fx->Parameter1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, -fx->Parameter1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, -fx->Parameter1, fx->TimingMode);
+ //make it compatible with 2nd edition
+ HandleBonus(target, IE_SAVEVSBREATH, -fx->Parameter1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, -fx->Parameter1, fx->TimingMode);
STAT_SUB(IE_MAXHITPOINTS, fx->Parameter1*5);
return FX_APPLIED;
}
@@ -3223,12 +3229,12 @@ int fx_day_blindness (Scriptable* Owner, Actor* target, Effect* fx)
target->AddPortraitIcon(PI_DAYBLINDNESS);
//saving throw penalty (bigger is better in iwd2)
- STAT_SUB(IE_SAVEFORTITUDE, penalty);
- STAT_SUB(IE_SAVEREFLEX, penalty);
- STAT_SUB(IE_SAVEWILL, penalty);
- //for compatibility reasons
- STAT_SUB(IE_SAVEVSBREATH, penalty);
- STAT_SUB(IE_SAVEVSSPELL, penalty);
+ HandleBonus(target, IE_SAVEFORTITUDE, -penalty, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, -penalty, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, -penalty, fx->TimingMode);
+ //make it compatible with 2nd edition
+ HandleBonus(target, IE_SAVEVSBREATH, -penalty, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, -penalty, fx->TimingMode);
//bigger is better in iwd2
target->ToHit.HandleFxBonus(-penalty, fx->TimingMode==FX_DURATION_INSTANT_PERMANENT);
@@ -3295,12 +3301,12 @@ int fx_heroic_inspiration (Scriptable* /*Owner*/, Actor* target, Effect* fx)
STAT_ADD( IE_DAMAGEBONUS, 1);
STAT_ADD( IE_HITBONUS, 1);
//+1 to all saves
- STAT_ADD( IE_SAVEFORTITUDE, 1);
- STAT_ADD( IE_SAVEREFLEX, 1);
- STAT_ADD( IE_SAVEWILL, 1);
+ HandleBonus(target, IE_SAVEFORTITUDE, 1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEREFLEX, 1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEWILL, 1, fx->TimingMode);
//make it compatible with 2nd edition
- STAT_ADD( IE_SAVEVSBREATH, 1);
- STAT_ADD( IE_SAVEVSSPELL, 1);
+ HandleBonus(target, IE_SAVEVSBREATH, 1, fx->TimingMode);
+ HandleBonus(target, IE_SAVEVSSPELL, 1, fx->TimingMode);
return FX_APPLIED;
}
@@ -3372,7 +3378,7 @@ int fx_tenser_transformation (Scriptable* /*Owner*/, Actor* target, Effect* fx)
// FIXME: should actually increase the base, so extra attacks can be gained
// but then the effect would be permanent and Actor::GetNumberOfAttacks doesn't handle effects yet
target->ToHit.HandleFxBonus(fx->CasterLevel/2, fx->TimingMode==FX_DURATION_INSTANT_PERMANENT);
- STAT_ADD(IE_SAVEFORTITUDE, 5);
+ HandleBonus(target, IE_SAVEFORTITUDE, 5, fx->TimingMode);
STAT_ADD(IE_MAXHITPOINTS, fx->Parameter3);
STAT_ADD(IE_STR, fx->Parameter4);
STAT_ADD(IE_CON, fx->Parameter5);

0 comments on commit 8397a0a

Please sign in to comment.