Merge pull request 'Add support for MultiShot enchantment' (#12) from Code-Sploit/MineClone2:master into master

Reviewed-on: #12
This commit is contained in:
epCode 2021-02-18 01:22:55 +00:00
commit cbe5e618a3
2 changed files with 16 additions and 5 deletions

View File

@ -93,9 +93,17 @@ local player_shoot_arrow = function(itemstack, player, power, damage, is_critica
local playerpos = player:get_pos() local playerpos = player:get_pos()
local dir = player:get_look_dir() local dir = player:get_look_dir()
local yaw = player:get_look_horizontal() 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) minetest.sound_play("mcl_bows_crossbow_shoot", {pos=playerpos, max_hear_distance=16}, true)
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) 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 return true
end end
@ -244,6 +252,7 @@ controls.register_on_press(function(player, key)
local speed, damage local speed, damage
local p_load = bow_load[player:get_player_name()] local p_load = bow_load[player:get_player_name()]
local charge local charge
-- Type sanity check -- Type sanity check
if type(p_load) == "number" then if type(p_load) == "number" then
charge = minetest.get_us_time() - p_load charge = minetest.get_us_time() - p_load
@ -255,7 +264,9 @@ controls.register_on_press(function(player, key)
end end
charge = 1000000 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) charge_ratio = math.max(math.min(charge_ratio, 1), 0)
-- Calculate damage and speed -- Calculate damage and speed

View File

@ -482,7 +482,7 @@ mcl_enchanting.enchantments.mending = {
} }
-- requires missing MineClone2 feature -- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.multishot = { mcl_enchanting.enchantments.multishot = {
name = S("Multishot"), name = S("Multishot"),
max_level = 1, max_level = 1,
primary = {crossbow = true}, primary = {crossbow = true},
@ -498,7 +498,7 @@ mcl_enchanting.enchantments.mending = {
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,
}]]-- }
-- requires missing MineClone2 feature -- requires missing MineClone2 feature
--[[mcl_enchanting.enchantments.piercing = { --[[mcl_enchanting.enchantments.piercing = {