fire_arrow.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. minetest.register_craftitem("throwing:arrow_fire", {
  2. description = "Fire Arrow",
  3. inventory_image = "throwing_arrow_fire.png",
  4. })
  5. minetest.register_node("throwing:arrow_fire_box", {
  6. drawtype = "nodebox",
  7. node_box = {
  8. type = "fixed",
  9. fixed = {
  10. -- Shaft
  11. {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
  12. --Spitze
  13. {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
  14. {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
  15. --Federn
  16. {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
  17. {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
  18. {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
  19. {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
  20. {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
  21. {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
  22. {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
  23. {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
  24. }
  25. },
  26. tiles = {"throwing_arrow_fire.png", "throwing_arrow_fire.png", "throwing_arrow_fire_back.png", "throwing_arrow_fire_front.png", "throwing_arrow_fire_2.png", "throwing_arrow_fire.png"},
  27. groups = {not_in_creative_inventory=1},
  28. })
  29. local THROWING_ARROW_ENTITY={
  30. physical = false,
  31. timer=0,
  32. visual = "wielditem",
  33. visual_size = {x=0.1, y=0.1},
  34. textures = {"throwing:arrow_fire_box"},
  35. lastpos={},
  36. collisionbox = {0,0,0,0,0,0},
  37. }
  38. THROWING_ARROW_ENTITY.on_step = function(self, dtime)
  39. self.timer=self.timer+dtime
  40. local pos = self.object:getpos()
  41. local node = minetest.env:get_node(pos)
  42. if self.timer>0.2 then
  43. local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
  44. for k, obj in pairs(objs) do
  45. if obj:get_luaentity() ~= nil then
  46. if obj:get_luaentity().name ~= "throwing:arrow_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then
  47. local damage = 5
  48. obj:punch(self.object, 1.0, {
  49. full_punch_interval=1.0,
  50. damage_groups={fleshy=damage},
  51. }, nil)
  52. self.object:remove()
  53. end
  54. else
  55. local damage = 5
  56. obj:punch(self.object, 1.0, {
  57. full_punch_interval=1.0,
  58. damage_groups={fleshy=damage},
  59. }, nil)
  60. self.object:remove()
  61. end
  62. end
  63. end
  64. if self.lastpos.x~=nil then
  65. if node.name ~= "air" and node.name ~= "throwing:light" then
  66. minetest.env:set_node(self.lastpos, {name="fire:basic_flame"})
  67. self.object:remove()
  68. end
  69. if math.floor(self.lastpos.x+0.5) ~= math.floor(pos.x+0.5) or math.floor(self.lastpos.y+0.5) ~= math.floor(pos.y+0.5) or math.floor(self.lastpos.z+0.5) ~= math.floor(pos.z+0.5) then
  70. if minetest.env:get_node(self.lastpos).name == "throwing:light" then
  71. minetest.env:remove_node(self.lastpos)
  72. end
  73. if minetest.env:get_node(pos).name == "air" then
  74. minetest.env:set_node(pos, {name="throwing:light"})
  75. end
  76. end
  77. end
  78. self.lastpos={x=pos.x, y=pos.y, z=pos.z}
  79. end
  80. minetest.register_entity("throwing:arrow_fire_entity", THROWING_ARROW_ENTITY)
  81. minetest.register_craft({
  82. output = 'throwing:arrow_fire 4',
  83. recipe = {
  84. {'default:stick', 'default:stick', 'bucket:bucket_lava'},
  85. },
  86. replacements = {
  87. {"bucket:bucket_lava", "bucket:bucket_empty"}
  88. }
  89. })
  90. minetest.register_node("throwing:light", {
  91. drawtype = "airlike",
  92. paramtype = "light",
  93. sunlight_propagates = true,
  94. tiles = {"throwing_empty.png"},
  95. light_source = LIGHT_MAX-4,
  96. selection_box = {
  97. type = "fixed",
  98. fixed = {
  99. {0,0,0,0,0,0}
  100. }
  101. },
  102. groups = {not_in_creative_inventory=1}
  103. })
  104. minetest.register_abm({
  105. nodenames = {"throwing:light"},
  106. interval = 10,
  107. chance = 1,
  108. action = function(pos, node)
  109. minetest.env:remove_node(pos)
  110. end
  111. })