Skip to content

Commit

Permalink
[MIRROR] Skateboard tweaks and buffs. (#1469) (#2442)
Browse files Browse the repository at this point in the history
* Skateboard tweaks and buffs.

* Update riding_vehicle.dm

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: Ghom <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
  • Loading branch information
4 people authored Mar 17, 2024
1 parent ce697ce commit d977ea6
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 5 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
76 changes: 76 additions & 0 deletions code/datums/components/riding/riding_vehicle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
. = ..()
Expand All @@ -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()
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions code/game/turfs/open/lava.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/mob_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 22 additions & 2 deletions code/modules/vehicles/scooter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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."
Expand All @@ -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
Expand Down

0 comments on commit d977ea6

Please sign in to comment.