A_LobShot assumes it's being used on the ground

Status
Not open for further replies.

742mph

My work is never done yet
I was trying to SOC a flying object that uses a A_LobShot as an attack today, but the object always missed its target by quite a bit when it used the attack. However, when I grounded the object, its aim suddenly became perfect. I think what's going on is that the code that calculates the force to throw the lobbed object with assumes that the actor is on the floor of the sector it's in and doesn't take Z position into account, and this was never noticed before because the only official object that uses A_LobShot, the Cannonball Launcher, is always placed on the ground.
 
Just checked the source code. Found function A_LobShot in p_enemy.c. Also found out that the code needed to your issue this is already there, but commented out:
Code:
/* Try to adjust when destination is not the same height
    if (actor->z != actor->target->z)
    {
        fixed_t launchhyp;
        fixed_t diff;
        fixed_t orig;

        diff = actor->z - actor->target->z;
        {
            launchhyp = P_AproxDistance(horizontal, vertical);

            orig = FixedMul(FixedDiv(vertical, horizontal), diff);

            DEBPRINT(va("orig: %d\n", (orig)>>FRACBITS));

            horizontal = dist / airtime;
            vertical = (gravity*airtime)/2;
        }
        dist -= orig;
        shot->momx = FixedMul(horizontal, FINECOSINE(an));
        shot->momy = FixedMul(horizontal, FINESINE(an));
        shot->momz = vertical;
*/
I'm currently unable to test if uncommenting this section will fix the bug, so if you know how to compile from source, it should be easy for you to try it out. Just remove the /* and */ and you're good.
 
I'm afraid I don't know how to compile source code, so I won't know if the issue is fixed by uncommenting that section unless someone else tries it out.
 
No, uncommenting that code will not fix it.

Lobbing a shot like that to a different elevation requires lots of crazy mathematics. A new algorithm will have to be developed.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top