• 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: Skills of Zero Trigger Errors

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
Just now I noticed the following lines in my error.log file:
Code:
RUNTIME ERROR - file: interface\character.c; line: 559
Divide by zero
RUNTIME ERROR - file: interface\character.c; line: 559
Divide by zero
RUNTIME ERROR - file: interface\character.c; line: 559
Divide by zero
RUNTIME ERROR - file: interface\character.c; line: 559
Divide by zero

I strongly suspect the reason to be this enemy captain I captured:
upload_2015-11-26_22-43-6.png


Savegame attached.
This one also contains the non-captain Mr. Bush who still shows as being a captain.
 

Attachments

  • -=Player2=- Cayman. Grand Cayman shipyard June 18th, 1798.zip
    711.2 KB · Views: 141
:S this shouldn't be possible to happen.
I think I'm going to add a little check in the character interface where if a percantage is above 100% it will run the AddXPtoSkill function once more so it should fix itself ...
Will see if that helps...
@Pieter Boelen you are using the latest files yes? Because untill 1 or 2 weeks ago there was a bug which could cause this..
 
I think I'm going to add a little check in the character interface where if a percantage is above 100% it will run the AddXPtoSkill function once more so it should fix itself ...
That would hide the issue, rather than fixing it, no?
Could the same functions not be called from outside the Character interface?

Also, is that "0 skill level" because the XP gain didn't actually increase the skills as it was meant to?
Or is it the other way around and the whole issue is caused by the "0 skill level"?

@Pieter Boelen you are using the latest files yes? Because untill 1 or 2 weeks ago there was a bug which could cause this..
I've got the current Beta 4 WIP code from the EXE; as far as I'm aware, that was indeed your latest code.
Excluding the "WIP" version you posted earlier this week, which I had a quick look at, but did not yet include in my game.
As far as I'm aware, I should be up-to-date. But feel free to double-check he current EXE.
 
That would hide the issue, rather than fixing it, no?
Could the same functions not be called from outside the Character interface?

Also, is that "0 skill level" because the XP gain didn't actually increase the skills as it was meant to?
Or is it the other way around and the whole issue is caused by the "0 skill level"?

it would fix it. The character does have the XP but something set the skill level to this. I think it has something to do with the weird character creation. So if I just call the XP function once with 0 XP it will see the XP is enough to level up and it will auto correct itself. As soon as this character gets some XP for the bugged level it should also fix itself.

I have no idea anymore where this could be changed thats why adding a fallback in the character interface sounds good to me.
 
it would fix it. The character does have the XP but something set the skill level to this. I think it has something to do with the weird character creation. So if I just call the XP function once with 0 XP it will see the XP is enough to level up and it will auto correct itself. As soon as this character gets some XP for the bugged level it should also fix itself.
So did that captain effectively have zero leadership during the prior sea battle too? If so, that may unfairly affect the difficulty of the fight.
That would also point to the 'Fantom_AddFantomCharacter' function as I think that is how the character should have been generated.
And if not, then somehow the captain skills are being changed later. Which shouldn't be happening in the first place. o_O

I have no idea anymore where this could be changed thats why adding a fallback in the character interface sounds good to me.
Scary.... :eek:
 
So did that captain effectively have zero leadership during the prior sea battle too? If so, that may unfairly affect the difficulty of the fight.
That would also point to the 'Fantom_AddFantomCharacter' function as I think that is how the character should have been generated.
And if not, then somehow the captain skills are being changed later. Which shouldn't be happening in the first place. o_O


Scary.... :eek:
I'm looking into it.
My suspect is that the problem lies in the hireprocess.
Between the captain and the hireing the character is copied 2 times with different manipulations done to it.
I'm still figuring out why this all has to happen and I'm afriand to change to much in it now because it might result in some more weird things.
 
Think I found the reason already:
Code:
refEnCaptain.skill.Leadership = sti(refEnCaptain.skill.Leadership)-1;//MAXIMUS: he surrendered and his Leadership goes to a Devil
    refEnCaptain.skill.Grappling = sti(refEnCaptain.skill.Grappling)-1;//MAXIMUS: he surrendered and his Grappling goes to a Devil

in SurrenderAction. This only sets back the skill one while the XP isn't set back so this means the XP is suddenly way higher then it needs to be.
So this should be a reduce skill function which takes care of this and manages everything. Or even better it should just get a negative skill modifier.
Will see how to fix this.
 
My suspect is that the problem lies in the hireprocess.
Of course that character wasn't truly "hired"; it's just a prisoner in my cargo hold.
But indeed I recall that would be a copy of the original captain as that one would need to die for quest purposes.

That copied character may be shown in the Characters interface without ever being loaded in a 3D scene.
Maybe the PostInit is then not executed at all? So if you'd visit the cargo hold, he'd fix himself?
 
@Pieter Boelen do you know if it's possible to set a modifier to a skill without using an item?
 
Think I found the reason already:
Code:
refEnCaptain.skill.Leadership = sti(refEnCaptain.skill.Leadership)-1;//MAXIMUS: he surrendered and his Leadership goes to a Devil
    refEnCaptain.skill.Grappling = sti(refEnCaptain.skill.Grappling)-1;//MAXIMUS: he surrendered and his Grappling goes to a Devil

in SurrenderAction. This only sets back the skill one while the XP isn't set back so this means the XP is suddenly way higher then it needs to be.
So this should be a reduce skill function which takes care of this and manages everything. Or even better it should just get a negative skill modifier.
Will see how to fix this.
Do we need to keep that at all? :wp
 
yeah so changing the skill level actually caused these kind of problems in the past already ... But because back then the XP you needed for each skill level was the same it didn't matter that much.
So effectivly I need to find all instances where skill levels are reduced ... oh joy...
 
@Levis, I'd just like to double-check with you that it IS correct that a Pirate Captain of Level 7 could have only 1 skill in Leadership.
For reference, here's the officer definition:
Code:
   type = OFFIC_TYPE_CAPPIRATE;
   OfficerTypes.(type).skills.Leadership = 0;
   OfficerTypes.(type).skills.Fencing = 0;
   OfficerTypes.(type).skills.Fencing.importance = 10;
   OfficerTypes.(type).skills.Sailing = 0;
   OfficerTypes.(type).skills.Sailing.importance = 3;
   OfficerTypes.(type).skills.Accuracy = 0;
   OfficerTypes.(type).skills.Accuracy.importance = 3;
   OfficerTypes.(type).skills.Cannons = 0;
   OfficerTypes.(type).skills.Cannons.importance = 5;
   OfficerTypes.(type).skills.Grappling = 0;
   OfficerTypes.(type).skills.Grappling.importance = 8;
   OfficerTypes.(type).skills.Repair = 0;
   OfficerTypes.(type).skills.Defence = 0;
   OfficerTypes.(type).skills.Commerce = 0;
   OfficerTypes.(type).skills.Sneak = 0;
I assume that "Leadership = 0" means that pirate captains don't get any? Why are all those skill values 0 though?
Are those just "bonuses" so having "1" there would actually mean that pirate captains always get 1 EXTRA leadership point?

Based on that, does it mean that there having no 'importance' there for leadership at all, pirate captains basically won't gain leadership on level-ups?
Or at least, not "extra"?

It does seem rather strange to me to have captains without leadership. Especially pirate ones.
When the player is a pirate captain, you pretty much HAVE to switch to "Divide the Plunder".
That relies partly on the captain Leadership skill without the effect of officers.

If becoming a pirate means less of an effect on leadership when it becomes more important at the same time,
that seems a bit of an odd situation.... :confused:
 
Hmmm....Forgot to give pirate captains some leadership indeed. They will get some.
The other values are if they contribute anything to the mainplayer :).
When I have some more time I will add comments in all the files to explain the stuff :).
 
The other values are if they contribute anything to the mainplayer :).
Ah, of course! Forgot about that and got all confused because the file looks different now than they did before.
But that was indeed the whole point of that file originally existing at all. :facepalm

I think "captains" should never be a part of the player party anyway.
They should be either already in command of a ship or be a prisoner in your cargo hold.
So those numbers don't mean anything at all for captains, because any captain always contributes ALL skills, same as the player.
As per Leveling.c:
Code:
int CalcPartySkill(ref character, string skillName)
{
   int skillPoints = CalcCharacterSkill(character, skillName); // Captain can use ALL skills
   if(skillName != SKILL_FENCING) // Aconcagua: Fencing is a personal skill...
 
Yes I know. but for sake of easier reading I kept them in. And because some functions might ask for them.
 
Back
Top