From b903680fbdfc46d42450505b0fb68c306b60a52e Mon Sep 17 00:00:00 2001 From: "elly1989@rocketmail.com" Date: Fri, 28 Sep 2012 06:45:57 +0000 Subject: [PATCH] Changed client/verb/a_intent_change() to mob/verb/a_intent_change() Replaced usr references with mob This means it can be called as a proc for any mob to use that code. Updated the click-procs to use this as they were using slightly different code. Fixed an issue with AIs using the intent hotkeys Added more sanity checks to it. Insert key uses the same code as other hotkeys. Commented out some unused hud-code from when we had separate intent buttons. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4766 316c924e-a436-60f5-8080-3fe189b3f50e --- code/modules/mob/mob_movement.dm | 29 ----------------------- code/modules/mob/screen.dm | 27 ++++----------------- interface/interface.dm | 40 ++++++++++++++++++++------------ interface/skin.dmf | 4 ++-- 4 files changed, 31 insertions(+), 69 deletions(-) diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 0f386d734f0..2e30d1ac16c 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -57,35 +57,6 @@ usr << "\red This mob type cannot drop items." return -//This gets called when you press the insert button. -/client/verb/insert_key_pressed() - set hidden = 1 - - if(!src.mob) - return - var/mob/M = src.mob - if(ishuman(M) || ismonkey(M) || istype(M,/mob/living/carbon/alien/humanoid) || islarva(M)) - switch(M.a_intent) - if("help") - usr.a_intent = "disarm" - usr.hud_used.action_intent.icon_state = "disarm" - if("disarm") - usr.a_intent = "grab" - usr.hud_used.action_intent.icon_state = "grab" - if("grab") - usr.a_intent = "hurt" - usr.hud_used.action_intent.icon_state = "harm" - if("hurt") - usr.a_intent = "help" - usr.hud_used.action_intent.icon_state = "help" - else if(isrobot(usr)) - if(usr.a_intent == "help") - usr.a_intent = "hurt" - usr.hud_used.action_intent.icon_state = "harm" - else - usr.a_intent = "help" - usr.hud_used.action_intent.icon_state = "help" - //This gets called when you press the delete button. /client/verb/delete_key_pressed() set hidden = 1 diff --git a/code/modules/mob/screen.dm b/code/modules/mob/screen.dm index 244743fe573..4a197a606a2 100644 --- a/code/modules/mob/screen.dm +++ b/code/modules/mob/screen.dm @@ -249,6 +249,7 @@ */ /obj/screen/Click(location, control, params) + if(!usr) return switch(name) if("map") usr.clearmap() @@ -357,28 +358,8 @@ else usr << "\blue You don't have an oxygen tank." if("act_intent") - if(ishuman(usr) || istype(usr,/mob/living/carbon/alien/humanoid) || islarva(usr)) - switch(usr.a_intent) - if("help") - usr.a_intent = "disarm" - usr.hud_used.action_intent.icon_state = "intent_disarm" - if("disarm") - usr.a_intent = "grab" - usr.hud_used.action_intent.icon_state = "intent_grab" - if("grab") - usr.a_intent = "hurt" - usr.hud_used.action_intent.icon_state = "intent_hurt" - if("hurt") - usr.a_intent = "help" - usr.hud_used.action_intent.icon_state = "intent_help" - if(issilicon(usr)) - if(usr.a_intent == "help") - usr.a_intent = "hurt" - usr.hud_used.action_intent.icon_state = "harm" - else - usr.a_intent = "help" - usr.hud_used.action_intent.icon_state = "help" - if("help") + usr.a_intent_change("right") +/* if("help") usr.a_intent = "help" usr.hud_used.action_intent.icon_state = "help" usr.hud_used.show_intent_icons = 0 @@ -393,7 +374,7 @@ if("disarm") usr.a_intent = "disarm" usr.hud_used.action_intent.icon_state = "disarm" - usr.hud_used.show_intent_icons = 0 + usr.hud_used.show_intent_icons = 0 */ if("pull") usr.stop_pulling() if("throw") diff --git a/interface/interface.dm b/interface/interface.dm index 1d5333778d9..21cc0e43d7b 100644 --- a/interface/interface.dm +++ b/interface/interface.dm @@ -1,3 +1,4 @@ +//Please use mob or src (not usr) in these procs. This way they can be called in the same fashion as procs. /client/verb/wiki() set name = "wiki" set desc = "Visit the wiki." @@ -30,6 +31,7 @@ src << browse(file(RULES_FILE), "window=rules;size=480x320") #undef RULES_FILE +//converts intent-strings into numbers and back var/list/intents = list("help","disarm","grab","hurt") /proc/intent_numeric(argument) if(istext(argument)) @@ -45,33 +47,35 @@ var/list/intents = list("help","disarm","grab","hurt") if(2) return "grab" else return "hurt" - -/client/verb/a_intent_change(input as text) +//change a mob's act-intent. Input the intent as a string such as "help" or use "right"/"left +/mob/verb/a_intent_change(input as text) set name = "a-intent" set hidden = 1 - if(ishuman(usr) || istype(usr,/mob/living/carbon/alien/humanoid) || islarva(usr)) + if(ishuman(src) || istype(src,/mob/living/carbon/alien/humanoid)) switch(input) if("help","disarm","grab","hurt") - usr.a_intent = input + a_intent = input if("right") - usr.a_intent = intent_numeric((intent_numeric(usr.a_intent)+1) % 4) + a_intent = intent_numeric((intent_numeric(a_intent)+1) % 4) if("left") - usr.a_intent = intent_numeric((intent_numeric(usr.a_intent)+3) % 4) - usr.hud_used.action_intent.icon_state = "intent_[usr.a_intent]" + a_intent = intent_numeric((intent_numeric(a_intent)+3) % 4) + if(hud_used && hud_used.action_intent) + hud_used.action_intent.icon_state = "intent_[a_intent]" - else if(issilicon(usr)) + else if(isrobot(src) || ismonkey(src) || islarva(src)) switch(input) if("help") - usr.a_intent = "help" + a_intent = "help" if("hurt") - usr.a_intent = "hurt" + a_intent = "hurt" if("right","left") - usr.a_intent = intent_numeric(intent_numeric(usr.a_intent) - 3) - if(usr.a_intent == "hurt") - usr.hud_used.action_intent.icon_state = "harm" - else - usr.hud_used.action_intent.icon_state = "help" + a_intent = intent_numeric(intent_numeric(a_intent) - 3) + if(hud_used && hud_used.action_intent) + if(a_intent == "hurt") + hud_used.action_intent.icon_state = "harm" + else + hud_used.action_intent.icon_state = "help" /client/verb/hotkeys_help() @@ -116,6 +120,12 @@ Any-Mode: (hotkey doesn't need to be on) \tCtrl+2 = disarm-intent \tCtrl+3 = grab-intent \tCtrl+4 = harm-intent +\tDEL = pull +\tINS = cycle-intents-right +\tHOME = drop +\tPGUP = swap-hand +\tPGDN = activate held object +\tEND = throw "} var/admin = {" diff --git a/interface/skin.dmf b/interface/skin.dmf index efed0da1e51..c151fdd1858 100644 --- a/interface/skin.dmf +++ b/interface/skin.dmf @@ -57,7 +57,7 @@ macro "macro" is-disabled = false elem name = "INSERT" - command = "insert-key-pressed" + command = "a-intent right" is-disabled = false elem name = "DELETE" @@ -223,7 +223,7 @@ macro "hotkeymode" is-disabled = false elem name = "INSERT" - command = "insert-key-pressed" + command = "a-intent right" is-disabled = false elem name = "DELETE"