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

WIP Improve the Crewmembers on Shore Mod

In the end, they both could use updating anyway. If the dialog does what we'd WANT it to, it can be restored to proper use.
Which would make it NOT a waste, but actually restoring lost functionality! :cheers

It's not that easy. Random_sailors_sit_tavern_dialog.c often uses things like this:

Code:
                Link.l1.go = "exit";
                 LAi_LocationFightDisable(&locations[FindLocation(Pchar.location)], false);
                 LAi_group_SetRelation("random_sailors_group", LAI_GROUP_PLAYER, LAI_GROUP_ENEMY); //MT: why is random_sailors_group being used here? Doesn't show up in search!
                 Random_Raid("soldiers", 5, makeint(NPchar.nation),"enemy","friend","");
                 Diag.TempNode = "exit";

See that? Either the name of the group of NPC's is still used/indentical, or it's referencing the files we thought were commented out. It might be better to just remove random_sailors_group_dialog entirely to avoid further problems like this. It's functionality seems to have been completely replaced by Random_sailors_sit_tavern_dialog.

Yes, it would. It is simple enough to add that function somewhere though.
But if it is truly different every time, then you can skip the function and just have switches for ONLY the sounds in the dialog files.

Well, Random_sailors_sit_tavern_dialog uses far more identical ones, though still quite a wide variety. 3 or 4, at first glance. Might be worth doing for that one.

At the moment i'm just cleaning up the code first. I'll try rearranging it like i did with random_sailors_group_dialog later. Random_sailors_sit_tavern_dialog is about twice as big; a truly humongous dialogue tree, which is going to take absolute ages to dig through and fix. :facepalmOnce i get to doing that i'll be having a lot of questions, by the looks of it. It uses many functions that i haven't seen before.
 
Last edited:
There is some good news: It seems that all the files i've worked with up until now were also the oldest ones. Random_sailors_sit_tavern_dialog is far newer, and seems to have been intended to be a complete replacement for random_sailors_group_dialog, meaning that it's code has been largely updated already. With luck, all that's needed is to update some of the clunkier bits that got directly copied over from the older file, like the switches and fame checks. That's what i just finished doing. I'll need to do some checking up on that to make sure i don't need to do anything else with it though.

In hindsight, i should have really started with this one. Random_sailors_sit_tavern_dialog is designed to work both with or without the Enable Flags mod; that's why it's so large. The others don't have that toggle built into them. Realising this makes things significantly easier, since i can just focus on the half of the file that works with the mod first. That bit seems mostly identical to random_sailors_group_dialog.

The most important piece of code i've seen is this:
Code:
if(CheckAttribute(Pchar,"traitor") && sti(pchar.traitor) == makeint(GetLocationNationFromID(NPchar.location)))
      {
         DeleteAttribute(Pchar,"traitor");   // so that recognizing happens only once

It's a replacement for what i originally thought was the player joining the pirate nation, but turns out to be a check to see if you hoisted to pirate flag at any point while in sight of non-pirate ships. I've copied it over to the older files, since that seems to have been the original intent of their code.
 
Last edited:
That traitor functionality should have been removed or modified already.
That feature no longer exists in that form.

I think I also removed the ENABLE_FLAGS toggle in the Beta 4 base.
Make sure you check that one.
 
That traitor functionality should have been removed or modified already.
That feature no longer exists in that form.

I think I also removed the ENABLE_FLAGS toggle in the Beta 4 base.
Make sure you check that one.

I'm currently working with files from beta 4, from the 29th of november. Did you remove it in the version after that? I should install the 4 december version over my game then.

As for the traitor functionality, what is it now?
 
Last edited:
I'm currently working with files from beta 4, from the 29th of november. Did you remove it in the version after that? I should install the 4 december version over my game then.
I removed that somewhere in the summer; it has been gone for months:
upload_2015-12-16_23-20-0.png

In my Beta 4 copy of "Random_sailors_sit_tavern_dialog.c", there is zero reference to the ENABLE_FLAGS toggle now.

As for the traitor functionality, what is it now?
Here's the main example from Enc_Walker.c:
Code:
        case 1:             // recognized or advice
           // ccc Dec 05 You are recognized for your pirating actions
           if(GetServedNation() == PIRATE && GetCurrentLocationNation() != PIRATE)   // PB: Link this to acting as a pirate
           {
             d.Text = DLG_TEXT[294];
             Link.l1 = RandSwear() + DLG_TEXT[295];
             Link.l1.go = "alarm";
           }
           else
           {
             d.Text = DLG_TEXT[3];
             Link.l1 = DLG_TEXT[4];
             Link.l1.go = "police";
             Link.l2 = DLG_TEXT[5];
             Link.l2.go = "exit";
           }   // ccc hoist flag end
         break;
 
I removed that somewhere in the summer; it has been gone for months:
View attachment 24642
In my Beta 4 copy of "Random_sailors_sit_tavern_dialog.c", there is zero reference to the ENABLE_FLAGS toggle now.

sigh. I'll get this right some day. Good thing i hadn't progressed that far in Random_sailors_sit_tavern_dialog.c yet, since i'd accidentally opened the beta 3.3 one. I would have sworn i double-checked.

Here's the main example from Enc_Walker.c:
Code:
        case 1:             // recognized or advice
           // ccc Dec 05 You are recognized for your pirating actions
           if(GetServedNation() == PIRATE && GetCurrentLocationNation() != PIRATE)   // PB: Link this to acting as a pirate
           {
             d.Text = DLG_TEXT[294];
             Link.l1 = RandSwear() + DLG_TEXT[295];
             Link.l1.go = "alarm";
           }
           else
           {
             d.Text = DLG_TEXT[3];
             Link.l1 = DLG_TEXT[4];
             Link.l1.go = "police";
             Link.l2 = DLG_TEXT[5];
             Link.l2.go = "exit";
           }   // ccc hoist flag end
         break;

Yep, it's in the latest version of Random_sailors_sit_tavern_dialog.c too. Just saw it. I'll be working in the proper file from now on.
 
I'm a bit lazy so haven't read everything yet :p. What is the Status on this. I believe on monday we want to have a new installer again :). So could you try to upload what you have before then?
 
I'm a bit lazy so haven't read everything yet :p. What is the Status on this. I believe on monday we want to have a new installer again :). So could you try to upload what you have before then?

err... I can try to get something workable before then. It's proving difficult though. I should be able to get at least two of the groups working properly by then.

Regarding all the posts that i've made here though, there was one thing where i'd like your input specifically. Can these lines be removed from the dialogue files?

"That raid of yours ruined my store! We'd been waiting for that cargo for weeks! I'm not letting you slip by now that I have my chance!",
"En garde!",
"Hey... hey guys. Bet that guy's got quite a bounty on his head. I say we get him!",
"Too rich for your blood!",
 
err... I can try to get something workable before then. It's proving difficult though. I should be able to get at least two of the groups working properly by then.

Regarding all the posts that i've made here though, there was one thing where i'd like your input specifically. Can these lines be removed from the dialogue files?

"That raid of yours ruined my store! We'd been waiting for that cargo for weeks! I'm not letting you slip by now that I have my chance!",
"En garde!",
"Hey... hey guys. Bet that guy's got quite a bounty on his head. I say we get him!",
"Too rich for your blood!",
I dont use those lines.
I made new Dialog files for the additions I made.

Would be nice to have at least 2 Groups working like you want it already :) Probably during the vacation another installer will be made because I'm not finished either yet.
 
I need some help with common signs i'm encountering in the code. What does the following mean? It would really help with figuring out some of the details.

Code:
&&                   i understand this means 'and', but does it mean that both conditions need to be true (when combined with an 'if') to return the whole thing as true, or does it work more like an 'or' function?
==                   looks like a simple 'is' to me.
!=                    This one i'm not sure about. 'is not'?
||                     Not the foggiest idea.
<=                   Same.
rand(1)==0)            Random chance for either true or false?

I've also noticed that this bit
Code:
if(Npchar.middlename!=""){LAi_tmpl_SetFollow(Npchar, CharacterFromId(Npchar.middlename), 120000);}
has been commented out in all random group dialogs except for the pirate one. Should i remove it from the pirates?
 
For "&&" to be true, both conditions need to be true. "||" is "or", it's true when either one of its subconditions is true.
"==" stands for "equal", "!=" -- "not equal" and "<=" means "less or equal".
"rand(1)==0" is basically a coin flip.
 
I'm a bit lazy so haven't read everything yet :p. What is the Status on this. I believe on monday we want to have a new installer again :). So could you try to upload what you have before then?
Simple version: Morgan Terror is cleaning up the relevant dialog files, because they were messy and largely outdated.

For "&&" to be true, both conditions need to be true. "||" is "or", it's true when either one of its subconditions is true.
"==" stands for "equal", "!=" -- "not equal" and "<=" means "less or equal".
"rand(1)==0" is basically a coin flip.
Thanks for responding there. Worth noting that the PotC game code does NOT properly understand using "||" and "&&" within the same if-statement.
Using brackets doesn't help; you have to use temporary boolean variables for that.

"rand(1)==0" is basically a coin flip.
I think this is an equivalent coin flip:
Code:
if (frnd() > 0.5)
But based on @Levis' investigations, I think the 'frnd' version may be the better choice.
See here for details: Solved - Random or Quasi Random Numbers? | PiratesAhoy!
 
Simple version: Morgan Terror is cleaning up the relevant dialog files, because they were messy and largely outdated.

And broken. The soldier patrols are a complete mess. What's happened basically is this:
A few years ago, i had a shot at fixing the terrible english that these dialogues suffered from. That went well enough, but some lines were so bad that i just had to make a guess at what was meant. When testing my new dialogue out in the game, i discovered that not only was the english broken, but many of the lines were called in the wrong places as well. Basically, the English had been so bad that noone had noticed how buggy it was. I then tried to move them around a bit to make them make sense. This kinda worked, but now we're discovering that the code itself is outdated and messy, and i'd not really finished the job i started a few years ago.

Thanks for responding there. Worth noting that the PotC game code does NOT properly understand using "||" and "&&" within the same if-statement.
Using brackets doesn't help; you have to use temporary boolean variables for that.
I understand. Only one And or Or statement per If then.

I think this is an equivalent coin flip:
Code:
if (frnd() > 0.5)
But based on @Levis' investigations, I think the 'frnd' version may be the better choice.
See here for details: Solved - Random or Quasi Random Numbers? | PiratesAhoy!

Thank you, but could you then tell me what these would be as a frnd?
Code:
rand(10)>8)
(rand(10)==0)

Also, i'd still like to know if i should remove this line from the pirate dialogue:
Code:
if(Npchar.middlename!=""){LAi_tmpl_SetFollow(Npchar, CharacterFromId(Npchar.middlename), 120000);}

It's been either removed or commented out in all the others, so it seems a bit out of place. It's part of this case, typically used for ending dialogue:
Code:
    case "exit":
       Diag.CurrentNode = Diag.TempNode;
       DialogExit();
       if(Npchar.middlename!=""){LAi_tmpl_SetFollow(Npchar, CharacterFromId(Npchar.middlename), 120000);}
     break;
 
Thank you, but could you then tell me what these would be as a frnd?
Code:
rand(10)>8)
(rand(10)==0)
rand(10)>8 = 80% chance = frnd()>0.8
(rand(10)==0) = 10% chance = frnd() <= 0.1

Also, i'd still like to know if i should remove this line from the pirate dialogue:
Code:
if(Npchar.middlename!=""){LAi_tmpl_SetFollow(Npchar, CharacterFromId(Npchar.middlename), 120000);}
Thanks for reminding me! I was going to respond, but then forgot.
That code looks VERY SCARY. Please don't use it.
I don't understand what it is meant for; if you do figure it out, we should use a different approach.

Npchar.middlename as ID sounds extremely unreliable. Middlename could be anything, though usually indeed "".

Could there be any reason for these guys following you around after the end of a dialog?
That is what it does as far as I know.
 
rand(10)>8 = 80% chance = frnd()>0.8
(rand(10)==0) = 10% chance = frnd() <= 0.1
That's obviously what the intention was, but weren't the real probabilities 2/11 and 1/11 respectively, given the authors of the language had decided it's a good idea for rand(10) to return 11 possible values? :)
 
rand(10)>8 = 80% chance = frnd()>0.8
(rand(10)==0) = 10% chance = frnd() <= 0.1

Thank you, great help as always!

Could there be any reason for these guys following you around after the end of a dialog?
That is what it does as far as I know.

Yes, although contrary to what you'd expect it's only in the dialogue files that DON'T have that line. The pirate dialogue doesn't involve any following around at all. I'll remove it. As for the files that do involve characters following you around, those already have other measures in place to arrange that.
 
I'll reupload all of these files in a proper zipfile with file directories once i'm done with all of them, but here's the new guard files:
Did you test those? Finally looking at the code now and I think this line would prevent the dialog from working:
Code:
Dialog.Text = DLG_TEXT[7] + GetMySimpleName(PChar) + DLG_TEXT[8] + nationme + DLG_TEXT[10];
Reason is that 'nationme' isn't defined.
I think using this instead should do the trick:
Code:
Dialog.Text = DLG_TEXT[7] + GetMySimpleName(PChar) + GetNationDescByType(sti(PChar.nation)) + DLG_TEXT[8];
 
Did you test those? Finally looking at the code now and I think this line would prevent the dialog from working:
Code:
Dialog.Text = DLG_TEXT[7] + GetMySimpleName(PChar) + DLG_TEXT[8] + nationme + DLG_TEXT[10];
Reason is that 'nationme' isn't defined.
I think using this instead should do the trick:
Code:
Dialog.Text = DLG_TEXT[7] + GetMySimpleName(PChar) + GetNationDescByType(sti(PChar.nation)) + DLG_TEXT[8];

I already spotted it. :yes Or at least, i remember replacing all instances of nationme. Where did you find this one? You've left out line 10.
 
Back
Top