Merge pull request #7204 from Crazylemon64/tk_refactor

Tk refactor+Remote tool use
This commit is contained in:
Fox McCloud
2017-06-26 16:55:04 -04:00
committed by GitHub
20 changed files with 200 additions and 122 deletions
+3 -3
View File
@@ -73,7 +73,7 @@
temp = pick(graffiti)
else
temp = href_list["type"]
if((usr.restrained() || usr.stat || usr.get_active_hand() != src))
if((usr.restrained() || usr.stat || !usr.is_in_active_hand(src)))
return
drawtype = temp
update_window(usr)
@@ -167,7 +167,7 @@
..()
/obj/item/toy/crayon/mime/Topic(href,href_list)
if((usr.restrained() || usr.stat || usr.get_active_hand() != src))
if((usr.restrained() || usr.stat || usr.is_in_active_hand(src)))
return
if(href_list["color"])
if(colour != "#FFFFFF")
@@ -195,7 +195,7 @@
if(href_list["color"])
var/temp = input(usr, "Please select colour.", "Crayon colour") as color
if((usr.restrained() || usr.stat || usr.get_active_hand() != src))
if((usr.restrained() || usr.stat || usr.is_in_active_hand(src)))
return
colour = temp
update_window(usr)
+1 -1
View File
@@ -55,7 +55,7 @@ var/global/list/datum/stack_recipe/rod_recipes = list ( \
"<span class='notice'>You shape [src] into metal with the welding tool.</span>", \
"<span class='italics'>You hear welding.</span>")
var/replace = user.get_inactive_hand() == src
var/replace = user.is_in_inactive_hand(src)
use(2)
if(get_amount() <= 0 && replace)
user.unEquip(src, 1)
+26 -8
View File
@@ -36,6 +36,23 @@
/obj/item/stack/attack_self(mob/user)
list_recipes(user)
/obj/item/stack/attack_self_tk(mob/user)
list_recipes(user)
/obj/item/stack/attack_tk(mob/user)
if(user.stat || !isturf(loc)) return
// Allow remote stack splitting, because telekinetic inventory managing
// is really cool
if(src in user.tkgrabbed_objects)
var/obj/item/stack/F = split(user, 1)
F.attack_tk(user)
if(src && user.machine == src)
spawn(0)
interact(user)
else
..()
/obj/item/stack/proc/list_recipes(mob/user, recipes_sublist)
if(!recipes)
return
@@ -107,7 +124,7 @@
/obj/item/stack/Topic(href, href_list)
..()
if(usr.incapacitated() || usr.get_active_hand() != src)
if(usr.incapacitated() || !usr.is_in_active_hand(src))
return 0
if(href_list["sublist"] && !href_list["make"])
@@ -124,6 +141,7 @@
var/datum/stack_recipe/R = recipes_list[text2num(href_list["make"])]
var/multiplier = text2num(href_list["multiplier"])
var/atom/creation_loc = (loc == usr) ? usr.loc : loc
if(!multiplier)
multiplier = 1
@@ -134,11 +152,11 @@
to_chat(usr, "<span class='warning'>You haven't got enough [src] to build \the [R.title]!</span>")
return 0
if(R.one_per_turf && (locate(R.result_type) in usr.loc))
if(R.one_per_turf && (locate(R.result_type) in creation_loc))
to_chat(usr, "<span class='warning'>There is another [R.title] here!</span>")
return 0
if(R.on_floor && !istype(usr.loc, /turf/simulated))
if(R.on_floor && !istype(creation_loc, /turf/simulated))
to_chat(usr, "<span class='warning'>\The [R.title] must be constructed on the floor!</span>")
return 0
@@ -150,7 +168,7 @@
if(amount < R.req_amount * multiplier)
return
var/atom/O = new R.result_type(usr.loc)
var/atom/O = new R.result_type(creation_loc)
O.dir = usr.dir
if(R.max_res_amount > 1)
var/obj/item/stack/new_item = O
@@ -215,7 +233,7 @@
return max_amount
/obj/item/stack/proc/split(mob/user, amt)
var/obj/item/stack/F = new type(user, amt)
var/obj/item/stack/F = new type(loc, amt)
F.copy_evidences(src)
if(isliving(user))
add_fingerprint(user)
@@ -224,7 +242,7 @@
return F
/obj/item/stack/attack_hand(mob/user)
if(user.get_inactive_hand() == src)
if(user.is_in_inactive_hand(src))
var/obj/item/stack/F = split(user, 1)
user.put_in_hands(F)
if(src && usr.machine == src)
@@ -241,7 +259,7 @@
return 1
var/to_transfer
if(user.get_inactive_hand() == src)
if(user.is_in_inactive_hand(src))
var/desired = input("How much would you like to transfer from this stack?", "How much?", 1) as null|num
if(!desired)
return
@@ -267,4 +285,4 @@
fingerprints = from.fingerprints
fingerprintshidden = from.fingerprintshidden
fingerprintslast = from.fingerprintslast
//TODO bloody overlay
//TODO bloody overlay
+3
View File
@@ -84,6 +84,9 @@ RCD
//Change the mode
ui_interact(user)
/obj/item/weapon/rcd/attack_self_tk(mob/user)
ui_interact(user)
/obj/item/weapon/rcd/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = inventory_state)
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
@@ -61,7 +61,7 @@
nadeassembly.attack_self(user)
return
var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num
if(user.get_active_hand() == src)
if(user.is_in_active_hand(src))
newtime = Clamp(newtime, 10, 60000)
det_time = newtime
to_chat(user, "Timer set for [det_time] seconds.")
@@ -62,7 +62,7 @@
/obj/item/weapon/flamethrower/afterattack(atom/target, mob/user, flag)
if(flag) return // too close
// Make sure our user is still holding us
if(user && user.get_active_hand() == src)
if(user && user.is_in_active_hand(src))
var/turf/target_turf = get_turf(target)
if(target_turf)
var/turflist = getline(user, target_turf)
@@ -32,7 +32,7 @@
/*/obj/item/weapon/grenade/afterattack(atom/target as mob|obj|turf|area, mob/user as mob)
if(istype(target, /obj/item/weapon/storage)) return ..() // Trying to put it in a full container
if(istype(target, /obj/item/weapon/gun/grenadelauncher)) return ..()
if((user.get_active_hand() == src) && (!active) && (clown_check(user)) && target.loc != src.loc)
if((user.is_in_active_hand(src)) && (!active) && (clown_check(user)) && target.loc != src.loc)
to_chat(user, "<span class='warning'>You prime the [name]! [det_time/10] seconds!</span>")
active = 1
icon_state = initial(icon_state) + "_active"
@@ -478,7 +478,7 @@
/obj/item/weapon/storage/attack_self(mob/user as mob)
//Clicking on itself will empty it, if it has the verb to do that.
if(user.get_active_hand() == src)
if(user.is_in_active_hand(src))
if(src.verbs.Find(/obj/item/weapon/storage/verb/quick_empty))
src.quick_empty()
return
@@ -128,7 +128,7 @@ Frequency:
if(turfs.len)
L["None (Dangerous)"] = pick(turfs)
var/t1 = input(user, "Please select a teleporter to lock in on.", "Hand Teleporter") as null|anything in L
if(!t1 || (user.get_active_hand() != src || user.stat || user.restrained()))
if(!t1 || (user.is_in_active_hand(src) || user.stat || user.restrained()))
return
if(active_portals >= 3)
user.show_message("<span class='notice'>\The [src] is recharging!</span>")