Advertisement
poikilos

partial rewrite of tsm_pyramids by oldcoder (vs MT6 200227)

Mar 12th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 114.33 KB | None | 0 0
  1. Common subdirectories: /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/locale and ../games/ENLIVEN/mods/codercore/tsm_pyramids/locale
  2. Common subdirectories: /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/models and ../games/ENLIVEN/mods/codercore/tsm_pyramids/models
  3. Common subdirectories: /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/sounds and ../games/ENLIVEN/mods/codercore/tsm_pyramids/sounds
  4. Common subdirectories: /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/src and ../games/ENLIVEN/mods/codercore/tsm_pyramids/src
  5. Common subdirectories: /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/textures and ../games/ENLIVEN/mods/codercore/tsm_pyramids/textures
  6. Only in ../games/Bucket_Game/mods/codercore/tsm_pyramids: 00README
  7. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/baseinit.lua /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/baseinit.lua
  8. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/baseinit.lua 2019-06-29 04:19:19.000000000 -0400
  9. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/baseinit.lua 2020-03-07 00:17:37.000000000 -0500
  10. @@ -1,177 +1,474 @@
  11. -pyramids = {}
  12. +local S = minetest.get_translator("tsm_pyramids")
  13. +
  14. +-- Pyramid width (must be an odd number)
  15. +local PYRA_W = 23
  16. +-- Pyramid width minus 1
  17. +local PYRA_Wm = PYRA_W - 1
  18. +-- Half of (Pyramid width minus 1)
  19. +local PYRA_Wh = PYRA_Wm / 2
  20. +
  21. +-- Minimum and maximum spawn heights
  22. +local PYRA_MIN_Y = 3
  23. +local PYRA_MAX_Y = 500
  24. +
  25. +tsm_pyramids = {}
  26.  
  27. dofile(minetest.get_modpath("tsm_pyramids").."/mummy.lua")
  28. dofile(minetest.get_modpath("tsm_pyramids").."/nodes.lua")
  29. dofile(minetest.get_modpath("tsm_pyramids").."/room.lua")
  30.  
  31. -local chest_stuff = {
  32. - {name="default:apple", max = 3},
  33. - {name="farming:bread", max = 3},
  34. - {name="default:steel_ingot", max = 2},
  35. - {name="default:gold_ingot", max = 2},
  36. - {name="default:diamond", max = 1},
  37. - {name="default:pick_steel", max = 1},
  38. - {name="default:pick_diamond", max = 1}
  39. +local mg_name = minetest.get_mapgen_setting("mg_name")
  40.  
  41. +local chest_stuff = {
  42. + normal = {
  43. + {name="default:steel_ingot", max = 3},
  44. + {name="default:copper_ingot", max = 3},
  45. + {name="default:gold_ingot", max = 2},
  46. + {name="default:diamond", max = 1},
  47. + {name="default:pick_steel", max = 1},
  48. + },
  49. + desert_stone = {
  50. + {name="default:mese_crystal", max = 4},
  51. + {name="default:gold_ingot", max = 10},
  52. + {name="default:pick_diamond", max = 1},
  53. + },
  54. + desert_sandstone = {
  55. + {name="default:apple", max = 1},
  56. + {name="default:stick", max = 64},
  57. + {name="default:acacia_bush_sapling", max = 1},
  58. + {name="default:paper", max = 9},
  59. + {name="default:shovel_bronze", max = 1},
  60. + {name="default:pick_mese", max = 1},
  61. + },
  62. + sandstone = {
  63. + {name="default:obsidian_shard", max = 5},
  64. + {name="default:apple", max = 3},
  65. + {name="default:blueberries", max = 9},
  66. + {name="default:glass", max = 64},
  67. + {name="default:bush_sapling", max = 1},
  68. + {name="default:pick_bronze", max = 1},
  69. + },
  70. }
  71.  
  72. -function pyramids.fill_chest(pos)
  73. - minetest.after(2, function()
  74. - local n = minetest.get_node(pos)
  75. - if n and n.name and n.name == "default:chest" then
  76. - local meta = minetest.get_meta(pos)
  77. - local inv = meta:get_inventory()
  78. - inv:set_size("main", 8*4)
  79. - if math.random(1,10) < 7 then return end
  80. - local stacks = {}
  81. - if minetest.get_modpath("treasurer") ~= nil then
  82. - stacks = treasurer.select_random_treasures(3,7,9,{"minetool", "food", "crafting_component"})
  83. - else
  84. - for i=0,2,1 do
  85. - local stuff = chest_stuff[math.random(1,#chest_stuff)]
  86. - if stuff.name == "farming:bread" and not minetest.get_modpath("farming") then stuff = chest_stuff[1] end
  87. - table.insert(stacks, {name=stuff.name, count = math.random(1,stuff.max)})
  88. - end
  89. - end
  90. - for s=1,#stacks do
  91. - if not inv:contains_item("main", stacks[s]) then
  92. - inv:set_stack("main", math.random(1,32), stacks[s])
  93. - end
  94. - end
  95. -
  96. - end
  97. - end)
  98. -end
  99. -
  100. -local function add_spawner(pos)
  101. - minetest.set_node(pos, {name="tsm_pyramids:spawner_mummy"})
  102. - if not minetest.setting_getbool("only_peaceful_mobs") then pyramids.spawn_mummy({x=pos.x,y=pos.y,z=pos.z-2},2) end
  103. +if minetest.get_modpath("farming") then
  104. + table.insert(chest_stuff.desert_sandstone, {name="farming:bread", max = 3})
  105. + table.insert(chest_stuff.sandstone, {name="farming:bread", max = 4})
  106. + table.insert(chest_stuff.normal, {name="farming:cotton", max = 32})
  107. + table.insert(chest_stuff.desert_sandstone, {name="farming:seed_cotton", max = 3})
  108. + table.insert(chest_stuff.desert_sandstone, {name="farming:hoe_stone", max = 1})
  109. +else
  110. + table.insert(chest_stuff.normal, {name="farming:apple", max = 8})
  111. + table.insert(chest_stuff.normal, {name="farming:apple", max = 3})
  112. +end
  113. +if minetest.get_modpath("tnt") then
  114. + table.insert(chest_stuff.normal, {name="tnt:gunpowder", max = 6})
  115. + table.insert(chest_stuff.desert_stone, {name="tnt:gunpowder", max = 6})
  116. +else
  117. + table.insert(chest_stuff.normal, {name="farming:apple", max = 3})
  118. +end
  119. +
  120. +function tsm_pyramids.fill_chest(pos, stype, flood_sand, treasure_chance)
  121. + local sand = "default:sand"
  122. + if not treasure_chance then
  123. + treasure_chance = 100
  124. + end
  125. + if stype == "desert_sandstone" or stype == "desert_stone" then
  126. + sand = "default:desert_sand"
  127. + end
  128. + local n = minetest.get_node(pos)
  129. + local treasure_added = false
  130. + if n and n.name and n.name == "default:chest" then
  131. + local meta = minetest.get_meta(pos)
  132. + local inv = meta:get_inventory()
  133. + inv:set_size("main", 8*4)
  134. + local stacks = {}
  135. + -- Fill with sand in sand-flooded pyramids
  136. + if flood_sand then
  137. + table.insert(stacks, {name=sand, count = math.random(1,32)})
  138. + end
  139. + -- Add treasures
  140. + if math.random(1,100) <= treasure_chance then
  141. + if minetest.get_modpath("treasurer") ~= nil then
  142. + stacks = treasurer.select_random_treasures(3,7,9,{"minetool", "food", "crafting_component"})
  143. + else
  144. + for i=0,2,1 do
  145. + local stuff = chest_stuff.normal[math.random(1,#chest_stuff.normal)]
  146. + table.insert(stacks, {name=stuff.name, count = math.random(1,stuff.max)})
  147. + end
  148. + if math.random(1,100) <= 75 then
  149. + local stuff = chest_stuff[stype][math.random(1,#chest_stuff[stype])]
  150. + table.insert(stacks, {name=stuff.name, count = math.random(1,stuff.max)})
  151. + end
  152. + treasure_added = true
  153. + end
  154. + end
  155. + for s=1,#stacks do
  156. + if not inv:contains_item("main", stacks[s]) then
  157. + inv:set_stack("main", math.random(1,32), stacks[s])
  158. + end
  159. + end
  160. + end
  161. + return treasure_added
  162. +end
  163. +
  164. +local function add_spawner(pos, mummy_offset)
  165. + minetest.set_node(pos, {name="tsm_pyramids:spawner_mummy"})
  166. + if not minetest.settings:get_bool("only_peaceful_mobs") then
  167. + for i=1,2 do
  168. + tsm_pyramids.attempt_mummy_spawn(pos, false)
  169. + end
  170. + end
  171. end
  172.  
  173. local function can_replace(pos)
  174. - local n = minetest.get_node_or_nil(pos)
  175. - if n and n.name and minetest.registered_nodes[n.name] and not minetest.registered_nodes[n.name].walkable then
  176. - return true
  177. - elseif not n then
  178. - return true
  179. - else
  180. - return false
  181. - end
  182. -end
  183. -
  184. -local function underground(pos)
  185. - local p2 = pos
  186. - local cnt = 0
  187. - local mat = "desert_sand"
  188. - p2.y = p2.y-1
  189. - while can_replace(p2)==true do
  190. - cnt = cnt+1
  191. - if cnt > 25 then break end
  192. - if cnt>math.random(2,4) then mat = "desert_stone"end
  193. - minetest.set_node(p2, {name="default:"..mat})
  194. - p2.y = p2.y-1
  195. - end
  196. -end
  197. -
  198. -local function make_entrance(pos)
  199. - local gang = {x=pos.x+10,y=pos.y, z=pos.z}
  200. - for iy=2,3,1 do
  201. - for iz=0,6,1 do
  202. - minetest.remove_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz})
  203. - if iz >=3 and iy == 3 then
  204. - minetest.set_node({x=gang.x,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
  205. - minetest.set_node({x=gang.x+1,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
  206. - minetest.set_node({x=gang.x+2,y=gang.y+iy+1,z=gang.z+iz}, {name="default:sandstonebrick"})
  207. - end
  208. - end
  209. - end
  210. -end
  211. -
  212. -local function make(pos)
  213. - minetest.log("action", "Created pyramid at ("..pos.x..","..pos.y..","..pos.z..")")
  214. - for iy=0,10,1 do
  215. - for ix=iy,22-iy,1 do
  216. - for iz=iy,22-iy,1 do
  217. - if iy <1 then underground({x=pos.x+ix,y=pos.y,z=pos.z+iz}) end
  218. - minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name="default:sandstonebrick"})
  219. - for yy=1,10-iy,1 do
  220. - local n = minetest.get_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz})
  221. - if n and n.name and n.name == "default:desert_stone" then minetest.set_node({x=pos.x+ix,y=pos.y+iy+yy,z=pos.z+iz},{name="default:desert_sand"}) end
  222. - end
  223. - end
  224. - end
  225. - end
  226. -
  227. - pyramids.make_room(pos)
  228. - minetest.after(2, pyramids.make_traps, pos)
  229. - add_spawner({x=pos.x+11,y=pos.y+2, z=pos.z+17})
  230. - make_entrance({x=pos.x,y=pos.y, z=pos.z})
  231. + local n = minetest.get_node_or_nil(pos)
  232. + if n and n.name and minetest.registered_nodes[n.name] and not minetest.registered_nodes[n.name].walkable then
  233. + return true
  234. + elseif not n then
  235. + return true
  236. + else
  237. + return false
  238. + end
  239. +end
  240. +
  241. +local function make_foundation_part(pos, set_to_stone)
  242. + local p2 = pos
  243. + local cnt = 0
  244. + p2.y = p2.y-1
  245. + while can_replace(p2)==true do
  246. + cnt = cnt+1
  247. + if cnt > 25 then
  248. + break
  249. + end
  250. + table.insert(set_to_stone, table.copy(p2))
  251. + p2.y = p2.y-1
  252. + end
  253. end
  254.  
  255. -local perl1 = {SEED1 = 9130, OCTA1 = 1, PERS1 = 0.5, SCAL1 = 25} -- Values should match minetest mapgen V7 desert noise.
  256. +local function make_entrance(pos, rot, brick, sand, flood_sand)
  257. + local roffset_arr = {
  258. + { x=0, y=0, z=1 }, -- front
  259. + { x=-1, y=0, z=0 }, -- left
  260. + { x=0, y=0, z=-1 }, -- back
  261. + { x=1, y=0, z=0 }, -- right
  262. + }
  263. + local roffset = roffset_arr[rot + 1]
  264. + local way
  265. + if rot == 0 then
  266. + way = vector.add(pos, {x=PYRA_Wh, y=0, z=0})
  267. + elseif rot == 1 then
  268. + way = vector.add(pos, {x=PYRA_Wm, y=0, z=PYRA_Wh})
  269. + elseif rot == 2 then
  270. + way = vector.add(pos, {x=PYRA_Wh, y=0, z=PYRA_Wm})
  271. + else
  272. + way = vector.add(pos, {x=0, y=0, z=PYRA_Wh})
  273. + end
  274. + local max_sand_height = math.random(1,3)
  275. + for ie=0,6,1 do
  276. + local sand_height = math.random(1,max_sand_height)
  277. + for iy=2,3,1 do
  278. + -- dig hallway
  279. + local way_dir = vector.add(vector.add(way, {x=0,y=iy,z=0}), vector.multiply(roffset, ie))
  280. + if flood_sand and sand ~= "ignore" and iy <= sand_height and ie >= 3 then
  281. + minetest.set_node(way_dir, {name=sand})
  282. + else
  283. + minetest.remove_node(way_dir)
  284. + end
  285. + -- build decoration above entrance
  286. + if ie == 3 and iy == 3 then
  287. + local deco = {x=way_dir.x, y=way_dir.y+1,z=way_dir.z}
  288. + minetest.set_node(deco, {name=brick})
  289. + if rot == 0 or rot == 2 then
  290. + minetest.set_node(vector.add(deco, {x=-1, y=0, z=0}), {name=brick})
  291. + minetest.set_node(vector.add(deco, {x=1, y=0, z=0}), {name=brick})
  292. + else
  293. + minetest.set_node(vector.add(deco, {x=0, y=0, z=-1}), {name=brick})
  294. + minetest.set_node(vector.add(deco, {x=0, y=0, z=1}), {name=brick})
  295. + end
  296. + end
  297. + end
  298. + end
  299. +end
  300. +
  301. +local function make_pyramid(pos, brick, sandstone, stone, sand)
  302. + local set_to_brick = {}
  303. + local set_to_stone = {}
  304. + -- Build pyramid
  305. + for iy=0,math.random(10,PYRA_Wh),1 do
  306. + for ix=iy,PYRA_W-1-iy,1 do
  307. + for iz=iy,PYRA_W-1-iy,1 do
  308. + if iy < 1 then
  309. + make_foundation_part({x=pos.x+ix,y=pos.y,z=pos.z+iz}, set_to_stone)
  310. + end
  311. + table.insert(set_to_brick, {x=pos.x+ix,y=pos.y+iy,z=pos.z+iz})
  312. + end
  313. + end
  314. + end
  315. + minetest.bulk_set_node(set_to_stone , {name=stone})
  316. + minetest.bulk_set_node(set_to_brick, {name=brick})
  317. +end
  318. +
  319. +local function make(pos, brick, sandstone, stone, sand, ptype, room_id)
  320. + local bpos = table.copy(pos)
  321. + -- Build pyramid
  322. + make_pyramid(bpos, brick, sandstone, stone, sand)
  323. +
  324. + local rot = math.random(0, 3)
  325. + -- Build room
  326. + local ok, msg, flood_sand = tsm_pyramids.make_room(bpos, ptype, room_id, rot)
  327. + -- Place mummy spawner
  328. + local r = math.random(1,3)
  329. + -- 4 possible spawner positions
  330. + local spawner_posses = {
  331. + -- front
  332. + {{x=bpos.x+PYRA_Wh,y=bpos.y+2, z=bpos.z+5}, {x=0, y=0, z=2}},
  333. + -- left
  334. + {{x=bpos.x+PYRA_Wm-5,y=bpos.y+2, z=bpos.z+PYRA_Wh}, {x=-2, y=0, z=0}},
  335. + -- back
  336. + {{x=bpos.x+PYRA_Wh,y=bpos.y+2, z=bpos.z+PYRA_W-5}, {x=0, y=0, z=-2}},
  337. + -- right
  338. + {{x=bpos.x+5,y=bpos.y+2, z=bpos.z+PYRA_Wh}, {x=2, y=0, z=0}},
  339. + }
  340. + -- Delete the spawner position in which the entrance will be placed
  341. + table.remove(spawner_posses, (rot % 4) + 1)
  342. + add_spawner(spawner_posses[r][1], spawner_posses[r][2])
  343. + -- Build entrance
  344. + make_entrance(bpos, rot, brick, sand, flood_sand)
  345. + -- Done
  346. + minetest.log("action", "[tsm_pyramids] Created pyramid at "..minetest.pos_to_string(bpos)..".")
  347. + return ok, msg
  348. +end
  349. +
  350. +local perl1 = { SEED1 = 9130, OCTA1 = 1, PERS1 = 0.5, SCAL1 = 25 } -- Values should match minetest mapgen V7 desert noise
  351. +
  352. +local perlin1 -- perlin noise buffer
  353.  
  354. local function hlp_fnct(pos, name)
  355. - local n = minetest.get_node_or_nil(pos)
  356. - if n and n.name and n.name == name then
  357. - return true
  358. - else
  359. - return false
  360. - end
  361. + local n = minetest.get_node_or_nil(pos)
  362. + if n and n.name and n.name == name then
  363. + return true
  364. + else
  365. + return false
  366. + end
  367. end
  368. local function ground(pos, old)
  369. - local p2 = pos
  370. - while hlp_fnct(p2, "air") do
  371. - p2.y = p2.y -1
  372. - end
  373. - if p2.y < old.y then
  374. - return p2
  375. - else
  376. - return old
  377. - end
  378. + local p2 = table.copy(pos)
  379. + while hlp_fnct(p2, "air") do
  380. + p2.y = p2.y -1
  381. + end
  382. + if p2.y < old.y then
  383. + return {x=old.x, y=p2.y, z=old.z}
  384. + else
  385. + return old
  386. + end
  387. +end
  388. +
  389. +-- Select the recommended type of pyramid to use, based on the environment.
  390. +-- One of sandstone, desert sandstone, desert stone.
  391. +local select_pyramid_type = function(minp, maxp)
  392. + local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  393. +
  394. + local sand
  395. + local sands = {"default:sand", "default:desert_sand", "default:desert_stone"}
  396. + local p2
  397. + local psand = {}
  398. + local sand
  399. + local cnt = 0
  400. + local sand_cnt_max = 0
  401. + local sand_cnt_max_id
  402. + -- Look for sand or desert stone to place the pyramid on
  403. + for s=1, #sands do
  404. + cnt = 0
  405. + local sand_cnt = 0
  406. + sand = sands[s]
  407. + psand[s] = minetest.find_node_near(mpos, 25, sand)
  408. + while cnt < 5 do
  409. + cnt = cnt+1
  410. + mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  411. + local spos = minetest.find_node_near(mpos, 25, sand)
  412. + if spos ~= nil then
  413. + sand_cnt = sand_cnt + 1
  414. + if psand[s] == nil then
  415. + psand[s] = spos
  416. + end
  417. + end
  418. + if sand_cnt > sand_cnt_max then
  419. + sand_cnt_max = sand_cnt
  420. + sand_cnt_max_id = s
  421. + p2 = psand[s]
  422. + end
  423. + end
  424. + end
  425. +
  426. + -- Select the material type by the most prominent node type
  427. + -- E.g. if desert sand is most prominent, we place a desert sandstone pyramid
  428. + if sand_cnt_max_id then
  429. + sand = sands[sand_cnt_max_id]
  430. + else
  431. + sand = nil
  432. + p2 = nil
  433. + end
  434. + return sand, p2
  435. end
  436.  
  437. +-- Attempt to generate a pyramid in the generated area.
  438. +-- Up to one pyramid per mapchunk.
  439.  
  440. minetest.register_on_generated(function(minp, maxp, seed)
  441. - if maxp.y < 0 or maxp.y > 50 then return end
  442. - math.randomseed(seed)
  443. - local cnt = 0
  444. -
  445. - local perlin1 = minetest.env:get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
  446. - local noise1 = perlin1:get2d({x=minp.x,y=minp.y})--,z=minp.z})
  447. -
  448. - if noise1 > 0.25 or noise1 < -0.26 then
  449. - local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  450. -
  451. - local p2 = minetest.find_node_near(mpos, 10, {"default:desert_sand"})
  452. - while p2 == nil and cnt < 5 do
  453. - cnt = cnt+1
  454. - mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  455. - p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"})
  456. - end
  457. - if p2 == nil then return end
  458. - if p2.y < 0 then return end
  459. -
  460. - local off = 0
  461. - local opos1 = {x=p2.x+22,y=p2.y-1,z=p2.z+22}
  462. - local opos2 = {x=p2.x+22,y=p2.y-1,z=p2.z}
  463. - local opos3 = {x=p2.x,y=p2.y-1,z=p2.z+22}
  464. - local opos1_n = minetest.get_node_or_nil(opos1)
  465. - local opos2_n = minetest.get_node_or_nil(opos2)
  466. - local opos3_n = minetest.get_node_or_nil(opos3)
  467. - if opos1_n and opos1_n.name and opos1_n.name == "air" then
  468. - p2 = ground(opos1, p2)
  469. - end
  470. - if opos2_n and opos2_n.name and opos2_n.name == "air" then
  471. - p2 = ground(opos2, p2)
  472. - end
  473. - if opos3_n and opos3_n.name and opos3_n.name == "air" then
  474. - p2 = ground(opos3, p2)
  475. - end
  476. - p2.y = p2.y - 3
  477. - if p2.y < 0 then p2.y = 0 end
  478. - if minetest.find_node_near(p2, 85, {"default:water_source"}) ~= nil or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or minetest.find_node_near(p2, 85, {"default:sandstonebrick"}) ~= nil then return end
  479. -
  480. - if math.random(0,10) > 7 then return end
  481. - minetest.after(0.8,make,p2)
  482. - end
  483. + if maxp.y < PYRA_MIN_Y or maxp.y > PYRA_MAX_Y then return end
  484. +
  485. + -- TODO: Use Minetests pseudo-random tools
  486. + math.randomseed(seed)
  487. +
  488. + if not perlin1 then
  489. + perlin1 = minetest.get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
  490. + end
  491. + --[[ Make sure the pyramid doesn't bleed outside of maxp,
  492. + so it doesn't get placed incompletely by the mapgen.
  493. + This creates a bias somewhat, as this means there are some coordinates in
  494. + which pyramids cannot spawn. But it's still better to have broken pyramids.
  495. + ]]
  496. + local limit = function(pos, maxp)
  497. + pos.x = math.min(pos.x, maxp.x - PYRA_W+1)
  498. + pos.y = math.min(pos.y, maxp.y - PYRA_Wh)
  499. + pos.z = math.min(pos.z, maxp.z - PYRA_W+1)
  500. + return pos
  501. + end
  502. + local noise1 = perlin1:get_2d({x=minp.x,y=minp.y})
  503. +
  504. + if noise1 > 0.25 or noise1 < -0.26 then
  505. + -- Need a bit of luck to place a pyramid
  506. + if math.random(0,10) > 7 then
  507. + minetest.log("verbose", "[tsm_pyramids] Pyramid not placed, bad dice roll. minp="..minetest.pos_to_string(minp))
  508. + return
  509. + end
  510. + local sand, p2
  511. + sand, p2 = select_pyramid_type(minp, maxp)
  512. +
  513. + if p2 == nil then
  514. + minetest.log("verbose", "[tsm_pyramids] Pyramid not placed, no suitable surface. minp="..minetest.pos_to_string(minp))
  515. + return
  516. + end
  517. + -- Select the material type by the most prominent node type
  518. + -- E.g. if desert sand is most prominent, we place a desert sandstone pyramid
  519. + if sand_cnt_max_id then
  520. + sand = sands[sand_cnt_max_id]
  521. + end
  522. + if p2.y < PYRA_MIN_Y or p2.y > PYRA_MAX_Y then
  523. + minetest.log("info", "[tsm_pyramids] Not placed, Y out of range. p2="..minetest.pos_to_string(p2))
  524. + return
  525. + end
  526. + -- Now sink the pyramid until each corner of it is no longer floating in mid-air
  527. + p2 = limit(p2, maxp)
  528. + local oposses = {
  529. + {x=p2.x,y=p2.y-1,z=p2.z},
  530. + {x=p2.x+PYRA_Wm,y=p2.y-1,z=p2.z+PYRA_Wm},
  531. + {x=p2.x+PYRA_Wm,y=p2.y-1,z=p2.z},
  532. + {x=p2.x,y=p2.y-1,z=p2.z+PYRA_Wm},
  533. + }
  534. + for o=1, #oposses do
  535. + local opos = oposses[o]
  536. + local n = minetest.get_node_or_nil(opos)
  537. + if n and n.name and n.name == "air" then
  538. + local old = table.copy(p2)
  539. + p2 = ground(opos, p2)
  540. + end
  541. + end
  542. + -- Random bonus sinking
  543. + p2.y = math.max(p2.y - math.random(0,3), PYRA_MIN_Y)
  544. +
  545. + -- Bad luck, we have hit the chunk border!
  546. + if p2.y < minp.y then
  547. + minetest.log("info", "[tsm_pyramids] Pyramid not placed, sunken too much. p2="..minetest.pos_to_string(p2))
  548. + return
  549. + end
  550. +
  551. + -- Make sure the pyramid is not near a "killer" node, like water
  552. + local middle = vector.add(p2, {x=PYRA_Wh, y=0, z=PYRA_Wh})
  553. + if minetest.find_node_near(p2, 5, {"default:water_source"}) ~= nil or
  554. + minetest.find_node_near(vector.add(p2, {x=PYRA_W, y=0, z=0}), 5, {"default:water_source"}) ~= nil or
  555. + minetest.find_node_near(vector.add(p2, {x=0, y=0, z=PYRA_W}), 5, {"default:water_source"}) ~= nil or
  556. + minetest.find_node_near(vector.add(p2, {x=PYRA_W, y=0, z=PYRA_W}), 5, {"default:water_source"}) ~= nil or
  557. +
  558. + minetest.find_node_near(middle, PYRA_W, {"default:dirt_with_grass"}) ~= nil or
  559. + minetest.find_node_near(middle, 52, {"default:sandstonebrick", "default:desert_sandstone_brick", "default:desert_stonebrick"}) ~= nil or
  560. + minetest.find_node_near(middle, PYRA_Wh + 3, {"default:cactus", "group:leaves", "group:tree"}) ~= nil then
  561. + minetest.log("info", "[tsm_pyramids] Pyramid not placed, inappropriate node nearby. p2="..minetest.pos_to_string(p2))
  562. + return
  563. + end
  564. +
  565. + -- Bonus chance to spawn a sandstone pyramid in v6 desert because otherwise they would be too rare in v6
  566. + if (mg_name == "v6" and sand == "default:desert_sand" and math.random(1, 2) == 1) then
  567. + sand = "default:sand"
  568. + end
  569. +
  570. + -- Desert stone pyramids only generate in areas with almost no sand
  571. + if sand == "default:desert_stone" then
  572. + local nodes = minetest.find_nodes_in_area(vector.add(p2, {x=-1, y=-2, z=-1}), vector.add(p2, {x=PYRA_W+1, y=PYRA_Wh, z=PYRA_W+1}), {"group:sand"})
  573. + if #nodes > 5 then
  574. + sand = "default:desert_sand"
  575. + end
  576. + end
  577. +
  578. + -- Generate the pyramid!
  579. + if sand == "default:desert_sand" then
  580. + -- Desert sandstone pyramid
  581. + make(p2, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert_sandstone")
  582. + elseif sand == "default:sand" then
  583. + -- Sandstone pyramid
  584. + make(p2, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone")
  585. + else
  586. + -- Desert stone pyramid
  587. + make(p2, "default:desert_stonebrick", "default:desert_stone_block", "default:desert_stone", "ignore", "desert_stone")
  588. + end
  589. + end
  590. end)
  591. +
  592. +-- Add backwards-compability for nodes from the original pyramids mod
  593. +if minetest.get_modpath("pyramids") == nil then
  594. + -- Nodes
  595. + minetest.register_alias("pyramids:trap", "tsm_pyramids:trap")
  596. + minetest.register_alias("pyramids:trap_2", "tsm_pyramids:trap_2")
  597. + minetest.register_alias("pyramids:deco_stone1", "tsm_pyramids:deco_stone1")
  598. + minetest.register_alias("pyramids:deco_stone2", "tsm_pyramids:deco_stone2")
  599. + minetest.register_alias("pyramids:deco_stone3", "tsm_pyramids:deco_stone3")
  600. + minetest.register_alias("pyramids:spawner_mummy", "tsm_pyramids:spawner_mummy")
  601. +end
  602. +
  603. +minetest.register_chatcommand("spawnpyramid", {
  604. + description = S("Generate a pyramid"),
  605. + params = S("[<room_type>]"),
  606. + privs = { server = true },
  607. + func = function(name, param)
  608. + local player = minetest.get_player_by_name(name)
  609. + if not player then
  610. + return false, S("No player.")
  611. + end
  612. + local pos = player:get_pos()
  613. + pos = vector.round(pos)
  614. + local s = math.random(1,3)
  615. + local r = tonumber(param)
  616. + local room_id
  617. + if r then
  618. + room_id = r
  619. + end
  620. + local ok, msg
  621. + pos = vector.add(pos, {x=-PYRA_Wh, y=-1, z=0})
  622. + if s == 1 then
  623. + -- Sandstone
  624. + ok, msg = make(pos, "default:sandstonebrick", "default:sandstone", "default:sandstone", "default:sand", "sandstone", room_id)
  625. + elseif s == 2 then
  626. + -- Desert sandstone
  627. + ok, msg = make(pos, "default:desert_sandstone_brick", "default:desert_sandstone", "default:desert_stone", "default:desert_sand", "desert_sandstone", room_id)
  628. + else
  629. + -- Desert stone
  630. + ok, msg = make(pos, "default:desert_stonebrick", "default:desert_stone_block", "default:desert_stone", "ignore", "desert_stone", room_id)
  631. + end
  632. + if ok then
  633. + return true, S("Pyramid generated at @1.", minetest.pos_to_string(pos))
  634. + else
  635. + return false, msg
  636. + end
  637. + end,
  638. + }
  639. +)
  640. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/bucket-tsm_pyramids.patch /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/bucket-tsm_pyramids.patch
  641. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/bucket-tsm_pyramids.patch 2019-06-29 04:17:47.000000000 -0400
  642. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/bucket-tsm_pyramids.patch 2020-03-07 00:03:19.000000000 -0500
  643. @@ -1,50 +1,46 @@
  644. --- tsm_pyramids.old/init.lua
  645. +++ tsm_pyramids/init.lua
  646. -@@ -132,7 +132,7 @@
  647. +@@ -6,8 +6,10 @@
  648. + local PYRA_Wm = PYRA_W - 1
  649. + -- Half of (Pyramid width minus 1)
  650. + local PYRA_Wh = PYRA_Wm / 2
  651. +--- Minimum spawn height
  652. ++
  653. ++-- Minimum and maximum spawn heights
  654. + local PYRA_MIN_Y = 3
  655. ++local PYRA_MAX_Y = 500
  656.  
  657. + tsm_pyramids = {}
  658.  
  659. - minetest.register_on_generated(function(minp, maxp, seed)
  660. -- if maxp.y < 0 then return end
  661. -+ if maxp.y < 0 or maxp.y > 500 then return end
  662. - math.randomseed(seed)
  663. - local cnt = 0
  664. -
  665. -====== end of patch ======
  666. ---- tsm_pyramids.old/init.lua
  667. -+++ tsm_pyramids/init.lua
  668. -@@ -108,7 +108,7 @@
  669. - make_entrance({x=pos.x,y=pos.y, z=pos.z})
  670. +@@ -237,7 +239,8 @@
  671. + return ok, msg
  672. end
  673.  
  674. -local perl1 = {SEED1 = 9130, OCTA1 = 3, PERS1 = 0.5, SCAL1 = 250} -- Values should match minetest mapgen V6 desert noise.
  675. -+local perl1 = {SEED1 = 9130, OCTA1 = 1, PERS1 = 0.5, SCAL1 = 25} -- Values should match minetest mapgen V7 desert noise.
  676. ++local perl1 = { SEED1 = 9130, OCTA1 = 1, PERS1 = 0.5, SCAL1 = 25 } -- Values should match minetest mapgen V7 desert noise
  677. ++
  678. + local perlin1 -- perlin noise buffer
  679.  
  680. local function hlp_fnct(pos, name)
  681. - local n = minetest.get_node_or_nil(pos)
  682. -@@ -132,7 +132,7 @@
  683. -
  684. +@@ -310,8 +313,9 @@
  685.  
  686. + -- Attempt to generate a pyramid in the generated area.
  687. + -- Up to one pyramid per mapchunk.
  688. ++
  689. minetest.register_on_generated(function(minp, maxp, seed)
  690. -- if maxp.y < 0 or maxp.y > 500 then return end
  691. -+ if maxp.y < 0 or maxp.y > 50 then return end
  692. - math.randomseed(seed)
  693. - local cnt = 0
  694. +- if maxp.y < PYRA_MIN_Y then return end
  695. ++ if maxp.y < PYRA_MIN_Y or maxp.y > PYRA_MAX_Y then return end
  696.  
  697. -@@ -142,7 +142,7 @@
  698. - if noise1 > 0.25 or noise1 < -0.26 then
  699. - local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  700. -
  701. -- local p2 = minetest.find_node_near(mpos, 25, {"default:desert_sand"})
  702. -+ local p2 = minetest.find_node_near(mpos, 10, {"default:desert_sand"})
  703. - while p2 == nil and cnt < 5 do
  704. - cnt = cnt+1
  705. - mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  706. -@@ -169,7 +169,7 @@
  707. + -- TODO: Use Minetests pseudo-random tools
  708. + math.randomseed(seed)
  709. +@@ -350,8 +354,8 @@
  710. + if sand_cnt_max_id then
  711. + sand = sands[sand_cnt_max_id]
  712. + end
  713. +- if p2.y < PYRA_MIN_Y then
  714. +- minetest.log("info", "[tsm_pyramids] Pyramid not placed, too deep. p2="..minetest.pos_to_string(p2))
  715. ++ if p2.y < PYRA_MIN_Y or p2.y > PYRA_MAX_Y then
  716. ++ minetest.log("info", "[tsm_pyramids] Not placed, Y out of range. p2="..minetest.pos_to_string(p2))
  717. + return
  718. end
  719. - p2.y = p2.y - 3
  720. - if p2.y < 0 then p2.y = 0 end
  721. -- if minetest.find_node_near(p2, 25, {"default:water_source"}) ~= nil or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or minetest.find_node_near(p2, 52, {"default:sandstonebrick"}) ~= nil then return end
  722. -+ if minetest.find_node_near(p2, 85, {"default:water_source"}) ~= nil or minetest.find_node_near(p2, 22, {"default:dirt_with_grass"}) ~= nil or minetest.find_node_near(p2, 85, {"default:sandstonebrick"}) ~= nil then return end
  723. -
  724. - if math.random(0,10) > 7 then return end
  725. - minetest.after(0.8,make,p2)
  726. + -- Now sink the pyramid until each corner of it is no longer floating in mid-air
  727. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/depends.txt /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/depends.txt
  728. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/depends.txt 2019-03-16 19:53:10.000000000 -0400
  729. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/depends.txt 2020-03-07 00:17:26.000000000 -0500
  730. @@ -1,3 +1,7 @@
  731. +awards?
  732. +cmi?
  733. default
  734. +doc_items?
  735. farming?
  736. +tnt?
  737. treasurer?
  738. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/init.lua /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/init.lua
  739. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/init.lua 2018-12-22 00:56:36.000000000 -0500
  740. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/init.lua 2020-03-07 00:22:26.000000000 -0500
  741. @@ -1,7 +1,6 @@
  742. local modname = minetest.get_current_modname()
  743. local modpath = minetest.get_modpath (modname)
  744.  
  745. -if minetest.setting_getbool("enable_tsm_pyramids") or
  746. - minetest.setting_getbool("enable_wonder" ) then
  747. +if minetest.setting_getbool ("enable_tsm_pyramids") then
  748. dofile (modpath .. "/baseinit.lua")
  749. end
  750. Only in /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids: locale
  751. Common subdirectories: ../games/Bucket_Game/mods/codercore/tsm_pyramids/models and /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/models
  752. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/mummy.lua /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/mummy.lua
  753. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/mummy.lua 2015-02-07 09:12:28.000000000 -0500
  754. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/mummy.lua 2019-09-02 14:45:11.000000000 -0400
  755. @@ -1,4 +1,6 @@
  756. ---pyramids = {}
  757. +local S = minetest.get_translator("tsm_pyramids")
  758. +
  759. +local mod_cmi = minetest.get_modpath("cmi") ~= nil
  760.  
  761. local mummy_walk_limit = 1
  762. local mummy_chillaxin_speed = 1
  763. @@ -16,24 +18,24 @@
  764. local sound_hit = "mummy_hurt"
  765. local sound_dead = "mummy_death"
  766.  
  767. -local spawner_range = 17
  768. +local spawner_check_range = 17
  769. local spawner_max_mobs = 6
  770.  
  771. local function get_animations()
  772. - return {
  773. - stand_START = 74,
  774. - stand_END = 74,
  775. - sit_START = 81,
  776. - sit_END = 160,
  777. - lay_START = 162,
  778. - lay_END = 166,
  779. - walk_START = 74,
  780. - walk_END = 105,
  781. - mine_START = 74,
  782. - mine_END = 105,
  783. - walk_mine_START = 74,
  784. - walk_mine_END = 105
  785. - }
  786. + return {
  787. + stand_START = 74,
  788. + stand_END = 74,
  789. + sit_START = 81,
  790. + sit_END = 160,
  791. + lay_START = 162,
  792. + lay_END = 166,
  793. + walk_START = 74,
  794. + walk_END = 105,
  795. + mine_START = 74,
  796. + mine_END = 105,
  797. + walk_mine_START = 74,
  798. + walk_mine_END = 105
  799. + }
  800. end
  801.  
  802. local npc_model = {}
  803. @@ -46,292 +48,312 @@
  804. local ANIM_WALK_MINE = 5
  805. local ANIM_MINE = 6
  806.  
  807. -function hit(self)
  808. - prop = {
  809. - mesh = mummy_mesh,
  810. - textures = {"tsm_pyramids_mummy.png^tsm_pyramids_hit.png"},
  811. - }
  812. - self.object:set_properties(prop)
  813. - minetest.after(0.4, function()
  814. - prop = {textures = mummy_texture,}
  815. - self.object:set_properties(prop)
  816. - end)
  817. -end
  818. -
  819. -function mummy_update_visuals_def(self)
  820. - --local name = get_player_name()
  821. - visual = default_model_def
  822. - npc_anim = 0 -- Animation will be set further below immediately
  823. - --npc_sneak[name] = false
  824. - prop = {
  825. - mesh = mummy_mesh,
  826. - textures = mummy_texture,
  827. - --visual_size = {x=1, y=1, z=1},
  828. - }
  829. - self.object:set_properties(prop)
  830. -end
  831. -
  832. -MUMMY_DEF = {
  833. - physical = true,
  834. - collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
  835. - visual = "mesh",
  836. - visual_size = {x=8,y=8},
  837. - mesh = mummy_mesh,
  838. - textures = mummy_texture,
  839. - makes_footstep_sound = true,
  840. - npc_anim = 0,
  841. - timer = 0,
  842. - turn_timer = 0,
  843. - vec = 0,
  844. - yaw = 0,
  845. - yawwer = 0,
  846. - state = 1,
  847. - jump_timer = 0,
  848. - punch_timer = 0,
  849. - sound_timer = 0,
  850. - attacker = "",
  851. - attacking_timer = 0,
  852. - mob_name = "mummy"
  853. +local function hit(self)
  854. + local prop = {
  855. + mesh = mummy_mesh,
  856. + textures = {"tsm_pyramids_mummy.png^tsm_pyramids_hit.png"},
  857. + }
  858. + self.object:set_properties(prop)
  859. + minetest.after(0.4, function(self)
  860. + local prop = {textures = mummy_texture,}
  861. + if self ~= nil and self.object ~= nil then
  862. + self.object:set_properties(prop)
  863. + end
  864. + end, self)
  865. +end
  866. +
  867. +local function mummy_update_visuals_def(self)
  868. + npc_anim = 0 -- Animation will be set further below immediately
  869. + local prop = {
  870. + mesh = mummy_mesh,
  871. + textures = mummy_texture,
  872. + }
  873. + self.object:set_properties(prop)
  874. +end
  875. +
  876. +local MUMMY_DEF = {
  877. + hp_max = mummy_hp,
  878. + physical = true,
  879. + collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
  880. + visual = "mesh",
  881. + visual_size = {x=8,y=8},
  882. + mesh = mummy_mesh,
  883. + textures = mummy_texture,
  884. + makes_footstep_sound = true,
  885. + npc_anim = 0,
  886. + timer = 0,
  887. + turn_timer = 0,
  888. + vec = 0,
  889. + yaw = 0,
  890. + yawwer = 0,
  891. + state = 1,
  892. + jump_timer = 0,
  893. + punch_timer = 0,
  894. + sound_timer = 0,
  895. + envdmg_timer = 0,
  896. + attacker = "",
  897. + attacking_timer = 0,
  898. +
  899. + -- CMI stuff
  900. + -- Track last cause of damage for cmi.notify_die
  901. + last_damage_cause = { type = "unknown" },
  902. + _cmi_is_mob = true,
  903. + description = S("Mummy"),
  904. }
  905.  
  906. -spawner_DEF = {
  907. - hp_max = 1,
  908. - physical = true,
  909. - collisionbox = {0,0,0,0,0,0},
  910. - visual = "mesh",
  911. - visual_size = {x=3.3,y=3.3},
  912. - mesh = mummy_mesh,
  913. - textures = mummy_texture,
  914. - makes_footstep_sound = false,
  915. - timer = 0,
  916. - automatic_rotate = math.pi * 2.9,
  917. - m_name = "dummy"
  918. +local spawner_DEF = {
  919. + hp_max = 1,
  920. + physical = false,
  921. + pointable = false,
  922. + visual = "mesh",
  923. + visual_size = {x=3.3,y=3.3},
  924. + mesh = mummy_mesh,
  925. + textures = mummy_texture,
  926. + makes_footstep_sound = false,
  927. + timer = 0,
  928. + automatic_rotate = math.pi * 2.9,
  929. }
  930.  
  931. spawner_DEF.on_activate = function(self)
  932. - mummy_update_visuals_def(self)
  933. - self.object:setvelocity({x=0, y=0, z=0})
  934. - self.object:setacceleration({x=0, y=0, z=0})
  935. - self.object:set_armor_groups({immortal=1})
  936. + mummy_update_visuals_def(self)
  937. + self.object:set_velocity({x=0, y=0, z=0})
  938. + self.object:set_acceleration({x=0, y=0, z=0})
  939. + self.object:set_armor_groups({immortal=1})
  940.  
  941. end
  942.  
  943. spawner_DEF.on_step = function(self, dtime)
  944. - self.timer = self.timer + 0.01
  945. - local n = minetest.get_node_or_nil(self.object:getpos())
  946. - if self.timer > 1 then
  947. - if n and n.name and n.name ~= "tsm_pyramids:spawner_mummy" then
  948. - self.object:remove()
  949. - end
  950. - end
  951. + self.timer = self.timer + 0.01
  952. + local n = minetest.get_node_or_nil(self.object:get_pos())
  953. + if self.timer > 1 then
  954. + if n and n.name and n.name ~= "tsm_pyramids:spawner_mummy" then
  955. + self.object:remove()
  956. + end
  957. + end
  958. end
  959.  
  960. spawner_DEF.on_punch = function(self, hitter)
  961.  
  962. end
  963.  
  964. -MUMMY_DEF.on_activate = function(self)
  965. - mummy_update_visuals_def(self)
  966. - self.anim = get_animations()
  967. - self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
  968. - self.npc_anim = ANIM_STAND
  969. - self.object:setacceleration({x=0,y=-20,z=0})--20
  970. - self.state = 1
  971. - self.object:set_hp(mummy_hp)
  972. - self.object:set_armor_groups({fleshy=130})
  973. -end
  974. -
  975. -MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
  976. -
  977. - --attack as group
  978. - --[[for _,object in ipairs(minetest.env:get_objects_inside_radius(self.object:getpos(), 5)) do
  979. - if not object:is_player() then
  980. - if object:get_luaentity().name == "peaceful_npc:npc_def" then
  981. - object:get_luaentity().state = 3
  982. - object:get_luaentity().attacker = puncher:get_player_name()
  983. - end
  984. - end
  985. - end]]
  986. -
  987. - --if self.state ~= 3 then
  988. - --self.state = 3
  989. - self.attacker = puncher--:get_player_name()
  990. - --end
  991. -
  992. - if puncher ~= nil then
  993. - local sound = sound_hit
  994. - if self.object:get_hp() == 0 then sound = sound_dead end
  995. - minetest.sound_play(sound, {to_player = puncher:get_player_name(), loop = false, gain = 0.3})
  996. - if time_from_last_punch >= 0.45 then
  997. - hit(self)
  998. - --local dir = puncher:get_look_dir()
  999. - --self.direction = dir
  1000. - self.direction = {x=self.object:getvelocity().x, y=self.object:getvelocity().y, z=self.object:getvelocity().z}
  1001. - self.punch_timer = 0
  1002. - self.object:setvelocity({x=dir.x*mummy_chillaxin_speed,y=5,z=dir.z*mummy_chillaxin_speed})--self.object:setvelocity({x=dir.x*4,y=5,z=dir.z*4})
  1003. - if self.state == 1 then
  1004. - self.state = 8
  1005. - elseif self.state >= 2 then
  1006. - self.state = 9
  1007. - end
  1008. - end
  1009. - end
  1010. -
  1011. - if self.object:get_hp() == 0 then
  1012. - local obj = minetest.env:add_item(self.object:getpos(), mummy_drop.." "..math.random(0,3))
  1013. - end
  1014. +MUMMY_DEF.on_activate = function(self, staticdata, dtime_s)
  1015. + if mod_cmi then
  1016. + cmi.notify_activate(self, dtime_s)
  1017. + end
  1018. + mummy_update_visuals_def(self)
  1019. + self.anim = get_animations()
  1020. + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
  1021. + self.npc_anim = ANIM_STAND
  1022. + self.object:set_acceleration({x=0,y=-20,z=0})--20
  1023. + self.state = 1
  1024. + self.object:set_armor_groups({fleshy=130})
  1025. +end
  1026. +
  1027. +MUMMY_DEF.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
  1028. + if mod_cmi then
  1029. + cmi.notify_punch(self, puncher, time_from_last_punch, tool_capabilities, dir, damage)
  1030. + end
  1031. + self.attacker = puncher
  1032. +
  1033. + if damage > 0 then
  1034. + self.last_damage = {
  1035. + type = "punch",
  1036. + puncher = puncher,
  1037. + }
  1038. + end
  1039. + if puncher ~= nil then
  1040. + minetest.sound_play(sound_hit, {pos = self.object:get_pos(), loop = false, max_hear_distance = 10, gain = 0.4})
  1041. + if time_from_last_punch >= 0.45 then
  1042. + hit(self)
  1043. + self.direction = {x=self.object:get_velocity().x, y=self.object:get_velocity().y, z=self.object:get_velocity().z}
  1044. + self.punch_timer = 0
  1045. + self.object:set_velocity({x=dir.x*mummy_chillaxin_speed,y=5,z=dir.z*mummy_chillaxin_speed})
  1046. + if self.state == 1 then
  1047. + self.state = 8
  1048. + elseif self.state >= 2 then
  1049. + self.state = 9
  1050. + end
  1051. + end
  1052. + end
  1053. +end
  1054. +
  1055. +MUMMY_DEF.on_death = function(self, killer)
  1056. + minetest.sound_play(sound_dead, {pos = self.object:get_pos(), max_hear_distance = 10 , gain = 0.3})
  1057. + -- Drop item on death
  1058. + local count = math.random(0,3)
  1059. + if count > 0 then
  1060. + local pos = self.object:get_pos()
  1061. + pos.y = pos.y + 1.0
  1062. + minetest.add_item(pos, mummy_drop .. " " .. count)
  1063. + end
  1064. + if mod_cmi then
  1065. + cmi.notify_die(self, self.last_damage)
  1066. + end
  1067. end
  1068.  
  1069. - local cnt1 = 0
  1070. - local cnt2 = 0
  1071. -
  1072. MUMMY_DEF.on_step = function(self, dtime)
  1073. - self.timer = self.timer + 0.01
  1074. - self.turn_timer = self.turn_timer + 0.01
  1075. - self.jump_timer = self.jump_timer + 0.01
  1076. - self.punch_timer = self.punch_timer + 0.01
  1077. - self.attacking_timer = self.attacking_timer + 0.01
  1078. - self.sound_timer = self.sound_timer + 0.01
  1079. -
  1080. - local current_pos = self.object:getpos()
  1081. - local current_node = minetest.env:get_node(current_pos)
  1082. - if self.time_passed == nil then
  1083. - self.time_passed = 0
  1084. - end
  1085. -
  1086. - --self.time_passed = self.time_passed + dtime
  1087. - if self.object:get_hp() == 0 then-- self.object:remove() end
  1088. -
  1089. - --if self.time_passed >= 5 then
  1090. - minetest.sound_play(sound_dead, {pos = current_pos, max_hear_distance = 10 , gain = 0.3})
  1091. - self.object:remove()
  1092. - end--else
  1093. - if current_node.name == "default:water_source" or current_node.name == "default:water_flowing" or current_node.name == "default:lava_source" or current_node.name == "default:lava_flowing" then
  1094. - --self.time_passed = self.time_passed + dtime
  1095. - self.sound_timer = self.sound_timer + dtime
  1096. - if self.sound_timer >= 0.8 then
  1097. - self.sound_timer = 0
  1098. - self.object:set_hp(self.object:get_hp()-5)
  1099. - hit(self)
  1100. - minetest.sound_play(sound_hit, {pos = current_pos, max_hear_distance = 10, gain = 0.3})
  1101. - end
  1102. - else
  1103. - self.time_passed = 0
  1104. - end
  1105. - --end
  1106. -
  1107. - --update moving state every 1 or 2 seconds
  1108. - if self.state < 3 then
  1109. - if self.timer > math.random(1,2) then
  1110. - if self.attacker == "" then
  1111. - self.state = math.random(1,2)
  1112. - else self.state = 1 end
  1113. - self.timer = 0
  1114. - end
  1115. - end
  1116. -
  1117. - --play sound
  1118. - if self.sound_timer > math.random(5,35) then
  1119. - minetest.sound_play(sound_normal, {pos = current_pos, max_hear_distance = 10, gain = 0.2})
  1120. - self.sound_timer = 0
  1121. - end
  1122. -
  1123. - --after punched
  1124. - if self.state >= 8 then
  1125. - if self.punch_timer > 0.15 then
  1126. - --self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
  1127. - if self.state == 9 then
  1128. - self.object:setvelocity({x=self.direction.x*mummy_chillaxin_speed,y=-20,z=self.direction.z*mummy_chillaxin_speed})
  1129. - self.state = 2
  1130. - elseif self.state == 8 then
  1131. - self.object:setvelocity({x=0,y=-20,z=0})
  1132. - self.state = 1
  1133. - end
  1134. - end
  1135. - end
  1136. -
  1137. - --STANDING
  1138. - if self.state == 1 then
  1139. - self.yawwer = true
  1140. - self.attacker = ""
  1141. - for _,object in ipairs(minetest.env:get_objects_inside_radius(self.object:getpos(), 4)) do
  1142. - if object:is_player() then
  1143. - self.yawwer = false
  1144. - NPC = self.object:getpos()
  1145. - PLAYER = object:getpos()
  1146. - self.vec = {x=PLAYER.x-NPC.x, y=PLAYER.y-NPC.y, z=PLAYER.z-NPC.z}
  1147. - self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
  1148. - if PLAYER.x > NPC.x then
  1149. - self.yaw = self.yaw + math.pi
  1150. - end
  1151. - self.yaw = self.yaw - 2
  1152. - self.object:setyaw(self.yaw)
  1153. - self.attacker = object--:get_player_name()
  1154. - end
  1155. - end
  1156. -
  1157. - if self.attacker == "" and self.turn_timer > math.random(1,4) then--and yawwer == true then
  1158. - self.yaw = 360 * math.random()
  1159. - self.object:setyaw(self.yaw)
  1160. - self.turn_timer = 0
  1161. - self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
  1162. - end
  1163. - self.object:setvelocity({x=0,y=self.object:getvelocity().y,z=0})
  1164. - if self.npc_anim ~= ANIM_STAND then
  1165. - self.anim = get_animations()
  1166. - self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
  1167. - self.npc_anim = ANIM_STAND
  1168. - end
  1169. - if self.attacker ~= "" then
  1170. - self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
  1171. - self.state = 2
  1172. - end
  1173. - end
  1174. - --WALKING
  1175. - if self.state == 2 then
  1176. -
  1177. - if self.direction ~= nil then
  1178. - self.object:setvelocity({x=self.direction.x*mummy_chillaxin_speed,y=self.object:getvelocity().y,z=self.direction.z*mummy_chillaxin_speed})
  1179. - end
  1180. - if self.turn_timer > math.random(1,4) and not self.attacker then
  1181. - self.yaw = 360 * math.random()
  1182. - self.object:setyaw(self.yaw)
  1183. - self.turn_timer = 0
  1184. - self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
  1185. - --self.object:setvelocity({x=self.direction.x,y=self.object:getvelocity().y,z=direction.z})
  1186. - --self.object:setacceleration(self.direction)
  1187. - end
  1188. - if self.npc_anim ~= ANIM_WALK then
  1189. - self.anim = get_animations()
  1190. - self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, mummy_animation_speed, mummy_animation_blend)
  1191. - self.npc_anim = ANIM_WALK
  1192. - end
  1193. - --[[jump
  1194. - if self.direction ~= nil then
  1195. - if self.jump_timer > 0.3 then
  1196. - if minetest.env:get_node({x=self.object:getpos().x + self.direction.x,y=self.object:getpos().y-1,z=self.object:getpos().z + self.direction.z}).name ~= "air" then
  1197. - self.object:setvelocity({x=self.object:getvelocity().x,y=5,z=self.object:getvelocity().z})
  1198. - self.jump_timer = 0
  1199. - end
  1200. - end
  1201. - end]]
  1202. -
  1203. - if self.attacker ~= "" and minetest.setting_getbool("enable_damage") then
  1204. - local s = self.object:getpos()
  1205. - local p = self.attacker:getpos()
  1206. - if (s ~= nil and p ~= nil) then
  1207. - local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
  1208. -
  1209. - if dist < 2 and self.attacking_timer > 0.6 then
  1210. - self.attacker:punch(self.object, 1.0, {
  1211. - full_punch_interval=1.0,
  1212. - damage_groups = {fleshy=1}
  1213. - })
  1214. - self.attacking_timer = 0
  1215. - end
  1216. - end
  1217. - end
  1218. - end
  1219. + if mod_cmi then
  1220. + cmi.notify_step(self, dtime)
  1221. + end
  1222. + self.timer = self.timer + 0.01
  1223. + self.turn_timer = self.turn_timer + 0.01
  1224. + self.jump_timer = self.jump_timer + 0.01
  1225. + self.punch_timer = self.punch_timer + 0.01
  1226. + self.attacking_timer = self.attacking_timer + 0.01
  1227. + self.sound_timer = self.sound_timer + dtime + 0.01
  1228. +
  1229. + local current_pos = self.object:get_pos()
  1230. + local current_node = minetest.get_node(current_pos)
  1231. + if self.time_passed == nil then
  1232. + self.time_passed = 0
  1233. + end
  1234. +
  1235. + -- Environment damage
  1236. + local def = minetest.registered_nodes[current_node.name]
  1237. + local dps = def.damage_per_second
  1238. + local dmg = 0
  1239. + local dmg_node, dmg_pos
  1240. + if dps ~= nil and dps > 0 then
  1241. + dmg = dps
  1242. + end
  1243. + -- Damage from node
  1244. + if dmg < 4 and (minetest.get_item_group(current_node.name, "water") ~= 0 or minetest.get_item_group(current_node.name, "lava") ~= 0) then
  1245. + dmg = 4
  1246. + end
  1247. + -- Damage by suffocation
  1248. + if (def.walkable == nil or def.walkable == true)
  1249. + and (def.drowning == nil or def.drowning == 0)
  1250. + and (def.damage_per_second == nil or def.damage_per_second <= 0)
  1251. + and (def.collision_box == nil or def.collision_box.type == "regular")
  1252. + and (def.node_box == nil or def.node_box.type == "regular")
  1253. + and (def.groups and def.groups.disable_suffocation ~= 1) then
  1254. + dmg = dmg + 1
  1255. + end
  1256. + self.envdmg_timer = self.envdmg_timer + dtime
  1257. + if dmg > 0 then
  1258. + if self.envdmg_timer >= 1 then
  1259. + self.envdmg_timer = 0
  1260. + self.object:set_hp(self.object:get_hp()-dmg)
  1261. + self.last_damage = {
  1262. + type = "environment",
  1263. + pos = current_pos,
  1264. + node = current_node,
  1265. + }
  1266. + if self.object:get_hp() <= 0 then
  1267. + if self.on_death then
  1268. + self.on_death(self)
  1269. + end
  1270. + self.object:remove()
  1271. + else
  1272. + hit(self)
  1273. + self.sound_timer = 0
  1274. + minetest.sound_play(sound_hit, {pos = current_pos, max_hear_distance = 10, gain = 0.4})
  1275. + end
  1276. + end
  1277. + else
  1278. + self.time_passed = 0
  1279. + end
  1280. +
  1281. + --update moving state every 1 or 2 seconds
  1282. + if self.state < 3 then
  1283. + if self.timer > math.random(1,2) then
  1284. + if self.attacker == "" then
  1285. + self.state = math.random(1,2)
  1286. + else self.state = 1 end
  1287. + self.timer = 0
  1288. + end
  1289. + end
  1290. +
  1291. + --play sound
  1292. + if self.sound_timer > math.random(5,35) then
  1293. + minetest.sound_play(sound_normal, {pos = current_pos, max_hear_distance = 10, gain = 0.2})
  1294. + self.sound_timer = 0
  1295. + end
  1296. +
  1297. + --after punched
  1298. + if self.state >= 8 then
  1299. + if self.punch_timer > 0.15 then
  1300. + if self.state == 9 then
  1301. + self.object:set_velocity({x=self.direction.x*mummy_chillaxin_speed,y=-20,z=self.direction.z*mummy_chillaxin_speed})
  1302. + self.state = 2
  1303. + elseif self.state == 8 then
  1304. + self.object:set_velocity({x=0,y=-20,z=0})
  1305. + self.state = 1
  1306. + end
  1307. + end
  1308. + end
  1309. +
  1310. + --STANDING
  1311. + if self.state == 1 then
  1312. + self.yawwer = true
  1313. + self.attacker = ""
  1314. + for _,object in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 4)) do
  1315. + if object:is_player() then
  1316. + self.yawwer = false
  1317. + local NPC = self.object:get_pos()
  1318. + local PLAYER = object:get_pos()
  1319. + self.vec = {x=PLAYER.x-NPC.x, y=PLAYER.y-NPC.y, z=PLAYER.z-NPC.z}
  1320. + self.yaw = math.atan(self.vec.z/self.vec.x)+math.pi^2
  1321. + if PLAYER.x > NPC.x then
  1322. + self.yaw = self.yaw + math.pi
  1323. + end
  1324. + self.yaw = self.yaw - 2
  1325. + self.object:set_yaw(self.yaw)
  1326. + self.attacker = object
  1327. + end
  1328. + end
  1329. +
  1330. + if self.attacker == "" and self.turn_timer > math.random(1,4) then
  1331. + self.yaw = 360 * math.random()
  1332. + self.object:set_yaw(self.yaw)
  1333. + self.turn_timer = 0
  1334. + self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
  1335. + end
  1336. + self.object:set_velocity({x=0,y=self.object:get_velocity().y,z=0})
  1337. + if self.npc_anim ~= ANIM_STAND then
  1338. + self.anim = get_animations()
  1339. + self.object:set_animation({x=self.anim.stand_START,y=self.anim.stand_END}, mummy_animation_speed, mummy_animation_blend)
  1340. + self.npc_anim = ANIM_STAND
  1341. + end
  1342. + if self.attacker ~= "" then
  1343. + self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
  1344. + self.state = 2
  1345. + end
  1346. + end
  1347. + --WALKING
  1348. + if self.state == 2 then
  1349. +
  1350. + if self.direction ~= nil then
  1351. + self.object:set_velocity({x=self.direction.x*mummy_chillaxin_speed,y=self.object:get_velocity().y,z=self.direction.z*mummy_chillaxin_speed})
  1352. + end
  1353. + if self.turn_timer > math.random(1,4) and not self.attacker then
  1354. + self.yaw = 360 * math.random()
  1355. + self.object:set_yaw(self.yaw)
  1356. + self.turn_timer = 0
  1357. + self.direction = {x = math.sin(self.yaw)*-1, y = -20, z = math.cos(self.yaw)}
  1358. + end
  1359. + if self.npc_anim ~= ANIM_WALK then
  1360. + self.anim = get_animations()
  1361. + self.object:set_animation({x=self.anim.walk_START,y=self.anim.walk_END}, mummy_animation_speed, mummy_animation_blend)
  1362. + self.npc_anim = ANIM_WALK
  1363. + end
  1364. +
  1365. + if self.attacker ~= "" and minetest.settings:get_bool("enable_damage") then
  1366. + local s = self.object:get_pos()
  1367. + local p = self.attacker:get_pos()
  1368. + if (s ~= nil and p ~= nil) then
  1369. + local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
  1370. +
  1371. + if dist < 2 and self.attacking_timer > 0.6 then
  1372. + self.attacker:punch(self.object, 1.0, {
  1373. + full_punch_interval=1.0,
  1374. + damage_groups = {fleshy=1}
  1375. + })
  1376. + self.attacking_timer = 0
  1377. + end
  1378. + end
  1379. + end
  1380. + end
  1381. end
  1382.  
  1383. minetest.register_entity("tsm_pyramids:mummy", MUMMY_DEF)
  1384. @@ -341,71 +363,163 @@
  1385. --spawn-egg/spawner
  1386.  
  1387. minetest.register_craftitem("tsm_pyramids:spawn_egg", {
  1388. - description = "Mummy spawn-egg",
  1389. - inventory_image = "tsm_pyramids_mummy_egg.png",
  1390. - liquids_pointable = false,
  1391. - stack_max = 99,
  1392. - on_place = function(itemstack, placer, pointed_thing)
  1393. - if pointed_thing.type == "node" then
  1394. - minetest.env:add_entity(pointed_thing.above,"tsm_pyramids:mummy")
  1395. - if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end
  1396. - return itemstack
  1397. - end
  1398. - end,
  1399. + description = S("Mummy Spawn Egg"),
  1400. + _doc_items_longdesc = S("Can be used to create a hostile mummy."),
  1401. + _doc_items_usagehelp = S("Place the egg to create a mummy on this spot. Careful, it will probably attack immediately!"),
  1402. + inventory_image = "tsm_pyramids_mummy_egg.png",
  1403. + liquids_pointable = false,
  1404. + stack_max = 99,
  1405. + on_place = function(itemstack, placer, pointed_thing)
  1406. + if pointed_thing.type ~= "node" then
  1407. + return itemstack
  1408. + end
  1409. +
  1410. + -- am I clicking on something with existing on_rightclick function?
  1411. + local node = minetest.get_node(pointed_thing.under)
  1412. + if placer and not placer:get_player_control().sneak then
  1413. + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
  1414. + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
  1415. + end
  1416. + end
  1417. +
  1418. + minetest.add_entity(pointed_thing.above,"tsm_pyramids:mummy")
  1419. + if not minetest.settings:get_bool("creative_mode") then
  1420. + itemstack:take_item()
  1421. + end
  1422. + return itemstack
  1423. + end,
  1424.  
  1425. })
  1426.  
  1427. -function pyramids.spawn_mummy (pos, number)
  1428. - for i=0,number do
  1429. - minetest.env:add_entity(pos,"tsm_pyramids:mummy")
  1430. - end
  1431. +-- Spawn a mummy at position
  1432. +function tsm_pyramids.spawn_mummy_at(pos, number)
  1433. + local node = minetest.get_node(pos)
  1434. + if node.name ~= "air" then
  1435. + return
  1436. + end
  1437. + for _=1, number do
  1438. + minetest.add_entity(pos,"tsm_pyramids:mummy")
  1439. + end
  1440. +end
  1441. +
  1442. +local spawnersounds
  1443. +if default.node_sound_metal_defaults then
  1444. + spawnersounds = default.node_sound_metal_defaults()
  1445. +else
  1446. + spawnersounds = default.node_sound_stone_defaults()
  1447. end
  1448.  
  1449. minetest.register_node("tsm_pyramids:spawner_mummy", {
  1450. - description = "Mummy spawner",
  1451. - paramtype = "light",
  1452. - tiles = {"tsm_pyramids_spawner.png"},
  1453. - is_ground_content = true,
  1454. - drawtype = "allfaces",--_optional",
  1455. - groups = {cracky=1,level=1},
  1456. - drop = "",
  1457. - on_construct = function(pos)
  1458. - pos.y = pos.y - 0.28
  1459. - minetest.env:add_entity(pos,"tsm_pyramids:mummy_spawner")
  1460. - end,
  1461. - on_destruct = function(pos)
  1462. - for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
  1463. - if not obj:is_player() then
  1464. - if obj ~= nil and obj:get_luaentity().m_name == "dummy" then
  1465. - obj:remove()
  1466. - end
  1467. - end
  1468. - end
  1469. - end
  1470. + description = S("Mummy Spawner"),
  1471. + _doc_items_longdesc = S("A mummy spawner causes hostile mummies to appear in its vicinity as long it exists."),
  1472. + paramtype = "light",
  1473. + tiles = {"tsm_pyramids_spawner.png"},
  1474. + is_ground_content = false,
  1475. + drawtype = "allfaces",
  1476. + groups = {cracky=1,level=1},
  1477. + drop = "",
  1478. + on_construct = function(pos)
  1479. + pos.y = pos.y - 0.28
  1480. + minetest.add_entity(pos,"tsm_pyramids:mummy_spawner")
  1481. + end,
  1482. + on_destruct = function(pos)
  1483. + for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
  1484. + if not obj:is_player() then
  1485. + if obj ~= nil and obj:get_luaentity().name == "tsm_pyramids:mummy_spawner" then
  1486. + obj:remove()
  1487. + end
  1488. + end
  1489. + end
  1490. + end,
  1491. + sounds = spawnersounds,
  1492. })
  1493. -if not minetest.setting_getbool("only_peaceful_mobs") then
  1494. - minetest.register_abm({
  1495. - nodenames = {"tsm_pyramids:spawner_mummy"},
  1496. - interval = 2.0,
  1497. - chance = 20,
  1498. - action = function(pos, node, active_object_count, active_object_count_wider)
  1499. - local player_near = false
  1500. - local mobs = 0
  1501. - for _,obj in ipairs(minetest.env:get_objects_inside_radius(pos, spawner_range)) do
  1502. - if obj:is_player() then
  1503. - player_near = true
  1504. - else
  1505. - if obj:get_luaentity().mob_name == "mummy" then mobs = mobs + 1 end
  1506. - end
  1507. - end
  1508. - if player_near then
  1509. - if mobs < spawner_max_mobs then
  1510. - pos.x = pos.x+1
  1511. - local p = minetest.find_node_near(pos, 5, {"air"})
  1512. - minetest.env:add_entity(p,"tsm_pyramids:mummy")
  1513. - end
  1514. - end
  1515. - end
  1516. - })
  1517. +
  1518. +-- Attempt to spawn a mummy at a random appropriate position around pos.
  1519. +-- Criteria:
  1520. +-- * Must be close to pos
  1521. +-- * Not in sunlight
  1522. +-- * Must be air on top of a non-air block
  1523. +-- * No more than 6 mummies in area
  1524. +-- * Player must be near is player_near_required is true
  1525. +function tsm_pyramids.attempt_mummy_spawn(pos, player_near_required)
  1526. + local player_near = false
  1527. + local mobs = 0
  1528. + for _,obj in ipairs(minetest.get_objects_inside_radius(pos, spawner_check_range)) do
  1529. + if obj:is_player() then
  1530. + player_near = true
  1531. + else
  1532. + if obj:get_luaentity() and obj:get_luaentity().name == "tsm_pyramids:mummy" then
  1533. + mobs = mobs + 1
  1534. + end
  1535. + end
  1536. + end
  1537. + if player_near or (not player_near_required) then
  1538. + if mobs < spawner_max_mobs then
  1539. + local offset = {x=5,y=2,z=5}
  1540. + local nposses = minetest.find_nodes_in_area(vector.subtract(pos, offset), vector.add(pos,offset), "air")
  1541. + local tries = math.min(6, #nposses)
  1542. + for i=1, tries do
  1543. + local r = math.random(1, #nposses)
  1544. + local npos = nposses[r]
  1545. + -- Check if mummy has 2 nodes of free space
  1546. + local two_space = false
  1547. + -- Check if mummy has something to walk on
  1548. + local footing = false
  1549. + -- Find the lowest node
  1550. + for y=-1, -5, -1 do
  1551. + npos.y = npos.y - 1
  1552. + local below = minetest.get_node(npos)
  1553. + if minetest.registered_items[below.name].liquidtype ~= "none" then
  1554. + break
  1555. + end
  1556. + if below.name ~= "air" then
  1557. + if y < -1 then
  1558. + two_space = true
  1559. + end
  1560. + npos.y = npos.y + 1
  1561. + footing = true
  1562. + break
  1563. + end
  1564. + end
  1565. + local light = minetest.get_node_light(npos, 0.5)
  1566. + if not two_space then
  1567. + local above = minetest.get_node({x=npos.x, y=npos.y+1, z=npos.z})
  1568. + if above.name == "air" then
  1569. + two_space = true
  1570. + end
  1571. + end
  1572. + if footing and two_space and light < 15 then
  1573. + tsm_pyramids.spawn_mummy_at(npos, 1)
  1574. + break
  1575. + else
  1576. + table.remove(nposses, r)
  1577. + end
  1578. + end
  1579. + end
  1580. + end
  1581. +end
  1582. +
  1583. +if not minetest.settings:get_bool("only_peaceful_mobs") then
  1584. + minetest.register_abm({
  1585. + nodenames = {"tsm_pyramids:spawner_mummy"},
  1586. + interval = 2.0,
  1587. + chance = 20,
  1588. + action = function(pos, node, active_object_count, active_object_count_wider)
  1589. + tsm_pyramids.attempt_mummy_spawn(pos, true)
  1590. + end,
  1591. + })
  1592. +end
  1593. +
  1594. +if minetest.get_modpath("awards") then
  1595. + awards.register_achievement("tsm_pyramids_no_mummy_spawner", {
  1596. + title = S("No more mummies!"),
  1597. + description = S("Destroy a mummy spawner by digging."),
  1598. + secret = true,
  1599. + icon = "tsm_pyramids_spawner.png",
  1600. + trigger = {
  1601. + type = "dig",
  1602. + node = "tsm_pyramids:spawner_mummy",
  1603. + target = 1
  1604. + }
  1605. + })
  1606. end
  1607. -
  1608. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/nodes.lua /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/nodes.lua
  1609. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/nodes.lua 2015-02-07 09:12:28.000000000 -0500
  1610. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/nodes.lua 2019-09-02 14:45:11.000000000 -0400
  1611. @@ -1,48 +1,98 @@
  1612. -local img = {"eye", "men", "sun"}
  1613. +local S = minetest.get_translator("tsm_pyramids")
  1614.  
  1615. -for i=1,3 do
  1616. - minetest.register_node("tsm_pyramids:deco_stone"..i, {
  1617. - description = "Sandstone with "..img[i],
  1618. - tiles = {"default_sandstone.png^tsm_pyramids_"..img[i]..".png"},
  1619. - is_ground_content = true,
  1620. - groups = {crumbly=2,cracky=3},
  1621. - sounds = default.node_sound_stone_defaults(),
  1622. - })
  1623. +local img = {
  1624. + "eye", "men", "sun",
  1625. + "ankh", "scarab", "cactus"
  1626. +}
  1627. +local desc = {
  1628. + S("Sandstone with Eye Engraving"), S("Sandstone with Man Engraving"), S("Sandstone with Sun Engraving"),
  1629. + S("Desert Sandstone with Ankh Engraving"), S("Desert Sandstone with Scarab Engraving"), S("Desert Sandstone with Cactus Engraving")
  1630. +}
  1631. +
  1632. +local decodesc = ""
  1633. +if minetest.get_modpath("doc_items") then
  1634. + decodesc = doc.sub.items.temp.deco
  1635. +end
  1636. +
  1637. +for i=1, #img do
  1638. + local sandstone_img, basenode
  1639. + if i > 3 then
  1640. + sandstone_img = "default_desert_sandstone.png"
  1641. + basenode = "default:desert_sandstone"
  1642. + else
  1643. + sandstone_img = "default_sandstone.png"
  1644. + basenode = "default:sandstone"
  1645. + end
  1646. + minetest.register_node("tsm_pyramids:deco_stone"..i, {
  1647. + description = desc[i],
  1648. + _doc_items_longdesc = decodesc,
  1649. + is_ground_content = false,
  1650. + tiles = {sandstone_img, sandstone_img, sandstone_img.."^tsm_pyramids_"..img[i]..".png"},
  1651. + groups = minetest.registered_nodes[basenode].groups,
  1652. + sounds = minetest.registered_nodes[basenode].sounds,
  1653. + })
  1654. end
  1655.  
  1656. -trap_on_timer = function (pos, elapsed)
  1657. - local objs = minetest.env:get_objects_inside_radius(pos, 2)
  1658. - for i, obj in pairs(objs) do
  1659. - if obj:is_player() then
  1660. - local n = minetest.get_node(pos)
  1661. - if n and n.name and minetest.registered_nodes[n.name].crack < 2 then
  1662. - minetest.set_node(pos, {name="tsm_pyramids:trap_2"})
  1663. - nodeupdate(pos)
  1664. - end
  1665. - end
  1666. - end
  1667. - return true
  1668. +local trap_on_timer = function(pos, elapsed)
  1669. + local n = minetest.get_node(pos)
  1670. + if not (n and n.name) then
  1671. + return true
  1672. + end
  1673. + -- Drop trap stone when player is nearby
  1674. + local objs = minetest.get_objects_inside_radius(pos, 2)
  1675. + for i, obj in pairs(objs) do
  1676. + if obj:is_player() then
  1677. + if minetest.registered_nodes[n.name]._tsm_pyramids_crack and minetest.registered_nodes[n.name]._tsm_pyramids_crack < 2 then
  1678. + -- 70% chance to ignore player to make the time of falling less predictable
  1679. + if math.random(1, 10) >= 3 then
  1680. + return true
  1681. + end
  1682. + if n.name == "tsm_pyramids:trap" then
  1683. + minetest.set_node(pos, {name="tsm_pyramids:trap_2"})
  1684. + minetest.check_for_falling(pos)
  1685. + elseif n.name == "tsm_pyramids:desert_trap" then
  1686. + minetest.set_node(pos, {name="tsm_pyramids:desert_trap_2"})
  1687. + minetest.check_for_falling(pos)
  1688. + end
  1689. + return true
  1690. + end
  1691. + end
  1692. + end
  1693. + return true
  1694. +end
  1695. +
  1696. +local register_trap_stone = function(basename, desc_normal, desc_falling, base_tile, drop)
  1697. + minetest.register_node("tsm_pyramids:"..basename, {
  1698. + description = desc_normal,
  1699. + _doc_items_longdesc = S("This brick is old, porous and unstable and is barely able to hold itself. One should be careful not to disturb it."),
  1700. + tiles = { base_tile .. "^tsm_pyramids_crack.png" },
  1701. + is_ground_content = false,
  1702. + groups = {crumbly=3,cracky=3},
  1703. + sounds = default.node_sound_stone_defaults(),
  1704. + on_construct = function(pos)
  1705. + minetest.get_node_timer(pos):start(0.1)
  1706. + end,
  1707. + _tsm_pyramids_crack = 1,
  1708. + on_timer = trap_on_timer,
  1709. + drop = drop,
  1710. + })
  1711. +
  1712. + minetest.register_node("tsm_pyramids:"..basename.."_2", {
  1713. + description = desc_falling,
  1714. + _doc_items_longdesc = S("This old porous brick falls under its own weight."),
  1715. + tiles = { base_tile .. "^tsm_pyramids_crack2.png" },
  1716. + is_ground_content = false,
  1717. + groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1},
  1718. + sounds = default.node_sound_stone_defaults(),
  1719. + drop = drop,
  1720. + })
  1721. end
  1722.  
  1723. -minetest.register_node("tsm_pyramids:trap", {
  1724. - description = "Cracked sandstone brick",
  1725. - tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"},
  1726. - is_ground_content = true,
  1727. - groups = {crumbly=2,cracky=3},
  1728. - sounds = default.node_sound_stone_defaults(),
  1729. - on_construct = function(pos)
  1730. - minetest.env:get_node_timer(pos):start(0.1)
  1731. - end,
  1732. - crack = 1,
  1733. - on_timer = trap_on_timer,
  1734. - drop = "",
  1735. -})
  1736. -
  1737. -minetest.register_node("tsm_pyramids:trap_2", {
  1738. - description = "trapstone",
  1739. - tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png^[transformR90"},
  1740. - is_ground_content = true,
  1741. - groups = {crumbly=2,cracky=3,falling_node=1,not_in_creative_inventory=1},
  1742. - sounds = default.node_sound_stone_defaults(),
  1743. - drop = "",
  1744. -})
  1745. +register_trap_stone("trap",
  1746. + S("Cracked Sandstone Brick"), S("Falling Cracked Sandstone Brick"),
  1747. + "default_sandstone_brick.png",
  1748. + { items = { { items = { "default:sand" }, rarity = 1 }, { items = { "default:sand" }, rarity = 2 }, } })
  1749. +register_trap_stone("desert_trap",
  1750. + S("Cracked Desert Sandstone Brick"), S("Falling Cracked Desert Sandstone Brick"),
  1751. + "default_desert_sandstone_brick.png",
  1752. + { items = { { items = { "default:desert_sand" }, rarity = 1 }, { items = { "default:desert_sand" }, rarity = 2 }, } })
  1753. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/oldcoder.txt /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/oldcoder.txt
  1754. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/oldcoder.txt 2019-07-03 05:59:38.000000000 -0400
  1755. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/oldcoder.txt 2020-03-07 00:23:04.000000000 -0500
  1756. @@ -4,24 +4,36 @@
  1757.  
  1758. ----------------------------------------------------------------------
  1759.  
  1760. -1. This version runs if and only if either of the following conf-file
  1761. -settings is used:
  1762. +1. Starting point:
  1763.  
  1764. + http://repo.or.cz/w/minetest_pyramids/tsm_pyramids.git/\
  1765. +snapshot/1.0.0.zip
  1766. +
  1767. +----------------------------------------------------------------------
  1768. +
  1769. +2. This version runs if and only if the following conf-file setting is
  1770. +used:
  1771. enable_tsm_pyramids = true
  1772. - enable_wonder = true
  1773.  
  1774. ----------------------------------------------------------------------
  1775.  
  1776. -2. Partial list of changes:
  1777. +3. Partial list of changes:
  1778.  
  1779. -2a. Applied the following patch file, which is included with this file
  1780. +3a. Applied the following patch file, which is included with this file
  1781. (oldcoder.txt):
  1782.  
  1783. bucket-tsm_pyramids.patch
  1784.  
  1785. -2b. Renamed "init.lua" to "baseinit.lua". Added a new "init.lua" file
  1786. +3b. Detabbed "*.lua".
  1787. +
  1788. +3c. Renamed "init.lua" to "baseinit.lua". Added a new "init.lua" file
  1789. that conditionally loads "baseinit.lua".
  1790.  
  1791. -2c. Added the files "00README" and "oldcoder.txt" (this file).
  1792. +3d. Replaced egg texture with a new Poikilos version.
  1793. +
  1794. +3e. Removed ".gitattributes", ".gitignore", "mod.conf", and screenshot
  1795. +file(s).
  1796. +
  1797. +3f. Added an appropriate "depends.txt" file.
  1798.  
  1799. -2d. Replaced egg texture with a new Poikilos version.
  1800. +3g. Added the files "00README" and "oldcoder.txt" (this file).
  1801. Only in /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids: README.md
  1802. Only in ../games/Bucket_Game/mods/codercore/tsm_pyramids: README.txt
  1803. diff -u ../games/Bucket_Game/mods/codercore/tsm_pyramids/room.lua /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/room.lua
  1804. --- ../games/Bucket_Game/mods/codercore/tsm_pyramids/room.lua 2015-02-07 09:12:28.000000000 -0500
  1805. +++ /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/room.lua 2019-09-02 14:45:11.000000000 -0400
  1806. @@ -1,78 +1,1172 @@
  1807. -local room = {"a","a","a","a","a","a","a","a","a",
  1808. - "a","c","a","c","a","c","a","c","a",
  1809. - "a","s","a","s","a","s","a","s","a",
  1810. - "a","a","a","a","a","a","a","a","a",
  1811. - "a","a","a","a","a","a","a","a","a",
  1812. - "a","a","a","a","a","a","a","a","a",
  1813. - "a","s","a","s","a","s","a","s","a",
  1814. - "a","c","a","c","a","c","a","c","a",
  1815. - "a","a","a","a","a","a","a","a","a"}
  1816. -
  1817. -local trap = {"b","b","b","b","b","b","b","b","b",
  1818. - "l","b","l","b","l","b","l","b","b",
  1819. - "l","b","l","b","l","b","l","b","b",
  1820. - "l","b","l","l","l","b","l","l","b",
  1821. - "l","l","b","l","b","l","l","b","b",
  1822. - "l","b","l","l","l","l","l","l","b",
  1823. - "l","b","l","b","l","b","l","b","b",
  1824. - "l","b","l","b","l","b","l","b","b",
  1825. - "b","b","b","b","b","b","b","b","b"}
  1826. -
  1827. -local code = {}
  1828. -code["s"] = "sandstone"
  1829. -code["eye"] = "deco_stone1"
  1830. -code["men"] = "deco_stone2"
  1831. -code["sun"] = "deco_stone3"
  1832. -code["c"] = "chest"
  1833. -code["b"] = "sandstonebrick"
  1834. -code["a"] = "air"
  1835. -code["l"] = "lava_source"
  1836. -code["t"] = "trap"
  1837. -
  1838. -local function replace(str,iy)
  1839. - local out = "default:"
  1840. - if iy < 4 and str == "c" then str = "a" end
  1841. - if iy == 0 and str == "s" then out = "tsm_pyramids:" str = "sun" end
  1842. - if iy == 3 and str == "s" then out = "tsm_pyramids:" str = "men" end
  1843. - if str == "a" then out = "" end
  1844. - return out..code[str]
  1845. -end
  1846. -
  1847. -local function replace2(str,iy)
  1848. - local out = "default:"
  1849. - if iy == 0 and str == "l" then out = "tsm_pyramids:" str = "t"
  1850. - elseif iy < 3 and str == "l" then str = "a" end
  1851. -
  1852. - if str == "a" then out = "" end
  1853. - return out..code[str]
  1854. -end
  1855. -
  1856. -function pyramids.make_room(pos)
  1857. - local loch = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
  1858. - for iy=0,4,1 do
  1859. - for ix=0,8,1 do
  1860. - for iz=0,8,1 do
  1861. - local n_str = room[tonumber(ix*9+iz+1)]
  1862. - local p2 = 0
  1863. - if n_str == "c" then
  1864. - if ix < 3 then p2 = 1 else p2 = 3 end
  1865. - pyramids.fill_chest({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz})
  1866. - end
  1867. - minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2})
  1868. - end
  1869. - end
  1870. - end
  1871. -end
  1872. -
  1873. -function pyramids.make_traps(pos)
  1874. - local loch = {x=pos.x+7,y=pos.y, z=pos.z+7}
  1875. - for iy=0,4,1 do
  1876. - for ix=0,8,1 do
  1877. - for iz=0,8,1 do
  1878. - local n_str = trap[tonumber(ix*9+iz+1)]
  1879. - local p2 = 0
  1880. - minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace2(n_str,iy), param2=p2})
  1881. - end
  1882. - end
  1883. - end
  1884. +local S = minetest.get_translator("tsm_pyramids")
  1885. +
  1886. +-- ROOM LAYOUTS
  1887. +
  1888. +local ROOM_WIDTH = 9
  1889. +
  1890. +local room_types = {
  1891. + -- Pillar room
  1892. + {
  1893. + style = "yrepeat",
  1894. + layout = {
  1895. + " "," "," "," "," "," "," "," "," ",
  1896. + " ","^"," ","^"," ","^"," ","^"," ",
  1897. + " ","c"," ","c"," ","c"," ","c"," ",
  1898. + " "," "," "," "," "," "," "," "," ",
  1899. + " "," "," "," "," "," "," "," "," ",
  1900. + " "," "," "," "," "," "," "," "," ",
  1901. + " ","c"," ","c"," ","c"," ","c"," ",
  1902. + " ","v"," ","v"," ","v"," ","v"," ",
  1903. + " "," "," "," "," "," "," "," "," "
  1904. + },
  1905. + traps = true,
  1906. + },
  1907. + -- Hieroglyph walls
  1908. + {
  1909. + style = "yrepeat",
  1910. + layout = {
  1911. + "s","h","h","h","h","h","h","h","s",
  1912. + "h"," "," "," "," "," "," "," ","h",
  1913. + "h"," "," "," "," "," "," "," ","h",
  1914. + "h"," "," "," "," "," "," "," ","h",
  1915. + " "," "," "," ","<"," "," "," ","h",
  1916. + "h"," "," "," "," "," "," "," ","h",
  1917. + "h"," "," "," "," "," "," "," ","h",
  1918. + "h"," "," "," "," "," "," "," ","h",
  1919. + "s","h","h","h","h","h","h","h","s"
  1920. + },
  1921. + },
  1922. + -- 4 large pillars
  1923. + {
  1924. + style = "yrepeat",
  1925. + layout = {
  1926. + " "," "," "," ","v"," "," "," "," ",
  1927. + " ","c","c"," "," "," ","c","c"," ",
  1928. + " ","c","c"," "," "," ","c","c"," ",
  1929. + " "," "," "," "," "," "," "," "," ",
  1930. + " "," "," "," "," "," "," "," ","<",
  1931. + " "," "," "," "," "," "," "," "," ",
  1932. + " ","c","c"," "," "," ","c","c"," ",
  1933. + " ","c","c"," "," "," ","c","c"," ",
  1934. + " "," "," "," ","^"," "," "," "," "
  1935. + },
  1936. + traps = true,
  1937. + },
  1938. + -- hidden room
  1939. + {
  1940. + style = "yrepeat",
  1941. + layout = {
  1942. + " "," "," "," "," "," "," "," "," ",
  1943. + " "," "," "," "," "," "," "," "," ",
  1944. + " "," ","c","S","c","S","c"," "," ",
  1945. + " "," ","S"," "," "," ","S"," "," ",
  1946. + " "," ","c"," ",">"," ","c"," ","<",
  1947. + " "," ","S"," "," "," ","S"," "," ",
  1948. + " "," ","c","S","c","S","c"," "," ",
  1949. + " "," "," "," "," "," "," "," "," ",
  1950. + " "," "," "," "," "," "," "," "," "
  1951. + },
  1952. + },
  1953. + -- spiral 1
  1954. + {
  1955. + style = "yrepeat",
  1956. + layout = {
  1957. + " "," "," "," "," "," "," "," "," ",
  1958. + " ","S","S","S","S","S","S","S"," ",
  1959. + " ","S"," "," "," "," "," ","S"," ",
  1960. + " ","S"," ","c","c","c"," ","S"," ",
  1961. + " ","S"," ","c","v","c"," ","S"," ",
  1962. + "S","S"," ","c"," ","c"," ","S"," ",
  1963. + "S","S"," ","c"," "," "," ","S"," ",
  1964. + "v","S"," ","S","S","S","S","S"," ",
  1965. + " ","S"," "," "," "," "," "," "," "
  1966. + },
  1967. + },
  1968. + -- spiral 2
  1969. + {
  1970. + style = "yrepeat",
  1971. + layout = {
  1972. + " "," "," "," "," "," "," "," "," ",
  1973. + " ","S","S","S","S","S","S","S"," ",
  1974. + " "," "," ","c"," "," "," ","S"," ",
  1975. + "S","S"," ","c"," ","c"," ","S"," ",
  1976. + " ","S"," ","c","^","c"," ","S"," ",
  1977. + " ","S"," ","c","c","c"," ","S"," ",
  1978. + " ","S"," "," "," "," "," ","S"," ",
  1979. + " ","S","S","S","S","S","S","S"," ",
  1980. + " "," "," "," "," "," "," "," "," "
  1981. + },
  1982. + },
  1983. + -- pillar mania
  1984. + {
  1985. + style = "yrepeat",
  1986. + layout = {
  1987. + " "," ","v"," ","v"," ","v"," ","v",
  1988. + " ","c"," ","c"," ","c"," ","c"," ",
  1989. + " "," "," "," "," "," "," "," "," ",
  1990. + " ","c"," ","c"," ","c"," ","c"," ",
  1991. + " "," "," "," "," "," "," "," "," ",
  1992. + " ","c"," ","c"," ","c"," ","c"," ",
  1993. + " "," "," "," "," "," "," "," "," ",
  1994. + " ","c"," ","c"," ","c"," ","c"," ",
  1995. + " "," ","^"," ","^"," ","^"," ","^",
  1996. + },
  1997. + traps = true,
  1998. + },
  1999. + -- plusses
  2000. + {
  2001. + style = "yrepeat",
  2002. + layout = {
  2003. + "c"," "," "," "," "," "," "," ","c",
  2004. + " "," ","c",">"," ","<","c"," "," ",
  2005. + " ","c","s","c"," ","c","s","c"," ",
  2006. + " "," ","c"," "," "," ","c"," "," ",
  2007. + " "," "," "," ","<"," "," "," "," ",
  2008. + " "," ","c"," "," "," ","c"," "," ",
  2009. + " ","c","s","c"," ","c","s","c"," ",
  2010. + " "," ","c",">"," ","<","c"," "," ",
  2011. + "c"," "," "," "," "," "," "," ","c",
  2012. + },
  2013. + traps = true,
  2014. + },
  2015. + -- diamond
  2016. + {
  2017. + style = "yrepeat",
  2018. + layout = {
  2019. + ">","s","s","c","c","c","s","s","s",
  2020. + "s","s","c"," "," "," ","c","s","s",
  2021. + "s","c"," "," "," "," "," ","c","s",
  2022. + "c"," "," "," "," "," "," "," ","c",
  2023. + " "," "," "," "," "," "," ","<","c",
  2024. + "c"," "," "," "," "," "," "," ","c",
  2025. + "s","c"," "," "," "," "," ","c","s",
  2026. + "s","s","c"," "," "," ","c","s","s",
  2027. + ">","s","s","c","c","c","s","s","s",
  2028. + },
  2029. + },
  2030. + -- square
  2031. + {
  2032. + style = "yrepeat",
  2033. + layout = {
  2034. + " "," "," "," "," "," "," "," "," ",
  2035. + " ","S","S","S","^","S","S","S"," ",
  2036. + " ","S","S","S","S","S","S","S"," ",
  2037. + " ","S","S","S","S","S","S","S"," ",
  2038. + " ","S","S","S","S","S","S",">"," ",
  2039. + " ","S","S","S","S","S","S","S"," ",
  2040. + " ","S","S","S","S","S","S","S"," ",
  2041. + " ","S","S","S","v","S","S","S"," ",
  2042. + " "," "," "," "," "," "," "," "," ",
  2043. + },
  2044. + },
  2045. + -- hallway 2
  2046. + {
  2047. + style = "yrepeat",
  2048. + layout = {
  2049. + "S","S","S","S",">"," "," "," "," ",
  2050. + "S","S","S","S","S","^","S","S"," ",
  2051. + "S","S","S","S","S","S","S","S"," ",
  2052. + "S","S","S","S","S","S","S","S"," ",
  2053. + " "," "," "," "," "," "," "," "," ",
  2054. + "S","S","S","S","S","S","S","S"," ",
  2055. + "S","S","S","S","S","S","S","S"," ",
  2056. + "S","S","S","S","S","v","S","S"," ",
  2057. + "S","S","S","S",">"," "," "," "," ",
  2058. + },
  2059. + },
  2060. + -- hallway 3
  2061. + {
  2062. + style = "yrepeat",
  2063. + layout = {
  2064. + "S","S","S","S","S"," "," "," "," ",
  2065. + "S","S","S","S","c",">"," "," "," ",
  2066. + "S","c","S","c","S","c","S"," "," ",
  2067. + " "," "," "," "," "," "," "," "," ",
  2068. + " "," "," "," "," "," "," "," "," ",
  2069. + " "," "," "," "," "," "," "," "," ",
  2070. + "S","c","S","c","S","c","S"," "," ",
  2071. + "S","S","S","S","c",">"," "," "," ",
  2072. + "S","S","S","S","S"," "," "," "," ",
  2073. + },
  2074. + traps = true,
  2075. + },
  2076. + -- hallway 4
  2077. + {
  2078. + style = "yrepeat",
  2079. + layout = {
  2080. + "S","S","S","S","S","v","S","S","S",
  2081. + "S","S","S","S","S","S","S","S","S",
  2082. + "c","S","c","S","c","S","c","S","c",
  2083. + " "," "," "," "," "," "," "," "," ",
  2084. + " "," "," "," "," "," "," "," ","<",
  2085. + " "," "," "," "," "," "," "," "," ",
  2086. + "c","S","c","S","c","S","c","S","c",
  2087. + "S","S","S","S","S","S","S","S","S",
  2088. + "S","S","S","S","S","^","S","S","S",
  2089. + },
  2090. + },
  2091. + -- tiny
  2092. + {
  2093. + style = "yrepeat",
  2094. + layout = {
  2095. + "S","S","S","S","S","S","S","S","v",
  2096. + "S","S","S","S","S","S","S","S"," ",
  2097. + "S","S","S","S","S","S","S","S"," ",
  2098. + "S","S","S"," "," "," ","S","S"," ",
  2099. + " "," "," "," ","<"," ","S","S"," ",
  2100. + "S","S","S"," "," "," ","S","S"," ",
  2101. + "S","S","S","S","S","S","S","S"," ",
  2102. + "S","S","S","S","S","S","S","S"," ",
  2103. + "S","S","S","S","S","S","S","S","^",
  2104. + },
  2105. + },
  2106. + -- small
  2107. + {
  2108. + style = "yrepeat",
  2109. + layout = {
  2110. + "S","S","S","S","S","S","S","S","S",
  2111. + "S","S","S","S","S","S","S","S","S",
  2112. + "S","S"," ","v"," ","v"," ","S","S",
  2113. + "S","S",">"," "," "," ","<","S"," ",
  2114. + " "," "," "," ","c"," "," ","S"," ",
  2115. + "S","S",">"," "," "," ","<","S"," ",
  2116. + "S","S"," ","^"," ","^"," ","S","S",
  2117. + "S","S","S","S","S","S","S","S","S",
  2118. + "S","S","S","S","S","S","S","S","S",
  2119. + },
  2120. + },
  2121. + -- small 2
  2122. + {
  2123. + style = "yrepeat",
  2124. + layout = {
  2125. + " "," "," "," "," "," "," "," "," ",
  2126. + " ","S","S","S","S","S","S","S"," ",
  2127. + " ","S"," "," ","v"," "," ","S"," ",
  2128. + "S","S"," "," "," "," "," ","S"," ",
  2129. + " "," "," "," "," "," ","<","S"," ",
  2130. + "S","S"," "," "," "," "," ","S"," ",
  2131. + " ","S"," "," ","^"," "," ","S"," ",
  2132. + " ","S","S","S","S","S","S","S"," ",
  2133. + " "," "," "," "," "," "," "," "," ",
  2134. + },
  2135. + },
  2136. + -- big pillar
  2137. + {
  2138. + style = "yrepeat",
  2139. + layout = {
  2140. + " "," "," "," "," "," "," "," "," ",
  2141. + " "," "," "," "," "," "," "," "," ",
  2142. + " "," "," "," ","^"," "," "," "," ",
  2143. + " "," "," ","c","c","c"," "," "," ",
  2144. + " "," ","<","c","S","c",">"," "," ",
  2145. + " "," "," ","c","c","c"," "," "," ",
  2146. + " "," "," "," ","v"," "," "," "," ",
  2147. + " "," "," "," "," "," "," "," "," ",
  2148. + " "," "," "," "," "," "," "," "," ",
  2149. + },
  2150. + traps = true,
  2151. + },
  2152. + -- pacman
  2153. + {
  2154. + style = "yrepeat",
  2155. + layout = {
  2156. + " "," "," "," "," "," "," "," "," ",
  2157. + " "," "," "," "," "," "," "," "," ",
  2158. + " "," "," ","c","c","c"," "," "," ",
  2159. + " "," ","c","c","v","c","c"," "," ",
  2160. + " "," ","c",">"," "," "," "," "," ",
  2161. + " "," ","c","c","^","c","c"," "," ",
  2162. + " "," "," ","c","c","c"," "," "," ",
  2163. + " "," "," "," "," "," "," "," "," ",
  2164. + " "," "," "," "," "," "," "," "," ",
  2165. + },
  2166. + traps = true,
  2167. + },
  2168. + -- the wall
  2169. + {
  2170. + style = "yrepeat",
  2171. + layout = {
  2172. + "S","S","S","S","S","S","S"," ","<",
  2173. + "s","c","s","c","s","c","s"," ","c",
  2174. + "c"," "," "," "," "," ","c"," ","<",
  2175. + "s"," "," "," "," "," ","s"," ","c",
  2176. + " "," "," "," "," ","<","c"," ","<",
  2177. + "s"," "," "," "," "," ","s"," ","c",
  2178. + "c"," "," "," "," "," ","c"," ","<",
  2179. + "s","c","s","c","s","c","s"," ","c",
  2180. + "S","S","S","S","S","S","S"," ","<",
  2181. + },
  2182. + traps = true,
  2183. + },
  2184. + -- split
  2185. + {
  2186. + style = "yrepeat",
  2187. + layout = {
  2188. + " "," "," "," "," "," "," "," "," ",
  2189. + " "," "," "," "," "," "," "," "," ",
  2190. + " "," "," "," "," "," "," "," "," ",
  2191. + " "," "," ","^"," ","^"," "," "," ",
  2192. + " "," "," ","c"," ","c"," "," "," ",
  2193. + " "," "," ","v"," ","v"," "," "," ",
  2194. + " "," "," "," "," "," "," "," "," ",
  2195. + " "," "," "," "," "," "," "," "," ",
  2196. + " "," "," "," "," "," "," "," "," ",
  2197. + },
  2198. + traps = true,
  2199. + },
  2200. + -- 4 small pillars
  2201. + {
  2202. + style = "yrepeat",
  2203. + layout = {
  2204. + " "," "," "," "," "," "," "," "," ",
  2205. + " "," "," "," ","^"," "," "," "," ",
  2206. + " "," "," "," ","c"," "," "," "," ",
  2207. + " "," "," "," "," "," "," "," "," ",
  2208. + " ","<","c"," "," "," ","c",">"," ",
  2209. + " "," "," "," "," "," "," "," "," ",
  2210. + " "," "," "," ","c"," "," "," "," ",
  2211. + " "," "," "," ","v"," "," "," "," ",
  2212. + " "," "," "," "," "," "," "," "," ",
  2213. + },
  2214. + traps = true,
  2215. + },
  2216. + -- 6 pillars
  2217. + {
  2218. + style = "yrepeat",
  2219. + layout = {
  2220. + " "," "," "," "," "," "," "," "," ",
  2221. + " "," ","^"," ","^"," ","^"," "," ",
  2222. + " "," ","c"," ","c"," ","c"," "," ",
  2223. + " "," "," "," "," "," "," "," "," ",
  2224. + " "," "," "," "," "," "," "," "," ",
  2225. + " "," "," "," "," "," "," "," "," ",
  2226. + " "," ","c"," ","c"," ","c"," "," ",
  2227. + " "," ","v"," ","v"," ","v"," "," ",
  2228. + " "," "," "," "," "," "," "," "," ",
  2229. + },
  2230. + traps = true,
  2231. + },
  2232. + -- stripes
  2233. + {
  2234. + style = "yrepeat",
  2235. + layout = {
  2236. + " ","S","v","S","v","S","v","S","v",
  2237. + " ","S"," ","S"," ","S"," ","S"," ",
  2238. + " ","c"," ","c"," ","c"," ","c"," ",
  2239. + " "," "," "," "," "," "," "," "," ",
  2240. + " "," "," "," "," "," "," "," "," ",
  2241. + " "," "," "," "," "," "," "," "," ",
  2242. + " ","c"," ","c"," ","c"," ","c"," ",
  2243. + " ","S"," ","S"," ","S"," ","S"," ",
  2244. + " ","S","^","S","^","S","^","S","^",
  2245. + },
  2246. + traps = true,
  2247. + },
  2248. + -- inside
  2249. + {
  2250. + style = "yrepeat",
  2251. + layout = {
  2252. + " "," "," "," "," "," "," "," "," ",
  2253. + " ","c"," "," "," "," "," ","c"," ",
  2254. + " "," "," "," "," "," "," "," "," ",
  2255. + " "," "," ","c","S","c"," "," "," ",
  2256. + " "," "," ","S",">"," "," "," "," ",
  2257. + " "," "," ","c","S","c"," "," "," ",
  2258. + " "," "," "," "," "," "," "," "," ",
  2259. + " ","c"," "," "," "," "," ","c"," ",
  2260. + " "," "," "," "," "," "," "," "," ",
  2261. + },
  2262. + },
  2263. + -- 1 chest
  2264. + {
  2265. + style = "yrepeat",
  2266. + layout = {
  2267. + " "," "," "," "," "," "," "," "," ",
  2268. + " "," "," "," "," "," "," "," "," ",
  2269. + " "," "," "," "," "," "," "," "," ",
  2270. + " "," "," "," "," "," "," "," "," ",
  2271. + " "," "," "," ","<"," "," "," "," ",
  2272. + " "," "," "," "," "," "," "," "," ",
  2273. + " "," "," "," "," "," "," "," "," ",
  2274. + " "," "," "," "," "," "," "," "," ",
  2275. + " "," "," "," "," "," "," "," "," ",
  2276. + },
  2277. + traps = true,
  2278. + },
  2279. + -- 2 chests
  2280. + {
  2281. + style = "yrepeat",
  2282. + layout = {
  2283. + " "," "," "," "," "," "," "," "," ",
  2284. + " "," "," "," "," "," "," "," ","<",
  2285. + " "," "," "," "," "," "," "," "," ",
  2286. + " "," "," "," "," "," "," "," "," ",
  2287. + " "," "," "," "," "," "," "," "," ",
  2288. + " "," "," "," "," "," "," "," "," ",
  2289. + " "," "," "," "," "," "," "," "," ",
  2290. + " "," "," "," "," "," "," "," ","<",
  2291. + " "," "," "," "," "," "," "," "," ",
  2292. + },
  2293. + traps = true,
  2294. + },
  2295. + -- X
  2296. + {
  2297. + style = "yrepeat",
  2298. + layout = {
  2299. + "c"," "," "," "," "," "," "," ","c",
  2300. + "c","c",">"," "," "," ","<","c","c",
  2301. + " ","c","c"," "," "," ","c","c"," ",
  2302. + " "," ","c","c"," ","c","c"," "," ",
  2303. + " "," "," "," "," "," "," "," "," ",
  2304. + " "," ","c","c"," ","c","c"," "," ",
  2305. + " ","c","c"," "," "," ","c","c"," ",
  2306. + "c","c",">"," "," "," ","<","c","c",
  2307. + "c"," "," "," "," "," "," "," ","c",
  2308. + },
  2309. + },
  2310. + -- split 2
  2311. + {
  2312. + style = "yrepeat",
  2313. + layout = {
  2314. + "S","S","S","S","S","S","S","S","S",
  2315. + "S","S","S"," "," "," "," "," "," ",
  2316. + "S","S","S"," "," "," "," "," "," ",
  2317. + "S","S","S"," "," ","^","^","^","^",
  2318. + " "," "," "," "," ","c","c","c","c",
  2319. + "S","S","S"," "," ","v","v","v","v",
  2320. + "S","S","S"," "," "," "," "," "," ",
  2321. + "S","S","S"," "," "," "," "," "," ",
  2322. + "S","S","S","S","S","S","S","S","S",
  2323. + },
  2324. + },
  2325. + -- split 3
  2326. + {
  2327. + style = "yrepeat",
  2328. + layout = {
  2329. + " "," "," "," "," "," "," "," "," ",
  2330. + " "," "," "," "," "," "," "," "," ",
  2331. + " "," "," "," "," "," "," "," "," ",
  2332. + " ","^"," ","^"," ","^"," ","^"," ",
  2333. + " ","c"," ","c"," ","c"," ","c"," ",
  2334. + " ","v"," ","v"," ","v"," ","v"," ",
  2335. + " "," "," "," "," "," "," "," "," ",
  2336. + " "," "," "," "," "," "," "," "," ",
  2337. + " "," "," "," "," "," "," "," "," ",
  2338. + },
  2339. + traps = true,
  2340. + },
  2341. + -- diamond 2
  2342. + {
  2343. + style = "yrepeat",
  2344. + layout = {
  2345. + "S","S"," "," "," "," "," ","S","S",
  2346. + "S"," "," "," ","c"," "," "," ","S",
  2347. + " "," ","<","S","S","S",">"," "," ",
  2348. + " "," ","S","S","S","S","S"," "," ",
  2349. + " ","c","S","S","S","S","S","c"," ",
  2350. + " "," ","S","S","S","S","S"," "," ",
  2351. + " "," ","<","S","S","S",">"," "," ",
  2352. + "S"," "," "," ","c"," "," "," ","S",
  2353. + "S","S"," "," "," "," "," ","S","S",
  2354. + },
  2355. + traps = true,
  2356. + },
  2357. + -- ultra pillars
  2358. + {
  2359. + style = "yrepeat",
  2360. + layout = {
  2361. + " "," "," "," "," "," "," "," "," ",
  2362. + " ","c","^","c"," ","c","^","c"," ",
  2363. + " ","c","c","c"," ","c","c","c"," ",
  2364. + " ","c","c","c"," ","c","c","c"," ",
  2365. + " "," "," "," "," "," "," "," "," ",
  2366. + " ","c","c","c"," ","c","c","c"," ",
  2367. + " ","c","c","c"," ","c","c","c"," ",
  2368. + " ","c","v","c"," ","c","v","c"," ",
  2369. + " "," "," "," "," "," "," "," "," ",
  2370. + },
  2371. + },
  2372. + -- vstripes
  2373. + {
  2374. + style = "yrepeat",
  2375. + layout = {
  2376. + "S"," "," "," "," "," "," "," "," ",
  2377. + "S"," "," ","^"," "," ","^"," "," ",
  2378. + "S"," "," ","c"," "," ","c"," "," ",
  2379. + "S"," "," "," "," "," "," "," "," ",
  2380. + " "," "," ","c"," "," ","c"," "," ",
  2381. + "S"," "," "," "," "," "," "," "," ",
  2382. + "S"," "," ","c"," "," ","c"," "," ",
  2383. + "S"," "," ","v"," "," ","v"," "," ",
  2384. + "S"," "," "," "," "," "," "," "," ",
  2385. + },
  2386. + traps = true,
  2387. + },
  2388. + -- sides
  2389. + {
  2390. + style = "yrepeat",
  2391. + layout = {
  2392. + "c"," ","c"," ","c"," ","c"," ","c",
  2393. + " "," ","v"," ","v"," ","v"," "," ",
  2394. + "c"," "," "," "," "," "," "," ","c",
  2395. + " "," "," "," "," "," "," "," "," ",
  2396. + " "," "," "," "," "," "," "," ","c",
  2397. + " "," "," "," "," "," "," "," "," ",
  2398. + "c"," "," "," "," "," "," "," ","c",
  2399. + " "," ","^"," ","^"," ","^"," "," ",
  2400. + "c"," ","c"," ","c"," ","c"," ","c",
  2401. + },
  2402. + traps = true,
  2403. + },
  2404. + -- 9 pillars
  2405. + {
  2406. + style = "yrepeat",
  2407. + layout = {
  2408. + " "," "," "," "," "," "," "," "," ",
  2409. + " "," ","^"," ","^"," ","^"," "," ",
  2410. + " "," ","c"," ","c"," ","c"," "," ",
  2411. + " "," "," "," "," "," "," "," "," ",
  2412. + " "," ","c"," ","c"," ","c"," "," ",
  2413. + " "," "," "," "," "," "," "," "," ",
  2414. + " "," ","c"," ","c"," ","c"," "," ",
  2415. + " "," ","v"," ","v"," ","v"," "," ",
  2416. + " "," "," "," "," "," "," "," "," ",
  2417. + },
  2418. + traps = true,
  2419. + },
  2420. + -- Ankh statue
  2421. + {
  2422. + style = "stacked",
  2423. + layout = { {
  2424. + " "," "," "," "," "," "," "," "," ",
  2425. + " "," "," "," "," "," "," "," "," ",
  2426. + " "," "," "," "," "," "," "," "," ",
  2427. + " "," "," "," "," "," "," "," "," ",
  2428. + " "," "," "," ","s",">"," "," "," ",
  2429. + " "," "," "," "," "," "," "," "," ",
  2430. + " "," "," "," "," "," "," "," "," ",
  2431. + " "," "," "," "," "," "," "," "," ",
  2432. + " "," "," "," "," "," "," "," "," ",
  2433. + },{
  2434. + " "," "," "," "," "," "," "," "," ",
  2435. + " "," "," "," "," "," "," "," "," ",
  2436. + " "," "," "," "," "," "," "," "," ",
  2437. + " "," "," "," ","s"," "," "," "," ",
  2438. + " "," "," "," ","s"," "," "," "," ",
  2439. + " "," "," "," ","s"," "," "," "," ",
  2440. + " "," "," "," "," "," "," "," "," ",
  2441. + " "," "," "," "," "," "," "," "," ",
  2442. + " "," "," "," "," "," "," "," "," ",
  2443. + },{
  2444. + " "," "," "," "," "," "," "," "," ",
  2445. + " "," "," "," "," "," "," "," "," ",
  2446. + " "," "," "," "," "," "," "," "," ",
  2447. + " "," "," "," "," "," "," "," "," ",
  2448. + " "," "," "," ","s"," "," "," "," ",
  2449. + " "," "," "," "," "," "," "," "," ",
  2450. + " "," "," "," "," "," "," "," "," ",
  2451. + " "," "," "," "," "," "," "," "," ",
  2452. + " "," "," "," "," "," "," "," "," ",
  2453. + },{
  2454. + " "," "," "," "," "," "," "," "," ",
  2455. + " "," "," "," "," "," "," "," "," ",
  2456. + " "," "," "," "," "," "," "," "," ",
  2457. + " "," "," "," ","s"," "," "," "," ",
  2458. + " "," "," "," "," "," "," "," "," ",
  2459. + " "," "," "," ","s"," "," "," "," ",
  2460. + " "," "," "," "," "," "," "," "," ",
  2461. + " "," "," "," "," "," "," "," "," ",
  2462. + " "," "," "," "," "," "," "," "," ",
  2463. + },{
  2464. + " "," "," "," "," "," "," "," "," ",
  2465. + " "," "," "," "," "," "," "," "," ",
  2466. + " "," "," "," "," "," "," "," "," ",
  2467. + " "," "," "," "," "," "," "," "," ",
  2468. + " "," "," "," ","s"," "," "," "," ",
  2469. + " "," "," "," "," "," "," "," "," ",
  2470. + " "," "," "," "," "," "," "," "," ",
  2471. + " "," "," "," "," "," "," "," "," ",
  2472. + " "," "," "," "," "," "," "," "," ",
  2473. + }},
  2474. + stype = "desert_sandstone",
  2475. + wall = {
  2476. + "S","S","S","S","S","S","S","S","S",
  2477. + "s","1","s","1","s","1","s","1","s",
  2478. + "S","S","S","S","S","S","S","S","S",
  2479. + "1","s","1","s","1","s","1","s","1",
  2480. + "S","S","S","S","S","S","S","S","S",
  2481. + },
  2482. + },
  2483. +--[[
  2484. + -- Cactus room 1
  2485. + {
  2486. + style = "stacked",
  2487. + layout_offset = -1,
  2488. + layout_height = 5,
  2489. + layout = {{
  2490. + "s","s","s","s","s","s","s","s","s",
  2491. + "s","a","a","a","a","a","a","a","s",
  2492. + "s","a","a","a","a","a","a","a","s",
  2493. + "s","a","a","a","a","a","a","a","s",
  2494. + "s","a","a","a","a","a","a","a","s",
  2495. + "s","a","a","a","a","a","a","a","s",
  2496. + "s","a","a","a","a","a","a","a","s",
  2497. + "s","a","a","a","a","a","a","a","s",
  2498. + "s","s","s","s","s","s","s","s","s",
  2499. + },{
  2500. + " "," "," "," "," "," "," "," ","<",
  2501. + " ","C"," ","C"," ","C"," ","C"," ",
  2502. + " "," "," "," "," "," "," "," "," ",
  2503. + " ","C"," ","C"," ","C"," ","C"," ",
  2504. + " "," "," "," "," "," "," "," "," ",
  2505. + " ","C"," ","C"," ","C"," ","C"," ",
  2506. + " "," "," "," "," "," "," "," "," ",
  2507. + " ","C"," ","C"," ","C"," ","C"," ",
  2508. + " "," "," "," "," "," "," "," ","<",
  2509. +
  2510. + }},
  2511. + wall = {
  2512. + "S","S","S","S","S","S","S","S","S",
  2513. + "S","S","S","S","S","S","S","S","S",
  2514. + "s","3","s","3","s","3","s","3","s",
  2515. + "S","S","S","S","S","S","S","S","S",
  2516. + "S","S","S","S","S","S","S","S","S",
  2517. + },
  2518. + stype = "desert_sandstone",
  2519. + },
  2520. +]]
  2521. + -- Cactus room 2
  2522. + {
  2523. + style = "stacked",
  2524. + layout_offset = -1,
  2525. + layout_height = 5,
  2526. + layout = {{
  2527. + "S","S","S","S","S","S","S","S","S",
  2528. + "S","s","s","s","s","s","s","s","S",
  2529. + "S","s","a","a","a","a","a","s","S",
  2530. + "S","s","a","a","a","a","a","s","S",
  2531. + "S","s","a","a","a","a","a","s","S",
  2532. + "S","s","a","a","a","a","a","s","S",
  2533. + "S","s","a","a","a","a","a","s","S",
  2534. + "S","s","s","s","s","s","s","s","S",
  2535. + "S","S","S","S","S","S","S","S","S",
  2536. + },{
  2537. + " "," "," "," "," "," "," "," ","<",
  2538. + " "," "," "," "," "," "," "," "," ",
  2539. + " "," ","C"," ","C"," ","C"," "," ",
  2540. + " "," "," "," "," "," "," "," "," ",
  2541. + " "," ","C"," ","C"," ","C"," "," ",
  2542. + " "," "," "," "," "," "," "," "," ",
  2543. + " "," ","C"," ","C"," ","C"," "," ",
  2544. + " "," "," "," "," "," "," "," "," ",
  2545. + " "," "," "," "," "," "," "," ","<",
  2546. +
  2547. + }},
  2548. + wall = {
  2549. + "S","S","S","S","S","S","S","S","S",
  2550. + "S","S","S","S","S","S","S","S","S",
  2551. + "s","3","s","3","s","3","s","3","s",
  2552. + "S","S","S","S","S","S","S","S","S",
  2553. + "S","S","S","S","S","S","S","S","S",
  2554. + },
  2555. + stype = "desert_sandstone",
  2556. + },
  2557. + -- Sun room
  2558. + {
  2559. + style = "stacked",
  2560. + layout_offset = 0,
  2561. + layout_height = 8,
  2562. + layout = {{
  2563. + "n","s","s","s","s","s","s","s","n",
  2564. + "s","n","s","s","s","s","s","n","s",
  2565. + "s","s","n","n","n","n","n","s","s",
  2566. + "s","s","n","s","s","s","n","s","s",
  2567. + "s","s","n","s","s","s","n","s","s",
  2568. + "s","s","n","s","s","s","n","s","s",
  2569. + "s","s","n","n","n","n","n","s","s",
  2570. + "s","n","s","s","s","s","s","n","s",
  2571. + "n","s","s","s","s","s","s","s","n",
  2572. + },{
  2573. + " "," "," "," "," "," "," "," "," ",
  2574. + " "," "," "," "," "," "," "," "," ",
  2575. + " "," "," "," "," "," "," "," "," ",
  2576. + " "," "," "," "," "," "," "," "," ",
  2577. + " "," "," "," ","<"," "," "," "," ",
  2578. + " "," "," "," "," "," "," "," "," ",
  2579. + " "," "," "," "," "," "," "," "," ",
  2580. + " "," "," "," "," "," "," "," "," ",
  2581. + " "," "," "," "," "," "," "," "," ",
  2582. + },{
  2583. + "n","s","s","s","s","s","s","s","n",
  2584. + "s","n","s","s","s","s","s","n","s",
  2585. + "s","s","n","n","n","n","n","s","s",
  2586. + "s","s","n","s","s","s","n","s","s",
  2587. + "s","s","n","s","s","s","n","s","s",
  2588. + "s","s","n","s","s","s","n","s","s",
  2589. + "s","s","n","n","n","n","n","s","s",
  2590. + "s","n","s","s","s","s","s","n","s",
  2591. + "n","s","s","s","s","s","s","s","n",
  2592. + }},
  2593. + wall = {
  2594. + "S","S","S","S","S","S","S","S","S",
  2595. + "s","3","s","3","s","3","s","3","s",
  2596. + "S","S","S","S","S","S","S","S","S",
  2597. + "3","s","3","s","3","s","3","s","3",
  2598. + "S","S","S","S","S","S","S","S","S",
  2599. + },
  2600. + stype = "sandstone",
  2601. + open_roof = true,
  2602. + },
  2603. + -- Attic
  2604. + {
  2605. + style = "stacked",
  2606. + layout_height = 6,
  2607. + layout_offset = 1,
  2608. + layout = { {
  2609. + " "," "," "," "," "," "," "," "," ",
  2610. + " ","S","S","S"," ","S","S","S"," ",
  2611. + " ","S"," "," "," "," "," ","S"," ",
  2612. + " ","S"," "," "," "," "," ","S"," ",
  2613. + " "," "," "," ","c",">"," "," "," ",
  2614. + " ","S"," "," "," "," "," ","S"," ",
  2615. + " ","S"," "," "," "," "," ","S"," ",
  2616. + " ","S","S","S"," ","S","S","S"," ",
  2617. + " "," "," "," "," "," "," "," "," ",
  2618. + },{
  2619. + " "," "," "," "," "," "," "," "," ",
  2620. + " ","S","S","S"," ","S","S","S"," ",
  2621. + " ","S"," "," "," "," "," ","S"," ",
  2622. + " ","S"," "," "," "," "," ","S"," ",
  2623. + " "," "," "," ","c"," "," "," "," ",
  2624. + " ","S"," "," "," "," "," ","S"," ",
  2625. + " ","S"," "," "," "," "," ","S"," ",
  2626. + " ","S","S","S"," ","S","S","S"," ",
  2627. + " "," "," "," "," "," "," "," "," ",
  2628. + },{
  2629. + " "," "," "," "," "," "," "," "," ",
  2630. + " ","S","S","S"," ","S","S","S"," ",
  2631. + " ","S"," "," "," "," "," ","S"," ",
  2632. + " ","S"," "," "," "," "," ","S"," ",
  2633. + " "," "," "," ","c"," "," "," "," ",
  2634. + " ","S"," "," "," "," "," ","S"," ",
  2635. + " ","S"," "," "," "," "," ","S"," ",
  2636. + " ","S","S","S"," ","S","S","S"," ",
  2637. + " "," "," "," "," "," "," "," "," ",
  2638. + },{
  2639. + "s","s","s","s","s","s","s","s","s",
  2640. + "s","S","S","S","S","S","S","S","s",
  2641. + "s","S","s","s","s","s","s","S","s",
  2642. + "s","S","s","s","s","s","s","S","s",
  2643. + "s","S","s","s","s","s","s","S","s",
  2644. + "s","S","s","s","s","s","s","S","s",
  2645. + "s","S","s","s","s","s","s","S","s",
  2646. + "s","S","S","S","S","S","S","S","c",
  2647. + "s","s","s","s","s","s","s","s","s",
  2648. + },{
  2649. + "S","S","S","S","S","S","S","S","S",
  2650. + "S","S","S","S","v","S","S","S","S",
  2651. + "S","S"," "," "," "," "," ","S","S",
  2652. + "S","S"," "," "," "," "," ","S","S",
  2653. + "S",">"," "," "," "," "," ","<","S",
  2654. + "S","S"," "," "," "," "," ","S","S",
  2655. + "S","S"," "," "," "," "," ","S","S",
  2656. + "S","S","S","S","^","S","S","S","S",
  2657. + "S","S","S","S","S","S","S","S","S",
  2658. + },{
  2659. + "S","S","S","S","S","S","S","S","S",
  2660. + "S","S","S","S","S","S","S","S","S",
  2661. + "S","S"," "," "," "," "," ","S","S",
  2662. + "S","S"," "," "," "," "," ","S","S",
  2663. + "S","S"," "," "," "," "," ","S","S",
  2664. + "S","S"," "," "," "," "," ","S","S",
  2665. + "S","S"," "," "," "," "," ","S","S",
  2666. + "S","S","S","S","S","S","S","S","S",
  2667. + "S","S","S","S","S","S","S","S","S",
  2668. + }},
  2669. + },
  2670. +}
  2671. +
  2672. +local layout_traps_template = {
  2673. + "S","S","S","S","S","S","S","S","S",
  2674. + "?","?","?","?","?","?","?","?","S",
  2675. + "?","?","?","?","?","?","?","?","S",
  2676. + "?","?","?","?","?","?","?","?","S",
  2677. + "?","?","?","?","?","?","?","?","S", -- << entrance on left side
  2678. + "?","?","?","?","?","?","?","?","S",
  2679. + "?","?","?","?","?","?","?","?","S",
  2680. + "?","?","?","?","?","?","?","?","S",
  2681. + "S","S","S","S","S","S","S","S","S"
  2682. +}
  2683. +
  2684. +local code_sandstone = {
  2685. + [" "] = "air",
  2686. + ["c"] = "default:sandstone",
  2687. + ["s"] = "default:sandstone",
  2688. + ["n"] = "default:desert_sandstone",
  2689. + ["h"] = "default:sandstone",
  2690. + ["S"] = "default:sandstonebrick",
  2691. + ["1"] = "tsm_pyramids:deco_stone1",
  2692. + ["2"] = "tsm_pyramids:deco_stone2",
  2693. + ["3"] = "tsm_pyramids:deco_stone3",
  2694. + ["^"] = "default:chest",
  2695. + ["<"] = "default:chest",
  2696. + [">"] = "default:chest",
  2697. + ["v"] = "default:chest",
  2698. + ["~"] = "default:lava_source",
  2699. + ["t"] = "tsm_pyramids:trap",
  2700. + ["C"] = "default:large_cactus_seedling",
  2701. + ["a"] = "default:sand",
  2702. +}
  2703. +local code_desert_sandstone = table.copy(code_sandstone)
  2704. +code_desert_sandstone["c"] = "default:desert_sandstone"
  2705. +code_desert_sandstone["s"] = "default:desert_sandstone"
  2706. +code_desert_sandstone["n"] = "default:sandstone"
  2707. +code_desert_sandstone["h"] = "default:desert_sandstone"
  2708. +code_desert_sandstone["1"] = "tsm_pyramids:deco_stone4"
  2709. +code_desert_sandstone["2"] = "tsm_pyramids:deco_stone5"
  2710. +code_desert_sandstone["3"] = "tsm_pyramids:deco_stone6"
  2711. +code_desert_sandstone["S"] = "default:desert_sandstone_brick"
  2712. +code_desert_sandstone["t"] = "tsm_pyramids:desert_trap"
  2713. +code_desert_sandstone["a"] = "default:desert_sand"
  2714. +
  2715. +local code_desert_stone = table.copy(code_sandstone)
  2716. +code_desert_stone["c"] = "default:desert_stone_block"
  2717. +code_desert_stone["s"] = "default:desert_stone_block"
  2718. +code_desert_stone["n"] = "default:desert_stone_block"
  2719. +code_desert_stone["h"] = "default:desert_stone_block"
  2720. +code_desert_stone["1"] = "default:desert_stone_block"
  2721. +code_desert_stone["2"] = "default:desert_stone_block"
  2722. +code_desert_stone["3"] = "default:desert_stone_block"
  2723. +code_desert_stone["S"] = "default:desert_stonebrick"
  2724. +code_desert_stone["t"] = "air"
  2725. +code_desert_stone["a"] = "default:desert_sand"
  2726. +
  2727. +local function replace(str, iy, code_table, deco, column_style)
  2728. + if iy < 4 and (str == "<" or str == ">" or str == "^" or str == "v") then str = " " end
  2729. + if str == "h" then
  2730. + local r = math.random(0,3)
  2731. + if r > 0 then
  2732. + str = deco[r]
  2733. + else
  2734. + str = "c"
  2735. + end
  2736. + elseif column_style == 1 or column_style == 2 then
  2737. + if iy == 0 and str == "c" then str = deco[1] end
  2738. + if iy == 3 and str == "c" then str = deco[2] end
  2739. + elseif column_style == 3 then
  2740. + if iy == 0 and str == "c" then str = deco[1] end
  2741. + if iy == 2 and str == "c" then str = deco[2] end
  2742. + elseif column_style == 4 then
  2743. + if iy == 2 and str == "c" then str = deco[1] end
  2744. + end
  2745. + return code_table[str]
  2746. +end
  2747. +
  2748. +local function replace2(str, iy, depth, code_table, trap_node)
  2749. + if iy == depth then
  2750. + -- Sandstone at the bottom-most layer
  2751. + str = "s"
  2752. + elseif iy == depth-1 then
  2753. + -- Brick at the layer above
  2754. + str = "S"
  2755. + elseif iy == 0 and str == "~" then
  2756. + -- Trap stones at the top layer
  2757. + str = "t"
  2758. + elseif str == "~" then
  2759. + if iy < depth-3 then
  2760. + -- Air below the trap stones
  2761. + str = " "
  2762. + else
  2763. + str = trap_node
  2764. + end
  2765. + end
  2766. + -- Everything else is untouched (will stay pyramid material)
  2767. +
  2768. + return code_table[str]
  2769. +end
  2770. +
  2771. +local function get_flat_index(x, y, width)
  2772. + return 1 + x + y * width
  2773. +end
  2774. +
  2775. +local function rotate_layout_single(layout, width)
  2776. + local size = width*width
  2777. + local new_layout = {}
  2778. + for x=0, width-1 do
  2779. + for y=0, width-1 do
  2780. + local symbol = layout[get_flat_index((width-1) - y, x, width)]
  2781. + -- Rotate chest
  2782. + if symbol == "^" then
  2783. + symbol = "<"
  2784. + elseif symbol == "<" then
  2785. + symbol = "v"
  2786. + elseif symbol == "v" then
  2787. + symbol = ">"
  2788. + elseif symbol == ">" then
  2789. + symbol = "^"
  2790. + end
  2791. + new_layout[get_flat_index(x, y, width)] = symbol
  2792. + end
  2793. + end
  2794. + return new_layout
  2795. +end
  2796. +
  2797. +local function rotate_layout(layout, width, rotations)
  2798. + local new_layout = table.copy(layout)
  2799. + for r=1, rotations do
  2800. + new_layout = rotate_layout_single(new_layout, width)
  2801. + end
  2802. + return new_layout
  2803. +end
  2804. +
  2805. +-- pos: Position to spawn pyramid
  2806. +-- stype: Sand type ("sandstone" or "desert")
  2807. +-- room_id: Room layout identified (see list of rooms above)
  2808. +-- rotations: Number of times to rotate the room (0-3)
  2809. +function tsm_pyramids.make_room(pos, stype, room_id, rotations)
  2810. + local code_table = code_sandstone
  2811. + if stype == "desert_sandstone" then
  2812. + code_table = code_desert_sandstone
  2813. + elseif stype == "desert_stone" then
  2814. + code_table = code_desert_stone
  2815. + end
  2816. + -- Select random deco block
  2817. + local deco_ids = {"1", "2", "3"}
  2818. + local deco = {}
  2819. + for i=1, 3 do
  2820. + local r = math.random(1, #deco_ids)
  2821. + table.insert(deco, deco_ids[r])
  2822. + table.remove(deco_ids, r)
  2823. + end
  2824. + local hole = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
  2825. + if room_id == nil then
  2826. + room_id = math.random(1, #room_types)
  2827. + end
  2828. + local room
  2829. + if room_id < 1 or room_id > #room_types then
  2830. + return false, S("Incorrect room type ID: @1", room_id)
  2831. + end
  2832. + local room = table.copy(room_types[room_id])
  2833. + local tries = 0
  2834. + while tries < #room_types do
  2835. + if room.stype and room.stype ~= stype then
  2836. + room_id = room_id + 1
  2837. + if room_id > #room_types then
  2838. + room_id = 1
  2839. + end
  2840. + room = table.copy(room_types[room_id])
  2841. + else
  2842. + break
  2843. + end
  2844. + tries = tries + 1
  2845. + end
  2846. + local chests = {}
  2847. + local column_style
  2848. + if stype == "desert_stone" then
  2849. + column_style = 0
  2850. + else
  2851. + column_style = math.random(0,4)
  2852. + end
  2853. + -- Custom room walls
  2854. + if room.wall then
  2855. + for iy=0,4,1 do
  2856. + for ie=0,8,1 do
  2857. + local nn = code_table[room.wall[iy*9+ie+1]]
  2858. + minetest.set_node({x=hole.x+ie, y=hole.y-iy, z=hole.z-1}, {name=nn})
  2859. + minetest.set_node({x=hole.x-1, y=hole.y-iy, z=hole.z+ie}, {name=nn})
  2860. +
  2861. + minetest.set_node({x=hole.x+ie, y=hole.y-iy, z=hole.z+9}, {name=nn})
  2862. + minetest.set_node({x=hole.x+9, y=hole.y-iy, z=hole.z+ie}, {name=nn})
  2863. + end
  2864. + end
  2865. + end
  2866. + local layout
  2867. + -- Place the room nodes
  2868. + if room.style == "yrepeat" then
  2869. + layout = rotate_layout(room.layout, ROOM_WIDTH, rotations)
  2870. + for iy=0,4,1 do
  2871. + for ix=0,8,1 do
  2872. + for iz=0,8,1 do
  2873. + local n_str = layout[ix*9+iz+1]
  2874. + local p2 = 0
  2875. + if n_str == "<" then
  2876. + p2 = 0
  2877. + elseif n_str == ">" then
  2878. + p2 = 2
  2879. + elseif n_str == "^" then
  2880. + p2 = 1
  2881. + elseif n_str == "v" then
  2882. + p2 = 3
  2883. + end
  2884. + local cpos = {x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}
  2885. + local nn = replace(n_str, iy, code_table, deco, column_style)
  2886. + minetest.set_node(cpos, {name=nn, param2=p2})
  2887. + if nn == "default:chest" then
  2888. + table.insert(chests, cpos)
  2889. + end
  2890. + end
  2891. + end
  2892. + end
  2893. + elseif room.style == "stacked" then
  2894. + local layout_list = room.layout
  2895. + local layout
  2896. + local layout_offset = room.layout_offset
  2897. + local layout_height = room.layout_height
  2898. + if not layout_offset then
  2899. + layout_offset = 0
  2900. + end
  2901. + if not layout_height then
  2902. + layout_height = 5
  2903. + end
  2904. + for iy=0,layout_height-1,1 do
  2905. + layout = nil
  2906. + if layout_list[layout_height-iy] then
  2907. + layout = rotate_layout(layout_list[layout_height-iy], ROOM_WIDTH, rotations)
  2908. + end
  2909. + for ix=0,8,1 do
  2910. + for iz=0,8,1 do
  2911. + local n_str
  2912. + if layout then
  2913. + n_str = layout[ix*9+iz+1]
  2914. + else
  2915. + n_str = " "
  2916. + end
  2917. + local p2 = 0
  2918. + if n_str == "<" then
  2919. + p2 = 0
  2920. + elseif n_str == ">" then
  2921. + p2 = 2
  2922. + elseif n_str == "^" then
  2923. + p2 = 1
  2924. + elseif n_str == "v" then
  2925. + p2 = 3
  2926. + end
  2927. + local cpos = {x=hole.x+ix,y=hole.y-iy+layout_offset,z=hole.z+iz}
  2928. + local nn = code_table[n_str]
  2929. + minetest.set_node(cpos, {name=nn, param2=p2})
  2930. + if nn == "default:chest" then
  2931. + table.insert(chests, cpos)
  2932. + end
  2933. + end
  2934. + end
  2935. + end
  2936. + else
  2937. + minetest.log("error", "Invalid pyramid room style! room type ID="..r)
  2938. + end
  2939. + local sanded = room.flood_sand ~= false and stype ~= "desert_stone" and math.random(1,8) == 1
  2940. + if #chests > 0 then
  2941. + -- Make at least 8 attempts to fill chests
  2942. + local filled = 0
  2943. + local chests_with_treasure = 0
  2944. + while filled < 8 do
  2945. + for c=1, #chests do
  2946. + local has_treasure = tsm_pyramids.fill_chest(chests[c], stype, sanded, 30)
  2947. + if has_treasure then
  2948. + chests_with_treasure = chests_with_treasure + 1
  2949. + end
  2950. + filled = filled + 1
  2951. + end
  2952. + end
  2953. + -- If no chests were filled with treasure so far, fill a random chest guaranteed
  2954. + if chests_with_treasure == 0 then
  2955. + tsm_pyramids.fill_chest(chests[math.random(1, #chests)], stype, sanded, 100)
  2956. + end
  2957. + end
  2958. + if room.traps and math.random(1,4) == 1 then
  2959. + tsm_pyramids.make_traps(pos, stype, rotations, layout)
  2960. + end
  2961. + if sanded then
  2962. + tsm_pyramids.flood_sand(pos, stype)
  2963. + end
  2964. + return true, nil, sanded
  2965. +end
  2966. +
  2967. +local shuffle_traps = function(layout_traps, layout_room, chance)
  2968. + for a=1, #layout_traps do
  2969. + -- Delete trap if this space of the room is occupied
  2970. + if layout_room[a] ~= " " then
  2971. + layout_traps[a] = "S"
  2972. + -- Randomly turn tile into a trap, or not
  2973. + elseif layout_traps[a] == "?" then
  2974. + -- percentage for a trap
  2975. + if math.random(1,100) <= chance then
  2976. + layout_traps[a] = "~"
  2977. + else
  2978. + layout_traps[a] = "S"
  2979. + end
  2980. + end
  2981. + end
  2982. +end
  2983. +
  2984. +function tsm_pyramids.make_traps(pos, stype, rotations, layout_room)
  2985. + local code_table = code_sandstone
  2986. + if stype == "desert_sandstone" then
  2987. + code_table = code_desert_sandstone
  2988. + elseif stype == "desert_stone" then
  2989. + code_table = code_desert_stone
  2990. + end
  2991. + local layout_traps = table.copy(layout_traps_template)
  2992. + layout_traps = rotate_layout(layout_traps, ROOM_WIDTH, rotations)
  2993. + shuffle_traps(layout_traps, layout_room, math.random(10,100))
  2994. + -- Depth is total depth of trap area:
  2995. + -- * top layer with trap stones
  2996. + -- * followed by air layers
  2997. + -- * followed by 2 layers of lava
  2998. + -- * and 2 layers of sandstone/brick at the bottom (to prevent lava escaping)
  2999. + -- The depth of air between trap stones and lava layer is <depth> - 4
  3000. + local deep_trap = math.random(1,2) == 1
  3001. + local trap_node
  3002. + if deep_trap then
  3003. + trap_node = " "
  3004. + depth = 14
  3005. + else
  3006. + trap_node = "~"
  3007. + depth = 7
  3008. + end
  3009. + local wmin, wmax = -1,9
  3010. + local hole = {x=pos.x+7,y=pos.y, z=pos.z+7}
  3011. + for iy=0,depth,1 do
  3012. + for ix=wmin,wmax,1 do
  3013. + for iz=wmin,wmax,1 do
  3014. + local n_str
  3015. + if ix == wmin or ix == wmax or iz == wmin or iz == wmax then
  3016. + -- Walls around room
  3017. + if iy == depth then
  3018. + n_str = code_table["s"]
  3019. + else
  3020. + n_str = code_table["S"]
  3021. + end
  3022. + minetest.set_node({x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}, {name=n_str})
  3023. + else
  3024. + n_str = layout_traps[ix*9+iz+1]
  3025. + minetest.set_node({x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}, {name=replace2(n_str, iy, depth, code_table, trap_node)})
  3026. + end
  3027. + end
  3028. + end
  3029. + end
  3030. +end
  3031. +
  3032. +function tsm_pyramids.flood_sand(pos, stype)
  3033. + local set_to_sand = {}
  3034. + local nn = "default:sand"
  3035. + if stype == "desert_sandstone" or stype == "desert_stone" then
  3036. + nn = "default:desert_sand"
  3037. + end
  3038. + local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
  3039. + local maxh = math.random(1,4)
  3040. + local chance = math.random(1,7)
  3041. + for ix=0,8,1 do
  3042. + for iz=0,8,1 do
  3043. + if math.random(1,chance) == 1 then
  3044. + local h = math.random(1,maxh)
  3045. + for iy=0,h,1 do
  3046. + local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
  3047. + if minetest.get_node(p).name == "air" then
  3048. + table.insert(set_to_sand, p)
  3049. + end
  3050. + end
  3051. + end
  3052. + end
  3053. + end
  3054. + minetest.bulk_set_node(set_to_sand, {name=nn})
  3055. end
  3056. Common subdirectories: ../games/Bucket_Game/mods/codercore/tsm_pyramids/sounds and /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/sounds
  3057. Only in /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids: src
  3058. Common subdirectories: ../games/Bucket_Game/mods/codercore/tsm_pyramids/textures and /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids/textures
  3059. Only in /home/owner/Downloads/minetest.org/insider-prerelease/EN00356/tsm_pyramids: TODO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement