Discuss this page on this page's Talk Page.
See forum post by alterecco.
Syntax | (extItmCreateRandomStats levelstring(s) criteria iterations) → table(s) |
---|---|
Argument List | levelstring(s): list of level strings used in calculating table contents. |
criteria: types of items that are valid for inclusion in calculations. | |
iterations: how many items to get during calculations. | |
Returns | Print out of table(s) to debug console and log file. |
Category | general helper functions |
Description | Shows rarity and level distributions when using itmCreateRandom |
(extItmCreateRandomStats '("c" "ucu") "*" 100)
Output produced:
[Iterations] 100 [Criteria] * [Level String] c LEVEL: 1 TOTAL: 100 COMMON: 54 UNCOMMON: 39 RARE: 7 VERYRARE: 0 [Iterations] 100 [Criteria] * [Level String] ucr LEVEL: 1 TOTAL: 32 COMMON: 15 UNCOMMON: 10 RARE: 7 VERYRARE: 0 LEVEL: 2 TOTAL: 53 COMMON: 26 UNCOMMON: 24 RARE: 3 VERYRARE: 0 LEVEL: 3 TOTAL: 15 COMMON: 6 UNCOMMON: 6 RARE: 3 VERYRARE: 0
(setq extItmCreateRandomStats (lambda (frequencies criteria iterations)
(block Nil (enum frequencies frequency (block ((data (list))) (for i 1 iterations (block (itm lvl lvlData freq index value) (setq itm (itmCreateRandom criteria frequency)) (setq lvl (itmGetLevel itm)) (if (not (setq lvlData (lookup data lvl 0))) (lnkAppend data (setq lvlData (list lvl 0 0 0 0))) ) (setq freq (itmGetFrequency itm)) (switch (eq freq 20) (setq index 1) (eq freq 10) (setq index 2) (eq freq 4) (setq index 3) (eq freq 1) (setq index 4) ) (setq lvlData (lnkReplace lvlData index (add (item lvlData index) 1))) (setq index (find data lvl 0)) (setq data (lnkReplace data index lvlData)) )) ;; pretty print (block (out (lvl 0) (cnt (count data)) (i 0)) (dbgLog "") (dbgOutput "") (setq out (cat "[Iterations] " iterations " [Criteria] " criteria " [Level String] " frequency)) (dbgLog out) (dbgOutput out) (loop (ls i cnt) (block (lvlData) (setq lvl (add lvl 1)) (if (setq lvlData (lookup data lvl 0)) (block Nil (setq i (add i 1)) (dbgLog "") (dbgOutput "") (setq out (cat "LEVEL: " (item lvlData 0) " TOTAL: " (add (item lvlData 1) (item lvlData 2) (item lvlData 3) (item lvlData 4) ))) (dbgLog out) (dbgOutput out) (dbgLog "") (dbgOutput "") (setq out (cat " COMMON: " (item lvlData 1))) (dbgLog out) (dbgOutput out) (setq out (cat " UNCOMMON: " (item lvlData 2))) (dbgLog out) (dbgOutput out) (setq out (cat " RARE: " (item lvlData 3))) (dbgLog out) (dbgOutput out) (setq out (cat " VERYRARE: " (item lvlData 4))) (dbgLog out) (dbgOutput out) (dbgLog "") (dbgOutput "") ) ) )) ) )) )
))
Return to functions list