From 0ac987d06dfc21eed2db7e209a19ac7cf3ceb28b Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 12 Jan 2022 18:07:07 +0100 Subject: [PATCH] Updated _handle_effect in Spell to use the new style. --- data/spells/spell.cpp | 70 +++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/data/spells/spell.cpp b/data/spells/spell.cpp index e71ba0c..59a433d 100644 --- a/data/spells/spell.cpp +++ b/data/spells/spell.cpp @@ -1936,43 +1936,69 @@ void Spell::_handle_effect(Ref info) { handle_spell_damage(sdi); } - for (int i = 0; i < _spells_cast_on_caster.size(); ++i) { + if (is_aura()) { + Ref ad; + + if (aura_get_aura_group().is_valid()) { + ad = info->target_get()->aura_gets_with_group_by_bind(info->caster_get(), aura_get_aura_group()); + } else { + ad = info->target_get()->aura_gets_by(info->caster_get(), get_id()); + } + + if (ad.is_valid()) { + info->target_get()->aura_removes_exact(ad); + } + Ref aai; aai.instance(); aai->caster_set(info->caster_get()); - aai->target_set(info->caster_get()); + aai->target_set(info->target_get()); aai->spell_scale_set(1); - aai->set_aura(_spells_cast_on_caster[i]); + aai->set_aura(Ref(this)); - _spells_cast_on_caster.get(i)->aura_sapply(aai); + aura_sapply(aai); + } + + for (int i = 0; i < _spells_cast_on_caster.size(); ++i) { + Ref spell = _spells_cast_on_caster.get(i); + + if (!spell.is_valid()) { + continue; + } + + Ref sci; + sci.instance(); + + sci->caster_set(info->caster_get()); + sci->target_set(info->caster_get()); + sci->has_cast_time_set(spell->cast_time_get_enabled()); + sci->cast_time_set(spell->cast_time_get()); + sci->spell_scale_set(info->spell_scale_get()); + sci->set_spell(spell); + + spell->cast_starts(sci); } if (has_target) { for (int i = 0; i < _spells_cast_on_target.size(); ++i) { - Ref aura = _spells_cast_on_target.get(i); + Ref spell = _spells_cast_on_target.get(i); - Ref ad; - - if (aura->aura_get_aura_group().is_valid()) { - ad = info->target_get()->aura_gets_with_group_by_bind(info->caster_get(), aura->aura_get_aura_group()); - } else { - ad = info->target_get()->aura_gets_by(info->caster_get(), aura->get_id()); + if (!spell.is_valid()) { + continue; } - if (ad.is_valid()) { - info->target_get()->aura_removes_exact(ad); - } + Ref sci; + sci.instance(); - Ref aai; - aai.instance(); + sci->caster_set(info->caster_get()); + sci->target_set(info->target_get()); + sci->has_cast_time_set(spell->cast_time_get_enabled()); + sci->cast_time_set(spell->cast_time_get()); + sci->spell_scale_set(info->spell_scale_get()); + sci->set_spell(spell); - aai->caster_set(info->caster_get()); - aai->target_set(info->target_get()); - aai->spell_scale_set(1); - aai->set_aura(aura); - - aura->aura_sapply(aai); + spell->cast_starts(sci); } } }