Loading...
  OR  Zero-K Name:    Password:   

Post edit history

Game mode random gun

To display differences between versions, select one or more edits in the list using checkboxes and click "diff selected"
Post edit history
Date Editor Before After
6/30/2024 4:46:22 AMAUrankSmokeDragon before revert after revert
6/29/2024 3:32:01 PMAUrankSmokeDragon before revert after revert
Before After
1 this seems to be working great now.. perhaps i should now link the changes to metalcost 1 this seems to be working great now.. perhaps i should now link the changes to metalcost
2 \n 2 \n
3 need to fix this the code does not lower the values correctly
4 \n
3 added clamping and doubled the rarity of extremes: 5 added clamping and doubled the rarity of extremes:
4 [spoiler] 6 [spoiler]
5 {{{ 7 {{{
6 local function normalrandom() 8 local function normalrandom()
7 local u1 = math.random() 9 local u1 = math.random()
8 local u2 = math.random() 10 local u2 = math.random()
9 local z = math.sqrt(-2 * math.log(u1)) * math.cos(2 * math.pi * u2) 11 local z = math.sqrt(-2 * math.log(u1)) * math.cos(2 * math.pi * u2)
10 return z 12 return z
11 end 13 end
12 local function grp(minp, maxp) 14 local function grp(minp, maxp)
13 local mid = (minp + maxp) / 2 15 local mid = (minp + maxp) / 2
14 local range = maxp - minp 16 local range = maxp - minp
15 local z = normalrandom() 17 local z = normalrandom()
16 local perc = mid + (z * (range / 8)) 18 local perc = mid + (z * (range / 8))
17 perc = math.max(minp, math.min(maxp, perc)) 19 perc = math.max(minp, math.min(maxp, perc))
18 return perc / 100 20 return perc / 100
19 end 21 end
20 for name, ud in pairs(UnitDefs) do 22 for name, ud in pairs(UnitDefs) do
21 if ud.weapondefs then 23 if ud.weapondefs then
22 for _, wd in pairs(ud.weapondefs) do 24 for _, wd in pairs(ud.weapondefs) do
23 for key, value in pairs(wd) do 25 for key, value in pairs(wd) do
24 if type(value) == "number" and value > 3 then 26 if type(value) == "number" and value > 3 then
25 local minp = 25 27 local minp = 25
26 local maxp = 400 28 local maxp = 400
27 local rp = grp(minp, maxp) 29 local rp = grp(minp, maxp)
28 wd[key] = math.floor(value * rp) 30 wd[key] = math.floor(value * rp)
29 end 31 end
30 end 32 end
31 end 33 end
32 end 34 end
33 end 35 end
34 }}} 36 }}}
35 [/spoiler] 37 [/spoiler]