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())
end
function mcl_burning.get_collisionbox(obj)
function mcl_burning.get_collisionbox(obj, smaller)
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
function mcl_burning.get_touching_nodes(obj, nodenames)
local pos = obj:get_pos()
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)
return nodes
end

View File

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

View File

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

View File

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