Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Beam weapons should target bounds, not collision/shield radius  (Read 2798 times)

NikolaiLev

  • Captain
  • ****
  • Posts: 325
    • View Profile
Beam weapons should target bounds, not collision/shield radius
« on: November 28, 2014, 06:26:54 PM »

I'm sure everyone knows by now that if you're in range of a ship, your beam weapons may autofire yet still miss the target.  This is because they target not bounds, but the collision and/or shield radius.  This is especially obvious if you have a long but thin ship like the Conquest.

I'm aware this is undoubtedly done for performance reasons.  But I honestly think it'd worth it to either allow the player an option, or accept the performance hit so weapons could be more accurate.  At least projectile weapons have fadeout time so they actually hit ships to a degree.
Logged


nomadic_leader

  • Admiral
  • *****
  • Posts: 725
    • View Profile
Re: Beam weapons should target bounds, not collision/shield radius
« Reply #1 on: November 29, 2014, 03:13:15 AM »

E.g. this bug thread I submitted.

Most of the time it's fine, so we only need a less performance costly 'workaround' for  the egregious cases. By egregious I mean like the borer drones vs. the Atlas, where an entire ship system is negated, and seeing it jars you out of the game.

A couple issues with making bounds targeting a settings option:

  • A bunch of obscure options is not desirable to me as an end-user. Don't know how developers feel.
  • It's a performance option that alters balance (e.g. Borer vs. Atlas). So every situation in vanilla and mods would have to be playtested with and without the option, tests in the code to see if the option is enabled, different behaviors for on vs off, etc.

Having every ship a ball like the enforcer or dominator isn't the solution; that's boring.

I don't know about performance optimization, so here are my very uneducated suggestions for workarounds. Knowledgeable people can contribute more useful ideas.

  • Some beams always target 20% inside the shield radius?
  • Some beams always target the collision radius instead of the shield radius?
  • Like OP says-Beam exceed 'official' range (with damage falloff) like projectiles?
  • AI/autofire has a separate procedure for target whose length:width ratio exceeds X. (but this mean's every time the game wants to fire a beam it has to think: "ok, what is the length:width ratio of this target?"; it sounds costly)
  • Remove the systems/weapons where this is going to be an existential problem. Like frag bombs: cool, but the AI couldn't use them right, so they were removed
« Last Edit: November 29, 2014, 03:17:39 AM by nomadic_leader »
Logged

Megas

  • Admiral
  • *****
  • Posts: 12159
    • View Profile
Re: Beam weapons should target bounds, not collision/shield radius
« Reply #2 on: November 29, 2014, 05:41:07 AM »

Odyssey is another frequent case, thanks to its long, thin shape.  When I used to play with Odyssey flagship much, I frequently (and shamelessly) abused the AI to avoid taking hits.
Logged

TJJ

  • Admiral
  • *****
  • Posts: 1905
    • View Profile
Re: Beam weapons should target bounds, not collision/shield radius
« Reply #3 on: November 29, 2014, 06:04:51 AM »

Ellipse<->line intersection isn't that much more expensive than circle<->line.

Though if it's a heavily used bit of code (which I imagine it could be, given the number of weapon arcs being AI controlled in a large battle), you could always pre-compute the projected bounds (on a per-hull basis), and interpolate between them to get a close approximation of the true width.
Such an approach would use a tiny amount of extra memory, but would be no slower than line<->circle intersection & would be a lot more accurate.
Logged

TheOverWhelming

  • Ensign
  • *
  • Posts: 34
    • View Profile
Re: Beam weapons should target bounds, not collision/shield radius
« Reply #4 on: December 02, 2014, 10:57:23 PM »

If the AI knows it's not hitting the ship (doing no damage in any way), just decrease the distance the AI needs to fire by what the game would consider the 'width' of a ship (the smallest distance between two bounds coordinates that aren't close to each other on the list)
This kind of thing is only a problem on long ships or awkwardish shape ships.  This would only work if, in the code, the game realizes or can easily realize it is doing damage

Using ellipse calculations would only help for long thin ships and the problem might still occur
Logged

Cosmitz

  • Admiral
  • *****
  • Posts: 758
    • View Profile
Re: Beam weapons should target bounds, not collision/shield radius
« Reply #5 on: December 03, 2014, 02:07:05 AM »

Ellipse<->line intersection isn't that much more expensive than circle<->line.

Though if it's a heavily used bit of code (which I imagine it could be, given the number of weapon arcs being AI controlled in a large battle), you could always pre-compute the projected bounds (on a per-hull basis), and interpolate between them to get a close approximation of the true width.
Such an approach would use a tiny amount of extra memory, but would be no slower than line<->circle intersection & would be a lot more accurate.

Alex has mentioned before that the bounds are used for a lot of calculations, including pathing and generally all the AI trickery. I'd think that if it was easy we'd have had a fix before now, given how many mods want 'long' ships.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Beam weapons should target bounds, not collision/shield radius
« Reply #6 on: December 03, 2014, 02:48:42 AM »

The problem comes from scale: calculating flight patch with the real bounds for each ship is somewhat costly but doable since we rarely have more than 20 ships around (fighters, drones and missiles don't need that). But unlike RTS games, in SS each weapon has it's own Auto-fire AI running each frame. Suddenly you are talking about 200+ weapons in large battles that would have to calculate bound collisions each frame, in addition to the ships.

Maybe it could be possible to simply add more that one collision radius on ships, imperfect but still better, for a small CPU cost. Or target a random bound point in range instead of calculating line intersections when targeting the center of the ship?

But this topic has been brought up with each update, and since it is mostly relevant with mods I doubt we will see a solution come in vanilla, or at least not before the final polish phase. Especially now that we have TwigLib that is meant to deal with this issue in mods.
Logged
 

NikolaiLev

  • Captain
  • ****
  • Posts: 325
    • View Profile
Re: Beam weapons should target bounds, not collision/shield radius
« Reply #7 on: December 04, 2014, 10:06:22 PM »

The problem comes from scale: calculating flight patch with the real bounds for each ship is somewhat costly but doable since we rarely have more than 20 ships around (fighters, drones and missiles don't need that). But unlike RTS games, in SS each weapon has it's own Auto-fire AI running each frame. Suddenly you are talking about 200+ weapons in large battles that would have to calculate bound collisions each frame, in addition to the ships.

Maybe it could be possible to simply add more that one collision radius on ships, imperfect but still better, for a small CPU cost. Or target a random bound point in range instead of calculating line intersections when targeting the center of the ship?

But this topic has been brought up with each update, and since it is mostly relevant with mods I doubt we will see a solution come in vanilla, or at least not before the final polish phase. Especially now that we have TwigLib that is meant to deal with this issue in mods.

May be possible to make the collision radius an ovaloid instead of a circle where appropriate.  This could be done automatically or determined by the modder.
Logged