Jump to content
Game-Labs Forum

Realism Work (code changes) v0.2


Recommended Posts

After playing with NAR for a while, there were a few things that didn't make sense to me. Discussion in that thread led me to looking at how the code actually worked (see this post on how rate of fire is actually calculated), and that led me to using the awesome sledgehammer (scalpel?) that is HarmonyX to make some changes. For now I've just made a couple changes to how guns work, but I'm looking into making some more changes (and would like to hear folks's suggestions/requests as to what changes they'd like to see that require code rather than just data work).

 

I'm currently working on ship design; you can see in the log the output of the detected block coefficient and calculated length along the waterline and beam (and draught, which doesn't need to be calculated, that can use the game's bounding box).

 

So here's the changes I've made so far:

  • The influence of caliber change on guns (i.e. 5" to 5.2") is no longer linear. Currently I'm using the 1.5th power. In addition, stock applies a scaling factor of 0.975x to the higher caliber data; due to the nonlinear scaling I added (and because it doesn't make much sense since it's not a scalar to the lerp, it's a scalar to the data...) I've removed it.
  • Player-set length changes no longer double-dip. In stock UAD, there's both a change to gun stats from caliber, but also a change based on the player-set length, so taking a 12"/45 and making it a 12"/50 manually will lead to it having different stats than a 12"/50 from a nation whose turrets are already 50-caliber-length guns. With this change, that double-dipping is removed, and you just get the regular scaling based off caliber length.
  • Shell velocity no longer influences rate of fire. In stock UAD, rate of fire is scaled between 1x and 0.606x based on the shell's velocity (between 0m/s and 1500m/s). So for a 800m/s velocity, rate of fire is actually 0.7426x what you'd expect from the data.

 

Download: https://drive.google.com/file/d/1SO9cQX1J8MykY1Kg6FwJ0ttHizsfYdD-/view?usp=sharing

Note that you'll need to install MelonLoader first (see install instructions here), then drop the dll from the zip into the Mods folder in your UAD folder. Note that apparently MelonLoader 0.6.2 has a bug where sometimes it pops up with an internal error on load; that's fixed in bleeding-edge and will be fixed in next release, but if you just OK out of the error, wait a sec, and relaunch UAD it should work fine eventually.

 

Changelog:

v0.2.0.0 - Started working on ship design. Updated to 1.5.

v0.1.2.0 - Rewrote (i.e. reimplemented) GunData.GetValue (both versions) to remove the 0.975x factor. It might also be faster than stock, since I'm actually caching some values and avoiding some extra calls.

v0.1.1.0 - Got rid of Shell Velocity's impact on fire rate.

v0.1.0.0 - initial release.

 

Up next I want to tackle refits. I'm quite unsatisfied with the refit system, so here's the changes I'm looking at:

  • You can no longer change armor type or thickness in a refit
  • You only get the effect of certain techs (i.e. fire control, sonar, ammunition, propellant/explosive choice, etc) by default.
  • You can no longer change bulkheads, flooding, double bottom, etc. You can increase torpedo bulkheads however.
  • You can opt to do a major refit, which does apply certain other tech effects, and allows replacement of the engine and upgrading of gun marks.
  • (Possibly: placing secondary weapons no longer triggers a major refit so long as they are the original type.)

That's obviously a bit more of a project, and will require poking at the UI some to lock away certain changes, but I don't see why it wouldn't be doable.

Edited by NathanKell
  • Like 2
Link to comment
Share on other sites

3 hours ago, SpardaSon21 said:

I'll check this out after the beta goes live, but be sure to make the devs themselves know what you've done, too.

These aren't bugfixes, they're balance changes; I'm pretty sure that the devs intentionally made these choices in the service of game balance. The caliber length one is kinda weird and could use some reworking, but it's clearly a design choice to penalize the player a bit for altering their gun's caliber length.

Link to comment
Share on other sites

7 hours ago, NathanKell said:

These aren't bugfixes, they're balance changes; I'm pretty sure that the devs intentionally made these choices in the service of game balance. The caliber length one is kinda weird and could use some reworking, but it's clearly a design choice to penalize the player a bit for altering their gun's caliber length.

Yeah, but as you said, it interacts weirdly with existing barrels, and muzzle velocity affecting reload rate seems like an odd choice.

 

EDIT: If possible, I'd rather you look at how pitch and roll are calculated instead of refits.  The game has a very strong bias towards citadel armor and the engines when it comes to things that reduce pitch and roll, so lengthening your citadel and putting a ton of deck armor on your ship reduces pitch and roll, when in reality deck armor was a major cause of instability in designs.  Meanwhile just about everything else increases pitch and roll, including things traditionally used as ballasting such as fuel and torpedo bulges.

Edited by SpardaSon21
Link to comment
Share on other sites

On 3/9/2024 at 9:54 AM, SpardaSon21 said:

Yeah, but as you said, it interacts weirdly with existing barrels, and muzzle velocity affecting reload rate seems like an odd choice.

 

EDIT: If possible, I'd rather you look at how pitch and roll are calculated instead of refits.  The game has a very strong bias towards citadel armor and the engines when it comes to things that reduce pitch and roll, so lengthening your citadel and putting a ton of deck armor on your ship reduces pitch and roll, when in reality deck armor was a major cause of instability in designs.  Meanwhile just about everything else increases pitch and roll, including things traditionally used as ballasting such as fuel and torpedo bulges.

Well, that was a slog but I kinda-mostly know how it works now. So I can start tweaking things. (Although if @Nick Thomadis has a managed dll hanging around, I'd be much obliged. Trying to read vector/floating point disassembly is way more taxing than more regular gameplay code.)

I wouldn't expect ballast per se to make roll better; indeed, while it increases stability by increasing metacentric height, I take roll ingame to mean "how stiff is the roll", and for a stable gun platform you want a slow, easy roll (though that's real bad for flooding, of course).

To properly calculate stiffness in pitch and roll you'd want to take into account a combination of the moments of inertia and the metacentric height. Certainly the game is doing the former; I _believe_ it's trying to do the latter, but it's much harder to tell what's going on, not least because there's an absolute smorgasbord of lerps, lemme tell you--I presume that's all tuning factors to get good gameplay and approximate / "feels right" results.

11 hours ago, anonusername said:

On 1.5 this seems to cause the game to load infinitely on start.

I would expect so. As I mentioned in the OP this is for 1.4.1.1 and I need to update and recompile.

Link to comment
Share on other sites

Ok I got fully nerdsniped and ended up implementing calculation of block coefficient (which involved detecting actual length along the waterline, LWL, and actual beam at the waterline, via a rendertexture). Probably going to go ahead and work on voxelizing the hull so I can get the real center of buoyancy and calculate that vs an estimated center of mass to get metacentric height and the real stability figures.

 

So, uh, thanks a lot. :P

I'm including some examples of the rendertexture because I think it's cool. It's simple once you have that, just count the pixels along the top row and divide by total width (512) and multiply by the bounds, and you get beam and LWL.

screenshot_cressy_hull(Clone)(Clone)dimension getter_Front.png

screenshot_cressy_hull(Clone)(Clone)dimension getter_Side.png

  • Like 2
Link to comment
Share on other sites

  • NathanKell changed the title to Realism Work (code changes) v0.2
  • 4 weeks later...
Posted (edited)

Yeah so per the NAR thread I took a week's vacation and then got super busy at work. But I did make some progress on this, I've got basic ship coefficients getting calculated, and ships getting scaled to the size they should be for their displacement and block coefficient. And you can control the length/beam ratio, rather than it being set by the tonnage slider (!) as in the vanilla game. Calculating actually-needed horsepower is in progress. Then I can tackle seakeeping and metacentric height / stability calcs.

 

Once I get done with the giant rabbit hole @SpardaSon21 then I'll get back to my original plan re: refits.

Edited by NathanKell
  • Like 2
Link to comment
Share on other sites

21 hours ago, NathanKell said:

Yeah so per the NAR thread I took a week's vacation and then got super busy at work. But I did make some progress on this, I've got basic ship coefficients getting calculated, and ships getting scaled to the size they should be for their displacement and block coefficient. And you can control the length/beam ratio, rather than it being set by the tonnage slider (!) as in the vanilla game. Calculating actually-needed horsepower is in progress. Then I can tackle seakeeping and metacentric height / stability calcs.

 

Once I get done with the giant rabbit hole @SpardaSon21 then I'll get back to my original plan re: refits.

I'll be happy with just the gun and ship balance changes.  Mildly surprised you've needed to put so much work into them, though.  Did the devs really screw things up that badly with them?

Link to comment
Share on other sites

2 hours ago, SpardaSon21 said:

I'll be happy with just the gun and ship balance changes.  Mildly surprised you've needed to put so much work into them, though.  Did the devs really screw things up that badly with them?

Eh? No, it's more like I said I got nerdsniped into going _very_ hardcore, wherein on game load I render every hull model at every possible midships section count in 3 views so I can compute a bunch of stats about the hulls, then change how hulls get refreshed on change so they now scale properly to their displacements whenever you change the displacement slider. And I'm unsatisfied with SpringSharp's resistance/power approximations (which I was going to go with initially) since we actually _do_ have hull geometry here, so I've been trying to find better ways of estimating resistance. Taylor's method is good (and highly appropriate) but it's designed for use by humans with rulers. Holtrop and Mennen's paper is straightforward to implement but doesn't produce as good results for the kind of vessels we're talking about.

There's definitely some things that have caused me to scratch my head in the game, however, like how foul weather is pretty much a flat penalty to speed rather than being based on seakeeping--destroyers, let alone early TBDs or TBs, should get absolutely pounded in a sea, and at best make a dozen knots or so, while 30kt+ dreadnoughts should laugh off the waves.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...