Fix calling restore_sp to drain SP from an affect special node

This also adds an Allow Resist flag to determine whether the target's
Mage Spells or Priest Spells skill can reduce the amount drained.

Thanks to @fosnola for spotting this issue.
This commit is contained in:
2023-01-21 17:26:02 -05:00
parent bad804bc71
commit d7dcf24644
10 changed files with 24 additions and 19 deletions

View File

@@ -857,7 +857,7 @@ void pc_attack_weapon(short who_att,iLiving& target,short hit_adj,short dam_adj,
else if(cPlayer* check = dynamic_cast<cPlayer*>(&target))
mage = check->skill(eSkill::MAGE_SPELLS), cleric = check->skill(eSkill::PRIEST_SPELLS);
if(mage + cleric > 0 && get_ran(1,0,1) == 1)
target.drain_sp(weap.abil_strength);
target.drain_sp(weap.abil_strength, true);
if(before > target.get_magic()) {
add_string_to_buf(" Blade drains energy.");
attacker.restore_sp(before / 3);
@@ -1854,7 +1854,7 @@ void fire_missile(location target) {
else if(cPlayer* check = dynamic_cast<cPlayer*>(victim))
mage = check->skill(eSkill::MAGE_SPELLS), cleric = check->skill(eSkill::PRIEST_SPELLS);
if(mage + cleric > 0 && get_ran(1,0,1) == 1)
victim->drain_sp(ammo.abil_strength);
victim->drain_sp(ammo.abil_strength, true);
if(before > victim->get_magic()) {
add_string_to_buf(" Missile drains energy.");
missile_firer.restore_sp((before - victim->get_magic()) / 3);

View File

@@ -2232,7 +2232,7 @@ void general_spec(const runtime_state& ctx) {
break;
case eSpecType::REST:
check_mess = true;
do_rest(spec.ex1a, spec.ex1b, spec.ex1b);
do_rest(max(spec.ex1a, 0), max(spec.ex1b, 0), max(spec.ex1b, 0));
break;
case eSpecType::END_SCENARIO:
end_scenario = true;
@@ -2789,7 +2789,7 @@ void affect_spec(const runtime_state& ctx) {
case eSpecType::AFFECT_SP:
if(spec.ex1b == 0)
pc.restore_sp(spec.ex1a);
else pc.restore_sp(-spec.ex1a);
else pc.drain_sp(spec.ex1a, spec.ex1c);
if(cCreature* who = dynamic_cast<cCreature*>(&pc)) {
if(spec.ex1b == 0)
who->spell_note(43);