void __cdecl TakeDamage(int damage)
{
if ( GameState | 2 )
{
if ( !invincTimer )
{
PlaySound(16, 1);
PlayerFlags &= -2u;
invincTimer = 0x80u;
if ( InFishBattle != 1 )
PlayerYVel = -0x400u;
currentHealth -= damage;
if ( EquippedItems & 0x80 )
{
if ( numWhimStars > 0 )
--numWhimStars;
}
if ( EquippedItems & 4 )
weaponEnergy[5 * currentWeapon] -= damage;
else
weaponEnergy[5 * currentWeapon] -= 2 * damage;
while ( weaponEnergy[5 * currentWeapon] < 0 )
{
if ( weaponLevel[5 * currentWeapon] <= 1 )
{
weaponEnergy[5 * currentWeapon] = 0;
}
else
{
--weaponLevel[5 * currentWeapon];
weaponEnergy[5 * currentWeapon] += *(&dword_493660[3 * weaponType[5 * currentWeapon]]
+ 4 * (weaponLevel[5 * currentWeapon] - 1));
if ( currentHealth > 0 )
{
if ( weaponType[5 * currentWeapon] != 13 )
CreateEffect(PlayerX, PlayerY, 10, 2);
}
}
}
createNumObj(&PlayerX, &PlayerY, -damage);
if ( currentHealth <= 0 )
{
PlaySound(17, 1);
PlayerFlags = 0;
createExplosion(PlayerX, PlayerY, 5120, 64);
runTsc(40);
}
}
}
}