Just need a quick pointer

Locked
phreakachew
Posts: 2
Joined: Thu Dec 13, 2007 6:25 pm

Just need a quick pointer

Post by phreakachew »

Hey all,
I need to change the player movement axis to the world axis instead of the player view (ie: pressing forward would always move north.)

I have scoured bg_pmove.c, but haven't found it yet.

Any help?
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Just need a quick pointer

Post by ^misantropia^ »

This would've belonged better in 'Programming Discussion' but not to worry. Off the top of my head, does inserting this snippet at the top of PM_Accelerate() solve your needs? I'm a bit stretched for time right now and I confess to not actually testing it, so let me know if you run into trouble or would like an overview of its inner workings (I skipped on comments, this time).

Code: Select all

    int total;

    wishdir[0] = 0;
    wishdir[1] = 0;
    wishdir[2] = 0;

#define F(x)    (x < 0 ? -1 : x > 0)
    wishdir[0] = F(pm->cmd.rightmove);
    wishdir[1] = F(pm->cmd.forwardmove);
    wishdir[2] = F(pm->cmd.upmove);

#define G(x)    (x != 0)
    total = G(wishdir[0])
          + G(wishdir[1])
          + G(wishdir[2]);

    if (total > 1) {
        wishdir[0] /= total;
        wishdir[1] /= total;
        wishdir[2] /= total;
    }
phreakachew
Posts: 2
Joined: Thu Dec 13, 2007 6:25 pm

Re: Just need a quick pointer

Post by phreakachew »

There is a programming section?!?! :confused:

Well, in PmoveSingle() in bg_pmove.c I found this code that loads the player view axis:

AngleVectors(pm->ps->viewangles, pml.forward, pml.right, pml.up);

So I set the pml.foward, .right, and .up to absolute values:

pml.forward[0] = 90;
pml.forward[1] = 0;
pml.forward[2] = 0;
pml.right[0] = 0;
pml.right[1] = -90;
pml.right[2] = 0;
pml.up[0] = 0;
pml.up[1] = 0;
pml.up[2] = 90;

And that seems to work fine.
Locked