forked from VoxeLibre/VoxeLibre
Simplify mcl_burning API
This commit is contained in:
parent
3d0f5a4de5
commit
5de9d90569
|
@ -107,11 +107,7 @@ function mcl_burning.damage(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
if do_damage then
|
if do_damage then
|
||||||
local damage = mcl_burning.get(obj, "float", "damage")
|
local new_hp = hp - 1
|
||||||
if damage == 0 then
|
|
||||||
damage = 1
|
|
||||||
end
|
|
||||||
local new_hp = hp - damage
|
|
||||||
if health then
|
if health then
|
||||||
luaentity.health = new_hp
|
luaentity.health = new_hp
|
||||||
else
|
else
|
||||||
|
@ -120,7 +116,7 @@ function mcl_burning.damage(obj)
|
||||||
end
|
end
|
||||||
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()
|
local luaentity = obj:get_luaentity()
|
||||||
if luaentity and luaentity.fire_resistant then
|
if luaentity and luaentity.fire_resistant then
|
||||||
return
|
return
|
||||||
|
@ -173,8 +169,6 @@ function mcl_burning.set_on_fire(obj, burn_time, damage, interval, reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mcl_burning.set(obj, "float", "burn_time", burn_time)
|
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, "string", "reason", reason)
|
||||||
mcl_burning.set(obj, "int", "hud_id", hud_id)
|
mcl_burning.set(obj, "int", "hud_id", hud_id)
|
||||||
mcl_burning.set(obj, "int", "sound_id", sound_id)
|
mcl_burning.set(obj, "int", "sound_id", sound_id)
|
||||||
|
@ -208,8 +202,6 @@ function mcl_burning.extinguish(obj)
|
||||||
obj:hud_remove(hud_id)
|
obj:hud_remove(hud_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_burning.set(obj, "float", "damage")
|
|
||||||
mcl_burning.set(obj, "float", "interval")
|
|
||||||
mcl_burning.set(obj, "string", "reason")
|
mcl_burning.set(obj, "string", "reason")
|
||||||
mcl_burning.set(obj, "float", "burn_time")
|
mcl_burning.set(obj, "float", "burn_time")
|
||||||
mcl_burning.set(obj, "float", "damage_timer")
|
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 damage_timer = mcl_burning.get(obj, "float", "damage_timer") + dtime
|
||||||
|
|
||||||
local interval = mcl_burning.get(obj, "float", "interval")
|
if damage_timer >= 1 then
|
||||||
if interval == 0 then
|
|
||||||
interval = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if damage_timer >= interval then
|
|
||||||
damage_timer = 0
|
damage_timer = 0
|
||||||
mcl_burning.damage(obj)
|
mcl_burning.damage(obj)
|
||||||
end
|
end
|
|
@ -5,7 +5,7 @@ mcl_burning = {
|
||||||
animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8
|
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", {
|
minetest.register_entity("mcl_burning:fire", {
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
|
|
|
@ -1059,7 +1059,7 @@ local do_env_damage = function(self)
|
||||||
end
|
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.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
|
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
|
else
|
||||||
deal_light_damage(self, pos, self.sunlight_damage)
|
deal_light_damage(self, pos, self.sunlight_damage)
|
||||||
return true
|
return true
|
||||||
|
@ -2975,8 +2975,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
if weapon then
|
if weapon then
|
||||||
local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect")
|
local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect")
|
||||||
if fire_aspect_level > 0 then
|
if fire_aspect_level > 0 then
|
||||||
local damage = fire_aspect_level * 4 - 1
|
mcl_burning.set_on_fire(self.object, fire_aspect_level * 4)
|
||||||
mcl_burning.set_on_fire(self.object, 4, 1, 4 / damage)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
|
||||||
if rawget(_G, "armor") and armor.last_damage_types then
|
if rawget(_G, "armor") and armor.last_damage_types then
|
||||||
armor.last_damage_types[player:get_player_name()] = "fireball"
|
armor.last_damage_types[player:get_player_name()] = "fireball"
|
||||||
end
|
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, {
|
player:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = 5},
|
damage_groups = {fleshy = 5},
|
||||||
|
@ -99,7 +99,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_mob = function(self, mob)
|
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, {
|
mob:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = 5},
|
damage_groups = {fleshy = 5},
|
||||||
|
|
|
@ -253,7 +253,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
end
|
end
|
||||||
damage_particles(self.object:get_pos(), self._is_critical)
|
damage_particles(self.object:get_pos(), self._is_critical)
|
||||||
if mcl_burning.is_burning(self.object) then
|
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
|
end
|
||||||
obj:punch(self.object, 1.0, {
|
obj:punch(self.object, 1.0, {
|
||||||
full_punch_interval=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
|
if wielditem then
|
||||||
local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect")
|
local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect")
|
||||||
if fire_aspect_level > 0 then
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue