Refactored go-kart code (#29938)

* Refactored go-kart code

* Go-karts explode fuel tanks

* Improved speen(), correctly reset fucked up offsets when leaving vehicles

* Even better speen()
This commit is contained in:
DamianX
2021-07-03 21:22:49 +02:00
committed by GitHub
parent dfc7eb87a3
commit acfca3215a
10 changed files with 48 additions and 25 deletions

View File

@@ -206,9 +206,6 @@ var/global/list/ghdel_profiling = list()
if(T)
T.densityChanged()
/atom/proc/bumped_by_firebird(var/obj/structure/bed/chair/vehicle/firebird/F)
return Bumped(F)
// Convenience proc to see if a container is open for chemistry handling
// returns true if open
// false if closed

View File

@@ -1193,3 +1193,13 @@
target = get_turf(target_loc)
current_tick = 1
/atom/movable/proc/speen(times = 4)
set waitfor = FALSE
var/prev_dir = dir
for(var/i in 1 to times)
for(var/new_dir in cardinal)
change_dir(new_dir)
sleep(1)
change_dir(prev_dir)

View File

@@ -141,7 +141,7 @@
/obj/item/stack/tile/mineral/phazon/adjust_slowdown(mob/living/L, current_slowdown)
current_slowdown *= 0.75
..()
return ..()
/obj/item/stack/tile/mineral/brass
name = "brass tile"

View File

@@ -13,6 +13,16 @@
if(slip_n_slide(M))
M.simple_message("<span class='notice'>You slipped on the [name]!</span>",
"<span class='userdanger'>Something is scratching at your feet! Oh god!</span>")
if(istype(AM, /obj/structure/bed/chair/vehicle/gokart))
var/obj/structure/bed/chair/vehicle/gokart/kart = AM
var/left_or_right = prob(50) ? turn(kart.dir, 90) : turn(kart.dir, -90)
var/tiles_to_slip = rand(round(potency/20, 1), round(potency/10, 1))
kart.speen()
playsound(src, 'sound/misc/slip.ogg', 50, 1, -3)
spawn()
for(var/i in 1 to tiles_to_slip)
step(kart, left_or_right)
sleep(1)
/datum/locking_category/banana_peel

View File

@@ -320,7 +320,9 @@
return 1
return 0
/obj/structure/table/bumped_by_firebird(obj/structure/bed/chair/vehicle/firebird/F)
/obj/structure/table/Bumped(atom/movable/AM)
..()
if(istype(AM, /obj/structure/bed/chair/vehicle/firebird))
destroy()
//checks if projectile 'P' from turf 'from' can hit whatever is behind the table. Returns 1 if it can, 0 if bullet stops.
@@ -778,7 +780,9 @@ obj/structure/table/plastic
return 1
return !density
/obj/structure/rack/bumped_by_firebird(obj/structure/bed/chair/vehicle/firebird/F)
/obj/structure/rack/Bumped(atom/movable/AM)
..()
if(istype(AM, /obj/structure/bed/chair/vehicle/firebird))
destroy()
/obj/structure/rack/attackby(obj/item/weapon/W as obj, mob/user as mob)

View File

@@ -29,7 +29,7 @@
plane = ABOVE_HUMAN_PLANE
pass_flags = PASSMOB|PASSDOOR
wreckage_type = /obj/effect/decal/mecha_wreckage/vehicle/firebird
explodes_fueltanks = TRUE
var/datum/effect/effect/system/trail/firebird/ion_trail
/obj/structure/bed/chair/vehicle/firebird/New()
@@ -61,12 +61,6 @@
/obj/structure/bed/chair/vehicle/firebird/handle_layer()
return
/obj/structure/bed/chair/vehicle/firebird/to_bump(var/atom/obstacle)
if(throwing)
return ..()
else
return obstacle.bumped_by_firebird(src) //Yep
/obj/structure/bed/chair/vehicle/firebird/santa
name = "magic snowmobile"
desc = "After a complaint from space PETA, santa's been forced to take a less elegant ride."

View File

@@ -12,6 +12,13 @@
noghostspin = 0
can_have_carts = FALSE
wreckage_type = /obj/effect/decal/mecha_wreckage/vehicle/gokart
explodes_fueltanks = TRUE
/obj/structure/bed/chair/vehicle/gokart/getMovementDelay()
. = ..()
var/turf/here = get_turf(src)
if(here)
return here.adjust_slowdown(src, .)
/obj/structure/bed/chair/vehicle/gokart/unlock_atom(var/atom/movable/AM)
. = ..()

View File

@@ -60,6 +60,7 @@
var/list/datum/action/vehicle_actions = list()
var/headlights = FALSE
var/explodes_fueltanks = FALSE
/obj/structure/bed/chair/vehicle/proc/getMovementDelay()
return movement_delay
@@ -421,8 +422,8 @@
if(!.)
return
AM.pixel_x -= offsets["[dir]"]["x"]
AM.pixel_y -= offsets["[dir]"]["y"]
AM.pixel_x = initial(AM.pixel_x)
AM.pixel_y = initial(AM.pixel_y)
last_dir = null

View File

@@ -42,11 +42,7 @@
/datum/emote/spin/run_emote(mob/user)
. = ..()
if(.)
var/prev_dir = user.dir
for(var/i in list(1, 4, 2, 8, 1, 4, 2, 8, 1, 4, 2, 8, 1, 4, 2, 8))
user.dir = i
sleep(1)
user.dir = prev_dir
user.speen()
/datum/emote/me
key = "me"

View File

@@ -194,8 +194,12 @@
if(exposed_temperature >= AUTOIGNITION_WELDERFUEL)
explode()
/obj/structure/reagent_dispensers/fueltank/bumped_by_firebird(var/obj/structure/bed/chair/vehicle/firebird/F)
visible_message("<span class='danger'>\the [F] crashes into \the [src]!</span>")
/obj/structure/reagent_dispensers/fueltank/Bumped(atom/movable/AM)
..()
if(istype(AM, /obj/structure/bed/chair/vehicle))
var/obj/structure/bed/chair/vehicle/car = AM
if(car.explodes_fueltanks)
visible_message("<span class='danger'>\The [car] crashes into \the [src]!</span>")
explode()
/obj/structure/reagent_dispensers/fueltank/proc/explode()