proc
bulletPreCalculate(part/gun/gun,mob/m)
var
d=sqrt(((px-m.px)^2) + ((py-m.py)^2))//distance from the person firing the bullet to the person being targetted converted into a scalar
t//the time it would take the bullet to reach the mob under normal circumstances
v=gun.bulletSpeed//the velocity of the bullet
t=(d/v)//time is equal to distance over time
var
dx//new x to aim at
dy//new y to aim at
dx=(t*m.vel_x)//distance = time times velocity
dy=(t*m.vel_y)//^^^^
//done
if(!m.vel_x&&!m.vel_y)
return list(m.px,m.py)
return list(dx,dy)
Problem description:
I'm trying to make a pre-calculation procedure so that when aiming at a mob, it's more accurate, because right now, it just aims at where they were, which will yield annoying gameplay if ever an enemy is moving with more than a velocity of 1.5 pixels/30/s (which is frequently). Right now , whenever they're moving it aims at the bottom right corner (I've also noticed the distance, d, has extremely variant numbers, i.e: when I print out the distance, it's 256 or so pixels between me and the tile two tiles away, 4 pixels away from the tile right in front of me, and like 310 pixels away for any tile further than 3 tiles away)
See if everything is correct now.