Attack Proc fixes (#1259)

Baymerge changed the attack proc, i think by removing a default value, and a lot of things broke because they weren't using the function correctly.

This proc does three main things.

Adds a default to /obj/item/proc/attack to target the chest when no target zone is supplied.

Fixes the lack of a target zone in many attack procs, properly defining it so it'll get passed to the parent, and ensure that bodypart-specific targeting works.

Removes most instances of code to retrieve the user's selected zone, and instead to use the zone passed into the attack function. saves duplication of effort.
This commit is contained in:
NanakoAC
2016-12-24 03:34:23 +02:00
committed by skull132
parent b0ae247b01
commit 6cef8c9074
24 changed files with 67 additions and 64 deletions
+2 -2
View File
@@ -91,7 +91,7 @@
qdel(src)
return
/obj/item/weapon/pen/crayon/attack(mob/M as mob, mob/user as mob)
/obj/item/weapon/pen/crayon/attack(mob/M as mob, mob/user as mob, var/target_zone)
if(M == user)
user << "You take a bite of the crayon and swallow it."
user.nutrition += 1
@@ -102,4 +102,4 @@
user << "<span class='warning'>You ate your crayon!</span>"
qdel(src)
else
..()
..(M, user, target_zone)
+1 -1
View File
@@ -10,7 +10,7 @@
var/mob/living/silicon/ai/carded_ai
/obj/item/device/aicard/attack(mob/living/silicon/decoy/M as mob, mob/user as mob)
/obj/item/device/aicard/attack(mob/living/silicon/decoy/M as mob, mob/user as mob, var/target_zone)
if (!istype (M, /mob/living/silicon/decoy))
return ..()
else
+3 -3
View File
@@ -6,12 +6,12 @@
icon_state = "tube"
origin_tech = list(TECH_MATERIAL = 4, TECH_ENGINEERING = 3)
amount = 10
var/list/construction_cost = list(DEFAULT_WALL_MATERIAL = 7000, "glass" = 7000)
var/construction_time = 5
/obj/item/stack/nanopaste/attack(mob/living/M as mob, mob/user as mob)
/obj/item/stack/nanopaste/attack(mob/living/M as mob, mob/user as mob, var/target_zone)
if (!istype(M) || !istype(user))
return 0
if (istype(M,/mob/living/silicon/robot)) //Repairing cyborgs
@@ -29,7 +29,7 @@
if (istype(M,/mob/living/carbon/human)) //Repairing robolimbs
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/S = H.get_organ(user.zone_sel.selecting)
var/obj/item/organ/external/S = H.get_organ(target_zone)
if(S.open == 1)
if (S && (S.status & ORGAN_ROBOT))
@@ -26,12 +26,12 @@
src.icon_state = "implanter0"
return
/obj/item/weapon/implanter/attack(mob/M as mob, mob/user as mob)
/obj/item/weapon/implanter/attack(mob/M as mob, mob/user as mob, var/target_zone)
if (!istype(M, /mob/living/carbon))
return
if (user && src.imp)
M.visible_message("<span class='warning'>[user] is attemping to implant [M].</span>")
user.setClickCooldown(DEFAULT_QUICK_COOLDOWN)
user.do_attack_animation(M)
@@ -48,7 +48,7 @@
src.imp.implanted = 1
if (ishuman(M))
var/mob/living/carbon/human/H = M
var/obj/item/organ/external/affected = H.get_organ(user.zone_sel.selecting)
var/obj/item/organ/external/affected = H.get_organ(target_zone)
affected.implants += src.imp
imp.part = affected
@@ -23,12 +23,12 @@
create_reagents(5)
return
/obj/item/weapon/material/kitchen/utensil/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
/obj/item/weapon/material/kitchen/utensil/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob, var/target_zone)
if(!istype(M))
return ..()
if(user.a_intent != I_HELP)
if(user.zone_sel.selecting == "head" || user.zone_sel.selecting == "eyes")
if(target_zone == "head" || target_zone == "eyes")
if((CLUMSY in user.mutations) && prob(50))
M = user
return eyestab(M,user)
@@ -93,7 +93,7 @@
applies_material_colour = 0
unbreakable = 1
/obj/item/weapon/material/kitchen/utensil/knife/attack(target as mob, mob/living/user as mob)
/obj/item/weapon/material/kitchen/utensil/knife/attack(target as mob, mob/living/user as mob, var/target_zone)
if ((CLUMSY in user.mutations) && prob(50))
user << "<span class='warning'>You accidentally cut yourself with \the [src].</span>"
user.take_organ_damage(20)
@@ -116,7 +116,7 @@
force_divisor = 0.7 // 10 when wielded with weight 15 (wood)
thrown_force_divisor = 1 // as above
/obj/item/weapon/material/kitchen/rollingpin/attack(mob/living/M as mob, mob/living/user as mob)
/obj/item/weapon/material/kitchen/rollingpin/attack(mob/living/M as mob, mob/living/user as mob, var/target_zone)
if ((CLUMSY in user.mutations) && prob(50))
user << "<span class='warning'>\The [src] slips out of your hand and hits your head.</span>"
user.drop_from_inventory(src)
@@ -154,11 +154,11 @@
reagents.trans_to_obj(C, (reagents.total_volume/contents.len))
..()
/obj/item/weapon/storage/fancy/cigarettes/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
/obj/item/weapon/storage/fancy/cigarettes/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob,var/target_zone)
if(!istype(M, /mob))
return
if(M == user && user.zone_sel.selecting == "mouth" && contents.len > 0 && !user.wear_mask)
if(M == user && target_zone == "mouth" && contents.len > 0 && !user.wear_mask)
var/obj/item/clothing/mask/smokable/cigarette/W = new /obj/item/clothing/mask/smokable/cigarette(user)
reagents.trans_to_obj(W, (reagents.total_volume/contents.len))
user.equip_to_slot_if_possible(W, slot_wear_mask)
@@ -215,11 +215,11 @@
reagents.trans_to_obj(C, (reagents.total_volume/contents.len))
..()
/obj/item/weapon/storage/fancy/cigar/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
/obj/item/weapon/storage/fancy/cigar/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob, var/target_zone)
if(!istype(M, /mob))
return
if(M == user && user.zone_sel.selecting == "mouth" && contents.len > 0 && !user.wear_mask)
if(M == user && target_zone == "mouth" && contents.len > 0 && !user.wear_mask)
var/obj/item/clothing/mask/smokable/cigarette/cigar/W = new /obj/item/clothing/mask/smokable/cigarette/cigar(user)
reagents.trans_to_obj(W, (reagents.total_volume/contents.len))
user.equip_to_slot_if_possible(W, slot_wear_mask)
@@ -96,12 +96,12 @@
update_force()
/obj/item/weapon/storage/toolbox/attack(mob/living/M as mob, mob/user as mob)
/obj/item/weapon/storage/toolbox/attack(mob/living/M as mob, mob/user as mob, var/target_zone)
update_force()
..(M, user)
if (contents.len)
spill(3, get_turf(M))
playsound(M, 'sound/items/trayhit2.ogg', 100, 1) //sound playin' again
update_force()
user.visible_message(span("danger", "[user] smashes the [src] into [M], causing it to break open and strew its contents across the area"))
if (..())
if (contents.len)
spill(3, get_turf(M))
playsound(M, 'sound/items/trayhit2.ogg', 100, 1) //sound playin' again
update_force()
user.visible_message(span("danger", "[user] smashes the [src] into [M], causing it to break open and strew its contents across the area"))
@@ -24,7 +24,7 @@
slot_flags = SLOT_BELT
force = 10
/obj/item/weapon/melee/classic_baton/attack(mob/M as mob, mob/living/user as mob)
/obj/item/weapon/melee/classic_baton/attack(mob/M as mob, mob/living/user as mob, var/target_zone)
if ((CLUMSY in user.mutations) && prob(50))
user << "<span class='warning'>You club yourself over the head.</span>"
user.Weaken(3 * force)
@@ -90,7 +90,7 @@
return
/obj/item/weapon/melee/telebaton/attack(mob/target as mob, mob/living/user as mob)
/obj/item/weapon/melee/telebaton/attack(mob/target as mob, mob/living/user as mob, var/target_zone)
if(on)
if ((CLUMSY in user.mutations) && prob(50))
user << "<span class='warning'>You club yourself over the head.</span>"
@@ -103,7 +103,7 @@
return
if(..() == 1)
playsound(src.loc, "swing_hit", 50, 1, -1)
if(user.zone_sel.selecting == "r_leg" || user.zone_sel.selecting == "l_leg")
if(target_zone == "r_leg" || target_zone == "l_leg")
target.Weaken(5) //nerfed, because yes.
return
else
+4 -4
View File
@@ -5,9 +5,9 @@
icon_state = "taperoll"
w_class = 1
/obj/item/weapon/tape_roll/attack(var/mob/living/carbon/human/H, var/mob/user)
/obj/item/weapon/tape_roll/attack(var/mob/living/carbon/human/H, var/mob/user, var/target_zone)
if(istype(H))
if(user.zone_sel.selecting == "eyes")
if(target_zone == "eyes")
if(!H.organs_by_name["head"])
user << "<span class='warning'>\The [H] doesn't have a head.</span>"
@@ -33,7 +33,7 @@
user.visible_message("<span class='danger'>\The [user] has taped up \the [H]'s eyes!</span>")
H.equip_to_slot_or_del(new /obj/item/clothing/glasses/sunglasses/blindfold/tape(H), slot_glasses)
else if(user.zone_sel.selecting == "mouth" || user.zone_sel.selecting == "head")
else if(target_zone == "mouth" || target_zone == "head")
if(!H.organs_by_name["head"])
user << "<span class='warning'>\The [H] doesn't have a head.</span>"
return
@@ -58,7 +58,7 @@
user.visible_message("<span class='danger'>\The [user] has taped up \the [H]'s mouth!</span>")
H.equip_to_slot_or_del(new /obj/item/clothing/mask/muzzle/tape(H), slot_wear_mask)
else if(user.zone_sel.selecting == "r_hand" || user.zone_sel.selecting == "l_hand")
else if(target_zone == "r_hand" || target_zone == "l_hand")
var/obj/item/weapon/handcuffs/cable/tape/T = new(user)
if(!T.place_handcuffs(H, user))
user.unEquip(T)
+5 -5
View File
@@ -75,10 +75,10 @@
src.pixel_y = rand(0, 16)
..()
/obj/item/weapon/screwdriver/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
/obj/item/weapon/screwdriver/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob, var/target_zone)
if(!istype(M) || user.a_intent == "help")
return ..()
if(user.zone_sel.selecting != "eyes" && user.zone_sel.selecting != "head")
if(target_zone != "eyes" && target_zone != "head")
return ..()
if((CLUMSY in user.mutations) && prob(50))
M = user
@@ -110,7 +110,7 @@
item_state = "cutters_yellow"
..()
/obj/item/weapon/wirecutters/attack(mob/living/carbon/C as mob, mob/user as mob)
/obj/item/weapon/wirecutters/attack(mob/living/carbon/C as mob, mob/user as mob, var/target_zone)
if(user.a_intent == I_HELP && (C.handcuffed) && (istype(C.handcuffed, /obj/item/weapon/handcuffs/cable)))
usr.visible_message("\The [usr] cuts \the [C]'s restraints with \the [src]!",\
"You cut \the [C]'s restraints with \the [src]!",\
@@ -289,11 +289,11 @@
if (istype(location, /turf))
location.hotspot_expose(700, 5)
/obj/item/weapon/weldingtool/attack(mob/living/M as mob, mob/user as mob)
/obj/item/weapon/weldingtool/attack(mob/living/M as mob, mob/user as mob, var/target_zone)
if(hasorgans(M))
var/obj/item/organ/external/S = M:organs_by_name[user.zone_sel.selecting]
var/obj/item/organ/external/S = M:organs_by_name[target_zone]
if (!S) return
if(!(S.status & ORGAN_ROBOT) || user.a_intent != I_HELP)
+3 -3
View File
@@ -31,7 +31,7 @@
/obj/item/weapon/flame/match,
/obj/item/weapon/material/ashtray)
/obj/item/weapon/tray/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
/obj/item/weapon/tray/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob, var/target_zone)
// Drop all the things. All of them.
spill(user, M.loc)
@@ -53,7 +53,7 @@
var/mob/living/carbon/human/H = M ///////////////////////////////////// /Let's have this ready for later.
if(!(user.zone_sel.selecting == ("eyes" || "head"))) //////////////hitting anything else other than the eyes
if(!(target_zone == ("eyes" || "head"))) //////////////hitting anything else other than the eyes
if(prob(33) && !issilicon(M))//robots dont bleed
src.add_blood(H)
var/turf/location = H.loc
@@ -87,7 +87,7 @@
if(istype(protection) && (protection.body_parts_covered & FACE))
protected = 1
break
if(protected)
M << "<span class='warning'>You get slammed in the face with the tray, against your mask!</span>"
if(prob(33) && !issilicon(M))