init.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. -- support for i18n
  2. local S = armor_i18n.gettext
  3. local disable_sounds = minetest.settings:get_bool("shields_disable_sounds")
  4. local use_moreores = minetest.get_modpath("moreores")
  5. local function play_sound_effect(player, name)
  6. if not disable_sounds and player then
  7. local pos = player:get_pos()
  8. if pos then
  9. minetest.sound_play(name, {
  10. pos = pos,
  11. max_hear_distance = 10,
  12. gain = 0.5,
  13. })
  14. end
  15. end
  16. end
  17. if minetest.global_exists("armor") and armor.elements then
  18. table.insert(armor.elements, "shield")
  19. local mult = armor.config.level_multiplier or 1
  20. armor.config.level_multiplier = mult * 0.9
  21. end
  22. -- Regisiter Shields
  23. armor:register_armor("shields:shield_admin", {
  24. description = S("Admin Shield"),
  25. inventory_image = "shields_inv_shield_admin.png",
  26. groups = {armor_shield=1000, armor_heal=100, armor_use=0, not_in_creative_inventory=1},
  27. })
  28. minetest.register_alias("adminshield", "shields:shield_admin")
  29. armor:register_armor("shields:shield_wood", {
  30. description = S("Wooden Shield"),
  31. inventory_image = "shields_inv_shield_wood.png",
  32. groups = {armor_shield=1, armor_heal=0, armor_use=2000, flammable=1},
  33. armor_groups = {fleshy=5},
  34. damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=1},
  35. reciprocate_damage = true,
  36. on_damage = function(player, index, stack)
  37. play_sound_effect(player, "default_wood_footstep")
  38. end,
  39. on_destroy = function(player, index, stack)
  40. play_sound_effect(player, "default_wood_footstep")
  41. end,
  42. })
  43. armor:register_armor("shields:shield_enhanced_wood", {
  44. description = S("Enhanced Wood Shield"),
  45. inventory_image = "shields_inv_shield_enhanced_wood.png",
  46. groups = {armor_shield=1, armor_heal=0, armor_use=2000},
  47. armor_groups = {fleshy=8},
  48. damage_groups = {cracky=3, snappy=2, choppy=3, crumbly=2, level=2},
  49. reciprocate_damage = true,
  50. on_damage = function(player, index, stack)
  51. play_sound_effect(player, "default_dig_metal")
  52. end,
  53. on_destroy = function(player, index, stack)
  54. play_sound_effect(player, "default_dug_metal")
  55. end,
  56. })
  57. minetest.register_craft({
  58. output = "shields:shield_enhanced_wood",
  59. recipe = {
  60. {"default:steel_ingot"},
  61. {"shields:shield_wood"},
  62. {"default:steel_ingot"},
  63. },
  64. })
  65. armor:register_armor("shields:shield_steel", {
  66. description = S("Steel Shield"),
  67. inventory_image = "shields_inv_shield_steel.png",
  68. groups = {armor_shield=1, armor_heal=0, armor_use=800,
  69. physics_speed=-0.03, physics_gravity=0.03},
  70. armor_groups = {fleshy=10},
  71. damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
  72. reciprocate_damage = true,
  73. on_damage = function(player, index, stack)
  74. play_sound_effect(player, "default_dig_metal")
  75. end,
  76. on_destroy = function(player, index, stack)
  77. play_sound_effect(player, "default_dug_metal")
  78. end,
  79. })
  80. armor:register_armor("shields:shield_bronze", {
  81. description = S("Bronze Shield"),
  82. inventory_image = "shields_inv_shield_bronze.png",
  83. groups = {armor_shield=1, armor_heal=6, armor_use=400,
  84. physics_speed=-0.03, physics_gravity=0.03},
  85. armor_groups = {fleshy=10},
  86. damage_groups = {cracky=2, snappy=3, choppy=2, crumbly=1, level=2},
  87. reciprocate_damage = true,
  88. on_damage = function(player, index, stack)
  89. play_sound_effect(player, "default_dig_metal")
  90. end,
  91. on_destroy = function(player, index, stack)
  92. play_sound_effect(player, "default_dug_metal")
  93. end,
  94. })
  95. armor:register_armor("shields:shield_diamond", {
  96. description = S("Diamond Shield"),
  97. inventory_image = "shields_inv_shield_diamond.png",
  98. groups = {armor_shield=1, armor_heal=12, armor_use=200},
  99. armor_groups = {fleshy=15},
  100. damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
  101. reciprocate_damage = true,
  102. on_damage = function(player, index, stack)
  103. play_sound_effect(player, "default_glass_footstep")
  104. end,
  105. on_destroy = function(player, index, stack)
  106. play_sound_effect(player, "default_break_glass")
  107. end,
  108. })
  109. armor:register_armor("shields:shield_gold", {
  110. description = S("Gold Shield"),
  111. inventory_image = "shields_inv_shield_gold.png",
  112. groups = {armor_shield=1, armor_heal=6, armor_use=300,
  113. physics_speed=-0.04, physics_gravity=0.04},
  114. armor_groups = {fleshy=10},
  115. damage_groups = {cracky=1, snappy=2, choppy=2, crumbly=3, level=2},
  116. reciprocate_damage = true,
  117. on_damage = function(player, index, stack)
  118. play_sound_effect(player, "default_dig_metal")
  119. end,
  120. on_destroy = function(player, index, stack)
  121. play_sound_effect(player, "default_dug_metal")
  122. end,
  123. })
  124. for k, v in pairs(armor.materials) do
  125. minetest.register_craft({
  126. output = "shields:shield_"..k,
  127. recipe = {
  128. {v, v, v},
  129. {v, v, v},
  130. {"", v, ""},
  131. },
  132. })
  133. end