void __cdecl PlayerAgil(int CanControlPC)
{
int v1; // ecx@162
int v2; // eax@166
int v3; // edx@170
int v4; // eax@171
int WaterX2; // ST48_4@201
int WaterVelY2; // ST10_4@201
int WaterVelX2; // eax@201
int WaterX; // ST48_4@207
int WaterVelY; // ST10_4@207
int WaterVelX; // eax@207
signed int WaterDir; // [sp+0h] [bp-2Ch]@195
unsigned int JumpSpeed; // [sp+4h] [bp-28h]@4
unsigned int WalkSpeed; // [sp+8h] [bp-24h]@4
unsigned int Friction; // [sp+Ch] [bp-20h]@4
unsigned int Grav; // [sp+10h] [bp-1Ch]@4
unsigned int AirControl; // [sp+14h] [bp-18h]@4
unsigned int MaxRunSpeed; // [sp+18h] [bp-14h]@4
unsigned int GravLow; // [sp+1Ch] [bp-10h]@4
signed int j; // [sp+24h] [bp-8h]@199
signed int i; // [sp+24h] [bp-8h]@205
if ( !(PlayerFlags & 2) )
{
if ( PlayerTileCollis & 0x100 )
{
MaxRunSpeed = 0x196u;
Grav = 0x28u;
GravLow = 0x10u;
JumpSpeed = 0x280u;
WalkSpeed = 0x2Au;
AirControl = 0x10u;
Friction = 0x19u;
}
else
{
MaxRunSpeed = 0x32Cu;
Grav = 0x50u;
GravLow = 0x20u;
JumpSpeed = 0x500u;
WalkSpeed = 0x55u;
AirControl = 0x20u;
Friction = 0x33u;
}
GenerateQmark = 0;
if ( !CanControlPC )
BoostState = 0;
if ( PlayerTileCollis & 8 || PlayerTileCollis & 0x10 || PlayerTileCollis & 0x20 )
{
BoostState = 0;
if ( EquippedItems & 1 )
{
JetPackEnergy = 0x32u;
}
else
{
if ( EquippedItems & 0x20 )
JetPackEnergy = 0x32u;
else
JetPackEnergy = 0;
}
if ( CanControlPC )
{
if ( Key_Pressed != Key_Down || Key_Held != Key_Down || PlayerFlags & 1 || GameState & 4 )
{
if ( Key_Held != Key_Down )
{
if ( KeyLeft & Key_Held )
{
if ( PlayerXVel > -MaxRunSpeed )
PlayerXVel -= WalkSpeed;
}
if ( KeyRight & Key_Held )
{
if ( PlayerXVel < (signed int)MaxRunSpeed )
PlayerXVel += WalkSpeed;
}
if ( KeyLeft & Key_Held )
DirectionFaced = 0;
if ( KeyRight & Key_Held )
DirectionFaced = 2;
}
}
else
{
PlayerFlags |= 1u;
GenerateQmark = 1;
}
}
if ( !(PlayerFlags & 0x20) )
{
if ( PlayerXVel < 0 )
{
if ( PlayerXVel <= -Friction )
PlayerXVel += Friction;
else
PlayerXVel = 0;
}
if ( PlayerXVel > 0 )
{
if ( PlayerXVel >= (signed int)Friction )
PlayerXVel -= Friction;
else
PlayerXVel = 0;
}
}
}
else
{
if ( CanControlPC )
{
if ( EquippedItems & 0x21 )
{
if ( Key_Jump & Key_Pressed )
{
if ( JetPackEnergy )
{
if ( EquippedItems & 1 )
{
BoostState = 1;
if ( PlayerYVel > 256 )
PlayerYVel /= 2;
}
if ( EquippedItems & 0x20 )
{
if ( Key_Up & Key_Held )
{
BoostState = 2;
PlayerXVel = 0;
PlayerYVel = -1535;
}
else
{
if ( KeyLeft & Key_Held )
{
BoostState = 1;
PlayerYVel = 0;
PlayerXVel = -1535;
}
else
{
if ( KeyRight & Key_Held )
{
BoostState = 1;
PlayerYVel = 0;
PlayerXVel = 1535;
}
else
{
if ( Key_Down & Key_Held )
{
BoostState = 3;
PlayerXVel = 0;
PlayerYVel = 1535;
}
else
{
BoostState = 2;
PlayerXVel = 0;
PlayerYVel = -1535;
}
}
}
}
}
}
}
}
if ( KeyLeft & Key_Held )
{
if ( PlayerXVel > -MaxRunSpeed )
PlayerXVel -= AirControl;
}
if ( KeyRight & Key_Held )
{
if ( PlayerXVel < (signed int)MaxRunSpeed )
PlayerXVel += AirControl;
}
if ( KeyLeft & Key_Held )
DirectionFaced = 0;
if ( KeyRight & Key_Held )
DirectionFaced = 2;
}
if ( EquippedItems & 0x20 )
{
if ( BoostState )
{
if ( !(Key_Jump & Key_Held) || !JetPackEnergy )
{
if ( BoostState == 1 )
{
PlayerXVel /= 2;
}
else
{
if ( BoostState == 2 )
PlayerYVel /= 2;
}
}
}
}
if ( !JetPackEnergy || !(Key_Jump & Key_Held) )
BoostState = 0;
}
if ( CanControlPC )
{
if ( Key_Up & Key_Held )
IsFacingUp = 1;
else
IsFacingUp = 0;
IsFacingDown = Key_Down & Key_Held && !(PlayerTileCollis & 8);
if ( Key_Jump & Key_Pressed )
{
if ( PlayerTileCollis & 8 || PlayerTileCollis & 0x10 || PlayerTileCollis & 0x20 )
{
if ( !(PlayerTileCollis & 0x2000) )
{
PlayerYVel = -JumpSpeed;
PlaySound(15, 1);
}
}
}
}
if ( CanControlPC )
{
if ( Key_Held & (Key_Shoot | Key_Jump | Key_Up | KeyRight | KeyLeft) )
PlayerFlags &= 0xFEu;
}
if ( BoostState )
{
if ( JetPackEnergy )
--JetPackEnergy;
}
if ( PlayerTileCollis & 0x1000 )
PlayerXVel -= 136;
if ( PlayerTileCollis & 0x2000 )
PlayerYVel -= 128;
if ( PlayerTileCollis & 0x4000 )
PlayerXVel += 136;
if ( PlayerTileCollis & 0x8000 )
PlayerYVel += 85;
if ( EquippedItems & 0x20 && BoostState )
{
switch ( BoostState )
{
case 1:
if ( PlayerTileCollis & 5 )
PlayerYVel = -256;
if ( !DirectionFaced )
PlayerXVel -= 32;
if ( DirectionFaced == 2 )
PlayerXVel += 32;
if ( Key_Jump & Key_Pressed || JetPackEnergy % 3 == 1 )
{
if ( !DirectionFaced )
CreateEffect(PlayerX + 0x400, PlayerY + 0x400, 7, 2);
if ( DirectionFaced == 2 )
CreateEffect(PlayerX - 0x400, PlayerY + 0x400, 7, 0);
PlaySound(113, 1);
}
break;
case 2:
PlayerYVel -= 32;
if ( Key_Jump & Key_Pressed || JetPackEnergy % 3 == 1 )
{
CreateEffect(PlayerX, PlayerY + 0xC00, 7, 3);
PlaySound(113, 1);
}
break;
case 3:
if ( Key_Jump & Key_Pressed || JetPackEnergy % 3 == 1 )
{
CreateEffect(PlayerX, PlayerY - 0xC00, 7, 1);
PlaySound(113, 1);
}
break;
}
}
else
{
if ( PlayerTileCollis & 0x2000 )
{
PlayerYVel += Grav;
}
else
{
if ( EquippedItems & 1 && BoostState && PlayerYVel > -1024 )
{
PlayerYVel -= 32;
if ( !(JetPackEnergy % 3) )
{
CreateEffect(PlayerX, PlayerY + PCHitrectDown / 2, 7, 3);
PlaySound(113, 1);
}
if ( PlayerTileCollis & 2 )
PlayerYVel = 512;
}
else
{
if ( PlayerYVel < 0 && CanControlPC && Key_Jump & Key_Held )
PlayerYVel += GravLow;
else
PlayerYVel += Grav;
}
}
}
if ( !CanControlPC || !(Key_Jump & Key_Pressed) )
{
if ( PlayerTileCollis & 0x10 )
{
if ( PlayerXVel < 0 )
PlayerYVel = -PlayerXVel;
}
if ( PlayerTileCollis & 0x20 )
{
if ( PlayerXVel > 0 )
PlayerYVel = PlayerXVel;
}
if ( PlayerTileCollis & 8 )
{
v1 = PlayerTileCollis;
if ( v1 & 0x80000 )
{
if ( PlayerXVel < 0 )
PlayerYVel = 1024;
}
}
if ( PlayerTileCollis & 8 )
{
v2 = PlayerTileCollis;
if ( v2 & 0x10000 )
{
if ( PlayerXVel > 0 )
PlayerYVel = 1024;
}
}
if ( PlayerTileCollis & 8 )
{
v3 = PlayerTileCollis;
if ( v3 & 0x20000 )
{
v4 = PlayerTileCollis;
if ( v4 & 0x40000 )
PlayerYVel = 1024;
}
}
}
if ( !(PlayerTileCollis & 0x100) || PlayerTileCollis & 0xF000 )
{
if ( PlayerXVel < -1535 )
PlayerXVel = -1535;
if ( PlayerXVel > 1535 )
PlayerXVel = 1535;
if ( PlayerYVel < -1535 )
PlayerYVel = -1535;
if ( PlayerYVel > 1535 )
PlayerYVel = 1535;
}
else
{
if ( PlayerXVel < -767 )
PlayerXVel = -767;
if ( PlayerXVel > 767 )
PlayerXVel = 767;
if ( PlayerYVel < -767 )
PlayerYVel = -767;
if ( PlayerYVel > 767 )
PlayerYVel = 767;
}
if ( !IsInWater )
{
if ( PlayerTileCollis & 0x100 )
{
if ( PlayerTileCollis & 0x800 )
WaterDir = 2;
else
WaterDir = 0;
if ( PlayerTileCollis & 8 || PlayerYVel <= 512 )
{
if ( PlayerXVel > 512 || PlayerXVel < -512 )
{
for ( i = 0; i < 8; ++i )
{
WaterX = PlayerX + (Random(-8, 8) << 9);
WaterVelY = Random(-512, 128);
WaterVelX = Random(-512, 512);
CreateNPC(73, WaterX, PlayerY, PlayerXVel + WaterVelX, WaterVelY, WaterDir, 0, 0);
}
PlaySound(0x38u, 1);
}
}
else
{
for ( j = 0; j < 8; ++j )
{
WaterX2 = PlayerX + (Random(-8, 8) << 9);
WaterVelY2 = Random(-512, 128) - PlayerYVel / 2;
WaterVelX2 = Random(-512, 512);
CreateNPC(73, WaterX2, PlayerY, PlayerXVel + WaterVelX2, WaterVelY2, WaterDir, 0, 0);
}
PlaySound(0x38u, 1);
}
IsInWater = 1;
}
}
if ( !(PlayerTileCollis & 0x100) )
IsInWater = 0;
if ( PlayerTileCollis & 0x400 )
TakeDamage(10);
if ( DirectionFaced )
{
QuoteCameraOffsetX += 512;
if ( QuoteCameraOffsetX > 32768 )
QuoteCameraOffsetX = 32768;
}
else
{
QuoteCameraOffsetX -= 512;
if ( QuoteCameraOffsetX < -32768 )
QuoteCameraOffsetX = -32768;
}
if ( Key_Up & Key_Held && CanControlPC )
{
QuoteCameraOffsetY -= 512;
if ( QuoteCameraOffsetY < -32768 )
QuoteCameraOffsetY = -32768;
}
else
{
if ( Key_Down & Key_Held && CanControlPC )
{
QuoteCameraOffsetY += 512;
if ( QuoteCameraOffsetY > 32768 )
QuoteCameraOffsetY = 32768;
}
else
{
if ( QuoteCameraOffsetY > 512 )
QuoteCameraOffsetY -= 512;
if ( QuoteCameraOffsetY < -512 )
QuoteCameraOffsetY += 512;
}
}
QuoteCamPosX = QuoteCameraOffsetX + PlayerX;
QuoteCamPosY = QuoteCameraOffsetY + PlayerY;
if ( PlayerXVel > (signed int)Friction || PlayerXVel < -Friction )
PlayerX += PlayerXVel;
PlayerY += PlayerYVel;
}