From 0aa3ce39e487874059edbc81aee9e44e6641ccb0 Mon Sep 17 00:00:00 2001 From: supersayu Date: Sat, 31 Aug 2013 23:53:33 -0400 Subject: [PATCH] Bugfixen Modifies Adjacent() for items, to allow items to be accessed properly inside each other and the user. This fixes a few bugs seen in testing. Sets a maximum telekinesis range (in case you were using cameras). The telekinetic grab now does nothing at all in melee combat. This prevents double messages where you attack them with the object telekinetically, and then also attack them with the telekinetic grab. Crayons had a bug where they were drawing at all distances. This is because in old click code, afterattack() only happened at range when you had the USE_DELAY flag, which is no longer true. Proper behavior is to use parameter 3 (proximity_flag), which is 1 when adjacent or 0 if inaccessible. --- code/_onclick/adjacent.dm | 10 ++++++++++ code/_onclick/click.dm | 8 +++++--- code/_onclick/item_attack.dm | 2 +- code/_onclick/telekinesis.dm | 6 +----- code/game/objects/items/crayons.dm | 3 ++- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/code/_onclick/adjacent.dm b/code/_onclick/adjacent.dm index aca9b94fff2..d866878c45f 100644 --- a/code/_onclick/adjacent.dm +++ b/code/_onclick/adjacent.dm @@ -61,12 +61,22 @@ This is not used in stock /tg/station currently. */ /atom/movable/Adjacent(var/atom/neighbor) + if(neighbor == loc) return 1 if(!isturf(loc)) return 0 for(var/turf/T in locs) if(isnull(T)) continue if(T.Adjacent(neighbor,src)) return 1 return 0 +// This is necessary for storage items not on your person. +/obj/item/Adjacent(var/atom/neighbor, var/recurse = 1) + if(neighbor == loc) return 1 + if(istype(loc,/obj/item)) + if(recurse > 0) + return loc.Adjacent(neighbor,recurse - 1) + return 0 + return ..() + /* This checks if you there is uninterrupted airspace between that turf and this one. This is defined as any dense ON_BORDER object, or any dense object without throwpass. diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 317604cad6c..ce716bcfe7b 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -153,13 +153,13 @@ // Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example) var/resolved = A.attackby(W,src) if(!resolved && A && W) - W.afterattack(A,src,1,params) + W.afterattack(A,src,1,params) // 1: clicking something Adjacent else UnarmedAttack(A) return else // non-adjacent click if(W) - W.afterattack(A,src,0,params) + W.afterattack(A,src,0,params) // 0: not Adjacent else if((LASER in mutations) && a_intent == "harm") LaserEyes(A) // moved into a proc below @@ -169,8 +169,10 @@ next_move += 2 if(5 to 7) next_move += 5 - if(8 to 1024) + if(8 to 15) next_move += 10 + if(16 to 128) + return A.attack_tk(src) return diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 32e022712ad..25ccdb506b4 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -17,7 +17,7 @@ // Proximity_flag is 1 if this afterattack was called on something adjacent, in your square, or on your person. // Click parameters is the params string from byond Click() code, see that documentation. -/obj/item/proc/afterattack(atom/target,mob/user,proximity_flag,click_parameters) +/obj/item/proc/afterattack(atom/target, mob/user, proximity_flag, click_parameters) return diff --git a/code/_onclick/telekinesis.dm b/code/_onclick/telekinesis.dm index 9e48c75e00e..247ebce905b 100644 --- a/code/_onclick/telekinesis.dm +++ b/code/_onclick/telekinesis.dm @@ -109,11 +109,7 @@ return attack(mob/living/M as mob, mob/living/user as mob, def_zone) - if(focus && focus.Adjacent(M)) - if(istype(focus,/obj/item)) - var/obj/item/I = focus - I.attack(M,user,def_zone) - return + return proc/focus_object(var/obj/target, var/mob/living/user) diff --git a/code/game/objects/items/crayons.dm b/code/game/objects/items/crayons.dm index 27b38ac5f0c..84f22b6932a 100644 --- a/code/game/objects/items/crayons.dm +++ b/code/game/objects/items/crayons.dm @@ -65,7 +65,8 @@ shadeColour = input(user, "Please select the shade colour.", "Crayon colour") as color return -/obj/item/toy/crayon/afterattack(atom/target, mob/user as mob) +/obj/item/toy/crayon/afterattack(atom/target, mob/user as mob, flag) + if(!flag) return if(istype(target,/turf/simulated/floor)) var/drawtype = input("Choose what you'd like to draw.", "Crayon scribbles") in list("graffiti","rune","letter") switch(drawtype)