From eb1b198fcb23bb5a57350d81c880786798b06617 Mon Sep 17 00:00:00 2001 From: XeonMations <62395746+XeonMations@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:14:12 +0300 Subject: [PATCH] Made electric vehicles no longer ignore EMPs (#11234) * emps * figured out a better way * gave it smoke and made it depend on severity * this should work --- code/datums/components/riding.dm | 21 +++++++++++++++++++ code/modules/vehicles/atv.dm | 1 + code/modules/vehicles/motorized_wheelchair.dm | 1 + code/modules/vehicles/pimpin_ride.dm | 1 + code/modules/vehicles/secway.dm | 1 + 5 files changed, 25 insertions(+) diff --git a/code/datums/components/riding.dm b/code/datums/components/riding.dm index 369c05a9e8d19..c57a67708a136 100644 --- a/code/datums/components/riding.dm +++ b/code/datums/components/riding.dm @@ -22,6 +22,8 @@ var/ride_check_ridden_restrained = FALSE var/del_on_unbuckle_all = FALSE + var/emped = FALSE + var/empable = FALSE /datum/component/riding/Initialize() if(!ismovable(parent)) @@ -29,6 +31,7 @@ RegisterSignal(parent, COMSIG_MOVABLE_BUCKLE, PROC_REF(vehicle_mob_buckle)) RegisterSignal(parent, COMSIG_MOVABLE_UNBUCKLE, PROC_REF(vehicle_mob_unbuckle)) RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(vehicle_moved)) + RegisterSignal(parent, COMSIG_ATOM_EMP_ACT, PROC_REF(on_emp_act)) //Calculate the move multiplier speed, to be proportional to mob speed vehicle_move_multiplier = CONFIG_GET(number/movedelay/run_delay) / 1.5 @@ -171,6 +174,9 @@ return last_vehicle_move = world.time + if(emped && empable) + to_chat(user, "\The [AM]'s controls aren't responding!") + return if(keycheck(user)) var/turf/next = get_step(AM, direction) var/turf/current = get_turf(AM) @@ -414,3 +420,18 @@ var/mob/living/simple_animal/S = parent S.toggle_ai(AI_ON) ..() + +/datum/component/riding/proc/on_emp_act(datum/source, severity) + SIGNAL_HANDLER + + if(!empable) + return + emped = TRUE + var/atom/movable/AM = parent + AM.add_emitter(/obj/emitter/fire_smoke, "smoke") + addtimer(CALLBACK(src, PROC_REF(reboot)), 300 / severity, TIMER_UNIQUE|TIMER_OVERRIDE) //if a new EMP happens, remove the old timer so it doesn't reactivate early + +/datum/component/riding/proc/reboot() + emped = FALSE + var/atom/movable/AM = parent + AM.remove_emitter("smoke") diff --git a/code/modules/vehicles/atv.dm b/code/modules/vehicles/atv.dm index e6baa174d8dfa..a81633cf9a561 100644 --- a/code/modules/vehicles/atv.dm +++ b/code/modules/vehicles/atv.dm @@ -13,6 +13,7 @@ . = ..() var/datum/component/riding/D = LoadComponent(/datum/component/riding) D.vehicle_move_delay = 1.5 + D.empable = TRUE D.set_riding_offsets(RIDING_OFFSET_ALL, list(TEXT_NORTH = list(0, 4), TEXT_SOUTH = list(0, 4), TEXT_EAST = list(0, 4), TEXT_WEST = list( 0, 4))) D.set_vehicle_dir_layer(SOUTH, ABOVE_MOB_LAYER) D.set_vehicle_dir_layer(NORTH, OBJ_LAYER) diff --git a/code/modules/vehicles/motorized_wheelchair.dm b/code/modules/vehicles/motorized_wheelchair.dm index 7cc942c5cbec8..b68c58a21a819 100644 --- a/code/modules/vehicles/motorized_wheelchair.dm +++ b/code/modules/vehicles/motorized_wheelchair.dm @@ -25,6 +25,7 @@ power_efficiency = C.rating var/datum/component/riding/D = GetComponent(/datum/component/riding) D.vehicle_move_delay = round(1.5 * delay_multiplier) / speed + D.empable = TRUE /obj/vehicle/ridden/wheelchair/motorized/get_cell() diff --git a/code/modules/vehicles/pimpin_ride.dm b/code/modules/vehicles/pimpin_ride.dm index 621dc2c51f772..476e1fa2dcafa 100644 --- a/code/modules/vehicles/pimpin_ride.dm +++ b/code/modules/vehicles/pimpin_ride.dm @@ -13,6 +13,7 @@ update_icon() var/datum/component/riding/D = LoadComponent(/datum/component/riding) D.set_riding_offsets(RIDING_OFFSET_ALL, list(TEXT_NORTH = list(0, 4), TEXT_SOUTH = list(0, 7), TEXT_EAST = list(-12, 7), TEXT_WEST = list( 12, 7))) + D.empable = TRUE GLOB.janitor_devices += src if(floorbuffer) AddElement(/datum/element/cleaning) diff --git a/code/modules/vehicles/secway.dm b/code/modules/vehicles/secway.dm index 4d2a4f5178421..0dc23070ea4b6 100644 --- a/code/modules/vehicles/secway.dm +++ b/code/modules/vehicles/secway.dm @@ -12,6 +12,7 @@ . = ..() var/datum/component/riding/D = LoadComponent(/datum/component/riding) D.vehicle_move_delay = 1.5 + D.empable = TRUE D.set_riding_offsets(RIDING_OFFSET_ALL, list(TEXT_NORTH = list(0, 4), TEXT_SOUTH = list(0, 4), TEXT_EAST = list(0, 4), TEXT_WEST = list( 0, 4))) /obj/vehicle/ridden/secway/obj_break()