Refactors various item attack() implementations

Replaced some attack() overrides with apply_hit_effect() or other attack
procs where appropriate.
Removed the attack() override from reagent_containers.
This commit is contained in:
mwerezak
2015-09-08 23:39:33 -04:00
parent 6ceffaacb5
commit 068d02c28c
22 changed files with 141 additions and 230 deletions
+4 -3
View File
@@ -31,8 +31,8 @@
last_used = world.time
times_used = max(0,round(times_used)) //sanity
/obj/item/device/flash/attack(mob/living/M as mob, mob/user as mob)
//attack_as_weapon
/obj/item/device/flash/attack(mob/living/M, mob/living/user, var/target_zone)
if(!user || !M) return //sanity
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been flashed (attempt) with [src.name] by [user.name] ([user.ckey])</font>")
@@ -183,7 +183,8 @@
icon_state = "sflash"
origin_tech = list(TECH_MAGNET = 2, TECH_COMBAT = 1)
/obj/item/device/flash/synthetic/attack(mob/living/M as mob, mob/user as mob)
//attack_as_weapon
/obj/item/device/flash/synthetic/attack(mob/living/M, mob/living/user, var/target_zone)
..()
if(!broken)
broken = 1
+6 -17
View File
@@ -10,31 +10,20 @@
icon = 'icons/obj/decals.dmi'
icon_state = "shock"
/obj/item/borg/stun/attack(var/mob/living/M, var/mob/living/silicon/robot/user)
if(!istype(M))
return
// How the Hell.
/obj/item/borg/stun/apply_hit_effect(mob/living/M, mob/living/silicon/robot/user, var/hit_zone)
if(!istype(user))
var/mob/living/temp = user
if(istype(temp))
temp.drop_from_inventory(src)
qdel(src)
return
M.attack_log += text("\[[time_stamp()]\] <font color='orange'>Has been attacked with [src.name] by [user.name] ([user.ckey])</font>")
user.attack_log += text("\[[time_stamp()]\] <font color='red'>Used the [src.name] to attack [M.name] ([M.ckey])</font>")
msg_admin_attack("[user.name] ([user.ckey]) used the [src.name] to attack [M.name] ([M.ckey]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[user.x];Y=[user.y];Z=[user.z]'>JMP</a>)")
if(!user.cell || !user.cell.checked_use(1250)) //Slightly more than a baton.
user.visible_message("<span class='danger'>\The [user] has prodded \the [M] with its arm!</span>")
return
if (M.stuttering < 5)
M.stuttering = 5
M.stun_effect_act(0, 70, check_zone(user.zone_sel.selecting), src)
user.visible_message("<span class='danger'>\The [user] has prodded \the [M] with \a [src]!</span>")
playsound(loc, 'sound/weapons/Egloves.ogg', 50, 1, -1)
M.apply_effect(5, STUTTER)
M.stun_effect_act(0, 70, check_zone(hit_zone), src)
if(ishuman(M))
var/mob/living/carbon/human/H = M
H.forcesay(hit_appends)
@@ -38,7 +38,8 @@
target.clean_blood()
return
/obj/item/weapon/soap/attack(mob/target as mob, mob/user as mob)
//attack_as_weapon
/obj/item/weapon/soap/attack(mob/living/target, mob/living/user, var/target_zone)
if(target && user && ishuman(target) && ishuman(user) && !target.stat && !user.stat && user.zone_sel &&user.zone_sel.selecting == "mouth" )
user.visible_message("<span class='danger'>\The [user] washes \the [target]'s mouth out with soap!</span>")
return
@@ -61,7 +61,7 @@
qdel(src)
/obj/item/weapon/a_gift/attack_self(mob/M as mob)
var/gift_type = pick(/obj/item/weapon/sord,
var/gift_type = pick(
/obj/item/weapon/storage/wallet,
/obj/item/weapon/storage/photo_album,
/obj/item/weapon/storage/box/snappops,
@@ -80,7 +80,6 @@
/obj/item/weapon/bikehorn,
/obj/item/weapon/beach_ball,
/obj/item/weapon/beach_ball/holoball,
/obj/item/weapon/banhammer,
/obj/item/toy/balloon,
/obj/item/toy/blink,
/obj/item/toy/crossbow,
@@ -108,6 +108,7 @@
/obj/item/weapon/material/kitchen/rollingpin/attack(mob/living/M as mob, mob/living/user as mob)
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)
user.take_organ_damage(10)
user.Paralyse(2)
return
@@ -64,9 +64,7 @@
processing_objects -= src
..()
/obj/item/weapon/material/attack()
if(!..())
return
/obj/item/weapon/material/apply_hit_effect()
if(!unbreakable)
if(material.is_brittle())
health = 0
@@ -44,7 +44,6 @@
icon = 'icons/obj/weapons.dmi'
icon_state = "hoe"
item_state = "hoe"
flags = CONDUCT | NOBLUDGEON
force_divisor = 0.25 // 5 with weight 20 (steel)
thrown_force_divisor = 0.25 // as above
w_class = 2
+27 -43
View File
@@ -97,70 +97,54 @@
user << "<span class='warning'>[src] is out of charge.</span>"
add_fingerprint(user)
/obj/item/weapon/melee/baton/attack(mob/M, mob/user)
if(status && (CLUMSY in user.mutations) && prob(50))
user << "<span class='danger'>You accidentally hit yourself with the [src]!</span>"
user.Weaken(30)
deductcharge(hitcost)
return
return ..()
if(isrobot(M))
/obj/item/weapon/melee/baton/apply_hit_effect(mob/living/target, mob/living/user, var/hit_zone)
if(isrobot(target))
..()
return
var/agony = agonyforce
var/stun = stunforce
var/mob/living/L = M
var/obj/item/organ/external/affecting = null
if(ishuman(target))
var/mob/living/carbon/human/H = target
affecting = H.get_organ(hit_zone)
var/target_zone = check_zone(user.zone_sel.selecting)
if(user.a_intent == I_HURT)
if (!..()) //item/attack() does it's own messaging and logs
return 0 // item/attack() will return 1 if they hit, 0 if they missed.
agony *= 0.5 //whacking someone causes a much poorer contact than prodding them.
..()
//whacking someone causes a much poorer electrical contact than deliberately prodding them.
agony *= 0.5
stun *= 0.5
//we can't really extract the actual hit zone from ..(), unfortunately. Just act like they attacked the area they intended to.
else
//copied from human_defense.dm - human defence code should really be refactored some time.
if (ishuman(L))
user.lastattacked = L //are these used at all, if we have logs?
L.lastattacker = user
if (user != L) // Attacking yourself can't miss
target_zone = get_zone_with_miss_chance(user.zone_sel.selecting, L)
if(!target_zone)
L.visible_message("<span class='danger'>\The [user] misses [L] with \the [src]!</span>")
return 0
var/mob/living/carbon/human/H = L
var/obj/item/organ/external/affecting = H.get_organ(target_zone)
if (affecting)
if(!status)
L.visible_message("<span class='warning'>[L] has been prodded in the [affecting.name] with [src] by [user]. Luckily it was off.</span>")
return 1
else
H.visible_message("<span class='danger'>[L] has been prodded in the [affecting.name] with [src] by [user]!</span>")
else if(!status)
if(affecting)
target.visible_message("<span class='warning'>[target] has been prodded in the [affecting.name] with [src] by [user]. Luckily it was off.</span>")
else
if(!status)
L.visible_message("<span class='warning'>[L] has been prodded with [src] by [user]. Luckily it was off.</span>")
return 1
else
L.visible_message("<span class='danger'>[L] has been prodded with [src] by [user]!</span>")
target.visible_message("<span class='warning'>[target] has been prodded with [src] by [user]. Luckily it was off.</span>")
else
if(affecting)
target.visible_message("<span class='danger'>[target] has been prodded in the [affecting.name] with [src] by [user]!</span>")
else
target.visible_message("<span class='danger'>[target] has been prodded with [src] by [user]!</span>")
playsound(loc, 'sound/weapons/Egloves.ogg', 50, 1, -1)
//stun effects
L.stun_effect_act(stun, agony, target_zone, src)
if(status)
target.stun_effect_act(stun, agony, hit_zone, src)
msg_admin_attack("[key_name(user)] stunned [key_name(target)] with the [src].")
playsound(loc, 'sound/weapons/Egloves.ogg', 50, 1, -1)
msg_admin_attack("[key_name(user)] stunned [key_name(L)] with the [src].")
deductcharge(hitcost)
deductcharge(hitcost)
if(ishuman(L))
var/mob/living/carbon/human/H = L
H.forcesay(hit_appends)
return 1
if(ishuman(target))
var/mob/living/carbon/human/H = target
H.forcesay(hit_appends)
/obj/item/weapon/melee/baton/emp_act(severity)
if(bcell)
@@ -1,18 +1,10 @@
/* Weapons
* Contains:
* Banhammer
* Sword
* Classic Baton
*/
/*
* Banhammer
*/
/obj/item/weapon/banhammer/attack(mob/M as mob, mob/user as mob)
M << "<font color='red'><b> You have been banned FOR NO REISIN by [user]</b></font>"
user << "<font color='red'> You have <b>BANNED</b> [M]</font>"
/*
/*
* Classic Baton
*/
/obj/item/weapon/melee/classic_baton
@@ -1,18 +1,3 @@
/obj/item/weapon/banhammer
desc = "banhammer"
name = "banhammer"
icon = 'icons/obj/items.dmi'
icon_state = "toyhammer"
slot_flags = SLOT_BELT
throwforce = 0
w_class = 2.0
throw_speed = 7
throw_range = 15
attack_verb = list("banned")
suicide_act(mob/user)
viewers(user) << "<span class='danger'>[user] is hitting \himself with the [src.name]! It looks like \he's trying to ban \himself from life.</span>"
return (BRUTELOSS|FIRELOSS|TOXLOSS|OXYLOSS)
/obj/item/weapon/nullrod
name = "null rod"
@@ -68,27 +53,6 @@
user << "<span class='notice'>You hit the floor with the [src].</span>"
call(/obj/effect/rune/proc/revealrunes)(src)
/obj/item/weapon/sord
name = "\improper SORD"
desc = "This thing is so unspeakably shitty you are having a hard time even holding it."
icon_state = "sord"
item_state = "sord"
slot_flags = SLOT_BELT
force = 2
throwforce = 1
sharp = 1
edge = 1
w_class = 3
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
suicide_act(mob/user)
viewers(user) << "<span class='danger'>[user] is impaling \himself with the [src.name]! It looks like \he's trying to commit suicide.</span>"
return(BRUTELOSS)
/obj/item/weapon/sord/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
playsound(loc, 'sound/weapons/bladeslice.ogg', 50, 1, -1)
return ..()
/obj/item/weapon/energy_net
name = "energy net"
desc = "It's a net made of green energy."