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

Need Help Execute console (F4) doesnt work.

Davy_Jones

Powder Monkey
I am trying to port the Submerge/Emerge functionality to the game for FD.

"Long story short: An attempt to port this functionality was made back in 2018, with the help of some people here. It worked but had some limited functionality.
I am trying to make it work better, but cant test because the console is not working..."


I am trying to use the execute console command, yet it doesn't work.

This is the code in the console:

void ExecuteConsole()
{
return;
ref pchar = GetMainCharacter();
Log_SetStringToLog("id " + pchar.id);
pchar.Ship.Type = GenerateShip(SHIP_CursedDutchman, 0);
pchar.Ship.SubmergeDutchman = true;
Log_SetStringToLog("Executed Console");
return;

if (!bSeaActive) ref lcn = &Locations[FindLocation(pchar.location)];
ref ch;
int i;
int limit;

Log_SetStringToLog("Executed Console");
}



Can someone tell me if there is a mistake, or the console execution is assigned to a different button in AOP2 GOF2.1.5?
 

Attachments

  • console.c
    431 bytes · Views: 153
void ExecuteConsole()
{
return;
ref pchar = GetMainCharacter();
At first glance, I'd say that first 'return' would prevent any of the code after to be run.
Try removing that and see what happens then.

I am trying to port the Submerge/Emerge functionality to the game for FD.
Glad to hear you like that 'ol feature of mine enough to try porting it!
If you have any other questions, feel free to ask. :doff
 
At first glance, I'd say that first 'return' would prevent any of the code after to be run.
Try removing that and see what happens then.


Glad to hear you like that 'ol feature of mine enough to try porting it!
If you have any other questions, feel free to ask. :doff

hi, thx for the tip!

The console worked. yet, I encountered few other weird things.
I have recorded a short clip.

Would be thankful if you could share your thoughts on the issues I've encountered.

Thanks in advance!

 
Would be thankful if you could share your thoughts on the issues I've encountered.
That looks really good! :shock

What issues are you referring to?
Is it that "screen flashing" thing?
I honestly haven't a clue what to do about that.
Maybe @Hammie would...?
It seems more like a game engine thing to me.
 
Well, the code was written here on the forum 2 years ago, but I don't remember by whom exactly :(
There are 3 problems so far:

1. Screen flashing, as you noticed. Once underwater there is a screen flash, which looks like the game is rendering the space above the water for a fraction of a second.
2. Once underwater, when pressing the F4 to execute the code again, the Dutchman doesn't emerge. Instead, it pops up on the surface and starts submerging again. I have shown it in the video. I might be confused or something, but maybe I need to assign a different button for emerge function and state pchar.Ship.SubmergeDutchman = false;?
3. Once submerged and on the world up, other ships still can see the Dutchman and engage it.

Cool thing though, sailors are still walking on the deck, while submerge :DD that's a positive
 
Last edited by a moderator:
@Pieter Boelen could you please point me towards the following:
Where can I find how to set up a battle interface functioning, so I have a submerge/emerge button, just like in POTC.
I have ported the code from "battleinterface.c", fixed the errors. But I wasn't able to find out how to assign a button and an icon to it.
Thanks in advance!
 
Well, the code was written here on the forum 2 years ago, but I don't remember by whom exactly :(
Not sure who posted the sections on the forum; but it was me who invented the feature for PotC: New Horizons.

1. Screen flashing, as you noticed. Once underwater there is a screen flash, which looks like the game is rendering the space above the water for a fraction of a second.
There's nothing I can think of to solve that. PotC doesn't do that. So I suspect it is an engine thing.
Only @Hammie or @ChezJfrey or one of the other engine experts might be able to say something about that.

And actually... for a future engine upgrade, we could definitely use a more scenic underwater look.
Not pure black, but something more blueish; with a fog effect of sorts.
So at least being underwater doesn't look quite as bad as it does not.

2. Once underwater, when pressing the F4 to execute the code again, the Dutchman doesn't emerge. Instead, it pops up on the surface and starts submerging again. I have shown it in the video. I might be confused or something, but maybe I need to assign a different button for emerge function and state pchar.Ship.SubmergeDutchman = false;?
Do you have somewhere "DeleteAttribute(pchar, "ship.SubmergeDutchman");" in there?
In my New Horizons implementation, that is what's used to stop the sinking effect.
Should be in a section like this:
Code:
           if(stf(rCharacter.ship.SubmergeDutchman) <= stf(rCharacter.ship.CorrectImmersion))
           {
               rCharacter.ship.immersion = rCharacter.ship.CorrectImmersion;
               [...]
               DeleteAttribute(rCharacter, "ship.SubmergeDutchman");
               DeleteAttribute(rCharacter, "ship.EmergeDutchman");
               DeleteAttribute(rCharacter, "ship.PlayedSplash");
           }

Also, this is the command that the "Submerge/Emerge" calls to:
Code:
       if(!CheckAttribute(PChar, "ship.SubmergeDutchman")) PChar.ship.SubmergeDutchman = PChar.ship.CorrectImmersion;
       else PChar.ship.EmergeDutchman = 0;
       DeleteAttribute(PChar, "ship.PlayedSplash");

3. Once submerged and on the world up, other ships still can see the Dutchman and engage it.
For 3D Sailing Mode, we added this in PROGRAM\SEA_AI\AIShip.c:
Code:
float Ship_GetDistance2D(ref rCharacter1, ref rCharacter2)
{
   //Levis trying to get the dutchman out of reach when submerged -->
   if(CheckAttribute(rCharacter1, "ship.SubmergeDutchman") || CheckAttribute(rCharacter2, "ship.SubmergeDutchman")) return DIST_NOSHIP;
   //Levis trying to get the dutchman out of reach when submerged <--
Then in PROGRAM\WorldMap\worldmap_encgen.c:
Code:
//Storm
void wdmStormGen(float dltTime, float playerShipX, float playerShipZ, float playerShipAY)
{
   ref mc = GetMainCharacter();
   bool encoff = false;
   if(GetAttribute(mc,"worldmapencountersoff") == 1)   return;
   if(CheckAttribute(mc,"ship.SubmergeDutchman"))       return;   // PB: No encounters or storms while you are submerged

And finally in PROGRAM\WorldMap\worldmap_globals.c:
Code:
bool wdmCreateFollowShip(int type, float dltSpeedInPMPercents)
{
   ref mc = GetMainCharacter();
   if(CheckAttribute(mc,"ship.SubmergeDutchman"))  return false;

Not sure how that compares to the CoAS code; but there must be something similar somewhere in there I imagine.

Cool thing though, sailors are still walking on the deck, while submerge :DD that's a positive
No surprises there.
The game doesn't have the faintest clue that sailors cannot survive underwater; because it doesn't even understand "underwater" is a thing.

Beautifully stupid game engine.
You have to manually explain it everything. :rofl
 
@Pieter Boelen could you please point me towards the following:
Where can I find how to set up a battle interface functioning, so I have a submerge/emerge button, just like in POTC.
I have ported the code from "battleinterface.c", fixed the errors. But I wasn't able to find out how to assign a button and an icon to it.
Thanks in advance!
Did you find this section?
Code:
    // для главного персонажа
   if(mainIdx==chIdx)
   {
       [...]
       BattleInterface.Commands.SubmergeDutchman.enable   = GetAttribute(mainCh, "ship.type") == "CursedDutchman";           // PB: Flying Dutchman
       [...]
   }
   // для спутников
   else
   {
       [...]
       BattleInterface.Commands.SubmergeDutchman.enable   = false; // PB: Flying Dutchman
And then also this further down in the same file:
Code:
// PB: Flying Dutchman -->
   BattleInterface.Commands.SubmergeDutchman.enable   = false;
   BattleInterface.Commands.SubmergeDutchman.picNum   = 20;
   BattleInterface.Commands.SubmergeDutchman.event       = "BI_SubmergeDutchman";
   BattleInterface.Commands.SubmergeDutchman.note       = LanguageConvertString(idLngFile, "sea_SubmergeDutchman");
// PB: Flying Dutchman <--
 
Did you find this section?
Code:
    // для главного персонажа
   if(mainIdx==chIdx)
   {
       [...]
       BattleInterface.Commands.SubmergeDutchman.enable   = GetAttribute(mainCh, "ship.type") == "CursedDutchman";           // PB: Flying Dutchman
       [...]
   }
   // для спутников
   else
   {
       [...]
       BattleInterface.Commands.SubmergeDutchman.enable   = false; // PB: Flying Dutchman
And then also this further down in the same file:
Code:
// PB: Flying Dutchman -->
   BattleInterface.Commands.SubmergeDutchman.enable   = false;
   BattleInterface.Commands.SubmergeDutchman.picNum   = 20;
   BattleInterface.Commands.SubmergeDutchman.event       = "BI_SubmergeDutchman";
   BattleInterface.Commands.SubmergeDutchman.note       = LanguageConvertString(idLngFile, "sea_SubmergeDutchman");
// PB: Flying Dutchman <--

Yes I have them ported.

For "BattleInterface.Commands.SubmergeDutchman.enable = GetAttribute(mainCh, "ship.type") == "CursedDutchman"; // PB: Flying Dutchman" had to replace "mainCh with rCharacter, otherwise I would get error (false argument, no function).

EDIT: Yet, there is no icon, since I don't know from where to take the icon and where to put it. I know the directory for it. "Resource/BattleInterface. But judging from POTC, I think all this button icons are inside one icon.tga.tx
So, I am a bit confused

Not sure who posted the sections on the forum; but it was me who invented the feature for PotC: New Horizons.


There's nothing I can think of to solve that. PotC doesn't do that. So I suspect it is an engine thing.
Only @Hammie or @ChezJfrey or one of the other engine experts might be able to say something about that.

And actually... for a future engine upgrade, we could definitely use a more scenic underwater look.
Not pure black, but something more blueish; with a fog effect of sorts.
So at least being underwater doesn't look quite as bad as it does not.


Do you have somewhere "DeleteAttribute(pchar, "ship.SubmergeDutchman");" in there?
In my New Horizons implementation, that is what's used to stop the sinking effect.
Should be in a section like this:
Code:
           if(stf(rCharacter.ship.SubmergeDutchman) <= stf(rCharacter.ship.CorrectImmersion))
           {
               rCharacter.ship.immersion = rCharacter.ship.CorrectImmersion;
               [...]
               DeleteAttribute(rCharacter, "ship.SubmergeDutchman");
               DeleteAttribute(rCharacter, "ship.EmergeDutchman");
               DeleteAttribute(rCharacter, "ship.PlayedSplash");
           }

Also, this is the command that the "Submerge/Emerge" calls to:
Code:
       if(!CheckAttribute(PChar, "ship.SubmergeDutchman")) PChar.ship.SubmergeDutchman = PChar.ship.CorrectImmersion;
       else PChar.ship.EmergeDutchman = 0;
       DeleteAttribute(PChar, "ship.PlayedSplash");

Where those should be? in which file? NK or AIShip?

ChezJfrey tried to help and convert it to GOF. Here is the link of it. They had to change the code somewhat, bcs the game didn't recognize some of the functions.
Mod Release - Gentlemen Of Fortune 2.1.5 mod development
 
Last edited by a moderator:
Yes I have them ported.
:onya

For "BattleInterface.Commands.SubmergeDutchman.enable = GetAttribute(mainCh, "ship.type") == "CursedDutchman"; // PB: Flying Dutchman" had to replace "mainCh with rCharacter, otherwise I would get error (false argument, no function).
Fair enough; it was to be expected some adaptation would be needed. :doff

Yet, there is no icon, since I don't know from where to take the icon and where to put it. I know the directory for it. "Resource/BattleInterface. But judging from POTC, I think all this button icons are inside one icon.tga.tx
So, I am a bit confused
Look at PotC's "cicons_command.tga.tx".

Not sure what CoAS's equivalent file might be; but with some luck it's defined similar to here:
Code:
void SetParameterData()
{
   int idLngFile = LanguageOpenFile("commands_name.txt"); // KK
   ref PChar = GetMainCharacter(); // PB
   string compasstype = CheckCharacterEquipByGroup(PChar, COMPASS_ITEM_TYPE); // KK
   if (iRealismMode == 0 && !NAVIGATION_EQUIPMENT) compasstype = "compass3"; // Erwin Lindemann

   BattleInterface.CommandTextures.list.t0.name = "battle_interface\cicons_charge.tga";
   BattleInterface.CommandTextures.list.t0.xsize = 1;
   BattleInterface.CommandTextures.list.t0.ysize = 4;

   BattleInterface.CommandTextures.list.t1.name = "battle_interface\cicons_command.tga";
   BattleInterface.CommandTextures.list.t1.xsize = 4;
   BattleInterface.CommandTextures.list.t1.ysize = 8; // FCoHS
That number before "FCoHS" is the one you need to increase if you add an extra row to the existing texture file.

Where those should be? in which file? NK or AIShip?
Those two sections are from NK.c .

If you haven't seen it already, have a look here: Tutorial - Modding Tips & Tricks
That's how I'm finding back my own code too; because of course I hardly remember either. :oops:
 
:onya


Fair enough; it was to be expected some adaptation would be needed. :doff


Look at PotC's "cicons_command.tga.tx".

Not sure what CoAS's equivalent file might be; but with some luck it's defined similar to here:
Code:
void SetParameterData()
{
   int idLngFile = LanguageOpenFile("commands_name.txt"); // KK
   ref PChar = GetMainCharacter(); // PB
   string compasstype = CheckCharacterEquipByGroup(PChar, COMPASS_ITEM_TYPE); // KK
   if (iRealismMode == 0 && !NAVIGATION_EQUIPMENT) compasstype = "compass3"; // Erwin Lindemann

   BattleInterface.CommandTextures.list.t0.name = "battle_interface\cicons_charge.tga";
   BattleInterface.CommandTextures.list.t0.xsize = 1;
   BattleInterface.CommandTextures.list.t0.ysize = 4;

   BattleInterface.CommandTextures.list.t1.name = "battle_interface\cicons_command.tga";
   BattleInterface.CommandTextures.list.t1.xsize = 4;
   BattleInterface.CommandTextures.list.t1.ysize = 8; // FCoHS
That number before "FCoHS" is the one you need to increase if you add an extra row to the existing texture file.


Thank you, I see!
Since there are rows in the texture file, that need to be followed strictly, could you kindly recommend a program to work with .tga files?
 
Since there are rows in the texture file, that need to be followed strictly, could you kindly recommend a program to work with .tga files?
I myself use Adobe Photoshop CS2; but a free program like The Gimp can do it too.
You've got the TX Converter already, right?
 
@Pieter Boelen @Grey Roger both programs are jewels. work flawlessly and are very intuitive. I am very surprised.

I have been modding Skyrim for 6 years now. There, when it comes to textures - it's a nightmare. There are no proper and easy to navigate tools to work with them and convert :(
Although Skyrim has a tool called the Creation Kit. It was build by Bethesda specifically for modders, so we can mod the game and add new items, quests, effects, locations, characters and etc. I wonder if the AOP or POTC creators ever had such a tool, hmm
 
@Pieter Boelen @Grey Roger both programs are jewels. work flawlessly and are very intuitive. I am very surprised.
Pretty sure it's both the same program.
We have only the one... :wp

I have been modding Skyrim for 6 years now. There, when it comes to textures - it's a nightmare. There are no proper and easy to navigate tools to work with them and convert :(
Ouch!!

I wonder if the AOP or POTC creators ever had such a tool, hmm
I know GM Viewer, Animation Viewer and TX Converter are all original Akella tools that were used in creating the game.
For the 3D modeling, the used Maya 5 with their own GM Exporter plugin, which we've also got.
Haven't a clue what kind of environment they used for the coding though.
 
Back
Top