Changeset 659
- Timestamp:
- 01/30/08 07:42:27 (7 months ago)
- Files:
-
- tools/obj-tweak/calc.lua (modified) (1 diff)
- tools/obj-tweak/extract.lua (modified) (1 diff)
- tools/obj-tweak/injector.lua (modified) (1 diff)
- tools/obj-tweak/parser.lua (modified) (2 diffs)
- tools/obj-tweak/restrict.lua (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/obj-tweak/calc.lua
r417 r659 11 11 -- Init allocation data 12 12 for ind, item in pairs(k_info) do 13 local min = item.min or -114 local max = item.max or -115 13 16 if item.rarity then 17 for lev = 0, 100 do 18 local u_prob = item.rarity 19 if (lev < min) or (lev > max) then u_prob = 0 end 14 for i = 1, #item.alloc do 20 15 21 totals[lev] = totals[lev] + u_prob 22 alloc[lev][ind] = u_prob 23 end 16 local this = item.alloc[i] 17 local next = item.alloc[i+1] or { depth = 100, abundance = this.abundance } 18 19 local r1, r2 = this.abundance, next.abundance 20 local l1, l2 = this.depth, next.depth 21 22 if not r2 then 23 r2 = r1 24 end 25 26 if r1 then 27 for lev = l1, l2 do 28 local prob = 0 29 30 if lev == l1 then 31 prob = r1 32 elseif lev == l2 then 33 prob = r2 34 else 35 prob = r1 + ((lev - l1) * ((r2 - r1) / (l2 - l1))) 36 end 37 38 totals[lev] = totals[lev] + prob 39 alloc[lev][ind] = prob 40 end 41 end 24 42 end 25 43 tools/obj-tweak/extract.lua
r417 r659 1 #!/usr/ local/bin/lua511 #!/usr/bin/env lua5.1 2 2 3 3 k_info = dofile("parser.lua")("object.txt") tools/obj-tweak/injector.lua
r417 r659 1 #!/usr/ local/bin/lua511 #!/usr/bin/env lua5.1 2 2 3 3 k_info = dofile("parser.lua")(arg[1]) tools/obj-tweak/parser.lua
r417 r659 15 15 number = tonumber(number) or error("!") 16 16 17 k_info[number] = { }17 k_info[number] = { alloc = {} } 18 18 cur = number 19 19 … … 46 46 47 47 for rarity, min, max in string.gmatch(str, "(%d+):(%d+) to (%d+)") do 48 k_info[cur].min = tonumber(min) 49 k_info[cur].max = tonumber(max) 50 k_info[cur].rarity = tonumber(rarity) 48 table.insert(k_info[cur].alloc, { depth = tonumber(min), 49 abundance = tonumber(rarity) }) 50 table.insert(k_info[cur].alloc, { depth = tonumber(max) }) 51 end 52 53 for depth, abundance in string.gmatch(str, "L(%d+)/(%d+)") do 54 table.insert(k_info[cur].alloc, { depth = tonumber(depth), 55 abundance = tonumber(abundance) }) 51 56 end 52 57 tools/obj-tweak/restrict.lua
r417 r659 7 7 8 8 is_potion = is_tval(75) 9 is_food = is_tval(80) 10 is_scroll = is_tval(70) 9 11 is_wand = is_tval(65) 10 is_food = is_tval(80) 12 is_rod = is_tval(66) 13 is_staff = is_tval(55) 14 is_lite = is_tval(39) 11 15 12 return is_ food16 return is_lite
