2023-06-13 13:58:22 +03:00
|
|
|
-- The Rainbow Staff is a reward for defeating the final boss
|
|
|
|
-- Classic implementation produces ranbow blocks in any direction it is pointed at and used
|
|
|
|
-- This tends to be problematic on servers, so is replaced with a powerful tool instead
|
|
|
|
-- if classic rainbow staff is not enabled
|
2018-08-09 13:36:34 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
-- How long the rainbow generating entity should remain in existence, Used to be 10,
|
|
|
|
-- really should not last so long, given that it adds rainbow on every server step...
|
|
|
|
local max_rainbow_time = 1
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
if nssm.classic_rainbow_staff
|
|
|
|
and minetest.registered_nodes["nyancat:nyancat_rainbow"] then
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
minetest.register_entity("nssm:rainbow", {
|
|
|
|
textures = {"transparent.png"},
|
|
|
|
velocity = 10,
|
|
|
|
hp_max = 50,
|
2018-08-08 12:56:14 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
on_step = function (self, pos, node, dtime)
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
self.timer = self.timer or os.time()
|
2018-08-08 12:56:14 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
local pos = self.object:get_pos()
|
2018-08-08 12:56:14 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
if minetest.is_protected(pos, "") then
|
|
|
|
return
|
|
|
|
end
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
if os.time() - self.timer > max_rainbow_time then
|
|
|
|
minetest.set_node(pos, {name = "nyancat:nyancat"})
|
|
|
|
self.object:remove()
|
|
|
|
end
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
if minetest.get_node(pos) then
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
local n = minetest.get_node(pos).name
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
if n ~= "nyancat:nyancat_rainbow" then
|
|
|
|
|
|
|
|
if n == "air" then
|
|
|
|
minetest.set_node(pos, {name = "nyancat:nyancat_rainbow"})
|
|
|
|
else
|
|
|
|
minetest.chat_send_all("Nome:" .. n)
|
|
|
|
minetest.set_node(pos, {name = "nyancat:nyancat"})
|
|
|
|
|
|
|
|
self.object:remove()
|
|
|
|
end
|
2018-08-08 12:56:14 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-06-13 13:58:22 +03:00
|
|
|
})
|
2018-08-08 12:56:14 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
minetest.register_tool("nssm:rainbow_staff", {
|
|
|
|
description = "Rainbow Staff",
|
|
|
|
inventory_image = "rainbow_staff.png",
|
|
|
|
groups = {not_in_creative_inventory = 1},
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
on_use = function(itemstack, placer, pointed_thing)
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
local dir = placer:get_look_dir()
|
|
|
|
local playerpos = placer:get_pos()
|
|
|
|
local obj = minetest.add_entity({
|
|
|
|
x = playerpos.x + dir.x,
|
|
|
|
y = playerpos.y + 2 + dir.y,
|
|
|
|
z = playerpos.z + dir.z
|
|
|
|
}, "nssm:rainbow")
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
local vec = {x = dir.x * 6, y = dir.y * 6, z = dir.z * 6}
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
obj:set_velocity(vec)
|
2022-09-28 21:01:53 +03:00
|
|
|
|
2023-06-13 13:58:22 +03:00
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
minetest.register_tool("nssm:rainbow_staff", {
|
|
|
|
description = "Rainbow Bludgeon",
|
|
|
|
inventory_image = "rainbow_staff.png",
|
|
|
|
tool_capabilities = {
|
|
|
|
full_punch_interval = 0.2,
|
|
|
|
max_drop_level = 1,
|
|
|
|
groupcaps = {
|
|
|
|
snappy = {
|
|
|
|
times = {[1] = 0.80, [2] = 0.40, [3] = 0.20}, uses = 70, maxlevel = 1
|
|
|
|
},
|
|
|
|
crumbly = {
|
|
|
|
times = {[1] = 0.80, [2] = 0.40, [3] = 0.20}, uses = 70, maxlevel = 1
|
|
|
|
},
|
|
|
|
choppy = {
|
|
|
|
times = {[1] = 0.80, [2] = 0.40, [3] = 0.20}, uses = 70, maxlevel = 1
|
|
|
|
},
|
|
|
|
cracky = {
|
|
|
|
times = {[1] = 0.80, [2] = 0.40, [3] = 0.20}, uses = 70, maxlevel = 1
|
|
|
|
},
|
|
|
|
fleshy = {
|
|
|
|
times = {[1] = 0.80, [2] = 0.60, [3] = 0.20}, uses = 140, maxlevel = 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
damage_groups = {fleshy = 40},
|
|
|
|
},
|
|
|
|
|
|
|
|
groups = {not_in_creative_inventory = 1}
|
|
|
|
})
|
|
|
|
end
|