Page 1 of 1

gFaceAngle

Posted: Fri Dec 26, 2008 6:53 pm
by pms
I believe the bool protects from abuse or getting stuck. This is still a safer way to do this instead of setting char data to illegal ranges. I believe this caused a bug in MoveUtils and I had borrowed the logic from this.

MQ2Pulse.cpp - Line 201

Code: Select all

edit: this was a bad implementation
I would say changes in red but I fixed the spacing too, with spaces not tabs even!

gLookAngle

Posted: Mon Dec 29, 2008 2:39 pm
by pms
gLookAngle uses the same logic. Here is the above idea applied to that as well. Also the double <----> float seems unused (convert back then forth?) but didn't change that since I'm unsure why.

MQ2Pulse.cpp - Line 229ish

Code: Select all

        if (gLookAngle != 10000.0f) {
            if (abs((INT)(pChar->CameraAngle - gLookAngle)) < 5) {
                pChar->CameraAngle = (FLOAT)gLookAngle;
                gLookAngle = 10000.0f;
                TurnNotDone = FALSE;
            } else {
                TurnNotDone = TRUE;
                FLOAT c1 = pChar->CameraAngle;
                FLOAT c2 = (FLOAT)gLookAngle;
                DOUBLE turn = (DOUBLE)(rand() % 200) / 20;
                if (c1 < c2) {
                    c1 += (FLOAT)turn;
                    if (c1 >= 128.0f) c1 -= 128.0f;
                    pChar->CameraAngle = c1;
                } else {
                    c1 -= (FLOAT)turn;
                    if (c1 <= -128.0f) c1 += 128.0f;
                    pChar->CameraAngle = c1;
                }
            }
        }

Re: gFaceAngle

Posted: Mon Dec 29, 2008 3:19 pm
by dont_know_at_all
pms wrote:MQ2Pulse.cpp - Line 201
What problem are you fixing here?

Posted: Mon Dec 29, 2008 6:01 pm
by pms
repasting this:

the way it was done before it would set heading to an invalid range then correct after the fact if it was out of range. in testing for loose heading in moveutils i found that when you set values out of range, your char can get stuck vibrating left and right over and over. it doesnt happen every time but the way i redid it above it wont let the value get set until it is within the correct range.

looking at this the only part i did not understand was declaring turn as a double then casting it to a float, greater rand precision when rounding back?

also i was under the impression when setting doubles you would use "10.0" whereas float you would use "10.0f" to avoid compiler warnings. this gives none but if my understanding is correct perhaps i should be anal and edit lines like this:

gLookAngle = 10000.0f;

to

gLookAngle = 10000.0; ?

Posted: Mon Dec 29, 2008 9:24 pm
by dont_know_at_all
How does it get stuck? The EQ client is single threaded. There is no way for any other part of the code to read the bad values before it is changed to the right value...

Posted: Tue Dec 30, 2008 12:06 am
by pms
good to know, this isn't needed then. was just the way i was calling it in moveutils.

thanks!