1. Dismiss Notice
  2. GOG.com logo

    Thanks to YOUR votes, GOG.com now sells:
    - Sea Dogs - Sea Dogs: Caribbean Tales
    - Sea Dogs: City of Abandoned Ships

    Vote now to add Pirates of the Caribbean to the list!

    Dismiss Notice
  3. Under the Crossbones Podcast

    A Pirate Podcast with Interviews
    Music, Comedy and all things Pirate!

    - Episode Guide - About - Subscribe -
    - Twitter - Facebook - iTunes - Android -
    - Youtube - Fill the Coffers -

    Dismiss Notice
  4. New Horizons logo

    Quick links for PotC: New Horizons
    - Download latest version
    - Wiki - FAQ - Report bugs here
    - ModDB profile

  5. GOF logo

    Quick links for AoP2: Gentlemen of Fortune 2
    - Downloads and info
    - Historical Immersion Supermod
    - ModDB Profile

Dismiss Notice
New to the forum?
Please take a moment to read our Welcome Message and Forum Rules.

Need Help Fire-ship how to make it?

Discussion in 'Sea Dogs: City of Abandoned Ships' started by Myth, Aug 19, 2017.

  1. Myth

    Myth Master Mariner

    Joined:
    Mar 25, 2014
    Messages:
    203
    Gender:
    Male
    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?
     
  2. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    221
    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.
     
    Myth likes this.
  3. Myth

    Myth Master Mariner

    Joined:
    Mar 25, 2014
    Messages:
    203
    Gender:
    Male
    Good, i will try it.
     

Share This Page