Log in

View Full Version : Easy queston



rj
12-05-2012, 02:30 AM
I am currently making a generator that generates rewards (simulation). How would I make it pick a random variable?

Like pick a random one of these:
Bpartyhat,Wpartyhat,Gpartyhat,Rpartyhat,Ypartyhat, Ppartyhat,boxopened:integer; //6
pernixcowl,pernixtop,pernixlegs,virtushood,virtust op,virtuslegs,Crapier:integer; //7
Cmaul,Cstaff,Bmelee,Brange,Bprayer,Bmage,Bagility, Btheiving,Bhuntig,Bmining:integer; //10
Bsmithing,Bfishing,Bcooking,Bfiremaking,Bwoodcut,D chain,Dlegs:integer

Laimonas171
12-05-2012, 02:32 AM
I am currently making a generator that generates rewards (simulation). How would I make it pick a random variable?

Like pick a random one of these:
Bpartyhat,Wpartyhat,Gpartyhat,Rpartyhat,Ypartyhat, Ppartyhat,boxopened:integer; //6
pernixcowl,pernixtop,pernixlegs,virtushood,virtust op,virtuslegs,Crapier:integer; //7
Cmaul,Cstaff,Bmelee,Brange,Bprayer,Bmage,Bagility, Btheiving,Bhuntig,Bmining:integer; //10
Bsmithing,Bfishing,Bcooking,Bfiremaking,Bwoodcut,D chain,Dlegs:integer

case Random(4) of
1: Bpartyhat;
2: Wpartyhat;
3: Rpartyhat;
4: Ypartyhat;
// and so on
end;

Rezozo
12-05-2012, 02:34 AM
Exactly how I would have done it^^^. Just make the case statement bigger, fill it with everything, and add a larger random to fit it.

Its even more fun if you add a case statement in a case statement!
~Rez

rj
12-05-2012, 02:44 AM
So what would be the id statement for this

if pick 1 then begin
code here
end;

Olly
12-05-2012, 03:08 AM
Can even do it a different way like this

program new;

var
Items: TStringArray;

procedure DeclareItems;
begin
SetArrayLength(Items,10) //set how many items we have including 0 (we have 10 currently)
Items[0] := 'Bpartyhat';
Items[1] := 'Wpartyhat';
Items[2] := 'Gpartyhat';
Items[3] := 'Rpartyhat';
Items[4] := 'Ypartyhat';
Items[5] := 'Ppartyhat';
Items[6] := 'Bsmithing';
Items[7] := 'Bfishing';
Items[8] := 'Bcooking';
Items[9] := 'Bfiremaking';
end;

function PickRandomItems(Amount: Integer): String;
var
i : integer;
begin
Writeln('Our '+ ToStr(Amount) +' items are:');
Result := '';
for i := 1 to Amount do
Result := Result + Items[Random(Length(Items))]+', ';
end;

begin
DeclareItems;
writeln(PickRandomItems(3));
end.

Our 3 items are:
Bsmithing, Ppartyhat, Rpartyhat,