So, I have a problem. I want a spawned LWeapon, with an initial Z axis velocity (Jump) to travel to an arbitrary, fixed point along a parabolic path. i.e. Z must be 0 when its X and Y reach the fixed point. The X and Y velocities (the LWeapon's Step) are constant. Normally the equation D(t) = at^2 + vt + d0 could solve this, but there's a big issue. I don't know how any of the units in ZC relate. I tried to estimate it, but it ended poorly. I might also be running into floating point numbers getting truncated somewhere. Here's the script:
ffc script ThrowBomb
{
void run()
{
lweapon weapon;
lweapon weapon_blast;
int BCounter = 0;
int target_counter = 0;
npc target;
float dist;
float step;
float v_adjust = 15972;
while (true)
{
for (int i = 1; i <= Screen->NumNPCs(); i++)
{
target_counter++;
}
if (!Link->InputB && BCounter < 40)
{
weapon = NextToLink(LW_BOMB, 0, 0);
weapon->Z = 1;
weapon->Jump = 3;
weapon->Dir = Link->Dir;
weapon->Step = 200;
break;
}
if (!Link->InputB && BCounter >= 40 && target_counter != 0)
{
target = Screen->LoadNPC(Rand(1, target_counter));
weapon = NextToLink(LW_BOMB, 0, 0);
weapon->Z = 1;
// Calculating the Z axis velocity
dist = Distance (Link->X, Link->Y, target->X, target->Y);
step = 200;
weapon->Jump = (-1 - GRAVITY_ACCEL * Pow((dist / (step / 100)), 2)) / ((v_adjust / 100000) * (dist / (step/100)));
weapon->Angular = true;
weapon->Angle = RadianAngle(Link->X, Link->Y, target->X, target->Y);
weapon->Step = step;
break;
}
if (Link->InputB)
{
BCounter++;
}
target_counter = 0;
Waitframe();
}
while (weapon->isValid())
{
if (weapon->Z <= 0)
{
weapon_blast = Screen->CreateLWeapon(LW_BOMBBLAST);
weapon_blast->X = weapon->X;
weapon_blast->Y = weapon->Y;
weapon_blast->Damage = 8;
weapon->DeadState = WDS_DEAD;
}
Waitframe();
}
}
}
If anyone could help with unit conversions between Step, Jump, and Gravity, or how to get numbers to stop being truncated, I would be grateful.

