When moving your Playable Character you can do
16 times QueuePersonCommand() (16 steps) and it will
move exactly 16 pixels.
When you modify your speed with SetPersonSpeedXY() to,
for example,
0.8, then because of a lower speed we need to
compensate with more
QueuePersonCommand() (make more steps).
The formula should be:
16 QueuePersonCommand() * 1 = x QueuePersonCommand() * .8
=> steps = ToInteger(16/speed);
This throws 20 steps to advance 16 pixels at speed 0.8
The problem is that because of rounding problems for
floats,
20 QueuePersonCommand() dont move you 16 pixels into
all directions.
Particulary for 0.8, there is no rounding problem as it
throws an
integer value of 20. But the bug is still there.
Even for speeds where moving steps once moves you
exactly 16 pixels,
it doesnt guarantee that the next steps in the same
direction will
move it 16 pixels again.
A workaround for this is: Before using
QueuePersonCommand(),
you first round your position to an integer position:
var G=GetInputPerson();
SetPersonX(G,GetPersonX(G)); //round float to integer
SetPersonY(G,GetPersonY(G)); //round float to integer
But even when doing this, you've got to compensate
when moving +x or +y you have to add an extra
QueuePersonCommand(),
But this is not correct for speed 0.4 (which gives 40
integer! steps)
For speed 0.4, you have to compensate like this:
if( (speed==.4) && ((xx>0)||(yy>0)) ) steps+=1;
if( (speed==.4) && ((xx<0)||(yy<0)) ) steps-=1;
Maybe it has to do with the fact that:
Abort(0.95-0.05);
doesnt return 0.90 but 0.8999999999999999999999
********************************************************************
Finally, the working workaround is:
speed=GetPersonSpeedX(MainChar);
SetPersonX(MainChar,GetPersonX(MainChar)); //round
float to integer
SetPersonY(MainChar,GetPersonY(MainChar)); //round
float to integer
if
(speed==1||speed==.1||speed==.4||speed==.8||speed==.16)
//Continues with smaller numbers
{
speed-=.009; //Fix Illegal speeds
SetPersonSpeedXY(MainChar,speed,speed);
}
var steps=Math.floor(16/speed);
if((xx>0) ||(yy>0) ) steps+=1; //FIX Sphere BUG
for (var i=0;i<steps;i++)
QueuePersonCommand(MainChar, getCommandDir(xx,yy), false);
********************************************************************
The Quick Check in the BugTest game is pressing "T".
It will Abort() with a message:
Failed with speed=0.8 -Xoffset=-1 Step=20 GPX=342.999999
This means that when my character had speed 0.8, and
going -X (left)
it was at -1 pixels from where it should be (1 pixel
too much to the left)
GPX is GetPersonX and we see that instead of 343, we
are at 342.
You can edit AutoMove16() and enable the workaround to
fix this.
********************************************************************
Bugtest usage:
First press R (round) F (floor) or C (ceil) to
determine the rounding
method for
steps = ToInteger(16/speed);
Then using PgUp/PgDn set your moving speed.
Move your Character 16 pixels using W,A,D,X
(tap, dont hold the key as you will oveflow the
PersonQueue resulting in a wrong offset)
FBnil
BugTest_QueuPersonCommand_SetPersonSpeed