// Credit: Lummox JR
atom/var/Owner
atom/movable/proc/PixelMove(dx, dy)
var/d = 0
if(dx) d |= (dx>0) ? EAST : WEST
if(dy) d |= (dy>0) ? NORTH : SOUTH
if(abs(dx) >= abs(dy)*2) d &= 3
else if(abs(dy) >= abs(dx)*2) d &= 12
Move(loc, d, step_x+dx, step_y+dy)
atom/movable
projectiles
parent_type = /obj
var dx
var dy
var speed = 1
Ball
icon = 'Effects.dmi'
icon_state = "Ball"
New(var/atom/movable/_owner, var/atom/loc, var/atom/clicked)
src.loc = loc
src.step_x = (64 - _owner.bound_width) / 2
src.step_y = _owner.step_y
src.Owner = _owner
var/dx = clicked.x - _owner.x
var/dy = clicked.y - _owner.y
var/r = sqrt(dx * dx + dy * dy)
var/vx = dx / r * speed
var/vy = dy / r * speed
for(var/i in 1 to 30)
src.PixelMove(dx+vx, dy+vy)
sleep(world.tick_lag)
del(src)
Crossed(var/atom/movable/target_crossed) //this doesn't work.
del(target_crossed)
if(src.Owner == target_crossed) return 1
// src.collide_with(target_crossed)
atom/movable/Click(location, control, params)
if(!location) return
new/atom/movable/projectiles/Ball(usr, usr.loc, location)
Problem description: The projectile isn't firing in the right angle. If you fire on the tile right below you, the projectile will be slowly moving to the left. Offsetting is all wrong. This is my first pixel projectile attempt, and it's difficult.
Or, if you don't want to go through that, you can just use Fireking's pixel projectiles implementation. Your current method isn't actually getting the angle, it's just getting the distance between the two atoms, which you can already do using get_dist() and bounds_dist(), so I'm not entirely sure why you redefined it.