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

Fixed Crewmen who die from gangrene are actually healed

This sounds very odd to me. The logic is that wounded crew are NOT part of the normal "Ship.Crew" attribute, but are stored separately.
So if you remove wounded crew without returning them to the normal crew, they have effectively died.
That logic is what the entire feature is based on.

The problem seems to be that SetWoundedCrewQuantity does much more than RemoveCharacterWoundedCrew needs it to.
Does that make sense to you?
 
The problem seems to be that SetWoundedCrewQuantity does much more than RemoveCharacterWoundedCrew needs it to.
Does that make sense to you?
Well, if the entire set of *WoundedCrew* functions was designed to manage both the "Ship.Crew" and "Ship.Crew.Wounded" attributes and to ensure the attributes remain consistent, it does make sense as one of possible designs. Although I must say if that was the intention, then the functions are named in a very confusing manner that inspires misusing them. But then again, the programmers probably were not native English speakers. Neither am I and I've seen much worse naming schemes. Invented several myself. :)
 
hough I must say if that was the intention, then the functions are named in a very confusing manner that inspires misusing them.
That may have happened here as I used the RemoveCharacterWoundedCrew as if its use would NOT affect the actual crew quantity.
That is what DailyCrewUpdate.c assumed, but looking at the functions, indeed it looks like that is not indeed true.

You'd be welcome to fix this if you can. Anything I don't have to do is always a bonus. ;)

But then again, the programmers probably were not native English speakers. Neither am I and I've seen much worse naming schemes. Invented several myself. :)
This is a feature that was added somewhere in Build 14 Alpha 8/9 by @konradk.
It was unfinished, so I finished it many years ago.
 
You'd be welcome to fix this if you can. Anything I don't have to do is always a bonus.
Shouldn't be very hard. Few of those functions are ever called, and rarely at that.

This is a feature that was added somewhere in Build 14 Alpha 8/9 by @konradk.
Not the original Akella team, then. It seems he was visiting the forums not so long ago, so maybe one day he'll beat us for mistreating his code. :)

It was unfinished, so I finished it many years ago.
What I can't understand is that I kinda remember that feature working perfectly a while ago on one hand, while on the other hand it looks like nobody has touched this code in years.
 
What I can't understand is that I kinda remember that feature working perfectly a while ago on one hand, while on the other hand it looks like nobody has touched this code in years.
Don't underestimate the power of "not paying attention". If people don't check if the math matches up, nobody ever finds out.
 
  • Like
Reactions: jsv
Any idea why the forums reject my zipfiles today? It used to accept them just fine.
Here then: https://dl.dropboxusercontent.com/u/719028/fixhealing.zip

I've tested the healing process itself, seems to work fine.
@Pieter Boelen, please take a look at Ship_ApplyCrewHitpoints (AIShip.c). As I understand it, your code there was written under the same assumption that Add/RemoveCharacterWoundedCrew do not affect the main crew. And as now they really don't, nothing there needs changing. Some testing of the battle part wouldn't hurt, though. :)
 
Any idea why the forums reject my zipfiles today? It used to accept them just fine.
No idea whatsoever. ZIPs should work.
Unless it is too big; but with just a few code files, that seems quite unlikely.

I've tested the healing process itself, seems to work fine.
Thanks! I'll add it to my game soon. :woot

@Pieter Boelen, please take a look at Ship_ApplyCrewHitpoints (AIShip.c). As I understand it, your code there was written under the same assumption that Add/RemoveCharacterWoundedCrew do not affect the main crew. And as now they really don't, nothing there needs changing. Some testing of the battle part wouldn't hurt, though. :)
Sounds like I've got my work cut out for me.... :wp
 
Thanks again for looking at this, @jsv! I've had a quick look at the code and it does seem to make sense.
But I won't have time for a few days to actually think it through properly.

One thing I did notice is that a bunch of the functions you added/changed don't need to be 'bool' ones, but can be 'void'.
For example:
Code:
void RemoveCharacterWoundedCrew(ref _refCharacter, int num)
{
   AddCharacterWoundedCrew(_refCharacter, -num);
}
The only need for 'bool' ones is if they can return true or false depending on what happens inside them.
But SetCharacterWoundedCrew always returns true, so then you don't need it I think.
 
KK made them returning bool, most likely because they are modelled after Add/RemoveCharacterCrew so it kinda makes sense for them to use the same calling interface.
I haven't changed that and I did make Add/RemoveCharacterWoundedCrew to return false when they have no work to do, that is, when they are called with num = 0. Admittedly, not a very useful property and, not surprisingly, it is never used. Changing bool to void for the entire *WoundedCrew bunch wouldn't break anything, that's for sure.
 
People please Keep an eye out for this :).
 
@jsv: What is this?
Code:
[character= 0] trying to remove 1 extra wounded
[character= 0] trying to remove 1 extra wounded
(Apparently happened twice in a row)

This apparently happens to my player character while being shot at in a sea battle early in the game.
Unless I am very much mistaken, this should be IMPOSSIBLE! :shock
 
Not a bug, I think, just inconsistency in either logic or error reporting :)

The culprit must be this (SeaAI\ship.c):

Code:
if (IsMainCharacter(rOurCharacter) || IsCompanion(rOurCharacter)) {
        int wounded = casualties - randnorm(casualties, iskillDefence);
        if (wounded > casualties) wounded = casualties;
        if (wounded > 0) AddCharacterWoundedCrew(rOurCharacter, wounded);
        else wounded = 0;
        int killed_wounded;
        if (rand( 3*iskillDefence ) == 1)
        {
            killed_wounded = 1;
            RemoveCharacterWoundedCrew(rOurCharacter, 1);
        }
        else killed_wounded = 0;
//trace("Ship_ApplyCrewHitpoints: casualties="+casualties+", iskillDefence="+iskillDefence +", wounded="+wounded +", killed_wounded="+killed_wounded);
    }
Every time the Defence check fails, the Code kills a kit... wounded crew member. Even if there are no wounded crew members.
RemoveCharacterWoundedCrew should handle the case correctly (by doing nothing, essentially... although it will remove Ship.Crew.Wounded if that is somehow present), but it complains in the process.
We can either add a check for non-zero amount of wounded to Ship_ApplyCrewHitpoints, or comment out the diagnostic message. :)
 
Last edited:
Could we not get rid of that altogether?
I always figured wounded should die only at the daily crew update.
That is also when you very the onscreen message about them dying.
 
The balancing was probably KK's work. And apparently my corrections to it weren't quite enough.

Would you reckon removing it would make sense?
Maybe we can try and see what happens with the numbers afterwards.
 
I don't really have any strong opinion about that. Wounded being cut down due to poor defence kind of make sense. But, as you've noted, that happens in rather opaque way, so removing it makes sense as well. The effect is most likely to be neglectable anyway (probability of wounded dying looks low for any defense skill above 2, but I don't know how often this function is called during a big fight); indeed, we can do some tracing to measure that.
 
I don't know how often this function is called during a big fight); indeed, we can do some tracing to measure that.
That is "Ship_ApplyCrewHitpoints", right? I think that gets called per cannonball hit.
 
That is "Ship_ApplyCrewHitpoints", right? I think that gets called per cannonball hit.
Oh. So with defense = 1, there is a 25% chance of any single cannonball killing a wounded? Vs. ~3% with defense = 10, but by that time you have broadsides of 70.
Better to remove it, then. It doesn't feel right anyway. As a bonus, that would improve performance a (very) little bit. :)
 
Back
Top