Minetest mod that adds spears in the game, improving the ones introduced within throwing enhanced
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2KB

  1. function spears_register_spear(spear_type, desc, base_damage, toughness, material)
  2. minetest.register_tool("spears:spear_" .. spear_type, {
  3. description = desc .. " spear",
  4. wield_image = "spears_spear_" .. spear_type .. ".png^[transform4",
  5. inventory_image = "spears_spear_" .. spear_type .. ".png",
  6. wield_scale= {x = 1.5, y = 1.5, z = 1.5},
  7. on_secondary_use = function(itemstack, user, pointed_thing)
  8. spears_throw(itemstack, user, pointed_thing)
  9. if not minetest.setting_getbool("creative_mode") then
  10. itemstack:take_item()
  11. end
  12. return itemstack
  13. end,
  14. on_place = function(itemstack, user, pointed_thing)
  15. spears_throw(itemstack, user, pointed_thing)
  16. if not minetest.setting_getbool("creative_mode") then
  17. itemstack:take_item()
  18. end
  19. return itemstack
  20. end,
  21. tool_capabilities = {
  22. full_punch_interval = 1.5,
  23. max_drop_level=1,
  24. groupcaps={
  25. cracky = {times={[3]=2}, uses=toughness, maxlevel=1},
  26. },
  27. damage_groups = {fleshy=base_damage},
  28. },
  29. sound = {breaks = "default_tool_breaks"},
  30. groups = {flammable = 1}
  31. })
  32. local SPEAR_ENTITY = spears_set_entity(spear_type, base_damage, toughness)
  33. minetest.register_entity("spears:spear_" .. spear_type .. "_entity", SPEAR_ENTITY)
  34. minetest.register_craft({
  35. output = 'spears:spear_' .. spear_type,
  36. recipe = {
  37. {'group:stick', 'group:stick', material},
  38. }
  39. })
  40. minetest.register_craft({
  41. output = 'spears:spear_' .. spear_type,
  42. recipe = {
  43. {material, 'group:stick', 'group:stick'},
  44. }
  45. })
  46. end
  47. if not DISABLE_STONE_SPEAR then
  48. spears_register_spear('stone', 'Stone', 4, 20, 'group:stone')
  49. end
  50. if not DISABLE_STEEL_SPEAR then
  51. spears_register_spear('steel', 'Steel', 6, 30, 'default:steel_ingot')
  52. end
  53. if not DISABLE_COPPER_SPEAR then
  54. spears_register_spear('copper', 'Copper', 5, 35, 'default:copper_ingot')
  55. end
  56. if not DISABLE_BRONZE_SPEAR then
  57. spears_register_spear('bronze', 'Bronze', 6, 35, 'default:bronze_ingot')
  58. end
  59. if not DISABLE_OBSIDIAN_SPEAR then
  60. spears_register_spear('obsidian', 'Obsidian', 8, 30, 'default:obsidian')
  61. end
  62. if not DISABLE_DIAMOND_SPEAR then
  63. spears_register_spear('diamond', 'Diamond', 8, 40, 'default:diamond')
  64. end
  65. if not DISABLE_GOLD_SPEAR then
  66. spears_register_spear('gold', 'Golden', 5, 40, 'default:gold_ingot')
  67. end