Advertisement
krusader74

Treasure.pal

Sep 10th, 2016
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.05 KB | None | 0 0
  1. /* Palamedes OD&D Treasure Generator v0.1 */
  2.  
  3. /* TREASURE TYPES */
  4.  
  5. Type_A_Land <- {"cp": 1--6: 50%, "sp": 1--6: 30%, "gp": 2--12: 35%, "gems": 6--36: 50%, "jewelry": 6--36: 50%, "maps or magic": MapsOrMagic(40%, 3, [])}
  6.  
  7. Type_A_Desert <- {"cp": 1--4: 20%, "sp": 1--4: 25%, "gp": 1--6: 30%, "gems": 10--40: 50%, "jewelry": 10--40: 50%, "maps or magic": flip(60%) ? 3 # Magic : []}
  8.  
  9. Type_A_Water <- {"cp": Nil, "sp": Nil, "gp": 5--30: 60%, "gems": 10--60: 60%, "jewelry": 10--60: 60%, "maps or magic": flip(50%) ? Map : []}
  10.  
  11. Type_B <- {"cp": 1--8: 50%, "sp": 1--6: 25%, "gp": 1--3: 25%, "gems": 1--6: 25%, "jewelry": 1--6: 25%, "maps or magic": flip(10%) ? Weapon : []}
  12.  
  13. Type_C <- {"cp": 1--12: 20%, "sp": 1--4: 30%, "gp": Nil, "gems": 1--4: 25%, "jewelry": 1--4: 25%, "maps or magic": MapsOrMagic(10%, 2, [])}
  14.  
  15. Type_D <- {"cp": 1--8: 10%, "sp": 1--12: 15%, "gp": 1--6: 60%, "gems": 1--8: 30%, "jewelry": 1--8: 30%, "maps or magic": MapsOrMagic(20%, 2, [Potion])}
  16.  
  17. Type_E <- {"cp": 1--10: 5%, "sp": 1--12: 30%, "gp": 1--8: 25%, "gems": 1--10: 10%, "jewelry": 1--10: 10%, "maps or magic": MapsOrMagic(30%, 3, [Scroll])}
  18.  
  19. Type_F <- {"cp": Nil, "sp": 2--20: 10%, "gp": 1--12: 45%, "gems": 2--24: 20%, "jewelry": 2--24: 20%, "maps or magic": MapsOrMagic_Type_F}
  20.  
  21. Type_G <- {"cp": Nil, "sp": Nil, "gp": 10--40: 75%, "gems": 3--18: 25%, "jewelry": 1--10: 25%, "maps or magic": MapsOrMagic(40%, 4, [Scroll])}
  22.  
  23. Type_H <- {"cp": 3--24: 25%, "sp": 1--100: 50%, "gp": 10--60: 75%, "gems": 1--100: 50%, "jewelry": 10--40: 50%, "maps or magic": MapsOrMagic(20%, 4, [Potion, Scroll])}
  24.  
  25. Type_I <- {"cp": Nil, "sp": Nil, "gp": Nil, "gems": 2--16: 50%, "jewelry": 2--16: 50%, "maps or magic": MapsOrMagic(20%, 1, [])}
  26.  
  27. MapsOrMagic <- flip(_1) ? any(_2) concat _3 : []
  28.  
  29. any <- {n1 set binom(_, 25%); n2 set _ - n1; (n1 # Maps) concat (n2 # Magic)}
  30.  
  31. MapsOrMagic_Type_F <- flip(35%) ? any_Type_F concat [Potion, Scroll] : []
  32.  
  33. any_Type_F <- {n1 set binom(3, 25%); n2 set 3 - n1; (n1 # Maps) concat (n2 # Non_Weapon)}
  34.  
  35. json_formatter <- if[_1 in ["cp", "sp", "gp"] => commify(1000*_2), otherwise, _2]
  36.  
  37. /* MAGIC ITEMS */
  38.  
  39. Magic <- lookup [ d%, ...
  40. 01--20 => Sword, ...
  41. 21--35 => Armor, ...
  42. 36--40 => Misc_Weapon, ...
  43. 41--65 => Potion, ...
  44. 66--85 => Scroll, ...
  45. 86--90 => Ring, ...
  46. 91--95 => Wand_Staff, ...
  47. 96--100 => Misc_Magic ]
  48.  
  49. Weapon <- lookup [d40, ...
  50. 01--20 => Sword, ...
  51. 21--35 => Armor, ...
  52. 36--40 => Misc_Weapon]
  53.  
  54. Non_Weapon <- Magic <- lookup [ d60 + 40, ...
  55. 41--65 => Potion, ...
  56. 66--85 => Scroll, ...
  57. 86--90 => Ring, ...
  58. 91--95 => Wand_Staff, ...
  59. 96--100 => Misc_Magic ]
  60.  
  61. No_Swords <- lookup [ d80 + 20, ...
  62. 21--35 => Armor, ...
  63. 36--40 => Misc_Weapon, ...
  64. 41--65 => Potion, ...
  65. 66--85 => Scroll, ...
  66. 86--90 => Ring, ...
  67. 91--95 => Wand_Staff, ...
  68. 96--100 => Misc_Magic ]
  69.  
  70. Sword <- lookup [ d%, ...
  71. 01--35 => "Sword +1", ...
  72. 36--40 => "Sword +1, +2 vs. Lycanthropes", ...
  73. 41--45 => "Sword +1, +2 vs. Magic-Users and Enchanted Monsters", ...
  74. 46--50 => "Sword +1, Locating Objects Ability", ...
  75. 51--60 => "Sword +1, +3 vs. Trolls (Clerics)", ...
  76. 61--65 => "Sword, Flaming: +1, +2 vs. Trolls (Pegasi, Hippogriffs, + Rocs), +3 vs. Undead (Treants)", ...
  77. 66--70 => "Sword +1, Wishes Included (2–8 Wishes)", ...
  78. 71--75 => "Sword +1, +3 vs. Dragons", ...
  79. 76--78 => "Sword +2", ...
  80. 79--80 => "Sword +2, Charm Person Ability", ...
  81. 81--82 => "Sword +3", ...
  82. 83 => "Sword, One Life Energy Draining Ability", ...
  83. 84--100 => "Sword -2 (Cursed Sword)" ]
  84.  
  85. Armor <- lookup [ d%, ...
  86. 01--30 => "Shield +1", ...
  87. 31--60 => "Armor +1", ...
  88. 61--75 => "Armor & Shield +1", ...
  89. 76--83 => "Shield +2", ...
  90. 84--90 => "Armor +2", ...
  91. 91--97 => "Armor & Shield +2", ...
  92. 98--100 => "Shield +3" ]
  93.  
  94. Misc_Weapon <- lookup [ z%, ...
  95. 01--25 => "10 Magic Arrows", ...
  96. 26--40 => 3d10 + " Magic Arrows", ...
  97. 41--55 => "Dagger +1 vs Man-Sized Opponents, +2 vs Goblins and Kobolds", ...
  98. 56--60 => "Dagger +2 vs Man-Sized Opponents, +3 vs Orcs, Goblins and Kobolds", ...
  99. 61--65 => "Magic Bow", ...
  100. 66--70 => "Axe +1", ...
  101. 71--80 => "Mace +2", ...
  102. 81--85 => "War Hammer +1", ...
  103. 86--89 => "War Hammer +2", ...
  104. 90 => "War Hammer +3, 6 in. Throwing Range with Return", ...
  105. 91--96 => "Spear +1", ...
  106. 97--99 => "Spear +2", ...
  107. 00 => "Spear +3"]
  108.  
  109. Potion <- "Potion of " + Potion_Lu
  110.  
  111. Potion_Lu <- lookup[ d%, ...
  112. 01--04 => "Growth", 49--52 => "Clairvoyance", ...
  113. 05--08 => "Diminution", 53--55 => "Clairaudience", ...
  114. 09--12 => "Giant Strength", 56--60 => "Animal Control", ...
  115. 13--16 => "Invisibility", 61--64 => "Undead Control", ...
  116. 17--20 => "Gaseous Form", 65--68 => "Plant Control", ...
  117. 21--24 => "Polymorph (Self)", 69--72 => "Human Control", ...
  118. 25--28 => "Speed", 73--76 => "Giant Control", ...
  119. 29--32 => "Levitation", 77--80 => "Dragon Control*", ...
  120. 33--36 => "Flying", 81--84 => "Poison**", ...
  121. 37--38 => "ESP", 85--88 => "Invulnerability", ...
  122. 39--40 => "Delusion", 89--92 => "Fire Resistance", ...
  123. 41--44 => "Healing", 93--96 => "Treasure Finding", ...
  124. 45--48 => "Longevity", 97--100 => "Heroism" ]
  125.  
  126. Potion_Fn <- {"*": "Referee to roll to determine which of the six types of Dragons will be controlled. " + Dragon_Type, "**": "Referee will mislead by naming any of the other Potions, but if carefully questioned should give it a singular feature."}
  127.  
  128. Dragon_Type <- choose["White", "Black", "Green", "Blue", "Red", "Golden"]
  129.  
  130. Scroll <- "Scroll of " + Scroll_Lu
  131.  
  132. Scroll_Lu <- lookup [ d%, ...
  133. 01--20 => "1 Spell", 61--70 => "Protection: Lycanthropes", ...
  134. 21--35 => "2 Spells", 71--80 => "Protection: Undead", ...
  135. 36--45 => "3 Spells", 81--90 => "Protection: Elementals", ...
  136. 46--50 => "7 Spells", 91--100 => "Protection: Magic", ...
  137. 51--60 => "1 Curse*" ]
  138.  
  139. /* There is a 25% chance that any scroll of spells found will contain those usable by clerics. */
  140.  
  141. Scroll_Fn <- {"*": "The referee must take extreme care in handling all Scrolls with an eye towards duping the players when a Curse Scroll is found. The curse takes effect immediately upon reading the Scroll; therefore having non-Curse Scrolls disappear on occasion if not identified will help to force reading of Curse Scrolls. To determine the type of curse use the table below: " + Curse}
  142.  
  143. Curse <- lookup [ d8, ...
  144. 1--2 => "Any monster of the referee’s choice", ...
  145. 3--4 => "Disease, fatal in 3 turns unless healed", ...
  146. 5--6 => "Polymorph to insect of referee’s choice", ...
  147. 7 => "Transportation 1,000 miles, random direction", ...
  148. 8 => "Transportation to another planet" ]
  149.  
  150. Ring <- "Ring of " + Ring_Lu
  151.  
  152. Ring_Lu <- lookup [ z%, ...
  153. 01--09 => "Invisibility", 81--85 => "Protection, 5’ r.", ...
  154. 10--15 => "Mammal Control", 86--90 => "Regeneration", ...
  155. 16--21 => "Human Control", 91--92 => "Djinn Summoning", ...
  156. 22--30 => "Weakness", 93--94 => "Telekinesis", ...
  157. 31--39 => "Protection", 95--96 => "X-Ray Vision", ...
  158. 40--49 => "Three Wishes", 97--98 => "Spell Turning", ...
  159. 50--60 => "Delusion", 99 => "Spell Storing", ...
  160. 61--70 => "Water Walking", 00 => "Many Wishes (" + 4d6 + ")", ...
  161. 71--80 => "Fire Resistance" ]
  162.  
  163. Wand_Staff <- lookup [ z%, ...
  164. 01--15 => "Wand of Metal Detection", 61--65 => "Wand of Polymorph", ...
  165. 16--20 => "Wand of Enemy Detection", 66--70 => "Wand of Negation", ...
  166. 21--25 => "Wand of Magic Detection", 71--80 => "Staff of Healing*", ...
  167. 26--30 => "Wand of Secret Doors & Traps Detection", 81--85 => "Staff of Commanding**", ...
  168. 31--35 => "Wand of Illusion", 86--90 => "Snake Staff*", ...
  169. 36--40 => "Wand of Fear", 91--95 => "Staff of Striking**", ...
  170. 41--45 => "Wand of Cold", 96--97 => "Staff of Withering*", ...
  171. 46--50 => "Wand of Paralyzation", 98--99 => "Staff of Power***", ...
  172. 51--55 => "Wand of Fire Balls", 00 => "Staff of Wizardry***" ]
  173.  
  174. Wand_Staff_Fn <- {"*": "Clerics only can employ", "**": "Clerics and Magic-Users may employ", "***": "Magic-Users only may employ"}
  175.  
  176. Misc_Magic <- lookup[ z%, ...
  177. 01--04 => "Crystal Ball", ...
  178. 05--06 => "Crystal Ball with Clairaudience", ...
  179. 07 => "Crystal Ball with ESP", ...
  180. 08--12 => "Medallion of ESP, 3” Range*", ...
  181. 13--15 => "Medallion of ESP, 9” Range*", ...
  182. 16--18 => "Amulet vs. Crystal Balls and ESP*", ...
  183. 19--24 => "Scarab of Protection from Evil High Priests*", ...
  184. 25--29 => "Bag of Holding*", ...
  185. 30 => "Censer Controlling Air Elementals", ...
  186. 31 => "Stone Controlling Earth Elementals", ...
  187. 32 => "Brazier Commanding Fire Elementals", ...
  188. 33 => "Bowl Commanding Water Elementals", ...
  189. 34--35 => "Efreet Bottle*", ...
  190. 36--38 => "Displacer Cloak*", ...
  191. 39--47 => "Elven Cloak and Boots*", ...
  192. 48--52 => "Boots of Speed*", ...
  193. 53--57 => "Boots of Levitation*", ...
  194. 58--62 => "Boots of Traveling and Leaping*", ...
  195. 63--67 => "Broom of Flying", ...
  196. 68--72 => "Helm of Reading Magic and Languages*", ...
  197. 73--75 => "Helm of Telepathy*", ...
  198. 76 => "Helm of Teleportation", ...
  199. 77--87 => "Helm of Chaos (Law)*", ...
  200. 88 => "Flying Carpet*", ...
  201. 89 => "Drums of Panic, 24” Range*", ...
  202. 90 => "Horn of Blasting, 10” Range*", ...
  203. 91--97 => "Gauntlets of Ogre Power*", ...
  204. 98--99 => "Girdle of Giant Strength*", ...
  205. 00 => "Mirror of Life Trapping" ]
  206.  
  207. Misc_Magic_Fn <- {"*": "Usable by all classes"}
  208.  
  209. /* MAPS */
  210.  
  211. Maps <- "Map to " + Maps_Lu
  212.  
  213. Maps_Lu <- lookup [d%, ...
  214. 01--60 => Treasure_Map, ...
  215. 61--90 => stringify(Magic_Map, " & "), ...
  216. 91--100 => Magic_Treasure_Map ]
  217.  
  218. Treasure_Map_1 <- commify(10000 * d4) + " Silver"
  219. Treasure_Map_2 <- commify( 1000 * 5d6) + " Gold"
  220. Treasure_Map_3 <- Treasure_Map_1 + " & " + Treasure_Map_2
  221. Treasure_Map_4 <- Treasure_Map_1 + " & " + 2d10 + " Gems"
  222. Treasure_Map_5 <- Treasure_Map_2 + " & " + 5d6 + " Gems"
  223. Treasure_Map_6 <- Treasure_Map_3 + " & " + d% + " Gems"
  224. Treasure_Map_7 <- 10d6 + " Gems & " + 2d10 + " Jewelry"
  225. Treasure_Map_8 <- Treasure_Map_3 + " & " + Treasure_Map_7
  226.  
  227. Treasure_Map <- lookup [d8, ...
  228. 1 => Treasure_Map_1, ...
  229. 2 => Treasure_Map_2, ...
  230. 3 => Treasure_Map_3, ...
  231. 4 => Treasure_Map_4, ...
  232. 5 => Treasure_Map_5, ...
  233. 6 => Treasure_Map_6, ...
  234. 7 => Treasure_Map_7, ...
  235. 8 => Treasure_Map_8 ]
  236.  
  237. Magic_Map_1 <- [Magic]
  238. Magic_Map_4 <- 2 # Magic
  239. Magic_Map_6 <- 2 # No_Swords
  240. Magic_Map_7 <- (4 # Magic) concat [Potion]
  241. Magic_Map_8 <- (5 # Magic) concat [Scroll, Potion]
  242.  
  243. Magic_Map <- lookup [d8, ...
  244. 1--3 => Magic_Map_1, ...
  245. 4--5 => Magic_Map_4, ...
  246. 6 => Magic_Map_6, ...
  247. 7 => Magic_Map_7, ...
  248. 8 => Magic_Map_8 ]
  249.  
  250. Magic_Treasure_Map <- lookup [d8, ...
  251. 1 => Treasure_Map_1 + " & " + Magic_Map_1, ...
  252. 2 => Treasure_Map_2 + " & " + Magic_Map_1, ...
  253. 3 => Treasure_Map_3 + " & " + Magic_Map_4, ...
  254. 4 => Treasure_Map_7 + " & " + Magic_Map_6 + " (already there)", ...
  255. 5 => Treasure_Map_5 + " & " + Magic_Map_4, ...
  256. 6 => Treasure_Map_1 + " & " + Magic_Map_1 + " (already there)", ...
  257. 7 => Treasure_Map_6 + " & " + Magic_Map_8, ...
  258. 8 => Treasure_Map_8 + " & " + Magic_Map_7 ]
  259.  
  260. /* SWORDS */
  261.  
  262. TODO
  263.  
  264. /* GEMS */
  265.  
  266. gemvalue <- {"10":1,"50":2,"100":3,"500":4,"1000":5,"5000":6,"10000":7,"25000":8,"50000":9,"100000":10,"500000":11}
  267.  
  268. gemprob <- censor(p(geom(5/6) + (pick [1 => 10%, 2 => 15%, 3 => 50%, 4 => 15%, 5 => 10%])), 1, 11)
  269.  
  270. Gem <- pick(gemprob after gemvalue)
  271.  
  272. /* JEWELRY */
  273.  
  274. TODO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement