SRL Archive - Help

Easy queston


rj

2012-12-04 21:30:45

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,virtustop,virtuslegs,Crapier:integer; //7
Cmaul,Cstaff,Bmelee,Brange,Bprayer,Bmage,Bagility,Btheiving,Bhuntig,Bmining:integer; //10
Bsmithing,Bfishing,Bcooking,Bfiremaking,Bwoodcut,Dchain,Dlegs:integer

Laimonas171

2012-12-04 21:32:52

From: rjj95
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,virtustop,virtuslegs,Crapier:integer; //7
Cmaul,Cstaff,Bmelee,Brange,Bprayer,Bmage,Bagility,Btheiving,Bhuntig,Bmining:integer; //10
Bsmithing,Bfishing,Bcooking,Bfiremaking,Bwoodcut,Dchain,Dlegs:integer


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

Rezozo

2012-12-04 21:34:48

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

2012-12-04 21:44:41

So what would be the id statement for this

if pick 1 then begin
code here
end;

Olly

2012-12-04 22:08:09

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,