diff --git a/src/magic.cpp b/src/magic.cpp index 1ca37e5093524..8e16171beda7e 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -498,6 +498,31 @@ int spell::damage() const } } +int spell::min_leveled_dot() const +{ + return type->min_dot + std::round( get_level() * type->dot_increment ); +} + +int spell::damage_dot() const +{ + const int leveled_dot = min_leveled_dot(); + if( type->min_dot >= 0 || type->max_dot >= type->min_dot ) { + return std::min( leveled_dot, type->max_dot ); + } else { // if it's negative, min and max work differently + return std::max( leveled_dot, type->max_dot ); + } +} + +damage_over_time_data spell::damage_over_time( const std::vector &bps ) const +{ + damage_over_time_data temp; + temp.bps = bps; + temp.duration = duration_turns(); + temp.amount = damage_dot(); + temp.type = dmg_type(); + return temp; +} + std::string spell::damage_string() const { if( has_flag( spell_flag::RANDOM_DAMAGE ) ) { @@ -1708,9 +1733,14 @@ void spellcasting_callback::draw_spell_info( const spell &sp, const uilist *menu if( fx == "target_attack" || fx == "projectile_attack" || fx == "cone_attack" || fx == "line_attack" ) { if( damage > 0 ) { - damage_string = string_format( "%s: %s %s", _( "Damage" ), colorize( sp.damage_string(), - sp.damage_type_color() ), - colorize( sp.damage_type_string(), sp.damage_type_color() ) ); + std::string dot_string; + if( sp.damage_dot() != 0 ) { + //~ amount of damage per second, abbreviated + dot_string = string_format( _( ", %d/sec" ), sp.damage_dot() ); + } + damage_string = string_format( "%s: %s %s%s", _( "Damage" ), sp.damage_string(), + sp.damage_type_string(), dot_string ); + damage_string = colorize( damage_string, sp.damage_type_color() ); } else if( damage < 0 ) { damage_string = string_format( "%s: %s", _( "Healing" ), colorize( sp.damage_string(), light_green ) ); diff --git a/src/magic.h b/src/magic.h index c762a2a627684..b859515c46e43 100644 --- a/src/magic.h +++ b/src/magic.h @@ -295,6 +295,7 @@ class spell // minimum damage including levels int min_leveled_damage() const; + int min_leveled_dot() const; // minimum aoe including levels int min_leveled_aoe() const; // minimum duration including levels (moves) @@ -334,6 +335,8 @@ class spell int field_intensity() const; // how much damage does the spell do int damage() const; + int damage_dot() const; + damage_over_time_data damage_over_time( const std::vector &bps ) const; dealt_damage_instance get_dealt_damage_instance() const; damage_instance get_damage_instance() const; // how big is the spell's radius diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 1be6d84a4a423..f5aaf0da33078 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -437,6 +437,8 @@ static void damage_targets( const spell &sp, Creature &caster, sp.heal( target ); add_msg( m_good, _( "%s wounds are closing up!" ), cr->disp_name( true ) ); } + // TODO: randomize hit location + cr->add_damage_over_time( sp.damage_over_time( { bodypart_str_id( "torso" ) } ) ); } }