Compare commits
81 Commits
version-0.
...
version-0.
Author | SHA1 | Date | |
---|---|---|---|
7a980a6717 | |||
fc3fcea4b7 | |||
b59464de88 | |||
80024fc154 | |||
d826b53877 | |||
01a3425ec8 | |||
616d9398f2 | |||
6661ec0b40 | |||
ca1cf6bfeb | |||
8f5ffeb384 | |||
ca79d39688 | |||
8b8a554ff7 | |||
3df7802439 | |||
19e297a2e8 | |||
190614d47b | |||
37b10d1cee | |||
4b45f85687 | |||
a5b650285b | |||
26212fb3e4 | |||
4829445d12 | |||
4d3b219e7d | |||
81ffdaa6a7 | |||
ba62febdee | |||
8939a0dd43 | |||
c691f3e219 | |||
bf9ba59c0f | |||
75f808131c | |||
b88f946929 | |||
c63376b523 | |||
c070dfb19f | |||
4b70580ce4 | |||
65b6d58580 | |||
98786fd8f7 | |||
9105e8403e | |||
6b2e3adc00 | |||
c9001f9e53 | |||
cc25d6be13 | |||
f557c4d69e | |||
456c84e93e | |||
0157ebd683 | |||
c39f838893 | |||
862deff373 | |||
ac414d3df3 | |||
3cf6887abd | |||
b14db3c43c | |||
8f8c6c6bfa | |||
54ec4b3cef | |||
32e87ee543 | |||
d322a0f110 | |||
9cc2f3db02 | |||
ddd7f3786c | |||
5c5359de4f | |||
1aa2b769d7 | |||
5421ce46da | |||
72cffbae17 | |||
170ee39aed | |||
59bbc55b73 | |||
1dd904f5be | |||
9de8cc12bb | |||
4e8cf05436 | |||
b6a44057a6 | |||
ae33659168 | |||
fb29ce9150 | |||
7408ebcd81 | |||
36737441d4 | |||
5a112547e6 | |||
0d5cf6d58a | |||
f17a104ab1 | |||
f83e7e9984 | |||
be1d353ec0 | |||
241aa663f1 | |||
921e1ace24 | |||
0ec2dbfb36 | |||
7fc991765c | |||
991d2955e0 | |||
64ec3dcf93 | |||
e1caf0ab0c | |||
a44d1a2530 | |||
16bc6232ca | |||
6efe3bf116 | |||
67867e78ec |
9
3d_armor/LICENSE.txt
Normal file
@ -0,0 +1,9 @@
|
||||
[mod] 3d Armor [3d_armor]
|
||||
=========================
|
||||
|
||||
License Source Code: (C) 2012-2017 Stuart Jones - LGPL v2.1
|
||||
|
||||
License Textures: Copyright (C) 2017 davidthecreator - CC-BY-SA 3.0
|
||||
|
||||
https://github.com/daviddoesminetest/3d-armors-new-textures
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
Depends: default
|
||||
|
||||
Recommends: inventory_plus or unified_inventory (use only one)
|
||||
Recommends: sfinv, inventory_plus or unified_inventory (use only one to avoid conflicts)
|
||||
|
||||
Adds craftable armor that is visible to other players. Each armor item worn contributes to
|
||||
a player's armor group level making them less vulnerable to weapons.
|
||||
@ -21,4 +21,3 @@ Armor can be configured by adding a file called armor.conf in 3d_armor mod and/o
|
||||
see armor.conf.example for all available options.
|
||||
|
||||
Note: worldpath config settings override any settings made in the mod's directory.
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
minetest.register_alias("adminboots","3d_armor:boots_admin")
|
||||
minetest.register_alias("adminhelmet","3d_armor:helmet_admin")
|
||||
minetest.register_alias("adminchestplate","3d_armor:chestplate_admin")
|
||||
minetest.register_alias("adminlegginss","3d_armor:leggings_admin")
|
||||
minetest.register_alias("adminleggings","3d_armor:leggings_admin")
|
||||
|
||||
minetest.register_tool("3d_armor:helmet_admin", {
|
||||
description = "Admin Helmet",
|
||||
inventory_image = "3d_armor_inv_helmet_admin.png",
|
||||
groups = {armor_head=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
|
||||
groups = {armor_head=1000, armor_heal=1000, armor_use=0, armor_water=1, not_in_creative_inventory=1},
|
||||
wear = 0,
|
||||
on_drop = function(itemstack, dropper, pos)
|
||||
return
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:chestplate_admin", {
|
||||
@ -15,6 +18,9 @@ minetest.register_tool("3d_armor:chestplate_admin", {
|
||||
inventory_image = "3d_armor_inv_chestplate_admin.png",
|
||||
groups = {armor_torso=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
|
||||
wear = 0,
|
||||
on_drop = function(itemstack, dropper, pos)
|
||||
return
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:leggings_admin", {
|
||||
@ -22,6 +28,9 @@ minetest.register_tool("3d_armor:leggings_admin", {
|
||||
inventory_image = "3d_armor_inv_leggings_admin.png",
|
||||
groups = {armor_legs=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
|
||||
wear = 0,
|
||||
on_drop = function(itemstack, dropper, pos)
|
||||
return
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_tool("3d_armor:boots_admin", {
|
||||
@ -29,5 +38,8 @@ minetest.register_tool("3d_armor:boots_admin", {
|
||||
inventory_image = "3d_armor_inv_boots_admin.png",
|
||||
groups = {armor_feet=1000, armor_heal=1000, armor_use=0, not_in_creative_inventory=1},
|
||||
wear = 0,
|
||||
on_drop = function(itemstack, dropper, pos)
|
||||
return
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -18,12 +18,13 @@ ARMOR_FIRE_PROTECT = false
|
||||
|
||||
-- Fire protection nodes, (name, protection level, damage)
|
||||
ARMOR_FIRE_NODES = {
|
||||
{"default:lava_source", 5, 4},
|
||||
{"default:lava_flowing", 5, 4},
|
||||
{"fire:basic_flame", 3, 4},
|
||||
{"ethereal:crystal_spike", 2, 1},
|
||||
{"bakedclay:safe_fire", 2, 1},
|
||||
{"default:torch", 1, 1},
|
||||
{"default:lava_source", 5, 4},
|
||||
{"default:lava_flowing", 5, 4},
|
||||
{"fire:basic_flame", 3, 4},
|
||||
{"fire:permanent_flame", 3, 4},
|
||||
{"ethereal:crystal_spike", 2, 1},
|
||||
{"ethereal:fire_flower", 2, 1},
|
||||
{"default:torch", 1, 1},
|
||||
}
|
||||
|
||||
-- Increase this if you get initialization glitches when a player first joins.
|
||||
@ -54,3 +55,7 @@ ARMOR_LEVEL_MULTIPLIER = 1
|
||||
-- eg: ARMOR_HEAL_MULTIPLIER = 0 will disable healing altogether.
|
||||
ARMOR_HEAL_MULTIPLIER = 1
|
||||
|
||||
-- You can use this to increase or decrease overall armor radiation protection,
|
||||
-- eg: ARMOR_RADIATION_MULTIPLIER = 0 will completely disable radiation protection.
|
||||
-- Note: patched technic mod is required
|
||||
ARMOR_RADIATION_MULTIPLIER = 1
|
||||
|
@ -6,6 +6,7 @@ ARMOR_DROP = minetest.get_modpath("bones") ~= nil
|
||||
ARMOR_DESTROY = false
|
||||
ARMOR_LEVEL_MULTIPLIER = 1
|
||||
ARMOR_HEAL_MULTIPLIER = 1
|
||||
ARMOR_RADIATION_MULTIPLIER = 1
|
||||
ARMOR_MATERIALS = {
|
||||
wood = "group:wood",
|
||||
cactus = "default:cactus",
|
||||
@ -18,16 +19,22 @@ ARMOR_MATERIALS = {
|
||||
}
|
||||
ARMOR_FIRE_PROTECT = minetest.get_modpath("ethereal") ~= nil
|
||||
ARMOR_FIRE_NODES = {
|
||||
{"default:lava_source", 5, 4},
|
||||
{"default:lava_flowing", 5, 4},
|
||||
{"default:lava_source", 5, 8},
|
||||
{"default:lava_flowing", 5, 8},
|
||||
{"fire:basic_flame", 3, 4},
|
||||
{"fire:permanent_flame", 3, 4},
|
||||
{"ethereal:crystal_spike", 2, 1},
|
||||
{"bakedclay:safe_fire", 2, 1},
|
||||
{"ethereal:fire_flower", 2, 1},
|
||||
{"default:torch", 1, 1},
|
||||
{"default:torch_ceiling", 1, 1},
|
||||
{"default:torch_wall", 1, 1},
|
||||
}
|
||||
|
||||
local skin_mod = nil
|
||||
local inv_mod = nil
|
||||
local use_player_monoids = minetest.global_exists("player_monoids")
|
||||
local use_armor_monoid = minetest.global_exists("armor_monoid")
|
||||
local preview_textures = {}
|
||||
|
||||
local modpath = minetest.get_modpath(ARMOR_MOD_NAME)
|
||||
local worldpath = minetest.get_worldpath()
|
||||
@ -50,82 +57,97 @@ if not minetest.get_modpath("ethereal") then
|
||||
ARMOR_MATERIALS.crystal = nil
|
||||
end
|
||||
|
||||
-- override hot nodes so they do not hurt player anywhere but mod
|
||||
if ARMOR_FIRE_PROTECT == true then
|
||||
for _, row in ipairs(ARMOR_FIRE_NODES) do
|
||||
if minetest.registered_nodes[row[1]] then
|
||||
minetest.override_item(row[1], {damage_per_second = 0})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local time = 0
|
||||
|
||||
armor = {
|
||||
player_hp = {},
|
||||
timer = 0,
|
||||
elements = {"head", "torso", "legs", "feet"},
|
||||
physics = {"jump","speed","gravity"},
|
||||
formspec = "size[8,8.5]image[2,0.75;2,4;armor_preview]"
|
||||
.."list[current_player;main;0,4.5;8,4;]"
|
||||
.."list[current_player;craft;4,1;3,3;]"
|
||||
.."list[current_player;craftpreview;7,2;1,1;]",
|
||||
formspec = "size[8,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
default.get_hotbar_bg(0,4.25)..
|
||||
"image[2,0.5;2,4;armor_preview]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"..
|
||||
"list[current_player;craft;4,0.5;3,3;]"..
|
||||
"list[current_player;craftpreview;7,1.5;1,1;]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_player;craft]",
|
||||
textures = {},
|
||||
default_skin = "character",
|
||||
version = "0.4.4",
|
||||
version = "0.4.8",
|
||||
}
|
||||
|
||||
local armor_formpage = "image[2.5,0;2,4;armor_preview]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
default.get_hotbar_bg(0,4.25)..
|
||||
"label[5,1;Level: armor_level]"..
|
||||
"label[5,1.5;Heal: armor_heal]"..
|
||||
"label[5,2;Fire: armor_fire]"..
|
||||
"label[5,2.5;Radiation: armor_radiation]"..
|
||||
"list[current_player;main;0,4.25;8,1;]"..
|
||||
"list[current_player;main;0,5.5;8,3;8]"
|
||||
if minetest.get_modpath("inventory_plus") then
|
||||
inv_mod = "inventory_plus"
|
||||
armor.formspec = "size[8,8.5]button[0,0;2,0.5;main;Back]"
|
||||
.."image[2.5,0.75;2,4;armor_preview]"
|
||||
.."label[5,1;Level: armor_level]"
|
||||
.."label[5,1.5;Heal: armor_heal]"
|
||||
.."label[5,2;Fire: armor_fire]"
|
||||
.."list[current_player;main;0,4.5;8,4;]"
|
||||
armor.formspec = "size[8,8.5]button[6,0;2,0.5;main;Back]"..armor_formpage
|
||||
if minetest.get_modpath("crafting") then
|
||||
inventory_plus.get_formspec = function(player, page)
|
||||
end
|
||||
end
|
||||
elseif minetest.get_modpath("unified_inventory") then
|
||||
elseif minetest.get_modpath("unified_inventory") and not unified_inventory.sfinv_compat_layer then
|
||||
inv_mod = "unified_inventory"
|
||||
unified_inventory.register_button("armor", {
|
||||
type = "image",
|
||||
image = "inventory_plus_armor.png",
|
||||
})
|
||||
unified_inventory.register_page("armor", {
|
||||
get_formspec = function(player)
|
||||
get_formspec = function(player, perplayer_formspec)
|
||||
local fy = perplayer_formspec.formspec_y
|
||||
local name = player:get_player_name()
|
||||
local formspec = "background[0.06,0.99;7.92,7.52;3d_armor_ui_form.png]"
|
||||
.."label[0,0;Armor]"
|
||||
.."list[detached:"..name.."_armor;armor;0,1;2,3;]"
|
||||
.."image[2.5,0.75;2,4;"..armor.textures[name].preview.."]"
|
||||
.."label[5,1;Level: "..armor.def[name].level.."]"
|
||||
.."label[5,1.5;Heal: "..armor.def[name].heal.."]"
|
||||
.."label[5,2;Fire: "..armor.def[name].fire.."]"
|
||||
if minetest.setting_getbool("unified_inventory_lite") then
|
||||
formspec = "background[0.06,0.49;7.92,7.52;3d_armor_ui_form.png]"
|
||||
.."label[0,0;Armor]"
|
||||
.."list[detached:"..name.."_armor;armor;0,0.5;2,3;]"
|
||||
.."image[2.5,0.25;2,4;"..armor.textures[name].preview.."]"
|
||||
.."label[5,0.5;Level: "..armor.def[name].level.."]"
|
||||
.."label[5,1;Heal: "..armor.def[name].heal.."]"
|
||||
.."label[5,1.5;Fire: "..armor.def[name].fire.."]"
|
||||
end
|
||||
local formspec = "background[0.06,"..fy..";7.92,7.52;3d_armor_ui_form.png]"..
|
||||
"label[0,0;Armor]"..
|
||||
"list[detached:"..name.."_armor;armor;0,"..fy..";2,3;]"..
|
||||
"image[2.5,"..(fy - 0.25)..";2,4;"..armor.textures[name].preview.."]"..
|
||||
"label[5.0,"..(fy + 0.0)..";Level: "..armor.def[name].level.."]"..
|
||||
"label[5.0,"..(fy + 0.5)..";Heal: "..armor.def[name].heal.."]"..
|
||||
"label[5.0,"..(fy + 1.0)..";Fire: "..armor.def[name].fire.."]"..
|
||||
"label[5.0,"..(fy + 1.5)..";Radiation: "..armor.def[name].radiation.."]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[detached:"..name.."_armor;armor]"
|
||||
return {formspec=formspec}
|
||||
end,
|
||||
})
|
||||
elseif minetest.get_modpath("inventory_enhanced") then
|
||||
inv_mod = "inventory_enhanced"
|
||||
elseif minetest.get_modpath("smart_inventory") then
|
||||
inv_mod = "smart_inventory"
|
||||
elseif minetest.get_modpath("sfinv") then
|
||||
inv_mod = "sfinv"
|
||||
armor.formspec = armor_formpage
|
||||
sfinv.register_page("3d_armor:armor", {
|
||||
title = "Armor",
|
||||
get = function(self, player, context)
|
||||
local name = player:get_player_name()
|
||||
local formspec = armor:get_armor_formspec(name, true)
|
||||
return sfinv.make_formspec(player, context, formspec, false)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if minetest.get_modpath("skins") then
|
||||
skin_mod = "skins"
|
||||
elseif minetest.get_modpath("simple_skins") then
|
||||
skin_mod = "simple_skins"
|
||||
elseif minetest.get_modpath("u_skins") then
|
||||
skin_mod = "u_skins"
|
||||
elseif minetest.get_modpath("wardrobe") then
|
||||
skin_mod = "wardrobe"
|
||||
local skin_mods = {"skins", "u_skins", "simple_skins", "wardrobe"}
|
||||
for _, mod in pairs(skin_mods) do
|
||||
local path = minetest.get_modpath(mod)
|
||||
if path then
|
||||
local dir_list = minetest.get_dir_list(path.."/textures")
|
||||
for _, fn in pairs(dir_list) do
|
||||
if fn:find("_preview.png$") then
|
||||
preview_textures[fn] = true
|
||||
end
|
||||
end
|
||||
skin_mod = mod
|
||||
end
|
||||
end
|
||||
|
||||
armor.def = {
|
||||
@ -156,13 +178,15 @@ armor.set_player_armor = function(self, player)
|
||||
local armor_level = 0
|
||||
local armor_heal = 0
|
||||
local armor_fire = 0
|
||||
local armor_water = 0
|
||||
local armor_radiation = 0
|
||||
local state = 0
|
||||
local items = 0
|
||||
local elements = {}
|
||||
local textures = {}
|
||||
local physics_o = {speed=1,gravity=1,jump=1}
|
||||
local material = {type=nil, count=1}
|
||||
local preview = armor:get_preview(name) or "character_preview.png"
|
||||
local preview = armor:get_preview(name)
|
||||
for _,v in ipairs(self.elements) do
|
||||
elements[v] = false
|
||||
end
|
||||
@ -175,16 +199,16 @@ armor.set_player_armor = function(self, player)
|
||||
if v == false then
|
||||
local level = def.groups["armor_"..k]
|
||||
if level then
|
||||
local texture = item:gsub("%:", "_")
|
||||
local texture = def.texture or item:gsub("%:", "_")
|
||||
table.insert(textures, texture..".png")
|
||||
preview = preview.."^"..texture.."_preview.png"
|
||||
armor_level = armor_level + level
|
||||
state = state + stack:get_wear()
|
||||
items = items + 1
|
||||
local heal = def.groups["armor_heal"] or 0
|
||||
armor_heal = armor_heal + heal
|
||||
local fire = def.groups["armor_fire"] or 0
|
||||
armor_fire = armor_fire + fire
|
||||
armor_heal = armor_heal + (def.groups["armor_heal"] or 0)
|
||||
armor_fire = armor_fire + (def.groups["armor_fire"] or 0)
|
||||
armor_water = armor_water + (def.groups["armor_water"] or 0)
|
||||
armor_radiation = armor_radiation + (def.groups["armor_radiation"] or 0)
|
||||
for kk,vv in ipairs(self.physics) do
|
||||
local o_value = def.groups["physics_"..vv]
|
||||
if o_value then
|
||||
@ -213,6 +237,7 @@ armor.set_player_armor = function(self, player)
|
||||
end
|
||||
armor_level = armor_level * ARMOR_LEVEL_MULTIPLIER
|
||||
armor_heal = armor_heal * ARMOR_HEAL_MULTIPLIER
|
||||
armor_radiation = armor_radiation * ARMOR_RADIATION_MULTIPLIER
|
||||
if #textures > 0 then
|
||||
armor_texture = table.concat(textures, "^")
|
||||
end
|
||||
@ -220,9 +245,25 @@ armor.set_player_armor = function(self, player)
|
||||
if armor_level > 0 then
|
||||
armor_groups.level = math.floor(armor_level / 20)
|
||||
armor_groups.fleshy = 100 - armor_level
|
||||
armor_groups.radiation = 100 - armor_radiation
|
||||
end
|
||||
if use_armor_monoid then
|
||||
armor_monoid.monoid:add_change(player, {
|
||||
fleshy = armor_groups.fleshy / 100
|
||||
}, "3d_armor:armor")
|
||||
else
|
||||
player:set_armor_groups(armor_groups)
|
||||
end
|
||||
if use_player_monoids then
|
||||
player_monoids.speed:add_change(player, physics_o.speed,
|
||||
"3d_armor:physics")
|
||||
player_monoids.jump:add_change(player, physics_o.jump,
|
||||
"3d_armor:physics")
|
||||
player_monoids.gravity:add_change(player, physics_o.gravity,
|
||||
"3d_armor:physics")
|
||||
else
|
||||
player:set_physics_override(physics_o)
|
||||
end
|
||||
player:set_armor_groups(armor_groups)
|
||||
player:set_physics_override(physics_o)
|
||||
self.textures[name].armor = armor_texture
|
||||
self.textures[name].preview = preview
|
||||
self.def[name].state = state
|
||||
@ -233,70 +274,14 @@ armor.set_player_armor = function(self, player)
|
||||
self.def[name].speed = physics_o.speed
|
||||
self.def[name].gravity = physics_o.gravity
|
||||
self.def[name].fire = armor_fire
|
||||
self.def[name].water = armor_water
|
||||
self.def[name].radiation = armor_radiation
|
||||
self:update_player_visuals(player)
|
||||
end
|
||||
|
||||
armor.update_armor = function(self, player)
|
||||
local name, player_inv, armor_inv, pos = armor:get_valid_player(player, "[update_armor]")
|
||||
if not name then
|
||||
return
|
||||
end
|
||||
local hp = player:get_hp() or 0
|
||||
if ARMOR_FIRE_PROTECT == true then
|
||||
pos.y = pos.y + 1.4 -- head level
|
||||
local node_head = minetest.get_node(pos).name
|
||||
pos.y = pos.y - 1.2 -- feet level
|
||||
local node_feet = minetest.get_node(pos).name
|
||||
-- is player inside a hot node?
|
||||
for _, row in ipairs(ARMOR_FIRE_NODES) do
|
||||
-- check for fire protection, if not enough then get hurt
|
||||
if row[1] == node_head or row[1] == node_feet then
|
||||
if hp > 0 and armor.def[name].fire < row[2] then
|
||||
hp = hp - row[3] * ARMOR_UPDATE_TIME
|
||||
player:set_hp(hp)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if hp <= 0 or hp == self.player_hp[name] then
|
||||
return
|
||||
end
|
||||
if self.player_hp[name] > hp then
|
||||
local heal_max = 0
|
||||
local state = 0
|
||||
local items = 0
|
||||
for i=1, 6 do
|
||||
local stack = player_inv:get_stack("armor", i)
|
||||
if stack:get_count() > 0 then
|
||||
local use = stack:get_definition().groups["armor_use"] or 0
|
||||
local heal = stack:get_definition().groups["armor_heal"] or 0
|
||||
local item = stack:get_name()
|
||||
stack:add_wear(use)
|
||||
armor_inv:set_stack("armor", i, stack)
|
||||
player_inv:set_stack("armor", i, stack)
|
||||
state = state + stack:get_wear()
|
||||
items = items + 1
|
||||
if stack:get_count() == 0 then
|
||||
local desc = minetest.registered_items[item].description
|
||||
if desc then
|
||||
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
|
||||
end
|
||||
self:set_player_armor(player)
|
||||
armor:update_inventory(player)
|
||||
end
|
||||
heal_max = heal_max + heal
|
||||
end
|
||||
end
|
||||
self.def[name].state = state
|
||||
self.def[name].count = items
|
||||
heal_max = heal_max * ARMOR_HEAL_MULTIPLIER
|
||||
if heal_max > math.random(100) then
|
||||
player:set_hp(self.player_hp[name])
|
||||
return
|
||||
end
|
||||
end
|
||||
self.player_hp[name] = hp
|
||||
-- Legacy support: Called when armor levels are changed
|
||||
-- Other mods can hook on to this function, see hud mod for example
|
||||
end
|
||||
|
||||
armor.get_player_skin = function(self, name)
|
||||
@ -312,12 +297,14 @@ armor.get_player_skin = function(self, name)
|
||||
end
|
||||
|
||||
armor.get_preview = function(self, name)
|
||||
if skin_mod == "skins" then
|
||||
return armor:get_player_skin(name).."_preview.png"
|
||||
local preview = armor:get_player_skin(name).."_preview.png"
|
||||
if preview_textures[preview] then
|
||||
return preview
|
||||
end
|
||||
return "character_preview.png"
|
||||
end
|
||||
|
||||
armor.get_armor_formspec = function(self, name)
|
||||
armor.get_armor_formspec = function(self, name, listring)
|
||||
if not armor.textures[name] then
|
||||
minetest.log("error", "3d_armor: Player texture["..name.."] is nil [get_armor_formspec]")
|
||||
return ""
|
||||
@ -326,11 +313,17 @@ armor.get_armor_formspec = function(self, name)
|
||||
minetest.log("error", "3d_armor: Armor def["..name.."] is nil [get_armor_formspec]")
|
||||
return ""
|
||||
end
|
||||
local formspec = armor.formspec.."list[detached:"..name.."_armor;armor;0,1;2,3;]"
|
||||
local formspec = armor.formspec.."list[detached:"..name.."_armor;armor;0,0.5;2,3;]"
|
||||
if listring == true then
|
||||
formspec = formspec.."listring[current_player;main]"..
|
||||
"listring[detached:"..name.."_armor;armor]"
|
||||
end
|
||||
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
|
||||
formspec = formspec:gsub("armor_level", armor.def[name].level)
|
||||
formspec = formspec:gsub("armor_heal", armor.def[name].heal)
|
||||
formspec = formspec:gsub("armor_fire", armor.def[name].fire)
|
||||
formspec = formspec:gsub("armor_radiation", armor.def[name].radiation)
|
||||
formspec = formspec:gsub("player_name", armor.def[name].radiation)
|
||||
return formspec
|
||||
end
|
||||
|
||||
@ -339,18 +332,33 @@ armor.update_inventory = function(self, player)
|
||||
if not name or inv_mod == "inventory_enhanced" then
|
||||
return
|
||||
end
|
||||
if inv_mod == "unified_inventory" then
|
||||
if inv_mod == "smart_inventory" then
|
||||
local state = smart_inventory.get_page_state("player", name)
|
||||
if state then
|
||||
state:get("update_hook"):submit()
|
||||
end
|
||||
elseif inv_mod == "sfinv" then
|
||||
if sfinv.set_page then
|
||||
sfinv.set_page(player, "3d_armor:armor")
|
||||
else
|
||||
-- Backwards compat
|
||||
sfinv.set_player_inventory_formspec(player, {
|
||||
page = "3d_armor:armor"
|
||||
})
|
||||
end
|
||||
elseif inv_mod == "unified_inventory" then
|
||||
if unified_inventory.current_page[name] == "armor" then
|
||||
unified_inventory.set_inventory_formspec(player, "armor")
|
||||
end
|
||||
else
|
||||
local formspec = armor:get_armor_formspec(name)
|
||||
if inv_mod == "inventory_plus" then
|
||||
local formspec = armor:get_armor_formspec(name, true)
|
||||
local page = player:get_inventory_formspec()
|
||||
if page:find("detached:"..name.."_armor") then
|
||||
inventory_plus.set_inventory_formspec(player, formspec)
|
||||
end
|
||||
else
|
||||
elseif not core.setting_getbool("creative_mode") then
|
||||
local formspec = armor:get_armor_formspec(name)
|
||||
player:set_inventory_formspec(formspec)
|
||||
end
|
||||
end
|
||||
@ -383,6 +391,13 @@ armor.get_valid_player = function(self, player, msg)
|
||||
return name, player_inv, armor_inv, pos
|
||||
end
|
||||
|
||||
armor.drop_armor = function(pos, stack)
|
||||
local obj = minetest.add_item(pos, stack)
|
||||
if obj then
|
||||
obj:setvelocity({x=math.random(-1, 1), y=5, z=math.random(-1, 1)})
|
||||
end
|
||||
end
|
||||
|
||||
-- Register Player Model
|
||||
|
||||
default.player_register_model("3d_armor_character.b3d", {
|
||||
@ -410,7 +425,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
if inv_mod == "inventory_plus" and fields.armor then
|
||||
local formspec = armor:get_armor_formspec(name)
|
||||
local formspec = armor:get_armor_formspec(name, true)
|
||||
inventory_plus.set_inventory_formspec(player, formspec)
|
||||
return
|
||||
end
|
||||
@ -457,7 +472,7 @@ minetest.register_on_joinplayer(function(player)
|
||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||
return count
|
||||
end,
|
||||
})
|
||||
}, name)
|
||||
if inv_mod == "inventory_plus" then
|
||||
inventory_plus.register_button(player,"armor", "Armor")
|
||||
end
|
||||
@ -466,17 +481,7 @@ minetest.register_on_joinplayer(function(player)
|
||||
for i=1, 6 do
|
||||
local stack = player_inv:get_stack("armor", i)
|
||||
armor_inv:set_stack("armor", i, stack)
|
||||
end
|
||||
|
||||
-- Legacy support, import player's armor from old inventory format
|
||||
for _,v in pairs(armor.elements) do
|
||||
local list = "armor_"..v
|
||||
armor_inv:add_item("armor", player_inv:get_stack(list, 1))
|
||||
player_inv:set_stack(list, 1, nil)
|
||||
end
|
||||
-- TODO Remove this on the next version upate
|
||||
|
||||
armor.player_hp[name] = 0
|
||||
armor.def[name] = {
|
||||
state = 0,
|
||||
count = 0,
|
||||
@ -486,6 +491,8 @@ minetest.register_on_joinplayer(function(player)
|
||||
speed = 1,
|
||||
gravity = 1,
|
||||
fire = 0,
|
||||
water = 0,
|
||||
radiation = 0,
|
||||
}
|
||||
armor.textures[name] = {
|
||||
skin = armor.default_skin..".png",
|
||||
@ -501,7 +508,7 @@ minetest.register_on_joinplayer(function(player)
|
||||
elseif skin_mod == "simple_skins" then
|
||||
local skin = skins.skins[name]
|
||||
if skin then
|
||||
armor.textures[name].skin = skin..".png"
|
||||
armor.textures[name].skin = skin..".png"
|
||||
end
|
||||
elseif skin_mod == "u_skins" then
|
||||
local skin = u_skins.u_skins[name]
|
||||
@ -514,12 +521,14 @@ minetest.register_on_joinplayer(function(player)
|
||||
armor.textures[name].skin = skin
|
||||
end
|
||||
end
|
||||
if minetest.get_modpath("player_textures") then
|
||||
local filename = minetest.get_modpath("player_textures").."/textures/player_"..name
|
||||
local f = io.open(filename..".png")
|
||||
if f then
|
||||
f:close()
|
||||
armor.textures[name].skin = "player_"..name..".png"
|
||||
local texture_path = minetest.get_modpath("player_textures")
|
||||
if texture_path then
|
||||
local dir_list = minetest.get_dir_list(texture_path.."/textures")
|
||||
for _, fn in pairs(dir_list) do
|
||||
if fn == "player_"..name..".png" then
|
||||
armor.textures[name].skin = fn
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
for i=1, ARMOR_INIT_TIMES do
|
||||
@ -533,12 +542,6 @@ minetest.register_on_joinplayer(function(player)
|
||||
end)
|
||||
|
||||
if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
||||
armor.drop_armor = function(pos, stack)
|
||||
local obj = minetest.add_item(pos, stack)
|
||||
if obj then
|
||||
obj:setvelocity({x=math.random(-1, 1), y=5, z=math.random(-1, 1)})
|
||||
end
|
||||
end
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local name, player_inv, armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
|
||||
if not name then
|
||||
@ -564,18 +567,24 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
||||
end
|
||||
if ARMOR_DESTROY == false then
|
||||
minetest.after(ARMOR_BONES_DELAY, function()
|
||||
local node = minetest.get_node(vector.round(pos))
|
||||
if node then
|
||||
if node.name == "bones:bones" then
|
||||
local meta = minetest.get_meta(vector.round(pos))
|
||||
local owner = meta:get_string("owner")
|
||||
local inv = meta:get_inventory()
|
||||
for _,stack in ipairs(drop) do
|
||||
if name == owner and inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
else
|
||||
armor.drop_armor(pos, stack)
|
||||
end
|
||||
local meta = nil
|
||||
local maxp = vector.add(pos, 8)
|
||||
local minp = vector.subtract(pos, 8)
|
||||
local bones = minetest.find_nodes_in_area(minp, maxp, {"bones:bones"})
|
||||
for _, p in pairs(bones) do
|
||||
local m = minetest.get_meta(p)
|
||||
if m:get_string("owner") == name then
|
||||
meta = m
|
||||
break
|
||||
end
|
||||
end
|
||||
if meta then
|
||||
local inv = meta:get_inventory()
|
||||
for _,stack in ipairs(drop) do
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
else
|
||||
armor.drop_armor(pos, stack)
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -588,13 +597,121 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
time = time + dtime
|
||||
if time > ARMOR_UPDATE_TIME then
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
armor:update_armor(player)
|
||||
minetest.register_on_player_hpchange(function(player, hp_change)
|
||||
local name, player_inv, armor_inv = armor:get_valid_player(player, "[on_hpchange]")
|
||||
if name and hp_change < 0 then
|
||||
|
||||
-- used for insta kill tools/commands like /kill (doesnt damage armor)
|
||||
if hp_change < -100 then
|
||||
return hp_change
|
||||
end
|
||||
time = 0
|
||||
|
||||
local heal_max = 0
|
||||
local state = 0
|
||||
local items = 0
|
||||
for i=1, 6 do
|
||||
local stack = player_inv:get_stack("armor", i)
|
||||
if stack:get_count() > 0 then
|
||||
local use = stack:get_definition().groups["armor_use"] or 0
|
||||
local heal = stack:get_definition().groups["armor_heal"] or 0
|
||||
local item = stack:get_name()
|
||||
stack:add_wear(use)
|
||||
armor_inv:set_stack("armor", i, stack)
|
||||
player_inv:set_stack("armor", i, stack)
|
||||
state = state + stack:get_wear()
|
||||
items = items + 1
|
||||
if stack:get_count() == 0 then
|
||||
local desc = minetest.registered_items[item].description
|
||||
if desc then
|
||||
minetest.chat_send_player(name, "Your "..desc.." got destroyed!")
|
||||
end
|
||||
armor:set_player_armor(player)
|
||||
armor:update_inventory(player)
|
||||
end
|
||||
heal_max = heal_max + heal
|
||||
end
|
||||
end
|
||||
armor.def[name].state = state
|
||||
armor.def[name].count = items
|
||||
heal_max = heal_max * ARMOR_HEAL_MULTIPLIER
|
||||
if heal_max > math.random(100) then
|
||||
hp_change = 0
|
||||
end
|
||||
armor:update_armor(player)
|
||||
end
|
||||
return hp_change
|
||||
end, true)
|
||||
|
||||
-- Fire Protection and water breating, added by TenPlus1
|
||||
|
||||
if ARMOR_FIRE_PROTECT == true then
|
||||
-- override hot nodes so they do not hurt player anywhere but mod
|
||||
for _, row in pairs(ARMOR_FIRE_NODES) do
|
||||
if minetest.registered_nodes[row[1]] then
|
||||
minetest.override_item(row[1], {damage_per_second = 0})
|
||||
end
|
||||
end
|
||||
else
|
||||
print ("[3d_armor] Fire Nodes disabled")
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
armor.timer = armor.timer + dtime
|
||||
if armor.timer < ARMOR_UPDATE_TIME then
|
||||
return
|
||||
end
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local pos = player:getpos()
|
||||
local hp = player:get_hp()
|
||||
-- water breathing
|
||||
if name and armor.def[name].water > 0 then
|
||||
if player:get_breath() < 10 then
|
||||
player:set_breath(10)
|
||||
end
|
||||
end
|
||||
-- fire protection
|
||||
if ARMOR_FIRE_PROTECT == true
|
||||
and name and pos and hp then
|
||||
pos.y = pos.y + 1.4 -- head level
|
||||
local node_head = minetest.get_node(pos).name
|
||||
pos.y = pos.y - 1.2 -- feet level
|
||||
local node_feet = minetest.get_node(pos).name
|
||||
-- is player inside a hot node?
|
||||
for _, row in pairs(ARMOR_FIRE_NODES) do
|
||||
-- check fire protection, if not enough then get hurt
|
||||
if row[1] == node_head or row[1] == node_feet then
|
||||
if hp > 0 and armor.def[name].fire < row[2] then
|
||||
hp = hp - row[3] * ARMOR_UPDATE_TIME
|
||||
player:set_hp(hp)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
armor.timer = 0
|
||||
end)
|
||||
|
||||
-- kill player when command issued
|
||||
minetest.register_chatcommand("kill", {
|
||||
params = "<name>",
|
||||
description = "Kills player instantly",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(param)
|
||||
if player then
|
||||
player:set_hp(0)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("killme", {
|
||||
description = "Kill yourself instantly",
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
player:set_hp(-1001)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -1,6 +1,9 @@
|
||||
default
|
||||
player_monoids?
|
||||
armor_monoid?
|
||||
inventory_plus?
|
||||
unified_inventory?
|
||||
sfinv?
|
||||
fire?
|
||||
ethereal?
|
||||
bakedclay?
|
||||
|
1
3d_armor/description.txt
Normal file
@ -0,0 +1 @@
|
||||
Adds craftable armor that is visible to other players.
|
@ -51,7 +51,7 @@ if ARMOR_MATERIALS.cactus then
|
||||
minetest.register_tool("3d_armor:boots_cactus", {
|
||||
description = "Cactus Boots",
|
||||
inventory_image = "3d_armor_inv_boots_cactus.png",
|
||||
groups = {armor_feet=5, armor_heal=0, armor_use=2000},
|
||||
groups = {armor_feet=5, armor_heal=0, armor_use=1000},
|
||||
wear = 0,
|
||||
})
|
||||
end
|
||||
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 242 B |
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 264 B |
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 242 B |
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 206 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 210 B |
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 196 B |
Before Width: | Height: | Size: 274 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 782 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 556 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 280 B |
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 456 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 300 B |
Before Width: | Height: | Size: 430 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 669 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 537 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 281 B |
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 362 B |
Before Width: | Height: | Size: 725 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 883 B After Width: | Height: | Size: 192 B |
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 891 B After Width: | Height: | Size: 225 B |
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 883 B After Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 902 B After Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 798 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 853 B After Width: | Height: | Size: 226 B |
Before Width: | Height: | Size: 556 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 878 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 200 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 155 B After Width: | Height: | Size: 3.0 KiB |