Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Esnardo opened this issue Dec 3, 2020 · 1 comment
Labels
bug Good First Issue Doesn't require much work or knowledge. Good for beginners

Comments

@Esnardo
Copy link
Contributor

Esnardo commented Dec 3, 2020

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

@BenjaminAmos BenjaminAmos added the Good First Issue Doesn't require much work or knowledge. Good for beginners label Mar 11, 2023
@BenjaminAmos
Copy link
Contributor

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;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Good First Issue Doesn't require much work or knowledge. Good for beginners
Projects
None yet
Development

No branches or pull requests

2 participants