Changeset 659

Show
Ignore:
Timestamp:
01/30/08 07:42:27 (7 months ago)
Author:
takkaria
Message:

Try a new object allocation syntax.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/obj-tweak/calc.lua

    r417 r659  
    1111  -- Init allocation data 
    1212  for ind, item in pairs(k_info) do 
    13     local min = item.min or -1 
    14     local max = item.max or -1 
    1513 
    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 
    2015 
    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 
    2442    end 
    2543 
  • tools/obj-tweak/extract.lua

    r417 r659  
    1 #!/usr/local/bin/lua5
     1#!/usr/bin/env lua5.
    22 
    33k_info = dofile("parser.lua")("object.txt") 
  • tools/obj-tweak/injector.lua

    r417 r659  
    1 #!/usr/local/bin/lua5
     1#!/usr/bin/env lua5.
    22 
    33k_info = dofile("parser.lua")(arg[1]) 
  • tools/obj-tweak/parser.lua

    r417 r659  
    1515        number = tonumber(number) or error("!") 
    1616 
    17         k_info[number] = {
     17        k_info[number] = { alloc = {}
    1818        cur = number 
    1919 
     
    4646 
    4747      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) }) 
    5156      end 
    5257 
  • tools/obj-tweak/restrict.lua

    r417 r659  
    77 
    88is_potion = is_tval(75) 
     9is_food = is_tval(80) 
     10is_scroll = is_tval(70) 
    911is_wand = is_tval(65) 
    10 is_food = is_tval(80) 
     12is_rod = is_tval(66) 
     13is_staff = is_tval(55) 
     14is_lite = is_tval(39) 
    1115 
    12 return is_food 
     16return is_lite