From 2e6ec485b0a89784bfe3d1fd8e4b45a7f8e6b108 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Mon, 14 Mar 2016 21:14:58 +0100 Subject: [PATCH] [runes] Add glyphs and stylus --- mods/runes/glyphs.lua | 234 ++++++++++++++++++ mods/runes/init.lua | 10 + mods/runes/scrolls.lua | 35 +++ .../textures/runes_glyph_deus_ex_machina.png | Bin 0 -> 418 bytes .../runes/textures/runes_glyph_manasucker.png | Bin 0 -> 145 bytes .../runes/textures/runes_glyph_spontafire.png | Bin 0 -> 139 bytes mods/runes/textures/runes_glyph_watchdog.png | Bin 0 -> 173 bytes .../textures/runes_scroll_deus_ex_machina.png | Bin 0 -> 410 bytes .../textures/runes_scroll_manasucker.png | Bin 0 -> 215 bytes mods/runes/textures/runes_scroll_unknown.png | Bin 0 -> 209 bytes mods/runes/textures/runes_scroll_watchdog.png | Bin 0 -> 257 bytes mods/runes/textures/runes_stylus.png | Bin 0 -> 247 bytes 12 files changed, 279 insertions(+) create mode 100644 mods/runes/glyphs.lua create mode 100644 mods/runes/scrolls.lua create mode 100644 mods/runes/textures/runes_glyph_deus_ex_machina.png create mode 100644 mods/runes/textures/runes_glyph_manasucker.png create mode 100644 mods/runes/textures/runes_glyph_spontafire.png create mode 100644 mods/runes/textures/runes_glyph_watchdog.png create mode 100644 mods/runes/textures/runes_scroll_deus_ex_machina.png create mode 100644 mods/runes/textures/runes_scroll_manasucker.png create mode 100644 mods/runes/textures/runes_scroll_unknown.png create mode 100644 mods/runes/textures/runes_scroll_watchdog.png create mode 100644 mods/runes/textures/runes_stylus.png diff --git a/mods/runes/glyphs.lua b/mods/runes/glyphs.lua new file mode 100644 index 00000000..ff9ba344 --- /dev/null +++ b/mods/runes/glyphs.lua @@ -0,0 +1,234 @@ +-- A stylus to inscribe glyphs +-- Part of a Rune Mod Redo +-- By Mg, 2016 +-- License : WTFPL +-- + +runes.glyphs = {} + +minetest.register_tool("runes:stylus", { + description = "Stylus", + inventory_image = "runes_stylus.png", + on_use = function(itemstack, user, pointed_thing) + if not user or pointed_thing.type ~= "node" then return end + + local node = minetest.get_node_or_nil(pointed_thing.under) + if not node or not minetest.registered_nodes[node.name].walkable then + return + end + + node = minetest.get_node_or_nil(pointed_thing.above) + if not node or node.name ~= "air" then + return + end + + local main_inv = user:get_inventory():get_list("main") + local scroll = main_inv[user:get_wield_index()-1] + if not scroll then + minetest.chat_send_player(user:get_player_name(), "There is no scroll before the stylus in your inventory!") + return + elseif minetest.get_item_group(scroll:get_name(), "scroll") == 0 then + minetest.chat_send_player(user:get_player_name(), "The item before your stylus is not a scroll of knowledge!") + return + end + + local name = scroll:get_name():gsub("runes:scroll_", "") + if not runes.scrolls[name] then return end + local glyph = runes.scrolls[name].glyph + if not glyph then return end + + if mana.get(user:get_player_name()) < runes.glyphs[name].mana_cost then + minetest.chat_send_player(user:get_player_name(), "You need " .. runes.glyphs[name].mana_cost .. " of mana to inscribe that glyph") + return + end + + -- Calculate param2 manually since MineTest doesn't even do it + local diff = vector.subtract(pointed_thing.under, pointed_thing.above) + + minetest.add_node(pointed_thing.above, {name = glyph, param2 = minetest.dir_to_wallmounted(diff)}) + minetest.get_meta(pointed_thing.above):set_string("master", user:get_player_name()) + + itemstack:add_wear(65535 / 30) + mana.subtract(user:get_player_name(), runes.glyphs[name].mana_cost) + return itemstack + end, +}) + +minetest.register_craft({ + output = "runes:stylus", + recipe = { + {"", "default:obsidian_shard", "moreores:mithril_ingot"}, + {"default:obsidian_shard", "default:nyancat_rainbow", "default:obsidian_shard"}, + {"default:obsidian_shard", "default:obsidian_shard", ""}, + }, +}) + +function register_glyph(name, basics, tab) + --[[ Basics can contain : + - texture = "runes_glyph_unknown.png", + - description = "Mysterious Glyph", + - initial_charge = 0 + - mana_cost = 0 + --]] + + runes.glyphs[name] = {} + runes.glyphs[name].mana_cost = basics.mana_cost or 0 + + def = table.copy(tab) + def.groups.glyph = 1 + + def.description = basics.description or "Mysterious Glyph" + def.inventory_image = basics.texture or "runes_glyph_unknown.png" + def.tiles = {basics.texture or "default_stone.png"} + def.on_construct = function(pos) + minetest.get_meta(pos):set_int("charge", (basics.initial_charge or 0)) + tab.on_construct(pos) + end + + def.drawtype = "signlike" + def.paramtype = "light" + def.paramtype2 = "wallmounted" + def.selection_box = { + type = "wallmounted", + wall_top = {-0.5, 0.4, -0.5, 0.5, 0.5, 0.5}, + wall_bottom = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}, + wall_side = {-0.5, -0.5, -0.5, -0.4, 0.5, 0.5}, + } + def.walkable = false + + minetest.register_node("runes:glyph_" .. name, def) +end + + +register_glyph("watchdog", { + description = "Watch Dog Glyph", + texture = "runes_glyph_watchdog.png", + initial_charge = 250, + mana_cost = 10, + }, { + light_source = 8, + groups = {snappy = 1}, + on_construct = function(pos) + minetest.get_node_timer(pos):start(0.2) + end, + on_timer = function(pos, elapsed) + local meta = minetest.get_meta(pos) + if meta:get_int("charge") <= 0 then + minetest.add_particlespawner({ + amount = 10, + minpos = pos, maxpos = pos, + minvel = vel, maxvel = vector.multiply(vel, 3), + minacc = 0, maxacc = 0, + minexptime = 3, maxexptime = 4, + minsize = 1, maxsize = 1, + collisiondetection = true, + vertical = false, + texture = "runes_glyph_watchdog.png", + }) + return + end + + for _, ref in pairs(minetest.get_objects_inside_radius(pos, 3)) do + if ref and not ref:get_armor_groups().immortal then + if not ref:is_player() or ref.is_fake_player or not meta:get_string("master") or meta:get_string("master") == "" or ref:get_player_name() ~= meta:get_string("master") then + ref:set_hp(ref:get_hp() - 1) + meta:set_int("charge", (meta:get_int("charge") or 1) - 1) + local collisionbox = ref:get_properties().collisionbox + local refpos = ref:getpos() + refpos.y = refpos.y + (((collisionbox[4] or 0) - (collisionbox[3] or 0)) / 2) + + local vel = vector.subtract(refpos, pos) + minetest.add_particlespawner({ + amount = 30, + minpos = pos, maxpos = pos, + minvel = vel, maxvel = vector.multiply(vel, 3), + minacc = 0, maxacc = 0,--vector.multiply(vel, 3), + minexptime = 1, maxexptime = 1, + minsize = 2, maxsize = 5, + collisiondetection = false, + vertical = false, + texture = "runes_glyph_watchdog.png", + }) + end + end + end + return true + end + } +) + +register_glyph("manasucker", { + description = "Mana Sucker Glyph", + texture = "runes_glyph_manasucker.png", + initial_charge = 100, + mana_cost = 20, + }, { + groups = {snappy = 1}, + on_construct = function(pos) + minetest.get_node_timer(pos):start(3) + minetest.get_meta(pos):set_int("mana", 0) + end, + on_punch = function(pos, _, puncher) + local meta = minetest.get_meta(pos) + if meta:get_string("master") and puncher:is_player() and not puncher.is_fake_player and puncher:get_player_name() == meta:get_string("master") then + local k = meta:get_int("mana") + local name = puncher:get_player_name() + local o = mana.getmax(name) - mana.get(name) + local u = 0 + + if k > o then + u = k - mana.getmax(name) + mana.set(name, o) + else + mana.add(name, k) + end + + meta:set_int("mana", u) + end + end, + on_timer = function(pos, elapsed) + local meta = minetest.get_meta(pos) + if meta:get_int("charge") <= 0 then + return true + end + + local more_mana = 0 + for _, ref in pairs(minetest.get_objects_inside_radius(pos, 5)) do + if ref and ref:is_player() and not ref.is_fake_player and (not meta:get_string("master") or meta:get_string("master") == "" or meta:get_string("master") ~= ref:get_player_name()) then + local burst = math.random(10, 40) + local manalevel = mana.get(ref:get_player_name()) + + if manalevel > 0 then + if manalevel < burst then + mana.set(ref:get_player_name(), 0) + more_mana = more_mana + manalevel + else + mana.subtract(ref:get_player_name(), burst) + more_mana = more_mana + burst + end + + local collisionbox = ref:get_properties().collisionbox + local refpos = ref:getpos() + refpos.y = refpos.y + (((collisionbox[4] or 0) - (collisionbox[3] or 0)) / 2) + + local vel = vector.subtract(pos, refpos) + minetest.add_particlespawner({ + amount = 30, + minpos = refpos, maxpos = refpos, + minvel = vel, maxvel = vel, + minacc = 0, maxacc = 0,--vector.multiply(vel, 3), + minexptime = 1, maxexptime = 1, + minsize = 1, maxsize = 1, + collisiondetection = false, + vertical = false, + texture = "runes_glyph_manasucker.png", + }) + meta:set_int("charge", meta:get_int("charge") - 1) + end + end + end + meta:set_int("mana", meta:get_int("mana") + more_mana) + return true + end + } +) diff --git a/mods/runes/init.lua b/mods/runes/init.lua index 087fe911..209f939d 100755 --- a/mods/runes/init.lua +++ b/mods/runes/init.lua @@ -3,6 +3,8 @@ local modpath = minetest.get_modpath("runes") +runes = {} + -- API first dofile(modpath.."/api.lua") @@ -15,4 +17,12 @@ dofile(modpath.."/handlers.lua") -- The amulets dofile(modpath.."/amulets.lua") +---- From this point everything is redo ---- + +-- Stylus +dofile(modpath .. "/glyphs.lua") + +-- Scrolls +dofile(modpath .. "/scrolls.lua") + minetest.log("action","[runes] Mod loaded") diff --git a/mods/runes/scrolls.lua b/mods/runes/scrolls.lua new file mode 100644 index 00000000..c92a8bb9 --- /dev/null +++ b/mods/runes/scrolls.lua @@ -0,0 +1,35 @@ +-- Scrolls for Runes Redo +-- + +runes.scrolls = {} + +function register_scroll(name, type, data) + if not data then return end + + def = { + inventory_image = (data.texture or "runes_scroll_unknown.png"), + groups = {scroll = 1}, + description = (data.description or "Mysterious Scroll"), + } + + minetest.register_craftitem("runes:scroll_" .. name, def) + runes.scrolls[name] = {} + + if type == "knowledge" and data.glyph then + runes.scrolls[name].glyph = data.glyph + end +end + + + +register_scroll("watchdog", "knowledge", { + glyph = "runes:glyph_watchdog", + texture = "runes_scroll_watchdog.png", + description = "Watch Dog Knowledge Scroll" +}) + +register_scroll("manasucker", "knowledge", { + glyph = "runes:glyph_manasucker", + texture = "runes_scroll_manasucker.png", + description = "Mana Sucker Knowledge Scroll", +}) diff --git a/mods/runes/textures/runes_glyph_deus_ex_machina.png b/mods/runes/textures/runes_glyph_deus_ex_machina.png new file mode 100644 index 0000000000000000000000000000000000000000..997da49fd6d3daeb3f057e2d05854e4a84236728 GIT binary patch literal 418 zcmV;T0bTxyP)B zc|0w#`P7;O`%j{DxNzS1bGh}86Ob6(jX(-ms#i=v0;kz^MVh#6*dvbJg(s1C`C z7yzJ~8(8De&5dXu9ZcW{+Hp;ut5XFKdmM^yYpnyCe5H_=kjdK6rXdtrz+tmYLYC+8 zv|Oj#>SgFXiND@oT7($I)sWs(-eVgD@#Q4i3%E1U%}tfcZ_)`JNqJt>j=wH@UP#1+ zNP8ud>Z$+_y_9nArFw4>h=G6Y!-SiA=hG}&2Xf-K)RI>0$asU7T literal 0 HcmV?d00001 diff --git a/mods/runes/textures/runes_glyph_manasucker.png b/mods/runes/textures/runes_glyph_manasucker.png new file mode 100644 index 0000000000000000000000000000000000000000..edcaf6b43ccdfc23c8d28c02c1b1392863336abe GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`5uPrNAr`&K2@AwlOpE_AU&c;& zsn}wPhCFU71r`5E<{6J!ix`x5Ic)v2=>J;&#}X5N?l9SI*OQ#0;wEUvZNRYdWusZ6 t$Mr7`dox_jwth{NQC75DDt4HWVQZ<2#nr7{qCh(sJYD@<);T3K0RR@5Fc$y- literal 0 HcmV?d00001 diff --git a/mods/runes/textures/runes_glyph_spontafire.png b/mods/runes/textures/runes_glyph_spontafire.png new file mode 100644 index 0000000000000000000000000000000000000000..de19275cef2d0cde8c881ac8d698b6833ee01319 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`L7py-Ar`&K2@*vQvUv~Jr`Rbg zvc728%^J+_ceaH`nWMvyVR`Wc)5pbTo{0_D|KBiC{=EO1!5?)?pAOCtwMjllm_GdG m>|Xogp+ks*5YL{4ybOWc)HCc|{fdF6GkCiCxvXTGrESu+-xB^ZFjyGbK9?(e>*-bXe&cE8S#574e+%V*d=-2)fxXAn Vr$NnB$p>gZgQu&X%Q~loCIBx1KeYe= literal 0 HcmV?d00001 diff --git a/mods/runes/textures/runes_scroll_deus_ex_machina.png b/mods/runes/textures/runes_scroll_deus_ex_machina.png new file mode 100644 index 0000000000000000000000000000000000000000..edd9c73c7b79435f70e72f46790978d284868895 GIT binary patch literal 410 zcmV;L0cHM)P)sfJ6>q#Ab%du4CfZ zaV%;Ho)qb`3WdsEF_5!q^jHNtHBe$ygmdWy1RMqjrVWw z2@sP9bVQv4>F&N~>*Faf3P{p*Vp6S=F;at(dNQ$9fDM9Nz*mH~0F``f&W2GJ1BYbv zb*}&;wJ{0LT{i%ZZWn?+w_l)HE7z49BG>C7@&;!O=d9t&a=}#_0H;~Y0mz4D?T>ZB zo+UutNQ_l--PYHR37FjpY1X3X@?I#Wz)8SZi4|RL{LUp0oRUx#AvP>G1hhJyy6AE& z%LP!mlLLXva9izUCFtT!W#}Y8pBp=!>0R&($&gomy%p{)@nE(I) literal 0 HcmV?d00001 diff --git a/mods/runes/textures/runes_scroll_manasucker.png b/mods/runes/textures/runes_scroll_manasucker.png new file mode 100644 index 0000000000000000000000000000000000000000..24463dcbc2909548b41786c2fe289736312b1562 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`^E_P~Lo9le6BY;8&!pZj~h zhVPw|1+_gqKv4GTR6#HM`A|WV1NT<+HUh!J3ukxti0p3QoX*0`%zSv3LggA0ql7~O zih>u;F(l3DzuqvRlwZ>6nr+MGiJ6Od6vP5@7`XK~XUuoLW}6ZrtkQq=Cl61C=gh{& z9Y

6%7r5U{9Twhkci-gkAy={P@41bAz_Xs|~MIB^em@tu$2Gv@Y2X=u!qxS3j3^ HP68&!pZj~h zhVPw|1+_gqKv4GTR6#HM`Ot+L)2>yYH~<76zD%--IdgACZzB*qyl{4RPem-lWgcb& z=LxX~T25!4Fgt9rNV+4D!LosMI?JZ{8(Wz#>K#}8&!pZj~h zhVPw|1+_jrKv4GT)c?0vrvASzy>+36PWFz*s|+)$csl>bKmYgtf9bn=SJ$Ke4azbz zU)Gltrr7%InB%6Ca7dl=Gn3wW10dLtAiSr1Y1_gz580fMbH2M002ovPDHLkV1mFcZ_@w( literal 0 HcmV?d00001