Punch
parent
86b2cd70f9
commit
494ffb41d3
|
@ -174,7 +174,7 @@ mcl_enchanting.enchantments.fire_protection = {
|
||||||
requires_tool = false,
|
requires_tool = false,
|
||||||
}]]--
|
}]]--
|
||||||
|
|
||||||
-- unimplemented
|
-- implemented in mcl_item_entity
|
||||||
mcl_enchanting.enchantments.fortune = {
|
mcl_enchanting.enchantments.fortune = {
|
||||||
name = "Fortune",
|
name = "Fortune",
|
||||||
max_level = 4,
|
max_level = 4,
|
||||||
|
@ -254,9 +254,15 @@ mcl_enchanting.enchantments.knockback = {
|
||||||
local old_calculate_knockback = minetest.calculate_knockback
|
local old_calculate_knockback = minetest.calculate_knockback
|
||||||
function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool_capabilities, dir, distance, damage)
|
function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool_capabilities, dir, distance, damage)
|
||||||
local knockback = old_calculate_knockback(player, hitter, time_from_last_punch, tool_capabilities, dir, distance, damage)
|
local knockback = old_calculate_knockback(player, hitter, time_from_last_punch, tool_capabilities, dir, distance, damage)
|
||||||
|
local luaentity
|
||||||
|
if hitter then
|
||||||
|
luaentity = hitter:get_luaentity()
|
||||||
|
end
|
||||||
if hitter and hitter:is_player() then
|
if hitter and hitter:is_player() then
|
||||||
local wielditem = hitter:get_wielded_item()
|
local wielditem = hitter:get_wielded_item()
|
||||||
knockback = knockback + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
|
knockback = knockback + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
|
||||||
|
elseif luaentity and luaentity._knockback then
|
||||||
|
knockback = knockback + luaentity._knockback
|
||||||
end
|
end
|
||||||
return knockback
|
return knockback
|
||||||
end
|
end
|
||||||
|
@ -366,7 +372,7 @@ mcl_enchanting.enchantments.protection = {
|
||||||
requires_tool = false,
|
requires_tool = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- unimplemented
|
-- implemented via minetest.calculate_knockback (together with the Knockback enchantment) and mcl_bows
|
||||||
mcl_enchanting.enchantments.punch = {
|
mcl_enchanting.enchantments.punch = {
|
||||||
name = "Punch",
|
name = "Punch",
|
||||||
max_level = 2,
|
max_level = 2,
|
||||||
|
|
|
@ -239,16 +239,9 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Punch target object but avoid hurting enderman.
|
-- Punch target object but avoid hurting enderman.
|
||||||
if lua then
|
if not lua or lua.name ~= "mobs_mc:enderman" then
|
||||||
if lua.name ~= "mobs_mc:enderman" then
|
|
||||||
damage_particles(self.object:get_pos(), self._is_critical)
|
|
||||||
obj:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval=1.0,
|
|
||||||
damage_groups={fleshy=self._damage},
|
|
||||||
}, nil)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
damage_particles(self.object:get_pos(), self._is_critical)
|
damage_particles(self.object:get_pos(), self._is_critical)
|
||||||
|
self.object:set_pos(vector.subtract(obj:get_pos(), vector.multiply(vector.normalize(self.object:get_velocity()), 2)))
|
||||||
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},
|
||||||
|
|
|
@ -41,10 +41,14 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
|
||||||
if damage == nil then
|
if damage == nil then
|
||||||
damage = 3
|
damage = 3
|
||||||
end
|
end
|
||||||
|
local knockback
|
||||||
if bow_stack then
|
if bow_stack then
|
||||||
local power_level = mcl_enchanting.get_enchantment(bow_stack, "power")
|
local enchantments = mcl_enchanting.get_enchantments(bow_stack)
|
||||||
if power_level > 0 then
|
if enchantments.power then
|
||||||
damage = damage + (power_level + 1) / 4
|
damage = damage + (enchantments.power + 1) / 4
|
||||||
|
end
|
||||||
|
if enchantments.punch then
|
||||||
|
knockback = enchantments.punch * 3
|
||||||
end
|
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})
|
||||||
|
@ -55,6 +59,7 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
|
||||||
le._damage = damage
|
le._damage = damage
|
||||||
le._is_critical = is_critical
|
le._is_critical = is_critical
|
||||||
le._startpos = pos
|
le._startpos = pos
|
||||||
|
le._knockback = knockback
|
||||||
minetest.sound_play("mcl_bows_bow_shoot", {pos=pos}, true)
|
minetest.sound_play("mcl_bows_bow_shoot", {pos=pos}, true)
|
||||||
if shooter ~= nil and shooter:is_player() then
|
if shooter ~= nil and shooter:is_player() then
|
||||||
if obj:get_luaentity().player == "" then
|
if obj:get_luaentity().player == "" then
|
||||||
|
|
Loading…
Reference in New Issue