mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-17 04:27:39 +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. /🆑
115 lines
3.3 KiB
Plaintext
115 lines
3.3 KiB
Plaintext
/**
|
|
* # Drone
|
|
*
|
|
* A movable mob that can be fed inputs on which direction to travel.
|
|
*/
|
|
/mob/living/circuit_drone
|
|
name = "drone"
|
|
icon = 'icons/obj/science/circuits.dmi'
|
|
icon_state = "setup_medium_med"
|
|
maxHealth = 300
|
|
health = 300
|
|
living_flags = 0
|
|
light_system = MOVABLE_LIGHT_DIRECTIONAL
|
|
light_on = FALSE
|
|
|
|
/mob/living/circuit_drone/Initialize(mapload)
|
|
. = ..()
|
|
AddComponent(/datum/component/shell, list(
|
|
new /obj/item/circuit_component/bot_circuit()
|
|
), SHELL_CAPACITY_LARGE)
|
|
|
|
/mob/living/circuit_drone/examine(mob/user)
|
|
. = ..()
|
|
if(health < maxHealth)
|
|
if(health > maxHealth/3)
|
|
. += "[src]'s parts look loose."
|
|
else
|
|
. += "[src]'s parts look very loose!"
|
|
else
|
|
. += "[src] is in pristine condition."
|
|
|
|
/mob/living/circuit_drone/updatehealth()
|
|
. = ..()
|
|
if(health < 0)
|
|
gib()
|
|
|
|
/mob/living/circuit_drone/welder_act(mob/living/user, obj/item/tool)
|
|
. = ..()
|
|
if(health == maxHealth)
|
|
balloon_alert(user, "already at maximum integrity!")
|
|
return TRUE
|
|
if(tool.use_tool(src, user, 1 SECONDS, volume = 50))
|
|
heal_overall_damage(50, 50)
|
|
return TRUE
|
|
|
|
/mob/living/circuit_drone/spawn_gibs()
|
|
new /obj/effect/gibspawner/robot(drop_location(), src, get_static_viruses())
|
|
|
|
/obj/item/circuit_component/bot_circuit
|
|
display_name = "Drone"
|
|
desc = "Used to send movement output signals to the drone shell."
|
|
|
|
/// The inputs to allow for the drone to move
|
|
var/datum/port/input/north
|
|
var/datum/port/input/east
|
|
var/datum/port/input/south
|
|
var/datum/port/input/west
|
|
|
|
// Done like this so that travelling diagonally is more simple
|
|
COOLDOWN_DECLARE(north_delay)
|
|
COOLDOWN_DECLARE(east_delay)
|
|
COOLDOWN_DECLARE(south_delay)
|
|
COOLDOWN_DECLARE(west_delay)
|
|
|
|
/// Delay between each movement
|
|
var/move_delay = 0.2 SECONDS
|
|
|
|
/obj/item/circuit_component/bot_circuit/register_shell(atom/movable/shell)
|
|
. = ..()
|
|
if(ismob(shell))
|
|
RegisterSignal(shell, COMSIG_PROCESS_BORGCHARGER_OCCUPANT, PROC_REF(on_borg_charge))
|
|
|
|
/obj/item/circuit_component/bot_circuit/unregister_shell(atom/movable/shell)
|
|
UnregisterSignal(shell, COMSIG_PROCESS_BORGCHARGER_OCCUPANT)
|
|
return ..()
|
|
|
|
/obj/item/circuit_component/bot_circuit/proc/on_borg_charge(datum/source, amount)
|
|
SIGNAL_HANDLER
|
|
if (isnull(parent.cell))
|
|
return
|
|
parent.cell.give(amount)
|
|
|
|
/obj/item/circuit_component/bot_circuit/populate_ports()
|
|
north = add_input_port("Move North", PORT_TYPE_SIGNAL)
|
|
east = add_input_port("Move East", PORT_TYPE_SIGNAL)
|
|
south = add_input_port("Move South", PORT_TYPE_SIGNAL)
|
|
west = add_input_port("Move West", PORT_TYPE_SIGNAL)
|
|
|
|
/obj/item/circuit_component/bot_circuit/input_received(datum/port/input/port)
|
|
|
|
var/mob/living/shell = parent.shell
|
|
if(!istype(shell) || shell.stat)
|
|
return
|
|
|
|
var/direction
|
|
|
|
if(COMPONENT_TRIGGERED_BY(north, port) && COOLDOWN_FINISHED(src, north_delay))
|
|
direction = NORTH
|
|
COOLDOWN_START(src, north_delay, move_delay)
|
|
else if(COMPONENT_TRIGGERED_BY(east, port) && COOLDOWN_FINISHED(src, east_delay))
|
|
direction = EAST
|
|
COOLDOWN_START(src, east_delay, move_delay)
|
|
else if(COMPONENT_TRIGGERED_BY(south, port) && COOLDOWN_FINISHED(src, south_delay))
|
|
direction = SOUTH
|
|
COOLDOWN_START(src, south_delay, move_delay)
|
|
else if(COMPONENT_TRIGGERED_BY(west, port) && COOLDOWN_FINISHED(src, west_delay))
|
|
direction = WEST
|
|
COOLDOWN_START(src, west_delay, move_delay)
|
|
|
|
if(!direction)
|
|
return
|
|
|
|
if(shell.Process_Spacemove(direction))
|
|
shell.Move(get_step(shell, direction), direction)
|