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

Ideas for the future!

I think this was an idea a long time before: Making lights for ships at night? I know that the locators are a problem but.. maybe we could do it by using particles, like with fire and smoke? Wouldn't that be possible?
Well, there is at least one possibility we haven't really looked into yet, and that's to somehow modify the glowing Incan Artefact from the original storyline.

This ancient post gives a couple of details:
Hello SirChristopherMings,

Actually, your reasoning is sound, even if it was a bit derailed due to lack of information on the inner workings of the game in this aspect.

I do believe that Some Kind of Locators (Fonar) for lack of a better word could be defined on a Ship model, and through scripting make the Inkan artefact attach itself to them on a ship, and have it activate and deactivate at will.

This, in theory at least, should work yes :)

The exact coding approach I would not be able to say, but the process should be similar to the "Reload" locators for other functions, might even be something like the Tent Merchants in harbors that are there during day and not there during night, if that is manipulable via script. ;)

Merits a try to say the least!
Nobody ever did try this out, though it's not guaranteed to work, either.
 
Interesting thought.

These are the lines of code that trigger the artifact:
Code:
      CreateEntity(&artifact, "artifact");
       LayerAddObject(SEA_REALIZE, &artifact, -1);
I think this runs MODULES\artifact.dll and that, in turn, uses RESOURCE\INI\PARTICLES\artifact.ini .
We might be able to HEX-edit that DLL file to use a different particle effect.

I'm not sure how the game decides the coordinates to do this though. Seems the game somehow "knows" where the quarterdeck is.
See? Even on the ridiculous stern of the Queen Anne's Revenge, it is still showing up.

So in order to make use of this, we would need to:
1. Make a copy of the DLL and INI files and edit them to use a different particle effect
2. Figure out how the game decides on the coordinates
3. Convince the game to put it at the coordinates we want

Edit: Could the game be making use of the existing "fireplace" locators?
I can't seem to visualize those with the GM Viewer. Is there one on the quarterdeck of Barque3_50 and QueenAnnesRevenge?
If that IS indeed what it uses, then this is never going to work. We need it to use something else that we can influence.
 

Attachments

  • Artifact.jpg
    Artifact.jpg
    130.9 KB · Views: 89
  • ArtifactQAR.jpg
    ArtifactQAR.jpg
    47.1 KB · Views: 97
Last edited:
PROGRAM\SEA_AI\AIShip.c contains the code related to the other on-sea particle effects, namely the fireplaces.
This is for the "fire ship" ability (does that even work???):
Code:
      case AITASK_BRANDER:
         ref rCharacter2Brander = GetCharacter(sti(rCharacter.SeaAI.Task.Target));
         ref rBaseShip = GetShipByType(GetCharacterShipType(rCharacter2Brander)); // PS
         float fBranderDistance = 30.0 + (8.0 - stf(rBaseShip.Class)) * 40.0;
         float fDistance = Ship_GetDistance2D(rCharacter, rCharacter2Brander);
         if (fBranderDistance > fDistance && fDistance >= 0) // NK for when dist < 0 05-04-15
         {
           // fire ship
           int iNumFirePlaces = 0;
           SendMessage(rShipObject, "le", MSG_SHIP_GET_NUM_FIRE_PLACES, &iNumFirePlaces);
           for (int i=0; i<iNumFirePlaces / 3; i++)
           {
             PostEvent(SHIP_ACTIVATE_FIRE_PLACE, rand(10000), "ialsf", rShipObject, rCharacter, i, "ship_onfire", 30.0);
           }
           rCharacter.fireplaces.brander = true; // NK 05-04-18
           PostEvent(SHIP_BRANDER_DETONATE, 10000, "l", sti(rCharacter.index));

           Ship_SetTaskNone(SECONDARY_TASK, sti(rCharacter.index));
         }
         //Trace("test1 rCharacter2Brander = " + rCharacter2Brander.index);
       break;
That SendMessage line is the link between the code we can access and the game engine. It calls something that is hidden away in those DLL files.

All "ship hit" particles are done with x,y,z coordinates, same as the SteamShip effects.
And the cannon fire effects in AICannon.c with void Cannon_FireCannon() ,
but again this gets its x,y,z coordinates from a GetEventData() which is sent out from the game engine.

Particle effects we can make or edit. But how do we control the coordinates?
If we can't do that, we can't do anything here. :facepalm
 
Edit: Could the game be making use of the existing "fireplace" locators?
I can't seem to visualize those with the GM Viewer. Is there one on the quarterdeck of Barque3_50 and QueenAnnesRevenge?
If that IS indeed what it uses, then this is never going to work. We need it to use something else that we can influence.
My best guess is that it makes use of the z-value of the aftermost 'fireplace' locator (these are all marked "locator#" in GM Viewer).
The rest seems to be automated - I think it's positioned centrally along the x-axis, and somehow chooses a y-value that puts it above the deck - but I might be wrong.

We could test this by moving a random fireplace locator off the back of a ship and see how that affects the artifact's position.
 
Sounds possible. If we really want to try this, we'd have to figure it out though.
No point in having a perfect lantern effect that refuses to be at the spot of the actual lantern. :confused:

(BTW: WHY can't this just be simple? Why has it all to be "game engine hidden crap"? :modding )
 
So in order to make use of this, we would need to:
1. Make a copy of the DLL and INI files and edit them to use a different particle effect
We CAN indeed do #1 there:
ShipFire.jpg

That fire uses the same method as the artifact particle system. It also shows up in exactly the same spot.
It doesn't influence the artifact effect either, so at least we can put something else to use.
Now HOW to influence the positioning???
 
It should be mentioned that this effect is near-perfect: it even gives off a proper light glow which is especially obvious at night.
All we'd need to do is adapt it to look like a lantern, which shouldn't be too difficult.
AND put it on the coordinated we want. Which would be a bit more challenging,
because I still have ZERO clue on how the game knows where to draw it in the first place. o_O
 
Extract attached to your main game folder to test this out. Press F12 to turn on/off the quarterdeck fire.
 

Attachments

  • ShipLampExperiment.zip
    34.7 KB · Views: 114
Was wondering if the height of the hull GM file has anything to do with it, so tried out a ship known to have the "camera bug".
See here the effect on La Couronne:
CouronneFire.jpg

And also an AoP style ship. Interestingly enough, on here the effect shows up behind the ship.
FleutWarFire.jpg
Though, in fact, that bottom boom is part of the hull, which probably explains it.

Another AoP ship that doesn't have such a boom and it is back on the quarterdeck:
BarqueHeavyFire.jpg

Still not making much sense to me. Might it be related to the "box size" of the ships?
But then again the problem remains: HOW do we put it somewhere else???

Changing that -1 into something else does have interesting effects, such as the effect only showing below the horizon or only within the confines of the ship model.
Quite weird, but not useful and the emission point doesn't change at all.
 
Interesting stuff! Still awfully confusing with the positioning, though. As you said, it may be to do with the ship's collision 'box'.
On some ships, it seems to emit slightly further back relative to others, so a constant percentage of the ship's length probably isn't used.
 
On some ships, it seems to emit slightly further back relative to others, so a constant percentage of the ship's length probably isn't used.
That's what's got me so confused too. If you get round to fixing the camera issue on the FR_Couronne, we can compare before and after. Perhaps that would tell us more?

There are two more things we can try:
1. Check ALL ship attributes; if we're REALLY lucky, locator coordinates would be in there
2. See if there is an AoP/CoAS .dll file that we can use instead and call through code
 
1. Check ALL ship attributes; if we're REALLY lucky, locator coordinates would be in there
Well THAT's disappointing. Turns out rShipObject is just the CAPTAIN of the ship and not the actual SHIP:
Code:
void Ship_CheckSituation()
{
   ref    rShip;
   //NK 04-09-15 comment out unneeded vars.
     ref rMainCharacter = GetMainCharacter();
   aref   rCharacter = GetEventData();
   aref   rShipObject = GetEventData();
If only there were some way to read out the ship GM files like we CAN do for location models.
If I do it the "normal" way, I only get the stuff defined through ships_init.c, but nothing extra. Booooring.
 
2. See if there is an AoP/CoAS .dll file that we can use instead and call through code
From CoAS AISea.c:
Code:
object   ShipLights;

extern void InitShipLights();

void SeaAI_GetLayers()
{
   aref oTmp = GetEventData();
   SendMessage(oTmp, "lss", AI_MESSAGE_SET_LAYERS, sCurrentSeaExecute, sCurrentSeaRealize);
}

void DeleteSea()
{
   DeleteClass(&Sea);
   DeleteClass(&ShipLights);
}

void CreateSea(string sExecuteLayer, string sRealizeLayer)
{
   if (IsEntity(&Sea)) { Trace("ERROR: Sea Already Loaded!!!"); return; }

   CreateEntity(&Sea, "sea");
   MoveSeaToLayers(sExecuteLayer, sRealizeLayer);

   LayerFreeze("sea_reflection2", false);

   if (LoadSegment("sea_ai\ShipLights.c"))
   {
     InitShipLights();
     UnloadSegment("sea_ai\ShipLights.c");
   }
   CreateEntity(&ShipLights, "ShipLights");     ReloadProgressUpdate();
   LayerAddObject(sExecuteLayer, &ShipLights, 0);
   LayerAddObject(sRealizeLayer, &ShipLights, -1);
   LayerAddObject("sea_sunroad", &ShipLights, -1);

   Sea.AbordageMode = false;
}
And separate ShipLights.c:
Code:
void InitShipLights()
{
   aref rlights;

   ShipLights.LightTypes = "";
   ShipLights.MaxD3DLights = 7;
   ShipLights.CoronaTextureX = 1;
   ShipLights.CoronaTextureY = 1;
   ShipLights.CoronaTexture = "ShipsFlares\corona.tga";
   ShipLights.FlareSunRoadTexture = "ShipsFlares\FlareSunRoad.tga";
   ShipLights.CoronaTechnique = "coronas";
   ShipLights.SunRoadFlareSize = 4.0;

  makearef(rlights, ShipLights.LightTypes);

   // default light emitter for ship
   rlights.default.light.r = 1.0;
   rlights.default.light.g = 0.9;
   rlights.default.light.b = 0.0;
   rlights.default.light.range = 15.0;

   rlights.default.light.Attenuation0 = 0.0;
   rlights.default.light.Attenuation1 = 0.3;
   rlights.default.light.Attenuation2 = 0.0;
   
   rlights.default.Oscillator1.Flicker = 0.15;
   rlights.default.Oscillator1.Freq = 5.0;

   rlights.default.Oscillator2.Flicker = 0.1;
   rlights.default.Oscillator2.Freq = 1.0;

   rlights.default.corona.r = 1.0;
   rlights.default.corona.g = 1.0;
   rlights.default.corona.b = 1.0;
   rlights.default.corona.subtexture = 0;
   rlights.default.corona.Range = 5.0
   rlights.default.corona.Size = 1.0
   rlights.default.SunRoadFlareFadeDistance = 600.0;

   // cannon default light emitter
   rlights.cannondefault.light.r = 2.0;
   rlights.cannondefault.light.g = 2.0;
   rlights.cannondefault.light.b = 2.0;
   rlights.cannondefault.light.range = 20.0;

   rlights.cannondefault.light.Attenuation0 = 0.0;
   rlights.cannondefault.light.Attenuation1 = 0.3;
   rlights.cannondefault.light.Attenuation2 = 0.0;   

   rlights.cannondefault.LifeTime = 0.2;
   rlights.cannondefault.UpTime = 0.1;

   // default flare for ship
   rlights.flare.light.r = 1.2;
   rlights.flare.light.g = 1.0;
   rlights.flare.light.b = 2.2;
   rlights.flare.light.range = 15.0;

   rlights.flare.light.Attenuation0 = 0.0;
   rlights.flare.light.Attenuation1 = 0.3;
   rlights.flare.light.Attenuation2 = 0.0;

   rlights.flare.Oscillator1.Flicker = 0.15;
   rlights.flare.Oscillator1.Freq = 5.0;

   rlights.flare.Oscillator2.Flicker = 0.1;
   rlights.flare.Oscillator2.Freq = 1.0;

   rlights.flare.corona.r = 1.0;
   rlights.flare.corona.g = 1.0;
   rlights.flare.corona.b = 1.0;
   rlights.flare.corona.subtexture = 0;
   rlights.flare.corona.Range = 5.0
   rlights.flare.corona.Size = 1.0
   rlights.flare.SunRoadFlareFadeDistance = 600.0;
}
I suspect this works in conjunction with "something" in the DLL files. Unfortunately there is no brand new file that could be it.
Nothing called "ShipLights.dll". Perhaps we can trace it in the CoAS source code.

Also, CoAS maintained the "Artifact" code in its source, even if I don't know it is ever used in there.
Still, it does allow us to see the code that is involved. Unfortunately though, the code involved is FAR more advanced than anything found in the PROGRAM folder.
As such, I can't say I understand much of anything of it. o_O
 
You can't imagine what it looks like when you are in shotgun mode on a boarding deck with like 20 enemies in front of you :rofl:rofl:rofl
And yes, the fire already looks really fine on some ships :yes , but the flames are a bit too big at the moment (the Black Pearl e.g. looks like shes burning :D )
A quick question, if we really manage those lights: Can we convince the AI to use these lights if its night?
 
ShipLights is referred to in the CoAS net.dll, sea_ai.dll and ship.dll . The net one is not in PotC and I believe it related to the network ability in there.
But just plopping a CoAS file into PotC doesn't work. I just tried with the Worldmap one.
I wonder if we could convince that to work by also adapting the PROGRAM code files as per their CoAS versions though.
But..... easy this is not.
 
That's what's got me so confused too. If you get round to fixing the camera issue on the FR_Couronne, we can compare before and after. Perhaps that would tell us more?
Good point. Not sure if it would have much of an effect, but it's worth checking anyway.

I suspect this works in conjunction with "something" in the DLL files. Unfortunately there is no brand new file that could be it.
Nothing called "ShipLights.dll". Perhaps we can trace it in the CoAS source code.
I suspect it would be linked to PARTICLES.dll and/or Locator.dll, and maybe even Ship.dll. Those are my best guesses, at least.

Also, CoAS maintained the "Artifact" code in its source, even if I don't know it is ever used in there.
Still, it does allow us to see the code that is involved. Unfortunately though, the code involved is FAR more advanced than anything found in the PROGRAM folder.
As such, I can't say I understand much of anything of it. o_O
If we could make sense of the Artifact source code, that may very well help us to figure out how it positions itself on the ships.
Do you know if it could be activated in CoAS as a test to see if it still works the same way?
 
ShipLights is referred to in the CoAS net.dll, sea_ai.dll and ship.dll . The net one is not in PotC and I believe it related to the network ability in there.
But just plopping a CoAS file into PotC doesn't work. I just tried with the Worldmap one.
I wonder if we could convince that to work by also adapting the PROGRAM code files as per their CoAS versions though.
But..... easy this is not.
Yeah, swapping DLLs does tend to upset the engine a bit. :facepalm
Even adapting the code files might be worth a try, at least to see if we can stop the engine from crashing. It's anyone's guess as to whether it would work, mind.
 
And yes, the fire already looks really fine on some ships :yes , but the flames are a bit too big at the moment (the Black Pearl e.g. looks like shes burning :D )
The effect itself is just a temporary placeholder. No point in making it all pretty if we can't put it WHERE WE WANT.

A quick question, if we really manage those lights: Can we convince the AI to use these lights if its night?
That all depends on IF and HOW we can get it to work. As I understand that Artifact code, that only works on the player ship.

I suspect it would be linked to PARTICLES.dll and/or Locator.dll, and maybe even Ship.dll. Those are my best guesses, at least.
See my post above; I already found the references.

If we could make sense of the Artifact source code, that may very well help us to figure out how it positions itself on the ships.
Do you know if it could be activated in CoAS as a test to see if it still works the same way?
Try the same lines of code that I put in the test console file.
Not sure how to EXECUTE that in CoAS though, since nobody seems to have bothered to add a similar console to ours.
Plus I think the CoAS particle system is completely different from the one in PotC. So that probably doesn't help.
Would it help if you had access to the CoAS source code?
 
Back
Top