diff --git a/3d_armor/README.txt b/3d_armor/README.txt index 02b9141..6ec80b4 100644 --- a/3d_armor/README.txt +++ b/3d_armor/README.txt @@ -103,7 +103,7 @@ armor:register_armor("mod_name: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}, + 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, @@ -126,7 +126,7 @@ 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 +Durability: armor_use, flammable Notes: @@ -150,7 +150,8 @@ Notes: `on_punch` 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. Return `false` to override armor damage effects. +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: diff --git a/3d_armor/api.lua b/3d_armor/api.lua index 535735f..d4d349d 100644 --- a/3d_armor/api.lua +++ b/3d_armor/api.lua @@ -284,7 +284,7 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili local def = stack:get_definition() or {} if type(def.on_punch) == "function" then damage = def.on_punch(player, hitter, time_from_last_punch, - tool_capabilities) ~= false + tool_capabilities) ~= false and damage == true end if damage == true and tool_capabilities then local damage_groups = def.damage_groups or default_groups @@ -325,6 +325,9 @@ armor.punch = function(self, player, hitter, time_from_last_punch, tool_capabili recip = false end end + if damage == true and hitter == "fire" then + damage = minetest.get_item_group(name, "flammable") > 0 + end if damage == true then local old_stack = ItemStack(stack) stack:add_wear(use) diff --git a/3d_armor/armor.lua b/3d_armor/armor.lua index 4cbd789..9dfb3fb 100644 --- a/3d_armor/armor.lua +++ b/3d_armor/armor.lua @@ -56,21 +56,21 @@ 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}, + 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}, + 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}, + groups = {armor_legs=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}, }) @@ -79,7 +79,7 @@ if armor.materials.wood then 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}, + groups = {armor_feet=1, armor_heal=0, armor_use=2000, flammable=1}, }) end diff --git a/3d_armor/init.lua b/3d_armor/init.lua index e03babf..c04c0e0 100644 --- a/3d_armor/init.lua +++ b/3d_armor/init.lua @@ -300,7 +300,7 @@ minetest.register_on_player_hpchange(function(player, hp_change) hp_change = 0 end end - -- check if armor damage was handled by on_punchplayer + -- 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) @@ -343,6 +343,7 @@ if armor.config.water_protect == true or armor.config.fire_protect == true then 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 @@ -351,6 +352,11 @@ if armor.config.water_protect == true or armor.config.fire_protect == true then 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) diff --git a/shields/init.lua b/shields/init.lua index f03ecce..4239ffe 100644 --- a/shields/init.lua +++ b/shields/init.lua @@ -42,7 +42,7 @@ if armor.materials.wood then armor:register_armor("shields:shield_wood", { description = S("Wooden Shield"), inventory_image = "shields_inv_shield_wood.png", - groups = {armor_shield=1, armor_heal=0, armor_use=2000}, + groups = {armor_shield=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}, reciprocate_damage = true,