• 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 Boarding: Stuck, but No Crash

Indeed no error log entries related to flags; just those other ones.

If you now go to another islands and try it with another shore encounter, does it work again on that one?
 
Oh, one thing just sprang to mind! Open PROGRAM\SEA_AI\AIFantom.c and find this code:
Code:
void Fantom_AddFantomCharacter(string sGroupName, int iShipType, string sFantomType, int iEncounterType, int iNation) // NK 04-09-05 add nation argument
{
   ref rFantom = GetFantomCharacter(iNumFantoms);
   ClearCharacter(rFantom); // PB: Clear ALL attributes from previous character
   rFantom.nation = iNation; // NK

//   DeleteAttribute(rFantom, "relation"); // PB: Character already cleared

   rFantom.SeaAI.Group.Name = sGroupName;
   rFantom.Ship.Type = GetShipID(iShipType); // PS
   //trace("added fantom " + rFantom.index + " with ship " + rFantom.ship.type);
   rFantom.Ship.idx = iShipType; // PS
   rFantom.Ship.Mode = sFantomType;
   rFantom.ship.cannons.Charge.Type = GOOD_BALLS;
//NK -->
//   DeleteAttribute(rFantom,"ship.cannons.borts"); rFantom.ship.cannons.borts = ""; // NK 05-04-18 cannon qty // PB: Character already cleared
   // PRS3 -->
   aref arship; makearef(arship, rFantom.ship);
//   DeleteAttribute(rFantom, "ship.stats"); // PB: Character already cleared
//KB - Tuning ships - changed call to SetRandomStatsToShip
   SetRandomStatsToShip(sti(rFantom.index), iShipType, iNation);
//KB - orig  SetRandomStatsToShip(arship, iShipType, iNation);
//KB
// PRS3 <--
   if(sti(rFantom.nation) == PIRATE) { sFantomType = "pirate"; }
   else { if(sFantomType == "pirate") { sFantomType = "war"; } }
   rFantom.shiptype = GetShipID(iShipType); // PS
   rFantom.FantomType = sFantomType;
   float mult = 1.0;
   if(DEBUG_EXPERIENCE>0) TraceAndLog("Fantom_AddFantomCharacter: Set officer type for " + GetMySimpleName(rFantom));
   switch(sFantomType)
   {
     case "trade":
       mult *= 1.0;
       rFantom.quest.officertype = OFFIC_TYPE_CAPMERCHANT;
       break;
      
     case "war":
       mult *= 1.25;
       rFantom.quest.officertype = OFFIC_TYPE_CAPNAVY;
       break;
      
     case "pirate":
       mult *= 1.25;
       rFantom.quest.officertype = OFFIC_TYPE_CAPPIRATE;
       break;

     case "error":
       mult *= 1.0;
       rFantom.quest.officertype = OFFIC_TYPE_CAPPIRATE;
       break;
   }
   ref Shiptype = GetShipByType(iShipType);
   int iMCShipClass = makeint(GetCharacterShipClass(GetMainCharacter()));
   if (sti(Shiptype.Class) < iMCShipClass) {
     mult *= 1.15;
   } else {
     if (makeint(Shiptype.Class) > iMCShipClass) mult *= 0.85;
   }
   rFantom.Points = mult * stf(GetLocalShipAttrib(&arship,&Shiptype,"Weight")) / 5000; // PRS3
   //Log_SetStringToLog("Type: " + rFantom.FantomType + "; Mult: " + rFantom.Points);
// NK <--
   InitCharacterSkills(rFantom);   // PB: Reset this character
   SetBaseShipData(rFantom); // PB: ADDED TO AVOID EXTRA ERRORS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   iNumFantoms++;
}
Add that line marked with "PB: ADDED TO AVOID EXTRA ERRORS" at the bottom there.
Could that possibly be helping?

I thought @Levis' character PostInit should take care of that, but we've seen missing "morale" attributes before and that happened when this function wasn't run on the applicable characters.
See here for last time we had similar errors: Fixed - Crew attributes missing on new game | PiratesAhoy!
The above code was originally rewritten by me to try to fix this error: Fixed - Levelling: Missing Ships and Crashes on Encounter Reload from Worldmap to Sea | PiratesAhoy!
But I'm still not overly fond of that "solution".
 
Thanks; that certainly helps. It seems these ones are still real problems:
Code:
RUNTIME ERROR - file: Loc_ai\LAi_boarding.c; line: 1781
missed attribute: morale
RUNTIME ERROR - file: Loc_ai\LAi_boarding.c; line: 1781
no rAP data
RUNTIME ERROR - file: Loc_ai\LAi_boarding.c; line: 1365
missed attribute: morale
RUNTIME ERROR - file: Loc_ai\LAi_boarding.c; line: 1365
no rAP data
RUNTIME ERROR - file: Loc_ai\LAi_boarding.c; line: 1013
invalid index -1 [size:1000]
RUNTIME ERROR - file: Loc_ai\LAi_boarding.c; line: 1013
invalid array index
RUNTIME ERROR - file: Loc_ai\LAi_boarding.c; line: 1013
function 'LAi_ReloadBoarding' stack error

I'm sure you already noticed but this error sequence is reported as the same in the last looting case in the other thread about crashes whilst looting during boarding, whilst @ANSEL 's previous example in there had the first four lines. So maybe not the longstanding issue in this case

Just saying is all, ;)(no response necessary) :no

EDIT and pretty much the same in the third thread - whilst keeping the reports apart makes sense -it looks likely to be the same root cause?
 
Last edited:
I moved some posts around to hopefully their appropriate threads. Still a bit confusing though.
I do believe the "being stuck" and one of the two CTD bugs are related.
But the inconsistent looting one most likely is not. :shrug
 
Oh, one thing just sprang to mind! Open PROGRAM\SEA_AI\AIFantom.c and find this code:
Code:
void Fantom_AddFantomCharacter(string sGroupName, int iShipType, string sFantomType, int iEncounterType, int iNation) // NK 04-09-05 add nation argument
{
   ref rFantom = GetFantomCharacter(iNumFantoms);
   ClearCharacter(rFantom); // PB: Clear ALL attributes from previous character
   rFantom.nation = iNation; // NK

//   DeleteAttribute(rFantom, "relation"); // PB: Character already cleared

   rFantom.SeaAI.Group.Name = sGroupName;
   rFantom.Ship.Type = GetShipID(iShipType); // PS
   //trace("added fantom " + rFantom.index + " with ship " + rFantom.ship.type);
   rFantom.Ship.idx = iShipType; // PS
   rFantom.Ship.Mode = sFantomType;
   rFantom.ship.cannons.Charge.Type = GOOD_BALLS;
//NK -->
//   DeleteAttribute(rFantom,"ship.cannons.borts"); rFantom.ship.cannons.borts = ""; // NK 05-04-18 cannon qty // PB: Character already cleared
   // PRS3 -->
   aref arship; makearef(arship, rFantom.ship);
//   DeleteAttribute(rFantom, "ship.stats"); // PB: Character already cleared
//KB - Tuning ships - changed call to SetRandomStatsToShip
   SetRandomStatsToShip(sti(rFantom.index), iShipType, iNation);
//KB - orig  SetRandomStatsToShip(arship, iShipType, iNation);
//KB
// PRS3 <--
   if(sti(rFantom.nation) == PIRATE) { sFantomType = "pirate"; }
   else { if(sFantomType == "pirate") { sFantomType = "war"; } }
   rFantom.shiptype = GetShipID(iShipType); // PS
   rFantom.FantomType = sFantomType;
   float mult = 1.0;
   if(DEBUG_EXPERIENCE>0) TraceAndLog("Fantom_AddFantomCharacter: Set officer type for " + GetMySimpleName(rFantom));
   switch(sFantomType)
   {
     case "trade":
       mult *= 1.0;
       rFantom.quest.officertype = OFFIC_TYPE_CAPMERCHANT;
       break;
     
     case "war":
       mult *= 1.25;
       rFantom.quest.officertype = OFFIC_TYPE_CAPNAVY;
       break;
     
     case "pirate":
       mult *= 1.25;
       rFantom.quest.officertype = OFFIC_TYPE_CAPPIRATE;
       break;

     case "error":
       mult *= 1.0;
       rFantom.quest.officertype = OFFIC_TYPE_CAPPIRATE;
       break;
   }
   ref Shiptype = GetShipByType(iShipType);
   int iMCShipClass = makeint(GetCharacterShipClass(GetMainCharacter()));
   if (sti(Shiptype.Class) < iMCShipClass) {
     mult *= 1.15;
   } else {
     if (makeint(Shiptype.Class) > iMCShipClass) mult *= 0.85;
   }
   rFantom.Points = mult * stf(GetLocalShipAttrib(&arship,&Shiptype,"Weight")) / 5000; // PRS3
   //Log_SetStringToLog("Type: " + rFantom.FantomType + "; Mult: " + rFantom.Points);
// NK <--
   InitCharacterSkills(rFantom);   // PB: Reset this character
   SetBaseShipData(rFantom); // PB: ADDED TO AVOID EXTRA ERRORS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   iNumFantoms++;
}
Add that line marked with "PB: ADDED TO AVOID EXTRA ERRORS" at the bottom there.
Could that possibly be helping?
I might be onto something there....

The Character_PostInit function calls SetBaseShipData .
This function is called once through DoCharactersPostInit at the start of a new game.
It NEVER gets called at any other point during the game and is therefore completely unrelated to the PostInit being done on each location load through the Levelling system.
This could explain why at game start, it all works, but not once encounter any "newly generated" enemies, such as worldmap/DirectSail ones.

There ARE, however, two calls to SetBaseShipData in PROGRAM\SEA_AI\AIShip.c that look like maybe they should cover this instead.
So please try my above suggestion so that we can find out if this is it or not.
 
Internal settings, like this:
 

Attachments

  • Udklip.PNG
    Udklip.PNG
    17.9 KB · Views: 107
@Pieter Boelen I think you are on to something.
I was thinking of just adding it to checkcharactersetup. This makes it be set for EACH character.
Do you know any reason why this shouldn't be set for all characters?
 
well after enabling cheats in the text pad I press (zero) in battle, no text comes up say god mode activated or anything.

when do you press (zero) to activate it
 
@Pieter Boelen indeed it doesn't work.
Looking into now why it isn't working.
Also my attempt didn't work either so this character doesn't go trough my function either....
 
Do you know any reason why this shouldn't be set for all characters?
Only needs to be done for characters who actually have a ship. :shrug

holy god jesus in hell....... i needed numlock on..... god thats depressing
Ah, yes; that is indeed needed. You're not the first to have that issue; I think I had it myself some time too, but forgot about it. Sorry. :facepalm

@Pieter Boelen in regards to the code fix I am stil unable to continue after boarding
Thanks for trying. Knowing something doesn't work is also useful. :onya
 
Very interesting indeed, tried boarding another coastal ship at another island and was able to complete it without any problems
And then I went onto the map found the first ship I could, boarded and couldn't complete it
 
@Pieter Boelen I've got a theory why it isn't working.
Captain are stored as fantoms. and in the past most data wasn't cleared that well. but I remember recently you added the Clearcharacter code somewhere else too. I think this might clear the captain when you reload from sea to the boarding location.
Going to look into this now.
 
That suggests that worldmap encounters don't trigger the same code that shore ones do.

@Levis: The relevant files would probably be sea.c and AIShip.c .
 
Back
Top