Hand refactor (#10045)

* hand refactor (COMPILES)

* Works pretty much

* Test martians

* Martians

* Fix human UI

* Fix find_organ_by_grasp_index() returning arms

* CL + tweaks

* Last fixes

* a

* Better CL

* Fix weird issue!

* Fix virologist job

* Resolves a very important issue

* I thought I had already fixed this

oh well

* Fix grabs

* Shat
This commit is contained in:
unid15
2016-06-05 09:33:12 +02:00
committed by clusterfack
parent e5bbbcf787
commit 75d79b3c23
137 changed files with 1652 additions and 1225 deletions

View File

@@ -89,10 +89,7 @@
if(W.flags&USEDELAY)
next_move += 5*/
W.attack_self(src, params)
if(hand)
update_inv_l_hand(0)
else
update_inv_r_hand(0)
update_inv_hand(active_hand)
return

View File

@@ -209,3 +209,6 @@
#define ui_blob_ping "EAST-1:24,CENTER+3:21"
#define ui_blob_rally "EAST-1:24,CENTER+4:25"
#define ui_blob_taunt "EAST-1:24,CENTER+5:29"
//Layers
#define UI_HAND_LAYER 19

View File

@@ -96,31 +96,7 @@
inv_box.layer = 19
src.adding += inv_box
inv_box = getFromPool(/obj/screen/inventory)
inv_box.name = "r_hand"
inv_box.dir = WEST
inv_box.icon = 'icons/mob/screen1_alien.dmi'
inv_box.icon_state = "hand_inactive"
if(mymob && !mymob.hand) //This being 0 or null means the right hand is in use
using.icon_state = "hand_active"
inv_box.screen_loc = ui_rhand
inv_box.layer = 19
src.r_hand_hud_object = inv_box
inv_box.slot_id = slot_r_hand
src.adding += inv_box
inv_box = getFromPool(/obj/screen/inventory)
inv_box.name = "l_hand"
inv_box.dir = EAST
inv_box.icon = 'icons/mob/screen1_alien.dmi'
inv_box.icon_state = "hand_inactive"
if(mymob && mymob.hand) //This being 1 means the left hand is in use
inv_box.icon_state = "hand_active"
inv_box.screen_loc = ui_lhand
inv_box.layer = 19
inv_box.slot_id = slot_l_hand
src.l_hand_hud_object = inv_box
src.adding += inv_box
init_hand_icons('icons/mob/screen1_alien.dmi')
using = getFromPool(/obj/screen/inventory)
using.name = "hand"

View File

@@ -20,8 +20,7 @@ var/global/obj/screen/clicker/catcher = new()
var/obj/screen/lingchemdisplay
var/obj/screen/vampire_blood_display // /vg/
var/obj/screen/r_hand_hud_object
var/obj/screen/l_hand_hud_object
var/list/obj/screen/hand_hud_objects = list()
var/obj/screen/action_intent
var/obj/screen/move_intent
@@ -44,8 +43,7 @@ var/global/obj/screen/clicker/catcher = new()
help_intent = null
lingchemdisplay = null
vampire_blood_display = null
r_hand_hud_object = null
l_hand_hud_object = null
hand_hud_objects = null
action_intent = null
move_intent = null
adding = null
@@ -102,6 +100,52 @@ var/global/obj/screen/clicker/catcher = new()
if(H.l_store) H.l_store.screen_loc = null
if(H.r_store) H.r_store.screen_loc = null
/datum/hud/proc/init_hand_icons(var/new_icon, var/new_color, var/new_alpha)
for(var/i = 1 to mymob.held_items.len) //Hands
var/obj/screen/inventory/inv_box = getFromPool(/obj/screen/inventory)
inv_box.name = "[mymob.get_index_limb_name(i)]"
if(mymob.get_direction_by_index(i) == "right_hand")
inv_box.dir = WEST
else
inv_box.dir = EAST
inv_box.icon = new_icon ? new_icon : 'icons/mob/screen1_White.dmi'
inv_box.icon_state = "hand_inactive"
if(mymob && mymob.active_hand == i)
inv_box.icon_state = "hand_active"
inv_box.screen_loc = mymob.get_held_item_ui_location(i)
inv_box.slot_id = null
inv_box.hand_index = i
inv_box.layer = UI_HAND_LAYER
inv_box.color = new_color ? new_color : inv_box.color
inv_box.alpha = new_alpha ? new_alpha : inv_box.alpha
src.hand_hud_objects += inv_box
src.adding += inv_box
/datum/hud/proc/update_hand_icons()
var/obj/screen/inventory/example = locate(/obj/screen/inventory) in hand_hud_objects
var/new_icon = 'icons/mob/screen1_White.dmi'
var/new_color = null
var/new_alpha = 255
if(example)
new_icon = example.icon
new_color = example.color
new_alpha = example.alpha
for(var/obj/screen/inventory/IN in hand_hud_objects)
if(mymob.client)
adding -= IN
mymob.client.screen -= IN
returnToPool(IN)
if(mymob.client)
adding = list()
init_hand_icons(new_icon, new_color, new_alpha)
mymob.client.screen += adding
/datum/hud/proc/instantiate()
if(!ismob(mymob))
@@ -148,6 +192,7 @@ var/global/obj/screen/clicker/catcher = new()
construct_hud()
else if(isobserver(mymob))
ghost_hud()
if(isliving(mymob))
var/obj/screen/using
using = getFromPool(/obj/screen)
@@ -182,8 +227,7 @@ var/global/obj/screen/clicker/catcher = new()
//Due to some poor coding some things need special treatment:
//These ones are a part of 'adding', 'other' or 'hotkeybuttons' but we want them to stay
src.client.screen += src.hud_used.l_hand_hud_object //we want the hands to be visible
src.client.screen += src.hud_used.r_hand_hud_object //we want the hands to be visible
src.client.screen += src.hud_used.hand_hud_objects
src.client.screen += src.hud_used.action_intent //we want the intent swticher visible
src.hud_used.action_intent.screen_loc = ui_acti_alt //move this to the alternative position, where zone_select usually is.
@@ -225,16 +269,12 @@ var/global/obj/screen/clicker/catcher = new()
var/mob/living/L = mymob
if(L.shown_schematics_background && !clear)
if(!istype(R))
switch(L.hand)
if(1)
R = L.l_hand
if(!istype(R))
return
else
R = L.r_hand
if(!istype(R))
return
R = L.get_active_hand()
if(!istype(R))
return
if((!R.schematics || !R.schematics.len) && !override)
to_chat(usr, "<span class='danger'>This [R] has no schematics to choose from.</span>")
return

View File

@@ -113,36 +113,7 @@
inv_box.alpha = ui_alpha
src.other += inv_box
inv_box = getFromPool(/obj/screen/inventory)
inv_box.name = "r_hand"
inv_box.dir = WEST
inv_box.icon = ui_style
inv_box.icon_state = "hand_inactive"
if(mymob && !mymob.hand) //This being 0 or null means the right hand is in use
inv_box.icon_state = "hand_active"
inv_box.screen_loc = ui_rhand
inv_box.slot_id = slot_r_hand
inv_box.layer = 19
inv_box.color = ui_color
inv_box.alpha = ui_alpha
src.r_hand_hud_object = inv_box
src.adding += inv_box
inv_box = getFromPool(/obj/screen/inventory)
inv_box.name = "l_hand"
inv_box.dir = EAST
inv_box.icon = ui_style
inv_box.icon_state = "hand_inactive"
if(mymob && mymob.hand) //This being 1 means the left hand is in use
inv_box.icon_state = "hand_active"
inv_box.screen_loc = ui_lhand
inv_box.slot_id = slot_l_hand
inv_box.layer = 19
inv_box.color = ui_color
inv_box.alpha = ui_alpha
src.l_hand_hud_object = inv_box
src.adding += inv_box
init_hand_icons(ui_style, ui_color, ui_alpha)
using = getFromPool(/obj/screen/inventory)
using.name = "hand"

View File

@@ -0,0 +1,211 @@
/datum/hud/proc/martian_hud(var/ui_style='icons/mob/screen1_old.dmi')
src.adding = list()
src.other = list()
var/obj/screen/using
var/obj/screen/inventory/inv_box
using = getFromPool(/obj/screen)
using.name = "act_intent"
using.dir = SOUTHWEST
using.icon = ui_style
using.icon_state = (mymob.a_intent == I_HURT ? "harm" : mymob.a_intent)
using.screen_loc = ui_acti
using.layer = 20
src.adding += using
action_intent = using
//intent small hud objects
var/icon/ico
ico = new(ui_style, "black")
ico.MapColors(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, -1,-1,-1,-1)
ico.DrawBox(rgb(255,255,255,1),1,ico.Height()/2,ico.Width()/2,ico.Height())
using = getFromPool(/obj/screen,src)
using.name = "help"
using.icon = ico
using.screen_loc = ui_acti
using.layer = 21
src.adding += using
help_intent = using
ico = new(ui_style, "black")
ico.MapColors(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, -1,-1,-1,-1)
ico.DrawBox(rgb(255,255,255,1),ico.Width()/2,ico.Height()/2,ico.Width(),ico.Height())
using = getFromPool(/obj/screen,src)
using.name = "disarm"
using.icon = ico
using.screen_loc = ui_acti
using.layer = 21
src.adding += using
disarm_intent = using
ico = new(ui_style, "black")
ico.MapColors(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, -1,-1,-1,-1)
ico.DrawBox(rgb(255,255,255,1),ico.Width()/2,1,ico.Width(),ico.Height()/2)
using = getFromPool(/obj/screen,src)
using.name = "grab"
using.icon = ico
using.screen_loc = ui_acti
using.layer = 21
src.adding += using
grab_intent = using
ico = new(ui_style, "black")
ico.MapColors(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, -1,-1,-1,-1)
ico.DrawBox(rgb(255,255,255,1),1,1,ico.Width()/2,ico.Height()/2)
using = getFromPool(/obj/screen,src)
using.name = "harm"
using.icon = ico
using.screen_loc = ui_acti
using.layer = 21
src.adding += using
hurt_intent = using
//end intent small hud objects
using = getFromPool(/obj/screen)
using.name = "mov_intent"
using.dir = SOUTHWEST
using.icon = ui_style
using.icon_state = (mymob.m_intent == "run" ? "running" : "walking")
using.screen_loc = ui_movi
using.layer = 20
src.adding += using
move_intent = using
using = getFromPool(/obj/screen)
using.name = "drop"
using.icon = ui_style
using.icon_state = "act_drop"
using.screen_loc = ui_drop_throw
using.layer = 19
src.adding += using
init_hand_icons(ui_style)
#define ui_swaphand_martian1 "CENTER-1:16,SOUTH:5"
#define ui_swaphand_martian2 "CENTER:16,SOUTH:5"
using = getFromPool(/obj/screen/inventory)
using.name = "hand"
using.dir = SOUTH
using.icon = ui_style
using.icon_state = "hand1"
using.screen_loc = ui_swaphand_martian1
using.layer = 19
src.adding += using
using = getFromPool(/obj/screen/inventory)
using.name = "hand"
using.dir = SOUTH
using.icon = ui_style
using.icon_state = "hand2"
using.screen_loc = ui_swaphand_martian2
using.layer = 19
src.adding += using
#undef ui_swaphand_martian1
#undef ui_swaphand_martian2
using = getFromPool(/obj/screen)
using.name = "resist"
using.icon = ui_style
using.icon_state = "act_resist"
using.screen_loc = ui_pull_resist
using.layer = 19
src.adding += using
inv_box = getFromPool(/obj/screen/inventory)
inv_box.name = "head"
inv_box.icon = ui_style
inv_box.icon_state = "hair"
inv_box.screen_loc = ui_monkey_hat
inv_box.slot_id = slot_head
inv_box.layer = 19
src.adding += inv_box
mymob.throw_icon = getFromPool(/obj/screen)
mymob.throw_icon.icon = ui_style
mymob.throw_icon.icon_state = "act_throw_off"
mymob.throw_icon.name = "throw"
mymob.throw_icon.screen_loc = ui_drop_throw
mymob.oxygen = getFromPool(/obj/screen)
mymob.oxygen.icon = ui_style
mymob.oxygen.icon_state = "oxy0"
mymob.oxygen.name = "oxygen"
mymob.oxygen.screen_loc = ui_oxygen
mymob.pressure = getFromPool(/obj/screen)
mymob.pressure.icon = ui_style
mymob.pressure.icon_state = "pressure0"
mymob.pressure.name = "pressure"
mymob.pressure.screen_loc = ui_pressure
mymob.toxin = getFromPool(/obj/screen)
mymob.toxin.icon = ui_style
mymob.toxin.icon_state = "tox0"
mymob.toxin.name = "toxin"
mymob.toxin.screen_loc = ui_toxin
mymob.internals = getFromPool(/obj/screen)
mymob.internals.icon = ui_style
mymob.internals.icon_state = "internal0"
mymob.internals.name = "internal"
mymob.internals.screen_loc = ui_internal
mymob.fire = getFromPool(/obj/screen)
mymob.fire.icon = ui_style
mymob.fire.icon_state = "fire0"
mymob.fire.name = "fire"
mymob.fire.screen_loc = ui_fire
mymob.bodytemp = getFromPool(/obj/screen)
mymob.bodytemp.icon = ui_style
mymob.bodytemp.icon_state = "temp1"
mymob.bodytemp.name = "body temperature"
mymob.bodytemp.screen_loc = ui_temp
mymob.healths = getFromPool(/obj/screen)
mymob.healths.icon = ui_style
mymob.healths.icon_state = "health0"
mymob.healths.name = "health"
mymob.healths.screen_loc = ui_health
mymob.pullin = getFromPool(/obj/screen)
mymob.pullin.icon = ui_style
mymob.pullin.icon_state = "pull0"
mymob.pullin.name = "pull"
mymob.pullin.screen_loc = ui_pull_resist
mymob.zone_sel = getFromPool(/obj/screen/zone_sel)
mymob.zone_sel.icon = ui_style
mymob.zone_sel.overlays.len = 0
mymob.zone_sel.overlays += image('icons/mob/zone_sel.dmi', "[mymob.zone_sel.selecting]")
//Handle the gun settings buttons
mymob.gun_setting_icon = getFromPool(/obj/screen/gun/mode)
if (mymob.client)
if (mymob.client.gun_mode) // If in aim mode, correct the sprite
mymob.gun_setting_icon.dir = 2
for(var/obj/item/weapon/gun/G in mymob) // If targeting someone, display other buttons
if (G.target)
mymob.item_use_icon = getFromPool(/obj/screen/gun/item)
if (mymob.client.target_can_click)
mymob.item_use_icon.dir = 1
src.adding += mymob.item_use_icon
mymob.gun_move_icon = getFromPool(/obj/screen/gun/move)
if (mymob.client.target_can_move)
mymob.gun_move_icon.dir = 1
mymob.gun_run_icon = getFromPool(/obj/screen/gun/run)
if (mymob.client.target_can_run)
mymob.gun_run_icon.dir = 1
src.adding += mymob.gun_run_icon
src.adding += mymob.gun_move_icon
mymob.client.reset_screen()
mymob.client.screen += list( mymob.throw_icon, mymob.zone_sel, mymob.oxygen, mymob.pressure, mymob.toxin, mymob.bodytemp, mymob.internals, mymob.fire, mymob.healths, mymob.pullin, mymob.gun_setting_icon)
mymob.client.screen += src.adding + src.other

View File

@@ -84,15 +84,19 @@
using.layer = 19
src.adding += using
init_hand_icons(ui_style)
/*
inv_box = getFromPool(/obj/screen/inventory)
inv_box.name = "r_hand"
inv_box.dir = WEST
inv_box.icon = ui_style
inv_box.icon_state = "hand_inactive"
if(mymob && !mymob.hand) //This being 0 or null means the right hand is in use
if(mymob && mymob.active_hand == GRASP_RIGHT_HAND)
inv_box.icon_state = "hand_active"
inv_box.screen_loc = ui_rhand
inv_box.slot_id = slot_r_hand
inv_box.slot_id = null
inv_box.hand_index = GRASP_RIGHT_HAND
inv_box.layer = 19
src.r_hand_hud_object = inv_box
src.adding += inv_box
@@ -102,13 +106,15 @@
inv_box.dir = EAST
inv_box.icon = ui_style
inv_box.icon_state = "hand_inactive"
if(mymob && mymob.hand) //This being 1 means the left hand is in use
if(mymob && mymob.active_hand == GRASP_LEFT_HAND)
inv_box.icon_state = "hand_active"
inv_box.screen_loc = ui_lhand
inv_box.slot_id = slot_l_hand
inv_box.slot_id = null
inv_box.hand_index = GRASP_LEFT_HAND
inv_box.layer = 19
src.l_hand_hud_object = inv_box
src.adding += inv_box
*/
using = getFromPool(/obj/screen/inventory)
using.name = "hand"

View File

@@ -57,6 +57,7 @@
/obj/screen/inventory
var/slot_id //The indentifier for the slot. It has nothing to do with ID cards.
var/hand_index
/obj/screen/close
name = "close"
@@ -359,12 +360,16 @@
if(ishuman(C))
var/mob/living/carbon/human/H = C
breathes = H.species.breath_type
nicename = list ("suit", "back", "belt", "right hand", "left hand", "left pocket", "right pocket")
tankcheck = list (H.s_store, C.back, H.belt, C.r_hand, C.l_hand, H.l_store, H.r_store)
nicename = list ("suit", "back", "belt", "left pocket", "right pocket") //Hands are added below
tankcheck = list (H.s_store, C.back, H.belt, H.l_store, H.r_store)
else
nicename = list("Right Hand", "Left Hand", "Back")
tankcheck = list(C.r_hand, C.l_hand, C.back)
nicename = list("back")
tankcheck = list(C.back)
tankcheck = tankcheck + C.held_items
for(var/i = 1 to C.held_items.len)
nicename.Add(C.get_index_limb_name(i))
for(var/i=1, i<tankcheck.len+1, ++i)
if(istype(tankcheck[i], /obj/item/weapon/tank))
@@ -869,25 +874,18 @@
return 1
if (istype(usr.loc,/obj/mecha)) // stops inventory actions in a mech
return 1
if(hand_index)
usr.activate_hand(hand_index)
switch(name)
if("r_hand")
if(iscarbon(usr))
var/mob/living/carbon/C = usr
C.activate_hand("r")
//usr.next_move = world.time+2
if("l_hand")
if(iscarbon(usr))
var/mob/living/carbon/C = usr
C.activate_hand("l")
//usr.next_move = world.time+2
if("swap")
usr:swap_hand()
if("hand")
usr:swap_hand()
else
if(usr.attack_ui(slot_id))
usr.update_inv_l_hand(0)
usr.update_inv_r_hand(0)
usr.update_inv_hands()
usr.delayNextAttack(6)
return 1

View File

@@ -58,7 +58,7 @@
if(!requires_dexterity(user))
attack_hand(user) //if the object doesn't need dexterity, we can use our stump
else
to_chat(user, "Your [user.hand ? "left hand" : "right hand"] is not fine enough for this action.")
to_chat(user, "Your [user.get_index_limb_name(user.active_hand)] is not fine enough for this action.")
/atom/proc/requires_dexterity(mob/user)
return 0

View File

@@ -90,8 +90,8 @@ var/const/tk_maxrange = 15
//stops TK grabs being equipped anywhere but into hands
equipped(var/mob/user, var/slot)
if( (slot == slot_l_hand) || (slot== slot_r_hand) ) return
equipped(var/mob/user, var/slot, hand_index)
if(!hand_index) return
qdel(src)
return