• 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 Relations for commissioned officers

Ah, I do believe you're right again! Try this instead:
Code:
if(CheckAttribute(pchar, "professionalnavy")) // For Commissioned NavalOfficers
{
if(i == GetServedNation() || j == GetServedNation())
{
if(i == GetServedNation()) i = j; // Don't change yourrelationtoyourOWNnation
switch(newRelation)
{
case RELATION_ENEMY:
SetActualRMRelation(i, REL_WAR);
break;
case RELATION_NEUTRAL:
SetActualRMRelation(i, REL_AFTERATTACK);
break;
case RELATION_FRIEND:
SetActualRMRelation(i, REL_AMNESTY);
break;
}
}
}
Note the extra check on if(i == GetServedNation() || j == GetServedNation()) . That should ensure this ONLY happens if one of the two nations involved is your served nation.

It's a good thing that YOU are paying attention, because apparently I am not entirely awake these days. :bow
 
Everyone is entitled to the occasional mistake - at least, I hope so, otherwise I'm in trouble. :rofl If anyone ought to be bowing down, it's me, because I may be able to spot the occasional hiccup but I'm certainly not up to writing much code in the first place. :bow

But I can sometimes suggest the occasional tweak, such as this. There are three calls on "GetServedNation" in quick succession. Why not define another variable k, say "k = GetServedNation()" once, then use k for those "if" lines? I don't know how complex "GetServedNation is, but calling it once instead of three times has to help performance a little...
 
Would certainly be possible and would probably help performance too. But if I recall GetServedNation is a fairly simple function, so I'm not sure if you would notice a difference.
That being said, the amount of times it is called in the rest of the function might indeed make this worth doing anyway. If it doesn't help notably, at least it couldn't hurt. :rolleyes:

If anyone ought to be bowing down, it's me, because I may be able to spot the occasional hiccup but I'm certainly not up to writing much code in the first place. :bow
The same applied to me when I got started. Now I make a living doing it. So you might make a coder yet, @Grey Roger! :razz
At least you generally understand the logic behind which has certainly proved a great help to me already. :cheeky
 
Would certainly be possible and would probably help performance too. But if I recall GetServedNation is a fairly simple function, so I'm not sure if you would notice a difference.
At the moment. But if it expanded to find the most appropriate nation for a privateer with multiple LoM's, e.g. to decide which flag to hoist when battle starts... ;)
 
Attached file contains both the fix I mentioned in post #14 and also reduces the calls to GetServedNation() to only one at the start of the function.
Here's to hoping this one actually does what we want it to, eh? :cheeky
 

Attachments

  • nations.zip
    11.4 KB · Views: 82
I haven't had a chance to see if this works properly yet because although there was a recent change in international relations in my game, which I discovered when I got news from the tavern, it had happened before I installed the fixes and then got into some sea fights. It's definitely not resetting my relations to Britain on a daily basis any more, but I am still waiting to see what happens when another change in international relations does force a check on my own relations.

There was one amusing aspect, though, particularly ironic as I'd used Britain, France and Spain in my example above. I'm playing Nelson, therefore British; and it was France and Spain who broke their alliance. When that happens, the reason for the break-up is shown in your log entry. There are several possible reasons in "nations.c", one of which doesn't use variables, it specifically names France and Spain, and if you know the reasons then you probably know where this is going.

Spain broke its alliance with France by sending a horde of French squirrels in blond wigs to attack a Spanish monastery. :rofl
 
It's definitely not resetting my relations to Britain on a daily basis any more, but I am still waiting to see what happens when another change in international relations does force a check on my own relations.
Even if it does nothing else, at least that is *some* improvement! :cheeky
I did actually do some quick tests on this by basically force-triggering several thousand relation changes and I couldn't notice anything strange.
But then.... I only checked for a few minutes.

There was one amusing aspect, though, particularly ironic as I'd used Britain, France and Spain in my example above. I'm playing Nelson, therefore British; and it was France and Spain who broke their alliance. When that happens, the reason for the break-up is shown in your log entry. There are several possible reasons in "nations.c", one of which doesn't use variables, it specifically names France and Spain, and if you know the reasons then you probably know where this is going.

Spain broke its alliance with France by sending a horde of French squirrels in blond wigs to attack a Spanish monastery. :rofl
That is indeed a proper funny one!
Do you know if that is only ever triggered for France and Spain? I think it might apply to *all* nations, which wouldn't make much sense.
But then... it doesn't make much sense in the first place. And I remember the rest of that "reason" indeed admits that it does - not - make - sense. :razz
 
I think it's available for any pair of nations. It just so happened that this time it was France and Spain. It's even funnier given that it was Spain who broke the alliance by sending French squirrels against their own monastery. xD And yes, the reason does then go on to say "This doesn't make any sense at all and does not really explain why "+GetNationNameByType(traitor)+" broke their alliance, but that's what they did".
 
:rofl :rofl :rofl

Of course we *could* change it to use the appropriate nation names. I'm not sure we should, though. This makes for much more hilarity.... :wp
 
Yes! I was playing as Commissioned officer. I have to start a new game and try out Pieters fix.
I`m a little :sickthese days, so everything`s is slowing down.
 
Two copies of what turned out to be the same issue now merged together.
Also marked as "Fixed" for now as I can't think of anything that would not work here anymore.
If testing does bring to light more issues, we can reopen the report. :doff
 
Back
Top