• 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 Dutchman Submerged function

Try some log messages to see what is actually being executed:
Code:
if(CheckAttribute(chr, "ship.SubmergeDutchman"))
{
   TraceAndLog("Setting visibility to 0 for submerged Dutchman");
   visibility_range = 0; // Making FD invisible when submerged
   chr.ship.OldVis = visibility_range;
}
else
{
   CheckAttribute(chr.ship,"OldVis")
   {
     TraceAndLog("Setting visibility back to original after emerging Dutchman");
     visibility_range = chr.ship.OldVis;
   }
   else
   {
     TraceAndLog("Restoring default visibility");
     visibility_range = 3000.0;
   }
}
That will log the different events both to the screen and into compile.log so you can check back later.
 
Where are you trying to add this? Do you know for sure chr is the player character? Often they use Pchar for this instead.
 
The code is in Screwface_functions.c . The Christmas is whatever character is captaining a ship.
There is no PChar in use there by default, if I remember. Could be added though if necessary.
 
okay I tested it with the log and it seems that I guessed right: The function jumps right to the first else and completely ignores the first {} , even when submerged

And BTW, I had to start a new game to let that logs appear?
 
yeah so it now checks if the captain of the ship itself is submerged. we dont want that now do we.

Code:
if(CheckAttribute(pchar, "ship.SubmergeDutchman"))
    {
        TraceAndLog("Setting visibility to 0 for submerged Dutchman");
        visibility_range = 0; // Making FD invisible when submerged
    }
So this should do it. We now check the player character (I checked it and its defined like this) if its submerged. if it is set to 0.
Make sure you place this right after there the visibility is set. to the default (line 8).

I removed the if cause it isn't needed anymore.
you can remove the log part after it works.

hope this helps @Pillat
 
This this should work, if not I will look at it some more tomorrow.
 
It works - but only once Oo .. the log appears and behaves correctly but as soon as I enter the worldmap and go back to open sea the log doesn't show up anymore and I'm visibleo_O

Correction: It only works when sailing around an island????? And somehow the visiblity_range gets ignored, since they still shoot at me
 
Last edited:
Please check if you where against merchant or war ships.
There seems to be a function to check if the merchant will attack or not called Check_courageous_merchant.
and try this:

Code:
if(CheckAttribute(pchar, "ship.SubmergeDutchman"))
{
TraceAndLog("Setting visibility to 0 for submerged Dutchman");
return -1; // Making FD invisible when submerged
}

in the code later on it checks if its -1 and if so it skips large parts of "getting to find you". also we dont need to run the rest of the function anymore if we know the dutchman is submerged....
 
Like I said might have something to do with merchants and warships.
Could it be you encountered merchants on open sea while you encountered warships round the island?
They use different AI.

Did the -1 work? Does it still only go once or doest it work more now?
might be else the submerged value is set to false.
you could change it to this to check:
Code:
if(CheckAttribute(pchar, "ship.SubmergeDutchman"))
{
    if(sti(pchar.ship.SubmergeDutchman) == 1) // Checking if the value is true
    {
        TraceAndLog("Setting visibility to 0 for submerged Dutchman");
        return -1; // Making FD invisible when submerged
    }
}
 
Well it seems that the function is completely ignored on open sea, since I dont receive any logs .. as soon as I enter an island-area, the log for invisibility appears all 5 seconds.

And this thing that it just only works once was wrong, I just didnt recognized the fact that it only works around an island ;)

I'm gonna test now that thing with merchants and warships ;)

Uhm... where exactly in this function do I have to put your code?:oops: Sorry I don't know much about coding :/
 
please check this function (in the same file)
Void Improve_SeaAi(String groupe)

and add some login info there and see which piece of the if/else structure you end up in at sea. this will give us some insight on where its going wrong.

my guess the problem is in the part after
// find new Quest_ship locator to patrol

but need to make sure and cant test here now.
 
Sorry but I'm afraid I can only copy + paste your code, writing something on my own unfortunaly is (still) too big for me :/
 
just add this line
TraceAndLog("Setting visibility to 0 for submerged Dutchman");
at different points in the structure
and change the thing between the " and " to a text you understand. this will create the log with the text you provided.
 
okay.. so I added a TraceAndLog at the beginning of this improved_seaAi function and he doesnt run it at all on open sea..
 
hmmm...ok this is strange.
I guess the problem then is in the open sea mod which doesn't call this function but uses something of itself.
the plot tickens!
 
I already thought about something like that too, before getting to sleep :D
Open Sea Mod = DirectSail Mod?
 
Ok let try this.
Open CCCdirectsail.c
find all instances of
Code:
FindClosestShipofRel
comment out the line with that.
and after that add a line there with this
Code:
Find_nearest_inf_ship(pchar);

there should be two instances. probally this will only cause a lot of new problems, maybe its better to first add a log line also at those place (and in the if statement after it) to see if these are called on open sea instead.
 
Open Sea Mod = DirectSail Mod?
Open Sea Mod is just an enlarged worldmap scale. DirectSail is the ability to sail from island to island without using the worldmap.
They both work together, but aren't the same.
 
Back
Top