• 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 Leveling: Sudden Huge Amounts of XP Gained

Got any error logs?
 
Found it already. I was still trying to fix a bug but gave up but forgot to revert my code back. Uploaded a new version in the same post.
Now it should work.

Download that or put this file in the INTERFACE folder
 

Attachments

  • character.c
    58.1 KB · Views: 101
please let me know if you encounter any weird things or find things to hard ...

btw a known bug is the character interface sometimes showing over 100% as experience for a skill. Looking into that problem
 
Last edited:
btw a known bug is the character interface sometimes showing over 100% as experience for a skill. Looking into that problem
Is this bug what are you mentioning to fix in progres? Because this is very strange... xD
Just started new game with a free and personal play, and I was doing Malcom's training with the sword. Yeah... for some reason, accuracy was advancing through new levels of skill, more or less, but fencing not. I played against him several times, but I didn't get the new level.

Bizarre Experience.jpg
 
This is fix in progress yes
 
Is this bug what are you mentioning to fix in progres? Because this is very strange... xD
Just started new game with a free and personal play, and I was doing Malcom's training with the sword. Yeah... for some reason, accuracy was advancing through new levels of skill, more or less, but fencing not. I played against him several times, but I didn't get the new level.

View attachment 22074
this is very weird, I will look into it tonight....
 
this is very weird, I will look into it tonight....
I did make a "fix" for something similar a while back that would use a while loop to continue adding skills until you have less than 100% left.
Is that change of mine still in there? If so, that is especially strange. But since my "fix" isn't a proper fix anyway, I can understand you would have dropped it and are working on something more reliable. :doff
 
Yes the loop is still there....
 
@Levis: What function should I call to get a character's effective total skills with all contributions and whatchamacallits included?
I did the following test:
Code:
  ch = CharacterFromID("IslaMuelle Commander");
   TraceAndLog("Leadership = " + GetSummonSkillFromName(ch, SKILL_LEADERSHIP));
   TraceAndLog("Sailing = " + GetSummonSkillFromName(ch, SKILL_SAILING));
But that returns 1 for both, while these are his actual skills:
Code:
id = IslaMuelle Commander
skill =
  leadership = 4
  importance = 31
  fencing = 4
  importance = 30
  sailing = 5
  importance = 51
  accuracy = 4
  importance = 27
  cannons = 4
  importance = 23
  grappling = 3
  importance = 13
  repair = 4
  importance = 16
  defence = 4
  importance = 18
  commerce = 4
  importance = 17
  sneak = 3
  importance = 11
  freeskill = 0
So I would expect to see 4 and 5 to be returned.

This is apparently not a new issue though; during my false flag testing, I have been seeing the "personal visibility range" for all ships and they're all showing 440 yards.
As different characters have different skills, I would expect them to also show different ranges, as I am using this function:
Code:
float GetCharVisibilityRange(ref chr, int iRange)
{
   // higher leadership and sailing skills result in better vision
   float visibility_range = GetVisibilityRange(iRange);
   visibility_range += makefloat(GetSummonSkillFromName(chr, SKILL_LEADERSHIP) * GetSummonSkillFromName(chr, SKILL_SAILING) * 5); // KK
   return visibility_range;
}
Not a game-killing issue, but I'm definitely curious what's going on.
If necessary, I'll just get the straight skills from the character only, but that shouldn't be needed, should it?
 
@Pieter Boelen I believe this funciton is the one you need " CalcSummOnSkillFromName ".

I've got an improved version of the xp gain again. Fixed some of the bugs and edge cases. Also tried to improve the performance a bit.
Also took a good look at the xp needed to get to a certain level and I think I got a nice build up now and how much xp each level cost etc. Please let me know if this feels good too.

new version:
http://www.piratesahoy.net/threads/sudden-huge-amounts-of-xp-gained.24829/page-5#post-513685
 
Last edited:
@Pieter Boelen I believe this funciton is the one you need " CalcSummOnSkillFromName ".
Looking into this a bit further, I can find four functions that might fit the bill:
Code:
int GetCharacterSkill(ref character, string skillName) // <----- THIS ONE -------
{
   int value = CalcCharacterSkill(character, skillName); // <----- OR THAT ONE -------
   return ApplyFleetMali(character, skillName, value, false);
}
Code:
int GetSummonSkillFromName(ref chref, string skillName) // <----- OR THAT ONE -------
{
   int skillPoints = CalcSummOnSkillFromName(chref, skillName); // <----- OR THAT ONE -------
   return ApplyFleetMali(chref, skillName, skillPoints, true);
}
CalcCharacterSkill gets its data from a stored list, which is probably better for performance.
CalcSummOnSkillFromName calculates it all anew by cycling through all the character's passengers.

So new test case:
Code:
id = IslaMuelle Commander
skill =
  leadership = 6
  fencing = 9
  sailing = 1
  accuracy = 9
  cannons = 7
  grappling = 1
  repair = 1
  defence = 4
  commerce = 1
  sneak = 1
  freeskill = 0
Gives:
Code:
CalcCharacterSkill: Leadership = 6, Sailing = 1
GetCharacterSkill: Leadership = 6, Sailing = 1
GetSummonSkillFromName: Leadership = 1, Sailing = 1
CalcSummOnSkillFromName: Leadership = 0, Sailing = 0
Looks like the two list-based functions do return the correct values, but when is that list updated?
And the other ones that recalculate everything seem to return pretty wrong values. Skills of 0? Wha???

So for now, I'll use CalcCharacterSkill as that is probably the best one to use. But I do think those other two need looking at.
If indeed the list of character skill modifiers is correctly updated also for NPCs when needed, why don't we get rid of those other functions altogether?
If that is not the case, then CalcSummOnSkillFromName will need fixing because it should be returning the same numbers as GetCharacterSkill, shouldn't it?

Code:
void LevelUp_Cheat(ref rCharacter, bool real)
{
   if (real)
   {
     int xp = CalculateExperienceFromRank(sti(rCharacter.rank)+1)-CalculateExperienceFromRank(sti(rCharacter.rank));
     float mult = 2.0 - (1.0-((GetDifficulty()-1.0) / 4.0));
     AddCharacterExpNS(&rCharacter, makeint(xp*mult)); // NK do it via actual call 05-07-10
   }
How come difficulty is factored in there now? Just curious.
 
YIKES! I am doing some more false flag testing and got this:
upload_2015-7-29_8-1-18.png

Gained a huge amount of levels from ONE hit by cannon. I didn't get any skills to match by the Auto Skill System though.

EDIT: Doesn't happen anymore now that I've started a new game. That's some improvement at least. :wp
 
Last edited:
An error in character_init.c:
Code:
SetCharSkillImportance(pchar,1); //Levis make sure all skill importances are set right.
Should be:
Code:
SetCharSkillImportance(ch,1); //Levis make sure all skill importances are set right.
 
So for now, I'll use CalcCharacterSkill as that is probably the best one to use. But I do think those other two need looking at.
If indeed the list of character skill modifiers is correctly updated also for NPCs when needed, why don't we get rid of those other functions altogether?
If that is not the case, then CalcSummOnSkillFromName will need fixing because it should be returning the same numbers as GetCharacterSkill, shouldn't it?
That seems to be serving its purpose for now to give different characters different ranges:
Code:
FLAGS: The 'Diana' has visibility 1737.5 // UH????
FLAGS: The HMS 'Tribune' has visibility 1737.5 // Too high????
FLAGS: The HMS 'Cyclop' has visibility 1737.5 // Same again!
FLAGS: The HMS 'Charlestown Fort' has visibility 318.75  // <-------- LOL!!! -----------
FLAGS: The 'Diana' has visibility 293.75 // Now to normal, very strange
FLAGS: The 'Protector' has visibility 293.75
FLAGS: The HMS 'Tribune' has visibility 293.75
FLAGS: The HMS 'Tigress' has visibility 293.75
FLAGS: The HMS 'Cyclop' has visibility 293.75
FLAGS: The HMS 'Crocodile' has visibility 293.75
Odd that the first time the visibility is logged for the Diana, Tribune and Cyclop, a stupidly high number was returned.
This seems to have fixed itself later though. Could it be that some skill-related stuff isn't initialized until after entering 3D sailing mode?
I want to make sure this cannot break the flag detection, because suddenly high visibilities might trigger recognizing when that is not intended.

All ships have the same visibility though, which at first glance appears to be correct because their captains have Sailing = 1 and Leadership = 1.
However, some do have higher ranks:
Code:
skill =
  fencing = 2
  leadership = 1
  sailing = 1
  accuracy = 1
  cannons = 1
  grappling = 1
  repair = 1
  defence = 1
  commerce = 1
  sneak = 1
rank = 3
And:
Code:
skill =
  fencing = 1
  leadership = 1
  sailing = 1
  accuracy = 1
  cannons = 1
  grappling = 1
  repair = 1
  defence = 1
  commerce = 1
  sneak = 1
rank = 2
Note that they do not have the skills to match their rank. Only the rank 3 one has one extra skill point, but of course should have 4 assigned to something.

The fort does correctly show a somewhat higher range.
 
Back
Top