bluefire_arrow.lua 3.6 KB

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