forked from Mineclonia/Mineclonia
Simplify mcl_burning API
This commit is contained in:
parent
3d0f5a4de5
commit
5de9d90569
|
@ -107,11 +107,7 @@ function mcl_burning.damage(obj)
|
|||
end
|
||||
|
||||
if do_damage then
|
||||
local damage = mcl_burning.get(obj, "float", "damage")
|
||||
if damage == 0 then
|
||||
damage = 1
|
||||
end
|
||||
local new_hp = hp - damage
|
||||
local new_hp = hp - 1
|
||||
if health then
|
||||
luaentity.health = new_hp
|
||||
else
|
||||
|
@ -120,7 +116,7 @@ function mcl_burning.damage(obj)
|
|||
end
|
||||
end
|
||||
|
||||
function mcl_burning.set_on_fire(obj, burn_time, damage, interval, reason)
|
||||
function mcl_burning.set_on_fire(obj, burn_time, reason)
|
||||
local luaentity = obj:get_luaentity()
|
||||
if luaentity and luaentity.fire_resistant then
|
||||
return
|
||||
|
@ -173,8 +169,6 @@ function mcl_burning.set_on_fire(obj, burn_time, damage, interval, reason)
|
|||
end
|
||||
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,8 +202,6 @@ function mcl_burning.extinguish(obj)
|
|||
obj:hud_remove(hud_id)
|
||||
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")
|
||||
|
@ -240,12 +232,7 @@ function mcl_burning.tick(obj, dtime)
|
|||
|
||||
local damage_timer = mcl_burning.get(obj, "float", "damage_timer") + dtime
|
||||
|
||||
local interval = mcl_burning.get(obj, "float", "interval")
|
||||
if interval == 0 then
|
||||
interval = 1
|
||||
end
|
||||
|
||||
if damage_timer >= interval then
|
||||
if damage_timer >= 1 then
|
||||
damage_timer = 0
|
||||
mcl_burning.damage(obj)
|
||||
end
|
|
@ -5,7 +5,7 @@ mcl_burning = {
|
|||
animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8
|
||||
}
|
||||
|
||||
dofile(modpath .. "/engine.lua")
|
||||
dofile(modpath .. "/api.lua")
|
||||
|
||||
minetest.register_entity("mcl_burning:fire", {
|
||||
initial_properties = {
|
||||
|
@ -33,4 +33,4 @@ end)
|
|||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
mcl_burning.set(player, "int", "hud_id")
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -1059,7 +1059,7 @@ local do_env_damage = function(self)
|
|||
end
|
||||
if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (minetest.get_node_light(pos) or 0) >= minetest.LIGHT_MAX and dim == "overworld" then
|
||||
if self.ignited_by_sunlight then
|
||||
mcl_burning.set_on_fire(self.object, 10, self.sunlight_damage or 1)
|
||||
mcl_burning.set_on_fire(self.object, 10)
|
||||
else
|
||||
deal_light_damage(self, pos, self.sunlight_damage)
|
||||
return true
|
||||
|
@ -2975,8 +2975,7 @@ 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
|
||||
local damage = fire_aspect_level * 4 - 1
|
||||
mcl_burning.set_on_fire(self.object, 4, 1, 4 / damage)
|
||||
mcl_burning.set_on_fire(self.object, fire_aspect_level * 4)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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, 5 / 4, "blaze")
|
||||
mcl_burning.set_on_fire(player, 5, "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, 1, 5 / 4)
|
||||
mcl_burning.set_on_fire(mob, 5)
|
||||
mob:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = 5},
|
||||
|
|
|
@ -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, 5, 1, 5 / 4)
|
||||
mcl_burning.set_on_fire(obj, 5)
|
||||
end
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
|
|
|
@ -215,7 +215,7 @@ 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())
|
||||
mcl_burning.set_on_fire(player, fire_aspect_level * 4, hitter:get_player_name())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue