Skip to content

Commit

Permalink
Making pushing and pulling more abstract, shield pushes into walls re…
Browse files Browse the repository at this point in the history
…sult Weaken.
  • Loading branch information
LudwigVonChesterfield committed Sep 26, 2019
1 parent 3b4dcff commit f202fd0
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 181 deletions.
44 changes: 4 additions & 40 deletions code/defines/obj/weapon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,9 @@
attack_verb = list("bludgeoned", "whacked", "disciplined", "thrashed")

can_push = TRUE
hit_on_harm_push = FALSE
can_pull = TRUE

/obj/item/weapon/cane/on_sweep_push_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_away(target, get_turf(src))

/obj/item/weapon/cane/on_sweep_pull_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(!has_gravity(src) && !istype(target, /turf/space))
step_to(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_to(target, get_turf(src))
hit_on_harm_pull = FALSE

/obj/item/weapon/gift
name = "gift"
Expand Down Expand Up @@ -321,27 +303,9 @@
attack_verb = list("bludgeoned", "whacked", "disciplined")

can_push = TRUE
hit_on_harm_push = FALSE
can_pull = TRUE

/obj/item/weapon/staff/on_sweep_push_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_away(target, get_turf(src))

/obj/item/weapon/staff/on_sweep_pull_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(!has_gravity(src) && !istype(target, /turf/space))
step_to(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_to(target, get_turf(src))
hit_on_harm_pull = FALSE

/obj/item/weapon/staff/broom
name = "broom"
Expand Down
64 changes: 4 additions & 60 deletions code/game/objects/items/weapons/makeshift.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,16 @@
attack_verb = list("attacked", "poked", "jabbed", "torn", "gored")

can_push = TRUE
hit_on_harm_push = TRUE
can_pull = TRUE
hit_on_harm_pull = TRUE

/obj/item/weapon/twohanded/spear/can_push()
return can_push && wielded

/obj/item/weapon/twohanded/spear/can_pull()
return can_pull && wielded

/obj/item/weapon/twohanded/spear/on_sweep_push_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_away(target, get_turf(src))

/obj/item/weapon/twohanded/spear/on_sweep_pull_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_to(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_to(target, get_turf(src))

/obj/item/weapon/twohanded/spear/update_icon()
icon_state = "spearglass[wielded]"

Expand Down Expand Up @@ -87,42 +59,14 @@
slot_flags = null

can_push = TRUE
hit_on_harm_push = TRUE
can_pull = TRUE
hit_on_harm_pull = TRUE

/obj/item/weapon/melee/cattleprod/atom_init()
. = ..()
update_icon()

/obj/item/weapon/melee/cattleprod/on_sweep_push_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_away(target, get_turf(src))

/obj/item/weapon/melee/cattleprod/on_sweep_pull_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_to(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_to(target, get_turf(src))

/obj/item/weapon/melee/cattleprod/attack_self(mob/user)
if(bcell && bcell.charge > hitcost)
status = !status
Expand Down
22 changes: 2 additions & 20 deletions code/game/objects/items/weapons/mop.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

can_push = TRUE
can_push_on_chair = TRUE
hit_on_harm_push = FALSE
can_pull = TRUE
hit_on_harm_pull = FALSE

can_sweep = TRUE
can_spin = TRUE
Expand Down Expand Up @@ -79,16 +81,6 @@
else
step_to(I, T_target)

/obj/item/weapon/mop/on_sweep_push_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_away(target, get_turf(src))

/obj/item/weapon/mop/on_sweep_pull(atom/target, turf/T, mob/user)
var/turf/src_turf = get_turf(src)

Expand All @@ -104,16 +96,6 @@
else
step_to(I, src_turf)

/obj/item/weapon/mop/on_sweep_pull_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(!has_gravity(src) && !istype(target, /turf/space))
step_to(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_to(target, get_turf(src))

/obj/item/weapon/mop/afterattack(atom/A, mob/living/user, proximity)
if(!proximity)
return
Expand Down
67 changes: 38 additions & 29 deletions code/game/objects/items/weapons/shields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name = "shield"
var/block_chance = 65

can_push = TRUE
hit_on_harm_push = TRUE
can_sweep = TRUE
interupt_on_sweep_hit_types = list(/turf, /obj/structure/table, /obj/machinery/disposal, /obj/structure/rack)

Expand All @@ -27,6 +29,36 @@

return is_stunned

/obj/item/weapon/shield/on_sweep_push_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(hit_on_harm_push && user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
var/old_loc = AM.loc
step_away(target, get_turf(src))
if(old_loc == AM.loc && isliving(AM)) // We tried pushing them, but pushed them into something, IT'S FALLING DOWN TIME.
var/mob/living/M = AM

user.attack_log += "\[[time_stamp()]\]<font color='red'>pushed [M.name] ([M.ckey]) with [src.name].</font>"
M.attack_log += "\[[time_stamp()]\]<font color='orange'>pushed [user.name] ([user.ckey]) with [src.name].</font>"
msg_admin_attack("[key_name(user)] pushed [key_name(M)] with [src.name].", user)
user.visible_message("<span class='warning'>[M] is stunned by [user] with [src]!</span>", "<span class='warning'>You stun [M] with [src]!</span>")
if(M.buckled)
M.buckled.user_unbuckle_mob(M)

M.apply_effect(3, STUN, 0)
M.apply_effect(3, WEAKEN, 0)
M.apply_effect(6, STUTTER, 0)
shake_camera(M, 1, 1)

/obj/item/weapon/shield/riot
name = "riot shield"
desc = "A shield adept at blocking blunt objects from connecting with the torso of the shield wielder."
Expand Down Expand Up @@ -57,35 +89,6 @@
else
..()

/obj/item/weapon/shield/riot/attack(mob/living/M, mob/user)
var/obj/item/weapon/shield/riot/tele/TS
if(istype(src, /obj/item/weapon/shield/riot/tele))
TS = src

if(M != user && ((TS && TS.active) || !TS) && !isrobot(M))
if(M.pulling)
M.stop_pulling()

user.do_attack_animation(M)
user.visible_message("<span class='warning'>[user.name] pushed away [M.name] with a [src.name]</span>")
addtimer(CALLBACK(GLOBAL_PROC, .proc/_step, M, user.dir), 1)
addtimer(CALLBACK(GLOBAL_PROC, .proc/_step, M, user.dir), 2)
user.attack_log += "\[[time_stamp()]\]<font color='red'>pushed [M.name] ([M.ckey]) with [src.name].</font>"
M.attack_log += "\[[time_stamp()]\]<font color='orange'>pushed [user.name] ([user.ckey]) with [src.name].</font>"
msg_admin_attack("[key_name(user)] pushed [key_name(M)] with [src.name].", user)

if(prob(20))
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.shoes)
if(H.shoes.flags & NOSLIP)
return
M.Weaken(3)
shake_camera(M, 1, 1)

if(user.a_intent == I_HURT || M == user || (TS && !TS.active) || isrobot(M))
..()

/obj/item/weapon/shield/energy
name = "energy combat shield"
desc = "A shield capable of stopping most projectile and melee attacks. It can be retracted, expanded, and stored anywhere."
Expand All @@ -103,6 +106,9 @@
var/active = 0
var/emp_cooldown = 0

/obj/item/weapon/shield/energy/can_push()
return can_push && active

/obj/item/weapon/shield/energy/IsReflect(def_zone, hol_dir, hit_dir)
if(active)
return is_the_opposite_dir(hol_dir, hit_dir)
Expand Down Expand Up @@ -135,6 +141,9 @@
w_class = ITEM_SIZE_NORMAL
var/active = 0

/obj/item/weapon/shield/riot/tele/can_push()
return can_push && active

/obj/item/weapon/shield/riot/tele/Get_shield_chance()
if(active)
return block_chance
Expand Down
32 changes: 2 additions & 30 deletions code/game/objects/items/weapons/swords_axes_etc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@
interupt_on_sweep_hit_types = list(/turf, /obj/machinery/disposal, /obj/structure/table, /obj/structure/rack, /obj/effect/effect/weapon_sweep)

can_push = TRUE
hit_on_harm_push = TRUE
can_pull = TRUE
hit_on_harm_pull = TRUE

/obj/item/weapon/melee/telebaton/can_sweep()
return can_sweep && on
Expand All @@ -155,36 +157,6 @@
/obj/item/weapon/melee/telebaton/can_pull()
return can_pull && on

/obj/item/weapon/melee/telebaton/on_sweep_push_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_away(target, get_turf(src))

/obj/item/weapon/melee/telebaton/on_sweep_pull_success(atom/target, mob/user)
var/turf/T_target = get_turf(target)

if(user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_to(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_to(target, get_turf(src))

/obj/item/weapon/melee/telebaton/attack_self(mob/user)
on = !on
if(on)
Expand Down
30 changes: 28 additions & 2 deletions code/game/objects/weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
var/interupt_on_sweep_hit_types = list(/atom) // By default we interupt on any hit.

var/can_push = FALSE
var/hit_on_harm_push = FALSE
var/can_push_on_chair = FALSE
var/can_pull = FALSE
var/hit_on_harm_pull = FALSE

var/can_sweep = FALSE
var/can_spin = FALSE
Expand Down Expand Up @@ -135,7 +137,19 @@
return

/obj/item/weapon/proc/on_sweep_push_success(atom/target, mob/user)
return
var/turf/T_target = get_turf(target)

if(hit_on_harm_push && user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_away(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_away(target, get_turf(src))

/obj/item/weapon/proc/sweep_push(atom/target, mob/user)
var/s_time = sweep_step * 2
Expand All @@ -162,7 +176,19 @@
return

/obj/item/weapon/proc/on_sweep_pull_success(atom/target, mob/user)
return
var/turf/T_target = get_turf(target)

if(hit_on_harm_pull && user.a_intent != I_HELP)
var/resolved = target.attackby(src, user, list())
if(!resolved && src)
afterattack(target, user, TRUE, list()) // 1 indicates adjacency

if(!has_gravity(src) && !istype(target, /turf/space))
step_to(user, T_target)
else if(istype(target, /atom/movable))
var/atom/movable/AM = target
if(!AM.anchored)
step_to(target, get_turf(src))

/obj/item/weapon/proc/sweep_pull(atom/target, mob/user)
var/s_time = sweep_step * 2
Expand Down

0 comments on commit f202fd0

Please sign in to comment.