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

Fixed Levelling: Treasure Quest Pirates Unaffected

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
Today I was investigating this here issue: Fix in Progress - Jack Sparrow: Improvements to Maximus and Philippe Quest | PiratesAhoy!

Some enemies didn't appear but the quest still worked because the game figured you already killed them.
The reason was really very similar to this problem we had before:
Fixed - Levelling: Missing Ships and Crashes on Encounter Reload from Worldmap to Sea | PiratesAhoy!

As a solution, I applied pretty much the same trick.
For that particular quest situation, the better fix would probably be to NOT use those pre-initialized characters in the first place.
But for the actual Treasure Quests, I noted that their settings are not at all making proper use of @Levis' Levelling system either.
This code may yield better results:
Code:
   if(rand(sti(Pchar.skill.sneak))<3) // PB: was >0 - HIGHER luck skill gives a HIGHER chance at enemies?
   {
     ref pir; string ani;
     int con;
     for(con =  1; con < 11 ; con++)
     {
       pir = &Characters[GetcharacterIndex("Treas_Pirate_" + con)];
       ClearCharacter(pir); // PB: Clear ALL attributes from previous character
       pir.nation = PIRATE;
       SetModelfromArray(pir, GetModelIndex(GetRandomModelForTypeExSubCheck(1, "Sailors", "man", sti(sld.nation))) );
       SetRandomNameToCharacter(pir);
       InitCharacterSkills(pir);   // PB: Reset this character
       LAi_NPC_Equip(pir, sti(pir.rank), true, true);
       LAi_SetWarriorType(pir);
       LAi_group_MoveCharacter(pir, "treasure_pirates");
       LAi_SetImmortal(pir, false);
      
       if(rand(Makeint(Pchar.skill.sneak)) > 0) { ChangeCharacterAddressGroup(pir, attackers_location, "goto", attackers_locator); }
       else { ChangeCharacterAddressGroup(pir, "", "", ""); }

       //Logit("TreasureQuest: Treas_Pirate "+GetcharacterIndex("Treas_Pirate_" + con)+" generated");// DEBUG
     }
     LAi_group_SetRelation(LAI_GROUP_PLAYER, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_DEFAULT_GROUP, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_GROUP_MONSTERS, "treasure_pirates", "enemy");
     LAi_group_FightGroups("treasure_pirates", LAI_GROUP_PLAYER, true);
   }
 
Okay to me but move it all in the if statement with the move character. So they only are initialized if they actually appear.
 
Okay to me but move it all in the if statement with the move character. So they only are initialized if they actually appear.
Something like this, you mean?
Code:
  if(rand(sti(Pchar.skill.sneak))<3) // PB: was >0 - HIGHER luck skill gives a HIGHER chance at enemies?
   {
     ref pir; string ani;
     int con;
     for(con =  1; con < 11 ; con++)
     {
       pir = &Characters[GetcharacterIndex("Treas_Pirate_" + con)];
       ClearCharacter(pir); // PB: Clear ALL attributes from previous character
       if(rand(Makeint(Pchar.skill.sneak)) == 0) continue;

       pir.nation = PIRATE;
       SetModelfromArray(pir, GetModelIndex(GetRandomModelForTypeExSubCheck(1, "Sailors", "man", sti(pir.nation))) );
       SetRandomNameToCharacter(pir);
       InitCharacterSkills(pir);   // PB: Reset this character
       LAi_NPC_Equip(pir, sti(pir.rank), true, true);
       LAi_SetWarriorType(pir);
       LAi_group_MoveCharacter(pir, "treasure_pirates");
       LAi_SetImmortal(pir, false);
       ChangeCharacterAddressGroup(pir, attackers_location, "goto", attackers_locator);

       //Logit("TreasureQuest: Treas_Pirate "+GetcharacterIndex("Treas_Pirate_" + con)+" generated");// DEBUG
     }
     LAi_group_SetRelation(LAI_GROUP_PLAYER, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_DEFAULT_GROUP, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_GROUP_MONSTERS, "treasure_pirates", "enemy");
     LAi_group_FightGroups("treasure_pirates", LAI_GROUP_PLAYER, true);
No need for teleporting characters away if we're only clearing them and not resetting them, right? :cheeky
 
Last edited:
In which file is this? Or do you have it? I will include it in my zip then.
 
Something like this, you mean?
Code:
  if(rand(sti(Pchar.skill.sneak))<3) // PB: was >0 - HIGHER luck skill gives a HIGHER chance at enemies?
   {
     ref pir; string ani;
     int con;
     for(con =  1; con < 11 ; con++)
     {
       pir = &Characters[GetcharacterIndex("Treas_Pirate_" + con)];
       ClearCharacter(pir); // PB: Clear ALL attributes from previous character
       if(rand(Makeint(Pchar.skill.sneak)) == 0) continue;

       pir.nation = PIRATE;
       SetModelfromArray(pir, GetModelIndex(GetRandomModelForTypeExSubCheck(1, "Sailors", "man", sti(pir.nation))) );
       SetRandomNameToCharacter(pir);
       InitCharacterSkills(pir);   // PB: Reset this character
       LAi_NPC_Equip(pir, sti(pir.rank), true, true);
       LAi_SetWarriorType(pir);
       LAi_group_MoveCharacter(pir, "treasure_pirates");
       LAi_SetImmortal(pir, false);
       ChangeCharacterAddressGroup(pir, attackers_location, "goto", attackers_locator);

       //Logit("TreasureQuest: Treas_Pirate "+GetcharacterIndex("Treas_Pirate_" + con)+" generated");// DEBUG
     }
     LAi_group_SetRelation(LAI_GROUP_PLAYER, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_DEFAULT_GROUP, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_GROUP_MONSTERS, "treasure_pirates", "enemy");
     LAi_group_FightGroups("treasure_pirates", LAI_GROUP_PLAYER, true);
No need for teleporting characters away if we're only clearing them and not resetting them, right? :cheeky
^ Typo corrected in the above code. :wp
 
I got a treasure quest to Boca De Hubon on Hispaniola and when we landed we were attacked by 11 pirates. We killed them and went for the treasure.

From there I went to Tortuga where I picked up a shipyard quest. I sailed back to Boca De Hubon to buy some sandal at the buccaneer camp and when I landed there were all these pirates just walking around! I was able to kill and loot them again too.
 

Attachments

  • -=Player=- Hispaniola. Boca de Hubon. December 9th, 1690.7z
    611.8 KB · Views: 75
So these are the Treasure Quest pirates being automatically resurrected?
That may be an unexpected side-effect from my recent changes here:
Code:
  if(rand(sti(Pchar.skill.sneak))<3) // PB: was >0 - HIGHER luck skill gives a HIGHER chance at enemies?
   {
     ref pir; string ani;
     int con;
     for(con =  1; con < 11 ; con++)
     {
       pir = &Characters[GetcharacterIndex("Treas_Pirate_" + con)];
       ClearCharacter(pir); // PB: Clear ALL attributes from previous character
       if(rand(Makeint(Pchar.skill.sneak)) == 0) continue;

       pir.nation = PIRATE;
       SetModelfromArray(pir, GetModelIndex(GetRandomModelForTypeExSubCheck(1, "Sailors", "man", sti(pir.nation))) );
       SetRandomNameToCharacter(pir);
       InitCharacterSkills(pir);   // PB: Reset this character
       LAi_NPC_Equip(pir, sti(pir.rank), true, true);
       LAi_SetWarriorType(pir);
       LAi_group_MoveCharacter(pir, "treasure_pirates");
       LAi_SetImmortal(pir, false);
       ChangeCharacterAddressGroup(pir, attackers_location, "goto", attackers_locator);

       //Logit("TreasureQuest: Treas_Pirate "+GetcharacterIndex("Treas_Pirate_" + con)+" generated");// DEBUG
     }
     LAi_group_SetRelation(LAI_GROUP_PLAYER, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_DEFAULT_GROUP, "treasure_pirates", "enemy");
     LAi_group_SetRelation(LAI_GROUP_MONSTERS, "treasure_pirates", "enemy");
     LAi_group_FightGroups("treasure_pirates", LAI_GROUP_PLAYER, true);
   }
But I don't quite know why. Maybe @Levis has a clue?

Might I assume that if you accept another Treasure Quest, these guys will have disappeared?
 
My thinking is that if you leave the island completely instead of sailing to different parts of it, then when you come back they are gone.
 
My thinking is that if you leave the island completely instead of sailing to different parts of it, then when you come back they are gone.
You mean as a proper solution? That could work.

Might I assume that if you accept another Treasure Quest, these guys will have disappeared?
^ The reason for me asking that is because I think that is how it would work right now.
I'd appreciate if you could double-check if that hypothesis is indeed true because that would tell us how we'd need to fix it.
 
I....think....maybe I already did that. I did the treasure quest to Boca de Hubon, then did the fetch quest from tortuga to there and back. Later I had another treasure quest to Cape Franco. I do not remember if I stopped off at Boca de Hubon or not but want to say I did and there were no dead pirates walking around.
 
I wuz wrong. I just sailed from Havana and stopped by there on my way south, and they are all still there just wandering around. I have a treasure quest in Barbados too.
 
Maybe they only disappear IF there are new Pirates at your next treasure quest?
The sane character IDs are reused, so they shouldn't be in multiple spots at the same time, at least.
 
Which file controls treasure quests? My guess is that a bunch of 'ChangeCharacterAddress(characterFromID("<pirate name"), "None", "");' lines after you find the treasure, or preferably as soon as possible after you've fought the pirates, would do the job.
 
Which file controls treasure quests?
PROGRAM\MAXIMUS_functions.c; search for "treasure".

My guess is that a bunch of 'ChangeCharacterAddress(characterFromID("<pirate name"), "None", "");' lines after you find the treasure, or preferably as soon as possible after you've fought the pirates, would do the job.
That's pretty much what I had in mind as well.

Altenate solution would be to NOT reuse the same characters in the first place, similar to this related change I did last month:
Fixed - Jack Sparrow: Improvements to Maximus and Philippe Quest | Page 4 | PiratesAhoy!

I do wonder WHY these guys are being resurrected now when they never were before.
Must be something related to a fix I did earlier, so I now merged this with the original thread about that.
 
I think adding this line should work:

Code:
LAi_NoRebirthEnable(pir); //Levis so they wont rebirth
 
I think adding this line should work:

Code:
LAi_NoRebirthEnable(pir); //Levis so they wont rebirth
In that case, can they still be reused a second time if they're placed again?
Probably because the characters are fully cleared, that may actually still work, no?
 
In that case, can they still be reused a second time if they're placed again?
Probably because the characters are fully cleared, that may actually still work, no?
its only setting a character attribute so yes after clearing it should be okay again
 
Back
Top