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

@ -3,7 +3,9 @@
Depends: default
Recommends: sfinv, inventory_plus or unified_inventory (use only one to avoid conflicts)
Recommends: sfinv, unified_inventory or smart_inventory (use only one to avoid conflicts)
Supports: player_monoids and armor_monoid
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.
@ -69,13 +71,22 @@ API
Armor Registration:
minetest.register_tool("your_mod_name:speed_boots", {
armor:register_armor(name, def)
armor:register_armor_group(group, base)
Example:
armor:register_armor_group("radiation", 100)
armor:register_armor("mod_name:speed_boots", {
description = "Speed Boots",
inventory_image = "your_mod_name_speed_boots_inv.png",
texture = "your_mod_name_speed_boots.png",
groups = {armor_feet=10, physics_speed=0.5, armor_use=2000},
inventory_image = "mod_name_speed_boots_inv.png",
texture = "mod_name_speed_boots.png",
preview = "mod_name_speed_boots_preview.png",
armor_groups = {fleshy=10, radiation=10},
groups = {armor_feet=1, physics_speed=0.5, armor_use=2000},
on_destroy = function(player, item_name)
minetest.sound_play("your_mod_name_break_sound", {
minetest.sound_play("mod_name_break_sound", {
to_player = player:get_player_name(),
})
end,
@ -92,15 +103,15 @@ Durability: armor_use
Notes:
Elements may be modified by dependent mods, eg shields adds armor_shield.
Physics values are 'stackable', durability is determined
by the level of armor_use. total uses == approx (65535/armor_use)
Attributes and physics values are 'stackable', durability is determined
by the level of armor_use, total uses == approx (65535/armor_use), non-fleshy
damage groups need to be defined in the tool/weapon used against the player
Item Callbacks:
on_equip = func(player, stack)
on_unequip = func(player, stack)
on_destroy = func(player, item_name)
on_destroy = func(player, stack)
Global Callbacks:

View File

@ -6,13 +6,14 @@ armor = {
timer = 0,
elements = {"head", "torso", "legs", "feet"},
physics = {"jump", "speed", "gravity"},
attributes = {"heal", "fire", "water"},
formspec = "image[2.5,0;2,4;armor_preview]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
default.get_hotbar_bg(0, 4.7)..
"label[5,1;Level: armor_level]"..
"label[5,1.5;Heal: armor_heal]"..
"label[5,1.5;Heal: armor_attr_heal]"..
"list[current_player;main;0,4.7;8,1;]"..
"list[current_player;main;0,5.85;8,3;8]",
def = {},
@ -39,6 +40,7 @@ armor = {
{"default:torch_ceiling", 1, 1},
{"default:torch_wall", 1, 1},
},
registered_groups = {["fleshy"]=100},
registered_callbacks = {
on_update = {},
on_equip = {},
@ -69,6 +71,20 @@ armor.config = {
fire_protect = minetest.get_modpath("ethereal") ~= nil
}
-- Armor Registration
armor.register_armor = function(self, name, def)
minetest.register_tool(name, def)
end
armor.register_armor_group = function(self, group, base)
base = base or 100
self.registered_groups[group] = base
if use_armor_monoid then
armor_monoid.register_armor_group(group, base)
end
end
-- Armor callbacks
armor.register_on_update = function(self, func)
@ -125,112 +141,125 @@ armor.update_player_visuals = function(self, player)
end
armor.set_player_armor = function(self, player)
local name, player_inv = armor:get_valid_player(player, "[set_player_armor]")
local name, player_inv = self:get_valid_player(player, "[set_player_armor]")
if not name then
return
end
local armor_texture = "3d_armor_trans.png"
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 count = 0
local material = {count=1}
local preview = armor:get_preview(name)
for _,v in ipairs(self.elements) do
elements[v] = false
local texture = "3d_armor_trans.png"
local textures = {}
local physics = {}
local attributes = {}
local levels = {}
local groups = {}
local change = {}
for _, phys in pairs(self.physics) do
physics[phys] = 0
end
for i=1, 6 do
local stack = player_inv:get_stack("armor", i)
local item = stack:get_name()
for _, attr in pairs(self.attributes) do
attributes[attr] = 0
end
for group, base in pairs(self.registered_groups) do
groups[group] = base
change[group] = 1
levels[group] = 0
end
local list = player_inv:get_list("armor")
for i, stack in pairs(list) do
if stack:get_count() == 1 then
local def = stack:get_definition()
for k, v in pairs(elements) do
if v == false then
local level = def.groups["armor_"..k]
if level then
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
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
physics_o[vv] = physics_o[vv] + o_value
for _, element in pairs(self.elements) do
if def.groups["armor_"..element] then
if def.armor_groups then
for group, level in pairs(def.armor_groups) do
if levels[group] then
levels[group] = levels[group] + level
end
end
local mat = string.match(item, "%:.+_(.+)$")
if material.type then
if material.type == mat then
material.count = material.count + 1
end
else
material.type = mat
end
elements[k] = true
else
local level = def.groups["armor_"..element]
levels["fleshy"] = levels["fleshy"] + level
end
end
-- DEPRECATED, use armor_groups instead
if def.groups["armor_radiation"] and levels["radiation"] then
levels["radiation"] = def.groups["armor_radiation"]
end
end
local item = stack:get_name()
local tex = def.texture or item:gsub("%:", "_")
local prev = def.preview or tex.."_preview"
tex = tex:gsub(".png$", "")
prev = prev:gsub(".png$", "")
texture = texture.."^"..tex..".png"
preview = preview.."^"..prev..".png"
state = state + stack:get_wear()
count = count + 1
for _, phys in pairs(self.physics) do
local value = def.groups["physics_"..phys] or 0
physics[phys] = physics[phys] + value
end
for _, attr in pairs(self.attributes) do
local value = def.groups["armor_"..attr] or 0
attributes[attr] = attributes[attr] + value
end
local mat = string.match(item, "%:.+_(.+)$")
if material.name then
if material.name == mat then
material.count = material.count + 1
end
else
material.name = mat
end
end
end
if minetest.get_modpath("shields") then
armor_level = armor_level * 0.9
for group, level in pairs(levels) do
if level > 0 then
local base = self.registered_groups[group]
if minetest.get_modpath("shields") then
level = level * 0.9
end
if material.name and material.count == #self.elements then
level = level * 1.1
end
level = level * armor.config.level_multiplier
self.def[name].groups[group] = level
if level > base then
level = base
end
groups[group] = base - level
change[group] = groups[group] / base
end
end
if material.type and material.count == #self.elements then
armor_level = armor_level * 1.1
for _, attr in pairs(self.attributes) do
self.def[name][attr] = attributes[attr]
end
armor_level = armor_level * self.config.level_multiplier
armor_heal = armor_heal * self.config.heal_multiplier
armor_radiation = armor_radiation * self.config.radiation_multiplier
if #textures > 0 then
armor_texture = table.concat(textures, "^")
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
armor_groups.radiation = 100 - armor_radiation
for _, phys in pairs(self.physics) do
self.def[name][phys] = physics[phys]
end
if use_armor_monoid then
armor_monoid.monoid:add_change(player, {
fleshy = armor_groups.fleshy / 100
}, "3d_armor:armor")
armor_monoid.monoid:add_change(player, change, "3d_armor:armor")
else
player:set_armor_groups(armor_groups)
player:set_armor_groups(groups)
end
if use_player_monoids then
player_monoids.speed:add_change(player, physics_o.speed,
player_monoids.speed:add_change(player, physics.speed,
"3d_armor:physics")
player_monoids.jump:add_change(player, physics_o.jump,
player_monoids.jump:add_change(player, physics.jump,
"3d_armor:physics")
player_monoids.gravity:add_change(player, physics_o.gravity,
player_monoids.gravity:add_change(player, physics.gravity,
"3d_armor:physics")
else
player:set_physics_override(physics_o)
player:set_physics_override(physics)
end
self.textures[name].armor = armor_texture
self.textures[name].armor = texture
self.textures[name].preview = preview
self.def[name].level = self.def[name].groups.fleshy or 0
self.def[name].state = state
self.def[name].count = items
self.def[name].level = armor_level
self.def[name].heal = armor_heal
self.def[name].jump = physics_o.jump
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.def[name].count = count
self:update_player_visuals(player)
self:run_callbacks("on_update", player)
end
@ -263,29 +292,28 @@ armor.get_preview = function(self, name)
end
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]")
if not armor.def[name] or not armor.textures[name] then
return ""
end
if not armor.def[name] then
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,0.5;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)
for _, attr in pairs(self.attributes) do
formspec = formspec:gsub("armor_attr_"..attr, armor.def[name][attr])
end
for _, group in pairs(self.attributes) do
formspec = formspec:gsub("armor_group_"..group, armor.def[name][group])
end
return formspec
end
armor.update_inventory = function(self, player)
-- DEPRECIATED: Legacy inventory support
-- DEPRECATED: Legacy inventory support
end
armor.set_inventory_stack = function(self, player, i, stack)

View File

@ -1,4 +1,4 @@
-- DEPRECIATED, will not be supported in future versions
-- DEPRECATED, will not be supported in future versions
-- See README.txt for new configuration options.

View File

@ -3,263 +3,264 @@ minetest.register_alias("adminhelmet","3d_armor:helmet_admin")
minetest.register_alias("adminchestplate","3d_armor:chestplate_admin")
minetest.register_alias("adminleggings","3d_armor:leggings_admin")
minetest.register_tool("3d_armor:helmet_admin", {
armor:register_armor("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, armor_water=1,
armor_groups = {fleshy=100},
groups = {armor_head=1, armor_heal=100, 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", {
armor:register_armor("3d_armor:chestplate_admin", {
description = "Admin Chestplate",
inventory_image = "3d_armor_inv_chestplate_admin.png",
groups = {armor_torso=1000, armor_heal=1000, armor_use=0,
armor_groups = {fleshy=100},
groups = {armor_torso=1, armor_heal=100, 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", {
armor:register_armor("3d_armor:leggings_admin", {
description = "Admin Leggings",
inventory_image = "3d_armor_inv_leggings_admin.png",
groups = {armor_legs=1000, armor_heal=1000, armor_use=0,
armor_groups = {fleshy=100},
groups = {armor_legs=1, armor_heal=100, 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", {
armor:register_armor("3d_armor:boots_admin", {
description = "Admin Boots",
inventory_image = "3d_armor_inv_boots_admin.png",
groups = {armor_feet=1000, armor_heal=1000, armor_use=0,
armor_groups = {fleshy=100},
groups = {armor_feet=1, armor_heal=100, armor_use=0,
not_in_creative_inventory=1},
wear = 0,
on_drop = function(itemstack, dropper, pos)
return
end,
})
if armor.materials.wood then
minetest.register_tool("3d_armor:helmet_wood", {
armor:register_armor("3d_armor:helmet_wood", {
description = "Wood Helmet",
inventory_image = "3d_armor_inv_helmet_wood.png",
groups = {armor_head=5, armor_heal=0, armor_use=2000},
wear = 0,
armor_groups = {fleshy=5},
groups = {armor_head=1, armor_heal=0, armor_use=2000},
})
minetest.register_tool("3d_armor:chestplate_wood", {
armor:register_armor("3d_armor:chestplate_wood", {
description = "Wood Chestplate",
inventory_image = "3d_armor_inv_chestplate_wood.png",
groups = {armor_torso=10, armor_heal=0, armor_use=2000},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_torso=1, armor_heal=0, armor_use=2000},
})
minetest.register_tool("3d_armor:leggings_wood", {
armor:register_armor("3d_armor:leggings_wood", {
description = "Wood Leggings",
inventory_image = "3d_armor_inv_leggings_wood.png",
groups = {armor_legs=5, armor_heal=0, armor_use=2000},
wear = 0,
armor_groups = {fleshy=5},
groups = {armor_legs=1, armor_heal=0, armor_use=2000},
})
minetest.register_tool("3d_armor:boots_wood", {
armor:register_armor("3d_armor:boots_wood", {
description = "Wood Boots",
inventory_image = "3d_armor_inv_boots_wood.png",
groups = {armor_feet=5, armor_heal=0, armor_use=2000},
wear = 0,
armor_groups = {fleshy=5},
groups = {armor_feet=1, armor_heal=0, armor_use=2000},
})
end
if armor.materials.cactus then
minetest.register_tool("3d_armor:helmet_cactus", {
armor:register_armor("3d_armor:helmet_cactus", {
description = "Cactus Helmet",
inventory_image = "3d_armor_inv_helmet_cactus.png",
groups = {armor_head=5, armor_heal=0, armor_use=1000},
wear = 0,
armor_groups = {fleshy=5},
groups = {armor_head=1, armor_heal=0, armor_use=1000},
})
minetest.register_tool("3d_armor:chestplate_cactus", {
armor:register_armor("3d_armor:chestplate_cactus", {
description = "Cactus Chestplate",
inventory_image = "3d_armor_inv_chestplate_cactus.png",
groups = {armor_torso=10, armor_heal=0, armor_use=1000},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_torso=1, armor_heal=0, armor_use=1000},
})
minetest.register_tool("3d_armor:leggings_cactus", {
armor:register_armor("3d_armor:leggings_cactus", {
description = "Cactus Leggings",
inventory_image = "3d_armor_inv_leggings_cactus.png",
groups = {armor_legs=5, armor_heal=0, armor_use=1000},
wear = 0,
armor_groups = {fleshy=5},
groups = {armor_legs=1, armor_heal=0, armor_use=1000},
})
minetest.register_tool("3d_armor:boots_cactus", {
armor:register_armor("3d_armor:boots_cactus", {
description = "Cactus Boots",
inventory_image = "3d_armor_inv_boots_cactus.png",
groups = {armor_feet=5, armor_heal=0, armor_use=1000},
wear = 0,
armor_groups = {fleshy=5},
groups = {armor_feet=1, armor_heal=0, armor_use=1000},
})
end
if armor.materials.steel then
minetest.register_tool("3d_armor:helmet_steel", {
armor:register_armor("3d_armor:helmet_steel", {
description = "Steel Helmet",
inventory_image = "3d_armor_inv_helmet_steel.png",
groups = {armor_head=10, armor_heal=0, armor_use=500},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_head=1, armor_heal=0, armor_use=500},
})
minetest.register_tool("3d_armor:chestplate_steel", {
armor:register_armor("3d_armor:chestplate_steel", {
description = "Steel Chestplate",
inventory_image = "3d_armor_inv_chestplate_steel.png",
groups = {armor_torso=15, armor_heal=0, armor_use=500},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_torso=1, armor_heal=0, armor_use=500},
})
minetest.register_tool("3d_armor:leggings_steel", {
armor:register_armor("3d_armor:leggings_steel", {
description = "Steel Leggings",
inventory_image = "3d_armor_inv_leggings_steel.png",
groups = {armor_legs=15, armor_heal=0, armor_use=500},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_legs=1, armor_heal=0, armor_use=500},
})
minetest.register_tool("3d_armor:boots_steel", {
armor:register_armor("3d_armor:boots_steel", {
description = "Steel Boots",
inventory_image = "3d_armor_inv_boots_steel.png",
groups = {armor_feet=10, armor_heal=0, armor_use=500},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_feet=1, armor_heal=0, armor_use=500},
})
end
if armor.materials.bronze then
minetest.register_tool("3d_armor:helmet_bronze", {
armor:register_armor("3d_armor:helmet_bronze", {
description = "Bronze Helmet",
inventory_image = "3d_armor_inv_helmet_bronze.png",
groups = {armor_head=10, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_head=1, armor_heal=6, armor_use=250},
})
minetest.register_tool("3d_armor:chestplate_bronze", {
armor:register_armor("3d_armor:chestplate_bronze", {
description = "Bronze Chestplate",
inventory_image = "3d_armor_inv_chestplate_bronze.png",
groups = {armor_torso=15, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_torso=1, armor_heal=6, armor_use=250},
})
minetest.register_tool("3d_armor:leggings_bronze", {
armor:register_armor("3d_armor:leggings_bronze", {
description = "Bronze Leggings",
inventory_image = "3d_armor_inv_leggings_bronze.png",
groups = {armor_legs=15, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_legs=1, armor_heal=6, armor_use=250},
})
minetest.register_tool("3d_armor:boots_bronze", {
armor:register_armor("3d_armor:boots_bronze", {
description = "Bronze Boots",
inventory_image = "3d_armor_inv_boots_bronze.png",
groups = {armor_feet=10, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_feet=1, armor_heal=6, armor_use=250},
})
end
if armor.materials.diamond then
minetest.register_tool("3d_armor:helmet_diamond", {
armor:register_armor("3d_armor:helmet_diamond", {
description = "Diamond Helmet",
inventory_image = "3d_armor_inv_helmet_diamond.png",
groups = {armor_head=15, armor_heal=12, armor_use=100},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_head=1, armor_heal=12, armor_use=100},
})
minetest.register_tool("3d_armor:chestplate_diamond", {
armor:register_armor("3d_armor:chestplate_diamond", {
description = "Diamond Chestplate",
inventory_image = "3d_armor_inv_chestplate_diamond.png",
groups = {armor_torso=20, armor_heal=12, armor_use=100},
wear = 0,
armor_groups = {fleshy=20},
groups = {armor_torso=1, armor_heal=12, armor_use=100},
})
minetest.register_tool("3d_armor:leggings_diamond", {
armor:register_armor("3d_armor:leggings_diamond", {
description = "Diamond Leggings",
inventory_image = "3d_armor_inv_leggings_diamond.png",
groups = {armor_legs=20, armor_heal=12, armor_use=100},
wear = 0,
armor_groups = {fleshy=20},
groups = {armor_legs=1, armor_heal=12, armor_use=100},
})
minetest.register_tool("3d_armor:boots_diamond", {
armor:register_armor("3d_armor:boots_diamond", {
description = "Diamond Boots",
inventory_image = "3d_armor_inv_boots_diamond.png",
groups = {armor_feet=15, armor_heal=12, armor_use=100},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_feet=1, armor_heal=12, armor_use=100},
})
end
if armor.materials.gold then
minetest.register_tool("3d_armor:helmet_gold", {
armor:register_armor("3d_armor:helmet_gold", {
description = "Gold Helmet",
inventory_image = "3d_armor_inv_helmet_gold.png",
groups = {armor_head=10, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_head=1, armor_heal=6, armor_use=250},
})
minetest.register_tool("3d_armor:chestplate_gold", {
armor:register_armor("3d_armor:chestplate_gold", {
description = "Gold Chestplate",
inventory_image = "3d_armor_inv_chestplate_gold.png",
groups = {armor_torso=15, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_torso=1, armor_heal=6, armor_use=250},
})
minetest.register_tool("3d_armor:leggings_gold", {
armor:register_armor("3d_armor:leggings_gold", {
description = "Gold Leggings",
inventory_image = "3d_armor_inv_leggings_gold.png",
groups = {armor_legs=15, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_legs=1, armor_heal=6, armor_use=250},
})
minetest.register_tool("3d_armor:boots_gold", {
armor:register_armor("3d_armor:boots_gold", {
description = "Gold Boots",
inventory_image = "3d_armor_inv_boots_gold.png",
groups = {armor_feet=10, armor_heal=6, armor_use=250},
wear = 0,
armor_groups = {fleshy=10},
groups = {armor_feet=1, armor_heal=6, armor_use=250},
})
end
if armor.materials.mithril then
minetest.register_tool("3d_armor:helmet_mithril", {
armor:register_armor("3d_armor:helmet_mithril", {
description = "Mithril Helmet",
inventory_image = "3d_armor_inv_helmet_mithril.png",
groups = {armor_head=15, armor_heal=12, armor_use=50},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_head=1, armor_heal=12, armor_use=50},
})
minetest.register_tool("3d_armor:chestplate_mithril", {
armor:register_armor("3d_armor:chestplate_mithril", {
description = "Mithril Chestplate",
inventory_image = "3d_armor_inv_chestplate_mithril.png",
groups = {armor_torso=20, armor_heal=12, armor_use=50},
wear = 0,
armor_groups = {fleshy=20},
groups = {armor_torso=1, armor_heal=12, armor_use=50},
})
minetest.register_tool("3d_armor:leggings_mithril", {
armor:register_armor("3d_armor:leggings_mithril", {
description = "Mithril Leggings",
inventory_image = "3d_armor_inv_leggings_mithril.png",
groups = {armor_legs=20, armor_heal=12, armor_use=50},
wear = 0,
armor_groups = {fleshy=20},
groups = {armor_legs=1, armor_heal=12, armor_use=50},
})
minetest.register_tool("3d_armor:boots_mithril", {
armor:register_armor("3d_armor:boots_mithril", {
description = "Mithril Boots",
inventory_image = "3d_armor_inv_boots_mithril.png",
groups = {armor_feet=15, armor_heal=12, armor_use=50},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_feet=1, armor_heal=12, armor_use=50},
})
end
if armor.materials.crystal then
minetest.register_tool("3d_armor:helmet_crystal", {
armor:register_armor("3d_armor:helmet_crystal", {
description = "Crystal Helmet",
inventory_image = "3d_armor_inv_helmet_crystal.png",
groups = {armor_head=15, armor_heal=12, armor_use=50, armor_fire=1},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_head=1, armor_heal=12, armor_use=50, armor_fire=1},
})
minetest.register_tool("3d_armor:chestplate_crystal", {
armor:register_armor("3d_armor:chestplate_crystal", {
description = "Crystal Chestplate",
inventory_image = "3d_armor_inv_chestplate_crystal.png",
groups = {armor_torso=20, armor_heal=12, armor_use=50, armor_fire=1},
wear = 0,
armor_groups = {fleshy=20},
groups = {armor_torso=1, armor_heal=12, armor_use=50, armor_fire=1},
})
minetest.register_tool("3d_armor:leggings_crystal", {
armor:register_armor("3d_armor:leggings_crystal", {
description = "Crystal Leggings",
inventory_image = "3d_armor_inv_leggings_crystal.png",
groups = {armor_legs=20, armor_heal=12, armor_use=50, armor_fire=1},
wear = 0,
armor_groups = {fleshy=20},
groups = {armor_legs=1, armor_heal=12, armor_use=50, armor_fire=1},
})
minetest.register_tool("3d_armor:boots_crystal", {
armor:register_armor("3d_armor:boots_crystal", {
description = "Crystal Boots",
inventory_image = "3d_armor_inv_boots_crystal.png",
groups = {armor_feet=15, armor_heal=12, armor_use=50, physics_speed=1, physics_jump=0.5, armor_fire=1},
wear = 0,
armor_groups = {fleshy=15},
groups = {armor_feet=1, armor_heal=12, armor_use=50, physics_speed=1,
physics_jump=0.5, armor_fire=1},
})
end

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

View File

@ -37,7 +37,7 @@ unified_inventory.register_page("armor", {
end
if minetest.global_exists("technic") then
formspec = formspec.."label[5.0,"..(fy + 1.5)..
";Radiation: "..armor.def[name].radiation.."]"
";Radiation: "..armor.def[name].groups["radiation"].."]"
end
return {formspec=formspec}
end,