From d977ea6d53565f188d603f3493ae221c0866ae29 Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com> Date: Sun, 17 Mar 2024 03:21:34 +0300 Subject: [PATCH] [MIRROR] Skateboard tweaks and buffs. (#1469) (#2442) * Skateboard tweaks and buffs. * Update riding_vehicle.dm --------- Co-authored-by: NovaBot <154629622+NovaBot13@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> Co-authored-by: SomeRandomOwl <2568378+SomeRandomOwl@users.noreply.github.com> --- .../signals/signals_mob/signals_mob_living.dm | 3 + .../components/riding/riding_vehicle.dm | 76 +++++++++++++++++++ code/game/atoms_movable.dm | 2 +- code/game/turfs/open/lava.dm | 4 +- code/modules/mob/mob_movement.dm | 2 + code/modules/vehicles/scooter.dm | 24 +++++- 6 files changed, 106 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm index d947e42302e..924488af73e 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm @@ -13,6 +13,9 @@ /// Called when an organ gets surgically removed (mob/living/user, mob/living/carbon/old_owner, target_zone, obj/item/tool) #define COMSIG_ORGAN_SURGICALLY_REMOVED "organ_surgically_removed" +///Called when movement intent is toggled. +#define COMSIG_MOVE_INTENT_TOGGLED "move_intent_toggled" + ///from base of mob/update_transform() #define COMSIG_LIVING_POST_UPDATE_TRANSFORM "living_post_update_transform" diff --git a/code/datums/components/riding/riding_vehicle.dm b/code/datums/components/riding/riding_vehicle.dm index bacf012aa5a..8935634cb42 100644 --- a/code/datums/components/riding/riding_vehicle.dm +++ b/code/datums/components/riding/riding_vehicle.dm @@ -169,6 +169,8 @@ /datum/component/riding/vehicle/scooter/skateboard vehicle_move_delay = 1.5 ride_check_flags = RIDER_NEEDS_LEGS | UNBUCKLE_DISABLED_RIDER + ///If TRUE, the vehicle will be slower (but safer) to ride on walk intent. + var/can_slow_down = TRUE /datum/component/riding/vehicle/scooter/skateboard/handle_specials() . = ..() @@ -177,8 +179,82 @@ set_vehicle_dir_layer(EAST, OBJ_LAYER) set_vehicle_dir_layer(WEST, OBJ_LAYER) +/datum/component/riding/vehicle/scooter/skateboard/RegisterWithParent() + . = ..() + if(can_slow_down) + RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine)) + var/obj/vehicle/ridden/scooter/skateboard/board = parent + if(istype(board)) + board.can_slow_down = can_slow_down + +/datum/component/riding/vehicle/scooter/skateboard/proc/on_examine(datum/source, mob/user, list/examine_list) + SIGNAL_HANDLER + examine_list += span_notice("Going slow and nice at [EXAMINE_HINT("walk")] speed will prevent crashing into things.") + +/datum/component/riding/vehicle/scooter/skateboard/vehicle_mob_buckle(datum/source, mob/living/rider, force = FALSE) + . = ..() + if(can_slow_down) + RegisterSignal(rider, COMSIG_MOVE_INTENT_TOGGLED, PROC_REF(toggle_move_delay)) + toggle_move_delay(rider) + +/datum/component/riding/vehicle/scooter/skateboard/handle_unbuckle(mob/living/rider) + . = ..() + if(can_slow_down) + toggle_move_delay(rider) + UnregisterSignal(rider, COMSIG_MOVE_INTENT_TOGGLED) + +/datum/component/riding/vehicle/scooter/skateboard/proc/toggle_move_delay(mob/living/rider) + SIGNAL_HANDLER + vehicle_move_delay = initial(vehicle_move_delay) + if(rider.move_intent == MOVE_INTENT_WALK) + vehicle_move_delay += 0.6 + +/datum/component/riding/vehicle/scooter/skateboard/pro + vehicle_move_delay = 1 + +///This one lets the rider ignore gravity, move in zero g and son on, but only on ground turfs or at most one z-level above them. +/datum/component/riding/vehicle/scooter/skateboard/hover + vehicle_move_delay = 1 + override_allow_spacemove = TRUE + +/datum/component/riding/vehicle/scooter/skateboard/hover/RegisterWithParent() + . = ..() + RegisterSignal(parent, COMSIG_ATOM_HAS_GRAVITY, PROC_REF(check_grav)) + RegisterSignal(parent, COMSIG_MOVABLE_SPACEMOVE, PROC_REF(check_drifting)) + hover_check() + +///Makes sure that the vehicle is grav-less if capable of zero-g movement. Forced gravity will honestly screw this. +/datum/component/riding/vehicle/scooter/skateboard/hover/proc/check_grav(datum/source, turf/gravity_turf, list/gravs) + SIGNAL_HANDLER + if(override_allow_spacemove) + gravs += 0 + +///Makes sure the vehicle isn't drifting while it can be maneuvered. +/datum/component/riding/vehicle/scooter/skateboard/hover/proc/check_drifting(datum/source, movement_dir, continuous_move) + SIGNAL_HANDLER + if(override_allow_spacemove) + return COMSIG_MOVABLE_STOP_SPACEMOVE + +/datum/component/riding/vehicle/scooter/skateboard/hover/vehicle_moved(atom/movable/source, oldloc, dir, forced) + . = ..() + hover_check(TRUE) + +///Makes sure that the hoverboard can move in zero-g in (open) space but only there's a ground turf on the z-level below. +/datum/component/riding/vehicle/scooter/skateboard/hover/proc/hover_check(is_moving = FALSE) + var/atom/movable/movable = parent + if(!isopenspaceturf(movable.loc)) + override_allow_spacemove = TRUE + return + var/turf/open/our_turf = movable.loc + var/turf/turf_below = GET_TURF_BELOW(our_turf) + if(our_turf.zPassOut(DOWN) && (isnull(turf_below) || (isopenspaceturf(turf_below) && turf_below.zPassIn(DOWN) && turf_below.zPassOut(DOWN)))) + override_allow_spacemove = FALSE + if(turf_below) + our_turf.zFall(movable, falling_from_move = is_moving) + /datum/component/riding/vehicle/scooter/skateboard/wheelys vehicle_move_delay = 1.75 // NOVA EDIT - ORIGINAL: 0 + can_slow_down = FALSE /datum/component/riding/vehicle/scooter/skateboard/wheelys/handle_specials() . = ..() diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index e0588e46932..43e37456a72 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -433,7 +433,7 @@ if(z_move_flags & ZMOVE_CAN_FLY_CHECKS && !(movement_type & (FLYING|FLOATING)) && has_gravity(start)) if(z_move_flags & ZMOVE_FEEDBACK) if(rider) - to_chat(rider, span_warning("[src] is is not capable of flight.")) + to_chat(rider, span_warning("[src] [p_are()] incapable of flight.")) else to_chat(src, span_warning("You are not Superman.")) return FALSE diff --git a/code/game/turfs/open/lava.dm b/code/game/turfs/open/lava.dm index 8f9e7b44aa6..8165b35a256 100644 --- a/code/game/turfs/open/lava.dm +++ b/code/game/turfs/open/lava.dm @@ -249,7 +249,7 @@ /turf/open/lava/proc/can_burn_stuff(atom/movable/burn_target) if(QDELETED(burn_target)) return LAVA_BE_IGNORING - if(burn_target.movement_type & MOVETYPES_NOT_TOUCHING_GROUND) //you're flying over it. + if(burn_target.movement_type & MOVETYPES_NOT_TOUCHING_GROUND || !burn_target.has_gravity()) //you're flying over it. return LAVA_BE_IGNORING if(isobj(burn_target)) @@ -268,7 +268,7 @@ var/mob/living/burn_living = burn_target var/atom/movable/burn_buckled = burn_living.buckled if(burn_buckled) - if(burn_buckled.movement_type & MOVETYPES_NOT_TOUCHING_GROUND) + if(burn_buckled.movement_type & MOVETYPES_NOT_TOUCHING_GROUND || !burn_buckled.has_gravity()) return LAVA_BE_PROCESSING if(isobj(burn_buckled)) var/obj/burn_buckled_obj = burn_buckled diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 4da5da30987..a11ef46c7f2 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -515,6 +515,8 @@ selector.update_appearance() update_move_intent_slowdown() + SEND_SIGNAL(user, COMSIG_MOVE_INTENT_TOGGLED) + ///Moves a mob upwards in z level /mob/verb/up() set name = "Move Upwards" diff --git a/code/modules/vehicles/scooter.dm b/code/modules/vehicles/scooter.dm index 4e1f115e55c..9e320c2f8de 100644 --- a/code/modules/vehicles/scooter.dm +++ b/code/modules/vehicles/scooter.dm @@ -49,6 +49,8 @@ var/board_item_type = /obj/item/melee/skateboard ///Stamina drain multiplier var/instability = 10 + ///If true, riding the skateboard with walk intent on will prevent crashing. + var/can_slow_down = TRUE /obj/vehicle/ridden/scooter/skateboard/Initialize(mapload) . = ..() @@ -87,9 +89,11 @@ . = ..() if(!bumped_thing.density || !has_buckled_mobs() || world.time < next_crash) return + var/mob/living/rider = buckled_mobs[1] + if(rider.move_intent == MOVE_INTENT_WALK && can_slow_down) //Going slow prevents you from crashing. + return next_crash = world.time + 10 - var/mob/living/rider = buckled_mobs[1] rider.adjustStaminaLoss(instability*6) playsound(src, 'sound/effects/bang.ogg', 40, TRUE) if(!iscarbon(rider) || rider.getStaminaLoss() >= 100 || grinding || iscarbon(bumped_thing)) @@ -181,13 +185,28 @@ board_item_type = /obj/item/melee/skateboard/pro instability = 6 -/obj/vehicle/ridden/scooter/skateboard/hoverboard/ +/obj/vehicle/ridden/scooter/skateboard/pro/make_ridable() + AddElement(/datum/element/ridable, /datum/component/riding/vehicle/scooter/skateboard/pro) + +/obj/vehicle/ridden/scooter/skateboard/hoverboard name = "hoverboard" desc = "A blast from the past, so retro!" board_item_type = /obj/item/melee/skateboard/hoverboard instability = 3 icon_state = "hoverboard_red" +/obj/vehicle/ridden/scooter/skateboard/hoverboard/make_ridable() + AddElement(/datum/element/ridable, /datum/component/riding/vehicle/scooter/skateboard/hover) + +/obj/vehicle/ridden/scooter/skateboard/hoverboard/can_z_move(direction, turf/start, turf/destination, z_move_flags = ZMOVE_FLIGHT_FLAGS, mob/living/rider) + . = ..() + if(!.) + return + if(rider && (z_move_flags & ZMOVE_CAN_FLY_CHECKS) && direction == UP) + if(z_move_flags & ZMOVE_FEEDBACK) + to_chat(rider, span_warning("[src] [p_are()] not powerful enough to fly upwards.")) + return FALSE + /obj/vehicle/ridden/scooter/skateboard/hoverboard/admin name = "\improper Board Of Directors" desc = "The engineering complexity of a spaceship concentrated inside of a board. Just as expensive, too." @@ -199,6 +218,7 @@ name = "improvised skateboard" desc = "An unfinished scooter which can only barely be called a skateboard. It's still rideable, but probably unsafe. Looks like you'll need to add a few rods to make handlebars." board_item_type = /obj/item/melee/skateboard/improvised + instability = 12 //CONSTRUCTION /obj/item/scooter_frame