Make crossbows check for multishot enchantment

This commit is contained in:
Code-Sploit 2021-02-17 14:29:33 +00:00
parent 79e03579bd
commit 63894eb5d6
1 changed files with 14 additions and 3 deletions

View File

@ -93,9 +93,17 @@ local player_shoot_arrow = function(itemstack, player, power, damage, is_critica
local playerpos = player:get_pos()
local dir = player:get_look_dir()
local yaw = player:get_look_horizontal()
local has_multishot_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "multishot")
minetest.sound_play("mcl_bows_crossbow_shoot", {pos=playerpos, max_hear_distance=16}, true)
mcl_bows.shoot_arrow("mcl_bows:arrow", {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), not infinity_used)
if has_multishot_enchantment then
for times_shot=0,2 do
mcl_bows.shoot_arrow("mcl_bows:arrow", {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), not infinity_used)
end
else
mcl_bows.shoot_arrow("mcl_bows:arrow", {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), not infinity_used)
end
return true
end
@ -244,6 +252,7 @@ controls.register_on_press(function(player, key)
local speed, damage
local p_load = bow_load[player:get_player_name()]
local charge
-- Type sanity check
if type(p_load) == "number" then
charge = minetest.get_us_time() - p_load
@ -255,7 +264,9 @@ controls.register_on_press(function(player, key)
end
charge = 1000000
local charge_ratio = charge / BOW_CHARGE_TIME_FULL
local charge_ratio
charge_ratio = charge / BOW_CHARGE_TIME_FULL
charge_ratio = math.max(math.min(charge_ratio, 1), 0)
-- Calculate damage and speed
@ -428,4 +439,4 @@ if minetest.get_modpath("doc") then
doc.add_entry_alias("tools", "mcl_bows:crossbow", "tools", "mcl_bows:crossbow_0")
doc.add_entry_alias("tools", "mcl_bows:crossbow", "tools", "mcl_bows:crossbow_1")
doc.add_entry_alias("tools", "mcl_bows:crossbow", "tools", "mcl_bows:crossbow_2")
end
end