Add unified_skins and update for game changes.
@ -1,8 +1,15 @@
|
||||
[mod] Visible Player Armor [3d_armor]
|
||||
=====================================
|
||||
|
||||
depends: default, inventory_plus, wieldview
|
||||
depends: default, inventory_plus, unified_skins
|
||||
|
||||
Adds craftable armor that is visible to other players. Armor takes damage when a player is hurt
|
||||
but also offers a percentage chance of healing.
|
||||
Adds craftable armor that is visible to other players. Each armor item worn contibutes to
|
||||
a player's armor group level making them less vulnerable to weapons.
|
||||
|
||||
Armor takes damage when a player is hurt but also offers a percentage chance of healing.
|
||||
|
||||
default settings: [minetest.conf]
|
||||
|
||||
# Set number of seconds between armor updates.
|
||||
3d_armor_update_time = 1
|
||||
|
||||
|
@ -1,46 +1,50 @@
|
||||
|
||||
armor_api = {
|
||||
player_hp = {},
|
||||
fleshy_max = 20
|
||||
}
|
||||
|
||||
armor_api.get_player_armor = function(self, player)
|
||||
armor_api.get_armor_textures = function(self, player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
local texture = ""
|
||||
local textures = {}
|
||||
local player_inv = player:get_inventory()
|
||||
local armor = {head, torso, legs, shield}
|
||||
for _,v in ipairs({"head", "torso", "legs"}) do
|
||||
local stack = player_inv:get_stack("armor_"..v, 1)
|
||||
armor[v] = stack:get_definition().groups["armor_"..v] or 0
|
||||
if armor[v] > 0 then
|
||||
item = stack:get_name()
|
||||
texture = texture.."^[combine:64x64:0,32="..item:gsub("%:", "_")..".png"
|
||||
if stack:get_definition().groups["armor_"..v] then
|
||||
local item = stack:get_name()
|
||||
textures[v] = item:gsub("%:", "_")..".png"
|
||||
end
|
||||
end
|
||||
local stack = player_inv:get_stack("armor_shield", 1)
|
||||
armor["shield"] = stack:get_definition().groups["armor_shield"] or 0
|
||||
if armor["shield"] > 0 then
|
||||
item = stack:get_name()
|
||||
texture = texture.."^[combine:64x64:16,0="..minetest.registered_items[item].inventory_image
|
||||
if stack:get_definition().groups["armor_shield"] then
|
||||
local item = stack:get_name()
|
||||
textures["shield"] = minetest.registered_items[item].inventory_image
|
||||
end
|
||||
return textures
|
||||
end
|
||||
|
||||
armor_api.set_player_armor = function(self, player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local armor_level = math.floor(
|
||||
(.2*armor["head"]) +
|
||||
(.3*armor["torso"]) +
|
||||
(.2*armor["legs"]) +
|
||||
(.3*armor["shield"])
|
||||
)
|
||||
local level = (armor_level / 2) + 0.5
|
||||
local fleshy = 3 - (armor_level / 2)
|
||||
if fleshy < 0 then
|
||||
fleshy = 0
|
||||
local name = player:get_player_name()
|
||||
local player_inv = player:get_inventory()
|
||||
local armor_level = 0
|
||||
for _,v in ipairs({"head", "torso", "legs", "shield"}) do
|
||||
local stack = player_inv:get_stack("armor_"..v, 1)
|
||||
local armor = stack:get_definition().groups["armor_"..v] or 0
|
||||
armor_level = armor_level + armor
|
||||
end
|
||||
local armor_groups = {fleshy=100}
|
||||
if armor_level > 0 then
|
||||
armor_groups.level = math.floor(armor_level / 20)
|
||||
armor_groups.fleshy = 100 - armor_level
|
||||
end
|
||||
local armor_groups = {level=1, fleshy=3, snappy=1, choppy=1}
|
||||
armor_groups.level = level
|
||||
armor_groups.fleshy = fleshy
|
||||
player:set_armor_groups(armor_groups)
|
||||
return texture
|
||||
uniskins:update_player_visuals(player)
|
||||
end
|
||||
|
||||
armor_api.update_armor = function(self, player)
|
||||
@ -73,7 +77,7 @@ armor_api.update_armor = function(self, player)
|
||||
if desc then
|
||||
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
|
||||
end
|
||||
wieldview:update_player_visuals(player)
|
||||
self:set_player_armor(player)
|
||||
end
|
||||
heal_max = heal_max + heal
|
||||
end
|
||||
|
@ -1,84 +1,74 @@
|
||||
3D Armor -- Visible Player Armor
|
||||
--------------------------------
|
||||
3d_armor -- Crafting Guide
|
||||
--------------------------
|
||||
|
||||
Crafting Guide
|
||||
--------------
|
||||
|
||||
S = Steel Ingot [default:steel_ingot], W = Wood [default:wood]
|
||||
|
||||
Steel Helmet [3d_armor:helmet_steel]
|
||||
Helmets:
|
||||
|
||||
+---+---+---+
|
||||
| S | S | S |
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| S | | S |
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
| | | |
|
||||
+---+---+---+
|
||||
|
||||
Steel Chestplate [3d_armor:chestplate_steel]
|
||||
[3d_armor:helmet_wood] X = [default:wood]
|
||||
[3d_armor:helmet_steel] X = [default:steel_ingot]
|
||||
[3d_armor:helmet_bronze] X = [default:bronze_ingot]
|
||||
|
||||
Chestplates:
|
||||
|
||||
+---+---+---+
|
||||
| S | | S |
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
| S | S | S |
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| S | S | S |
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
|
||||
Steel Leggings [3d_armor:leggings_steel]
|
||||
[3d_armor:chestplate_wood] X = [default:wood]
|
||||
[3d_armor:chestplate_steel] X = [default:steel_ingot]
|
||||
[3d_armor:chestplate_bronze] X = [default:bronze_ingot]
|
||||
|
||||
Leggings:
|
||||
|
||||
+---+---+---+
|
||||
| S | S | S |
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| S | | S |
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
| S | | S |
|
||||
| X | | X |
|
||||
+---+---+---+
|
||||
|
||||
Steel Shield [3d_armor:shield_steel]
|
||||
[3d_armor:leggings_wood] X = [default:wood]
|
||||
[3d_armor:leggings_steel] X = [default:steel_ingot]
|
||||
[3d_armor:leggings_bronze] X = [default:bronze_ingot]
|
||||
|
||||
Shields:
|
||||
|
||||
+---+---+---+
|
||||
| S | S | S |
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| S | S | S |
|
||||
| X | X | X |
|
||||
+---+---+---+
|
||||
| | S | |
|
||||
| | X | |
|
||||
+---+---+---+
|
||||
|
||||
Wooden Shield [3d_armor:shield_wood]
|
||||
|
||||
+---+---+---+
|
||||
| W | W | W |
|
||||
+---+---+---+
|
||||
| w | W | W |
|
||||
+---+---+---+
|
||||
| | W | |
|
||||
+---+---+---+
|
||||
|
||||
Enhanced Wooden Shield [3d_armor:shield_enhanced_wood]
|
||||
|
||||
+---+---+---+
|
||||
| S | W | S |
|
||||
+---+---+---+
|
||||
| W | S | W |
|
||||
+---+---+---+
|
||||
| | W | |
|
||||
+---+---+---+
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[3d_armor:shield_wood] X = [default:wood]
|
||||
[3d_armor:shield_steel] X = [default:steel_ingot]
|
||||
[3d_armor:shield_bronze] X = [default:bronze_ingot
|
||||
|
||||
Enhanced Wooden Shield:
|
||||
|
||||
SI = [default:steel_ingot]
|
||||
WS = [3d_armor:shield_wood]
|
||||
|
||||
+----+
|
||||
| SI |
|
||||
+----+
|
||||
| WS |
|
||||
+----+
|
||||
| SI |
|
||||
+----+
|
||||
|
||||
[3d_armor:shield_enhanced_wood]
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
default
|
||||
inventory_plus
|
||||
wieldview
|
||||
unified_skins
|
||||
|
@ -1,38 +1,34 @@
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/armor_api.lua")
|
||||
|
||||
local time = 0
|
||||
local update_time = tonumber(minetest.setting_get("3d_armor_update_time"))
|
||||
if not update_time then
|
||||
update_time = 1
|
||||
minetest.setting_set("3d_armor_update_time", tostring(update_time))
|
||||
end
|
||||
|
||||
-- Regisiter Head Armor
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_wood", {
|
||||
description = "Wood Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_wood.png",
|
||||
groups = {armor_head=2, armor_heal=10, armor_use=5000},
|
||||
groups = {armor_head=5, armor_heal=0, armor_use=1000},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_steel", {
|
||||
description = "Steel Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_steel.png",
|
||||
groups = {armor_head=3, armor_heal=15, armor_use=1000},
|
||||
groups = {armor_head=10, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:helmet_wood",
|
||||
recipe = {
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:wood", "", "default:wood"},
|
||||
{"", "", ""},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:helmet_steel",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
{"", "", ""},
|
||||
},
|
||||
minetest.register_tool("3d_armor:helmet_bronze", {
|
||||
description = "Bronze Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_bronze.png",
|
||||
groups = {armor_head=15, armor_heal=10, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
-- Regisiter Torso Armor
|
||||
@ -40,33 +36,22 @@ minetest.register_craft({
|
||||
minetest.register_tool("3d_armor:chestplate_wood", {
|
||||
description = "Wood Chestplate",
|
||||
inventory_image = "3d_armor_inv_chestplate_wood.png",
|
||||
groups = {armor_torso=2, armor_heal=10, armor_use=5000},
|
||||
groups = {armor_torso=10, armor_heal=0, armor_use=1000},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:chestplate_steel", {
|
||||
description = "Steel Chestplate",
|
||||
inventory_image = "3d_armor_inv_chestplate_steel.png",
|
||||
groups = {armor_torso=3, armor_heal=15, armor_use=2500},
|
||||
groups = {armor_torso=15, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:chestplate_wood",
|
||||
recipe = {
|
||||
{"default:wood", "", "default:wood"},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:chestplate_steel",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
},
|
||||
minetest.register_tool("3d_armor:chestplate_bronze", {
|
||||
description = "Bronze Chestplate",
|
||||
inventory_image = "3d_armor_inv_chestplate_bronze.png",
|
||||
groups = {armor_torso=25, armor_heal=10, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
-- Regisiter Leg Armor
|
||||
@ -74,33 +59,22 @@ minetest.register_craft({
|
||||
minetest.register_tool("3d_armor:leggings_wood", {
|
||||
description = "Wood Leggings",
|
||||
inventory_image = "3d_armor_inv_leggings_wood.png",
|
||||
groups = {armor_legs=2, armor_heal=10, armor_use=5000},
|
||||
groups = {armor_legs=5, armor_heal=0, armor_use=1000},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:leggings_steel", {
|
||||
description = "Steel Leggings",
|
||||
inventory_image = "3d_armor_inv_leggings_steel.png",
|
||||
groups = {armor_legs=3, armor_heal=15, armor_use=1500},
|
||||
groups = {armor_legs=10, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:leggings_wood",
|
||||
recipe = {
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:wood", "", "default:wood"},
|
||||
{"default:wood", "", "default:wood"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:leggings_steel",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "", "default:steel_ingot"},
|
||||
},
|
||||
minetest.register_tool("3d_armor:leggings_bronze", {
|
||||
description = "Bronze Leggings",
|
||||
inventory_image = "3d_armor_inv_leggings_bronze.png",
|
||||
groups = {armor_legs=15, armor_heal=10, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
-- Regisiter Shields
|
||||
@ -108,48 +82,80 @@ minetest.register_craft({
|
||||
minetest.register_tool("3d_armor:shield_wood", {
|
||||
description = "Wooden Shield",
|
||||
inventory_image = "3d_armor_inv_shield_wood.png",
|
||||
groups = {armor_shield=1, armor_heal=10, armor_use=10000},
|
||||
groups = {armor_shield=10, armor_heal=0, armor_use=1000},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:shield_enhanced_wood", {
|
||||
description = "Enhanced Wooden Shield",
|
||||
inventory_image = "3d_armor_inv_shield_enhanced_wood.png",
|
||||
groups = {armor_shield=2, armor_heal=15, armor_use=3000},
|
||||
groups = {armor_shield=15, armor_heal=5, armor_use=500},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:shield_steel", {
|
||||
description = "Steel Shield",
|
||||
inventory_image = "3d_armor_inv_shield_steel.png",
|
||||
groups = {armor_shield=3, armor_heal=20, armor_use=1500},
|
||||
groups = {armor_shield=20, armor_heal=5, armor_use=250},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:shield_wood",
|
||||
recipe = {
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"default:wood", "default:wood", "default:wood"},
|
||||
{"", "default:wood", ""},
|
||||
},
|
||||
minetest.register_tool("3d_armor:shield_bronze", {
|
||||
description = "Bronze Shield",
|
||||
inventory_image = "3d_armor_inv_shield_bronze.png",
|
||||
groups = {armor_shield=25, armor_heal=10, armor_use=100},
|
||||
wear = 0,
|
||||
})
|
||||
|
||||
-- Register Craft Recipies
|
||||
|
||||
local craft_ingreds = {
|
||||
wood = "default:wood",
|
||||
steel = "default:steel_ingot",
|
||||
bronze = "default:bronze_ingot",
|
||||
}
|
||||
|
||||
for k, v in ipairs({"wood", "steel", "bronze"}) do
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:helmet_"..k,
|
||||
recipe = {
|
||||
{v, v, v},
|
||||
{v, "", v},
|
||||
{"", "", ""},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:chestplate_"..k,
|
||||
recipe = {
|
||||
{v, "", v},
|
||||
{v, v, v},
|
||||
{v, v, v},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:leggings_"..k,
|
||||
recipe = {
|
||||
{v, v, v},
|
||||
{v, "", v},
|
||||
{v, "", v},
|
||||
},
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:shield_"..k,
|
||||
recipe = {
|
||||
{v, v, v},
|
||||
{v, v, v},
|
||||
{"", v, ""},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:shield_enhanced_wood",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:wood", "default:steel_ingot"},
|
||||
{"default:wood", "default:steel_ingot", "default:wood"},
|
||||
{"", "default:wood", ""},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "3d_armor:shield_steel",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot"},
|
||||
{"3d_armor:shield_wood"},
|
||||
{"default:steel_ingot"},
|
||||
},
|
||||
})
|
||||
|
||||
@ -169,8 +175,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end
|
||||
for field, _ in pairs(fields) do
|
||||
if string.sub(field,0,string.len("skins_set_")) == "skins_set_" then
|
||||
minetest.after(1, function(player)
|
||||
wieldview:update_player_visuals(player)
|
||||
minetest.after(0, function(player)
|
||||
armor_api:set_player_armor(player)
|
||||
end, player)
|
||||
end
|
||||
end
|
||||
@ -183,11 +189,11 @@ minetest.register_on_joinplayer(function(player)
|
||||
local armor_inv = minetest.create_detached_inventory(name.."_outfit",{
|
||||
on_put = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, stack)
|
||||
wieldview:update_player_visuals(player)
|
||||
armor_api:set_player_armor(player)
|
||||
end,
|
||||
on_take = function(inv, listname, index, stack, player)
|
||||
player:get_inventory():set_stack(listname, index, nil)
|
||||
wieldview:update_player_visuals(player)
|
||||
armor_api:set_player_armor(player)
|
||||
end,
|
||||
allow_put = function(inv, listname, index, stack, player)
|
||||
if inv:is_empty(listname) then
|
||||
@ -209,5 +215,18 @@ minetest.register_on_joinplayer(function(player)
|
||||
armor_inv:set_stack(armor, 1, player_inv:get_stack(armor, 1))
|
||||
end
|
||||
armor_api.player_hp[name] = 0
|
||||
minetest.after(0, function(player)
|
||||
armor_api:set_player_armor(player)
|
||||
end, player)
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
time = time + dtime
|
||||
if time > update_time then
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
armor_api:update_armor(player)
|
||||
end
|
||||
time = 0
|
||||
end
|
||||
end)
|
||||
|
||||
|
BIN
3d_armor/textures/3d_armor_chestplate_bronze.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
BIN
3d_armor/textures/3d_armor_helmet_bronze.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
3d_armor/textures/3d_armor_inv_chestplate_bronze.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
3d_armor/textures/3d_armor_inv_helmet_bronze.png
Normal file
After Width: | Height: | Size: 232 B |
BIN
3d_armor/textures/3d_armor_inv_leggings_bronze.png
Normal file
After Width: | Height: | Size: 240 B |
BIN
3d_armor/textures/3d_armor_inv_shield_bronze.png
Normal file
After Width: | Height: | Size: 723 B |
BIN
3d_armor/textures/3d_armor_leggings_bronze.png
Normal file
After Width: | Height: | Size: 885 B |