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

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

By the way Pieter, do you have any ideas. How I could do this.

Cheers, :cheers
 
I do have some vague ideas, but no time to put them into a specific post.
Can you wait 2.5 week? I'll be home again then and should have time once more. :facepalm
 
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

By the way Pieter, do you have any ideas. How I could do this.

Cheers, :cheers

Bump for Pieter.

Cheers, :cheers
 
Code:
			Pchar.quest.EstharosRunAway.win_condition.l1 = "Ship_HP";
Pchar.quest.EstharosRunAway.win_condition.l1.character = "Estharos";
Pchar.quest.EstharosRunAway.win_condition.l1.quantity = 0.5*GetCharacterShipHP(characterFromID("Estharos"));
Pchar.quest.EstharosRunAway.win_condition.l1.operation = "<";
Pchar.quest.EstharosRunAway.win_condition = "EstharosRunAway";
I think the above code should trigger quest case "EstharosRunAway" when Estharos' ship HP gets lower than 50% of his ship's max HP.
Code:
		case "EstharosRunAway":
Group_CreateGroup("Estharos");
Group_AddCharacter("Estharos", "Estharos");
Group_SetGroupCommander("Estharos", "Estharos");
Group_SetPursuitGroup("Estharos", PLAYER_GROUP);
Group_LockTask("Estharos");
Group_SetTaskRunAway("Estharos");
Characters[getCharacterIndex("Estharos")].ship.sp = GetCharacterShipSP(characterFromID("Estharos"));
break;
Then the above quest case should make Estharos' ship run away, while the final line before the break; sets his sail points back to 100%.

I hope the above works. :doff
 
Code:
			Pchar.quest.EstharosRunAway.win_condition.l1 = "Ship_HP";
Pchar.quest.EstharosRunAway.win_condition.l1.character = "Estharos";
Pchar.quest.EstharosRunAway.win_condition.l1.quantity = 0.5*GetCharacterShipHP(characterFromID("Estharos"));
Pchar.quest.EstharosRunAway.win_condition.l1.operation = "<";
Pchar.quest.EstharosRunAway.win_condition = "EstharosRunAway";
I think the above code should trigger quest case "EstharosRunAway" when Estharos' ship HP gets lower than 50% of his ship's max HP.
Code:
		case "EstharosRunAway":
Group_CreateGroup("Estharos");
Group_AddCharacter("Estharos", "Estharos");
Group_SetGroupCommander("Estharos", "Estharos");
Group_SetPursuitGroup("Estharos", PLAYER_GROUP);
Group_LockTask("Estharos");
Group_SetTaskRunAway("Estharos");
Characters[getCharacterIndex("Estharos")].ship.sp = GetCharacterShipSP(characterFromID("Estharos"));
break;
Then the above quest case should make Estharos' ship run away, while the final line before the break; sets his sail points back to 100%.

I hope the above works. :doff

It ain't working Pieter. I'm trying to make it work but no succes so far.

Cheers, :cheers
 
Is anything happening at all? Put some Log_SetStringToLog/Trace lines in there to check what happens and what doesn't.
Then try splitting the code into pieces and seeing which ones work and which ones don't.
For example, replace 0.5*GetCharacterShipHP(characterFromID("Estharos")) with a straight number
or use the console to execute the code from case "EstharosRunAway" to check if that has the desired results.
 
Is anything happening at all? Put some Log_SetStringToLog/Trace lines in there to check what happens and what doesn't.
Then try splitting the code into pieces and seeing which ones work and which ones don't.
For example, replace 0.5*GetCharacterShipHP(characterFromID("Estharos")) with a straight number
or use the console to execute the code from case "EstharosRunAway" to check if that has the desired results.

Can you explain more Pieter?

I try splitting the coding as you said and nothing is working except the Group_SetTaskRunAway("Estharos");, then again I'm not really happy with what I saw with this command. Once the NPC receive the orther to runaway it those in the direction he is already heading, meaning if he face the wind, I can stand there on his portside and shoot him at will. If she were fleeing correctly perhaps I could try to use this code but it's meaningless to do so right now. IA are a bit to stupid to created this scenario me think. On top of that the encounter is close to the Island Shore, so if the NPC got the wind behind him to help him escape, he will hit the shore somewhere and get stuck or he gonna hit the shore until it sunk.

And for some reason the first coding doesn't seem to work at all:

Code:
Pchar.quest.EstharosRunAway.win_condition.l1 = "Ship_HP"; 
Pchar.quest.EstharosRunAway.win_condition.l1.character = "Estharos"; 
Pchar.quest.EstharosRunAway.win_condition.l1.quantity = 0.5*GetCharacterShipHP(characterFromID("Estharos")); 
Pchar.quest.EstharosRunAway.win_condition.l1.operation = "<"; 
Pchar.quest.EstharosRunAway.win_condition = "EstharosRunAway";

I look everywhere to see if I could see the Pchar.quest.EstharosRunAway.win_condition.l1 = "Ship_HP"; and can't seem to see it anywhere, so I'm not sure if the code is legit but then again I got no error in the error.log saying that the code is wrong. It's like the game accept the code but nothing happen. Same thing for Pchar.quest.EstharosRunAway.win_condition.l1.quantity = 0.5*GetCharacterShipHP(characterFromID("Estharos")); got no error in the log but nothing happen once the NPC ship reach less then 50% of his hull. I try with a legit code that I found in the game that's do the same thing with the same result. So I wonder if the win_condition "Ship_HP" work correctly.

Cheers, :cheers
 
The original PotC game had win_condition.l1 = "Ship_HP"; code, but I don't know if CoAS supports that too. :?
 
You can also put it in an if-statement and put it in a code section that executed regularly at sea.
That'd become a bit more complex though...
 
Is it possible to reload the playing character, from town to his cabin? I want my PChar to be teleport from the shipyard to his cabin, is it possible?

Cheers, :cheers
 
I think this should work:
Code:
DoQuestReloadToLocation("My_Cabin", "reload", "reload1" ,"");
However, I'm not 100% sure of the CoAS cabin location IDs. Check PROGRAM\Locations\init\boarding.c for more possibilities.
 
There's multiple cabin for the player, it's differ from the class of ship you got. I will need to do a check to see witch cabin the player got then reload the playing character to that cabin. I got the frigate and it's using the my_cabin location as a cabin. I try to teleport the playing character there and it work but the problem is when I want to go back to sea, I get a black screen.

Now how can I do the check so I can reload the playing character at the right cabin?
and
How can I avoid the black screen after I try to go back to sea?

Also, I manage to create a quest at random, any shipyard you enter, the npchar appear there so they can talk to the player for the quest. I would like to be able to teleport the pchar back to the pier next to the row boat in town but the problem is that I don't know where the player will trigger the quest. Is it possible to do a check to see in witch town the pchar is, so it can be teleport at the pier?

Cheers, :cheers
 
If it can help you I did do that, reload from land to(unfortunely) worldmap. If you reload char to cabin you can walk through the ship but it seems AI don't remember worldmap coordonates

/////////////Philippe retour à bord//////////

case "Retour à bord":
////==>Philippe ajout pour bonne location retour à terre
DelEventHandler("FaderEvent_StartFade", "Land_MapStartFade");
string deckID = pchar.location;
ref loc = &locations[FindLocation(deckID)];
UnloadLocation(loc);
// EmptyAllFantomShips();//<== Philippe bloqué pour
// wdmEmptyAllDeadQuestEncounter();// vol de navire
////<===========

int iLoc = FindLocation(deckID);//<==========meilleure location


if(UnloadLocation(&Locations[iLoc]) == true)
{
if(CheckAttribute(WorldMap, "old"))
{
pchar.ship.pos.x = WorldMap.old.x;
pchar.ship.Ang.y = WorldMap.old.y;
pchar.ship.pos.z = WorldMap.old.z;
DeleteAttribute(WorldMap, "old");
}
Land_MapLoad();
pchar.location = FindIsland("");//"Nevos";
}

Locations[iLoc].boarding = "true";


DialogExit();
break;
 
You want the reload to the cabin while at sea? I think just calling this function might work:
Code:
Sea_CabinStartNow();
 
Hi Pieter, I tryed but it doesn't work, I only get a black screen. For now the only way is to go to worldmap. I'll see that tomorrow.
 
Of course I don't play CoAS so didn't test that. You did call that function while at sea, right? Otherwise you would get issues.
In any case, it SHOULD be possible somehow; it works fine in the PotC Build Mod in similar cases. :shrug
 
I called the fonction to go back from jungle to sea, but I don't find the way to do that, only go back from anywhere at land to worldmap. I don't know how to code it to go back at sea. If you go back in your cabin AI doesn't get ship coordonates. I'll take an eye in PotC Build files, try to find something. :facepalm
 
Back
Top