random create
Posted: Tue Jul 18, 2006 9:18 pm
how do i make if player collides with the enemy there is a 10% chance that coin will be created
int coinC;
coinC=rand(10);
if(coinC ==1)
{
createactor("Coin", 0, 0, "non
_relative");
void LeaveItem(int th, int fl, int ar, int br, int sl, int gl, int rb, int hp, int na)
{
int total = th + fl + ar + br + sl + gl + rb + hp + na;
double THC;
double FLC;
double ARC;
double BRC;
double SLC;
double GLC;
double RBC;
double HPC;
if (total != 0)
{
double itm = rand(100);
THC = (round(th) / total) * 100;
FLC = ((round(fl) / total) * 100) + THC;
ARC = ((round(ar) / total) * 100) + FLC;
BRC = ((round(br) / total) * 100) + ARC;
SLC = ((round(sl) / total) * 100) + BRC;
GLC = ((round(gl) / total) * 100) + SLC;
RBC = ((round(rb) / total) * 100) + GLC;
HPC = ((round(hp) / total) * 100) + RBC;
if (itm <= THC){CreateActor("TH");}
else if (itm <= FLC){CreateActor("FL");}
else if (itm <= ARC){CreateActor("AR");}
else if (itm <= BRC){CreateActor("BR");}
else if (itm <= SLC){CreateActor("SL");}
else if (itm <= GLC){CreateActor("GL");}
else if (itm <= RBC){CreateActor("RB");}
else if (itm <= HPC){CreateActor("HP");}
}
}
LeaveItem(0, 0, 0, 0, 0, 1, 0, 0, 9);