Directional Locking

This adds the ability to lock your mob towards facing either a certain
direction or a certain atom. Direction is done by shift-middleclick,
atom is done by shift-ctrl-middleclick.
This commit is contained in:
tigercat2000
2018-04-19 19:01:29 -08:00
parent 604f26f2ec
commit caccc13e82
4 changed files with 56 additions and 0 deletions
+32
View File
@@ -70,6 +70,12 @@
changeNext_click(1)
var/list/modifiers = params2list(params)
if(modifiers["middle"] && modifiers["shift"] && modifiers["ctrl"])
MiddleShiftControlClickOn(A)
return
if(modifiers["middle"] && modifiers["shift"])
MiddleShiftClickOn(A)
return
if(modifiers["shift"] && modifiers["ctrl"])
CtrlShiftClickOn(A)
return
@@ -225,6 +231,32 @@
else
..()
/*
Middle shift-click
Makes the mob face the direction of the clicked thing
*/
/mob/proc/MiddleShiftClickOn(atom/A)
var/face_dir = get_cardinal_dir(src, A)
if(forced_look == face_dir)
forced_look = null
to_chat(src, "<span class='notice'>You are no longer facing any direction.</span>")
return
forced_look = face_dir
to_chat(src, "<span class='notice'>You are now facing [dir2text(forced_look)].</span>")
/*
Middle shift-control-click
Makes the mob constantly face the object (until it's out of sight)
*/
/mob/proc/MiddleShiftControlClickOn(atom/A)
var/face_uid = A.UID()
if(forced_look == face_uid)
forced_look = null
to_chat(src, "<span class='notice'>You are no longer facing [A].</span>")
return
forced_look = face_uid
to_chat(src, "<span class='notice'>You are now facing [A].</span>")
// In case of use break glass
/*
/atom/proc/MiddleClick(var/mob/M as mob)
+20
View File
@@ -170,6 +170,15 @@
return 0
/mob/proc/Life()
if(forced_look)
if(!isnum(forced_look))
var/atom/A = locateUID(forced_look)
if(istype(A))
if(get_dist(src, A) > (client ? client.view : world.view))
forced_look = null
to_chat(src, "<span class='notice'>Your direction target has left your view, you are no longer facing anything.</span>")
return
setDir()
// handle_typing_indicator()
return
@@ -533,6 +542,17 @@ var/list/slot_equipment_priority = list( \
client.screen = list()
hud_used.show_hud(hud_used.hud_version)
/mob/setDir(new_dir)
if(forced_look)
if(isnum(forced_look))
dir = forced_look
else
var/atom/A = locateUID(forced_look)
if(istype(A))
dir = get_cardinal_dir(src, A)
return
. = ..()
/mob/proc/show_inv(mob/user)
user.set_machine(src)
var/dat = {"<table>
+2
View File
@@ -199,3 +199,5 @@
var/list/progressbars = null //for stacking do_after bars
var/list/tkgrabbed_objects = list() // Assoc list of items to TK grabs
var/forced_look = null // This can either be a numerical direction or a soft object reference (UID). It makes the mob always face towards the selected thing.
+2
View File
@@ -268,6 +268,8 @@
else
. = ..()
mob.setDir(direct)
for(var/obj/item/grab/G in mob)
if(G.state == GRAB_NECK)
mob.setDir(reverse_dir[direct])