MovingBlocks/DestinationSol

(minor) When getting crushed between a starport and a hub, you can have negative HP

Esnardo opened this issue · 1 comments

This one is kinda rare since it involves having a save where a planet generates so close to a hub that it's startport will intersect the hub within a reasonable timeframe. It also doesn't affect gameplay (all effects clear on respawn), so it's a really low priority unless there's another way to trigger it (maybe you don't need 2 immovable objects?)

Issue: see title

Repro:

  1. Generate a world where a starport passes through a hub
  2. get crushed in the gap
  3. Sometimes your HP bar will show up as negative

V2.0.0

LGK20, Android

For anyone interested in fixing this, it should be easy enough to clamp ship health so that it doesn't go below zero. If it does, then it should just be reset to 0. The code referenced below should be responsible for ship damage:

private void getHitWith(float dmg, SolGame game, Vector2 position, DmgType dmgType) {
playHitSound(game, position, dmgType);
boolean wasAlive = myHull.life > 0;
myHull.life -= dmg;
if (wasAlive && myHull.life <= 0) {
onDeath(game);
Vector2 shipPos = getPosition();
game.getSpecialEffects().explodeShip(game, shipPos, myHull.config.getSize());
game.getSoundManager().play(game, game.getContext().get(SpecialSounds.class).shipExplosion, null, this);
}
if (dmgType == DmgType.FIRE) {
myFireAwait = MAX_FIRE_AWAIT;
}
}