2024-04-27 21:04:49 +02:00
local modname = minetest.get_current_modname ( )
local modpath = minetest.get_modpath ( modname )
local S = minetest.get_translator ( modname )
local hammer_tt = S ( " Can crush blocks " ) .. " \n " .. S ( " Increased knockback " )
local hammer_longdesc = S ( " Hammers are great in melee combat, as they deal high damage with increased knockback and can endure countless battles. Hammers can also be used to crush things. " )
2024-09-29 21:01:45 +02:00
local hammer_use = S ( " To crush a block, dig the block with the hammer. This only works with some blocks. " )
2024-04-27 21:04:49 +02:00
local spear_tt = S ( " Reaches farther " ) .. " \n " .. S ( " Can be thrown " )
local spear_longdesc = S ( " Spears are great in melee combat, as they have an increased reach. They can also be thrown. " )
local spear_use = S ( " To throw a spear, hold it in your hand, then hold use (rightclick) in the air. " )
local wield_scale = mcl_vars.tool_wield_scale
2024-11-16 00:44:07 +01:00
local spear_entity = table.copy ( mcl_bows.arrow_entity )
table.update ( spear_entity , {
visual = " item " ,
visual_size = { x =- 0.5 , y =- 0.5 } ,
textures = { " vl_weaponry:spear_wood " } ,
2024-11-16 01:11:40 +01:00
_on_remove = function ( self )
vl_projectile.replace_with_item_drop ( self , self.object : get_pos ( ) )
end ,
2024-11-16 00:44:07 +01:00
} )
table.update ( spear_entity._vl_projectile , {
behaviors = {
vl_projectile.sticks ,
vl_projectile.burns ,
vl_projectile.has_tracer ,
vl_projectile.has_owner_grace_distance ,
vl_projectile.collides_with_solids ,
vl_projectile.raycast_collides_with_entities ,
} ,
pitch_offset = math.pi / 4 ,
} )
vl_projectile.register ( " vl_weaponry:spear_entity " , spear_entity )
2024-04-27 21:04:49 +02:00
local spear_throw_power = 25
local spear_on_place = function ( wear_divisor )
return function ( itemstack , user , pointed_thing )
if pointed_thing.type == " node " then
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node ( pointed_thing.under )
if user and not user : get_player_control ( ) . sneak then
if minetest.registered_nodes [ node.name ] and minetest.registered_nodes [ node.name ] . on_rightclick then
return minetest.registered_nodes [ node.name ] . on_rightclick ( pointed_thing.under , node , user , itemstack ) or itemstack
end
end
end
if minetest.is_protected ( pointed_thing.under , user : get_player_name ( ) ) then
minetest.record_protection_violation ( pointed_thing.under , user : get_player_name ( ) )
return itemstack
end
local pos = user : get_pos ( )
pos.y = pos.y + 1.5
local dir = user : get_look_dir ( )
local yaw = user : get_look_horizontal ( )
2024-11-16 00:44:07 +01:00
local obj = vl_projectile.create ( " vl_weaponry:spear_entity " , {
pos = pos ,
dir = dir ,
owner = user ,
velocity = spear_throw_power ,
} )
2024-04-27 21:04:49 +02:00
obj : set_properties ( { textures = { itemstack : get_name ( ) } } )
local le = obj : get_luaentity ( )
le._shooter = user
le._source_object = user
le._damage = itemstack : get_definition ( ) . _mcl_spear_thrown_damage
le._is_critical = false
le._startpos = pos
le._collectable = true
2024-11-16 00:44:07 +01:00
le._arrow_item = itemstack : get_name ( )
2024-04-27 21:04:49 +02:00
minetest.sound_play ( " mcl_bows_bow_shoot " , { pos = pos , max_hear_distance = 16 } , true )
if user and user : is_player ( ) then
if obj : get_luaentity ( ) . player == " " then
obj : get_luaentity ( ) . player = user
end
-- obj:get_luaentity().node = shooter:get_inventory():get_stack("main", 1):get_name()
end
return ItemStack ( )
end
end
local uses = {
wood = 60 ,
stone = 132 ,
iron = 251 ,
gold = 33 ,
diamond = 1562 ,
netherite = 2031 ,
}
local SPEAR_RANGE = 4.5
--Hammers
minetest.register_tool ( " vl_weaponry:hammer_wood " , {
description = S ( " Wooden Hammer " ) ,
_tt_help = hammer_tt ,
_doc_items_longdesc = hammer_longdesc ,
_doc_items_usagehelp = hammer_use ,
_doc_items_hidden = false ,
inventory_image = " vl_tool_woodhammer.png " ,
wield_scale = wield_scale ,
groups = { weapon = 1 , hammer = 1 , dig_speed_class = 2 , enchantability = 15 } ,
tool_capabilities = {
full_punch_interval = 1.2 ,
max_drop_level = 1 ,
damage_groups = { fleshy = 4 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.wood ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " group:wood " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
pickaxey = { speed = 1 , level = 1 , uses = uses.wood } ,
shovely = { speed = 1 , level = 2 , uses = uses.wood }
2024-04-27 21:04:49 +02:00
} ,
} )
minetest.register_tool ( " vl_weaponry:hammer_stone " , {
description = S ( " Stone Hammer " ) ,
_tt_help = hammer_tt ,
_doc_items_longdesc = hammer_longdesc ,
_doc_items_usagehelp = hammer_use ,
inventory_image = " vl_tool_stonehammer.png " ,
wield_scale = wield_scale ,
groups = { weapon = 1 , hammer = 1 , dig_speed_class = 2 , enchantability = 5 } ,
tool_capabilities = {
full_punch_interval = 1.3 ,
max_drop_level = 3 ,
damage_groups = { fleshy = 5 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.stone ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " group:cobble " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
pickaxey = { speed = 2 , level = 3 , uses = uses.stone } ,
shovely = { speed = 2 , level = 3 , uses = uses.stone }
2024-04-27 21:04:49 +02:00
} ,
} )
minetest.register_tool ( " vl_weaponry:hammer_iron " , {
description = S ( " Iron Hammer " ) ,
_tt_help = hammer_tt ,
_doc_items_longdesc = hammer_longdesc ,
_doc_items_usagehelp = hammer_use ,
inventory_image = " vl_tool_steelhammer.png " ,
wield_scale = wield_scale ,
groups = { weapon = 1 , hammer = 1 , dig_speed_class = 2 , enchantability = 14 } ,
tool_capabilities = {
full_punch_interval = 1.2 ,
max_drop_level = 4 ,
damage_groups = { fleshy = 6 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.iron ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_core:iron_ingot " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
pickaxey = { speed = 3 , level = 4 , uses = uses.iron } ,
shovely = { speed = 3 , level = 4 , uses = uses.iron }
2024-04-27 21:04:49 +02:00
} ,
} )
minetest.register_tool ( " vl_weaponry:hammer_gold " , {
description = S ( " Golden Hammer " ) ,
_tt_help = hammer_tt ,
_doc_items_longdesc = hammer_longdesc ,
_doc_items_usagehelp = hammer_use ,
inventory_image = " vl_tool_goldhammer.png " ,
wield_scale = wield_scale ,
groups = { weapon = 1 , hammer = 1 , dig_speed_class = 2 , enchantability = 22 } ,
tool_capabilities = {
full_punch_interval = 1.0 ,
max_drop_level = 2 ,
damage_groups = { fleshy = 5 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.gold ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_core:gold_ingot " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
pickaxey = { speed = 8 , level = 4 , uses = uses.gold } ,
shovely = { speed = 8 , level = 4 , uses = uses.gold }
2024-04-27 21:04:49 +02:00
} ,
} )
minetest.register_tool ( " vl_weaponry:hammer_diamond " , {
description = S ( " Diamond Hammer " ) ,
_tt_help = hammer_tt ,
_doc_items_longdesc = hammer_longdesc ,
_doc_items_usagehelp = hammer_use ,
inventory_image = " vl_tool_diamondhammer.png " ,
wield_scale = wield_scale ,
groups = { weapon = 1 , hammer = 1 , dig_speed_class = 2 , enchantability = 10 } ,
tool_capabilities = {
full_punch_interval = 1.0 ,
max_drop_level = 5 ,
damage_groups = { fleshy = 7 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.diamond ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_core:diamond " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
pickaxey = { speed = 4 , level = 5 , uses = uses.diamond } ,
pickaxey = { speed = 4 , level = 5 , uses = uses.diamond }
2024-04-27 21:04:49 +02:00
} ,
_mcl_upgradable = true ,
_mcl_upgrade_item = " vl_weaponry:hammer_netherite "
} )
minetest.register_tool ( " vl_weaponry:hammer_netherite " , {
description = S ( " Netherite Hammer " ) ,
_tt_help = hammer_tt ,
_doc_items_longdesc = hammer_longdesc ,
_doc_items_usagehelp = hammer_use ,
inventory_image = " vl_tool_netheritehammer.png " ,
wield_scale = wield_scale ,
groups = { weapon = 1 , hammer = 1 , dig_speed_class = 2 , enchantability = 10 , fire_immune = 1 } ,
tool_capabilities = {
full_punch_interval = 1.0 ,
max_drop_level = 5 ,
damage_groups = { fleshy = 9 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.netherite ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_nether:netherite_ingot " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
pickaxey = { speed = 6 , level = 6 , uses = uses.netherite } ,
shovely = { speed = 6 , level = 6 , uses = uses.netherite }
2024-04-27 21:04:49 +02:00
} ,
} )
--Spears
minetest.register_tool ( " vl_weaponry:spear_wood " , {
description = S ( " Wooden Spear " ) ,
_tt_help = spear_tt ,
_doc_items_longdesc = spear_longdesc ,
_doc_items_usagehelp = spear_use ,
_doc_items_hidden = false ,
inventory_image = " vl_tool_woodspear.png " ,
wield_scale = wield_scale ,
on_place = spear_on_place ( uses.wood ) ,
on_secondary_use = spear_on_place ( uses.wood ) ,
groups = { weapon = 1 , spear = 1 , dig_speed_class = 2 , enchantability = 15 } ,
range = SPEAR_RANGE ,
tool_capabilities = {
full_punch_interval = 0.75 ,
max_drop_level = 1 ,
damage_groups = { fleshy = 3 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.wood ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " group:wood " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
swordy = { speed = 2 , level = 1 , uses = uses.wood } ,
swordy_cobweb = { speed = 2 , level = 1 , uses = uses.wood }
2024-04-27 21:04:49 +02:00
} ,
_mcl_spear_thrown_damage = 5 ,
} )
minetest.register_tool ( " vl_weaponry:spear_stone " , {
description = S ( " Stone Spear " ) ,
_tt_help = spear_tt ,
_doc_items_longdesc = spear_longdesc ,
_doc_items_usagehelp = spear_use ,
inventory_image = " vl_tool_stonespear.png " ,
wield_scale = wield_scale ,
on_place = spear_on_place ( uses.stone ) ,
on_secondary_use = spear_on_place ( uses.stone ) ,
groups = { weapon = 1 , spear = 1 , dig_speed_class = 2 , enchantability = 5 } ,
range = SPEAR_RANGE ,
tool_capabilities = {
full_punch_interval = 0.75 ,
max_drop_level = 3 ,
damage_groups = { fleshy = 4 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.stone ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " group:cobble " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
swordy = { speed = 2 , level = 1 , uses = uses.stone } ,
swordy_cobweb = { speed = 2 , level = 1 , uses = uses.stone }
2024-04-27 21:04:49 +02:00
} ,
_mcl_spear_thrown_damage = 6 ,
} )
minetest.register_tool ( " vl_weaponry:spear_iron " , {
description = S ( " Iron Spear " ) ,
_tt_help = spear_tt ,
_doc_items_longdesc = spear_longdesc ,
_doc_items_usagehelp = spear_use ,
inventory_image = " vl_tool_steelspear.png " ,
wield_scale = wield_scale ,
on_place = spear_on_place ( uses.iron ) ,
on_secondary_use = spear_on_place ( uses.iron ) ,
groups = { weapon = 1 , spear = 1 , dig_speed_class = 2 , enchantability = 14 } ,
range = SPEAR_RANGE ,
tool_capabilities = {
full_punch_interval = 0.75 ,
max_drop_level = 4 ,
damage_groups = { fleshy = 5 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.iron ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_core:iron_ingot " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
swordy = { speed = 2 , level = 1 , uses = uses.iron } ,
swordy_cobweb = { speed = 2 , level = 1 , uses = uses.iron }
2024-04-27 21:04:49 +02:00
} ,
_mcl_spear_thrown_damage = 7 ,
} )
minetest.register_tool ( " vl_weaponry:spear_gold " , {
description = S ( " Golden Spear " ) ,
_tt_help = spear_tt ,
_doc_items_longdesc = spear_longdesc ,
_doc_items_usagehelp = spear_use ,
inventory_image = " vl_tool_goldspear.png " ,
wield_scale = wield_scale ,
on_place = spear_on_place ( uses.gold ) ,
on_secondary_use = spear_on_place ( uses.gold ) ,
groups = { weapon = 1 , spear = 1 , dig_speed_class = 2 , enchantability = 22 } ,
range = SPEAR_RANGE ,
tool_capabilities = {
full_punch_interval = 0.75 ,
max_drop_level = 2 ,
damage_groups = { fleshy = 3 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.gold ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_core:gold_ingot " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
swordy = { speed = 2 , level = 1 , uses = uses.gold } ,
swordy_cobweb = { speed = 2 , level = 1 , uses = uses.gold }
2024-04-27 21:04:49 +02:00
} ,
_mcl_spear_thrown_damage = 5 ,
} )
minetest.register_tool ( " vl_weaponry:spear_diamond " , {
description = S ( " Diamond Spear " ) ,
_tt_help = spear_tt ,
_doc_items_longdesc = spear_longdesc ,
_doc_items_usagehelp = spear_use ,
inventory_image = " vl_tool_diamondspear.png " ,
wield_scale = wield_scale ,
on_place = spear_on_place ( uses.diamond ) ,
on_secondary_use = spear_on_place ( uses.diamond ) ,
groups = { weapon = 1 , spear = 1 , dig_speed_class = 2 , enchantability = 10 } ,
range = SPEAR_RANGE ,
tool_capabilities = {
full_punch_interval = 0.75 ,
max_drop_level = 5 ,
damage_groups = { fleshy = 6 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.diamond ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_core:diamond " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
swordy = { speed = 2 , level = 1 , uses = uses.diamond } ,
swordy_cobweb = { speed = 2 , level = 1 , uses = uses.diamond }
2024-04-27 21:04:49 +02:00
} ,
_mcl_spear_thrown_damage = 8 ,
_mcl_upgradable = true ,
_mcl_upgrade_item = " vl_weaponry:spear_netherite "
} )
minetest.register_tool ( " vl_weaponry:spear_netherite " , {
description = S ( " Netherite Spear " ) ,
_tt_help = spear_tt ,
_doc_items_longdesc = spear_longdesc ,
_doc_items_usagehelp = spear_use ,
inventory_image = " vl_tool_netheritespear.png " ,
wield_scale = wield_scale ,
on_place = spear_on_place ( uses.netherite ) ,
on_secondary_use = spear_on_place ( uses.netherite ) ,
groups = { weapon = 1 , spear = 1 , dig_speed_class = 2 , enchantability = 10 , fire_immune = 1 } ,
range = SPEAR_RANGE ,
tool_capabilities = {
full_punch_interval = 0.75 ,
max_drop_level = 5 ,
damage_groups = { fleshy = 8 } ,
2024-11-16 01:33:51 +01:00
punch_attack_uses = uses.netherite ,
2024-04-27 21:04:49 +02:00
} ,
sound = { breaks = " default_tool_breaks " } ,
_repair_material = " mcl_nether:netherite_ingot " ,
_mcl_toollike_wield = true ,
_mcl_diggroups = {
2024-11-16 01:33:51 +01:00
swordy = { speed = 2 , level = 1 , uses = uses.netherite } ,
swordy_cobweb = { speed = 2 , level = 1 , uses = uses.netherite }
2024-04-27 21:04:49 +02:00
} ,
_mcl_spear_thrown_damage = 12 ,
} )