@@ -1818,14 +1818,6 @@ void Creature::add_effect( const effect_source &source, const efftype_id &eff_id
1818
1818
const int prev_int = e.get_intensity ();
1819
1819
// If we do, mod the duration, factoring in the mod value
1820
1820
e.mod_duration ( dur * e.get_dur_add_perc () / 100 );
1821
- // Limit to max duration
1822
- if ( e.get_duration () > e.get_max_duration () ) {
1823
- e.set_duration ( e.get_max_duration () );
1824
- }
1825
- // Adding a permanent effect makes it permanent
1826
- if ( e.is_permanent () ) {
1827
- e.pause_effect ();
1828
- }
1829
1821
// int_dur_factor overrides all other intensity settings
1830
1822
// ...but it's handled in set_duration, so explicitly do nothing here
1831
1823
if ( e.get_int_dur_factor () > 0_turns ) {
@@ -1836,14 +1828,8 @@ void Creature::add_effect( const effect_source &source, const efftype_id &eff_id
1836
1828
} else if ( e.get_int_add_val () != 0 ) {
1837
1829
e.mod_intensity ( e.get_int_add_val (), is_avatar () );
1838
1830
}
1839
-
1840
- // Bound intensity by [1, max intensity]
1841
- if ( e.get_intensity () < 1 ) {
1842
- add_msg_debug ( debugmode::DF_CREATURE, " Bad intensity, ID: %s" , e.get_id ().c_str () );
1843
- e.set_intensity ( 1 );
1844
- } else if ( e.get_intensity () > e.get_max_intensity () ) {
1845
- e.set_intensity ( e.get_max_intensity () );
1846
- }
1831
+ // Bound new effect intensity by [1, max intensity]
1832
+ e.clamp_intensity ();
1847
1833
if ( e.get_intensity () != prev_int ) {
1848
1834
on_effect_int_change ( eff_id, e.get_intensity (), bp );
1849
1835
}
@@ -1855,23 +1841,7 @@ void Creature::add_effect( const effect_source &source, const efftype_id &eff_id
1855
1841
1856
1842
// Now we can make the new effect for application
1857
1843
effect e ( effect_source ( source ), &type, dur, bp.id (), permanent, intensity, calendar::turn );
1858
- // Bound to max duration
1859
- if ( e.get_duration () > e.get_max_duration () ) {
1860
- e.set_duration ( e.get_max_duration () );
1861
- }
1862
1844
1863
- // Force intensity if it is duration based
1864
- if ( e.get_int_dur_factor () != 0_turns ) {
1865
- const int intensity = std::ceil ( e.get_duration () / e.get_int_dur_factor () );
1866
- e.set_intensity ( std::max ( 1 , intensity ) );
1867
- }
1868
- // Bound new effect intensity by [1, max intensity]
1869
- if ( e.get_intensity () < 1 ) {
1870
- add_msg_debug ( debugmode::DF_CREATURE, " Bad intensity, ID: %s" , e.get_id ().c_str () );
1871
- e.set_intensity ( 1 );
1872
- } else if ( e.get_intensity () > e.get_max_intensity () ) {
1873
- e.set_intensity ( e.get_max_intensity () );
1874
- }
1875
1845
( *effects )[eff_id][bp] = e;
1876
1846
if ( Character *ch = as_character () ) {
1877
1847
get_event_bus ().send <event_type::character_gains_effect>( ch->getID (), bp.id (), eff_id, intensity );
0 commit comments