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

Solved Dutchman Quest Revisions (Test Game Download Included)

At least this time it passes to the special character spawn code in the cabin, however none of the win conditions work, nor is the character redefined properly (the model is fine at least).... I was able to shoot him once and he died... Also he didn't have his gear equipped... Could this be related to the invalid character index I keep getting or am I passing the values to the new method in the wrong order?
 

Attachments

  • compile.log
    19 KB · Views: 164
  • error.log
    3.9 KB · Views: 159
  • system.log
    7.4 KB · Views: 132
What exactly is and isn't working?

If he's getting the correct model now, it sounds like the character reference should not be the problem.
 
I only got to test it once last night. I'm not sure that the model is fixed.... Considering the fact that Davy Jone's HP is not set and his weapons are not equipped, It either is I have to reverse the way the characters are passed or add the give and equip statements along with setting the HP or both...
 
Maybe for the weapons and HP, you need to do a function call instead of setting the attributes directly?
I know that is the case in PotC, depending on when the code is executed (before or after the scene/character is loaded).
 
That function you borrowed to copy attributes, expects a char reference. Change your call parms:

ChangeAttributesFromCharacter(chr, GetCharacterIndex("Davy Jones"), false);

to

ChangeAttributesFromCharacter(chr, boarding_enemy, false);
 
New Errors:
 

Attachments

  • compile.log
    39.8 KB · Views: 142
  • error.log
    1.2 KB · Views: 157
  • system.log
    13.3 KB · Views: 161
The interface\itemstrade.c; line: 1045 error occurs in UpdateDescrInfo during a scroll change where the item with a particular iStep index does not have a .item attribute. That does not seem relevant.

The characters\characterUtilite.c; line: 1726 error occurs in GetChrItemQuantity which is called in only two places:

TakeNItems of CharacterUtilite.c and CanCharacterTakeItem of itemsbox.c.

Coincidentally, TakeNItems consists of lines that correspond to that other error characters\characterUtilite.c; line: 1808. Since neither of those functions look to relate to anything to do with the Davy Jones mod, I don't think they are relevant; they are due to something else and can probably be identified by putting a trace in UpdateDescrInfo to check for attribute .item and if non-existent, output what the iStep value is, and comparing it to the size of InterfaceItems array...what it might contain.

In the compile log, I see:

*** Slip of Paper Given
*** Davy Jones login successful

I see you don't start getting invalid char index errors until after that SpawnDutchman call, so I'm curious what's happening there...try tracing that function to see what's up and if that might be a problem. Maybe change:

Code:
int SpawnDutchman()
{
   int iChar = GetCharacterIndex("Davy Jones");
   if(iChar < 0) { //New      
      iChar = GenerateCharacter(PIRATE, WITH_SHIP, "officer", MAN, 1, BOSS);
       characters[iChar].id = "Davy Jones";
       characters[iChar].name = "Davy";
       characters[iChar].location = "Grenada";
       characters[iChar].lastname = "Jones";
       characters[iChar].model = "pirate_5";
       characters[iChar].Ship.Type = GenerateShip(SHIP_DUTCHMAN, 1);
       characters[iChar].Ship.Cannons.Type = CANNON_TYPE_CANNON_LBS48;
       characters[iChar].ship.name = "The Flying Dutchman";
       characters[iChar].skill.cannons = 5;
       characters[iChar].skill.grappling = 5;
       characters[iChar].skill.accuracy = 5;
       characters[iChar].skill.defense = 10;
       characters[iChar].rank = 20;
       characters[iChar].skill.Fencing = 10;
       characters[iChar].skill.Gun = 10;
       characters[iChar].cannotsurrender = 1;
      FaceMaker(&characters[iChar]);
      trace("Davy new = " + iChar);
   }
   else { //Reset ship attributes (restock HP, ammo, etc.)
       trace("Davy exist = " + iChar);
       SetBaseShipData(GetCharacter(iChar));
   }

   DeleteAttribute(&characters[iChar], "seaai");
   Group_CreateGroup("FlyingDutchman");
   Group_AddCharacter("FlyingDutchman", "Davy Jones");
   Group_SetGroupCommander("FlyingDutchman", "Davy Jones");
   Group_SetPursuitGroup("FlyingDutchman", PLAYER_GROUP);

   string sLocator = "Grenada_locators" + (rand(2)+2);
   Group_SetAddress("FlyingDutchman", "Grenada", "quest_ships", sLocator);
   SetCharacterRelationBoth(nMainCharacterIndex, iChar, RELATION_ENEMY);

   Group_SetTaskAttack("FlyingDutchman", PLAYER_GROUP);
   Group_LockTask("FlyingDutchman");
   UpdateRelations();
   trace("*** Davy Jones login successful");
   trace("returning iChar = " + iChar);
   return iChar;
}
 
Logs (from those traces) (Note: changed iChar to qChar in the Dutchman Encounter quest file to prevent it conflicting with the storyline's iChar):
 

Attachments

  • compile.log
    53.1 KB · Views: 139
  • error.log
    656 bytes · Views: 156
  • system.log
    10.4 KB · Views: 140
Nope, the problem lies elsewhere:

Davy new = 317
*** Davy Jones login successful
returning qChar = 317
Incorrect Index for a character! Wrong Index is 0
 
Hmmm, this is interesting. Technically, zero is not an invalid index. That error comes from only one place: GetCharacter() in globals.c:

Code:
ref GetCharacter(int iIndex)
{
    //if (iIndex >= TOTAL_CHARACTERS || iIndex < 0) { return &NullCharacter; }
    if(iIndex >= TOTAL_CHARACTERS)
    {
        trace("Incorrect Index for a character! Wrong Index is " + iIndex);
        return &NullCharacter;
    }
    if(iIndex < 1)
    {
        trace("Incorrect Index for a character! Wrong Index is " + iIndex);
        return &NullCharacter;
    }
    return &Characters[iIndex]);
}

In COAS, that code is different. I suggest changing it to match:

Code:
ref GetCharacter(int iIndex)
{
    if (iIndex < 0 || iIndex >= TOTAL_CHARACTERS)
    {
        trace("Incorrect Index for a character! Wrong Index is " + iIndex);
        return &NullCharacter;
    }
    return &Characters[iIndex]);
}

Oh, but prior to doing that, it might be beneficial, just to see what might be going on, in the GetCharacter trace error for zero, put in a trace for the .id and/or name of the character. Maybe see what it is? I suspect that you are getting those from locations_loader.c where it loops
// create other quest characters ships
for (i=0;i<MAX_CHARACTERS;i++)
{...

It sets iShips[locNumShips] = i, which later gets sent to the func as GetCharacter(iShips[n]);
 
Last edited:
In trying to test which character it was that had index of 0, I am getting trace errors out the wazoo:
Code:
ref GetCharacter(int iIndex)
{
   //if (iIndex >= TOTAL_CHARACTERS || iIndex < 0) { return &NullCharacter; }
   if(iIndex >= TOTAL_CHARACTERS)
   {
       trace("Incorrect Index for a character! Wrong Index is " + iIndex);
       trace("Bad Character index - Character ID " + &Characters[iIndex].id);
       trace("Bad Character index - Name of Character " + &Characters[iIndex].name + " " + &Characters[iIndex].lastname);
       return &NullCharacter;
   }
   if(iIndex < 1)
   {
       trace("Incorrect Index for a character! Wrong Index is " + iIndex);
       trace("Bad Character index -  Character ID " + &Characters[iIndex].id);
       trace("Bad Character index -  Name of Character " + &Characters[iIndex].name + " " + &Characters[iIndex].lastname);
       return &NullCharacter;
   }
   return &Characters[iIndex]);
}
Code:
COMPILE ERROR - file: globals.c; line: 174
Invalid Expression
COMPILE ERROR - file: globals.c; line: 174
Invalid Expression
COMPILE ERROR - file: globals.c; line: 174
Invalid Expression
COMPILE ERROR - file: globals.c; line: 174
Invalid Expression
COMPILE ERROR - file: globals.c; line: 174
Invalid Expression
COMPILE ERROR - file: globals.c; line: 174
Invalid Expression
COMPILE ERROR - file: globals.c; line: 174
Invalid Expression
COMPILE ERROR - file: globals.c; line: 174
invalid syntax
COMPILE ERROR - file: globals.c; line: 175
Invalid Expression
COMPILE ERROR - file: globals.c; line: 175
Invalid Expression
COMPILE ERROR - file: globals.c; line: 175
Invalid Expression
COMPILE ERROR - file: globals.c; line: 175
Invalid Expression
COMPILE ERROR - file: globals.c; line: 175
Invalid Expression
COMPILE ERROR - file: globals.c; line: 175
Invalid Expression
COMPILE ERROR - file: globals.c; line: 175
Invalid Expression
COMPILE ERROR - file: globals.c; line: 175
invalid syntax
COMPILE ERROR - file: globals.c; line: 181
Invalid Expression
COMPILE ERROR - file: globals.c; line: 181
Invalid Expression
COMPILE ERROR - file: globals.c; line: 181
Invalid Expression
COMPILE ERROR - file: globals.c; line: 181
Invalid Expression
COMPILE ERROR - file: globals.c; line: 181
Invalid Expression
COMPILE ERROR - file: globals.c; line: 181
Invalid Expression
COMPILE ERROR - file: globals.c; line: 181
Invalid Expression
COMPILE ERROR - file: globals.c; line: 181
invalid syntax
COMPILE ERROR - file: globals.c; line: 182
Invalid Expression
COMPILE ERROR - file: globals.c; line: 182
Invalid Expression
COMPILE ERROR - file: globals.c; line: 182
Invalid Expression
COMPILE ERROR - file: globals.c; line: 182
Invalid Expression
COMPILE ERROR - file: globals.c; line: 182
Invalid Expression
COMPILE ERROR - file: globals.c; line: 182
Invalid Expression
COMPILE ERROR - file: globals.c; line: 182
Invalid Expression
COMPILE ERROR - file: globals.c; line: 182
invalid syntax
 
Isn't Characters[0] the player character? If so, that check 'if(iIndex < 1)' is going to cause trouble!

Otherwise, if iIndex is less than 0 then Characters[iIndex] won't work at all, and if iIndex is greater than TOTAL_CHARACTERS then Characters[iIndex] won't be defined, which means most of your trace commands won't work.
 
Grey: I also thought zero would be the main character, but in a test game for this mod, an output of GetMainCharacterIndex() displayed a 2 for me.

I'm not sure why zero is even a problem for this function and why it was written to not accept (considering it is technically a valid index, and subsequent versions of this game changed that particular function to accept a zero), and also why it only seems to appear after Modder creates that Davy Jones character...which is especially weird considering an output of the character generation for Davy showed index 317 in his last test, so that would not seem to be the cause, but a suspicious circumstance that the error and that code generation warrants some investigation as there still might be a loose end somewhere with that char/ship introduction that still needs attending.

I still suspect the invalid index error has its founding in locations_loader because its logic clearly has the potential to send a zero to GetCharacter. It would be beneficial to first see if this zero index char is even a problem to begin with and if not, could just change the function to match the later versions of the game that allow zero within GetCharacter().

Modder, this will get rid of your compile errors:

Code:
ref GetCharacter(int iIndex)
{
   //if (iIndex >= TOTAL_CHARACTERS || iIndex < 0) { return &NullCharacter; }
   if(iIndex >= TOTAL_CHARACTERS)
   {
       trace("Incorrect Index for a character! Wrong Index is " + iIndex);
       trace("Bad Character index - Character ID " + Characters[iIndex].id);
       trace("Bad Character index - Name of Character " + Characters[iIndex].name + " " + Characters[iIndex].lastname);
       return &NullCharacter;
   }
   if(iIndex < 1)
   {
       trace("Incorrect Index for a character! Wrong Index is " + iIndex);
       trace("Bad Character index -  Character ID " + Characters[iIndex].id);
       trace("Bad Character index -  Name of Character " + Characters[iIndex].name + " " + Characters[iIndex].lastname);
       return &NullCharacter;
   }
   return &Characters[iIndex]);
}
 
'trace("Bad Character index - Character ID " + Characters[iIndex].id);' still won't work if "iIndex" isn't a valid index.
 
'trace("Bad Character index - Character ID " + Characters[iIndex].id);' still won't work if "iIndex" isn't a valid index.

Agreed. But right now, the error log already tells him, in every case right now, that the 'invalid' index is zero, which is technically OK.

But it still may turn out that this zero is invalid in the sense that for zero, maybe those attributes are still not set up for that character, in which case, yes, that particular trace line for .id and .name will get output as invalid attributes. We will just have to wait for a test to see what happens, then try to figure out how to track back from where this is coming from. The unfortunate case here is that GetCharacter is called from hundreds of different places, so it is going to be difficult to discern the origin of this iIndex = 0. My first inclination is to put a trace prior to the GetCharacter calls in locations_loader.
 
'trace("Bad Character index - Character ID " + Characters[iIndex].id);' still won't work if "iIndex" isn't a valid index.

Also, just an additional note. The 'arrays' in the script part of the game are not like C++ arrays, where trying to access array[-1], or array[indexbeyondmax] would cause the process to crash. All that happens in those instances within the script code, is that an error is output to the log, so trying to access them is relatively harmless. Each script variable is a type of malleable/flexible 'object' in the sense that trying to access non-existent attributes and invalid array indices just prompts a log error and the script iteration continues.
 
The game, as a result of that latest change of globals.c has gotten very choppy and nearly unplayable, when running the intro videos at the beginning (without skipping them) the game crashed altogether... Here are the logs (I initiated the dutchman quest, however when testing it in godmode I got killed by the game, not by the ship that was shooting at me - lol):
 

Attachments

  • compile.log
    34.1 KB · Views: 154
  • error.log
    38.4 KB · Views: 142
  • system.log
    5.3 KB · Views: 138
Well, that doesn't tell us much...the .id is 0, which was somewhat predictable since the Generate NPC function defaults to that...and there is no name attribute. Since I believe the GetCharacter call with the 0 index is initiated within locations_loader.c, let's check that.

Find LocLoadShips and scroll down to:

// create other quest characters ships
for (i=0;i<MAX_CHARACTERS;i++)
.
.
.
Scroll a little further to find the GetCharacter function call:

ref rCharacter = GetCharacter(iShips[n]);

Just before that, put a trace: if(n==0) trace("My test message, calling GetCharacter with a zero");

I also notice that in the later versions, they don't even loop from zero. The for loop starts at 1, with a new comment that translates to '
beginning not from 0' so undoubtedly a fix:

// create other quest characters ships
for (i=1;i<MAX_CHARACTERS;i++) // начало не с 0
 
Tested that for replacing the characters loop with what you have there, but still the trace statement fires...
Logs are attached. I had to hard reset my computer after the globals.c trace statements gave my computer a hard freeze - I removed the trace statements that were added to globals.c because they were causing problems with the game. the logs pertain to a short run I did after the hard computer reset, but before removing the new trace statements in globals.c.
 

Attachments

  • compile.log
    9.4 KB · Views: 137
  • error.log
    3.5 KB · Views: 145
  • system.log
    2.2 KB · Views: 136
Ah, I see a mistake in the trace...doesn't help as much as we'd like. Should be:

if(sti(iShips[n])==0) trace("My test message, calling GetCharacter with a zero " + iShips[n]);

Also, given you now start the characters loop with a 1, let's also look in the companion loop, and put a trace to see if iCompanionIndex is ever a zero, just before this line:

iShips[locNumShips] = iCompanionIndex;
 
Back
Top