obj/Projectiles
Cross(atom/a)
//doesn't seem to inluence anything it is crossing
//only other /obj/projectiles that cross it.
if(istype(a,/obj/IntangibleObject))
return 1
if(istype(a,/obj/Projectiles))
return 1
else
return 0
Bump(atom/a)
if(istype(a,/obj/IntangibleObject))
var/s = src.step_size
switch(dir)
if(EAST) src.step_x+=s
if(WEST) src.step_x-=s
if(NORTH) src.step_y+=s
if(SOUTH) src.step_y-=s
if(NORTHEAST) {src.step_x+=s; src.step_y+=s}
if(SOUTHEAST) {src.step_x+=s; src.step_y-=s}
if(NORTHWEST) {src.step_x-=s; src.step_y+=s}
if(SOUTHWEST) {src.step_x-=s; src.step_y-=s}
else
del src
Problem description:
The desired outcome is that when a projectile hits certain certain turfs/objs/mobs, certain specified things happen. Including things like deletion and passing through the obstacle.
The code presented above gives the desired results, but confuses me a bit and seems wrong/bad.
Firstly, the Cross() procedure doesn't work as I'm used to with Bump()...Ergo, the way I've got Cross() here essentially contributes nothing other than managing inter-projectile collisions.
This leaves Bump() as my sole source for managing collisions as well as pass-throughs. As I said, it works as intended, but I'm sure there must be a simpler or better way to handle this?
Cross() literally only affects movables that are crossing it. Likewise, Crossed() reacts to things that have crossed it.
If you want the object being crossed to react when Cross()ed, I would suggest adding hooks that do just that. Here's an implementation I use in my own projects:
Also note that my setting of the return value in Bump(), by default, has no significance, because Bump() doesn't return anything.