Add crystal armor and fire protection by TenPlus1

This commit is contained in:
stujones11 2015-05-04 17:08:40 +01:00
parent d107708bec
commit 0fc71201b4
23 changed files with 118 additions and 16 deletions

View File

@ -11,6 +11,9 @@ 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.
Configuration
-------------

View File

@ -10,6 +10,20 @@ ARMOR_MATERIALS = {
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},
{"ethereal:crystal_spike", 2, 1},
{"bakedclay:safe_fire", 2, 1},
{"default:torch", 1, 1},
}
-- Increase this if you get initialization glitches when a player first joins.
@ -40,10 +54,3 @@ ARMOR_LEVEL_MULTIPLIER = 1
-- eg: ARMOR_HEAL_MULTIPLIER = 0 will disable healing altogether.
ARMOR_HEAL_MULTIPLIER = 1
-- You can also use this file to execute arbitary lua code
-- eg: Dumb the armor down if using Simple Mobs
if minetest.get_modpath("mobs") then
ARMOR_LEVEL_MULTIPLIER = 0.5
ARMOR_HEAL_MULTIPLIER = 0
end

View File

@ -14,6 +14,16 @@ ARMOR_MATERIALS = {
diamond = "default:diamond",
gold = "default:gold_ingot",
mithril = "moreores:mithril_ingot",
crystal = "ethereal:crystal_ingot",
}
ARMOR_FIRE_PROTECT = minetest.get_modpath("ethereal") ~= nil
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},
}
local skin_mod = nil
@ -36,7 +46,20 @@ 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
-- override hot nodes so they do not hurt player anywhere but mod
if ARMOR_FIRE_PROTECT == true then
minetest.after(2, function()
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)
end
local time = 0
@ -61,6 +84,7 @@ if minetest.get_modpath("inventory_plus") then
.."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;]"
elseif minetest.get_modpath("unified_inventory") then
inv_mod = "unified_inventory"
@ -77,6 +101,7 @@ elseif minetest.get_modpath("unified_inventory") then
.."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.."]"
return {formspec=formspec}
end,
})
@ -121,6 +146,7 @@ armor.set_player_armor = function(self, player)
local armor_texture = "3d_armor_trans.png"
local armor_level = 0
local armor_heal = 0
local armor_fire = 0
local state = 0
local items = 0
local elements = {}
@ -148,6 +174,8 @@ armor.set_player_armor = function(self, player)
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
for kk,vv in ipairs(self.physics) do
local o_value = def.groups["physics_"..vv]
if o_value then
@ -195,15 +223,32 @@ armor.set_player_armor = function(self, player)
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:update_player_visuals(player)
end
armor.update_armor = function(self, player)
local name, player_inv, armor_inv = armor:get_valid_player(player, "[update_armor]")
armor.update_armor = function(self, player, dtime)
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
player:set_hp(hp - row[3] * dtime)
break
end
end
end
end
if hp == 0 or hp == self.player_hp[name] then
return
end
@ -274,7 +319,9 @@ armor.get_armor_formspec = function(self, name)
local formspec = armor.formspec:gsub("player_name", name)
formspec = formspec:gsub("armor_preview", armor.textures[name].preview)
formspec = formspec:gsub("armor_level", armor.def[name].level)
return formspec:gsub("armor_heal", armor.def[name].heal)
formspec = formspec:gsub("armor_heal", armor.def[name].heal)
formspec = formspec:gsub("armor_fire", armor.def[name].fire)
return formspec
end
armor.update_inventory = function(self, player)
@ -348,7 +395,6 @@ default.player_register_model("3d_armor_character.b3d", {
-- Register Callbacks
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = armor:get_valid_player(player, "[on_player_receive_fields]")
if not name or inv_mod == "inventory_enhanced" then
return
@ -373,7 +419,7 @@ minetest.register_on_joinplayer(function(player)
default.player_set_model(player, "3d_armor_character.b3d")
local name = player:get_player_name()
local player_inv = player:get_inventory()
local armor_inv = minetest.create_detached_inventory(name.."_armor",{
local armor_inv = minetest.create_detached_inventory(name.."_armor", {
on_put = function(inv, listname, index, stack, player)
player:get_inventory():set_stack(listname, index, stack)
armor:set_player_armor(player)
@ -429,6 +475,7 @@ minetest.register_on_joinplayer(function(player)
jump = 1,
speed = 1,
gravity = 1,
fire = 0,
}
armor.textures[name] = {
skin = armor.default_skin..".png",
@ -490,7 +537,6 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
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
@ -545,7 +591,7 @@ 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)
armor:update_armor(player, time)
end
time = 0
end

View File

@ -18,6 +18,7 @@ Helmets:
[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:
@ -36,6 +37,7 @@ Chestplates:
[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:
@ -54,6 +56,7 @@ Leggings:
[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:
@ -70,6 +73,7 @@ Boots:
[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 moreores mod by Calinou - https://forum.minetest.net/viewtopic.php?id=549
** Requires ethereal mod by Chinchow & TenPlus1 - https://github.com/tenplus1/ethereal

View File

@ -191,6 +191,33 @@ if ARMOR_MATERIALS.mithril then
})
end
if ARMOR_MATERIALS.crystal then
minetest.register_tool("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,
})
minetest.register_tool("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,
})
minetest.register_tool("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,
})
minetest.register_tool("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,
})
end
for k, v in pairs(ARMOR_MATERIALS) do
minetest.register_craft({
output = "3d_armor:helmet_"..k,

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -15,6 +15,10 @@ Armor takes damage when a player is hurt, however, many armor items offer a 'sta
percentage chance of restoring the lost health points. Overall armor level is boosted by 10%
when wearing a full matching set (helmet, chestplate, leggings and boots of the same material)
Fire protection has been added by TenPlus1 and in use when ethereal mod is found and crystal
armor has been enabled. each piece of armor offers 1 fire protection, level 1 protects
against torches, level 2 against crystal spikes, 3 for fire and 5 protects when in lava.
Compatible with player skins [skins] by Zeg9 and Player Textures [player_textures] by PilzAdam
and [simple_skins] by TenPlus1.

View File

@ -15,6 +15,8 @@ Shields -- Crafting Guide
[shields:shield_bronze] X = [default:bronze_ingot]
[shields:shield_diamond] X = [default:diamond]
[shields:shield_gold] X = [default:gold_ingot]
[shields:shield_mithril] X = [moreores:mithril_ingot]
[shields:shield_crystal] X = [ethereal:crystal_ingot]
Enhanced Shields
----------------

View File

@ -100,6 +100,15 @@ if ARMOR_MATERIALS.mithril then
})
end
if ARMOR_MATERIALS.crystal then
minetest.register_tool("shields:shield_crystal", {
description = "Crystal Shield",
inventory_image = "shields_inv_shield_crystal.png",
groups = {armor_shield=15, armor_heal=12, armor_use=50, armor_fire=1},
wear = 0,
})
end
for k, v in pairs(ARMOR_MATERIALS) do
minetest.register_craft({
output = "shields:shield_"..k,

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB