Alpha-v0.0.2a #1
|
@ -0,0 +1,26 @@
|
||||||
|
[mod] 3d Armor [3d_armor]
|
||||||
|
=========================
|
||||||
|
|
||||||
|
License Source Code
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Copyright (C) 2012-2019 stujones11, Stuart Jones <stujones111@gmail.com>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
License Textures
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Copyright (C) 2017-2019 davidthecreator - CC-BY-SA 3.0
|
|
@ -0,0 +1,191 @@
|
||||||
|
[mod] Visible Player Armor [3d_armor]
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
Depends: default
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Armor takes damage when a player is hurt but also offers a percentage chance of healing.
|
||||||
|
Overall level is boosted by 10% when wearing a full matching set.
|
||||||
|
|
||||||
|
Fire protection added by TenPlus1 when using crystal armor if Ethereal mod active, level 1
|
||||||
|
protects against torches, level 2 for crystal spike, level 3 for fire, level 5 for lava.
|
||||||
|
|
||||||
|
Armor Configuration
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
Override the following default settings by adding them to your minetest.conf file.
|
||||||
|
|
||||||
|
-- Set false to disable individual armor materials.
|
||||||
|
armor_material_wood = true
|
||||||
|
armor_material_cactus = true
|
||||||
|
armor_material_steel = true
|
||||||
|
armor_material_bronze = true
|
||||||
|
armor_material_diamond = true
|
||||||
|
armor_material_gold = true
|
||||||
|
armor_material_mithril = true
|
||||||
|
armor_material_crystal = true
|
||||||
|
|
||||||
|
-- Increase this if you get initialization glitches when a player first joins.
|
||||||
|
armor_init_delay = 2
|
||||||
|
|
||||||
|
-- Number of initialization attempts.
|
||||||
|
-- Use in conjunction with armor_init_delay if initialization problems persist.
|
||||||
|
armor_init_times = 10
|
||||||
|
|
||||||
|
-- Increase this if armor is not getting into bones due to server lag.
|
||||||
|
armor_bones_delay = 1
|
||||||
|
|
||||||
|
-- How often player armor items are updated.
|
||||||
|
armor_update_time = 1
|
||||||
|
|
||||||
|
-- Drop armor when a player dies.
|
||||||
|
-- Uses bones mod if present, otherwise items are dropped around the player.
|
||||||
|
armor_drop = true
|
||||||
|
|
||||||
|
-- Pulverise armor when a player dies, overrides armor_drop.
|
||||||
|
armor_destroy = false
|
||||||
|
|
||||||
|
-- You can use this to increase or decrease overall armor effectiveness,
|
||||||
|
-- eg: level_multiplier = 0.5 will reduce armor level by half.
|
||||||
|
armor_level_multiplier = 1
|
||||||
|
|
||||||
|
-- You can use this to increase or decrease overall armor healing,
|
||||||
|
-- eg: armor_heal_multiplier = 0 will disable healing altogether.
|
||||||
|
armor_heal_multiplier = 1
|
||||||
|
|
||||||
|
-- Enable water protection (periodically restores breath when activated)
|
||||||
|
armor_water_protect = true
|
||||||
|
|
||||||
|
-- Enable fire protection (defaults true if using ethereal mod)
|
||||||
|
armor_fire_protect = false
|
||||||
|
|
||||||
|
-- Enable punch damage effects.
|
||||||
|
armor_punch_damage = true
|
||||||
|
|
||||||
|
-- Enable migration of old armor inventories
|
||||||
|
armor_migrate_old_inventory = true
|
||||||
|
|
||||||
|
API
|
||||||
|
---
|
||||||
|
|
||||||
|
Armor Registration:
|
||||||
|
|
||||||
|
armor:register_armor(name, def)
|
||||||
|
|
||||||
|
Wrapper function for `minetest.register_tool`, while registering armor as
|
||||||
|
a tool item is still supported, this may be deprecated in future so new code
|
||||||
|
should use this method.
|
||||||
|
|
||||||
|
Additional fields supported by 3d_armor:
|
||||||
|
|
||||||
|
texture = <filename>
|
||||||
|
preview = <filename>
|
||||||
|
armor_groups = <table>
|
||||||
|
damage_groups = <table>
|
||||||
|
reciprocate_damage = <bool>
|
||||||
|
on_equip = <function>
|
||||||
|
on_unequip = <function>
|
||||||
|
on_destroy = <function>
|
||||||
|
on_damage = <function>
|
||||||
|
on_punched = <function>
|
||||||
|
|
||||||
|
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 = "mod_name_speed_boots_inv.png",
|
||||||
|
texture = "mod_name_speed_boots.png",
|
||||||
|
preview = "mod_name_speed_boots_preview.png",
|
||||||
|
groups = {armor_feet=1, armor_use=500, physics_speed=1.2, flammable=1},
|
||||||
|
armor_groups = {fleshy=10, radiation=10},
|
||||||
|
damage_groups = {cracky=3, snappy=3, choppy=3, crumbly=3, level=1},
|
||||||
|
reciprocate_damage = true,
|
||||||
|
on_destroy = function(player, index, stack)
|
||||||
|
local pos = player:get_pos()
|
||||||
|
if pos then
|
||||||
|
minetest.sound_play({
|
||||||
|
name = "mod_name_break_sound",
|
||||||
|
pos = pos,
|
||||||
|
gain = 0.5,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
See armor.lua, technic_armor and shields mods for more examples.
|
||||||
|
|
||||||
|
Default groups:
|
||||||
|
|
||||||
|
Elements: armor_head, armor_torso, armor_legs, armor_feet
|
||||||
|
Attributes: armor_heal, armor_fire, armor_water
|
||||||
|
Physics: physics_jump, physics_speed, physics_gravity
|
||||||
|
Durability: armor_use, flammable
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
Elements may be modified by dependent mods, eg shields adds armor_shield.
|
||||||
|
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.
|
||||||
|
|
||||||
|
Reciprocal tool damage will be done only by the first armor inventory item
|
||||||
|
with `reciprocate_damage = true`
|
||||||
|
|
||||||
|
Armor Functions:
|
||||||
|
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
|
||||||
|
Primarily an internal function but can be called externally to apply any
|
||||||
|
changes that might not otherwise get handled.
|
||||||
|
|
||||||
|
armor:punch(player, hitter, time_from_last_punch, tool_capabilities)
|
||||||
|
|
||||||
|
Used to apply damage to all equipped armor based on the damage groups of
|
||||||
|
each individual item.`hitter`, `time_from_last_punch` and `tool_capabilities`
|
||||||
|
are optional but should be valid if included.
|
||||||
|
|
||||||
|
armor:damage(player, index, stack, use)
|
||||||
|
|
||||||
|
Adds wear to a single armor itemstack, triggers `on_damage` callbacks and
|
||||||
|
updates the necessary inventories. Also handles item destruction callbacks
|
||||||
|
and so should NOT be called from `on_unequip` to avoid an infinite loop.
|
||||||
|
|
||||||
|
Item Callbacks:
|
||||||
|
|
||||||
|
on_equip = func(player, index, stack)
|
||||||
|
on_unequip = func(player, index, stack)
|
||||||
|
on_destroy = func(player, index, stack)
|
||||||
|
on_damage = func(player, index, stack)
|
||||||
|
on_punched = func(player, hitter, time_from_last_punch, tool_capabilities)
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
`on_punched` is called every time a player is punched or takes damage, `hitter`,
|
||||||
|
`time_from_last_punch` and `tool_capabilities` can be `nil` and will be in the
|
||||||
|
case of fall damage, etc. When fire protection is enabled, hitter == "fire"
|
||||||
|
in the event of fire damage. Return `false` to override armor damage effects.
|
||||||
|
When armor is destroyed `stack` will contain a copy of the previous stack.
|
||||||
|
|
||||||
|
Global Callbacks:
|
||||||
|
|
||||||
|
armor:register_on_update(func(player))
|
||||||
|
armor:register_on_equip(func(player, index, stack))
|
||||||
|
armor:register_on_unequip(func(player, index, stack))
|
||||||
|
armor:register_on_destroy(func(player, index, stack))
|
||||||
|
|
||||||
|
Global Callback Example:
|
||||||
|
|
||||||
|
armor:register_on_update(function(player)
|
||||||
|
print(player:get_player_name().." armor updated!")
|
||||||
|
end)
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
-- DEPRECATED, will not be supported in future versions
|
||||||
|
|
||||||
|
-- See README.txt for new configuration options.
|
||||||
|
|
||||||
|
-- Armor Configuration (defaults)
|
||||||
|
|
||||||
|
-- You can remove any unwanted armor materials from this table.
|
||||||
|
-- Note that existing armor that is removed will show up as an unknown item.
|
||||||
|
ARMOR_MATERIALS = {
|
||||||
|
wood = "group:wood",
|
||||||
|
cactus = "default:cactus",
|
||||||
|
steel = "default:steel_ingot",
|
||||||
|
bronze = "default:bronze_ingot",
|
||||||
|
diamond = "default:diamond",
|
||||||
|
gold = "default:gold_ingot",
|
||||||
|
mithril = "moreores:mithril_ingot",
|
||||||
|
crystal = "ethereal:crystal_ingot",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Enable fire protection (defaults true if using ethereal mod)
|
||||||
|
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},
|
||||||
|
{"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.
|
||||||
|
ARMOR_INIT_DELAY = 1
|
||||||
|
|
||||||
|
-- Number of initialization attempts.
|
||||||
|
-- Use in conjunction with ARMOR_INIT_DELAY if initialization problems persist.
|
||||||
|
ARMOR_INIT_TIMES = 1
|
||||||
|
|
||||||
|
-- Increase this if armor is not getting into bones due to server lag.
|
||||||
|
ARMOR_BONES_DELAY = 1
|
||||||
|
|
||||||
|
-- How often player armor/wield items are updated.
|
||||||
|
ARMOR_UPDATE_TIME = 1
|
||||||
|
|
||||||
|
-- Drop armor when a player dies.
|
||||||
|
-- Uses bones mod if present, otherwise items are dropped around the player.
|
||||||
|
ARMOR_DROP = true
|
||||||
|
|
||||||
|
-- Pulverise armor when a player dies, overrides ARMOR_DROP.
|
||||||
|
ARMOR_DESTROY = false
|
||||||
|
|
||||||
|
-- You can use this to increase or decrease overall armor effectiveness,
|
||||||
|
-- eg: ARMOR_LEVEL_MULTIPLIER = 0.5 will reduce armor level by half.
|
||||||
|
ARMOR_LEVEL_MULTIPLIER = 1
|
||||||
|
|
||||||
|
-- You can use this to increase or decrease overall armor healing,
|
||||||
|
-- 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
|
|
@ -0,0 +1,346 @@
|
||||||
|
-- support for i18n
|
||||||
|
local S = armor_i18n.gettext
|
||||||
|
|
||||||
|
armor:register_armor("3d_armor:helmet_admin", {
|
||||||
|
description = S("Admin Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_admin.png",
|
||||||
|
armor_groups = {fleshy=100},
|
||||||
|
groups = {armor_head=1, armor_heal=100, armor_use=0, armor_water=1,
|
||||||
|
not_in_creative_inventory=1},
|
||||||
|
on_drop = function(itemstack, dropper, pos)
|
||||||
|
return
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
armor:register_armor("3d_armor:chestplate_admin", {
|
||||||
|
description = S("Admin Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_admin.png",
|
||||||
|
armor_groups = {fleshy=100},
|
||||||
|
groups = {armor_torso=1, armor_heal=100, armor_use=0,
|
||||||
|
not_in_creative_inventory=1},
|
||||||
|
on_drop = function(itemstack, dropper, pos)
|
||||||
|
return
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
armor:register_armor("3d_armor:leggings_admin", {
|
||||||
|
description = S("Admin Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_admin.png",
|
||||||
|
armor_groups = {fleshy=100},
|
||||||
|
groups = {armor_legs=1, armor_heal=100, armor_use=0,
|
||||||
|
not_in_creative_inventory=1},
|
||||||
|
on_drop = function(itemstack, dropper, pos)
|
||||||
|
return
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
armor:register_armor("3d_armor:boots_admin", {
|
||||||
|
description = S("Admin Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_admin.png",
|
||||||
|
armor_groups = {fleshy=100},
|
||||||
|
groups = {armor_feet=1, armor_heal=100, armor_use=0,
|
||||||
|
not_in_creative_inventory=1},
|
||||||
|
on_drop = function(itemstack, dropper, pos)
|
||||||
|
return
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
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("adminleggings", "3d_armor:leggings_admin")
|
||||||
|
|
||||||
|
if armor.materials.wood then
|
||||||
|
armor:register_armor("3d_armor:helmet_wood", {
|
||||||
|
description = S("Wood Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_wood.png",
|
||||||
|
groups = {armor_head=1, armor_heal=0, armor_use=2000, flammable=1},
|
||||||
|
armor_groups = {fleshy=5},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_wood", {
|
||||||
|
description = S("Wood Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_wood.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=0, armor_use=2000, flammable=1},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_wood", {
|
||||||
|
description = S("Wood Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_wood.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=0, armor_use=2000, flammable=1},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_wood", {
|
||||||
|
description = S("Wood Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_wood.png",
|
||||||
|
armor_groups = {fleshy=5},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1},
|
||||||
|
groups = {armor_feet=1, armor_heal=0, armor_use=2000, flammable=1},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.materials.cactus then
|
||||||
|
armor:register_armor("3d_armor:helmet_cactus", {
|
||||||
|
description = S("Cactus Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_cactus.png",
|
||||||
|
groups = {armor_head=1, armor_heal=0, armor_use=1000},
|
||||||
|
armor_groups = {fleshy=5},
|
||||||
|
damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=1},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_cactus", {
|
||||||
|
description = S("Cactus Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_cactus.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=0, armor_use=1000},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=1},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_cactus", {
|
||||||
|
description = S("Cactus Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_cactus.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=0, armor_use=1000},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=1},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_cactus", {
|
||||||
|
description = S("Cactus Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_cactus.png",
|
||||||
|
groups = {armor_feet=1, armor_heal=0, armor_use=1000},
|
||||||
|
armor_groups = {fleshy=5},
|
||||||
|
damage_groups = {cracky=3, snappy=3, choppy=2, crumbly=2, level=1},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.materials.steel then
|
||||||
|
armor:register_armor("3d_armor:helmet_steel", {
|
||||||
|
description = S("Steel Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_steel.png",
|
||||||
|
groups = {armor_head=1, armor_heal=0, armor_use=800,
|
||||||
|
physics_speed=-0.01, physics_gravity=0.01},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_steel", {
|
||||||
|
description = S("Steel Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_steel.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=0, armor_use=800,
|
||||||
|
physics_speed=-0.04, physics_gravity=0.04},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_steel", {
|
||||||
|
description = S("Steel Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_steel.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=0, armor_use=800,
|
||||||
|
physics_speed=-0.03, physics_gravity=0.03},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_steel", {
|
||||||
|
description = S("Steel Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_steel.png",
|
||||||
|
groups = {armor_feet=1, armor_heal=0, armor_use=800,
|
||||||
|
physics_speed=-0.01, physics_gravity=0.01},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.materials.bronze then
|
||||||
|
armor:register_armor("3d_armor:helmet_bronze", {
|
||||||
|
description = S("Bronze Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_bronze.png",
|
||||||
|
groups = {armor_head=1, armor_heal=6, armor_use=400,
|
||||||
|
physics_speed=-0.01, physics_gravity=0.01},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_bronze", {
|
||||||
|
description = S("Bronze Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_bronze.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=6, armor_use=400,
|
||||||
|
physics_speed=-0.04, physics_gravity=0.04},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_bronze", {
|
||||||
|
description = S("Bronze Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_bronze.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=6, armor_use=400,
|
||||||
|
physics_speed=-0.03, physics_gravity=0.03},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_bronze", {
|
||||||
|
description = S("Bronze Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_bronze.png",
|
||||||
|
groups = {armor_feet=1, armor_heal=6, armor_use=400,
|
||||||
|
physics_speed=-0.01, physics_gravity=0.01},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=3, snappy=2, choppy=2, crumbly=1, level=2},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.materials.diamond then
|
||||||
|
armor:register_armor("3d_armor:helmet_diamond", {
|
||||||
|
description = S("Diamond Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_diamond.png",
|
||||||
|
groups = {armor_head=1, armor_heal=12, armor_use=200},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_diamond", {
|
||||||
|
description = S("Diamond Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_diamond.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=12, armor_use=200},
|
||||||
|
armor_groups = {fleshy=20},
|
||||||
|
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_diamond", {
|
||||||
|
description = S("Diamond Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_diamond.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=12, armor_use=200},
|
||||||
|
armor_groups = {fleshy=20},
|
||||||
|
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_diamond", {
|
||||||
|
description = S("Diamond Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_diamond.png",
|
||||||
|
groups = {armor_feet=1, armor_heal=12, armor_use=200},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.materials.gold then
|
||||||
|
armor:register_armor("3d_armor:helmet_gold", {
|
||||||
|
description = S("Gold Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_gold.png",
|
||||||
|
groups = {armor_head=1, armor_heal=6, armor_use=300,
|
||||||
|
physics_speed=-0.02, physics_gravity=0.02},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=1, snappy=2, choppy=2, crumbly=3, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_gold", {
|
||||||
|
description = S("Gold Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_gold.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=6, armor_use=300,
|
||||||
|
physics_speed=-0.05, physics_gravity=0.05},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=1, snappy=2, choppy=2, crumbly=3, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_gold", {
|
||||||
|
description = S("Gold Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_gold.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=6, armor_use=300,
|
||||||
|
physics_speed=-0.04, physics_gravity=0.04},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=1, snappy=2, choppy=2, crumbly=3, level=2},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_gold", {
|
||||||
|
description = S("Gold Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_gold.png",
|
||||||
|
groups = {armor_feet=1, armor_heal=6, armor_use=300,
|
||||||
|
physics_speed=-0.02, physics_gravity=0.02},
|
||||||
|
armor_groups = {fleshy=10},
|
||||||
|
damage_groups = {cracky=1, snappy=2, choppy=2, crumbly=3, level=2},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.materials.mithril then
|
||||||
|
armor:register_armor("3d_armor:helmet_mithril", {
|
||||||
|
description = S("Mithril Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_mithril.png",
|
||||||
|
groups = {armor_head=1, armor_heal=12, armor_use=100},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_mithril", {
|
||||||
|
description = S("Mithril Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_mithril.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=12, armor_use=100},
|
||||||
|
armor_groups = {fleshy=20},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_mithril", {
|
||||||
|
description = S("Mithril Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_mithril.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=12, armor_use=100},
|
||||||
|
armor_groups = {fleshy=20},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_mithril", {
|
||||||
|
description = S("Mithril Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_mithril.png",
|
||||||
|
groups = {armor_feet=1, armor_heal=12, armor_use=100},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.materials.crystal then
|
||||||
|
armor:register_armor("3d_armor:helmet_crystal", {
|
||||||
|
description = S("Crystal Helmet"),
|
||||||
|
inventory_image = "3d_armor_inv_helmet_crystal.png",
|
||||||
|
groups = {armor_head=1, armor_heal=12, armor_use=100, armor_fire=1},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:chestplate_crystal", {
|
||||||
|
description = S("Crystal Chestplate"),
|
||||||
|
inventory_image = "3d_armor_inv_chestplate_crystal.png",
|
||||||
|
groups = {armor_torso=1, armor_heal=12, armor_use=100, armor_fire=1},
|
||||||
|
armor_groups = {fleshy=20},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:leggings_crystal", {
|
||||||
|
description = S("Crystal Leggings"),
|
||||||
|
inventory_image = "3d_armor_inv_leggings_crystal.png",
|
||||||
|
groups = {armor_legs=1, armor_heal=12, armor_use=100, armor_fire=1},
|
||||||
|
armor_groups = {fleshy=20},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
armor:register_armor("3d_armor:boots_crystal", {
|
||||||
|
description = S("Crystal Boots"),
|
||||||
|
inventory_image = "3d_armor_inv_boots_crystal.png",
|
||||||
|
groups = {armor_feet=1, armor_heal=12, armor_use=100, physics_speed=1,
|
||||||
|
physics_jump=0.5, armor_fire=1},
|
||||||
|
armor_groups = {fleshy=15},
|
||||||
|
damage_groups = {cracky=2, snappy=1, level=3},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
for k, v in pairs(armor.materials) 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:boots_"..k,
|
||||||
|
recipe = {
|
||||||
|
{v, "", v},
|
||||||
|
{v, "", v},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
|
@ -0,0 +1,79 @@
|
||||||
|
3d_armor -- Crafting Guide
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Helmets:
|
||||||
|
|
||||||
|
+---+---+---+
|
||||||
|
| X | X | X |
|
||||||
|
+---+---+---+
|
||||||
|
| X | | X |
|
||||||
|
+---+---+---+
|
||||||
|
| | | |
|
||||||
|
+---+---+---+
|
||||||
|
|
||||||
|
[3d_armor:helmet_wood] X = [default:wood]
|
||||||
|
[3d_armor:helmet_cactus] X = [default:cactus]
|
||||||
|
[3d_armor:helmet_steel] X = [default:steel_ingot]
|
||||||
|
[3d_armor:helmet_bronze] X = [default:bronze_ingot]
|
||||||
|
[3d_armor:helmet_diamond] X = [default:diamond]
|
||||||
|
[3d_armor:helmet_gold] X = [default:gold_ingot]
|
||||||
|
[3d_armor:helmet_mithril] X = [moreores:mithril_ingot] *
|
||||||
|
[3d_armor:helmet_crystal] X = [ethereal:crystal_ingot] **
|
||||||
|
|
||||||
|
Chestplates:
|
||||||
|
|
||||||
|
+---+---+---+
|
||||||
|
| X | | X |
|
||||||
|
+---+---+---+
|
||||||
|
| X | X | X |
|
||||||
|
+---+---+---+
|
||||||
|
| X | X | X |
|
||||||
|
+---+---+---+
|
||||||
|
|
||||||
|
[3d_armor:chestplate_wood] X = [default:wood]
|
||||||
|
[3d_armor:chestplate_cactus] X = [default:cactus]
|
||||||
|
[3d_armor:chestplate_steel] X = [default:steel_ingot]
|
||||||
|
[3d_armor:chestplate_bronze] X = [default:bronze_ingot]
|
||||||
|
[3d_armor:chestplate_diamond] X = [default:diamond]
|
||||||
|
[3d_armor:chestplate_gold] X = [default:gold_ingot]
|
||||||
|
[3d_armor:chestplate_mithril] X = [moreores:mithril_ingot] *
|
||||||
|
[3d_armor:chestplate_crystal] X = [ethereal:crystal_ingot] **
|
||||||
|
|
||||||
|
Leggings:
|
||||||
|
|
||||||
|
+---+---+---+
|
||||||
|
| X | X | X |
|
||||||
|
+---+---+---+
|
||||||
|
| X | | X |
|
||||||
|
+---+---+---+
|
||||||
|
| X | | X |
|
||||||
|
+---+---+---+
|
||||||
|
|
||||||
|
[3d_armor:leggings_wood] X = [default:wood]
|
||||||
|
[3d_armor:leggings_cactus] X = [default:cactus]
|
||||||
|
[3d_armor:leggings_steel] X = [default:steel_ingot]
|
||||||
|
[3d_armor:leggings_bronze] X = [default:bronze_ingot]
|
||||||
|
[3d_armor:leggings_diamond] X = [default:diamond]
|
||||||
|
[3d_armor:leggings_gold] X = [default:gold_ingot]
|
||||||
|
[3d_armor:leggings_mithril] X = [moreores:mithril_ingot] *
|
||||||
|
[3d_armor:leggings_crystal] X = [ethereal:crystal_ingot] **
|
||||||
|
|
||||||
|
Boots:
|
||||||
|
|
||||||
|
+---+---+---+
|
||||||
|
| X | | X |
|
||||||
|
+---+---+---+
|
||||||
|
| X | | X |
|
||||||
|
+---+---+---+
|
||||||
|
|
||||||
|
[3d_armor:boots_wood] X = [default:wood]
|
||||||
|
[3d_armor:boots_cactus] X = [default:cactus]
|
||||||
|
[3d_armor:boots_steel] X = [default:steel_ingot]
|
||||||
|
[3d_armor:boots_bronze] X = [default:bronze_ingot
|
||||||
|
[3d_armor:boots_diamond] X = [default:diamond]
|
||||||
|
[3d_armor:boots_gold] X = [default:gold_ingot]
|
||||||
|
[3d_armor:boots_mithril] X = [moreores:mithril_ingot] *
|
||||||
|
[3d_armor:boots_crystal] X = [ethereal:crystal_ingot] **
|
||||||
|
|
||||||
|
* Requires moreores mod by Calinou - https://forum.minetest.net/viewtopic.php?id=549
|
||||||
|
** Requires ethereal mod by Chinchow & TenPlus1 - https://github.com/tenplus1/ethereal
|
|
@ -0,0 +1,8 @@
|
||||||
|
default
|
||||||
|
player_monoids?
|
||||||
|
armor_monoid?
|
||||||
|
pova?
|
||||||
|
fire?
|
||||||
|
ethereal?
|
||||||
|
bakedclay?
|
||||||
|
intllib?
|
|
@ -0,0 +1 @@
|
||||||
|
Adds craftable armor that is visible to other players.
|
|
@ -0,0 +1,469 @@
|
||||||
|
local modname = minetest.get_current_modname()
|
||||||
|
local modpath = minetest.get_modpath(modname)
|
||||||
|
local worldpath = minetest.get_worldpath()
|
||||||
|
local last_punch_time = {}
|
||||||
|
local pending_players = {}
|
||||||
|
local timer = 0
|
||||||
|
|
||||||
|
-- support for i18n
|
||||||
|
armor_i18n = { }
|
||||||
|
armor_i18n.gettext, armor_i18n.ngettext = dofile(modpath.."/intllib.lua")
|
||||||
|
|
||||||
|
-- local functions
|
||||||
|
local S = armor_i18n.gettext
|
||||||
|
local F = minetest.formspec_escape
|
||||||
|
|
||||||
|
dofile(modpath.."/api.lua")
|
||||||
|
|
||||||
|
-- Legacy Config Support
|
||||||
|
|
||||||
|
local input = io.open(modpath.."/armor.conf", "r")
|
||||||
|
if input then
|
||||||
|
dofile(modpath.."/armor.conf")
|
||||||
|
input:close()
|
||||||
|
input = nil
|
||||||
|
end
|
||||||
|
input = io.open(worldpath.."/armor.conf", "r")
|
||||||
|
if input then
|
||||||
|
dofile(worldpath.."/armor.conf")
|
||||||
|
input:close()
|
||||||
|
input = nil
|
||||||
|
end
|
||||||
|
for name, _ in pairs(armor.config) do
|
||||||
|
local global = "ARMOR_"..name:upper()
|
||||||
|
if minetest.global_exists(global) then
|
||||||
|
armor.config[name] = _G[global]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if minetest.global_exists("ARMOR_MATERIALS") then
|
||||||
|
armor.materials = table.copy(ARMOR_MATERIALS)
|
||||||
|
end
|
||||||
|
if minetest.global_exists("ARMOR_FIRE_NODES") then
|
||||||
|
armor.fire_nodes = table.copy(ARMOR_FIRE_NODES)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Load Configuration
|
||||||
|
|
||||||
|
for name, config in pairs(armor.config) do
|
||||||
|
local setting = minetest.settings:get("armor_"..name)
|
||||||
|
if type(config) == "number" then
|
||||||
|
setting = tonumber(setting)
|
||||||
|
elseif type(config) == "boolean" then
|
||||||
|
setting = minetest.settings:get_bool("armor_"..name)
|
||||||
|
end
|
||||||
|
if setting ~= nil then
|
||||||
|
armor.config[name] = setting
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for material, _ in pairs(armor.materials) do
|
||||||
|
local key = "material_"..material
|
||||||
|
if armor.config[key] == false then
|
||||||
|
armor.materials[material] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Mod Compatibility
|
||||||
|
|
||||||
|
if minetest.get_modpath("technic") then
|
||||||
|
armor.formspec = armor.formspec..
|
||||||
|
"label[5,2.5;"..F(S("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
|
||||||
|
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
|
||||||
|
armor:add_preview(fn)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
armor.skin_mod = mod
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not minetest.get_modpath("moreores") then
|
||||||
|
armor.materials.mithril = nil
|
||||||
|
end
|
||||||
|
if not minetest.get_modpath("ethereal") then
|
||||||
|
armor.materials.crystal = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
dofile(modpath.."/armor.lua")
|
||||||
|
|
||||||
|
-- Armor Initialization
|
||||||
|
|
||||||
|
armor.formspec = armor.formspec..
|
||||||
|
"label[5,1;"..F(S("Level"))..": armor_level]"..
|
||||||
|
"label[5,1.5;"..F(S("Heal"))..": armor_attr_heal]"
|
||||||
|
if armor.config.fire_protect then
|
||||||
|
armor.formspec = armor.formspec.."label[5,2;"..F(S("Fire"))..": armor_attr_fire]"
|
||||||
|
end
|
||||||
|
armor:register_on_destroy(function(player, index, stack)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local def = stack:get_definition()
|
||||||
|
if name and def and def.description then
|
||||||
|
minetest.chat_send_player(name, S("Your @1 got destroyed!", def.description))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function validate_armor_inventory(player)
|
||||||
|
-- Workaround for detached inventory swap exploit
|
||||||
|
local _, inv = armor:get_valid_player(player, "[validate_armor_inventory]")
|
||||||
|
if not inv then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local armor_prev = {}
|
||||||
|
local armor_list_string = player:get_attribute("3d_armor_inventory")
|
||||||
|
if armor_list_string then
|
||||||
|
local armor_list = armor:deserialize_inventory_list(armor_list_string)
|
||||||
|
for i, stack in ipairs(armor_list) do
|
||||||
|
if stack:get_count() > 0 then
|
||||||
|
armor_prev[stack:get_name()] = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local elements = {}
|
||||||
|
local player_inv = player:get_inventory()
|
||||||
|
for i = 1, 6 do
|
||||||
|
local stack = inv:get_stack("armor", i)
|
||||||
|
if stack:get_count() > 0 then
|
||||||
|
local item = stack:get_name()
|
||||||
|
local element = armor:get_element(item)
|
||||||
|
if element and not elements[element] then
|
||||||
|
if armor_prev[item] then
|
||||||
|
armor_prev[item] = nil
|
||||||
|
else
|
||||||
|
-- Item was not in previous inventory
|
||||||
|
armor:run_callbacks("on_equip", player, i, stack)
|
||||||
|
end
|
||||||
|
elements[element] = true;
|
||||||
|
else
|
||||||
|
inv:remove_item("armor", stack)
|
||||||
|
-- The following code returns invalid items to the player's main
|
||||||
|
-- inventory but could open up the possibity for a hacked client
|
||||||
|
-- to receive items back they never really had. I am not certain
|
||||||
|
-- so remove the is_singleplayer check at your own risk :]
|
||||||
|
if minetest.is_singleplayer() and player_inv and
|
||||||
|
player_inv:room_for_item("main", stack) then
|
||||||
|
player_inv:add_item("main", stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for item, i in pairs(armor_prev) do
|
||||||
|
local stack = ItemStack(item)
|
||||||
|
-- Previous item is not in current inventory
|
||||||
|
armor:run_callbacks("on_unequip", player, i, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function init_player_armor(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local pos = player:get_pos()
|
||||||
|
if not name or not pos then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local armor_inv = minetest.create_detached_inventory(name.."_armor", {
|
||||||
|
on_put = function(inv, listname, index, stack, player)
|
||||||
|
validate_armor_inventory(player)
|
||||||
|
armor:save_armor_inventory(player)
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
end,
|
||||||
|
on_take = function(inv, listname, index, stack, player)
|
||||||
|
validate_armor_inventory(player)
|
||||||
|
armor:save_armor_inventory(player)
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
end,
|
||||||
|
on_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
validate_armor_inventory(player)
|
||||||
|
armor:save_armor_inventory(player)
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
end,
|
||||||
|
allow_put = function(inv, listname, index, put_stack, player)
|
||||||
|
local element = armor:get_element(put_stack:get_name())
|
||||||
|
if not element then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
for i = 1, 6 do
|
||||||
|
local stack = inv:get_stack("armor", i)
|
||||||
|
local def = stack:get_definition() or {}
|
||||||
|
if def.groups and def.groups["armor_"..element]
|
||||||
|
and i ~= index then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 1
|
||||||
|
end,
|
||||||
|
allow_take = function(inv, listname, index, stack, player)
|
||||||
|
return stack:get_count()
|
||||||
|
end,
|
||||||
|
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||||
|
return count
|
||||||
|
end,
|
||||||
|
}, name)
|
||||||
|
armor_inv:set_size("armor", 6)
|
||||||
|
if not armor:load_armor_inventory(player) and armor.migrate_old_inventory then
|
||||||
|
local player_inv = player:get_inventory()
|
||||||
|
player_inv:set_size("armor", 6)
|
||||||
|
for i=1, 6 do
|
||||||
|
local stack = player_inv:get_stack("armor", i)
|
||||||
|
armor_inv:set_stack("armor", i, stack)
|
||||||
|
end
|
||||||
|
armor:save_armor_inventory(player)
|
||||||
|
player_inv:set_size("armor", 0)
|
||||||
|
end
|
||||||
|
for i=1, 6 do
|
||||||
|
local stack = armor_inv:get_stack("armor", i)
|
||||||
|
if stack:get_count() > 0 then
|
||||||
|
armor:run_callbacks("on_equip", player, i, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
armor.def[name] = {
|
||||||
|
init_time = minetest.get_gametime(),
|
||||||
|
level = 0,
|
||||||
|
state = 0,
|
||||||
|
count = 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,
|
||||||
|
armor = "3d_armor_trans.png",
|
||||||
|
wielditem = "3d_armor_trans.png",
|
||||||
|
preview = armor.default_skin.."_preview.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
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Armor Player Model
|
||||||
|
|
||||||
|
default.player_register_model("3d_armor_character.b3d", {
|
||||||
|
animation_speed = 30,
|
||||||
|
textures = {
|
||||||
|
armor.default_skin..".png",
|
||||||
|
"3d_armor_trans.png",
|
||||||
|
"3d_armor_trans.png",
|
||||||
|
},
|
||||||
|
animations = {
|
||||||
|
stand = {x=0, y=79},
|
||||||
|
lay = {x=162, y=166},
|
||||||
|
walk = {x=168, y=187},
|
||||||
|
mine = {x=189, y=198},
|
||||||
|
walk_mine = {x=200, y=219},
|
||||||
|
sit = {x=81, y=160},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
local name = armor:get_valid_player(player, "[on_player_receive_fields]")
|
||||||
|
if not name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for field, _ in pairs(fields) do
|
||||||
|
if string.find(field, "skins_set") then
|
||||||
|
minetest.after(0, function(player)
|
||||||
|
local skin = armor:get_player_skin(name)
|
||||||
|
armor.textures[name].skin = skin
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
end, player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
default.player_set_model(player, "3d_armor_character.b3d")
|
||||||
|
minetest.after(0, function(player)
|
||||||
|
if init_player_armor(player) == false then
|
||||||
|
pending_players[player] = 0
|
||||||
|
end
|
||||||
|
end, player)
|
||||||
|
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
|
||||||
|
pending_players[player] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
if armor.config.drop == true or armor.config.destroy == true then
|
||||||
|
minetest.register_on_dieplayer(function(player)
|
||||||
|
local name, armor_inv = armor:get_valid_player(player, "[on_dieplayer]")
|
||||||
|
if not name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local drop = {}
|
||||||
|
for i=1, armor_inv:get_size("armor") do
|
||||||
|
local stack = armor_inv:get_stack("armor", i)
|
||||||
|
if stack:get_count() > 0 then
|
||||||
|
table.insert(drop, stack)
|
||||||
|
armor:run_callbacks("on_unequip", player, i, stack)
|
||||||
|
armor_inv:set_stack("armor", i, nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
armor:save_armor_inventory(player)
|
||||||
|
armor:set_player_armor(player)
|
||||||
|
local pos = player:get_pos()
|
||||||
|
if pos and armor.config.destroy == false then
|
||||||
|
minetest.after(armor.config.bones_delay, function()
|
||||||
|
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
|
||||||
|
for _,stack in ipairs(drop) do
|
||||||
|
armor.drop_armor(pos, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.config.punch_damage == true then
|
||||||
|
minetest.register_on_punchplayer(function(player, hitter,
|
||||||
|
time_from_last_punch, tool_capabilities)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if name then
|
||||||
|
armor:punch(player, hitter, time_from_last_punch, tool_capabilities)
|
||||||
|
last_punch_time[name] = minetest.get_gametime()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_player_hpchange(function(player, hp_change)
|
||||||
|
if player and hp_change < 0 then
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if name then
|
||||||
|
local heal = armor.def[name].heal
|
||||||
|
if heal >= math.random(100) then
|
||||||
|
hp_change = 0
|
||||||
|
end
|
||||||
|
-- check if armor damage was handled by fire or on_punchplayer
|
||||||
|
local time = last_punch_time[name] or 0
|
||||||
|
if time == 0 or time + 1 < minetest.get_gametime() then
|
||||||
|
armor:punch(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return hp_change
|
||||||
|
end, true)
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
timer = timer + dtime
|
||||||
|
if timer > armor.config.init_delay then
|
||||||
|
for player, count in pairs(pending_players) do
|
||||||
|
local remove = init_player_armor(player) == true
|
||||||
|
pending_players[player] = count + 1
|
||||||
|
if remove == false and count > armor.config.init_times then
|
||||||
|
minetest.log("warning", S("3d_armor: Failed to initialize player"))
|
||||||
|
remove = true
|
||||||
|
end
|
||||||
|
if remove == true then
|
||||||
|
pending_players[player] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
timer = 0
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Fire Protection and water breating, added by TenPlus1
|
||||||
|
|
||||||
|
if armor.config.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 (S("[3d_armor] Fire Nodes disabled"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if armor.config.water_protect == true or armor.config.fire_protect == true then
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
armor.timer = armor.timer + dtime
|
||||||
|
if armor.timer < armor.config.update_time then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local pos = player:get_pos()
|
||||||
|
local hp = player:get_hp()
|
||||||
|
if not name or not pos or not hp then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- water breathing
|
||||||
|
if armor.config.water_protect == true then
|
||||||
|
if armor.def[name].water > 0 and
|
||||||
|
player:get_breath() < 10 then
|
||||||
|
player:set_breath(10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- fire protection
|
||||||
|
if armor.config.fire_protect == true then
|
||||||
|
local fire_damage = true
|
||||||
|
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 fire_damage == true then
|
||||||
|
armor:punch(player, "fire")
|
||||||
|
last_punch_time[name] = minetest.get_gametime()
|
||||||
|
fire_damage = false
|
||||||
|
end
|
||||||
|
if hp > 0 and armor.def[name].fire < row[2] then
|
||||||
|
hp = hp - row[3] * armor.config.update_time
|
||||||
|
player:set_hp(hp)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
armor.timer = 0
|
||||||
|
end)
|
||||||
|
end
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
-- Fallback functions for when `intllib` is not installed.
|
||||||
|
-- Code released under Unlicense <http://unlicense.org>.
|
||||||
|
|
||||||
|
-- Get the latest version of this file at:
|
||||||
|
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
|
||||||
|
|
||||||
|
local function format(str, ...)
|
||||||
|
local args = { ... }
|
||||||
|
local function repl(escape, open, num, close)
|
||||||
|
if escape == "" then
|
||||||
|
local replacement = tostring(args[tonumber(num)])
|
||||||
|
if open == "" then
|
||||||
|
replacement = replacement..close
|
||||||
|
end
|
||||||
|
return replacement
|
||||||
|
else
|
||||||
|
return "@"..open..num..close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
|
||||||
|
end
|
||||||
|
|
||||||
|
local gettext, ngettext
|
||||||
|
if minetest.get_modpath("intllib") then
|
||||||
|
if intllib.make_gettext_pair then
|
||||||
|
-- New method using gettext.
|
||||||
|
gettext, ngettext = intllib.make_gettext_pair()
|
||||||
|
else
|
||||||
|
-- Old method using text files.
|
||||||
|
gettext = intllib.Getter()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fill in missing functions.
|
||||||
|
|
||||||
|
gettext = gettext or function(msgid, ...)
|
||||||
|
return format(msgid, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
|
||||||
|
return format(n==1 and msgid or msgid_plural, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return gettext, ngettext
|
Loading…
Reference in New Issue