246 lines
7.5 KiB
Lua
246 lines
7.5 KiB
Lua
local gem_names = {
|
|
"ruby", -- red
|
|
"sapphire", --blue
|
|
"emerald", --green
|
|
"opal", --yellow
|
|
}
|
|
local gem_names_caps = {
|
|
"Ruby", -- red
|
|
"Sapphire", --blue
|
|
"Emerald", --green
|
|
"Opal", --yellow
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, gem_name in pairs(gem_names) do
|
|
|
|
local color
|
|
|
|
if gem_name == "ruby" then color = "#e6482e" end
|
|
if gem_name == "emerald" then color = "#397b44" end
|
|
if gem_name == "opal" then color = "#f4b41b" end
|
|
if gem_name == "sapphire" then color = "#28ccdf" end
|
|
|
|
minetest.register_craftitem("gems:".. gem_name , {
|
|
description = minetest.colorize( color, gem_names_caps[_]),
|
|
inventory_image = "item_"..gem_name..".png",
|
|
})
|
|
|
|
|
|
--==================== Revealer =========================
|
|
-- use to reveal the current locations of all team members of that gem team
|
|
|
|
minetest.register_craftitem("gems:".. gem_name .. "_reveal", {
|
|
description = minetest.colorize( color, gem_names_caps[_] .. " Revealer") .."\nUse to reveal the current location\nof all " .. minetest.colorize( color, gem_names_caps[_]) .. " team members to your team.\nDisappears after 5 sec and does not update.",
|
|
inventory_image = "gems_reveal.png^[colorize:"..color.."88",
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
if not user then return end
|
|
if not user:is_player() then return end
|
|
local p_name = user:get_player_name()
|
|
if not arena_lib.is_player_in_arena(p_name, "gems_2") and not arena_lib.is_player_in_arena(p_name, "gems_4") then return end
|
|
if arena_lib.is_player_spectating(p_name) then return end
|
|
|
|
local arena = arena_lib.get_arena_by_player(p_name)
|
|
if not arena then return end
|
|
--returns the id of the team whose color the item is
|
|
|
|
local t_team_id = gems.get_team_id_by_name(arena , gem_name)
|
|
|
|
if not t_team_id then
|
|
minetest.chat_send_player(p_name,gem_names_caps[_].. " Team isnt in this game!")
|
|
itemstack:take_item()
|
|
|
|
return itemstack
|
|
end
|
|
|
|
itemstack:take_item()
|
|
--returns the team_id of the user
|
|
if not arena.players[p_name] then return end
|
|
if not arena.players[p_name].teamID then return end
|
|
local p_team_id = arena.players[p_name].teamID
|
|
|
|
gems.show_hud_team_location( arena, p_team_id , t_team_id , color )
|
|
|
|
|
|
return itemstack
|
|
end,
|
|
|
|
})
|
|
|
|
--==================== Picks =========================
|
|
-- picks are used to break blocks of the other gems, but they are easiest to use when turned against their own color. They are
|
|
-- the only way to break gem blocks and Great gems, and the fastest way to break gem glass.
|
|
|
|
--groupcaps
|
|
local gc = {cracky = {times={[1]=2.4, [2]=1.2, [3]=0.60}, uses=20, maxlevel=3},}
|
|
gc[ gem_name ] = {times={[1]=25, [2]=13, [3]=4}, uses=20, maxlevel=3}
|
|
|
|
minetest.register_tool("gems:pick_" .. gem_name, {
|
|
description = minetest.colorize(gem_names_caps[_] .. " Pickaxe") .. " \nUse to break Gem blocks, and Great Gems of\nAny team except " .. gems.get_opposite_team(gem_name),
|
|
inventory_image = "pick_"..gem_name..".png",
|
|
tool_capabilities = {
|
|
full_punch_interval = 0.9,
|
|
max_drop_level=3,
|
|
groupcaps = gc ,
|
|
},
|
|
sound = {breaks = "default_tool_breaks"},
|
|
groups = {pickaxe = 1 ,
|
|
not_in_creative_inventory = 1,
|
|
},
|
|
})
|
|
|
|
|
|
|
|
--==================== Swords =========================
|
|
-- gem swords are the best swords available, and they are most effecive against players of the same gem team.
|
|
--
|
|
|
|
minetest.register_tool("gems:sword_" .. gem_name, {
|
|
description = minetest.colorize(gem_names_caps[_] .. " Sword" ) .. " - \nMost useful against the".. gem_name .. " team",
|
|
inventory_image = "sword_"..gem_name..".png",
|
|
tool_capabilities = {
|
|
full_punch_interval = 0.7,
|
|
max_drop_level=1,
|
|
groupcaps={
|
|
snappy={times={[1]=2.0, [2]=1.00, [3]=0.35}, uses=30, maxlevel=3},
|
|
},
|
|
damage_groups = {fleshy=7},
|
|
},
|
|
sound = {breaks = "default_tool_breaks"},
|
|
groups = {sword = 1,
|
|
not_in_creative_inventory = 1,
|
|
},
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
--register_on_hp_change... for making gem swords more effective against their own team and a bit against adjacent teams
|
|
|
|
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
|
|
|
local p_name = player:get_player_name()
|
|
|
|
if not p_name then return hp_change end
|
|
if (( not (arena_lib.is_player_in_arena( p_name , "gems_2" ) ) ) and not (arena_lib.is_player_in_arena(p_name, "gems_4"))) or arena_lib.is_player_spectating(p_name) then
|
|
return hp_change
|
|
end
|
|
|
|
local arena = arena_lib.get_arena_by_player(p_name)
|
|
|
|
|
|
if not arena.players[ p_name ] then return hp_change end
|
|
|
|
local p_team_id = arena.players[ p_name ].teamID
|
|
local p_team_name = arena.teams[p_team_id].name
|
|
|
|
if reason and reason.type == "punch" and reason.object and reason.object:is_player() then
|
|
|
|
local puncher = reason.object
|
|
|
|
local puncher_name = puncher:get_player_name()
|
|
|
|
if ( not (arena_lib.is_player_in_arena( puncher_name , "gems_2" ) ) ) and not (arena_lib.is_player_in_arena(puncher_name, "gems_4")) then
|
|
return hp_change
|
|
end
|
|
|
|
|
|
if puncher then
|
|
|
|
local itemstack = puncher:get_wielded_item()
|
|
|
|
if itemstack then
|
|
|
|
if itemstack:get_name() == "gems:sword_ruby" then
|
|
|
|
if p_team_name == "ruby" then
|
|
|
|
hp_change = hp_change - 3
|
|
|
|
return hp_change
|
|
|
|
end
|
|
if p_team_name == "sapphire" or p_team_name == "opal" then
|
|
|
|
hp_change = hp_change - 1
|
|
|
|
return hp_change
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if itemstack:get_name() == "gems:sword_emerald" then
|
|
|
|
if p_team_name == "emerald" then
|
|
|
|
hp_change = hp_change - 3
|
|
|
|
return hp_change
|
|
|
|
end
|
|
if p_team_name == "sapphire" or p_team_name == "opal" then
|
|
|
|
hp_change = hp_change - 1
|
|
|
|
return hp_change
|
|
|
|
end
|
|
end
|
|
|
|
if itemstack:get_name() == "gems:sword_opal" then
|
|
|
|
if p_team_name == "opal" then
|
|
|
|
hp_change = hp_change - 3
|
|
|
|
return hp_change
|
|
|
|
end
|
|
if p_team_name == "ruby" or p_team_name == "emerald" then
|
|
|
|
hp_change = hp_change - 1
|
|
|
|
return hp_change
|
|
|
|
end
|
|
end
|
|
|
|
if itemstack:get_name() == "gems:sword_sapphire" then
|
|
|
|
if p_team_name == "sapphire" then
|
|
|
|
hp_change = hp_change - 3
|
|
|
|
return hp_change
|
|
|
|
end
|
|
if p_team_name == "ruby" or p_team_name == "emerald" then
|
|
|
|
hp_change = hp_change - 1
|
|
|
|
return hp_change
|
|
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
|
|
return hp_change
|
|
|
|
end, true)
|
|
|
|
|
|
|
|
--TODO: gem arrows, add to hp_change
|
|
|
|
--TODO: gem armor
|
|
|
|
--TODO, urgent: add an item that reveals the location of all players on that team
|
|
|