rings.lua 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. --Aliases:
  2. minetest.register_alias("lottores:blue_gem_ore", "lottother:blue_gem_ore")
  3. minetest.register_alias("lottores:red_gem_ore", "lottother:red_gem_ore")
  4. minetest.register_alias("lottores:white_gem_ore", "lottother:white_gem_ore")
  5. minetest.register_alias("lottores:blue_gem", "lottother:blue_gem")
  6. minetest.register_alias("lottores:red_gem", "lottother:red_gem")
  7. minetest.register_alias("lottores:white_gem", "lottother:white_gem")
  8. minetest.register_alias("lottother:blue_am_ring", "lottother:blue_rr_ring")
  9. minetest.register_alias("lottother:red_am_ring", "lottother:red_rr_ring")
  10. minetest.register_alias("lottother:white_am_ring", "lottother:white_rr_ring")
  11. minetest.register_alias("lottother:purple_gem_mithril_ring", "lottother:purple_am_ring")
  12. minetest.register_alias("lottother:ringsilver_lump", "lottother:ringsilver")
  13. minetest.register_alias("lottother:ringsilver_ingot", "lottother:ringsilver")
  14. minetest.register_privilege("purity", {
  15. description = "Immunity against corruption effects",
  16. give_to_singleplayer = false,
  17. })
  18. local function ring_drop(itemstack, dropper, pos)
  19. local ent = lottother.item_drop(itemstack, dropper, pos)
  20. minetest.after(5, function()
  21. if ent ~= nil then
  22. local pos = ent:getpos()
  23. if pos ~= nil then
  24. local node = minetest.get_node(pos).name
  25. if node == "default:lava_source" then
  26. ent:set_velocity({x=0, y=15, z=0})
  27. ent:set_properties({automatic_rotate = 30, pointable = false})
  28. minetest.add_particlespawner({
  29. amount = 500,
  30. time = 5,
  31. minvel = {x=-3, y=3, z=-3},
  32. maxvel = {x=3, y=7, z=3},
  33. minacc = {x=-2, y=1, z=-2},
  34. maxacc = {x=2, y=5, z=2},
  35. minexptime = 1,
  36. maxexptime = 4,
  37. attached = ent,
  38. glow = 14,
  39. texture = "fire_basic_flame.png",
  40. })
  41. if dropper then
  42. dropper:override_day_night_ratio(0)
  43. end
  44. minetest.after(5, function()
  45. if ent then
  46. ent:remove()
  47. default.explode(pos, 0, 5, 10)
  48. default.explode(pos, 3, 20, 20)
  49. default.explode(pos, 10, 40, 40)
  50. end
  51. minetest.after(20, function()
  52. if dropper then
  53. dropper:override_day_night_ratio(nil)
  54. end
  55. end)
  56. end)
  57. end
  58. end
  59. end
  60. end)
  61. end
  62. --ELF RINGS
  63. --FUNCTION = Fast health regeneration + Breathing underwater + Flight / Emits blue particles
  64. minetest.register_craftitem("lottother:vilya", {
  65. description = minetest.colorize("skyblue", "Vilya\nElven Ring of Air") ..
  66. minetest.get_background_escape_sequence("lightgoldenrodyellow"),
  67. inventory_image = "lottother_vilya.png",
  68. stack_max = 1,
  69. groups = {forbidden=1},
  70. on_drop = function(itemstack, dropper, pos)
  71. ring_drop(itemstack, dropper, pos)
  72. end,
  73. })
  74. --FUNCTION = Makes (good) mobs follow you + deadly attack + Invisibility
  75. minetest.register_craftitem("lottother:narya", {
  76. description = minetest.colorize("crimson", "Narya\nElven Ring of Fire") ..
  77. minetest.get_background_escape_sequence("lightgoldenrodyellow"),
  78. inventory_image = "lottother_narya.png",
  79. stack_max = 1,
  80. groups = {forbidden=1},
  81. tool_capabilities = {
  82. full_punch_interval = 10.00,
  83. max_drop_level=1,
  84. groupcaps={
  85. snappy={times={[1]=2.50, [2]=1.30, [3]=0.45}, uses=0, maxlevel=3},
  86. },
  87. damage_groups = {fleshy=50},
  88. },
  89. on_drop = function(itemstack, dropper, pos)
  90. ring_drop(itemstack, dropper, pos)
  91. end,
  92. })
  93. --In mob def:
  94. --follow = "lottother:narya",
  95. --FUNCTION = Physical-damage immunity / Emits white particles
  96. minetest.register_craftitem("lottother:nenya", {
  97. description = minetest.colorize("silver", "Nenya\nElven Ring of Immunity") ..
  98. minetest.get_background_escape_sequence("lightgoldenrodyellow"),
  99. inventory_image = "lottother_nenya_inv.png",
  100. stack_max = 1,
  101. groups = {forbidden=1},
  102. on_drop = function(itemstack, dropper, pos)
  103. ring_drop(itemstack, dropper, pos)
  104. end,
  105. })
  106. local time = 0
  107. lottother = {}
  108. lottother.corrupt = {}
  109. minetest.register_globalstep(function(dtime)
  110. time = time + dtime
  111. if time > 1 then
  112. time = 0
  113. for _, player in ipairs(minetest.get_connected_players()) do
  114. local name = player:get_player_name()
  115. local wield = player:get_inventory():get_stack("main", player:get_wield_index()):get_name()
  116. if lottother.corrupt == nil then
  117. lottother.corrupt = {}
  118. end
  119. if lottother.corrupt[name] == nil or not tonumber(lottother.corrupt[name]) then
  120. lottother.corrupt[name] = 0
  121. end
  122. -- corruption effect
  123. if wield == "lottother:nenya" or wield == "lottother:vilya" or wield == "lottother:narya" or wield == "lottother:dwarf_ring" then
  124. lottother.corrupt[name] = lottother.corrupt[name] + 1
  125. local corruption = tonumber(lottother.corrupt[name])
  126. if corruption > 29 and minetest.get_player_privs(name).GAMEwizard == nil and minetest.get_player_privs(name).purity == nil then
  127. if corruption == 30 then
  128. lottother.corrupt[name.."_1"] = player:hud_add({
  129. hud_elem_type = "image",
  130. position = {x=0.5, y=0.5},
  131. scale = {x=-100, y=-100},
  132. text = "lottother_corruption.png",
  133. offset = {x=0, y=0},
  134. })
  135. elseif corruption == 60 then
  136. lottother.corrupt[name.."_2"] = player:hud_add({
  137. hud_elem_type = "image",
  138. position = {x=0.5, y=0.5},
  139. scale = {x=-100, y=-100},
  140. text = "lottother_corruption.png",
  141. offset = {x=0, y=0},
  142. })
  143. elseif corruption == 90 then
  144. lottother.corrupt[name.."_3"] = player:hud_add({
  145. hud_elem_type = "image",
  146. position = {x=0.5, y=0.5},
  147. scale = {x=-100, y=-100},
  148. text = "lottother_corruption.png",
  149. offset = {x=0, y=0},
  150. })
  151. elseif corruption == 120 then
  152. lottother.corrupt[name.."_4"] = player:hud_add({
  153. hud_elem_type = "image",
  154. position = {x=0.5, y=0.5},
  155. scale = {x=-100, y=-100},
  156. text = "lottother_corruption_eye.png",
  157. offset = {x=0, y=0},
  158. })
  159. elseif corruption > 135 then
  160. player:set_hp(player:get_hp()-0.5)
  161. end
  162. end
  163. elseif tonumber(lottother.corrupt[name]) > 0 then
  164. lottother.corrupt[name] = lottother.corrupt[name] - 1
  165. local corruption = tonumber(lottother.corrupt[name])
  166. if corruption < 30 then
  167. player:hud_remove(lottother.corrupt[name.."_1"])
  168. elseif corruption < 60 then
  169. player:hud_remove(lottother.corrupt[name.."_2"])
  170. elseif corruption < 90 then
  171. player:hud_remove(lottother.corrupt[name.."_3"])
  172. elseif corruption < 120 then
  173. player:hud_remove(lottother.corrupt[name.."_4"])
  174. end
  175. end
  176. -- nenya ring
  177. if wield == "lottother:nenya" then
  178. if player:get_attribute("lott:immunity") == nil then
  179. player:set_attribute("lott:immunity", "ring")
  180. armor:set_player_armor(player)
  181. end
  182. end
  183. if player:get_attribute("lott:immunity") == "ring" then
  184. if wield ~= "lottother:nenya" then
  185. player:set_attribute("lott:immunity", nil)
  186. armor:set_player_armor(player)
  187. end
  188. end
  189. -- vilya ring
  190. if wield == "lottother:vilya" then
  191. -- handle hp
  192. if player:get_hp() < 20 and player:get_hp() > 0 then
  193. if tonumber(lottother.corrupt[name]) then
  194. if lottother.corrupt[name] < 120 then
  195. player:set_hp(player:get_hp()+2)
  196. end
  197. end
  198. end
  199. -- handle breath
  200. if player:get_breath() < 10 then
  201. player:set_breath(10)
  202. end
  203. -- handle flight
  204. if player:get_attribute("lott:vilya") == nil and minetest.get_player_privs(name).fly == nil then
  205. local privs = minetest.get_player_privs(name)
  206. privs.fly = true
  207. minetest.set_player_privs(name, privs)
  208. player:set_attribute("lott:vilya", "ring")
  209. end
  210. end
  211. -- remove flight
  212. if player:get_attribute("lott:vilya") == "ring" then
  213. if wield ~= "lottother:vilya" then
  214. local privs = minetest.get_player_privs(name)
  215. privs.fly = nil
  216. minetest.set_player_privs(name, privs)
  217. player:set_attribute("lott:vilya", nil)
  218. end
  219. end
  220. -- narya ring
  221. if player:get_attribute("lott:narya") == nil and wield == "lottother:narya" then
  222. player:set_properties({visual_size = {x = 0, y = 0}})
  223. player:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}})
  224. player:set_attribute("lott:narya", "ring")
  225. end
  226. if player:get_attribute("lott:narya") == "ring" then
  227. if wield ~= "lottother:narya" then
  228. player:set_properties({visual_size = {x = 1, y = 1}})
  229. player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
  230. player:set_attribute("lott:narya", nil)
  231. end
  232. end
  233. end
  234. end
  235. end)
  236. -- remove ring corruption upon death
  237. minetest.register_on_dieplayer(function(player)
  238. local name = player:get_player_name()
  239. if tonumber(lottother.corrupt[name]) then
  240. lottother.corrupt[name] = nil
  241. player:hud_remove(lottother.corrupt[name.."_1"])
  242. player:hud_remove(lottother.corrupt[name.."_2"])
  243. player:hud_remove(lottother.corrupt[name.."_3"])
  244. player:hud_remove(lottother.corrupt[name.."_4"])
  245. end
  246. end)
  247. -- Ring Particles Trail
  248. local time2 = 0
  249. minetest.register_globalstep(function(dtime)
  250. time2 = time2 + dtime
  251. if time2 > 0.3 then
  252. time2 = 0
  253. for _, player in ipairs(minetest.get_connected_players()) do
  254. local name = player:get_player_name()
  255. local pos = player:getpos()
  256. -- nenya ring particles
  257. if player:get_inventory():get_stack("main", player:get_wield_index()):get_name() == "lottother:nenya" then
  258. minetest.add_particlespawner({
  259. amount = 5,
  260. time = 0.01,
  261. minpos = {x = pos.x - 0.25, y = pos.y + 0.5, z = pos.z - 0.25},
  262. maxpos = {x = pos.x + 0.25, y = pos.y + 1, z = pos.z + 0.25},
  263. minvel = {x = -0.5, y = 0, z = -0.5},
  264. maxvel = {x = 0.5, y = 0.1, z = 0.5},
  265. minacc = {x = 0, y = 0, z = 0},
  266. maxacc = {x = 0, y = -0.1, z = 0},
  267. minexptime = 0.25,
  268. maxexptime = 3.0,
  269. minsize = 0.5,
  270. maxsize = 1.0,
  271. vertical = false,
  272. collisiondetection = false,
  273. texture = "lottother_orb_white.png",
  274. glow = 12,
  275. })
  276. -- vilya ring particles
  277. elseif player:get_inventory():get_stack("main", player:get_wield_index()):get_name() == "lottother:vilya" then
  278. minetest.add_particlespawner({
  279. amount = 5,
  280. time = 0.01,
  281. minpos = {x = pos.x - 0.25, y = pos.y + 0.5, z = pos.z - 0.25},
  282. maxpos = {x = pos.x + 0.25, y = pos.y + 1, z = pos.z + 0.25},
  283. minvel = {x = -0.5, y = 0, z = -0.5},
  284. maxvel = {x = 0.5, y = 0.1, z = 0.5},
  285. minacc = {x = 0, y = 0, z = 0},
  286. maxacc = {x = 0, y = -0.1, z = 0},
  287. minexptime = 0.25,
  288. maxexptime = 3.0,
  289. minsize = 0.5,
  290. maxsize = 1.0,
  291. vertical = false,
  292. collisiondetection = false,
  293. texture = "lottother_orb_blue.png",
  294. glow = 12,
  295. })
  296. -- dwarven ring particles
  297. elseif player:get_inventory():get_stack("main", player:get_wield_index()):get_name() == "lottother:dwarf_ring" then
  298. minetest.add_particlespawner({
  299. amount = 5,
  300. time = 0.01,
  301. minpos = {x = pos.x - 0.25, y = pos.y + 0.5, z = pos.z - 0.25},
  302. maxpos = {x = pos.x + 0.25, y = pos.y + 1, z = pos.z + 0.25},
  303. minvel = {x = -0.5, y = 0, z = -0.5},
  304. maxvel = {x = 0.5, y = 0.1, z = 0.5},
  305. minacc = {x = 0, y = 0, z = 0},
  306. maxacc = {x = 0, y = -0.1, z = 0},
  307. minexptime = 0.25,
  308. maxexptime = 3.0,
  309. minsize = 0.5,
  310. maxsize = 1.0,
  311. vertical = false,
  312. collisiondetection = false,
  313. texture = "lottother_orb_purple.png",
  314. glow = 12,
  315. })
  316. end
  317. end
  318. end
  319. end)
  320. --------------------------------------------------------
  321. --Dwarf Ring = Punching an ore will destroy it in a puff of smoke and multiply the resource drops
  322. local dwarf_ring_multiply = {
  323. -- ore block, ore drop, min drop, max drop
  324. { "lottores:rough_rock", "lottores:rough_rock_lump", 1, 2 },
  325. { "lottores:silver_ore", "lottores:silver_lump", 1, 3 },
  326. { "lottores:tin_ore", "lottores:tin_lump", 2, 4 },
  327. { "lottores:lead_ore", "lottores:lead_lump", 2, 3 },
  328. { "lottores:mithril_ore", "lottores:mithril_lump", 1, 2 },
  329. { "lottores:orc_ore", "lottores:orc_lump", 2, 4 },
  330. { "lottores:limestone", "lottores:marble", 5, 13 },
  331. { "lottores:mineral_pearl", "lottores:pearl", 1, 3 },
  332. { "lottores:mineral_salt", "lottores:salt", 5, 7 },
  333. { "default:stone_with_coal", "default:coal_lump", 3, 6 },
  334. { "default:stone_with_iron", "default:iron_lump", 2, 4 },
  335. { "darkage:desert_stone_with_iron", "default:iron_lump", 2, 4 },
  336. { "default:stone_with_copper", "default:copper_lump", 2, 3 },
  337. { "default:stone_with_mese", "default:mese_crystal", 1, 2 },
  338. { "default:stone_with_gold", "default:gold_lump", 1, 3 },
  339. }
  340. minetest.register_craftitem("lottother:dwarf_ring", {
  341. description = minetest.colorize("darkviolet", "Dwarven Ring of Power") ..
  342. minetest.get_background_escape_sequence("lightgoldenrodyellow"),
  343. inventory_image = "lottother_dwarf_ring.png",
  344. stack_max = 1,
  345. groups = {forbidden=1},
  346. on_use = function(itemstack, user, pointed_thing)
  347. local name = user:get_player_name()
  348. if pointed_thing.type == "node" then
  349. local pos = pointed_thing.under
  350. if minetest.is_protected(pos, name) then
  351. return
  352. end
  353. local nn = minetest.get_node(pos).name
  354. for i in ipairs(dwarf_ring_multiply) do
  355. local name = dwarf_ring_multiply[i][1]
  356. local drop = dwarf_ring_multiply[i][2]
  357. local mind = dwarf_ring_multiply[i][3]
  358. local maxd = dwarf_ring_multiply[i][4]
  359. if nn == name then
  360. minetest.dig_node(pos)
  361. minetest.add_particlespawner({
  362. amount = 5,
  363. time = 0.01,
  364. minpos = {x = pos.x - 0.25, y = pos.y, z = pos.z - 0.25},
  365. maxpos = {x = pos.x + 0.25, y = pos.y, z = pos.z + 0.25},
  366. minvel = {x = -0.5, y = 0, z = -0.5},
  367. maxvel = {x = 0.5, y = 0.1, z = 0.5},
  368. minacc = {x = 0, y = 0.5, z = 0},
  369. maxacc = {x = 0, y = 1, z = 0},
  370. minexptime = 0.25,
  371. maxexptime = 2.0,
  372. minsize = 2.0,
  373. maxsize = 5.0,
  374. vertical = false,
  375. collisiondetection = true,
  376. texture = "smoke_puff.png",
  377. })
  378. minetest.add_item(pos, drop .. " " .. math.random(mind, maxd))
  379. end
  380. end
  381. end
  382. end,
  383. on_drop = function(itemstack, dropper, pos)
  384. ring_drop(itemstack, dropper, pos)
  385. end,
  386. })