forked from VoxeLibre/VoxeLibre
Punch
This commit is contained in:
parent
86b2cd70f9
commit
494ffb41d3
|
@ -174,7 +174,7 @@ mcl_enchanting.enchantments.fire_protection = {
|
|||
requires_tool = false,
|
||||
}]]--
|
||||
|
||||
-- unimplemented
|
||||
-- implemented in mcl_item_entity
|
||||
mcl_enchanting.enchantments.fortune = {
|
||||
name = "Fortune",
|
||||
max_level = 4,
|
||||
|
@ -254,9 +254,15 @@ mcl_enchanting.enchantments.knockback = {
|
|||
local old_calculate_knockback = minetest.calculate_knockback
|
||||
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 luaentity
|
||||
if hitter then
|
||||
luaentity = hitter:get_luaentity()
|
||||
end
|
||||
if hitter and hitter:is_player() then
|
||||
local wielditem = hitter:get_wielded_item()
|
||||
knockback = knockback + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
|
||||
elseif luaentity and luaentity._knockback then
|
||||
knockback = knockback + luaentity._knockback
|
||||
end
|
||||
return knockback
|
||||
end
|
||||
|
@ -366,7 +372,7 @@ mcl_enchanting.enchantments.protection = {
|
|||
requires_tool = false,
|
||||
}
|
||||
|
||||
-- unimplemented
|
||||
-- implemented via minetest.calculate_knockback (together with the Knockback enchantment) and mcl_bows
|
||||
mcl_enchanting.enchantments.punch = {
|
||||
name = "Punch",
|
||||
max_level = 2,
|
||||
|
|
|
@ -239,16 +239,9 @@ ARROW_ENTITY.on_step = function(self, dtime)
|
|||
end
|
||||
|
||||
-- Punch target object but avoid hurting enderman.
|
||||
if lua 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
|
||||
if not lua or lua.name ~= "mobs_mc:enderman" then
|
||||
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, {
|
||||
full_punch_interval=1.0,
|
||||
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
|
||||
damage = 3
|
||||
end
|
||||
local knockback
|
||||
if bow_stack then
|
||||
local power_level = mcl_enchanting.get_enchantment(bow_stack, "power")
|
||||
if power_level > 0 then
|
||||
damage = damage + (power_level + 1) / 4
|
||||
local enchantments = mcl_enchanting.get_enchantments(bow_stack)
|
||||
if enchantments.power then
|
||||
damage = damage + (enchantments.power + 1) / 4
|
||||
end
|
||||
if enchantments.punch then
|
||||
knockback = enchantments.punch * 3
|
||||
end
|
||||
end
|
||||
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._is_critical = is_critical
|
||||
le._startpos = pos
|
||||
le._knockback = knockback
|
||||
minetest.sound_play("mcl_bows_bow_shoot", {pos=pos}, true)
|
||||
if shooter ~= nil and shooter:is_player() then
|
||||
if obj:get_luaentity().player == "" then
|
||||
|
|
Loading…
Reference in New Issue