Code Cleanup: (Bump(), Bumped()) -> (Collide(), CollidedWith()) (#4349)

This PR rips out the old Bump() and Bumped() procs and replaces them with Collide() and CollidedWith() respectively. Behavior should be the same, but Bump() should no longer be double-called, and no longer relies on spawns.

Other changes:

LAssailant is now a weakref.
Some direct loc setting are now forceMove().
This commit is contained in:
Lohikar
2018-03-08 09:39:53 +02:00
committed by Erki
parent 057e787948
commit a86398d0d2
66 changed files with 231 additions and 216 deletions
+6 -5
View File
@@ -254,7 +254,8 @@
return 1
/obj/item/projectile/Bump(atom/A as mob|obj|turf|area, forced=0)
/obj/item/projectile/Collide(atom/A, forced = 0)
. = ..()
if(A == src)
return 0 //no
@@ -276,8 +277,8 @@
var/obj/item/weapon/grab/G = locate() in M
if(G && G.state >= GRAB_NECK)
visible_message("<span class='danger'>\The [M] uses [G.affecting] as a shield!</span>")
if(Bump(G.affecting, forced=1))
return //If Bump() returns 0 (keep going) then we continue on to attack M.
if(Collide(G.affecting, forced = 1))
return //If Collide() returns 0 (keep going) then we continue on to attack M.
passthrough = !attack_mob(M, distance)
else
@@ -350,7 +351,7 @@
if(!bumped && !isturf(original))
if(loc == get_turf(original))
if(!(original in permutated))
if(Bump(original))
if(Collide(original))
return
if(first_step)
@@ -436,7 +437,7 @@
xo = null
var/result = 0 //To pass the message back to the gun.
/obj/item/projectile/test/Bump(atom/A as mob|obj|turf|area)
/obj/item/projectile/test/Collide(atom/A)
if(A == firer)
loc = A.loc
return //cannot shoot yourself
@@ -6,8 +6,8 @@
nodamage = 1
check_armour = "energy"
/obj/item/projectile/animate/Bump(var/atom/change)
/obj/item/projectile/animate/Collide(atom/change)
if((istype(change, /obj/item) || istype(change, /obj/structure)) && !is_type_in_list(change, protected_objects))
var/obj/O = change
new /mob/living/simple_animal/hostile/mimic/copy(O.loc, O, firer)
..()
. = ..()
+2 -3
View File
@@ -71,12 +71,11 @@
icon_state = "pulse1_bl"
var/life = 20
/obj/item/projectile/beam/pulse/heavy/Bump(atom/A)
/obj/item/projectile/beam/pulse/heavy/Collide(atom/A)
A.bullet_act(src, def_zone)
src.life -= 10
if(life <= 0)
qdel(src)
return
/obj/item/projectile/beam/emitter
name = "emitter beam"
@@ -345,4 +344,4 @@
/obj/item/projectile/beam/energy_net/proc/do_net(var/mob/M)
var/obj/item/weapon/energy_net/net = new (get_turf(M))
net.throw_impact(M)
net.throw_impact(M)
@@ -75,7 +75,7 @@
var/base_spread = 90 //lower means the pellets spread more across body parts. If zero then this is considered a shrapnel explosion instead of a shrapnel cone
var/spread_step = 10 //higher means the pellets spread more across body parts with distance
/obj/item/projectile/bullet/pellet/Bumped()
/obj/item/projectile/bullet/pellet/CollidedWith()
. = ..()
bumped = 0 //can hit all mobs in a tile. pellets is decremented inside attack_mob so this should be fine.
@@ -122,7 +122,7 @@
if(. && !base_spread && isturf(loc))
for(var/mob/living/M in loc)
if(M.lying || !M.CanPass(src, loc)) //Bump if lying or if we would normally Bump.
if(Bump(M)) //Bump will make sure we don't hit a mob multiple times
if(Collide(M)) //Bump will make sure we don't hit a mob multiple times
return
/* short-casing projectiles, like the kind used in pistols or SMGs */
@@ -152,7 +152,7 @@
if(!bumped && !isturf(original))
if(loc == get_turf(original))
if(!(original in permutated))
if(Bump(original))
if(Collide(original))
return
if(first_step)
@@ -69,7 +69,7 @@
nodamage = 1
check_armour = "bullet"
/obj/item/projectile/meteor/Bump(atom/A as mob|obj|turf|area)
/obj/item/projectile/meteor/Collide(atom/A)
if(A == firer)
loc = A.loc
return