From 9ad0b03eafc34647a8be37afea67ca0a099b33c4 Mon Sep 17 00:00:00 2001 From: Lumipharon Date: Mon, 23 Dec 2024 11:41:38 +1300 Subject: [PATCH] Weed fix (#16832) --- code/__DEFINES/dcs/signals/signals.dm | 6 +++++ code/controllers/subsystem/monitor.dm | 4 +++- code/datums/gamemodes/crash.dm | 1 + .../mob/living/carbon/xenomorph/abilities.dm | 24 +++++-------------- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/dcs/signals/signals.dm b/code/__DEFINES/dcs/signals/signals.dm index a8b1decc85325..fc9183d99190b 100644 --- a/code/__DEFINES/dcs/signals/signals.dm +++ b/code/__DEFINES/dcs/signals/signals.dm @@ -13,6 +13,12 @@ #define COMSIG_GLOB_OPEN_TIMED_SHUTTERS_XENO_HIVEMIND "!open_timed_shutters_xeno_hivemind" #define COMSIG_GLOB_OPEN_TIMED_SHUTTERS_CRASH "!open_timed_shutters_crash" #define COMSIG_GLOB_OPEN_SHUTTERS_EARLY "!open_shutters_early" +///Marine ship in Crash gamemode has landed +#define COMSIG_GLOB_CRASH_SHIP_LANDED "!crash_ship_landed" +///Gamemode changed to groundside state +#define COMSIG_GLOB_GAMESTATE_GROUNDSIDE "!gamestate_groundside" +///Gamemode changed to shipside state +#define COMSIG_GLOB_GAMESTATE_SHIPSIDE "!gamestate_shipside" #define COMSIG_GLOB_TADPOLE_LAUNCHED "!tadpole_launched" #define COMSIG_GLOB_DROPPOD_LANDED "!pod_landed" diff --git a/code/controllers/subsystem/monitor.dm b/code/controllers/subsystem/monitor.dm index a1a2c262a2c8a..66e200d9f15b6 100644 --- a/code/controllers/subsystem/monitor.dm +++ b/code/controllers/subsystem/monitor.dm @@ -42,7 +42,7 @@ SUBSYSTEM_DEF(monitor) var/list/b17_in_use = list() /datum/controller/subsystem/monitor/Initialize() - RegisterSignals(SSdcs, list(COMSIG_GLOB_OPEN_TIMED_SHUTTERS_LATE, COMSIG_GLOB_OPEN_SHUTTERS_EARLY), PROC_REF(set_groundside_calculation)) + RegisterSignals(SSdcs, list(COMSIG_GLOB_OPEN_TIMED_SHUTTERS_LATE, COMSIG_GLOB_OPEN_SHUTTERS_EARLY, COMSIG_GLOB_CRASH_SHIP_LANDED), PROC_REF(set_groundside_calculation)) RegisterSignal(SSdcs, COMSIG_GLOB_DROPSHIP_HIJACKED, PROC_REF(set_shipside_calculation)) is_automatic_balance_on = CONFIG_GET(flag/is_automatic_balance_on) return SS_INIT_SUCCESS @@ -76,10 +76,12 @@ SUBSYSTEM_DEF(monitor) /datum/controller/subsystem/monitor/proc/set_groundside_calculation() SIGNAL_HANDLER gamestate = GROUNDSIDE + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_GAMESTATE_GROUNDSIDE) /datum/controller/subsystem/monitor/proc/set_shipside_calculation() SIGNAL_HANDLER gamestate = SHIPSIDE + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_GAMESTATE_SHIPSIDE) ///Calculate the points supposedly representating of the situation /datum/controller/subsystem/monitor/proc/calculate_state_points() diff --git a/code/datums/gamemodes/crash.dm b/code/datums/gamemodes/crash.dm index 5c75d1bc4bedb..34003de991817 100644 --- a/code/datums/gamemodes/crash.dm +++ b/code/datums/gamemodes/crash.dm @@ -132,6 +132,7 @@ last_larva_check = world.time /datum/game_mode/infestation/crash/proc/crash_shuttle(obj/docking_port/stationary/target) + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CRASH_SHIP_LANDED) shuttle_landed = TRUE shuttle.crashing = FALSE diff --git a/code/modules/mob/living/carbon/xenomorph/abilities.dm b/code/modules/mob/living/carbon/xenomorph/abilities.dm index a4e3b28ef81fc..7b58766e1af46 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities.dm @@ -44,25 +44,13 @@ /datum/action/ability/activable/xeno/plant_weeds/New(Target) . = ..() if(SSmonitor.gamestate == SHUTTERS_CLOSED) - RegisterSignals(SSdcs, list(COMSIG_GLOB_OPEN_SHUTTERS_EARLY, COMSIG_GLOB_OPEN_TIMED_SHUTTERS_LATE), PROC_REF(update_ability_cost_shutters)) + RegisterSignals(SSdcs, list(COMSIG_GLOB_GAMESTATE_GROUNDSIDE), PROC_REF(update_ability_cost)) + update_ability_cost() -/datum/action/ability/activable/xeno/plant_weeds/can_use_action(atom/A, silent = FALSE, override_flags) - update_ability_cost() - return ..() - -/// Updates the ability cost based on gamestate. -/datum/action/ability/activable/xeno/plant_weeds/proc/update_ability_cost(shutters_recently_opened) - ability_cost = initial(ability_cost) * initial(weed_type.ability_cost_mult) - ability_cost = (!shutters_recently_opened && SSmonitor.gamestate == SHUTTERS_CLOSED) ? ability_cost/2 : ability_cost - -/** - * Updates the ability cost as if the gamestate was not SHUTTERS_CLOSED. - * The signal happens at the same time of gamestate changing, so that variable cannot be depended on. - */ -/datum/action/ability/activable/xeno/plant_weeds/proc/update_ability_cost_shutters() +///Updates the ability cost based on gamestate +/datum/action/ability/activable/xeno/plant_weeds/proc/update_ability_cost(datum/source) SIGNAL_HANDLER - UnregisterSignal(SSdcs, list(COMSIG_GLOB_OPEN_SHUTTERS_EARLY, COMSIG_GLOB_OPEN_TIMED_SHUTTERS_LATE)) - update_ability_cost(TRUE) + ability_cost = initial(ability_cost) * initial(weed_type.ability_cost_mult) * ((SSmonitor.gamestate == SHUTTERS_CLOSED) ? 0.5 : 1) update_button_icon() /datum/action/ability/activable/xeno/plant_weeds/action_activate() @@ -191,7 +179,7 @@ return ..() /datum/action/ability/activable/xeno/plant_weeds/ranged/can_use_action(silent = FALSE, override_flags, selecting = FALSE) - if (owner.status_flags & INCORPOREAL) + if (owner?.status_flags & INCORPOREAL) return FALSE return ..()