Skip to content

Commit

Permalink
Weed fix (#16832)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lumipharon authored Dec 22, 2024
1 parent 7d02ca8 commit 9ad0b03
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
6 changes: 6 additions & 0 deletions code/__DEFINES/dcs/signals/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion code/controllers/subsystem/monitor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions code/datums/gamemodes/crash.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 6 additions & 18 deletions code/modules/mob/living/carbon/xenomorph/abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 ..()

Expand Down

0 comments on commit 9ad0b03

Please sign in to comment.