fire_arrow.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. minetest.register_craftitem("lottthrowing:arrow_fire", {
  2. description = "Fire Arrow",
  3. inventory_image = "lottthrowing_arrow_fire.png",
  4. })
  5. minetest.register_node("lottthrowing: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 = {"lottthrowing_arrow_fire.png", "lottthrowing_arrow_fire.png", "lottthrowing_arrow_fire_back.png", "lottthrowing_arrow_fire_front.png", "lottthrowing_arrow_fire_2.png", "lottthrowing_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 = {"lottthrowing:arrow_fire_box"},
  35. lastpos={},
  36. collisionbox = {0,0,0,0,0,0},
  37. player = nil,
  38. }
  39. THROWING_ARROW_ENTITY.on_step = function(self, dtime)
  40. self.timer=self.timer+dtime
  41. local pos = self.object:getpos()
  42. local node = minetest.get_node(pos)
  43. if self.timer>0.2 then
  44. local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
  45. for k, obj in pairs(objs) do
  46. if obj:get_luaentity() ~= nil then
  47. if obj:get_luaentity().name ~= "lottthrowing:arrow_fire_entity" and obj:get_luaentity().name ~= "__builtin:item" then
  48. local damage = 5
  49. obj:punch(self.player, 1.0, {
  50. full_punch_interval=1.0,
  51. damage_groups={fleshy=damage},
  52. }, nil)
  53. self.object:remove()
  54. end
  55. else
  56. local damage = 5
  57. obj:punch(self.player, 1.0, {
  58. full_punch_interval=1.0,
  59. damage_groups={fleshy=damage},
  60. }, nil)
  61. self.object:remove()
  62. end
  63. end
  64. end
  65. if self.lastpos.x~=nil then
  66. if node.name ~= "air" and node.name ~= "lottthrowing:light" then
  67. minetest.set_node(self.lastpos, {name="fire:basic_flame"})
  68. self.object:remove()
  69. end
  70. 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
  71. if minetest.get_node(self.lastpos).name == "lottthrowing:light" then
  72. minetest.remove_node(self.lastpos)
  73. end
  74. if minetest.get_node(pos).name == "air" then
  75. minetest.set_node(pos, {name="lottthrowing:light"})
  76. end
  77. end
  78. end
  79. self.lastpos={x=pos.x, y=pos.y, z=pos.z}
  80. end
  81. minetest.register_entity("lottthrowing:arrow_fire_entity", THROWING_ARROW_ENTITY)
  82. minetest.register_craft({
  83. output = 'lottthrowing:arrow_fire 1',
  84. recipe = {
  85. {'default:stick', 'default:stick', 'default:torch'},
  86. },
  87. })
  88. minetest.register_node("lottthrowing:light", {
  89. drawtype = "airlike",
  90. paramtype = "light",
  91. sunlight_propagates = true,
  92. tiles = {"lottthrowing_empty.png"},
  93. light_source = LIGHT_MAX-4,
  94. selection_box = {
  95. type = "fixed",
  96. fixed = {
  97. {0,0,0,0,0,0}
  98. }
  99. },
  100. groups = {not_in_creative_inventory=1}
  101. })
  102. minetest.register_abm({
  103. nodenames = {"lottthrowing:light"},
  104. interval = 10,
  105. chance = 1,
  106. action = function(pos, node)
  107. minetest.remove_node(pos)
  108. end
  109. })