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

Mod Release Age of Pirates: Caribbean Tales - Historical Immersion Supermod

Need some C code debugging for quest, the quest delay is 1/2 working. It delays the quest from engaging at the same time as the story_line, but when I go to rank 2, It won't start the video that starts the rest of the code. The game still works, but I need some input Levis.

Code:
void DutchmanQuestComplete(string sQuestName, string qname)
{
    ref chr;

    //trace("--- QUEST " + sQuestName + " CHECKED ---");
    int iChar = -1;
    int iShipChar = -1;
    string sVideoFile = "";

    switch(sQuestName)
    {
        case "begin_dutchman":
            DoQuestCheckDelay("rank2 check", 1.0);
          
            case "rank2 check"
            if (sti(pchar.rank) >= 2)
            {
                PauseAllSounds();
                SendMessage(&sound,"lfff", MSG_SOUND_SET_MASTER_VOLUME, 0.0, 0.0, 0.0);
                sVideoFile = "IntroDutch"
                StartPostVideoAndQuest(sVideoFile,0,"begin_dutchman_continue");
            }
            else
            {
                CheckDutchmanRank(qname, 2);
            }
        break;
    }
    {  
        case "begin_dutchman_continue";
            ResumeAllSounds();
            SendMessage(&sound,"lfff", MSG_SOUND_SET_MASTER_VOLUME, 0.5, 0.5, 0.5);
          
            //login Davy Jones
            iChar = GenerateCharacter(PIRATE, WITH_SHIP, "officer", MAN, 1, BOSS);
            characters[iChar].id = "Davy Jones";
            characters[iChar].name = "Davy";
            characters[iChar].lastname = "Jones";
            characters[iChar].model = "pirate_5";
            characters[iChar].Ship.Type = GenerateShip(SHIP_DUTCHMAN, 1);
            characters[iChar].ship.name = "The Flying Dutchman";
            characters[iChar].skill.Fencing = 10;
            characters[iChar].skill.Gun = 10;
            GiveItem2Character(CharacterFromID("Davy Jones"), "blade15");
            EquipCharacterByItem(CharacterFromID("Davy Jones"), "blade15");
            characters[iChar].cannotsurrender = 1;  
          
            DoQuestCheckDelay("rank5 check", 1.0);
        break;
      
            case "rank5 check":
                if (sti(pchar.rank) >= 5)
                {
                    GiveItem2Character(pchar, "pslip");
                    DoQuestCheckDelay(rank5 passed)
                }
                else
                {
                    CheckStoryLineRank(qname, 5);
                }
            break;
              
                case "rank5 passed"
                    //generate encounter
                    iChar = GetCharacterIndex("Davy Jones");
                    DeleteAttribute(&characters[iChar], "seaai");
                    Group_CreateGroup("dutchman");
                    Group_AddCharacter("dutchman", "Davy Jones");
                    Group_SetGroupCommander("dutchman", "Davy Jones");
                    Group_SetAddress("dutchman", "grenada", "quest_ships", "quest_ship_1");
                    SetCharacterRelationBoth(nMainCharacterIndex, iChar, RELATION_ENEMY);
                    Group_SetTaskAttack("dutchman", PLAYER_GROUP);
                    Group_LockTask("dutchman");
                    UpdateRelations();
                break;

                if trace("!!! sea spawned") = true;
                    DoQuestCheckDelay(ship dead, 1.0);
                break;

            case "ship dead":
                GiveItem2Character(pchar, "blade19");
                GiveItem2Character(pchar, "gun6");
                TakeItemFromCharacter(pchar, "pslip");
                DoQuestCheckDelay("quest_complete")
            break;
      
        case "quest_complete"
            PauseAllSounds();
            SendMessage(&sound,"lfff", MSG_SOUND_SET_MASTER_VOLUME, 0.0, 0.0, 0.0);
            sVideoFile = "OutroDutch"
            StartPostVideo(sVideoFile,1);
            ResumeAllSounds();
            SendMessage(&sound,"lfff", MSG_SOUND_SET_MASTER_VOLUME, 0.5, 0.5, 0.5);
        break;
    }
}
 
Can you Show the code for DoQuestCheckDelay or check what that does. Where does it look for rank2 check?
 
Can you Show the code for DoQuestCheckDelay or check what that does. Where does it look for rank2 check?
DoQuestCheckDelay puts an infinite delay timer on the code until the check passes in which the code init's the next case. For example if it checks for the rank you are at, it will check pchar until the rank = the value. When that is done it will go to the first instance and will do what code is in there and after identification, go to the next case. If it is not equal to or greater than the value, it loops back around to the main code where it checks pchar rank. Here is the definition for it in quests.c. Hope it helps if the explanation doesn't make sense!

Code:
void QuestsInit()
{
    aref postEvDelay, arTmp;
    makearef(postEvDelay,pchar.PostEventQuest.questDelay);
    int q = GetAttributesNum(postEvDelay);
    for(int i=0; i<q; i++)
    {
        arTmp = GetAttributeN(postEvDelay,i);
        DoQuestCheckDelay(arTmp.qname, stf(arTmp.delay));
    }
 
DoQuestCheckDelay puts an infinite delay timer on the code until the check passes in which the code init's the next case. For example if it checks for the rank you are at, it will check pchar until the rank = the value. When that is done it will go to the first instance and will do what code is in there and after identification, go to the next case. If it is not equal to or greater than the value, it loops back around to the main code where it checks pchar rank. Here is the definition for it in quests.c. Hope it helps if the explanation doesn't make sense!

Code:
void QuestsInit()
{
aref postEvDelay, arTmp;
makearef(postEvDelay,pchar.PostEventQuest.questDelay);
int q = GetAttributesNum(postEvDelay);
for(int i=0; i<q; i++)
{
arTmp = GetAttributeN(postEvDelay,i);
DoQuestCheckDelay(arTmp.qname, stf(arTmp.delay));
}
 
Levis do you want me to pack the "test game" up and send it to you so we can troubleshoot the quest problem better? I recently completed a balance issue on turn rates for the schooner and the new capital ships that I introduced in Mod v3.5. I also changed the Dutchman quest to something better in terms of fixing code errors, but still it doesn't work the way its supposed to. I await your reply.
 
New information about quest:
COMPILE ERROR - file: quests\dutchman.c; line: 26
invalid case syntax
 
Can you show the relevant code? If necessary, attach the entire file.
 
You have a whole bunch of brackets there that don't belong. Try attached.
 

Attachments

  • dutchman_new.zip
    1 KB · Views: 160
You have a whole bunch of brackets there that don't belong. Try attached.
I updated a few quotation marks that belonged to init a "case", but the error this time is a compile error on line 15 being "invalid case syntax".

Also would the "goto" command also work for switching cases?

for example:
goto (case, "begin_dutchman_continue")

Updated File:
 

Attachments

  • dutchman.zip
    1 KB · Views: 175
There's a break missing. Should be:
Code:
  switch(sQuestName)
   {
     case "begin_dutchman":
       DoQuestCheckDelay("rank2 check", 1.0);
     break;
       
     case "rank2 check"
       if (sti(pchar.rank) >= 2)
       {
         PostVideoAndQuest("IntroDutch",1.0,"begin_dutchman_continue");
       }
       else
       {
         CheckDutchmanRank(qname, 2);
       }
     break;

Also would the "goto" command also work for switching cases?

for example:
goto (case, "begin_dutchman_continue")
Don't think so. Why would you want to do that? o_O
 
There's a break missing. Should be:
Code:
  switch(sQuestName)
   {
     case "begin_dutchman":
       DoQuestCheckDelay("rank2 check", 1.0);
     break;
    
     case "rank2 check"
       if (sti(pchar.rank) >= 2)
       {
         PostVideoAndQuest("IntroDutch",1.0,"begin_dutchman_continue");
       }
       else
       {
         CheckDutchmanRank(qname, 2);
       }
     break;
I'm still having trouble with invalid case even though I added the break. line 16 is still the problem according to the error file.

I based the code off of the main storyline. There is enough code in that file alone to make a similar quest from it. Do you have the time to analyze the code from the story line and properly implement it into a quest file under the name "dutchman". I would also be willing to provide a beta test game for you as long as it's deleted when this business is done. If you do not wish to use my personal test game, then perhaps I'll send you the entire quest folder. The quests.c file provides key quest definitions such as "DoQuestCheckDelay". I have plenty of time, but I don't know enough about quest coding to make a quest that overlaps with the storyline (as long as the videos don't overlap). My plan for the quest is outlined in the file I gave you, however I will list the events by the code in chronological order:

1. Check if player is rank 2 (if yes pause game and post video "IntoDutch" then proceed to next case after resuming game)
2. Define new "IChar" (Davy Jones) then proceed to next case
3. Check if player is rank 5 (if yes give player item "pslip" and proceed to next case)
4. Generate ship "Dutchman" named "The Flying Dutchman" patrolling with AI around island "Grenada" (proceed to next case)
5. Check for two outcomes (Davy Jones killed in aboardage on ship or Ship sunk by cannon fire)
6. Init relevant outcome case (Davy jones killed= take away "pslip" and give unique sword and gun else backtrack to generate ship case) then proceed to next relevent case
7. Post video "OutroDutch" and end quest
 
case "rank2 check"
should read
case "rank2 check":

Perhaps that is it?
 
case "rank2 check"
should read
case "rank2 check":

Perhaps that is it?
Your right! That code form is identical to what is found in story_line.c. I will implement it immediately on all cases(one had a ";" rofl). I will edit this post once a test is conducted.

EDIT: Almost worked! debugging code.
EDIT2: Roadblock. New code using quests.c as a template failed (quest ship captured). Looks like the code before this instance is working.

DATA:
"error.txt":
Code:
COMPILE ERROR - file: quests\dutchman.c; line: 76
missed '('


Line 76 from dutchman.c including dependencies:
Code:
        case "capture":
            if QuestShipCaptured("quest_ship_1", 4);
            {
                DoQuestCheckDelay("reward", 5);
            }
            else
            {
                DoQuestCheckDelay("init dutchman", 3);
            }
        break;


event_handler definition in "quests.c":
Code:
void QuestShipCaptured()
{
    int idx = GetEventData();
    if(idx==-1) return;
    ref chref = GetCharacter(idx);
    chref.ShipCapture = "1";
    QuestsCheck();
}

Help!

EDIT3:
Changed quest to the following and it starts up. Starting a new profile to test the quest.
Code:
case "capture":
            //start check: kill ships
            pchar.quest.Kill_ships.win_condition.l1 = "npc_death";
            pchar.quest.Kill_ships.win_condition.l1.character = iChar;
            pchar.quest.Kill_ships.win_condition = "reward";

            trace("!!! sea spawned");
        break;

EDIT4:
Had to debug again. Going to test the quest again later.
 
Last edited:
Good luck. :onya

I have had it :ko. Is there a way to just make it patrol Grenada until it is sunk or roaming around the islands at random? That might be a bit simpler than quests. I have done all that I can to make a second quest in parallel to the story_line, but to no avail. I am officially giving up on the dutchman quest, however if anyone wants to develop this quest further, I will have the resource files contained as a non argument for those that might add to what I have.
 
Finalized everything except for the quest as a release for 4.0. Unless you have a way to make the unique ship "the flying dutchman" patrol grenada and after being sunk to get two items, I think its time to give our players the new release.
 
The only ones who can help you are Pieter, who is away at sea, and Levis who is away doing exams and life.
 
The only ones who can help you are Pieter, who is away at sea, and Levis who is away doing exams and life.

Oh, so that's why Levis hasn't been returning my messages lately... I understand! Although under my schools rules I'm exempt from exams. A good thing too because I don't test well, even when I study harder than usual:facepalm. The "clicker technology" otherwise known as "e-Instruction CPS: classroom performance system" is very inaccurate and for every question it has a 50% chance that it will mark it wrong; contrary to the value or letter the teacher put in:mad:. At least Scan-trons are better lol;)!
 
Last edited:
Here is some relevant code from PotC that might be useful.
It might be slightly different in CoAS, so you have to see if you can find anything similar. But it'll be close to this anyway.
Code:
       Group_CreateGroup("FlyingDutchman");
       Group_AddCharacter("FlyingDutchman", "Davy Jones");
       Group_SetGroupCommander("FlyingDutchman", "Davy Jones");
       Group_SetPursuitGroup("FlyingDutchman", PLAYER_GROUP);
       Group_SetTaskAttack("FlyingDutchman", PLAYER_GROUP);
       Group_SetAddress("FlyingDutchman", "Cayman", "Quest_ships", "Quest_ship_12");
       Group_LockTask("FlyingDutchman");

       Pchar.quest.Story_Sink_Dutchman1.win_condition.l1 = "Ship_HP";
       Pchar.quest.Story_Sink_Dutchman1.win_condition.l1.character = "Davy Jones";
       Pchar.quest.Story_Sink_Dutchman1.win_condition.l1.quantity = 1;
       Pchar.quest.Story_Sink_Dutchman1.win_condition.l1.operation = "<";
       Pchar.quest.Story_Sink_Dutchman1.win_condition = "Story_Sink_Dutchman";
       Pchar.quest.Story_Sink_Dutchman2.win_condition.l1 = "NPC_Death";
       Pchar.quest.Story_Sink_Dutchman2.win_condition.l1.character = "Davy Jones";
       Pchar.quest.Story_Sink_Dutchman2.win_condition = "Story_Sink_Dutchman";
And:
Code:
     case "Story_Sink_Dutchman":
       GiveItem2Character(PChar, "whatyouwant");
     break;
 
Back
Top