mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
It'd be weird to have the top part of a ladder moved five tiles and then still lead to the ladder underneath its old location. Just destroys it instead.
131 lines
3.5 KiB
Plaintext
131 lines
3.5 KiB
Plaintext
/obj/structure/ladder
|
|
name = "ladder"
|
|
desc = "A sturdy metal ladder."
|
|
icon = 'icons/obj/structures.dmi'
|
|
icon_state = "ladder11"
|
|
var/id = null
|
|
var/height = 0 //the 'height' of the ladder. higher numbers are considered physically higher
|
|
var/obj/structure/ladder/down = null //the ladder below this one
|
|
var/obj/structure/ladder/up = null //the ladder above this one
|
|
var/auto_connect = FALSE
|
|
|
|
/obj/structure/ladder/unbreakable //mostly useful for awaymissions to prevent halting progress in a mission
|
|
name = "sturdy ladder"
|
|
desc = "An extremely sturdy metal ladder."
|
|
|
|
|
|
/obj/structure/ladder/Initialize(mapload)
|
|
GLOB.ladders += src
|
|
..()
|
|
return INITIALIZE_HINT_LATELOAD
|
|
|
|
/obj/structure/ladder/Destroy()
|
|
if(up && up.down == src)
|
|
up.down = null
|
|
up.update_icon()
|
|
if(down && down.up == src)
|
|
down.up = null
|
|
down.update_icon()
|
|
GLOB.ladders -= src
|
|
. = ..()
|
|
|
|
/obj/structure/ladder/LateInitialize()
|
|
for(var/obj/structure/ladder/L in GLOB.ladders)
|
|
if(L.id == id || (auto_connect && L.auto_connect && L.x == x && L.y == y))
|
|
if(L.height == (height - 1))
|
|
down = L
|
|
continue
|
|
if(L.height == (height + 1))
|
|
up = L
|
|
continue
|
|
|
|
if(up && down) //if both our connections are filled
|
|
break
|
|
update_icon()
|
|
|
|
|
|
/obj/structure/ladder/update_icon()
|
|
if(up && down)
|
|
icon_state = "ladder11"
|
|
|
|
else if(up)
|
|
icon_state = "ladder10"
|
|
|
|
else if(down)
|
|
icon_state = "ladder01"
|
|
|
|
else //wtf make your ladders properly assholes
|
|
icon_state = "ladder00"
|
|
|
|
/obj/structure/ladder/proc/travel(going_up, mob/user, is_ghost, obj/structure/ladder/ladder)
|
|
if(!is_ghost)
|
|
show_fluff_message(going_up,user)
|
|
ladder.add_fingerprint(user)
|
|
|
|
var/atom/movable/AM
|
|
if(user.pulling)
|
|
AM = user.pulling
|
|
user.pulling.forceMove(get_turf(ladder))
|
|
user.forceMove(get_turf(ladder))
|
|
if(AM)
|
|
user.start_pulling(AM)
|
|
|
|
|
|
/obj/structure/ladder/proc/use(mob/user,is_ghost=0)
|
|
if(up && down)
|
|
switch( alert("Go up or down the ladder?", "Ladder", "Up", "Down", "Cancel") )
|
|
if("Up")
|
|
travel(TRUE, user, is_ghost, up)
|
|
if("Down")
|
|
travel(FALSE, user, is_ghost, down)
|
|
if("Cancel")
|
|
return
|
|
else if(up)
|
|
travel(TRUE, user, is_ghost, up)
|
|
else if(down)
|
|
travel(FALSE, user,is_ghost, down)
|
|
else
|
|
to_chat(user, "<span class='warning'>[src] doesn't seem to lead anywhere!</span>")
|
|
|
|
if(!is_ghost)
|
|
add_fingerprint(user)
|
|
|
|
/obj/structure/ladder/attack_hand(mob/user)
|
|
if(can_use(user))
|
|
use(user)
|
|
|
|
/obj/structure/ladder/attack_paw(mob/user)
|
|
return attack_hand(user)
|
|
|
|
/obj/structure/ladder/attackby(obj/item/W, mob/user, params)
|
|
return attack_hand(user)
|
|
|
|
/obj/structure/ladder/attack_ghost(mob/dead/observer/user)
|
|
use(user,1)
|
|
|
|
/obj/structure/ladder/proc/show_fluff_message(up,mob/user)
|
|
if(up)
|
|
user.visible_message("[user] climbs up \the [src].","<span class='notice'>You climb up \the [src].</span>")
|
|
else
|
|
user.visible_message("[user] climbs down \the [src].","<span class='notice'>You climb down \the [src].</span>")
|
|
|
|
/obj/structure/ladder/proc/can_use(mob/user)
|
|
return 1
|
|
|
|
/obj/structure/ladder/unbreakable/Destroy(force)
|
|
if(force)
|
|
. = ..()
|
|
else
|
|
return QDEL_HINT_LETMELIVE
|
|
|
|
/obj/structure/ladder/unbreakable/singularity_pull()
|
|
return
|
|
|
|
/obj/structure/ladder/auto_connect //They will connect to ladders with the same X and Y without needing to share an ID
|
|
auto_connect = TRUE
|
|
|
|
|
|
/obj/structure/ladder/singularity_pull()
|
|
visible_message("<span class='danger'>[src] is torn to pieces by the gravitational pull!</span>")
|
|
qdel(src)
|