From 565bbe05084cc3ea0d4097a57df98c3badf665ff Mon Sep 17 00:00:00 2001 From: Treer Date: Sun, 19 Sep 2021 01:16:50 +1000 Subject: [PATCH] Treasure: Nether staff of light Adds "Nether staff of Light" and "Nether staff of Eternal Light" One is limited to 60 uses, and the other has unlimited uses but the glowstone it creates will only last for 40 seconds. There are no crafting recipes as I hope these to eventually be treasure that can be found in the nether. --- README.md | 7 +- nodes.lua | 106 +++++++++++++++++ sounds/nether_rack_destroy.ogg | Bin 0 -> 12238 bytes textures/nether_lightstaff.png | Bin 0 -> 1669 bytes tools.lua | 200 +++++++++++++++++++++++++++++++++ 5 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 sounds/nether_rack_destroy.ogg create mode 100644 textures/nether_lightstaff.png diff --git a/README.md b/README.md index d72df3f..0c2c509 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ right-click/used on the frame to activate it. See portal_api.txt for how to create custom portals to your own realms. +Nether Portals can allow surface fast-travel. + This mod provides Nether basalts (natural, hewn, and chiseled) as nodes which require a player to journey to the magma ocean to obtain, so these can be used for gating progression through a game. For example, a portal to another realm @@ -24,8 +26,7 @@ the nether first, or basalt might be a crafting ingredient required to reach a particular branch of the tech-tree. Netherbrick tools are provided (pick, shovel, axe, & sword), see tools.lua - -Nether Portals can allow surface fast-travel. +The Nether pickaxe has a 10x bonus again wear when mining netherrack. ## License of source code: @@ -50,6 +51,7 @@ SOFTWARE. ### [Public Domain Dedication (CC0 1.0)](https://creativecommons.org/publicdomain/zero/1.0/) * `nether_portal_teleport.ogg` is a timing adjusted version of "teleport" by [outroelison](https://freesound.org/people/outroelison), used under CC0 1.0 + * `nether_rack_destroy.ogg` is from "Rock destroy" by [Bertsz](https://freesound.org/people/Bertsz/), used under CC0 1.0 ### [Attribution 3.0 Unported (CC BY 3.0)](https://creativecommons.org/licenses/by/3.0/) @@ -64,6 +66,7 @@ SOFTWARE. * `nether_fumarole.ogg`: Treer, 2020 * `nether_lava_bubble`* (files starting with "nether_lava_bubble"): Treer, 2020 * `nether_lava_crust_animated.png`: Treer, 2019-2020 + * `nether_lightstaff.png`: Treer, 2021 * `nether_particle_anim`* (files starting with "nether_particle_anim"): Treer, 2019 * `nether_portal_ignition_failure.ogg`: Treer, 2019 * `nether_smoke_puff.png`: Treer, 2020 diff --git a/nodes.lua b/nodes.lua index f82559f..a484278 100644 --- a/nodes.lua +++ b/nodes.lua @@ -65,6 +65,110 @@ nether.register_wormhole_node("nether:portal_alt", { }) +--== Transmogrification functions ==-- +-- Functions enabling selected nodes to be temporarily transformed into other nodes. +-- (so the light staff can temporarily turn netherrack into glowstone) + +-- Swaps the node at `nodePos` with `newNode`, unless `newNode` is nil in which +-- case the node is swapped back to its original type. +-- `monoSimpleSoundSpec` is optional. +-- returns true if a node was transmogrified +nether.magicallyTransmogrify_node = function(nodePos, playerName, newNode, monoSimpleSoundSpec, isPermanent) + + local meta = minetest.get_meta(nodePos) + local playerEyePos = nodePos -- fallback value in case the player no longer exists + local player = minetest.get_player_by_name(playerName) + if player ~= nil then + local playerPos = player:get_pos() + playerEyePos = vector.add(playerPos, {x = 0, y = 1.5, z = 0}) -- not always the cameraPos, e.g. 3rd person mode. + end + + local oldNode = minetest.get_node(nodePos) + if oldNode.name == "air" then + -- the node has been mined or otherwise destroyed, abort the operation + return false + end + local oldNodeDef = minetest.registered_nodes[oldNode.name] or minetest.registered_nodes["air"] + + local specialFXSize = 1 -- a specialFXSize of 1 is for full SFX, 0.5 is half-sized + local returningToNormal = newNode == nil + if returningToNormal then + -- This is the transmogrified node returning back to normal - a more subdued animation + specialFXSize = 0.5 + -- read what the node used to be from the metadata + newNode = { + name = meta:get_string("transmogrified_name"), + param1 = meta:get_string("transmogrified_param1"), + param2 = meta:get_string("transmogrified_param2") + } + if newNode.name == "" then + minetest.log("warning", "nether.magicallyTransmogrify_node() invoked to restore node which wasn't transmogrified") + return false + end + end + + local soundSpec = monoSimpleSoundSpec + if soundSpec == nil and oldNodeDef.sounds ~= nil then + soundSpec = oldNodeDef.sounds.dug or oldNodeDef.sounds.dig + if soundSpec == "__group" then soundSpec = "default_dig_cracky" end + end + if soundSpec ~= nil then + minetest.sound_play(soundSpec, {pos = nodePos, max_hear_distance = 50}) + end + + -- Start the particlespawner nearer the player's side of the node to create + -- more initial occlusion for an illusion of the old node breaking apart / falling away. + local dirToPlayer = vector.normalize(vector.subtract(playerEyePos, nodePos)) + local impactPos = vector.add(nodePos, vector.multiply(dirToPlayer, 0.5)) + local velocity = 1 + specialFXSize + minetest.add_particlespawner({ + amount = 50 * specialFXSize, + time = 0.1, + minpos = vector.add(impactPos, -0.3), + maxpos = vector.add(impactPos, 0.3), + minvel = {x = -velocity, y = -velocity, z = -velocity}, + maxvel = {x = velocity, y = 3 * velocity, z = velocity}, -- biased upward to counter gravity in the initial stages + minacc = {x=0, y=-10, z=0}, + maxacc = {x=0, y=-10, z=0}, + minexptime = 1.5 * specialFXSize, + maxexptime = 3 * specialFXSize, + minsize = 0.5, + maxsize = 5, + node = {name = oldNodeDef.name}, + glow = oldNodeDef.light_source + }) + + if returningToNormal or isPermanent then + -- clear the metadata that indicates the node is transformed + meta:set_string("transmogrified_name", "") + meta:set_int("transmogrified_param1", 0) + meta:set_int("transmogrified_param2", 0) + else + -- save the original node so it can be restored + meta:set_string("transmogrified_name", oldNode.name) + meta:set_int("transmogrified_param1", oldNode.param1) + meta:set_int("transmogrified_param2", oldNode.param2) + end + + minetest.swap_node(nodePos, newNode) + return true +end + + +local function transmogrified_can_dig (pos, player) + if minetest.get_meta(pos):get_string("transmogrified_name") ~= "" then + -- This node was temporarily transformed into its current form + -- revert it back, rather than allow the player to mine transmogrified nodes. + local playerName = "" + if player ~= nil then playerName = player:get_player_name() end + nether.magicallyTransmogrify_node(pos, playerName) + return false + end + return true +end + + + -- Nether nodes minetest.register_node("nether:rack", { @@ -105,6 +209,7 @@ minetest.register_node("nether:glowstone", { paramtype = "light", groups = {cracky = 3, oddly_breakable_by_hand = 3}, sounds = default.node_sound_glass_defaults(), + can_dig = transmogrified_can_dig, -- to ensure glowstone temporarily created by the lightstaff can't be kept }) -- Deep glowstone, found in the mantle / central magma layers @@ -116,6 +221,7 @@ minetest.register_node("nether:glowstone_deep", { paramtype = "light", groups = {cracky = 3, oddly_breakable_by_hand = 3}, sounds = default.node_sound_glass_defaults(), + can_dig = transmogrified_can_dig, -- to ensure glowstone temporarily created by the lightstaff can't be kept }) minetest.register_node("nether:brick", { diff --git a/sounds/nether_rack_destroy.ogg b/sounds/nether_rack_destroy.ogg new file mode 100644 index 0000000000000000000000000000000000000000..04fa2ed6b17716d72e4b3ea61b3367658aa5a8dc GIT binary patch literal 12238 zcmd6NcT`kQvtSQ7i-<75kQ5|mkRTuuC5hxXf<(y(j7T1pBw0j~NM?{BDLI3vphT4< zk_3bS1{jg3q`mn2zTLNH-`hQV_Mh#!)3-x)bysy&b=|txz{SNF5P^TCs-S-gO-D&h zFb>!~Z(n;?ztbidy5*mqf8QHn2B#zcdpaEngKDpJpA*iQoczZmN&F8UA*kEJ)#r|= zfv*dfhpWBWU+i4kT$17vlH!u$Qe6B7o?fm#zD|BlUj727*v>T+ajE=x zwtIO~9ajWBtMN?%(oCa7BUcuOqkQW=@ zP`xgbHfAKi?q_7=c5NA&Qnj8dg7)F3WYg1icB;^`R#SnS0MN(g!()jeqRNSYBmg9N z{E74Yi5KNl9JHDKfF)o?kxZQteWRU*aQY`8$H|m;8M$j4o+= z2`(*V`whzTJ@@OD!)5!$`Z`P8f#9)=fe5p#c3JaeYt#YNBbZZN|_=j=| z0JtL{@ZU)2mMtcky)SEH$@Wzf~H z8?|t#Xu@T?(|xgWt*9H*5h#XsS>P}K(9rf!us9}P(>%o-!;Q)I?G<>LNA#DSQ0J+_ zD1P))*Yf`#SC5~fR;s!-bk*whjp!MiHywS3v>tPs-u1lAd~bRWHM@se7>~SdndbCA zUH^~{QG%vdrTB-CVz@)U1TOFCP1S#s$puZ=X^41#mq*K&=VOYn_ETxy8pVNOMg47c zLq`2!6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QIsNiLr*H z!9`DxAQSC$u}i4$nLQEBLf@p;-$jtZlvj>Ww%p_F4}P2OLi3f$+`b}P5}sg)!grVZTY$mzJWW zz6sfwMtJMc?%&=49<`;b;^pvW|og|MgsVj;etMMjWU6mv3FzH zgHPCdZ&E!lZ6klxCv zF~rHMa&1%n32pguNrcmG`>|?nAD-Eb3j7UKkjyWgj`}B50ZAjszulQjA}b@v7zR!8 za;ld7XH?ew4XaZSn^~8=q!-X94>ovF>tVGm5^2{@*A$v(Gk4$6pT$-@ATu8(1`w&a zx{LYiDtpj4fhu_-&;@;L0==PVHxH*$xf4ux&Di*hPvIRqUL#p^ra~@#`-fgM?a-i_ zpGH?cwLy_u9X_A}JuCpwS@*{U0G;cz9STGO%6V8S6`&Zld_)kQ8lm&|ekpJYbDI7e D2Rm2B literal 0 HcmV?d00001 diff --git a/textures/nether_lightstaff.png b/textures/nether_lightstaff.png new file mode 100644 index 0000000000000000000000000000000000000000..915a7062b362e0ac399658562769c9821ccefda8 GIT binary patch literal 1669 zcmah}PiP}m7=K|~sa*<-y08=v!>fW@$;>3()@C--HJijH*r_3nY$^yloq3ZyI+-`l zylf^tEvq8xK|CsY_f%B8c~B4!T38PvyMn!RVHZJB+>1hC{oW)^nr*9x{Q2JR_x;}Y zzJG65R+pzHrza6YQ{_^j3cqK>XY3Sw|Gv8?4#pZeBZtsu@15Q^$H7j7)#b}*`{t9s zg7K(dS`QIA{kZrf(1#zLLumX(TC4NAv7%Y5C7U+eAad05fsIi1QskS~CgIWsX;4qc ze|-5BmZ+`cEAxhG_<7Q#rLBOhZLQXI{7U8B8wOlXMA|1!N8vGZ> z3YKCD-_&v4s7QGh5NTeXmsPwpDP;rO(W-?P`p#hKxXHP%DN3i)kvnrT3mQr)lgTJ* zT1lsqz(|H&kDF1_3ulBxPoqFWE1*87%#(zsxxw08#~5&_FK$}{ZNDA3v9fI`#3e1_ z@lZ+0DdjMqM06O97xvQyiBkjubajNzsdEBdAV=talW`U{nLh|>k$TLD-yatKu7hxo(gA2l1*C$GqgsdG{q<9UoHxnmLl(j95Q|^-3 z>PSsT=9*qZ$5GNIj@foOUJAMCI9Wx^j7$6Ov31~|RYt_K5S(FXB^q)T zbPwIPMqV4eFCINfiW^EZEm030`vJ4t7O~?DLgYO(WDf6`0m(I>mvo$S914}|N)<6A z5)7u=&*Q+O($ix^jCXTRHK_in!b=kBKu?%#gp{CV@jg$Muq_V@0`-+V%EeLHgp z_z7NJT|>{`z3qT8UoPZo6Su6Z*Aw!+sWXr4e1Rrj&-{4m`-#+BvwP1xcK!2nXU*w1 zOJ{FP{~$Stj9vWt)dbrAYkUX))X9Lr)4W*cxqw4SP%R)Nki_(cutOV^H`^Ps*jX{~ o^BeE(gToWTA8qOzyHh5OMs(taka30`Ra{-0gJK(O#lD@ literal 0 HcmV?d00001 diff --git a/tools.lua b/tools.lua index b821f07..5679e75 100644 --- a/tools.lua +++ b/tools.lua @@ -151,3 +151,203 @@ minetest.register_craft({ {"group:stick"} } }) + + + + +--===========================-- +--== Nether Staff of Light ==-- +--===========================-- + +nether.lightstaff_recipes = { + ["nether:rack"] = "nether:glowstone", + ["nether:brick"] = "nether:glowstone", + ["nether:brick_cracked"] = "nether:glowstone", + ["nether:brick_compressed"] = "nether:glowstone", + ["stairs:slab_netherrack"] = "nether:glowstone", + ["nether:rack_deep"] = "nether:glowstone_deep", + ["nether:brick_deep"] = "nether:glowstone_deep", + ["stairs:slab_netherrack_deep"] = "nether:glowstone_deep" +} +nether.lightstaff_range = 100 +nether.lightstaff_velocity = 60 +nether.lightstaff_gravity = 0 -- using 0 instead of 10 because the particle physics doesn't seem accurate enough for curved trajectories +nether.lightstaff_uses = 60 -- number of times the Eternal Lightstaff can be used before wearing out +nether.lightstaff_duration = 40 -- lifespan of glowstone created by the termporay Lightstaff +local serverLag = 0.05 -- rough amount reduce particle effect synchronization with lightstaff node changes + +-- returns a pointed_thing, or nil if no solid node intersected the ray +local function raycastForSolidNode(rayStartPos, rayEndPos) + + local raycast = minetest.raycast( + rayStartPos, + rayEndPos, + false, -- objects - if false, only nodes will be returned. Default is `true` + true -- liquids - if false, liquid nodes won't be returned. Default is `false` + ) + local next_pointed = raycast:next() + while next_pointed do + local under_node = minetest.get_node(next_pointed.under) + local under_def = minetest.registered_nodes[under_node.name] + + if (under_def and not under_def.buildable_to) or not under_def then + return next_pointed + end + + next_pointed = raycast:next(next_pointed) + end + return nil +end + +-- Turns a node into a light source +-- `lightDuration` 0 is considered permanent, lightDuration is in seconds +-- returns true if a node is transmogrified into a glowstone +local function light_node(pos, playerName, lightDuration) + + local result = false + if minetest.is_protected(pos, playerName) then + minetest.record_protection_violation(pos, playerName) + return false + end + + local oldNode = minetest.get_node(pos) + local litNodeName = nether.lightstaff_recipes[oldNode.name] + + if litNodeName ~= nil then + result = nether.magicallyTransmogrify_node( + pos, + playerName, + {name=litNodeName}, + {name = "nether_rack_destroy", gain = 0.8}, + lightDuration == 0 -- isPermanent + ) + + if lightDuration > 0 then + minetest.after(lightDuration, + function() + -- Restore the node to its original type. + -- + -- If the server crashes or shuts down before this is invoked, the node + -- will remain in its transmogrified state. These could be cleaned up + -- with an LBM, but I don't think that's necessary: if this functionality + -- is only being used for the Nether Lightstaff then I don't think it + -- matters if there's occasionally an extra glowstone left in the + -- netherrack. + nether.magicallyTransmogrify_node(pos, playerName) + end + ) + end + end + return result +end + +-- a lightDuration of 0 is considered permanent, lightDuration is in seconds +-- returns true if a node is transmogrified into a glowstone +local function lightstaff_on_use(user, boltColorString, lightDuration) + + if not user then return false end + local playerName = user:get_player_name() + local playerlookDir = user:get_look_dir() + local playerPos = user:get_pos() + local playerEyePos = vector.add(playerPos, {x = 0, y = 1.5, z = 0}) -- not always the cameraPos, e.g. 3rd person mode. + local target = vector.add(playerEyePos, vector.multiply(playerlookDir, nether.lightstaff_range)) + + local targetHitPos = nil + local targetNodePos = nil + local target_pointed = raycastForSolidNode(playerEyePos, target) + if target_pointed then + targetNodePos = target_pointed.under + targetHitPos = vector.divide(vector.add(target_pointed.under, target_pointed.above), 2) + end + + local wieldOffset = {x= 0.5, y = -0.2, z= 0.8} + local lookRotation = ({x = -user:get_look_vertical(), y = user:get_look_horizontal(), z = 0}) + local wieldPos = vector.add(playerEyePos, vector.rotate(wieldOffset, lookRotation)) + local aimPos = targetHitPos or target + local distance = math.abs(vector.length(vector.subtract(aimPos, wieldPos))) + aimPos.y = aimPos.y + (distance / nether.lightstaff_velocity) * nether.lightstaff_gravity + local boltDir = vector.normalize(vector.subtract(aimPos, wieldPos)) + + -- needs a proper casting sound, instead of the portal ignition + minetest.sound_play("nether_portal_ignite", {to_player = playerName, gain = .3, pitch = 1.7}, true) + + -- animate a "magic bolt" from wieldPos to aimPos + local particleSpawnDef = { + amount = 20, + time = 0.4, + minpos = vector.add(wieldPos, -0.13), + maxpos = vector.add(wieldPos, 0.13), + minvel = vector.multiply(boltDir, nether.lightstaff_velocity - 0.3), + maxvel = vector.multiply(boltDir, nether.lightstaff_velocity + 0.3), + minacc = {x=0, y=-nether.lightstaff_gravity, z=0}, + maxacc = {x=0, y=-nether.lightstaff_gravity, z=0}, + minexptime = 1, + maxexptime = 2, + minsize = 4, + maxsize = 5, + collisiondetection = true, + collision_removal = true, + texture = "nether_particle_anim3.png", + animation = { type = "vertical_frames", aspect_w = 7, aspect_h = 7, length = 0.8 }, + glow = 15 + } + minetest.add_particlespawner(particleSpawnDef) + particleSpawnDef.texture = "nether_particle_anim3.png^[colorize:" .. boltColorString .. ":alpha" + particleSpawnDef.amount = 12 + particleSpawnDef.time = 0.2 + particleSpawnDef.minsize = 6 + particleSpawnDef.maxsize = 7 + particleSpawnDef.minpos = vector.add(wieldPos, -0.35) + particleSpawnDef.maxpos = vector.add(wieldPos, 0.35) + minetest.add_particlespawner(particleSpawnDef) + + local result = false + if targetNodePos then + -- delay the impact until roughly when the particle effects will have reached the target + minetest.after( + math.max(0, (distance / nether.lightstaff_velocity) - serverLag), + function() + light_node(targetNodePos, playerName, lightDuration) + end + ) + + if lightDuration ~= 0 then + -- we don't need to care whether the transmogrify will be successful + result = true + else + -- check whether the transmogrify will be successful + local targetNode = minetest.get_node(targetNodePos) + result = nether.lightstaff_recipes[targetNode.name] ~= nil + end + end + return result +end + +-- Inspired by FaceDeer's torch crossbow and Xanthin's Staff of Light +minetest.register_tool("nether:lightstaff", { + description = S("Nether staff of Light\nTemporarily transforms the netherrack into glowstone"), + inventory_image = "nether_lightstaff.png", + wield_image = "nether_lightstaff.png", + light_source = 11, -- used by wielded_light mod etc. + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + lightstaff_on_use(user, "#F70", nether.lightstaff_duration) + end +}) + +minetest.register_tool("nether:lightstaff_eternal", { + description = S("Nether staff of Eternal Light\nCreates glowstone from netherrack"), + inventory_image = "nether_lightstaff.png^[colorize:#55F:90", + wield_image = "nether_lightstaff.png^[colorize:#55F:90", + light_source = 11, -- used by wielded_light mod etc. + sound = {breaks = "default_tool_breaks"}, + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + if lightstaff_on_use(user, "#23F", 0) then -- was "#8088FF" or "#13F" + -- The staff of Eternal Light wears out, to limit how much + -- a player can alter the nether with it. + itemstack:add_wear(65535 / (nether.lightstaff_uses - 1)) + end + return itemstack + end +})