2023-10-30 23:42:11 +01:00
|
|
|
-- true = blocks all damage
|
|
|
|
-- {base_block, block_per_rm}: Amount blocked by full dark matter, extra amount per red matter armor piece
|
2023-08-07 22:56:29 +02:00
|
|
|
local blocked_damage_types = {
|
|
|
|
drown = true,
|
|
|
|
lava = true,
|
|
|
|
in_fire = true,
|
|
|
|
on_fire = true,
|
|
|
|
hot_floor = true,
|
2023-10-30 23:42:11 +01:00
|
|
|
fall = {0.9, 0.0125},
|
2023-08-07 22:56:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local function get_armor_texture(type, matter, preview)
|
2023-10-04 02:08:07 +02:00
|
|
|
local modifier
|
2023-08-07 22:56:29 +02:00
|
|
|
-- hsl only works in 5.8 which hasn't been released yet
|
|
|
|
if matter == "dark" then
|
|
|
|
modifier = "^[multiply:#222222"
|
|
|
|
--modifier = "^[hsl:0:-100:-100^[hsl:0:-100:-100"
|
|
|
|
else
|
|
|
|
modifier = "^[multiply:#990000"
|
|
|
|
--modifier = "^[hsl:-180:100:-100"
|
|
|
|
end
|
|
|
|
local result
|
2023-09-29 01:23:49 +02:00
|
|
|
if exchangeclone.mcl then
|
2023-08-07 22:56:29 +02:00
|
|
|
result = "exchangeclone_mcl_"..type.."_base.png"..modifier
|
|
|
|
else
|
|
|
|
result = "exchangeclone_mtg_"..type.."_base"
|
|
|
|
if preview then result = result.."_preview" end
|
|
|
|
result = result..".png"..modifier
|
|
|
|
end
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
|
2023-10-30 23:42:11 +01:00
|
|
|
-- Reset health
|
2023-08-07 22:56:29 +02:00
|
|
|
function exchangeclone.check_armor_health(obj)
|
2023-10-30 23:42:11 +01:00
|
|
|
if obj:get_meta():get_int("exchangeclone_red_matter_armor") == 1 then
|
|
|
|
obj:set_hp(math.min(obj:get_hp(), 20))
|
|
|
|
obj:set_properties({hp_max = 20})
|
|
|
|
obj:get_meta():set_int("exchangeclone_red_matter_armor", 0)
|
2023-08-07 22:56:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_joinplayer(function(ObjectRef, last_login)
|
|
|
|
exchangeclone.check_armor_health(ObjectRef)
|
|
|
|
end)
|
|
|
|
|
2023-09-29 01:23:49 +02:00
|
|
|
if exchangeclone.mcl then
|
2023-08-07 22:56:29 +02:00
|
|
|
mcl_armor.register_set({
|
|
|
|
name = "dark_matter",
|
|
|
|
description = "Dark Matter",
|
2023-10-04 02:08:07 +02:00
|
|
|
descriptions = exchangeclone.mineclonia and {
|
2023-09-29 01:23:49 +02:00
|
|
|
head = "Dark Matter Helmet",
|
|
|
|
torso = "Dark Matter Chestplate",
|
|
|
|
legs = "Dark Matter Leggings",
|
|
|
|
feet = "Dark Matter Boots"
|
|
|
|
},
|
2023-08-07 22:56:29 +02:00
|
|
|
durability = -1,
|
|
|
|
enchantability = 0,
|
|
|
|
points = {
|
2023-10-30 23:42:11 +01:00
|
|
|
head = 6,
|
|
|
|
torso = 10,
|
|
|
|
legs = 8,
|
2023-08-07 22:56:29 +02:00
|
|
|
feet = 4,
|
|
|
|
},
|
|
|
|
textures = {
|
|
|
|
head = get_armor_texture("helmet","dark"),
|
|
|
|
torso = get_armor_texture("chestplate","dark"),
|
|
|
|
legs = get_armor_texture("leggings","dark"),
|
|
|
|
feet = get_armor_texture("boots","dark"),
|
|
|
|
},
|
|
|
|
toughness = 4,
|
2023-10-07 17:26:21 +02:00
|
|
|
groups = {dark_matter_armor = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
2023-08-07 22:56:29 +02:00
|
|
|
craft_material = "exchangeclone:dark_matter",
|
|
|
|
cook_material = "mcl_core:diamondblock",
|
|
|
|
})
|
|
|
|
mcl_armor.register_set({
|
|
|
|
name = "red_matter",
|
|
|
|
description = "Red Matter",
|
2023-10-04 02:08:07 +02:00
|
|
|
descriptions = exchangeclone.mineclonia and {
|
2023-09-29 01:23:49 +02:00
|
|
|
head = "Red Matter Helmet",
|
|
|
|
torso = "Red Matter Chestplate",
|
|
|
|
legs = "Red Matter Leggings",
|
|
|
|
feet = "Red Matter Boots"
|
|
|
|
},
|
2023-08-07 22:56:29 +02:00
|
|
|
durability = -1,
|
|
|
|
enchantability = 0,
|
|
|
|
points = {
|
|
|
|
head = 7,
|
|
|
|
torso = 12,
|
2023-10-30 23:42:11 +01:00
|
|
|
legs = 9,
|
2023-08-07 22:56:29 +02:00
|
|
|
feet = 5,
|
|
|
|
},
|
|
|
|
textures = {
|
|
|
|
head = get_armor_texture("helmet","red"),
|
|
|
|
torso = get_armor_texture("chestplate","red"),
|
|
|
|
legs = get_armor_texture("leggings","red"),
|
|
|
|
feet = get_armor_texture("boots","red"),
|
|
|
|
},
|
|
|
|
toughness = 5,
|
2023-10-07 17:26:21 +02:00
|
|
|
groups = {red_matter_armor = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
2023-08-07 22:56:29 +02:00
|
|
|
craft_material = "exchangeclone:red_matter",
|
|
|
|
cook_material = "exchangeclone:dark_matter",
|
|
|
|
})
|
|
|
|
|
|
|
|
for _, matter in ipairs({"dark", "red"}) do
|
|
|
|
for _, type in ipairs({"helmet", "chestplate", "leggings", "boots"}) do
|
|
|
|
minetest.override_item("exchangeclone:"..type.."_"..matter.."_matter", {
|
|
|
|
inventory_image = get_armor_texture("inv_"..type, matter),
|
|
|
|
wield_image = get_armor_texture("inv_"..type, matter),
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
mcl_damage.register_modifier(function(obj, damage, reason)
|
2023-10-30 23:42:11 +01:00
|
|
|
local blocked = blocked_damage_types[reason.type]
|
2023-08-07 22:56:29 +02:00
|
|
|
local inv = mcl_util.get_inventory(obj)
|
|
|
|
if inv then
|
|
|
|
local armor_pieces = 0
|
2023-10-30 23:42:11 +01:00
|
|
|
local red_armor_pieces = 0
|
2023-08-07 22:56:29 +02:00
|
|
|
for name, element in pairs(mcl_armor.elements) do
|
|
|
|
local itemstack = inv:get_stack("armor", element.index)
|
|
|
|
if not itemstack:is_empty() then
|
2023-10-30 23:42:11 +01:00
|
|
|
if minetest.get_item_group(itemstack:get_name(), "dark_matter_armor") > 0 then
|
2023-08-07 22:56:29 +02:00
|
|
|
armor_pieces = armor_pieces + 1
|
2023-10-30 23:42:11 +01:00
|
|
|
elseif minetest.get_item_group(itemstack:get_name(), "red_matter_armor") > 0 then
|
|
|
|
armor_pieces = armor_pieces + 1
|
|
|
|
red_armor_pieces = red_armor_pieces + 1
|
2023-08-07 22:56:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if armor_pieces >= 4 then
|
2023-10-30 23:42:11 +01:00
|
|
|
if blocked then
|
|
|
|
if blocked == true then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return (blocked[1] + blocked[2]*red_armor_pieces) * damage
|
|
|
|
end
|
2023-10-08 23:12:25 +02:00
|
|
|
end
|
2023-08-07 22:56:29 +02:00
|
|
|
end
|
|
|
|
end
|
2023-10-30 23:42:11 +01:00
|
|
|
end)
|
2023-08-07 22:56:29 +02:00
|
|
|
else
|
|
|
|
armor:register_armor("exchangeclone:helmet_dark_matter", {
|
|
|
|
description = "Dark Matter Helmet",
|
|
|
|
texture = get_armor_texture("helmet","dark"),
|
|
|
|
inventory_image = get_armor_texture("inv_helmet","dark"),
|
|
|
|
preview = get_armor_texture("helmet","dark", true),
|
|
|
|
armor_groups = {fleshy = 13},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_head = 1, dark_matter_armor = 1, armor_heal = 5, armor_fire = 1, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:chestplate_dark_matter", {
|
|
|
|
description = "Dark Matter Chestplate",
|
|
|
|
texture = get_armor_texture("chestplate","dark"),
|
|
|
|
inventory_image = get_armor_texture("inv_chestplate","dark"),
|
|
|
|
preview = get_armor_texture("chestplate","dark", true),
|
|
|
|
armor_groups = {fleshy = 21},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_torso = 1, dark_matter_armor = 1, armor_heal = 8, armor_fire = 2, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:leggings_dark_matter", {
|
|
|
|
description = "Dark Matter Leggings",
|
|
|
|
texture = get_armor_texture("leggings","dark"),
|
|
|
|
inventory_image = get_armor_texture("inv_leggings","dark"),
|
|
|
|
preview = get_armor_texture("leggings","dark", true),
|
|
|
|
armor_groups = {fleshy = 18},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_legs = 1, dark_matter_armor = 1, armor_heal = 7, armor_fire = 1, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:boots_dark_matter", {
|
|
|
|
description = "Dark Matter Boots",
|
|
|
|
texture = get_armor_texture("boots","dark"),
|
|
|
|
inventory_image = get_armor_texture("inv_boots","dark"),
|
|
|
|
preview = get_armor_texture("boots","dark", true),
|
|
|
|
armor_groups = {fleshy = 10},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_feet = 1, dark_matter_armor = 1, armor_heal = 4, armor_fire = 1, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:shield_dark_matter", {
|
|
|
|
description = "Dark Matter Shield",
|
|
|
|
texture = get_armor_texture("shield","dark"),
|
|
|
|
inventory_image = get_armor_texture("inv_shield","dark"),
|
|
|
|
preview = get_armor_texture("shield","dark", true),
|
|
|
|
armor_groups = {fleshy = 18},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_shield = 1, dark_matter_armor = 1, armor_heal = 7, armor_fire = 1, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:helmet_red_matter", {
|
|
|
|
description = "Red Matter Helmet",
|
|
|
|
texture = get_armor_texture("helmet","red"),
|
|
|
|
inventory_image = get_armor_texture("inv_helmet","red"),
|
|
|
|
preview = get_armor_texture("helmet","red", true),
|
|
|
|
armor_groups = {fleshy = 15},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_head = 1, red_matter_armor = 1, armor_heal = 10, armor_fire = 2, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:chestplate_red_matter", {
|
|
|
|
description = "Red Matter Chestplate",
|
|
|
|
texture = get_armor_texture("chestplate","red"),
|
|
|
|
inventory_image = get_armor_texture("inv_chestplate","red"),
|
|
|
|
preview = get_armor_texture("chestplate","red", true),
|
|
|
|
armor_groups = {fleshy = 23},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_torso = 1, red_matter_armor = 1, armor_heal = 16, armor_fire = 2, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:leggings_red_matter", {
|
|
|
|
description = "Red Matter Leggings",
|
|
|
|
texture = get_armor_texture("leggings","red"),
|
2023-09-25 16:41:23 +02:00
|
|
|
inventory_image = get_armor_texture("inv_leggings","red"),
|
2023-08-07 22:56:29 +02:00
|
|
|
preview = get_armor_texture("leggings","red", true),
|
|
|
|
armor_groups = {fleshy = 20},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_legs = 1, red_matter_armor = 1, armor_heal = 14, armor_fire = 2, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:boots_red_matter", {
|
|
|
|
description = "Red Matter Boots",
|
|
|
|
texture = get_armor_texture("boots","red"),
|
2023-09-25 16:41:23 +02:00
|
|
|
inventory_image = get_armor_texture("inv_boots","red"),
|
2023-08-07 22:56:29 +02:00
|
|
|
preview = get_armor_texture("boots","red", true),
|
|
|
|
armor_groups = {fleshy = 12},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_feet = 1, red_matter_armor = 1, armor_heal = 8, armor_fire = 2, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
armor:register_armor("exchangeclone:shield_red_matter", {
|
|
|
|
description = "Red Matter Shield",
|
|
|
|
texture = get_armor_texture("shield","red"),
|
2023-09-25 16:41:23 +02:00
|
|
|
inventory_image = get_armor_texture("inv_shield","red"),
|
2023-08-07 22:56:29 +02:00
|
|
|
preview = get_armor_texture("shield","red", true),
|
|
|
|
armor_groups = {fleshy = 20},
|
2023-10-30 23:42:11 +01:00
|
|
|
groups = {armor_shield = 1, red_matter_armor = 1, armor_heal = 14, armor_fire = 2, armor_water = 1, disable_repair = 1, exchangeclone_upgradable = 1}
|
2023-08-07 22:56:29 +02:00
|
|
|
})
|
|
|
|
end
|
|
|
|
local d = "exchangeclone:dark_matter"
|
|
|
|
local r = "exchangeclone:red_matter"
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:helmet_dark_matter",
|
|
|
|
recipe = {
|
|
|
|
{d,d,d},
|
|
|
|
{d,"",d}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:chestplate_dark_matter",
|
|
|
|
recipe = {
|
|
|
|
{d,"",d},
|
|
|
|
{d,d,d},
|
|
|
|
{d,d,d},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:leggings_dark_matter",
|
|
|
|
recipe = {
|
|
|
|
{d,d,d},
|
|
|
|
{d,"",d},
|
|
|
|
{d,"",d},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:boots_dark_matter",
|
|
|
|
recipe = {
|
|
|
|
{d,"",d},
|
|
|
|
{d,"",d},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:helmet_red_matter",
|
|
|
|
recipe = {
|
|
|
|
{r,r,r},
|
|
|
|
{r,"exchangeclone:helmet_dark_matter",r}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:chestplate_red_matter",
|
|
|
|
recipe = {
|
|
|
|
{r,"exchangeclone:chestplate_dark_matter",r},
|
|
|
|
{r,r,r},
|
|
|
|
{r,r,r},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:leggings_red_matter",
|
|
|
|
recipe = {
|
|
|
|
{r,r,r},
|
|
|
|
{r,"exchangeclone:leggings_dark_matter",r},
|
|
|
|
{r,"",r},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:boots_red_matter",
|
|
|
|
recipe = {
|
|
|
|
{r,"exchangeclone:boots_dark_matter",r},
|
|
|
|
{r,"",r},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if minetest.get_modpath("3d_armor") then
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:shield_dark_matter",
|
|
|
|
recipe = {
|
|
|
|
{d,d,d},
|
|
|
|
{d,d,d},
|
|
|
|
{"",d,""},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:shield_red_matter",
|
|
|
|
recipe = {
|
2023-11-13 02:30:16 +01:00
|
|
|
{r,r,r},
|
|
|
|
{r,r,r},
|
|
|
|
{"exchangeclone:shield_dark_matter",r,""},
|
2023-08-07 22:56:29 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|