Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Add look up verb for multi-z (tgstation#50782)
Browse files Browse the repository at this point in the history
* Add look up verb

* Made requested changes

* Added a toggle

* Removed redundant arg from signal

* Update code/modules/mob/living/living.dm

Co-authored-by: Rohesie <[email protected]>

* Update code/modules/mob/living/living.dm

Co-authored-by: Rohesie <[email protected]>

* Adds keybinding description

* Removed unused signal

Co-authored-by: Rohesie <[email protected]>
  • Loading branch information
Koshenko and Rohesie authored May 3, 2020
1 parent cbc0179 commit a3ac168
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#define CLICK_CD_HANDCUFFED 10
#define CLICK_CD_RESIST 20
#define CLICK_CD_GRABBING 10
#define CLICK_CD_LOOK_UP 5

//Cuff resist speeds
#define FAST_CUFFBREAK 1
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@

// /mob/living signals
#define COMSIG_LIVING_RESIST "living_resist" //from base of mob/living/resist() (/mob/living)
#define COMSIG_LIVING_LOOK_UP "living_look_up" //from base of mob/living/look_up() (/mob/living)
#define COMSIG_LIVING_IGNITED "living_ignite" //from base of mob/living/IgniteMob() (/mob/living)
#define COMSIG_LIVING_EXTINGUISHED "living_extinguished" //from base of mob/living/ExtinguishMob() (/mob/living)
#define COMSIG_LIVING_ELECTROCUTE_ACT "living_electrocute_act" //from base of mob/living/electrocute_act(): (shock_damage, source, siemens_coeff, flags)
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ GLOBAL_LIST_INIT(turfs_without_ground, typecacheof(list(

#define isplatingturf(A) (istype(A, /turf/open/floor/plating))

#define isopenspace(A) (istype(A, /turf/open/openspace))

//Mobs
#define isliving(A) (istype(A, /mob/living))

Expand Down
16 changes: 16 additions & 0 deletions code/datums/keybinding/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@
var/mob/living/L = user.mob
L.resist()
return TRUE

/datum/keybinding/living/look_up
hotkey_keys = list("L")
name = "look up"
full_name = "Look Up"
description = "Look up at the next z-level. Only works if directly below open space."

/datum/keybinding/living/look_up/down(client/user)
var/mob/living/L = user.mob
L.look_up()
return TRUE

/datum/keybinding/living/look_up/up(client/user)
var/mob/living/L = user.mob
L.stop_look_up()
return TRUE
33 changes: 33 additions & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1495,3 +1495,36 @@
if(!apply_change)
return BODYTEMP_NORMAL
return BODYTEMP_NORMAL + get_body_temp_normal_change()

///Checks if the user is incapacitated or on cooldown.
/mob/living/proc/can_look_up()
return !((next_move > world.time) || incapacitated(ignore_restraints = TRUE))

/**
* look_up Changes the perspective of the mob to any openspace turf above the mob
*
* This also checks if an openspace turf is above the mob before looking up or resets the perspective if already looking up
*
*/
/mob/living/proc/look_up()

if(client.perspective != MOB_PERSPECTIVE) //We are already looking up.
stop_look_up()
return
if(!can_look_up())
return
var/turf/ceiling = get_step_multiz(src, UP)
if(!ceiling) //We are at the highest z-level.
to_chat(src, "<span class='warning'>You can't see through the ceiling above you.</span>")
return
else if(!isopenspace(ceiling)) //There is no openspace turf above us.
to_chat(src, "<span class='warning'>You can't see through the floor above you.</span>")
return

changeNext_move(CLICK_CD_LOOK_UP)
reset_perspective(ceiling)
RegisterSignal(src, COMSIG_MOVABLE_PRE_MOVE, .proc/stop_look_up) //We stop looking up if we move.

/mob/living/proc/stop_look_up()
reset_perspective()
UnregisterSignal(src, COMSIG_MOVABLE_PRE_MOVE)

0 comments on commit a3ac168

Please sign in to comment.