Files
Bubberstation/code/datums/elements/basic_body_temp_sensitive.dm
san7890 1d256b5506 Refactors Rabbits to be a Basic Mob (#71205)
## About The Pull Request

Back in #64175, I reworked rabbits such that their base behavior was
just a cute fluffy snuggle monster, and not have the "easter" variant be
the default. Now that we're transitioning everything from simple_animal
to basic, I figured now was the time to shift that over too.

Pretty much everything should be the same as it was before, I even took
some time to add behavior to some elements to allow it to work (let me
know if I should handle it a different way) but rabbits as a
simple_animal and rabbits as a basic mob should now not be very
distinguishable (beyond the fact that they only speak via subtrees).

I also got rid of the single-letter icon_states in the DMI and
accomodated the code to fix because I finally got irritated enough to do
something about that.
## Why It's Good For The Game

Although I didn't really have any pressing urge to add more complex AI
behavior to rabbits than just pretty much re-implementing what they had
as a simple_animal, this is an excellent first-step to allowing much
more extensible behaviors to these fuzzy creatures.

Also, it takes three more mobs off "the frozen list". Whoopie!
## Changelog
🆑
fix: Dead Black Space Rabbits should now properly have a sprite.
/🆑

The UpdatePaths is useless for the maps we have on our repository
(holodecks use a spawner code-side), but I'm going to be nice to
downstreams who need it.
2022-11-15 23:40:39 -08:00

72 lines
2.1 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(isnum(min_body_temp))
src.min_body_temp = min_body_temp
if(isnum(max_body_temp))
src.max_body_temp = max_body_temp
if(isnum(cold_damage))
src.cold_damage = cold_damage
if(isnum(heat_damage))
src.heat_damage = heat_damage
RegisterSignal(target, COMSIG_LIVING_LIFE, PROC_REF(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)