• 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 Hide officers

Myth

Freebooter
Good afternoon. On the plot events, I several times temporarily deprive the main character of everything that he has. But then I return everything back.
Now for such cases I create a copy of the hero without a ship and officers. Skills and experience are completely copied. The only problem: I can not copy the ship's log. The clone is empty.
I need a method that will allow copying all sections of the logbook into a clone.
Either you need to somehow hide your companions, captives, officers, etc. for a while. The menu "Ship" I just block.
 
In the original PotC storyline, at some point you lose your ship. This is done by temporarily exchanging it with a "placeholder" character.
Maybe that works in CoAS too:
Code:
            pchar.ship.type = SHIP_NOTUSED_TYPE_NAME; // PS
            ExchangeCharacterShip(Pchar, characterFromID("Ship Storage"));

Maybe @Jack Rackham and/or @Grey Roger know a trick to temporarily hide your officers too.
 
PoTC has functions to temporarily store your ship, your passengers and your equipment, and corresponding functions to put them back. If you want, I can either upload the file which contains them, or post the functions here. Passengers include officers, prisoners and anyone else associated with the player.
 
PoTC has functions to temporarily store your ship, your passengers and your equipment, and corresponding functions to put them back. If you want, I can either upload the file which contains them, or post the functions here. Passengers include officers, prisoners and anyone else associated with the player.

bool SetTempRemoveParam(ref _refCharacter, string _param)
{
string sParam = "TmpRemember" + _param;

if( CheckAttribute(_refCharacter, sParam) ) return false;
if( !CheckAttribute(_refCharacter, _param) ) return false;

aref dstRef; makearef(dstRef, _refCharacter.(sParam));
aref srcRef; makearef(srcRef, _refCharacter.(_param));

CopyAttributes(dstRef,srcRef);
return true;
}
are you talking about this?
 
or this?
bool ShipTempRemove(ref _refCharacter)
{
if( CheckAttribute(_refCharacter,"TmpShipHolder") ) return false;
if( !CheckAttribute(_refCharacter,"Ship") ) return false;

aref dstRef; makearef(dstRef, _refCharacter.TmpShipHolder);
aref srcRef; makearef(srcRef, _refCharacter.Ship);

CopyAttributes(dstRef,srcRef);
return true;
}
 
'ShipTempRemove(ref _refCharacter)' is the one to store the ship. If you're looking at "PROGRAM\QUESTS\quests.c" in PoTC, then 'RestoreTempRemovedShip(ref _refCharacter)' will put the ship back.

Likewise, 'TempRemoveItems(ref _refCharacter)' will store all your equipment and 'RestoreTempRemovedItems(ref _refCharacter)' will put them back. 'StorePassengers(string idCharacter)' and 'RestorePassengers(string idCharacter)' are for your passengers, including officers and prisoners.

There's also 'ExchangeCharacterShip(ref oneCharacter, ref twoCharacter)', which is what @Pieter Boelen referred to in the standard storyline. This can also be used to hide the player's ship by giving it to someone else, then you can restore the player's ship by exchanging it back. I made a lot of use of this in my own storyline. You swap ship with the governor of Santiago, who originally has none - he doesn't use the ship, he just acts as a store for it. Then you swap ship with an enemy commander because you've just stolen his ship. When you return to Santiago, you swap ship with the governor, then the governor swaps ship with a different character. The end result is that you have your own ship back, the governor is back to having no ship, and the other character now has the ship you stole from the enemy.
 
I thought your problem was that you can't copy the logbook to a clone of the hero. But you don't need to clone the hero. You just store the passengers, ship and equipment, and keep the original hero character along with the logbook.
 
No function to copy logbook?
The logbook functionality in PotC:NH was a mod-added feature.
That means the code for it is likely 100% different from CoAS, so whatever works there in PotC probably wouldn't work in CoAS.
 
No function to copy logbook?

Look at the function void selectJournal() in INTERFACE\QuestBook.c.

All of the quests (open and complete), are stored in pchar.QuestInfo. The function shows how to get the number of attributes, their names, and copy them. You will need to create another object (like a dummy character), and use the same methods to copy each QuestInfo.attributename to the new. Then, DeleteAttribute(pchar, "QuestInfo"). When you want them back, do the reverse to copy from your dummy back to pchar.
 
Look at the function void selectJournal() in INTERFACE\QuestBook.c.

All of the quests (open and complete), are stored in pchar.QuestInfo. The function shows how to get the number of attributes, their names, and copy them. You will need to create another object (like a dummy character), and use the same methods to copy each QuestInfo.attributename to the new. Then, DeleteAttribute(pchar, "QuestInfo"). When you want them back, do the reverse to copy from your dummy back to pchar.

I previously copied all the attributes completely. Then I changed the identifier of the clone. But when I returned everything to the place, the ship was not the one. Just now I understood:
1) You need 3 characters: the main character, clone and temporary character.
2) The temporary character is given any ship.
3) Then we change it and the main character by the ships.
4) Copy all the attributes from the Hero to the clone.
5) We remove the vessel from the clone.
On the return of everything: copy from the clone all into the hero. And with the temporary character again the exchange of ships.
I'll have to check it out today.
 
I don't think you need to use 3 characters, two will suffice (pchar and a copy). For the ship, I think it might be simpler to just set a temporary attribute to the 'real ship' index, then set .type to not used, like this:

pchar.ship.keepshiptype = pchar.ship.type;
pchar.ship.type = SHIP_NOTUSED;

When you want it restored:

pchar.ship.type = pchar.ship.keepshiptype
DeleteAttribute(pchar, "ship.keepshiptype");

I am fairly certain that if the ship.type equals SHIP_NOTUSED, then all the interface and sea load code will skip/not show the pchar ship, with no need to copy attributes at all. Worth a try?
 
I don't think you need to use 3 characters, two will suffice (pchar and a copy). For the ship, I think it might be simpler to just set a temporary attribute to the 'real ship' index, then set .type to not used, like this:

pchar.ship.keepshiptype = pchar.ship.type;
pchar.ship.type = SHIP_NOTUSED;

When you want it restored:

pchar.ship.type = pchar.ship.keepshiptype
DeleteAttribute(pchar, "ship.keepshiptype");

I am fairly certain that if the ship.type equals SHIP_NOTUSED, then all the interface and sea load code will skip/not show the pchar ship, with no need to copy attributes at all. Worth a try?

I wanted to use a third character to save the cargo, etc
I think I am found alternative:

DeleteAttribute(CopyChref, "QuestInfo");
CopyChref.QuestInfo = "";
makearef(arToChar, CopyChref.QuestInfo);
makearef(arFromChar, sld.QuestInfo);
CopyAttributes(arToChar,arFromChar);
 
Last edited:
I wanted to use a third character to save the cargo, etc
I think I am found alternative:

DeleteAttribute(CopyChref, "QuestInfo");
CopyChref.QuestInfo = "";
makearef(arToChar, CopyChref.QuestInfo);
makearef(arFromChar, sld.QuestInfo);
CopyAttributes(arToChar,arFromChar);

Yes, that is similar to what I saw in QuestBook.c.

Also, I am not convinced you need to copy cargo, either. Almost everywhere in the scripts I've seen, if .ship.type equals SHIP_NOTUSED, it will not display or compute any ship attributes. An example is in CharacterUtilite.c, SetBaseShipData:

makearef(refShip,refCharacter.Ship);
nShipType = GetCharacterShipType(refCharacter);
if(nShipType==SHIP_NOTUSED) return;

So I don't think you will have to copy cargo or ship to another character if you just set pchar.ship.type = SHIP_NOTUSED. All the cargo elements are under the .ship attribute (e.g. pchar.Ship.Cargo.Goods.(goodsName)), so if you just keep the ship.type in another, temporary attribute, like I described:

pchar.ship.keepshiptype = pchar.ship.type;
pchar.ship.type = SHIP_NOTUSED;

I don't think you will need to copy anything and the screens/loading ship processes will just skip what it thinks is an invalid ship. If that works, would save code, time and effort.
 
Yes, that is similar to what I saw in QuestBook.c.

Also, I am not convinced you need to copy cargo, either. Almost everywhere in the scripts I've seen, if .ship.type equals SHIP_NOTUSED, it will not display or compute any ship attributes. An example is in CharacterUtilite.c, SetBaseShipData:

makearef(refShip,refCharacter.Ship);
nShipType = GetCharacterShipType(refCharacter);
if(nShipType==SHIP_NOTUSED) return;

So I don't think you will have to copy cargo or ship to another character if you just set pchar.ship.type = SHIP_NOTUSED. All the cargo elements are under the .ship attribute (e.g. pchar.Ship.Cargo.Goods.(goodsName)), so if you just keep the ship.type in another, temporary attribute, like I described:

pchar.ship.keepshiptype = pchar.ship.type;
pchar.ship.type = SHIP_NOTUSED;

I don't think you will need to copy anything and the screens/loading ship processes will just skip what it thinks is an invalid ship. If that works, would save code, time and effort.


I do not want to break the rules, but I hope you saw two emails that I sent you a few days ago.
 
Back
Top