1
0
Fork 0

Add flame enchantment

objects
HimbeerserverDE 2021-01-27 20:11:02 +01:00
parent 0022c9902b
commit 00df587bf7
4 changed files with 24 additions and 6 deletions

View File

@ -37,15 +37,21 @@ function mcl_burning.is_affected_by_rain(obj)
return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos())
end end
function mcl_burning.get_collisionbox(obj) function mcl_burning.get_collisionbox(obj, smaller)
local box = obj:get_properties().collisionbox local box = obj:get_properties().collisionbox
return vector.new(box[1], box[2], box[3]), vector.new(box[4], box[5], box[6]) local minp, maxp = vector.new(box[1], box[2], box[3]), vector.new(box[4], box[5], box[6])
if smaller then
local s_vec = vector.new(0.1, 0.1, 0.1)
minp = vector.add(minp, s_vec)
maxp = vector.subtract(maxp, s_vec)
end
return minp, maxp
end end
function mcl_burning.get_touching_nodes(obj, nodenames) function mcl_burning.get_touching_nodes(obj, nodenames)
local pos = obj:get_pos() local pos = obj:get_pos()
local box = obj:get_properties().collisionbox local box = obj:get_properties().collisionbox
local minp, maxp = mcl_burning.get_collisionbox(obj) local minp, maxp = mcl_burning.get_collisionbox(obj, true)
local nodes = minetest.find_nodes_in_area(vector.add(pos, minp), vector.add(pos, maxp), nodenames) local nodes = minetest.find_nodes_in_area(vector.add(pos, minp), vector.add(pos, maxp), nodenames)
return nodes return nodes
end end

View File

@ -83,6 +83,7 @@ local ARROW_ENTITY={
textures = {"mcl_bows:arrow_box"}, textures = {"mcl_bows:arrow_box"},
collisionbox = {-0.19, -0.125, -0.19, 0.19, 0.125, 0.19}, collisionbox = {-0.19, -0.125, -0.19, 0.19, 0.125, 0.19},
collide_with_objects = false, collide_with_objects = false,
_fire_damage_resistant = true,
_lastpos={}, _lastpos={},
_startpos=nil, _startpos=nil,
@ -105,6 +106,7 @@ local spawn_item = function(self, pos)
item:set_velocity({x=0, y=0, z=0}) item:set_velocity({x=0, y=0, z=0})
item:set_yaw(self.object:get_yaw()) item:set_yaw(self.object:get_yaw())
end end
mcl_burning.extinguish(self.object)
self.object:remove() self.object:remove()
end end
@ -131,6 +133,8 @@ local damage_particles = function(pos, is_critical)
end end
ARROW_ENTITY.on_step = function(self, dtime) ARROW_ENTITY.on_step = function(self, dtime)
mcl_burning.tick(self.object, dtime)
local pos = self.object:get_pos() local pos = self.object:get_pos()
local dpos = table.copy(pos) -- digital pos local dpos = table.copy(pos) -- digital pos
dpos = vector.round(dpos) dpos = vector.round(dpos)
@ -140,6 +144,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
self._stucktimer = self._stucktimer + dtime self._stucktimer = self._stucktimer + dtime
self._stuckrechecktimer = self._stuckrechecktimer + dtime self._stuckrechecktimer = self._stuckrechecktimer + dtime
if self._stucktimer > ARROW_TIMEOUT then if self._stucktimer > ARROW_TIMEOUT then
mcl_burning.extinguish(self.object)
self.object:remove() self.object:remove()
return return
end end
@ -171,6 +176,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
}, true) }, true)
end end
end end
mcl_burning.extinguish(self.object)
self.object:remove() self.object:remove()
return return
end end
@ -232,6 +238,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
local def = minetest.registered_nodes[nn] local def = minetest.registered_nodes[nn]
if (not def) or def.walkable then if (not def) or def.walkable then
-- There's a node in the way. Delete arrow without damage -- There's a node in the way. Delete arrow without damage
mcl_burning.extinguish(self.object)
self.object:remove() self.object:remove()
return return
end end
@ -244,6 +251,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
armor.last_damage_types[obj:get_player_name()] = "projectile" armor.last_damage_types[obj:get_player_name()] = "projectile"
end end
damage_particles(self.object:get_pos(), self._is_critical) damage_particles(self.object:get_pos(), self._is_critical)
mcl_burning.set_on_fire(obj, 4)
obj:punch(self.object, 1.0, { obj:punch(self.object, 1.0, {
full_punch_interval=1.0, full_punch_interval=1.0,
damage_groups={fleshy=self._damage}, damage_groups={fleshy=self._damage},
@ -271,6 +279,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
end end
minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true) minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true)
end end
mcl_burning.extinguish(self.object)
self.object:remove() self.object:remove()
return return
end end
@ -403,6 +412,7 @@ ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s)
-- If yes, delete it. -- If yes, delete it.
self._stucktimer = minetest.get_gametime() - data.stuckstarttime self._stucktimer = minetest.get_gametime() - data.stuckstarttime
if self._stucktimer > ARROW_TIMEOUT then if self._stucktimer > ARROW_TIMEOUT then
mcl_burning.extinguish(self.object)
self.object:remove() self.object:remove()
return return
end end

View File

@ -50,6 +50,9 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
if enchantments.punch then if enchantments.punch then
knockback = enchantments.punch * 3 knockback = enchantments.punch * 3
end end
if enchantments.flame then
mcl_burning.set_on_fire(obj, math.huge)
end
end end
obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power}) obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power})
obj:set_acceleration({x=0, y=-GRAVITY, z=0}) obj:set_acceleration({x=0, y=-GRAVITY, z=0})

View File

@ -240,8 +240,7 @@ mcl_enchanting.enchantments.fire_protection = {
inv_tool_tab = false, inv_tool_tab = false,
} }
-- requires missing MineClone2 feature mcl_enchanting.enchantments.flame = {
--[[mcl_enchanting.enchantments.flame = {
name = S("Flame"), name = S("Flame"),
max_level = 1, max_level = 1,
primary = {bow = true}, primary = {bow = true},
@ -257,7 +256,7 @@ mcl_enchanting.enchantments.fire_protection = {
power_range_table = {{20, 50}}, power_range_table = {{20, 50}},
inv_combat_tab = true, inv_combat_tab = true,
inv_tool_tab = false, inv_tool_tab = false,
}]]-- }
-- implemented in mcl_item_entity -- implemented in mcl_item_entity
mcl_enchanting.enchantments.fortune = { mcl_enchanting.enchantments.fortune = {