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.
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.