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

Guide NPC Positioning/Movement

Cerez

Baroness of the High Seas
Storm Modder
This is a slightly more advanced modders' question: how are character positionings defined in the Storm engine? I can't seem to find any text file that defines how characters are positioned in a level or the waypoints they go to. Is this something that is embedded in the level/map model files? How to modify character movement/positioning?

I expect those who have worked on previous new story mods, such as New Horizons, will have the answer. ;)
 
Is this something that is embedded in the level/map model files?
Indeed that. It's done with "locators", which are named coordinates included in the location GM model files.
Probably this game also has a line in the "cameras" file to make them visible during gameplay.
 
Thanks Pieter. Yes, I've noticed the references to "locators" in the C code. What would be the easiest and most practical way of editing a GM model file? Are these compiled?
 
To see the locators: PROGRAM/InternalSettings.h at the very end set VISIBLE_LOCATORS to 1
and if you want also WITH_BRIGHT_COLOURS to 1.

To get the position for a locator: PROGRAM/console.c set the first switch to 2.
Go to the location and press F12.

To change or add locators use the TOOL: Open GM, search for the locatorfile, view/Locators/Locators
The first 3 numbers are x, y and z coordinates for the position. All the rest are the direction, where
xx = zz, xz = -zx, yy = 1, s0 = 1, all other can be 0. (y is the height)

When you have made your changes: Apply changes, Save GM.
 
Another useful trick in TOOL is to click the "Locators" tab, then "Write to File". This saves the locators as a text file. The file isn't that easy to read, but it makes adding a new locator a bit easier. Use your favourite text editing program to edit the file, copy and paste the line for an existing locator, and save the file back. Then, in TOOL, click the "Locators" tab, then "Read from File". Click the "View" tab followed by "View Locators" again, and now you can change the values for your new locator.

Note that locators for places such as towns aren't in the model file, but in another file with a similar name but typically with "_l" added. If the town's model is "Havana_center.gm", for example, then the locators are probably in something like "Havana_center_l.gm". You can use "Write to File" to copy the locators into a text file, then open the town model file, use "Read from File" to import the locators, and then save the file as something new, e.g. "Havana_center_with_locators.gm" - be careful not to overwrite the original town model!

You can then use GM Viewer to look at that combined model/locator file. Use TOOL to move the locator, use GM Viewer to see where it is now, repeat until the locator is where you want it. Then use "Write to File" to update the text file, open the original locator file again, use "Read from File" to import the updated locators, and save the result back to the locator file.
 
@Jack Rackham: Thanks for your write-up!

Additional note: the question was about Sea Dogs: Caribbean Tales, which is unfortunately a bit more primitive on this than PotC:NH.
The InternalSettings.h option and console are unique to PotC:NH, as far as I'm aware.
 
Geat tips, thanks guys! This thread will be useful to anyone else looking to get into some more comprehensive Sea Dogs modding. We should mark it as guide documentation.

And yes, Captain @Pieter Boelen is quite right; Caribbean Tales doesn't have an "InternalSettings.h" or "console.c". These were later added for practical purpose by Seaward, it seems. However, nothing stops us from writing a simple C function to display those markers and values in CT -- which is something I may personally look into if I end up working on some story mods, and share with you here.

(I've already written a similar debugging code snippet into the game for current game world time reference.)

And just to say that with your guiding instructions (thank you), I've successfully patched a mispositioned locator with the Inez Dias Tool for CT and got it working without any problems in-game, so thumbs up, this process definitely works.

Worth noting that in CT, GMs that contain location/scene locators are often stored in a file that, intuitively, contains the "_locators" suffix in the file name.
 
Last edited:
I don't know if this is of any help but I upload the POTC:NH console so you can see how the function for getting the coordinates is written (case 2)
 

Attachments

  • console.c
    65.7 KB · Views: 322
Wow, that's so considerate! Thank you! :3

Yes, this will definitely help give me an idea on how to go about it.

Edit:

In fact, I can pretty much just take case 2 as is and integrate it into CT. The retrieval functions used are exactly the same! I think only "Logit" needs to be changed to use CT's log interface.
 
Last edited:
Yep, just tested it, and the following seems to work without issue:
Code:
if (ILogAndActions.type != "sea")
{
               float x,y,z,ay,xx,zz,xz,zx;
               GetCharacterPos(GetMainCharacter(), &x, &y, &z);
               GetCharacterAy(pchar, &ay);
               xx = -sin(ay - PId2);
               zz = xx;
               xz = -cos(ay - PId2);
               zx = -xz;
               Log_SetStringToLog("Location id: "+pchar.location);
               Log_SetStringToLog("Your Coords x: " + x+"  y: "+y+"  z: "+z );
               Log_SetStringToLog("Viewangle ay: "+ay+"; xx= "+xx+" xz= "+xz+" zx= "+zx+" zz= "+zz);
}
else
{
               Log_SetStringToLog("Ship position: x="+pchar.ship.pos.x+", z="+pchar.ship.pos.z);
}

Just need to find a way to bind it to the F12 key...
 
And yes, Captain @Pieter Boelen is quite right; Caribbean Tales doesn't have an "InternalSettings.h" or "console.c". These were later added for practical purpose by Seaward, it seems. However, nothing stops us from writing a simple C function to display those markers and values in CT -- which is something I may personally look into if I end up working on some story mods, and share with you here.
Almost right; those features were added by us here for the older 2003 PotC game in the series.
It is certainly very possible to add it to any of the newer games too, but I don't know if anyone ever did in any of the mods.
Definitely worth doing though; those features are insanely useful!
You're welcome to download the free PotC:NH mod files and see what inspiration you can find in there. :doff

I think only "Logit" needs to be changed to use CT's log interface.
Replace it with 'Log_SetStringToLog'.
We made a function alias in our mod, because we are lazy and got tired of writing that long name. :wp
 
Thanks Pieter. Yes, I've noticed the references to "locators" in the C code. What would be the easiest and most practical way of editing a GM model file? Are these compiled?
Almost right; those features were added by us here for the older 2003 PotC game in the series.
It is certainly very possible to add it to any of the newer games too, but I don't know if anyone ever did in any of the mods.
Definitely worth doing though; those features are insanely useful!
You're welcome to download the free PotC:NH mod files and see what inspiration you can find in there. :doff


Replace it with 'Log_SetStringToLog'.
We made a function alias in our mod, because we are lazy and got tired of writing that long name. :wp

I'm not sure, but it's probably best not to use 'SetStringToLog'

In my opinion it is better to use Trace ("");

In quotes, you write what you need to output to one of the debug files.

The second function will display all the same data, but in a file comple.log

It will be more convenient to take coordinates.
 
I'm not sure, but it's probably best not to use 'SetStringToLog'

In my opinion it is better to use Trace ("");
If you want to debug, indeed 'Trace' is great. If you want something on-screen for gameplay, 'SetStringToLog' is good instead.
In PotC:NH, I added a 'TraceAndLog' function, which does both at the same time. Can sometimes be useful too, especially combined with the console.
 
The function that was suggested by me is more convenient - you do not need to remember the numbers, copied them from the debugging data and everything.
 
The function that was suggested by me is more convenient - you do not need to remember the numbers, copied them from the debugging data and everything.
For remembering numbers, you are definitely very much correct. :onya
 
I'm not sure, but it's probably best not to use 'SetStringToLog'

In my opinion it is better to use Trace ("");

In quotes, you write what you need to output to one of the debug files.

The second function will display all the same data, but in a file compile.log

It will be more convenient to take coordinates.

You're quite right, good suggestion. I've attached an update to the patch that does both for those who find this method easier for taking notes:
 

Attachments

  • seadogs.c
    27.1 KB · Views: 329
You're quite right, good suggestion. I've attached an update to the patch that does both for those who find this method easier for taking notes:

void showLocatorPos()
{
string sText1, sText2, sText3;
if (ILogAndActions.type != "sea")
{
float x,y,z,ay,xx,zz,xz,zx;
GetCharacterPos(GetMainCharacter(), &x, &y, &z);
GetCharacterAy(pchar, &ay);
xx = -sin(ay - PId2);
zz = xx;
xz = -cos(ay - PId2);
zx = -xz;
sText1 = "Location id: "+pchar.location;
sText2 = "Your coords x: " + x+" y: "+y+" z: "+z;
sText3 = "Viewangle ay: "+ay+"; xx= "+xx+" xz= "+xz+" zx= "+zx+" zz= "+zz;
Log_SetStringToLog(sText1);
Log_SetStringToLog(sText2);
Log_SetStringToLog(sText3);
Trace(sText1);
Trace(sText2);
Trace(sText3);
}
else
{
sText1 = "Ship position: x="+pchar.ship.pos.x+", z="+pchar.ship.pos.z;
Log_SetStringToLog(sText1);
Trace(sText1);
}
}
 
Last edited:
Back
Top