mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-09 16:33:50 +00:00
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.
35 lines
1.0 KiB
Plaintext
35 lines
1.0 KiB
Plaintext
/**
|
|
* ## death drops element!
|
|
*
|
|
* bespoke element that spawns loot when a mob is killed
|
|
*/
|
|
/datum/element/death_drops
|
|
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
|
|
id_arg_index = 2
|
|
///what items the target drops when killed
|
|
var/list/loot
|
|
|
|
/datum/element/death_drops/Attach(datum/target, list/loot)
|
|
. = ..()
|
|
if(!isliving(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
if(!loot)
|
|
stack_trace("death drops element added to [target] with NO LOOT")
|
|
if(!src.loot)
|
|
src.loot = loot.Copy()
|
|
RegisterSignal(target, COMSIG_LIVING_DEATH, .proc/on_death)
|
|
|
|
/datum/element/death_drops/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, COMSIG_LIVING_DEATH)
|
|
|
|
///signal called by the stat of the target changing
|
|
/datum/element/death_drops/proc/on_death(mob/living/target, gibbed)
|
|
SIGNAL_HANDLER
|
|
for(var/thing_to_spawn in loot)
|
|
if(loot[thing_to_spawn]) //If this is an assoc list, use the value of that to get the right amount
|
|
for(var/index in 1 to loot[thing_to_spawn])
|
|
new thing_to_spawn(target.drop_location())
|
|
else
|
|
new thing_to_spawn(target.drop_location())
|