From c9e589b931b6de4bd31f086b8d7da273b9aae430 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 18 Feb 2021 14:47:35 +0100 Subject: [PATCH] Add mcl_burning damage interval --- mods/ENTITIES/mcl_boats/init.lua | 9 ++++++++- mods/ENTITIES/mcl_burning/engine.lua | 11 +++++++++-- mods/ENTITIES/mcl_mobs/api.lua | 3 ++- mods/ENTITIES/mobs_mc/blaze.lua | 4 ++-- mods/ITEMS/mcl_bows/arrow.lua | 2 +- mods/ITEMS/mcl_enchanting/enchantments.lua | 3 ++- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 5f666709c..77708d8dc 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -36,6 +36,7 @@ local paddling_speed = 22 local boat_y_offset = 0.35 local boat_y_offset_ground = boat_y_offset + 0.6 local boat_side_offset = 1.001 +local boat_max_hp = 4 -- -- Boat entity @@ -50,7 +51,7 @@ local boat = { mesh = "mcl_boats_boat.b3d", textures = {"mcl_boats_texture_oak_boat.png"}, visual_size = boat_visual_size, - hp_max = 4, + hp_max = boat_max_hp, _driver = nil, -- Attached driver (player) or nil if none _passenger = nil, @@ -186,6 +187,12 @@ function boat.on_step(self, dtime, moveresult) v_slowdown = 0.05 end + --local yaw = self.object:get_yaw() + --local hp = math.min(self.object:get_hp() + 2 * dtime, boat_max_hp) + --self.object:set_rotation(vector.new((boat_max_hp - hp) / boat_max_hp, 0, 0)) + self.object:set_hp(self.object:get_hp() + 2 * dtime) + --self.object:set_yaw(yaw) + if moveresult and moveresult.collides then for _, collision in ipairs(moveresult.collisions) do local pos = collision.node_pos diff --git a/mods/ENTITIES/mcl_burning/engine.lua b/mods/ENTITIES/mcl_burning/engine.lua index 57890dd2f..5be11a254 100644 --- a/mods/ENTITIES/mcl_burning/engine.lua +++ b/mods/ENTITIES/mcl_burning/engine.lua @@ -120,7 +120,7 @@ function mcl_burning.damage(obj) end end -function mcl_burning.set_on_fire(obj, burn_time, damage, reason) +function mcl_burning.set_on_fire(obj, burn_time, damage, interval, reason) local luaentity = obj:get_luaentity() if luaentity and luaentity.fire_resistant then return @@ -174,6 +174,7 @@ function mcl_burning.set_on_fire(obj, burn_time, damage, reason) end mcl_burning.set(obj, "float", "burn_time", burn_time) mcl_burning.set(obj, "float", "damage", damage) + mcl_burning.set(obj, "float", "interval", interval) mcl_burning.set(obj, "string", "reason", reason) mcl_burning.set(obj, "int", "hud_id", hud_id) mcl_burning.set(obj, "int", "sound_id", sound_id) @@ -208,6 +209,7 @@ function mcl_burning.extinguish(obj) end mcl_burning.set(obj, "float", "damage") + mcl_burning.set(obj, "float", "interval") mcl_burning.set(obj, "string", "reason") mcl_burning.set(obj, "float", "burn_time") mcl_burning.set(obj, "float", "damage_timer") @@ -238,7 +240,12 @@ function mcl_burning.tick(obj, dtime) local damage_timer = mcl_burning.get(obj, "float", "damage_timer") + dtime - if damage_timer >= 1 then + local interval = mcl_burning.get(obj, "float", "interval") + if interval == 0 then + interval = 1 + end + + if damage_timer >= interval then damage_timer = 0 mcl_burning.damage(obj) end diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 24130cb97..460988972 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2975,7 +2975,8 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) if weapon then local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect") if fire_aspect_level > 0 then - mcl_burning.set_on_fire(self.object, 4, fire_aspect_level * 2) + local damage = fire_aspect_level * 4 - 1 + mcl_burning.set_on_fire(self.object, 4, 1, 4 / damage) end end diff --git a/mods/ENTITIES/mobs_mc/blaze.lua b/mods/ENTITIES/mobs_mc/blaze.lua index 00988a903..2b9000de7 100644 --- a/mods/ENTITIES/mobs_mc/blaze.lua +++ b/mods/ENTITIES/mobs_mc/blaze.lua @@ -91,7 +91,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { if rawget(_G, "armor") and armor.last_damage_types then armor.last_damage_types[player:get_player_name()] = "fireball" end - mcl_burning.set_on_fire(player, 5, 1, "blaze") + mcl_burning.set_on_fire(player, 5, 1, 5 / 4, "blaze") player:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 5}, @@ -99,7 +99,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", { end, hit_mob = function(self, mob) - mcl_burning.set_on_fire(mob, 5) + mcl_burning.set_on_fire(mob, 5, 1, 5 / 4) mob:punch(self.object, 1.0, { full_punch_interval = 1.0, damage_groups = {fleshy = 5}, diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 6a02f35c4..ba9158078 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -253,7 +253,7 @@ ARROW_ENTITY.on_step = function(self, dtime) end damage_particles(self.object:get_pos(), self._is_critical) if mcl_burning.is_burning(self.object) then - mcl_burning.set_on_fire(obj, 4) + mcl_burning.set_on_fire(obj, 5, 1, 5 / 4) end obj:punch(self.object, 1.0, { full_punch_interval=1.0, diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index 75969f516..203c403d0 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -215,7 +215,8 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, if wielditem then local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect") if fire_aspect_level > 0 then - mcl_burning.set_on_fire(player, fire_aspect_level * 4 - 1, 1, hitter:get_player_name()) + local damage = fire_aspect_level * 4 - 1 + mcl_burning.set_on_fire(player, 4, 1, 4 / damage, hitter:get_player_name()) end end end