Skip to content

Commit

Permalink
Merge pull request #77674 from GuardianDll/spell_dot_fixes
Browse files Browse the repository at this point in the history
DoT spell fixes
  • Loading branch information
Maleclypse authored Nov 9, 2024
2 parents b09ca0e + f10f747 commit 243622b
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions src/magic_spell_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bodypart_id> target_bdpts = cr->get_all_body_parts( get_body_part_flags::only_main );
if( cr->as_character() != nullptr ) {
std::vector<bodypart_id> 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( 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( { 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 ) );
}
}
}
Expand Down

0 comments on commit 243622b

Please sign in to comment.