• 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 Fire-ship how to make it?

Myth

Freebooter
Good afternoon. Guys tell me how to make a ship become a fire-ship and explode next to a certain ship? How do I enforce this in the code?
 
In battle_interface\BattleInterface.c, there is a handler for the Brander action:

case "BI_Brander":
//ActivateCharacterPerk(pchar,"Brander"); - многоразовый приказ
Ship_SetTaskBrander(SECONDARY_TASK, charIdx, targetNum);
break;

This calls the function Ship_SetTaskBrander with the character index in command of the ship to explode, and the character index commanding the target ship.

Ship_SetTaskBrander function resides in SEA_AI\AIShip.c, and sends a message to the engine, which takes care of the AI to sail the ship toward the target.

void Ship_SetTaskBrander(int iTaskPriority, int iCharacterIndex, int iCharacterIndexBranderTo)
{
ref rCharacter = GetCharacter(iCharacterIndex);
rCharacter.SeaAI.Task = AITASK_BRANDER;
rCharacter.SeaAI.Task.Target = iCharacterIndexBranderTo;
SendMessage(&AISea, "lllaa", AI_MESSAGE_SHIP_SET_TASK, AITASK_BRANDER, iTaskPriority, &Characters[iCharacterIndex], &Characters[iCharacterIndexBranderTo]);
}

AIShip.c also contains the function Ship_CheckSituation()

This checks the task, and distance, and posts an event to explode the ship upon a certain proximity:

switch (sti(rCharacter.SeaAI.Task))
{
case AITASK_BRANDER:
ref rCharacter2Brander = GetCharacter(sti(rCharacter.SeaAI.Task.Target));
ref rBaseShip = GetRealShip(sti(rCharacter2Brander.Ship.Type));
float fBranderDistance = 30.0 + (7.0 - stf(rBaseShip.Class)) * 40.0;
float fDistance = Ship_GetDistance2D(rCharacter, rCharacter2Brander);
if (fBranderDistance > fDistance)
{
// 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), "ialsfl", rShipObject, rCharacter, i, "ship_onfire", 30.0, -1);
}
PostEvent(SHIP_BRANDER_DETONATE, 10000, "l", sti(rCharacter.index));

Ship_SetTaskNone(SECONDARY_TASK, sti(rCharacter.index));
}
//Trace("test1 rCharacter2Brander = " + rCharacter2Brander.index);
break;
}
}

That SHIP_BRANDER_DETONATE event is handled in AIShip.c, in the Ship_BranderDetonate() function.
 
In battle_interface\BattleInterface.c, there is a handler for the Brander action:

case "BI_Brander":
//ActivateCharacterPerk(pchar,"Brander"); - многоразовый приказ
Ship_SetTaskBrander(SECONDARY_TASK, charIdx, targetNum);
break;

This calls the function Ship_SetTaskBrander with the character index in command of the ship to explode, and the character index commanding the target ship.

Ship_SetTaskBrander function resides in SEA_AI\AIShip.c, and sends a message to the engine, which takes care of the AI to sail the ship toward the target.

void Ship_SetTaskBrander(int iTaskPriority, int iCharacterIndex, int iCharacterIndexBranderTo)
{
ref rCharacter = GetCharacter(iCharacterIndex);
rCharacter.SeaAI.Task = AITASK_BRANDER;
rCharacter.SeaAI.Task.Target = iCharacterIndexBranderTo;
SendMessage(&AISea, "lllaa", AI_MESSAGE_SHIP_SET_TASK, AITASK_BRANDER, iTaskPriority, &Characters[iCharacterIndex], &Characters[iCharacterIndexBranderTo]);
}

AIShip.c also contains the function Ship_CheckSituation()

This checks the task, and distance, and posts an event to explode the ship upon a certain proximity:

switch (sti(rCharacter.SeaAI.Task))
{
case AITASK_BRANDER:
ref rCharacter2Brander = GetCharacter(sti(rCharacter.SeaAI.Task.Target));
ref rBaseShip = GetRealShip(sti(rCharacter2Brander.Ship.Type));
float fBranderDistance = 30.0 + (7.0 - stf(rBaseShip.Class)) * 40.0;
float fDistance = Ship_GetDistance2D(rCharacter, rCharacter2Brander);
if (fBranderDistance > fDistance)
{
// 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), "ialsfl", rShipObject, rCharacter, i, "ship_onfire", 30.0, -1);
}
PostEvent(SHIP_BRANDER_DETONATE, 10000, "l", sti(rCharacter.index));

Ship_SetTaskNone(SECONDARY_TASK, sti(rCharacter.index));
}
//Trace("test1 rCharacter2Brander = " + rCharacter2Brander.index);
break;
}
}

That SHIP_BRANDER_DETONATE event is handled in AIShip.c, in the Ship_BranderDetonate() function.

Good, i will try it.
 
Back
Top