by Razumen » Sat Apr 02, 2022 6:56 am
Hey, thanks for this equation!
I'm trying to convert your solution into ACS for my map, and I've got it working, but I can't get it to work if the target changes position vertically.
What am I missing here? I really suck at math, and after hours of fiddling with it, my brain is fried at this point lol.
Here's the code so far:
Code: Select all
//TID0 is the target, TID671 the shooter
int dist = (playerd2d)>>16; //horizontal distance to target, calculated by the function below
int vdisp = (GetActorZ(0) - GetActorZ(671))>>16; //height difference between the spawnspot and the target
int ftime = 10; //time of flight, seems to break at higher numbers
int vvel = ((vdisp + 0.5 * ftime*ftime) / ftime)>>16; //Vertical speed
int hvel = dist / ftime; //Horizontal speed
//Thrust(hvel,angle); //Don't think I need these two
//vel.z = vvel;
while (shotcount<shots)
{
SpawnProjectile (671, "Fireball", shotangle>>8, hvel, vvel, 1, 0);
shotcount++;
Delay (firerate);
}
function int distance2d (int tid1, int tid2)
{
int y = getactory(tid1) - getactory(tid2);
int x = getactorx(tid1) - getactorx(tid2);
int len = VectorLength (x, y);
return len;
}
Hey, thanks for this equation!
I'm trying to convert your solution into ACS for my map, and I've got it working, but I can't get it to work if the target changes position vertically.
What am I missing here? I really suck at math, and after hours of fiddling with it, my brain is fried at this point lol.
Here's the code so far:
[code]
//TID0 is the target, TID671 the shooter
int dist = (playerd2d)>>16; //horizontal distance to target, calculated by the function below
int vdisp = (GetActorZ(0) - GetActorZ(671))>>16; //height difference between the spawnspot and the target
int ftime = 10; //time of flight, seems to break at higher numbers
int vvel = ((vdisp + 0.5 * ftime*ftime) / ftime)>>16; //Vertical speed
int hvel = dist / ftime; //Horizontal speed
//Thrust(hvel,angle); //Don't think I need these two
//vel.z = vvel;
while (shotcount<shots)
{
SpawnProjectile (671, "Fireball", shotangle>>8, hvel, vvel, 1, 0);
shotcount++;
Delay (firerate);
}
function int distance2d (int tid1, int tid2)
{
int y = getactory(tid1) - getactory(tid2);
int x = getactorx(tid1) - getactorx(tid2);
int len = VectorLength (x, y);
return len;
}[/code]