//KB Tuning ships, changed parameters - removed aref chrship and changed by int _idx
//// NK PRS3 -->
void SetRandomStatsToShip(int _idx, int idx, int nat)
{
//KB - Tuning ships - changed calling parameters
if (_idx < 0) return;
aref chrship;
ref character;
if (_idx == GetMainCharacterIndex())
character = GetMainCharacter();
else
character = GetCharacter(_idx);
makearef(chrship, character.ship);
ref refShip = GetShipByType(idx); //this is our base
if (CheckAttribute(refShip, "unique")) {
if (sti(refShip.unique)) return; //if ship is unique, do not modify stats
}
if (CheckAttribute(chrship, "nomodstats")) {
if (sti(chrship.nomodstats)) return; //if flag set, do not mod stats
}
arSetRandomStatsToShip(chrship, idx, nat);
if (CheckAttribute(chrship, "standard")) {
if (sti(chrship.standard)) return; //if ship is "standard", do not tune her
}
//KB - Tuning ships
//KB Tuning ships <--
//KB - Tuning Ships - Adding random tuned chars to ships
InitTun(_idx);
int cost=0;
int time=0;
if (rand(99) <= sti(CPDISP) ) {ApplyTun(_idx,"cplates",cost,time) ;}
if (rand(99) <= sti(BCDISP) ) {ApplyTun(_idx,"bcannons",cost,time);}
if (rand(99) <= sti(GCDISP) ) { ApplyTun(_idx,"gchasers",cost,time);}
if (rand(99) <= sti(NSDISP) ) { ApplyTun(_idx,"nsails",cost,time);}
if (rand(99) <= sti(TMDISP) ) { ApplyTun(_idx,"ltopmasts",cost,time);}
if (rand(99) <= sti(SSDISP) ) {ApplyTun(_idx,"stays",cost,time);}
if (rand(99) <= sti(RHDISP) ) { ApplyTun(_idx,"rhull",cost,time);}
if (nat == PIRATE || character.nation == PIRATE ) {
if (rand(99) <= sti(FLUSHEDPROB_IFPIRATE)) { ApplyTun(_idx,"flushed",cost,time); }
}
else {
if (rand(99) <= sti(FLUSHEDPROB) ) ApplyTun(_idx,"flushed",cost,time);
}
}