AmericanNero
Seasoned veteran member
- Joined
- Oct 13, 2020
- RedCents
- 4,709¢
Dear MQ2 Deities. I would like to address an issue, and provide the fix.
First the annoyance. Then it's all unicorns and rainbows.
The simplest case to reproduce:
1) /face heading 0 - this points you due North
2) /echo ${Me.Heading.Degrees} to see. It should return 360.00
3) /face heading 360.00 - works fine. This is aka 0.00.
3) /face heading 20. It should turn you 20 degrees to the right. But it doesn't.
4) /echo ${Me.Heading.Degrees} will now show you 340.00 (which is correct - degrees increase clockwise)
5) /face heading 340.00 - whoa whiskey-tango-foxtrot! it spun you around to the other 340.00.
The code converts the degrees float into a range from 0-512, which I presume is how eq stores it.
A value of 0 or 512 corresponds to 0 or 360 degrees.
128 corresponds to 90 deg
256 to 180 deg
384 to 270 deg.
The conversion would be:
1) Degrees mod 360
2) Degrees * 1.422222...and so on.
[CODE lang="cpp" title="Old and Busted - Line 2365 MQ2Commands.cpp"]gFaceAngle = Heading / 0.703125f;
if (gFaceAngle >= 512.0f) gFaceAngle -= 512.0f;
if (gFaceAngle<0.0f) gFaceAngle += 512.0f;[/CODE]
[CODE lang="cpp" title="New Hotness"]gFaceAngle = Heading % 360.0f;
gFaceAngle *= 1.422222f;[/CODE]
AN
First the annoyance. Then it's all unicorns and rainbows.
The simplest case to reproduce:
1) /face heading 0 - this points you due North
2) /echo ${Me.Heading.Degrees} to see. It should return 360.00
3) /face heading 360.00 - works fine. This is aka 0.00.
3) /face heading 20. It should turn you 20 degrees to the right. But it doesn't.
4) /echo ${Me.Heading.Degrees} will now show you 340.00 (which is correct - degrees increase clockwise)
5) /face heading 340.00 - whoa whiskey-tango-foxtrot! it spun you around to the other 340.00.
The code converts the degrees float into a range from 0-512, which I presume is how eq stores it.
A value of 0 or 512 corresponds to 0 or 360 degrees.
128 corresponds to 90 deg
256 to 180 deg
384 to 270 deg.
The conversion would be:
1) Degrees mod 360
2) Degrees * 1.422222...and so on.
[CODE lang="cpp" title="Old and Busted - Line 2365 MQ2Commands.cpp"]gFaceAngle = Heading / 0.703125f;
if (gFaceAngle >= 512.0f) gFaceAngle -= 512.0f;
if (gFaceAngle<0.0f) gFaceAngle += 512.0f;[/CODE]
[CODE lang="cpp" title="New Hotness"]gFaceAngle = Heading % 360.0f;
gFaceAngle *= 1.422222f;[/CODE]
AN


Go for it!