1
0
mirror of https://github.com/minetest-mods/3d_armor.git synced 2025-06-29 23:00:55 +02:00

Add support for non-fleshy damage groups, closes #47

This commit is contained in:
stujones11
2017-03-23 00:52:32 +00:00
parent 86fd6b0d7d
commit 11ce84873b
6 changed files with 274 additions and 222 deletions

View File

@ -50,16 +50,17 @@ for material, _ in pairs(armor.materials) do
armor.materials[material] = nil
end
end
if armor.config.fire_protect then
armor.formspec = armor.formspec.."label[5,2;Fire: armor_fire]"
end
dofile(modpath.."/armor.lua")
-- Mod Compatibility
if armor.config.fire_protect then
armor.formspec = armor.formspec.."label[5,2;Fire: armor_fire]"
end
if minetest.get_modpath("technic") then
armor.formspec = armor.formspec.."label[5,2.5;Radiation: armor_radiation]"
armor.formspec = armor.formspec.."label[5,2.5;Radiation: armor_group_radiation]"
armor:register_armor_group("radiation")
end
local skin_mods = {"skins", "u_skins", "simple_skins", "wardrobe"}
for _, mod in pairs(skin_mods) do
@ -167,17 +168,20 @@ minetest.register_on_joinplayer(function(player)
armor:run_callbacks("on_equip", player, stack)
end
armor.def[name] = {
level = 0,
state = 0,
count = 0,
level = 0,
heal = 0,
jump = 1,
speed = 1,
gravity = 1,
fire = 0,
water = 0,
radiation = 0,
groups = {},
}
for _, phys in pairs(armor.physics) do
armor.def[name][phys] = 1
end
for _, attr in pairs(armor.attributes) do
armor.def[name][attr] = 0
end
for group, _ in pairs(armor.registered_groups) do
armor.def[name].groups[group] = 0
end
local skin = armor:get_player_skin(name)
armor.textures[name] = {
skin = skin..".png",
@ -202,6 +206,14 @@ minetest.register_on_joinplayer(function(player)
end
end)
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
if name then
armor.def[name] = nil
armor.textures[name] = nil
end
end)
if armor.config.drop == true or armor.config.destroy == true then
minetest.register_on_dieplayer(function(player)
local name, player_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
@ -282,7 +294,7 @@ minetest.register_on_player_hpchange(function(player, hp_change)
armor.def[name].state = state
armor.def[name].count = items
heal_max = heal_max * armor.config.heal_multiplier
if heal_max > math.random(100) then
if heal_max >= math.random(100) then
hp_change = 0
end
end