• 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!

Realistic Guns?

KnowNothingBozo

Landlubber
Storm Modder
Hi all, I picked this game up a while ago and applied the build mod. You've done some great things here, but I wasn't quite satisfied with the gunnery. The cannon just seemed far too weak and short ranged in the game. And who's ever heard of naval cannon firing bombs? From what I've read, cannons could fire round shot at about the speed of sound and had enough range to begin an engagement at well over a mile away, even though they had little chance of hitting anything past 400 yards.

After searching these forums and looking through the code, I've managed to almost entirely remove bombs from my game. After that, it only took me a liittle more research to find and implement more realistic cannon muzzle velocities and fire arcs. It was surprising, but the game plays remarkably well with cannons that can fire over a mile at 5 degrees elevation. I didn't even have to do too much fiddling with dispersion values; hitting a small ship past 200 yards is nearly impossible if the seas are in the least bit rough.


There are a lot of things I can't do, though. I have a basic knoledge of C/C++ (a required `one-semester` course in technical computing...), so I can read and understand most of the code, but I don't really know where to get started on adding stuff. Basically, I want to add ricochets and `ammo-based` inaccuracy, but I have no idea how to start.

It seems as if it might be possible to simulate ricochet by creating a new cannonball with Ball_WaterHitEvent() in AIBalls.c if a few conditions are met, but I don't know what any of the calls are. It would need to know the velocity of the cannonball and some value for the roughness of the seas. It would be pretty straightforward, but is there any provision for creating a new cannonball?

It likewise seems possible to add a switch to do different dispersion calculations for each ammo type, but I don't know how to do this either. This isn't quite as vital, but it seems easy enough to add.


A couple of questions too, if I might: how complex are the shot physics? Is air resistance applied to the rounds? If so, does damage vary based on velocity? If not, is there any way to fix this?


This is all more suggestion than anything, but I felt like showing at least a little bit of initiative. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/hi.gif" style="vertical-align:middle" emoid=":gday" border="0" alt="hi.gif" /> <b>KnowNothingBozo, </b>and welcome aboard! Have an ale! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/beer2.gif" style="vertical-align:middle" emoid=":beer" border="0" alt="beer2.gif" />

Wow, I can't honestly say you're a `Know-Nothing`, Bozo! These are some great questions, and you quite obviously know a bit about coding...

Here are some helpful tutorials and other code help from the PotC Modding Wiki:

<a href="http://robotsdontbleed.com/wacko/wakka.php?wakka=POTCwiki" target="_blank">http://robotsdontbleed.com/wacko/wakka.php...?wakka=POTCwiki</a>

Sounds like you've got a really cool mod going - I am not the one to answer questions like this, I'm just a hack - but there are a couple of people here who will be able to address your concerns/questions... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />

BTW, we're not responsible for the bombs, LOL! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" /> That was stock in the game... There have been some attempts to do exactly what you are doing, so this mod, if you are willing to share, will be greatly appreciated! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />
 
Well i can agree to most of that, i mean a normal cannon ball lets say 24 ib, fired would pretty much go starit through most ships if its fired from close, i think there should be a longer loading time, but more damage to balance it. And yes, ships could fire very long. It would be great if you could do this, just imagen being bombed by a MoW <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" /> . Keep up the work mate! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />
 
After a bit of fiddling, it doesn't appear that ricochets are possible; I just see no way to deterimine the velocity of a ball hitting the water. I hope someone can prove me wrong here.

Ammo dependent accuracy, however, was as easy to do as I'd hoped. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> It actually looked like someone meant to do this and forgot, because the hook for the shot type was already there. Note that I've also changed velocity dispersion to be a configurable percentage of v0 and halved the affect of the accuracy trait (so the guns have more innate inaccuracy...).

In AIBalls.c, void Ball_AddBall:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->  AIBalls.Type = Goods[sti(aCharacter.Ship.Cannons.Charge.Type)].Name;



 // for type "balls"

 float fTempDispersionY = Degree2Radian(8.0);

 float fTempDispersionX = Degree2Radian(3.0);

 float fTempDispersionV = 0.03; // in percent



 switch (AIBalls.Type)

 {

   case "Grapes":

     fTempDispersionY = Degree2Radian(18.0);

     fTempDispersionX = Degree2Radian(8.0);

     fTempDispersionV = 0.15;

   break;

   case "Knippels":

     fTempDispersionY = Degree2Radian(14.0);

     fTempDispersionX = Degree2Radian(6.0);

     fTempDispersionV = 0.10;

   break;

   case "Bombs":

     fTempDispersionY = Degree2Radian(10.0);

     fTempDispersionX = Degree2Radian(4.0);

     fTempDispersionV = 0.06;

   break;

 }



 float fAccuracy = 1.0 - 0.5 * stf(aCharacter.TmpSkill.Accuracy);

 AIBalls.Dir = fDirAng + fAccuracy * fTempDispersionY * (frnd() - 0.5);

 AIBalls.SpdV0 = fSpeedV0 + fAccuracy * (fTempDispersionV * fSpeedV0) * (frnd() - 0.5);

 AIBalls.Ang = fHeightAng + fAccuracy * fTempDispersionX * (frnd() - 0.5);<!--c2--></div><!--ec2-->

After looking through the code, it doesn't appear that range has any affect whatsoever on damage. I should be able to write a quick hack that scales damage based on the range from the firing ship to the target, however, letting me really boost the damage each shot does at close range. I'm just not sure how quickly it should decay. If it's possible to determine the velocities or orientations of each ship as well as their positions, I should be able to give a bonus for raking fire, too. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Anyway, that's my next project, I'm going to play the game now.
<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/keith.gif" style="vertical-align:middle" emoid=":keith" border="0" alt="keith.gif" />
 
Wow, this is great!!! WTG! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />
 
Thanks, although I haven't really done anything very hard yet.

I did find something interesting, though: the cannonballs normally move at the equivalent of 3x time accelleration. I'm not sure if everyone already knew this, but it came as quite a shock to me. I got kind of suspicious that my modded cannonballs were moving at hypersonic speed, and started to wonder why the shots always *looked* right in the original, and then I found this.

The pertinent variable is AIBalls.SpeedMultipy in AIBalls.c and it does exactly what it says it does. The default 3.0 makes the horrendously slow cannonballs in the original look like they're moving at a real speed, but it's entirely unneeded with realistic guns. So, as a bonus, you'll not only get better guns, but better physics as well -- where g = 9.81 -- when I'm done. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
Supoib! I like to see someone jump right into this, and you seem to have an excellent grasp of it.

The bomb issue was raised a while ago, and some people suggested making them heated shot, likely to cause sails to flame up or something (I know as it is the deck can catch fire, but can the sails themselves? That'd rock -- not only can you lose your masts, but your sails could get burnt off too). But they never did anything about it.

If you do implement this change (and I'm attached to the bombs but I agree they're a travesty of historical inaccuracy), I'd still like to see some sort of `bomb-type` ammo, maybe for use at only `point-blank` range before boarding.

Something else people wanted but didn't think possible is different gun calibres on the same ship. Does that look `do-able` to you?
 
Different guns on the same ship? The best I can do is fudge the numbers for the big guns so they do less damage than would be expected. I already redid all the damage multipliers (long guns fire faster shot, so do slightly more damage than cannon, etc.), so I've done all I can here.

I did, however, already manage to put in range- and `aspect-based` damage multipliers. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

Per this bit of code, guns do 2x damage at point blank, falling off exponentially to 1x at 500 yards, ~0.5x at 1000 yards, and ~0.25x at extreme range for an average long gun. Damage also varies based on the angle between the ships, from 1.75x damage at a 90 degree angle to 0.75x damage when the ships are parallel. <b>[UPDATE: in a fit of reasonableness, I decided that this should be ammo based. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />] [UPDATE 2: now its a general equation, needing only shot velocity. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />]</b>

In AIShip.c, void Ship_HullHitEvent()
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->  // KNB `04-01`-17 distance/aspect based damage multipliers -->

 float fShotDistance = Ship_GetDistance2D(rBallCharacter, rOurCharacter);

 float fShotSpeed = rCannon.SpeedV0 * stf(Goods[iBallType].SpeedV0);

 float fBallAngle = stf(rBallCharacter.Ship.Ang.y);

 float fOurAngle = stf(rOurCharacter.Ship.Ang.y);



 fCannonDamageMultiply *= 2 * pow(`1-1`/(2.25*fShotSpeed),fShotDistance); //2x at point blank, decreasing exponentially with range

 // It's amazing that this works as well as it does, for all guns and shot types



 if (iBallType != GOOD_GRAPES)

 {

   fCannonDamageMultiply *= 1.75 - GetDotProduct(fBallAngle,fOurAngle); //75%-175% depending on angle

 }<!--c2--></div><!--ec2-->

This *seems* to work, but I can't be completely sure if I'm detecting raking fire or not. If anyone could tell me how to output messages to the log, I'd be much obliged. And if anyone has any better values for the damage multipliers, I'm all ears.

Keep in mind that this has no effect on firing against forts, because I don't understand the fort damage code. From the code it looks like they take <1% damage from any gun fired from more than 20 yards away, but that doesn't make ANY sense.


I'm not really sure what to do with bombs. I've made a quick hack so that enemy ships and forts will never be given them and won't use them if they have them, but you can still buy and fire them. I have made them less accurate than balls (see the post above), so they're at least slightly more balanced than before if you really want to use them. I might be able to remove them <i>in toto,</i> but it will be a lot of work and prone to bugs. Heated shot is a decent idea, but it really shouldn't be a different ammo type, and we can just assume that normal cannonballs are heated (thus the inflame and critical hit chances). It does bring up the idea of `ammo-based` reload times, however...
 
I don't even use the bombs, as I'd prefer the ship to not be quite so beat up when I sell it after I capture it <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="icon_wink.gif" /> !

Cap'n Cornish made a carronade, <a href="http://forum.piratesahoy.net/sutra67154.php&highlight=carronade#67154" target="_blank">http://forum.piratesahoy.net/sutra67154.ph...carronade#67154</a> Haven't seen him about for quite some time now, tho...
 
Forts were capable of using bombs, though, so they should keep them maybe? And as I understand, forts often heated their shot to rain fire and death down on attacking ships.
 
To a minimal degree, they were also heating balls on ships... But that was very minimal. I've heard of shipwrecks where they've found the stove that would have been used for this purpose. BUT that was very late in the "age of sail", so...
 
I love your ideas Bozo!

As for bombs, I know it's not historical, but sometimes I'd rather sink enemy ships rather than board them because I'm in a hurry to go do something so bombs come in handy to speed up the combat. Also enemy ships also have bombs so the odds are still even <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="icon_wink.gif" />

But perhaps bombs should have the same, (or maybe shorter), short range but cannon balls a much further range... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/bookish.gif" style="vertical-align:middle" emoid=":mm" border="0" alt="bookish.gif" />
Otherwise, as is, cannon balls are practically useless.
 
Forts would have heated shot more often than ships, yes. To represent this, I might be able to give shots from forts greater chances of inflicting a critical hit and starting fires. I might even replace the bombs with heated shot for this purpose and equip forts with it, but I don't know if it's possible to keep it out of the player's hands. Forts firing bombs against ships, however, seems rediculous. Correct me if I'm wrong, but I have a very hard time believing that the fuses were anywhere near good enough for the bombs to explode on hitting a ship. The only use I could find for 17th century bombs was in assaulting a fort with siege mortars; the bombs would be fired over the walls with 68+ pounder mortars, roll around for `5-10` seconds, and THEN explode.

Hopefully, with the increased damage, a damage bonus at close range, and a damage bonus for raking fire, you'll be able to sink a ship pretty quickly with balls. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> MoWs are still all but invincible, but sloops shouldn't last long against real warships. I might boost the damage a bit more, too, because I can barely imagine a sloop withstanding a full broadside from an `18-pounder` frigate. If I do that, though, I might be tempted to redo the armament weight of all the ships; a little ship like a Xebec firing `24-pounders` just doesn't seem right. In fact, I will definitely do this if I can add `9-pounder` guns for the merchants.


I might have just found a way to completely remove bombs from the stores; I might be able to use them as `fort-specific` heated shot after all. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />

[update] After `8-9` missed attempts, I finally managed to remove bombs from the stores. I don't know why it was so hard; I had to create a new variable in the Goods object and a check for it in StoreUtilite in order to set them as NotUsed.
 
Hello there. I have an idea for a mod and I think this might be the spot to ask if it can be done. I was playing the game and I thought it would be cool if you could knock out the guns on ships. You could set it up the same way the forts are, that every once and a while you see the 1000XP points, Gun exploded, etc. The cool thing would be that once you captured a ship that was supposed to have say, 44 guns, only had 10 left, would make the game a whole lot more fun. That and I hate getting shot at by a dismasted ship. Just an idea. TTYL!

<img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/keith.gif" style="vertical-align:middle" emoid=":keith" border="0" alt="keith.gif" />
 
I think the fort gun destruction is `hard-coded`, and impossible to transfer to ships. If it were possible it would have been the very first thing I did, believe me. Someone might come up with a way to do it, but I don't see it as likely.

I have, however, managed to create and implement 9pdrs without any problems, so I've started redoing all the guns. My current project is a wholesale replacement of the current guns with 4, 6, 9, 12, 18, 24, and 32 pound long guns and 12, 18, and 24 pound carronades. I can't change the number of guns without editing the models, but I wholely intend to change broadside weights to be more accurate.

I really wish I could outfit brigs and such with 18pdr carronades as broadside guns and 6pdr long guns as chasers, but I can't think of any way to do it. In addition, placing multiple gun types on the same arc seems completely impossible. As such, carronades will only really be plausible on the small ships (not that they're plausible at all; they weren't developed until 1780...).

In other news, I hereby proclaim<a href="http://members.aol.com/batrnq/" target="_blank">this</a> the greatest site on the internet.
 
Cool site, Bo, is it yours? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />
 
It's not mine, it's just the only site I've found that actually gives `in-depth` armament figures for sailing ships. It only has the `real-life` counterparts of the ships a fictional character sailed in the early 1800's, but it's still incredibly well researched.

Oh, and a status update:

I've successfully replaced all guns with long guns and carronades, for a total of 10 guns compared to the original 7. Carronades display as 12, 18, and 24 pounders, but can be mounted in place of 6, 9, or 12 pound long guns. All gun damage decreases with range and varies with the angle between ships, and the relative damages of the guns are derived from relative kinetic energy. I've even changed the code so it doesn't say "culverine" anywhere in my program folder. And it all works. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> (I'm not sure that "culverine" is actually ahistorical for the time period -- apparently French `extra-long` guns were known as such -- but it certainly doesn't fit with carronades.)

I've hit two problems, though: Forts stopped firing their guns a while back, presumably when I decreased cannon fire arcs, and the pulsing aiming crosshair only displays when you're aiming directly at a ship's waterline. This second bit doesn't sound like much of a problem, but ships only turn hostile if the game *knows* you're aiming and firing at them. That and the AI tends to aim a bit low, although they still hit you because of the spread.

I'll probably figure out the fort bug eventually, but I'm not so sure what to do about the other. I think it has something to do with the height block:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    refShip.Height.Bombs.Y    = 3.0;    refShip.Height.Bombs.DY   = 1.0;

   refShip.Height.Grapes.Y   = 4.0;    refShip.Height.Grapes.DY  = 1.0;

   refShip.Height.Knippels.Y = 25.0;   refShip.Height.Knippels.DY  = 15.0;

   refShip.Height.Balls.Y    = 3.0;    refShip.Height.Balls.DY   = 1.0;<!--c2--></div><!--ec2-->

This looks like it sets the location and size of the aiming area for each ship, but it's set to default or lower than default for everything. I don't have access to the models to find the right values, but I might do some tests if I have time. I can't say for sure what it does by looking at the code, but it looks like *something* to do with aiming.

But then again, this isn't defined for forts, and I can aim at them just perfectly. If anyone knows what could be causing my problem, I'd be very appreciative.

(Should I post this in the sticky help thread, even though `no-one`'s posted to it in months?)
 
KnowNothingBozo, Great work - when will this mod be released?

Different guns on one ship would be realistic. At the end of the file AI_Forts there is some code talking about two types of guns (at forts). Could this be maybe be used?
 
Thank's for the link. POB rules <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" />

Keep up the good work <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/onya.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="onya.gif" />
 
Yeah, I've seen the fort cannon bit, but unfortunately the only references to multiple cannon types are in AIFort and FortCommandants, and they're both the same declaration. Whatever the engine does for multiple fort guns, it does internally and most likely only for forts.

I'll release this when I stop fiddling with it, I guess. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I only really have time to work on it on weekends, so it might be a couple weeks. I'll need a place to put it, too.

I just found out that a copy of the main reference book used for that site is owned by my university library, though. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <i>The Sailing Navy List: All the Ships of the Royal Navy Built, Purchased and Captured, `1688-1860`.</i> Sounds useful.

Once again, if anyone has info on how the aiming reticule works, I'd be most appreciative.
 
Back
Top