I need a tweak that I can't understand. More of a luxury request than a necessity.
I have a script that randomly drops items when they die.
The thing is, it looks like this.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
addhook("die","randomChance")
function randomChance(id,killer,weapon,x,y)
	local R=math.random(1,1800)
	
	
	if R==1 then
	-- RPG
	parse("spawnitem 47 "..player(id,"tilex").." "..player(id,"tiley").." ")
	parse("sv_soundpos \"SFsfx 4.wav\" "..player(id,"x").." "..player(id,"y").." ")
	parse("effect \"flare\" "..player(id,"x").." "..player(id,"y").." 5 16 150 150 255")
	
	elseif R==2 then
	-- RPG
	parse("spawnitem 47 "..player(id,"tilex").." "..player(id,"tiley").." ")
	parse("sv_soundpos \"SFsfx 4.wav\" "..player(id,"x").." "..player(id,"y").." ")
	parse("effect \"flare\" "..player(id,"x").." "..player(id,"y").." 5 16 150 150 255")
	
	elseif R==3 then
	-- RPG
	parse("spawnitem 47 "..player(id,"tilex").." "..player(id,"tiley").." ")
	parse("sv_soundpos \"SFsfx 4.wav\" "..player(id,"x").." "..player(id,"y").." ")
	parse("effect \"flare\" "..player(id,"x").." "..player(id,"y").." 5 16 150 150 255")
I wish it to be based on percentage from 1 to 100, e.g.
RPG - 1% chance
Grenade Launcher - 5% chance
- or -
(If range was from 1 to 1000)
RPG - 1 to 10
Grenade launcher - 11 to 50
I know that the first step would be to change math.random to 1,100
I wish to shorten it because doing it the long way, it takes up 986 lines and it is horror to customize it.