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

Coding Help!

Estharos

Landlubber
Storm Modder
I'm working on a project for COAS and I need help on how to create some code.

1. I want the game to check if the player got at least a certain amount of goods.

ei: I want the game to make sure the player got at least 300 grape shot, 300 chain shot, 300 explosif shot, 600 gunpowder, 10 sailcloth, 20 planks, 200 food, 100 weapons and 200 medecines. Before leaving the store.

2. I want the game to check if the player got a minimum crew.

ei: I want the game to check if the player got at least the min crew on bord before leaving the tavern.

There's many more to come but let's start with those 2.

Thanks.

Cheers, :cheers
 
Try these functions:

int GetCargoGoods(ref _refCharacter,int _Goods)
int GetCrewQuantity(ref _refCharacter)

They're PotC functions, but CoAS probably has them too.
You can use them in if-statements like this:
Code:
if(GetCargoGoods(pchar,GOOD_GRAPES) > 300 && GetCargoGoods(pchar,GOOD_KNIPPELS) > 300 && GetCrewQuantity(pchar) > 100)
Obviously you can expand this.
 
If I want the game to check the player if he got minimum crew on board. How I would do that?

Cheers, :cheers
 
You mean THE minimum crew as defined in ships_init.c? Try:
Code:
if(GetCrewQuantity(pchar) >= GetMinCrewQuantity(pchar))
 
I try the code and it ain't working. I'm trying to make it work in a dialog. When I exit the store the NPC walk to me and engage the dialog but there's no dialog in the dialog box, it's blank. Here is the code I'm using:

Code:
case "Node_28":
if(GetCargoGoods(Pchar, GOOD_GRAPES) >= 300 && GetCargoGoods(Pchar, GOOD_KNIPPELS) >= 300 && GetCargoGoods(Pchar, GOOD_BOMBS) >= 300 && GetCargoGoods(Pchar, GOOD_POWDER) >= 600 && GetCargoGoods(Pchar, GOOD_FOOD) >= 200 && GetCargoGoods(Pchar, GOOD_MEDICAMENT) >= 90 && GetCargoGoods(Pchar, GOOD_WEAPON) >= 100)
{
Dialog.Text = DLG_TEXT_UW[55];
Link.l1     = DLG_TEXT_UW[54];
Link.l1.go  = "Exit";

AddQuestRecord("Ship", "4");
}
else
{
Dialog.Text = DLG_TEXT_UW[56];
Link.l1     = DLG_TEXT_UW[54];
Link.l1.go  = "Exit";
}

CloseQuestHeader("Ship");
break;

Cheers, :cheers
 
Have you enabled error logging? Anything in error.log about this one?
(I think CoAS has error logging the same as PotC)
 
That's the thing nothing show up in the error log. :shrug So I'm assuming that the code is ok, but why it don't work I don't know. :modding

Cheers, :cheers
 
Is the correct .h file present? Does it work if you DON'T add that whole if-statement?
Would be good to know if it was a dialog code problem or one related to that check.
 
n/m Pieter, I found my error. I'm using this character like Malcolm on POTC. It help the player and you can recruit him.

But once you recruite him, he use the dialog of the Enc_Officer_dialog.c. But I'm also using him to help the player so I must redirect the dialog filename to Malcolm.c then once he finish is task(helping the player) it switch back to the Enc_Officer_dialog.c. I didn't notice that Malcolm was recruited so it was looking for Text_28 in Enc_Officer_dialog.c file instead of the Malcolm.c file.

Sorry for the trouble.

Cheers, :cheers
 
Is it possible for an Npchar to run away from the Pchar with is ship at a certain number of HP?

I would like my Npchar to run away once is hull of his ship reach 50%(or a certain number of Hull HP), also I would like to restore his sails to max HP, to help him run away.

Can anyone help?

Cheers, :cheers
 
Can anyone help me with this?

Is it possible for an Npchar to run away from the Pchar with is ship at a certain number of HP?

I would like my Npchar to run away once is hull of his ship reach 50%(or a certain number of Hull HP), also I would like to restore his sails to max HP, to help him run away.

Can anyone help?

Cheers, :cheers

Also, I manage to spawn a few pirates on a shore of an Island but I would like that those Pirates turn into squeleton at night, how can I do that?

I'm using this code to spawn those pirates;

Code:
for (i=1; i<=7; i++)
{
sld = GetCharacter(NPC_GenerateCharacter("Bandit2"+i, "Pirate_"+(rand(9)+1), "man", "man", sti(Pchar.Rank), PIRATE, -1, false));
ChangeCharacterAddressGroup(sld, "Caiman_Jungle_01", "goto",  "goto"+i);
FantomMakeCoolFighter(sld, sti(Pchar.Rank) + MOD_SKILL_ENEMY_RATE + 15, 90, 90, LinkRandPhrase("blade33", "blade26", "blade23"), "", 50);
LAi_SetWarriorType(sld);
LAi_warrior_SetStay(sld, true);
LAi_group_MoveCharacter(sld, LAI_GROUP_MONSTERS);
}

Cheers, :cheers
 
Remind me when I get back home again and I'll see if I can figure something out.

Do you want them to change during nighttime or will it just do to generate skeletons when their generation takes place during nighttime?
 
Actually I don't understand what you mean. But basically what I want it's the pirate to change into squeleton when the sun set down.

Cheers, :cheers
 
Is there any time progression going on? If so, is it continuous or on location loading?
It's easy enough to take those characters and change their models when it's night-time.
The main issue would be at which point to trigger that code.

This line should be useful for checking if it's night:
Code:
if (Whr_IsNight())
 
Found another way, it was quite simple. :facepalm I'll let you see buy yourself. :cheeky

Code:
for (i=1; i<=4; i++)
{
sld = GetCharacter(NPC_GenerateCharacter("Skeleton4"+i, "Skel"+(rand(3)+1), "skeleton", "man", sti(Pchar.Rank), PIRATE, -1, false));
ChangeCharacterAddressGroup(sld, "Caiman_Grot", "monsters",  "monster"+i);
FantomMakeCoolFighter(sld, sti(Pchar.Rank) + MOD_SKILL_ENEMY_RATE + 15, 90, 90, LinkRandPhrase("blade33", "blade26", "blade23"), "", 50);
LAi_SetLoginTime(sld, 22.0, 5.99);
LAi_SetWarriorType(sld);
LAi_warrior_SetStay(sld, true);
LAi_group_MoveCharacter(sld, LAI_GROUP_MONSTERS);

sld = GetCharacter(NPC_GenerateCharacter("Bandit4"+i, "Pirate_"+(rand(9)+1), "man", "man", sti(Pchar.Rank), PIRATE, -1, false));
ChangeCharacterAddressGroup(sld, "Caiman_Grot", "monsters",  "monster"+i);
FantomMakeCoolFighter(sld, sti(Pchar.Rank) + MOD_SKILL_ENEMY_RATE + 15, 90, 90, LinkRandPhrase("blade33", "blade26", "blade23"), "", 50);
LAi_SetLoginTime(sld, 6.0, 21.99);
LAi_SetWarriorType(sld);
LAi_warrior_SetStay(sld, true);
LAi_group_MoveCharacter(sld, LAI_GROUP_MONSTERS);
}

Cheers, :cheers
 
Back
Top