mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-26 09:32:21 +00:00
* Turns most alerts into defines * Update mobs.dm Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
68 lines
2.0 KiB
Plaintext
68 lines
2.0 KiB
Plaintext
/**
|
|
* When attached to a basic mob, it gives it the ability to be hurt by cold/hot body temperatures
|
|
*/
|
|
/datum/element/basic_body_temp_sensitive
|
|
element_flags = ELEMENT_BESPOKE
|
|
id_arg_index = 2
|
|
|
|
///Min body temp
|
|
var/min_body_temp = 250
|
|
///Max body temp
|
|
var/max_body_temp = 350
|
|
////Damage when below min temp
|
|
var/cold_damage = 1
|
|
///Damage when above max temp
|
|
var/heat_damage = 1
|
|
|
|
/datum/element/basic_body_temp_sensitive/Attach(datum/target, min_body_temp, max_body_temp, cold_damage, heat_damage)
|
|
. = ..()
|
|
if(!isbasicmob(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
if(min_body_temp)
|
|
src.min_body_temp = min_body_temp
|
|
if(max_body_temp)
|
|
src.max_body_temp = max_body_temp
|
|
if(cold_damage)
|
|
src.cold_damage = cold_damage
|
|
if(heat_damage)
|
|
src.heat_damage = heat_damage
|
|
RegisterSignal(target, COMSIG_LIVING_LIFE, .proc/on_life)
|
|
|
|
/datum/element/basic_body_temp_sensitive/Detach(datum/source)
|
|
if(source)
|
|
UnregisterSignal(source, COMSIG_LIVING_LIFE)
|
|
return ..()
|
|
|
|
|
|
/datum/element/basic_body_temp_sensitive/proc/on_life(datum/target, delta_time, times_fired)
|
|
SIGNAL_HANDLER
|
|
|
|
var/mob/living/basic/basic_mob = target
|
|
var/gave_alert = FALSE
|
|
|
|
if(basic_mob.bodytemperature < min_body_temp)
|
|
basic_mob.adjust_health(cold_damage * delta_time)
|
|
switch(cold_damage)
|
|
if(1 to 5)
|
|
basic_mob.throw_alert(ALERT_TEMPERATURE, /atom/movable/screen/alert/cold, 1)
|
|
if(5 to 10)
|
|
basic_mob.throw_alert(ALERT_TEMPERATURE, /atom/movable/screen/alert/cold, 2)
|
|
if(10 to INFINITY)
|
|
basic_mob.throw_alert(ALERT_TEMPERATURE, /atom/movable/screen/alert/cold, 3)
|
|
gave_alert = TRUE
|
|
|
|
else if(basic_mob.bodytemperature > max_body_temp)
|
|
basic_mob.adjust_health(heat_damage * delta_time)
|
|
switch(heat_damage)
|
|
if(1 to 5)
|
|
basic_mob.throw_alert(ALERT_TEMPERATURE, /atom/movable/screen/alert/hot, 1)
|
|
if(5 to 10)
|
|
basic_mob.throw_alert(ALERT_TEMPERATURE, /atom/movable/screen/alert/hot, 2)
|
|
if(10 to INFINITY)
|
|
basic_mob.throw_alert(ALERT_TEMPERATURE, /atom/movable/screen/alert/hot, 3)
|
|
gave_alert = TRUE
|
|
|
|
if(!gave_alert)
|
|
basic_mob.clear_alert(ALERT_TEMPERATURE)
|