From 02306cfec433c29c3d68a1674d9f51f23caaf1b9 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Fri, 8 Nov 2024 14:41:55 +0100 Subject: [PATCH 1/2] fix dot spells behavior with negative values --- src/magic_spell_effect.cpp | 48 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 907d61002df36..412fd1a4c83b7 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -622,38 +622,36 @@ static void damage_targets( const spell &sp, Creature &caster, } // handling DOTs here - if( sp.damage_dot( caster ) > 0 ) { - if( cr->as_character() != nullptr ) { - std::vector target_bdpts = cr->get_all_body_parts( get_body_part_flags::only_main ); + if( cr->as_character() != nullptr ) { + std::vector target_bdpts = cr->get_all_body_parts( get_body_part_flags::only_main ); - if( sp.bps_affected() > 0 ) { - for( auto it = target_bdpts.begin(); it != target_bdpts.end(); ) { - if( !sp.bp_is_affected( it->id() ) ) { - it = target_bdpts.erase( it ); - } else { - ++it; - } + if( sp.bps_affected() > 0 ) { + for( auto it = target_bdpts.begin(); it != target_bdpts.end(); ) { + if( !sp.bp_is_affected( it->id() ) ) { + it = target_bdpts.erase( it ); + } else { + ++it; } } + } - if( sp.has_flag( spell_flag::PERCENTAGE_DAMAGE ) ) { - for( bodypart_id bpid : target_bdpts ) { - damage_over_time_data foo = sp.damage_over_time( { bpid }, caster ); - foo.amount = cr->get_hp( bpid ) * foo.amount / 100.0; - cr->add_damage_over_time( foo ); - } - } else if( sp.has_flag( spell_flag::SPLIT_DAMAGE ) ) { - damage_over_time_data dot_data = sp.damage_over_time( target_bdpts, caster ); - dot_data.amount /= target_bdpts.size(); - cr->add_damage_over_time( dot_data ); - } else if( !target_bdpts.empty() ) { - cr->add_damage_over_time( sp.damage_over_time( target_bdpts, caster ) ); - } else { - cr->add_damage_over_time( sp.damage_over_time( { cr->get_random_body_part() }, caster ) ); + if( sp.has_flag( spell_flag::PERCENTAGE_DAMAGE ) ) { + for( bodypart_id bpid : target_bdpts ) { + damage_over_time_data foo = sp.damage_over_time( { bpid }, caster ); + foo.amount = cr->get_hp( bpid ) * foo.amount / 100.0; + cr->add_damage_over_time( foo ); } + } else if( sp.has_flag( spell_flag::SPLIT_DAMAGE ) ) { + damage_over_time_data dot_data = sp.damage_over_time( target_bdpts, caster ); + dot_data.amount /= target_bdpts.size(); + cr->add_damage_over_time( dot_data ); + } else if( !target_bdpts.empty() ) { + cr->add_damage_over_time( sp.damage_over_time( target_bdpts, caster ) ); } else { - cr->add_damage_over_time( sp.damage_over_time( { body_part_bp_null }, caster ) ); + cr->add_damage_over_time( sp.damage_over_time( { cr->get_random_body_part() }, caster ) ); } + } else { + cr->add_damage_over_time( sp.damage_over_time( { body_part_bp_null }, caster ) ); } } } From f10f7474c3f9ac90b00bb18159484f5895fc34cb Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Fri, 8 Nov 2024 14:42:42 +0100 Subject: [PATCH 2/2] fix dots dealing damage to all bpts even without bodyparts affected --- src/magic_spell_effect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 412fd1a4c83b7..de3da097af16b 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -645,7 +645,7 @@ static void damage_targets( const spell &sp, Creature &caster, damage_over_time_data dot_data = sp.damage_over_time( target_bdpts, caster ); dot_data.amount /= target_bdpts.size(); cr->add_damage_over_time( dot_data ); - } else if( !target_bdpts.empty() ) { + } else if( sp.bps_affected() > 0 ) { cr->add_damage_over_time( sp.damage_over_time( target_bdpts, caster ) ); } else { cr->add_damage_over_time( sp.damage_over_time( { cr->get_random_body_part() }, caster ) );