Files
Bubberstation/code/datums/elements/basic_body_temp_sensitive.dm
AMonkeyThatCodes 46cb925af0 Basic Mobs: the cooler simple mobs that run on datum AI. (With reworked cockroach AI as proof of concept) (#60694)
Simple_animals / mobs are the biggest lie in this code-base. They're far from simple and have an extreme god-object problem. Especially when you get to /hostile, where there is so many procs, vars, and what not, that you can't make any interesting additions without snowflaking the hell out of the code.

This PR hopes to help kill this problem by introducing a new /living subtype, /living/basic. The idea of this refactor is to slowly start moving all old simple_animals to this new system, moving over behaviors like charging and more extravagant mobs like megafauna over bit by bit similar to how newfood was implemented.

One of the other big goals of this refactor is to move many of the fringe simple animal behaviors into either AI datums, or components/elements. (Some of which still needs to be done in this PR).

As a proof of concept, I created the base mob/living/basic, and moved cockroaches over to the system. Since cockroaches have both a passive, melee and ranged mob.

This PR does slightly affect balance as the behavior isn't 1-on-1 due to it no longer running on the janky /hostile behavior, but I tried to keep the effects to a minimum, and the glockroach and hauberoach are not spawnable through many means as far as I know.
2021-08-30 16:22:24 +01:00

66 lines
1.9 KiB
Plaintext

/**
* When attached to a basic mob, it gives it the ability to be hurt by cold body temperatures
*/
/datum/element/basic_body_temp_sensetive
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_sensetive/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_sensetive/Detach(datum/source)
if(source)
UnregisterSignal(source, COMSIG_LIVING_LIFE)
return ..()
/datum/element/basic_body_temp_sensetive/proc/on_life(datum/target, delta_time, times_fired)
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("temp", /atom/movable/screen/alert/cold, 1)
if(5 to 10)
basic_mob.throw_alert("temp", /atom/movable/screen/alert/cold, 2)
if(10 to INFINITY)
basic_mob.throw_alert("temp", /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("temp", /atom/movable/screen/alert/hot, 1)
if(5 to 10)
basic_mob.throw_alert("temp", /atom/movable/screen/alert/hot, 2)
if(10 to INFINITY)
basic_mob.throw_alert("temp", /atom/movable/screen/alert/hot, 3)
gave_alert = TRUE
if(!gave_alert)
basic_mob.clear_alert("temp")