Author Topic: Damage Algorithm  (Read 1913 times)

0 Members and 1 Guest are viewing this topic.

Offline pSimon

  • 23
Is there a good description of the damage algorithm anywhere?

I'm playing around with armor.tbl values. and some of my results feel a trifle odd.

I'm assuming it goes something like this, without armor tables:

- Weapon damage * SH fac applied to shield
- If shield>0 stop
- Weapon damage * Hull fac applied to hull
- Weapon damage * Subsys fac applied to subsystem

1] Is this correct?

2] _When_ do the calculations in armor.tbl get applied? (i.e to raw dmg, or to dmg*whatever_factor)

3] What do the "weapon piercing" parameters actually do?




 
- If shield>0 stop
This is definitely not true. Try outfitting a myrm with 2 banks or Prom S(total 6 gunpoints) and you'll be able to oneshot manticores. You will break a shield quadrant and instatlly do enough hull damage to kill them.

Same for the Trebuchet, or Torando, or Hornet, they all do enough damage to penetrate a quadrant and instantly do hull damage.

Calculation order is defined in armor.tbl AFAIK.
« Last Edit: February 26, 2016, 04:42:12 am by FrikgFeek »
[19:31] <MatthTheGeek> you all high up on your mointain looking down at everyone who doesn't beam everything on insane blindfolded

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
The sequence goes like this:
1. Weapon hits ship.
2. Find out how much damage the weapon does (this can vary depending on whether or not it has attenuating damage, or is an unarmed missile)
3. Multiply the damage by the shield factor of the weapon.
4. If damage is positive, retrieve the weapons' damage type and the ship's shield armor type.
5. Scale the damage according to the formulas defined in armor.tbl (this includes difficulty scaling), or just difficulty scaling if no armor types are defined for both ship and weapon.
6. Apply damage to the shield quadrant being hit.
7. If there is damage left over, undo shield scaling.
8. If there is damage left over, retrieve the ship's hull armor type.
9. Apply armor type or difficulty scaling, as per step 5
10. Apply the weapons' armor factor
11. Subtract remaining damage from the ship hull.

- If shield>0 stop
This is definitely not true. Try outfitting a myrm with 2 banks or Prom S(total 6 gunpoints) and you'll be able to oneshot manticores. You will break a shield quadrant and instatlly do enough hull damage to kill them.

It is definitely true. Remember that the game treats every weapon as a separate object, if you hit something with a quad bank of PromS, there will be 4 separate impacts; In your example, the first one or two prom hits will kill the shield, the others will be applied to the hull. This usually happens fast enough that you won't notice the separate impacts.

As for weapon piercing, those parameters determine the point at which the game will add the penetration particle effects (Like the beam piercing effect).
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 
Are you sure about that? What about a single Treb or Grimmler killing a fighter(not a doubleshot)? Is it because of the seperate damage from the shockwave?

If "shield>0 stop" was the case a single Trebuchet would do 0 damage to a Nahema as it has 900 shields and the trebuchet only does 175 shield damage, not enough to fully break a quadrant. You'd get its front quadrant down to 50 with the direct hit and the shockwave would end up stripping the shields completely and then doing 0 hull damage. Yet in game it will bring it down to ~52% hull. That means the trebuchet did ~144 hull damage with the shockwave. I don't know how and why it's that number as it doesn't seem to be related to any of the treb's stats but this is reproducible in-game.

By your calculations it should do 225 hull damage if it hits a quadrant with 50 shielding and no difficulty/armor trickery is involved.
« Last Edit: February 26, 2016, 05:46:29 am by FrikgFeek »
[19:31] <MatthTheGeek> you all high up on your mointain looking down at everyone who doesn't beam everything on insane blindfolded

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
If the weapon deals more damage than the shield quadrant has strength, it will deal the leftovers through the shield.

Additionally, modded weapons can always deal some percentage of their damage through shields.

EDIT: Shockwaves, by default, do as much damage as the weapon itself. That's why the trebuchet deals so much damage.
« Last Edit: February 26, 2016, 10:56:39 am by AdmiralRalwood »
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 
I know that, the problem is that it deals too LITTLE damage. Edited numbers after some testing.

Trebuchet stats:
Damage: 350
Hull Factor: 0.9
Shied factor: 0.5
Subsystem factor: 2.4

Normal calculations would suggest this in the Nahema scenario:

1.Direct trebuchet hit, 175 shield damage. Front quadrant taken from 225 to 50.
2.Shockwave hit, front quadrant taken from 50 to 0, leftover damage is 125
3.Shield factor un-applied, leftover damage is 250
4.Hull factor applied, hull damage equals 225.
5.Nahema left at 25% hull(75/300)

What actually happens.
1.Direct trebuchet hit, 175 shield damage.
2.Shockwave hit, front quadrant taken to 0.
3.????
4.Nahema is around 63% hull, taking ~111 damage.


This seems to be rather consistent, tested it on a zero-effort test mission where you shoot a play-dead Nahema with a treb.
« Last Edit: February 26, 2016, 11:34:50 am by FrikgFeek »
[19:31] <MatthTheGeek> you all high up on your mointain looking down at everyone who doesn't beam everything on insane blindfolded

 
How is the shockwave damage calculated?
If it scales with distance, then hull-to-shields distance could explain the discrepancy. Do you get the full double damage (350) when hitting the shields alone of eg. Seraphim? Or full 630 when hitting an unshielded ship?
The lyf so short, the craft so long to lerne.

 
It's not that. I think I got it.

This step:

7. If there is damage left over, undo shield scaling.


Doesn't happen. It makes sense now. 125 leftover damage from the shockwave after depleting a full quadrant multiplied by the armor factor comes out to 112.5, which would bring the Nahema to 63% hull.

So what ACTUALLY happens is that leftover shield damage is then multiplied by the hull factor without undoing the shield factor multiplication. That means a weapon that has a huge shield factor but a normal hull factor can actually wreck hulls if it manages to pierce the shields with a lot of leftover damage.

Or not, as I've been informed that there is code to specifically un-apply the shield factor if it's >1.
« Last Edit: February 26, 2016, 12:06:43 pm by FrikgFeek »
[19:31] <MatthTheGeek> you all high up on your mointain looking down at everyone who doesn't beam everything on insane blindfolded

 

Offline pSimon

  • 23
Thanks for the info.

Plainly it's not the stupid question I feared it might be.

Would it be sensible to wiki this?

 
I just realised what I wrote.

If shield>0 stop is definitely true, I just somehow misread it, thinking it means that all damage stops if shields absorbed something. What you actually meant was that all damage stops if there are shield points left over after the damage is taken.

My bad.
[19:31] <MatthTheGeek> you all high up on your mointain looking down at everyone who doesn't beam everything on insane blindfolded

 

Offline pSimon

  • 23
I could have put it better, TBH