• 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 (fix attached) reversed skill bonus chance

Tingyun

Corsair
Storm Modder
@Levis : while working with the leveling perk stuff I stumbled on a small bug to correct.

Currently, a hired officer has a 90% chance of having 2 bonus skills, and a 10% chance of having none. There is no chance of having 1 bonus skill. I thought this was by design until now.

The reason is these two lines are reversed in Leveling.c:

if(val < NPC_ONE_BONUS_CHANCE) numbonus = 1;
if(val < (NPC_ONE_BONUS_CHANCE+NPC_TWO_BONUS_CHANCE)) numbonus = 2;

If the condition for 1 is satisfied, the condition for 2 is satisfied also, which is the source of the bug, 90% chance for two bonuses this way.

Those two need to be flipped around and two substituted for one like this:

if(val < (NPC_ONE_BONUS_CHANCE+NPC_TWO_BONUS_CHANCE)) numbonus = 1;
if(val < NPC_TWO_BONUS_CHANCE) numbonus = 2;

Then there will be:
10% no bonuses
60% only one bonus
30% two bonuses

Which is the goal I think. :) File attached if so.
 

Attachments

  • Leveling.c
    59 KB · Views: 110
@Levis I might be misunderstanding something, but I think there is a problem still. Here is the new version from your file, which seems aimed at 40% no bonus, 30% one bonus, 30% two bonuses:

Two bonus chance is 30, one bonus chance is 60, and then we have

if(val < NPC_TWO_BONUS_CHANCE) numbonus = 2;
if(val < NPC_ONE_BONUS_CHANCE) numbonus = 1;

But let's say we roll a 25, which is under the 30 two bonus chance. We will also be under the 60 one bonus chance, so won't we just get turned back to one bonus when the next line is read? Ie, you will never have 2 bonuses now, only ever 1?

I am still new to this coding stuff, I apologize if misunderstanding. :)
 
@Levis I might be misunderstanding something, but I think there is a problem still. Here is the new version from your file, which seems aimed at 40% no bonus, 30% one bonus, 30% two bonuses:

Two bonus chance is 30, one bonus chance is 60, and then we have

if(val < NPC_TWO_BONUS_CHANCE) numbonus = 2;
if(val < NPC_ONE_BONUS_CHANCE) numbonus = 1;

But let's say we roll a 25, which is under the 30 two bonus chance. We will also be under the 60 one bonus chance, so won't we just get turned back to one bonus when the next line is read? Ie, you will never have 2 bonuses now, only ever 1?

I am still new to this coding stuff, I apologize if misunderstanding. :)
ugh .... I put them the wrong way around again?
Like I said in the other topic it was early XD.

the should be the other way around.
 
Plus I'm actively trying to study how Levis coded things, and learn from him, so I pay extra attention. :)
Don't know if I'm the best teacher for coding :p.
Granted at the moment it's also my job and I'm programming some programs for a very large compagny but still ... :p
 
btw I was sleeping yesterday so here is the correct thing:
Code:
numbonus = 0;
if(val < (NPC_ONE_BONUS_CHANCE+NPC_TWO_BONUS_CHANCE)) numbonus = 2;
if(val < NPC_ONE_BONUS_CHANCE) numbonus = 1;

one_bonus_chance = 60
two_bonus_chance = 30
so:
if val = 0-59 it will return 1
(59 < 90) ==true
(59 < 60) == true
if val = 60-89 it will return 2
(89 < 90) ==true
(89 < 60) == false
if val = 90-100 it will return 0
(100< 90) ==false
(100< 60) == false
 
That's mathematically equivlant to what I proposed in my first post in this thread (same chances, different order), so you must be a good teacher after all. ;)
 
Back
Top