mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-13 11:12:14 +00:00
## About The Pull Request This takes all the gib related procs: - `gib()` - `spawn_gibs()` - `spill_organs()` - `spread_bodyparts()` And adds heavy documentation that communicates what the procs are used for and how the different bitflags affect them. The difference is noticeable: `gib(TRUE, FALSE, FALSE, null)` vs `gib(DROP_ORGANS|DROP_BODYPARTS)` The code is now much more legible which is important considering it's used in a lot of places! Another robust change, is that we had several places in the code where there were double negatives like so: ``` /mob/living/carbon/spill_organs(no_brain, no_organs, no_bodyparts) if(!no_bodyparts) // DOUBLE NEGATIVES ARE BAD M'KAY?!? // do stuff here ``` This is a mindfuck to untangle. I inverted a lot of these parts so we don't lose our sanity. Last thing that was changed was a big `if()` loop in the `spill_organ()` proc. This was refactored to just be a simple `for` loop with `continue` statements where we needed to skip enabled bitflags. It's now shorter and cleaner than before. The only slight gameplay change this affects is that gibbing a mob now guarantees to drop all items unless the `DROP_ITEMS` bitflag is deliberately omitted. Some places like admin gib self, we don't want this to happen. ## Why It's Good For The Game Gib code is very old. (~15 years) People kept adding more arguments to the procs when it should have been a bitflag initially. By doing it this way, there is more flexibility and readability when it comes to adding new code in the future. ## Changelog 🆑 refactor: Refactor gib code to be more robust. qol: Gibbing a mob will result in all items being dropped instead of getting deleted. There are a few exceptions (like admin gib self) where this will not take place. /🆑
58 lines
2.1 KiB
Plaintext
58 lines
2.1 KiB
Plaintext
/*
|
|
This component is similar to stationloving in that it is meant to keep something on the z-level
|
|
The difference is that stationloving is for objects and stationstuck is for mobs.
|
|
It has a punishment variable that is what happens to the parent when they leave the z-level. See punish() documentation
|
|
*/
|
|
/datum/component/stationstuck
|
|
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
|
|
var/punishment = PUNISHMENT_GIB //see defines above
|
|
var/stuck_zlevel
|
|
var/message = ""
|
|
|
|
/datum/component/stationstuck/Initialize(_punishment = PUNISHMENT_GIB, _message = "")
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/mob/living/L = parent
|
|
RegisterSignals(L, list(COMSIG_MOVABLE_Z_CHANGED), PROC_REF(punish))
|
|
punishment = _punishment
|
|
message = _message
|
|
stuck_zlevel = L.z
|
|
|
|
/datum/component/stationstuck/InheritComponent(datum/component/stationstuck/newc, original, _punishment, _message)
|
|
if(newc)
|
|
punishment = newc.punishment
|
|
message = newc.message
|
|
else
|
|
punishment = _punishment
|
|
message = _message
|
|
|
|
/**
|
|
* Called when parent leaves the zlevel this is set to (aka whichever zlevel it was on when it was added)
|
|
* Sends a message, then does an effect depending on what the punishment was.
|
|
*
|
|
* Punishments:
|
|
* * PUNISHMENT_MURDER: kills parent
|
|
* * PUNISHMENT_GIB: gibs parent
|
|
* * PUNISHMENT_TELEPORT: finds a safe turf if possible, or a completely random one if not.
|
|
*/
|
|
/datum/component/stationstuck/proc/punish()
|
|
SIGNAL_HANDLER
|
|
|
|
var/mob/living/escapee = parent
|
|
if(message)
|
|
var/span = punishment == PUNISHMENT_TELEPORT ? "danger" : "userdanger"
|
|
to_chat(escapee, "<span class='[span]'>[message]</span>")
|
|
switch(punishment)
|
|
if(PUNISHMENT_MURDER)
|
|
if(escapee.stat != DEAD)
|
|
escapee.investigate_log("has been killed by stationstuck component.", INVESTIGATE_DEATHS)
|
|
escapee.death()
|
|
if(PUNISHMENT_GIB)
|
|
escapee.investigate_log("has been gibbed by stationstuck component.", INVESTIGATE_DEATHS)
|
|
escapee.gib(DROP_ALL_REMAINS)
|
|
if(PUNISHMENT_TELEPORT)
|
|
var/targetturf = find_safe_turf(stuck_zlevel)
|
|
if(!targetturf)
|
|
targetturf = locate(world.maxx/2,world.maxy/2,stuck_zlevel)
|
|
escapee.forceMove(targetturf)
|