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

Can someone else help me understand this part of the equipment code?

Tingyun

Corsair
Storm Modder
I am trying to understand how difficulty and rarity of weapons works in LAi_equip.c.

First it selects a random blade (that part I understand). Then we have this:

float rareconst = 1.0; //this multiplies the rare percentage, so that it's more possible to get rare blades
rareconst *= (1 + ((makefloat(GetDifficulty())-1)/3.0));

Which seems to make higher difficulties get more rare blades, but I have no idea how it is operating because I don't understand the below:

ref refBlade;
float randrare;

bool bFound = false;
while (!bFound && intRandBlade >= 0)
{
makeref(refBlade,BladeItems[intRandBlade]);
randrare = frnd();

bFound = refBlade.skipequip == false && randrare < stf(refBlade.rare)*rareconst; // && stf(refBlade.rare) != 0.0
intRandBlade--;
}
string blade = refBlade.id;
if (!bFound) blade = "blade4";
return blade;

Can anyone explain the above to me? If I just wanted blades picked randomly according to their rarity (with a 0.1 rare blade 10% as common as a 1.0 rarity blade), should I just remove the difficulty modifier, or comment out some part? I want to make it consistent across difficulty levels, so swashbuckler doesn't get more rare blades, and make sure it is operating linearly with the rarity setting in the items file.
 
It selects a random blade, then checks if it is 'valid' based on several criteria.
If it isn't, it keeps reducing the ID number and keeps trying until it finds one that does pass.

Try commenting out this line:
Code:
rareconst *= (1 + ((makefloat(GetDifficulty())-1)/3.0));
 
You can always add a line like
trace("show me somthing with var="+variable+" show me some more");
This will out put this to the compile.log file.
If you change variable to a variable you can see the value of it (if its a string, int, float or bool).
 
Back
Top