• 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

ANSEL

Corsair
Storm Modder
Hearts of Oak Donator
I loose all points Landing at Port Royal. The green color disappear , and numbers drop to zero.
 

Attachments

  • error.log
    126 bytes · Views: 92
  • compile.log
    74.1 KB · Views: 100
Where you doing any quest or so? Can't fine anything really weird in the log files...

Edit: WOW 2000th post on this forum :D.
 
Last edited:
At sea and in harbor.
 

Attachments

  • seadogs2_0001.jpg
    seadogs2_0001.jpg
    443.3 KB · Views: 108
  • seadogs2_0015.jpg
    seadogs2_0015.jpg
    443.7 KB · Views: 91
There's no need to worry about what will happen when commissioned officer characters receive promotions. It won't happen, at least not if "Nelson's First Command" is anything to go by.

Relations start off with Britain 0, Holland -30. I capture a pirate ship and now it's Britain 1, Holland -29. Shortly thereafter (possibly part of the daily check?) it returns to Britain 0, Holland -30. (Other relations are probably doing something similar. The reason I mention Holland is that I'd visited Kralendijk and completed a ship-hunting quest for the governor to see what that did to relations.)

And so, having cruised around for a while and captured or sunk numerous enemy ships, relations with Britain remain at 0. I'll get no promotion this side of the ocean...
 
AGH! I'll mark this as "Confirmed Bug" since I think I may know what causes it.

When nation relations change, the player relations are set to match. However, that could very well be resetting your relations to ALL nations, including your own!
So I need to add an exception or store your rank before resetting it and then set it back.
 
It's a lot more frequent than nations changing relations. There have been occasional changes, e.g. Spain starts off at peace with Britain, in this game they declared war (allowing me to attack a Spanish group), then made peace (Spain is afraid of me :rpirate). But the resets back to 0 for Britain happened almost at once, every time. So did the reset back to -30 for Holland.
 
Hmm... Can't remember how I coded it; perhaps I went the simple route and did a SetRelationsAsNation call on EVERY daily update.
Looks like I can't get away with being too simple about this. :modding
 
Yup, that is exactly what I did. And no, that's not good.
Currently doing a complete rewrite. :facepalm
 
Made the following changes:

- RELATION_CHANGE_PROBABILITY is now in percentages, set to 1% by default; that should match with approximately 1 relation change per 100 days.

- Whenever a relation change does occur, it will always be ONLY 1 change. So never two changes on the same day.

- On Commissioned player type, player relations change ONLY if the relation of your "served nation" changes too. So no longer a daily reset of your relations.
If this now DOES work properly for the Commissioned player type, we can consider making this the default behaviour for ALL player types.
Then we could take @Grey Roger's suggestion of unlinking the player relations as soon as you hoist a personal or pirate flag.

Anyway, we first need to establish if I fixed this properly and didn't mess it up instead.... :wp
 

Attachments

  • nations.zip
    11.4 KB · Views: 90
What happens if you just change SetRelationsAsNation so that it does not set your relations relative to your own nation? Relations with other nations should be reset regularly so that if relations between your nation and another change, so do relations between that nation and you. Relations between you and your own nation should not be reset, they should change with your actions, so that you can be promoted. (Or, if you do something naughty enough to turn your own nation hostile, you're court-martialled and it's game over!)

Is SetRelationsAsNation used for anything other than keeping a commissioned officer's relations in line with his nation?
Edit: I was writing that while you were writing the update. :facepalm

Does that update take effect at once or does it need a whole new game?
 
Does that update take effect at once or does it need a whole new game?
Should be immediate, no new game required. :doff

Is SetRelationsAsNation used for anything other than keeping a commissioned officer's relations in line with his nation?
I wrote it to set the correct relations at game start depending on your chosen nation; it was never used for anything else nor was it meant to be.
Calling it daily for the Commissioned officer type was a far-too-simple cop-out in coding on my part.
While technically the player relations DID match with the chosen nation, resetting ALL relations EVERY day was perhaps not the cleverest idea.... :wp
 
Now that this was mentioned I noticed it in my game and was like....oh my god no. Also is the then linked to for example, i hoist a french flag, then "spawn in" next to their port. But they seem to attack me and checking the relations it has reset to as if i had my default flag or personal.

Thanks for the fast fix attempt though, will give it a bash. Hopefully progress can be made as you explained.
 
Cheers. :doff

So I think we need to have a few things confirmed:
1. On Free Play, do relation changes still happen at all?
2. If so, does the frequency seem right or too often/not often enough?
3. On Commissioned player type, do your nation relations follow changes in relation between your served nation and other ones?
4. Are you actually able to gain ranks with your nation now, e.g. do your relations no longer get "reset" when they shouldn't?
 
Cheers. :doff

So I think we need to have a few things confirmed:
1. On Free Play, do relation changes still happen at all?
2. If so, does the frequency seem right or too often/not often enough?
3. On Commissioned player type, do your nation relations follow changes in relation between your served nation and other ones?
4. Are you actually able to gain ranks with your nation now, e.g. do your relations no longer get "reset" when they shouldn't?
I suspect that you won't be able to gain ranks, and here's why:
- On Commissioned player type, player relations change ONLY if the relation of your "served nation" changes too. So no longer a daily reset of your relations.
So it's not every day, but do your relations with your own nation still change? That was the problem - whenever your relations with nations is reset, it includes your relations with your own nation. If I understand correctly, your relations are now only reset if, for example, you're playing a British commissioned officer and Britain declares war on Spain. That's when your relations with Britain will revert to 0. Which means you'll have longer to earn points and may even get a promotion, but then you get zeroed and you have to earn all the points back again...
 
@ANSEL: Have you applied Pieter's fix in the Relations for commissioned officers thread?

I'm guessing you're playing a commissioned officer, whether by choice or if someone edited the "Master and Commander" storyline to set you as commissioned officer by default. Your relation with Britain reverting to 0 is familiar to me, the same happens to me when I'm playing the new "Nelson's First Command" storyline, though it happened so often that I never got as high as +15! I've yet to try out the fix, though. Go to the tavern and ask about gossip, then check your log - has Britain declared war or made peace with anyone recently?
 
So it's not every day, but do your relations with your own nation still change?
No, it wouldn't. ;)

See here the rewritten code:
Code:
// Sulan: Improved Random Relations code -->
void RandomNationsRelationsChange()
{
int i,j;
int newRelation = RELATION_UNKNOWN;
int random;
ref pchar = GetMainCharacter();
string logTitle;
string logEntry;
// PB: Rewritten to a maximum of one change per day -->
if(rand(1000) < RELATION_CHANGE_PROBABILITY*10) // do relation change
{
// STEP 1: Find nations for relation change
i = PERSONAL_NATION;
j = PERSONAL_NATION;
while(i==PERSONAL_NATION || i==PIRATE) // Pirate relation doesn't change
{
i = rand(NATIONS_QUANTITY-1);
}
while(j==PERSONAL_NATION || j==PIRATE || i==j) // Also don't change relation to same nation
{
j = rand(NATIONS_QUANTITY-1);
}
// STEP 2: Figure out what to do with them
switch(GetNationRelation(i,j))
{
case RELATION_ENEMY:
logTitle = GetNationNameByType(i)+" and "+GetNationNameByType(j)+" make peace";
logEntry = "After some time of bloody warfare "+GetNationNameByType(i)+" and "+GetNationNameByType(j)+" have declared a ceasefire.";
if(GetNationRelation2MainCharacter(i)==RELATION_FRIEND && GetNationRelation2MainCharacter(j)==RELATION_FRIEND) logEntry += " This is good news as it was a very hard time to keep friendly relations with two warfaring parties.";
if(GetServedNation()==i && GetNationRelation2MainCharacter(j)==RELATION_ENEMY) logEntry += "\n \nAlthough good news in general, this is bad news for me. Attacking "+GetNationDescByType(j)+" ships and towns will not raise my reputation with the "+GetNationDescByType(i)+" anymore.";
if(GetServedNation()==j && GetNationRelation2MainCharacter(i)==RELATION_ENEMY) logEntry += "\n \nAlthough good news in general, this is bad news for me. Attacking "+GetNationDescByType(i)+" ships and towns will not raise my reputation with the "+GetNationDescByType(j)+" anymore.";
WriteNewLogEntry(logTitle, logEntry, "General",false);
newRelation = RELATION_NEUTRAL;
break;
case RELATION_NEUTRAL:
random = rand(2);
if(random==0)
{
logTitle = GetNationNameByType(i)+" and "+GetNationNameByType(j)+" have allied";
logEntry = GetNationNameByType(i)+" and "+GetNationNameByType(j)+" have formed an alliance. Attacking ships or towns of either nation will also decrease the standing with the ally.";
if(GetNationRelation2MainCharacter(i)==RELATION_FRIEND && GetNationRelation2MainCharacter(j)==RELATION_FRIEND) logEntry += " Very good news, indeed. Working for the "+GetNationDescByType(i)+" and the "+GetNationDescByType(j)+", as I currently do, my deeds will raise my standing with both nations.";
if(GetNationRelation2MainCharacter(i)==RELATION_ENEMY && GetNationRelation2MainCharacter(j)==RELATION_ENEMY) logEntry += " Whoops! It seems I have bothered them a little too much. But their alliance won't stop me.";
if(GetServedNation()==i && GetNationRelation2MainCharacter(j)==RELATION_ENEMY) logEntry += "\n \nThis makes working for the "+GetNationDescByType(i)+" somewhat more difficult, as sinking "+GetNationDescByType(j)+" ships is no longer an option.";
if(GetServedNation()==j && GetNationRelation2MainCharacter(i)==RELATION_ENEMY) logEntry += "\n \nThis makes working for the "+GetNationDescByType(j)+" somewhat more difficult, as sinking "+GetNationDescByType(i)+" ships is no longer an option.";
WriteNewLogEntry(logTitle, logEntry, "General",false);
newRelation = RELATION_FRIEND;
}
if(random==1) // i declared war on j
{
logTitle = GetNationNameByType(i)+" is at war with "+GetNationNameByType(j);
logEntry = GetNationNameByType(i)+" has declared war on "+GetNationNameByType(j)+". "+GetNationDescByType(i)+" ships have attacked a small "+GetNationDescByType(j)+" settlement, as I was told.";
if(GetServedNation()==i && GetNationRelation2MainCharacter(j)==RELATION_ENEMY) logEntry += "\n \nIt was about time to show those "+GetNationDescByType(j)+" landlubbers who's in charge in the caribbean!";
if(GetServedNation()==j && GetNationRelation2MainCharacter(i)==RELATION_ENEMY) logEntry += "\n \nThose bloody cowards! The next "+GetNationDescByType(i)+" ship we encounter will surely pay for this.";
WriteNewLogEntry(logTitle, logEntry, "General",false);
newRelation = RELATION_ENEMY;
}
if(random==2) // j declared war on i
{
logTitle = GetNationNameByType(j)+" is at war with "+GetNationNameByType(i);
logEntry = GetNationNameByType(j)+" has declared war on "+GetNationNameByType(i)+". "+GetNationDescByType(j)+" troops have landed near "+GetTownByNation(i)+", as I was told.";
if(GetServedNation()==i && GetNationRelation2MainCharacter(j)==RELATION_ENEMY) logEntry += "\n \nThose bloody cowards! The next "+GetNationDescByType(j)+" ship we encounter will surely pay for this.";
if(GetServedNation()==j && GetNationRelation2MainCharacter(i)==RELATION_ENEMY) logEntry += "\n \nIt was about time to show those "+GetNationDescByType(i)+" landlubbers who's in charge in the caribbean!";
WriteNewLogEntry(logTitle, logEntry, "General",false);
newRelation = RELATION_ENEMY;
}
break;
case RELATION_FRIEND:
random = rand(2);
if(random==0)
{
logTitle = GetNationNameByType(i)+" and "+GetNationNameByType(j)+" broke their alliance";
logEntry = GetNationNameByType(i)+" and "+GetNationNameByType(j)+" have broken their alliance, but are currently peaceful. Observers report military activity on both sides, but so far an open conflict has been avoided.";
newRelation = RELATION_NEUTRAL;
}
if(random==1) // i broke the alliance
{
logTitle = GetNationNameByType(i)+" and "+GetNationNameByType(j)+" broke their alliance";
logEntry = GetNationNameByType(i)+" and "+GetNationNameByType(j)+" have broken their alliance and are now at war! It was reported that "+GetNationNameByType(i)+" broke the alliance by "+GetBreakAllianceReason(i,j);
if(GetServedNation()==j && GetNationRelation2MainCharacter(i)==RELATION_ENEMY) logEntry += "\n \nThose treacherous bastards! The "+GetNationDescByType(i)+" will pay for this betrayal. I have ordered to open fire on sight of any "+GetNationDescByType(i)+" ship.";
WriteNewLogEntry(logTitle, logEntry, "General",false);
newRelation = RELATION_NEUTRAL;
}
if(random==2) // j broke the alliance
{
logTitle = GetNationNameByType(j)+" and "+GetNationNameByType(i)+" broke their alliance";
logEntry = GetNationNameByType(j)+" and "+GetNationNameByType(i)+" have broken their alliance and are now at war! It was reported that "+GetNationNameByType(j)+" broke the alliance by "+GetBreakAllianceReason(j,i);
if(GetServedNation()==i && GetNationRelation2MainCharacter(j)==RELATION_ENEMY) logEntry += "\n \nThose treacherous bastards! The "+GetNationDescByType(j)+" will pay for this betrayal. I have ordered to open fire on sight of any "+GetNationDescByType(j)+" ship.";
WriteNewLogEntry(logTitle, logEntry, "General",false);
newRelation = RELATION_ENEMY;
}
break;
}
// STEP 3: Change relation and match player if required
SetNationRelationBoth(i, j, newRelation);
if(CheckAttribute(pchar, "professionalnavy")) // For Commissioned Naval Officers
{
if(i == GetServedNation()) i = j; // Don't change your relation to your OWN nation
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;
}
}
}
// PB: Rewritten to a maximum of one change per day <--
}
string GetBreakAllianceReason(int traitor, int victim)
{
int random;
string sReasons[6];
sReasons[0] = "'accidently' sinking the "+GetNationDescByType(victim)+" military supply convoy.";
sReasons[1] = "treating the "+GetNationDescByType(victim)+" ambassador in a 'disrespectful' manner, as was reported from Europe.";
sReasons[2] = "brutally burning down a small settlement of the "+GetNationDescByType(victim)+", leaving no one alive (I am curious how they got this report then?).";
sReasons[3] = "officially knighting a notorious freebooter, who plundered the "+GetNationDescByType(victim)+" colonies in the previous war.";
sReasons[4] = "inciting a slave revolt in a major "+GetNationDescByType(victim)+" colony.";
sReasons[5] = "sending a horde of French squirrels with blond wigs to pillage a Spanish monastery.\n \n 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.";
random = rand(5);
return sReasons[random];
}
// <-- Sulan
Note that SetRelationsAsNation is no longer used at all. Under STEP 3 you can see that when you serve Britain and Britian declares war on France,
then the ONLY thing that should happen with the player relations is that France indeed turns hostile.
Basically the rewritten code could should not ever touch the relations to your served nation at all, allowing you to properly gain ranks this time.
 
If I understand it correctly, this is the relevant bit:
Code:
if(CheckAttribute(pchar, "professionalnavy")) // For Commissioned Naval Officers
{
   if(i == GetServedNation()) i = j; // Don't change your relation to your OWN nation
   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;
   }
}
i and j point to the two nations involved. If you serve nation i then we're actually interested in nation j. So if Britain declared war on France then i is Britain, j is France, and after that line i is France as well. It then proceeds to adjust your relations to France. Fine.

Now try this one. You serve Britain. France is at war with Britain and Spain. France and Spain have just made peace. i is France, j is Spain, i is not your served nation so that condition doesn't trigger, then the code proceeds to the switch. "newRelation" has been defined by step 2 as "RELATION_NEUTRAL". If "SetActualRMRelation" does what I imagine, which is to set your relation to nation i, then your relation to France is now set to "REL_AFTERATTACK". Britain hasn't made peace with France, but you have. :D
 
Back
Top