• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Need Help Questions regarding how the DamageX variables work for cannon ammunition

Scheveningen

Landlubber
So I admit I'm confused, I went through Atom to skim pretty much every file in the PROGRAM folder (since to my understanding that's everything about the game that's coded), and I'm here to ask another silly question.

How do the damage formulas for ship munition types work?

Let's say I'm referring to the vanilla cannonballs for a second.


Goods[GOOD_BALLS].DamageHull = 6.0;
Goods[GOOD_BALLS].DamageRig = 2.0;
Goods[GOOD_BALLS].DamageCrew = 1.5;
Goods[GOOD_BALLS].Dispersion.X = 1.0;
Goods[GOOD_BALLS].Dispersion.Y = 3.0;
Goods[GOOD_BALLS].Dispersion.V = 0.03;

My usual assumption would be that irrespective of the cannon caliber and any defensive abilities the enemy captain of that ship has, we'll say the damage multiplier for a single cannon that fires deals 6 damage to an enemy ship.

The problem is that I've attempted to do manual changes to these variables a few times (both for the realistic cannons and the arcade cannon fields) and I hadn't seen any noticeable change until I tweaked the DamageCrew variable to be under "1", in which suddenly I turned enemy crews into swiss cheese.

Which leads me to potentially assume that these aren't multipliers but actually is a divisor.

Either that or my testing is totally wrong, but I honestly have no clue how the damage variables are supposed to factor in, I'm basically changing them blindly and don't know how to really calculate the damage involved. Is there an equation somewhere in the code that I missed? I feel pretty silly not being able to figure this out.
 
Are those variables references anywhere in the PROGRAM\SEA_AI folder?
If so, that should probably tell you how they are used.
 
They're certainly multipliers. I've no idea why a 'DamageCrew' attribute less than 1 would cause more damage. In any case, the files you want are "PROGRAM\SEA_AI\AIShip.c" and "PROGRAM\BATTLE_INTERFACE\BattleInterface.c". Look for functions 'Ship_ApplyHullHitpoints' and 'Ship_ApplyCrewHitpoints' in the first, and look for 'GetRigDamage' in the second.
 
{
case GOOD_BALLS:
fDamage = fDamage + MAST_BALL_SCL * hp * fMult;
break;

case GOOD_GRAPES:
fDamage = fDamage + MAST_GRAPE_SCL * hp * fMult;
break;

case GOOD_KNIPPELS:
fDamage = fDamage + MAST_CHAIN_SCL * hp * fMult;
break;

case GOOD_BOMBS:
fDamage = fDamage + MAST_BOMB_SCL * hp * fMult;
break;
}

This is in SEA_AI\AIShip.c, and the original thing I ripped a mild page out of was in PROGRAM\STORE\initGoods.c.

I think it's not really a multiplier in that case. Although to be fair I'm not sure what to think.
 
MAST_BALL_SCL looks like it may be a #define somewhere. Those 'goods' values don't appear to be used there.
Maybe the use of those values is hidden away somewhere in the engine/DLLs?
That 'Dispersion' stuff certainly sounds like it could be used by the engine, rather than anything in the PROGRAM folder.
If so, those three 'Damage' values might still do something and could show up as part of those 'fDamage' values. Somehow. :confused:
 
Ah, alright.

I was aiming to adjust the effectiveness of grapeshot since despite around 15 or so salvos on a Fleut-Of-War I was trading broadsides with, I wasn't able to put much of a dent in the manpower, no matter what angle I tried or how close I got. I endangered my ship too much and I eventually decided to just savescum back to the original save I loaded before looking for a prize ship.

I had a good gunner so accuracy wasn't the problem, most of my grapeshot was indeed hitting, it just wasn't effective at all.
 
MAST_GRAPE_SCL
See if you can find where that is defined.
Maybe tweaking that will be more effective?

Might also be worth noting that changes to the goods init file won't take effect until you start a new game.
Especially in the stock game, because that doesn't have reinit functionality.
 
That's defined in "InternalSettings.h". But that's for damage to masts. It won't do anything for damage to crew.

Crew damage is calculated in this part of 'Ship_HullHitEvent' in "AIShip.c":
Code:
       float fCrewDamage;
       if (USE_REAL_CANNONS)
           fCrewDamage = stf(rBall.DamageCrew) * fCannonDamageMultiply * AIShip_isPerksUse(rBallCharacter.TmpPerks.CrewDamageUp, 1.0, 1.10); // 1.15  KNB;
       else
           fCrewDamage = stf(rBall.DamageCrew) * fCannonDamageMultiply * AIShip_isPerksUse(rBallCharacter.TmpPerks.CrewDamageUp, 1.0, 1.15);
// KK -->
//trace("fCrewDamage="+fCrewDamage);
       fCrewDamage = FRAND(fCrewDamage);
I wonder why that 'FRAND' line is there. It means the damage from the hit is calculated, taking into account damage rating for ammo type ("rBall.DamageCrew"), cannon size ("fCannonDamageMultiply") and whether the firing ship has the "Increase Crew Damage" perk. And then the actual damage is set to a random number between 0 and the calculated number. Maybe change it to 'fCrewDamage = FRAND(fCrewDamage*2)' so that you get a random damage between 0 and double, and the average should then be the original calculated damage.

Having said that, I routinely use grapeshot myself. A few good broadsides of that have a reasonable chance of making an enemy ship surrender, or failing that, weaken the enemy's crew in both strength and morale, so that the boarding is a bit easier.
 
Having said that, I routinely use grapeshot myself. A few good broadsides of that have a reasonable chance of making an enemy ship surrender, or failing that, weaken the enemy's crew in both strength and morale, so that the boarding is a bit easier.
I think @Scheveningen said he's working with the stock game, without mods.
Surrender is a mod-added feature, so that won't happen. And I think morale is mod-added too, so that doesn't apply either.
Plus all the damage modifiers have probably been tweaked a lot over the years, so it could be that the original game was badly balanced and the mod is better.

I wonder why that 'FRAND' line is there. It means the damage from the hit is calculated, taking into account damage rating for ammo type ("rBall.DamageCrew"), cannon size ("fCannonDamageMultiply") and whether the firing ship has the "Increase Crew Damage" perk. And then the actual damage is set to a random number between 0 and the calculated number. Maybe change it to 'fCrewDamage = FRAND(fCrewDamage*2)' so that you get a random damage between 0 and double, and the average should then be the original calculated damage.
That does indeed seem a bit odd.
As an alternative, might I suggest 0.5*fCrewDamage+rand(0.5*fCrewDamage) ?
That way, at least you've got 50% fixed damage, rather than 100% random (with some chance at zero despite a correct hit).

Of course both approaches could easily be combined.
 
Raise that to 0.5*fCrewDamage+frand(0.5*fCrewDamage)+frand(0.5*fCrewDamage) perhaps? Each frand(0.5*fCrewDamage) should on average return 0.25*fCrewDamage, two of them should average to 0.5*fCrewDamage with a bell rather than linear distribution, then add on the fixed 0.5*fCrewDamage and the net result should be a randomised damage centred on the originally calculated value.
 
Oh, sorry, when I referenced the "vanilla cannonballs" I was making a point of example for the sake of reference since those stats for the cannonballs was what was adjusted for vanilla. I am playing with most of the mods flicked on for New Horizons. Enemy ship surrendering is possible in my version of the game ("They've striked their colors, captain!")

I will try your suggestion regarding the bell curve calculation as that seems like the better idea. Appreciate the help! I'm only just getting into understanding code, so I'm not quite *savvy* at it nor do I know what I'm looking for half the time. xD
 
Note that the increased crew damage goes both ways. If you suddenly find yourself short of crew after a few broadsides from that fleut of war, it's your own fault. xD
 
Oh yes, I'm totally fine with that. I felt as if my own crew applied on the same principle of being nearly untouchable since the crew damage formulas were off. Having only a 50% chance of doing even a little bit of manpower damage didn't seem fun.
 
It seemed that *2 was too much of a modifier, eventually I just adjusted it to *1.2 for a flat 20% bonus, so that grapeshot broadsides deal at least 20% damage to crew and at most 120% damage.

Thanks anyway!
 
Last edited:
Does that mean you're now using frand(fCrewDamage * 1.2)?

It occurs to me that random credit damage, even down to 0, may be realistic. Hull damage certainly happens; if you've hit the ship, you've put a hole somewhere. But you could easily hit an area where there is no crew, e.g. the captain's cabin - nobody should be in there during a battle, especially the captain!
 
Effectively, yeah. I admittedly hadn't tried out 0.5*fCrewDamage+frand(0.5*fCrewDamage)+frand(0.5*fCrewDamage) yet, but I'll give it a try when I get around to it.
 
That will give the same average as frand(fCrewDamage * 2), which you say is too much. You could try:
  • frand(0.5*fCrewDamage) + frand(0.5*fCrewDamage): same average as original but more centred, so less chance of 0 and also less chance of full damage;
  • frand(0.6*fCrewDamage) + frand(0.6*fCrewDamage): same average as what you are now using, again more centred;
  • 0.1*fCrewDamage + frand(0.5*fCrewDamage) + frand(0.5*fCrewDamage): same average as what you are now using, more centred, guaranteed to score at least some slight damage.
 
Last edited:
Back
Top