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.

Solved Dutchman Quest Revisions (Test Game Download Included)

Discussion in 'Sea Dogs: Caribbean Tales' started by Modder01, Oct 11, 2017.

  1. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    Trace statement for companion:
    Code:
               if(sti(iCompanionIndex)==0) trace("Calling Companion GetCharacter with a zero " + iCompanionIndex);
    
    New Errors:
     

    Attached Files:

  2. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Well, it's none of those...I think I might have found it for you. TakeNItems calls GetCharacter, and TakeNItems is used in the Item2Char/Equip functions. I see that they don't take char index values, but a char reference, so change them in the SpawnDutchman function:

    GiveItem2Character(qChar, "blade19");
    EquipCharacterByItem(qChar, "blade19");
    GiveItem2Character(qChar, "gun6");
    EquipCharacterByItem(qChar, "gun6");

    to

    GiveItem2Character(&characters[qChar], "blade19");
    EquipCharacterByItem(&characters[qChar], "blade19");
    GiveItem2Character(&characters[qChar], "gun6");
    EquipCharacterByItem(&characters[qChar], "gun6");
     
  3. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    New Errors (The change attributes function still is random - in short I can barely make heads or tails of it in it's current state):
     

    Attached Files:

  4. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Looking at some similar code for NPC_Death, it looks like the .character is supposed to be an index, not an ID name. That might explain why so many index 0 as the quest check function is called often. Change this part:

    Code:
    case "spawn_dutchman":
           //login Davy Jones
    
           //generate encounter
                int qChar = SpawnDutchman();
    
                Pchar.quest.dutchman_KillJones.win_condition.l1 = "NPC_Death";
                Pchar.quest.dutchman_KillJones.win_condition.l1.character = qChar;
                PChar.quest.dutchman_KillJones.win_condition = "dutchman_KillJones";
           break;
    
           case "dutchman_KillJones":
               //Kill Jones by function
               //Play a sound here "Damn you jack sparrow" (sound sample filtered from original movie)
               chr = GetCharacter(GetCharacterIndex("Davy Jones"));
               if( CheckAttribute(chr,"Killer.status") && sti(chr.Killer.status)!=KILL_BY_ABORDAGE )
               {
                    trace("Flying Dutchman Killed by Cannonfire");
                    SetQuestHeader("Dutchman");
                    AddQuestRecord("Dutchman", "2_failed");
                    LAi_group_Delete("FlyingDutchman"); //Sea group
                    Pchar.quest.dutchman_Respawn.win_condition.l1 = "ExitFromLocation";
                    Pchar.quest.dutchman_Respawn.win_condition.l1.location = "Grenada";
                    PChar.quest.dutchman_Respawn.win_condition = "spawn_dutchman";
                }
                else
                {
                   SetQuestHeader("Dutchman");
                   AddQuestRecord("Dutchman", "3_captured");
                   trace("*** Davy Jones Killed by Abordage");
                   DoQuestCheckDelay("dutchman_dead", 2.0);
    
                }
           break;
     
    Last edited: Oct 17, 2017
  5. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    New Errors (That function didn't update the logbook, I am almost convinced that the spawn code I put in is responsible.The models are still random and the character still doesn't get assigned the blade and gun on spawn...) At least there's no Error log this time:
     

    Attached Files:

  6. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    The good news is that it looks like changing .character = qChar fixed the index zero problem and that is resolved. I also see that the "Special Character" trace shows output, so we know that the boarding function finds the "copyme" attribute and calls ChangeAttributesFromCharacter. Perhaps the copy function needs some work. First, see what comes back by tracing the _SetBoardingCaptain. Put these statements near the end of that function to see if the correct attributes show as correctly copied:

    trace("Standin capt .model = " + chr.model);
    trace("Standin capt .equip.gun = " + chr.equip.gun);
    trace("Standin capt .equip.blade = " + chr.equip.blade);
    trace("Standin capt .location = " + chr.location);
     
  7. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    From all the trace statements I am getting Invalid Expression and Invalid Syntax.....

    Nevermind, I added a trace for the CopyChref at the end of the change attributes function(I am starting to think that the function should return a ref) and in the set Boarding captain function I added the original trace functions. Testing now!
     
    Last edited: Oct 19, 2017
  8. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    Ok Some new errors to pick your brain at.... Apparently the change attributes function itself is not the problem, however the character is not being spawned, instead the character generated with random data is instead. Also the error.log is possibly the cause of the suicide error where sometimes during an encounter your ship will be sunk, even with god mode on after the first volley is fired by the opponent's cannons...
     

    Attached Files:

  9. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Interesting...I note that the create fantom character sends a message for the character to be 'entered'. I wonder if that puts a hard set on the model being used, because looking at newer code of COAS, there is another function that gets called to SetNewModelToChar during the boarding load. Similar to that ChangeAttributesFromCharacter function, this appears to be a new method for that boarding. So, let's try that. Add this function, like you did for that ChangeAttributes... function:

    Code:
    void SetNewModelToChar(ref chref)
    {
        float liveTime = 0.1;
        int colors = argb(64, 64, 64, 64);
        int colore = argb(0, 32, 32, 32);
    
        if (IsEntity(chref))
        {
            if(CheckAttribute(chref, "model"))
            {
                SendMessage(chref, "lss",   MSG_CHARACTER_SETMODEL, chref.model, chref.model.animation);
            }
            if(CheckAttribute(chref, "equip.gun"))
            {
                SendMessage(chref, "ls",    MSG_CHARACTER_SETGUN,   chref.equip.gun);
            }
            if(CheckAttribute(chref, "equip.blade"))
            {
                //SendMessage(chref, "lsfll", MSG_CHARACTER_SETBLADE, chref.equip.blade, liveTime, colors, colore);
                SendMessage(chref, "llsfll", MSG_CHARACTER_SETBLADE, 0, chref.equip.blade, liveTime, colors, colore);
            }
        }
    }
    Then in the _SetBoardingCaptain function, just before LAi_group_MoveCharacter(chr, LAI_GROUP_BRDENEMY):

    Code:
    SetNewModelToChar(chr);
    LAi_group_MoveCharacter(chr, LAI_GROUP_BRDENEMY);
     
  10. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    The right character spawns and the right sword. The gun is missing though (not sure If cabin fights usually have guns... It is mainly just a sword duel, but the main character can use his gun - so why not the enemy char)... I may want to tweak Jones's HP so that it is higher, but overall a great start.... The win conditions still aren't working though....
     
  11. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    The logs from the latest run:
     

    Attached Files:

  12. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Looking into your gun problem, I think it's because 'they' screwed up. the SetNewModelToChar uses chref.gun.equip, which is populated with the item id of the gun. Every other function, such as EquipCharacterByItem, which calls SetEquipedItemToCharacter, where it then needs the model of the gun, looks up the item by id, then sends a MSG_CHARACTER_SETGUN message of the .model for that gun item when needed. But in this case, since we are copying the attributes of the Davy character to the standin character, then calling SetNewModelToChar, which then sends MSG_CHARACTER_SETGUN the gun.equip, that message wants the model name, but is given the gun item id, instead.

    The only reason that SetNewModelToChar works in COAS, is because the gun ids were changed to match the model name.

    I did a search for "gun, and see that there are many places where the gun ids are hardcoded/assigned (e.g. "gun1" "gun7"). If you don't want to search for them all, and change them in the code and in the items init (this would obviously require a new game, too), I also see that there really aren't that many in Models\Ammo. For this, to quickly test, copy pistol6, rename the copy to gun6 and see if the gun shows up on the character. Then, if it shows and verifies my thinking, a quick, but not ideal fix, would be to copy all 7, renaming the Ammo models gun1 through gun7.
     
  13. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    That worked, but the character does not use it in the fight with the player character... And the win conditions are still not working right... Also Error log returns...
     

    Attached Files:

  14. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Well, well. You have discovered a bug that still exists to this day in all subsequent versions (COAS, GOF, etc.). Granted, it's unnoticed in the later versions, but only due to the id and model names coincidentally match. Let's fix the bugged SetNewModelToChar function. First, go ahead and delete those ammo models GunsX.gm that you had copied from the PistolX.gm. Then change the function:

    Code:
    void SetNewModelToChar(ref chref)
    {
        float liveTime = 0.1;
        int colors = argb(64, 64, 64, 64);
        int colore = argb(0, 32, 32, 32);
    
        aref arItm;
        string modelName;
        object emptyItm;
    
        if (IsEntity(chref))
        {
            if(CheckAttribute(chref, "model"))
            {
                SendMessage(chref, "lss",   MSG_CHARACTER_SETMODEL, chref.model, chref.model.animation);
            }
            if(CheckAttribute(chref, "equip.gun"))
            {
                modelName = chref.equip.gun;
                makearef(arItm,emptyItm);
                if(modelName!="")
                {
                    Items_FindItem(modelName,&arItm);
                }
                if(CheckAttribute(arItm,"model"))    {modelName = arItm.model;}
                //SendMessage(chref, "ls",    MSG_CHARACTER_SETGUN,   chref.equip.gun);
                SendMessage(chref, "ls",    MSG_CHARACTER_SETGUN,   modelName);
            }
            if(CheckAttribute(chref, "equip.blade"))
            {
                modelName = chref.equip.blade;
                makearef(arItm,emptyItm);
                if(modelName!="")
                {
                    Items_FindItem(modelName,&arItm);
                }
                if(CheckAttribute(arItm,"model"))    {modelName = arItm.model;}
                //SendMessage(chref, "lsfll", MSG_CHARACTER_SETBLADE, chref.equip.blade, liveTime, colors, colore);
                //SendMessage(chref, "llsfll", MSG_CHARACTER_SETBLADE, 0, chref.equip.blade, liveTime, colors, colore);
                SendMessage(chref, "llsfll", MSG_CHARACTER_SETBLADE, 0, modelName, liveTime, colors, colore);
            }
        }
    }
    As for your character not using the gun, I wonder if it may just be a case that their skills are low in that area, so perhaps disfavored? Let's grant them higher skills based on their rank, and the GunProfessional perk to see. Replace this part of SpawnDutchman:

    Code:
    int SpawnDutchman()
    {
    
        int nRank = 20;
    
        int qChar = GetCharacterIndex("Davy Jones");
        if(qChar < 0) { //New
            qChar = GenerateCharacter(PIRATE, WITH_SHIP, "officer", MAN, 1, BOSS);
            characters[qChar].id = "Davy Jones";
            characters[qChar].name = "Davy";
            characters[qChar].location = "Grenada";
            characters[qChar].lastname = "Jones";
            characters[qChar].model = "pirate_5";
            characters[qChar].copyme = true;
            FaceMaker(&characters[qChar]);
            characters[qChar].rank = nRank;
            LAi_NPC_Equip(&characters[qChar], nRank, true, true);
            GiveItem2Character(&characters[qChar], "blade19");
            EquipCharacterByItem(&characters[qChar], "blade19");
            GiveItem2Character(&characters[qChar], "gun6");
            EquipCharacterByItem(&characters[qChar], "gun6");
            characters[qChar].perks.list.GunProfessional = "1";
            characters[qChar].Ship.Type = GenerateShip(SHIP_DUTCHMAN, 1);
            characters[qChar].Ship.Cannons.Type = CANNON_TYPE_CANNON_LBS48;
            characters[qChar].ship.name = "The Flying Dutchman";
            characters[qChar].skill.cannons = 5;
            characters[qChar].skill.grappling = 5;
            characters[qChar].skill.accuracy = 5;
            characters[qChar].skill.defense = 10;
            //characters[qChar].skill.Fencing = 10;
            //characters[qChar].skill.Gun = 10;
            characters[qChar].cannotsurrender = 1;
        }
    During the encounter, try to stay at a distance for as long as you can to see if the NPC will eventually draw the gun. We'll investigate the win conditions after these last details are ironed out.

    Also, that error log: Those errors both occur in LAi_SetBoardingCaptainLevelHP due to a missing chr.ship attribute. That function is only called in one place, LAi_SetBoardingCaptain, but last I saw in the function we never get to the line that calls LAi_SetBoardingCaptainLevelHP because it is in the block of "Random character" instead of the "Special character" trace. So unless you changed that around, I can't see how that line was ever called in your test because I only see the Special character log in compile.log, not a single Random character trace.
     
  15. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    Fixed that (accidentally moved the setboardingcaptainlevelhp function) New Errors and Report:
    In the cabin fight, Davy Jones never drew his gun despite dancing around the cabin as best I could for 10 minutes. Also, in coas, The player character's weapon reloads during aboardage and land encounters, but in CT it doesn't reload at all... Only on land when not in a threatening situation does that code execute... The insta-killed bug at battle with the Dutchman happened again so the error log should probably reflect that.

    Logs Below:
     

    Attached Files:

  16. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Interesting. I've never played CT, so was unaware of that. Since the PC gun doesn't reload, I suspect that is the problem with the NPC gun. Probably also explains why the original boarding captain code doesn't even give the NPC a gun. I bet though the NPC has a gun, it is probably 'not loaded' from the outset (for instance, and since guns don't recharge while engaged in CT, it never charges up. Will need to look around to see if there is a way to at least give the NPC an initial charge prior to the cabin fight, so at least both the PC and NPC start off on even footing of getting a loaded gun at the beginning, then equally neither getting a reload during the fight.
     
  17. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    The only other gun now that rivals the Gun from Davy Jones is Duelist's Dream, a quad charge pistol (used to be double). So the player will be at a disadvantage on average if Jones pulls the gun on an inexperienced player (4 shots is usually enough to kill any character). The only other guns that come close are the muskets and the blunderbuss and they are single shot weapons...
     
  18. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Let's see what this says...in LAi_boarding.c, in the SetBoardingCaptain, insert two trace statements for the charge values:

    SetNewModelToChar(chr);
    trace("charge max " + chr.chr_ai.charge_max);
    trace("charge curr " + chr.chr_ai.charge);
    LAi_group_MoveCharacter(chr, LAI_GROUP_BRDENEMY);
     
  19. Modder01

    Modder01 Freebooter Storm Modder

    Joined:
    Feb 1, 2014
    Messages:
    294
    Gender:
    Male
    Location:
    Oxford, Michigan, USA
    The charge max trace is giving me errors:
     

    Attached Files:

  20. ChezJfrey

    ChezJfrey Master Mariner Storm Modder

    Joined:
    Apr 24, 2015
    Messages:
    226
    Interesting. I think it's possible not having a max charge could contribute to the 'not using gun'. Add another trace with it:

    trace("charge max _enemy " + boarding_enemy.chr_ai.charge_max);

    EquipCharacterByItem, calling SetEquipedItemToCharacter should have set it for Davy. So let's verify that, and see if perhaps the char copy needs adjusting.
     

Share This Page