Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Hitpoints < 0f results in ship disappearing from battlefield  (Read 2392 times)

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Hitpoints < 0f results in ship disappearing from battlefield
« on: January 31, 2014, 11:47:55 AM »

Basically, if Hitpoints < 0f, then a ship just goes poof, no explosion and no Hulk. 

I presume this is some sort of safety catch to prevent div-by-zero somewhere; could it maybe force the hitpoints back to zero or whatever is safe at that point and convert it into a Hulk instead?  I'm preventing it over here with a catch that sets Hitpoints to 0.00001f in that case, but I thought I'd mention that this can happen and that it's probably not the desired behavior.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Hitpoints < 0f results in ship disappearing from battlefield
« Reply #1 on: January 31, 2014, 12:03:35 PM »

Changed so they don't disappear, as I don't think this actually affects anything in vanilla.

Not sure how this would come up as a problem - you probably shouldn't be setting hitpoints to <0, and as far as I can tell, vanilla doesn't do that.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Hitpoints < 0f results in ship disappearing from battlefield
« Reply #2 on: January 31, 2014, 01:54:02 PM »

We're you directly applying damage to the hull?  I'll have to take note of that as I've been thinking of looking at weapons that bypass shields and armour.

On another note, if you 'heal' a ship too much it will cause a crash as well. I'll need to check the logs but I think it had something to do with the hull strength bar length becoming too long.

That said I don't think this would come up on vanilla gameplay, ever.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Hitpoints < 0f results in ship disappearing from battlefield
« Reply #3 on: January 31, 2014, 04:13:55 PM »

Yeah, I was setting Hitpoint values directly. 

This has been 100% safe in testing:

Code
ship.setHitpoints(Math.max(0.00001f,ship.getHitpoints() - dam));

But I saw this error with:

Code
ship.setHitpoints(Math.max(0f,ship.getHitpoints() - dam));

...probably floating-point silliness :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Hitpoints < 0f results in ship disappearing from battlefield
« Reply #4 on: January 31, 2014, 04:23:30 PM »

I'm still getting around to it, but can you kill an shop with 'direct' hitpoint manipulation? Aka, cause it to explode. Or do you need to cause normal in-game mechanic damage to get the final kill?

BTW I'm having so much fun messing with the ShipAPI
« Last Edit: January 31, 2014, 05:49:00 PM by Debido »
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Hitpoints < 0f results in ship disappearing from battlefield
« Reply #5 on: January 31, 2014, 04:32:08 PM »

Yes, that always results in a dead ship, at least over here.

Oh, snap.  I forgot about the "critical reactor meltdown" script... I'll bet that's what's happening; some weird interaction where it's deleting the entity or something.  Got to check what happens there if Hitpoints < 0f...

Anyhow, like Alex said, setting to 0f should be safe and should result in a dead ship.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Hitpoints < 0f results in ship disappearing from battlefield
« Reply #6 on: January 31, 2014, 04:35:03 PM »

Nope, that doesn't do it; that's all direct damage.  So hitting 0f really does appear to be triggering the sudden removal of the entity.  Anyhow, fixed over here and setting to 0.00001f always results in "dead" :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack