mirror of
https://gitlab.com/echoes91/throwing.git
synced 2025-06-30 07:10:22 +02:00
Version MFF.
This commit is contained in:
74
fireworks_arrows.lua
Normal file → Executable file
74
fireworks_arrows.lua
Normal file → Executable file
@ -3,7 +3,7 @@ local function throwing_register_fireworks(color, desc)
|
||||
description = desc .. "fireworks arrow",
|
||||
inventory_image = "throwing_arrow_fireworks_" .. color .. ".png",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("throwing:arrow_fireworks_" .. color .. "_box", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
@ -19,7 +19,7 @@ local function throwing_register_fireworks(color, desc)
|
||||
{7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
|
||||
{7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
|
||||
{6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
|
||||
|
||||
|
||||
{7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
|
||||
{8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
|
||||
{8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
|
||||
@ -29,7 +29,7 @@ local function throwing_register_fireworks(color, desc)
|
||||
tiles = {"throwing_arrow_fireworks_" .. color .. ".png", "throwing_arrow_fireworks_" .. color .. ".png", "throwing_arrow_fireworks_" .. color .. "_back.png", "throwing_arrow_fireworks_" .. color .. "_front.png", "throwing_arrow_fireworks_" .. color .. "_2.png", "throwing_arrow_fireworks_" .. color .. ".png"},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
})
|
||||
|
||||
|
||||
local THROWING_ARROW_ENTITY={
|
||||
physical = false,
|
||||
timer=0,
|
||||
@ -38,10 +38,12 @@ local function throwing_register_fireworks(color, desc)
|
||||
textures = {"throwing:arrow_fireworks_" .. color .. "_box"},
|
||||
lastpos={},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
player = "",
|
||||
bow_damage = 0,
|
||||
}
|
||||
|
||||
|
||||
local radius = 0.5
|
||||
|
||||
|
||||
local function add_effects(pos, radius)
|
||||
minetest.add_particlespawner({
|
||||
amount = 256,
|
||||
@ -59,8 +61,8 @@ local function throwing_register_fireworks(color, desc)
|
||||
texture = "throwing_sparkle_" .. color .. ".png",
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
local function boom(pos)
|
||||
minetest.sound_play("throwing_firework_boom", {pos=pos, gain=1, max_hear_distance=2*64})
|
||||
if minetest.get_node(pos).name == 'air' or minetest.get_node(pos).name == 'throwing:firework_trail' then
|
||||
@ -69,21 +71,20 @@ local function throwing_register_fireworks(color, desc)
|
||||
end
|
||||
add_effects(pos, radius)
|
||||
end
|
||||
|
||||
|
||||
-- Back to the arrow
|
||||
|
||||
|
||||
THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos)
|
||||
local newpos = self.object:getpos()
|
||||
if self.timer < 0.07 then
|
||||
minetest.sound_play("throwing_firework_launch", {pos=pos, gain=0.8, max_hear_distance=2*64})
|
||||
minetest.sound_play("throwing_firework_launch", {pos=newpos, gain=0.8, max_hear_distance=2*64})
|
||||
end
|
||||
minetest.add_particlespawner({
|
||||
amount = 16,
|
||||
time = 0.1,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minpos = newpos,
|
||||
maxpos = newpos,
|
||||
minvel = {x=-5, y=-5, z=-5},
|
||||
maxvel = {x=5, y=5, z=5},
|
||||
minacc = vector.new(),
|
||||
@ -94,48 +95,49 @@ local function throwing_register_fireworks(color, desc)
|
||||
maxsize = 1,
|
||||
texture = "throwing_sparkle.png",
|
||||
})
|
||||
if self.timer>0.2 then
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
if obj:get_luaentity() ~= nil then
|
||||
if obj:get_luaentity().name ~= "throwing:arrow_fireworks_" .. color .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||
if self.lastpos.x ~= nil then
|
||||
for _, pos in pairs(throwing_get_trajectoire(self, newpos)) do
|
||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
|
||||
for k, obj in pairs(objs) do
|
||||
if throwing_is_player(self.player, obj) or throwing_is_entity(obj) then
|
||||
local damage = 2
|
||||
if self.bow_damage and self.bow_damage > 0 then
|
||||
damage = damage + (self.bow_damage/12)
|
||||
end
|
||||
obj:punch(self.object, 1.0, {
|
||||
full_punch_interval=1.0,
|
||||
damage_groups={fleshy=damage},
|
||||
}, nil)
|
||||
self.object:remove()
|
||||
boom(pos)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.timer > 2 then
|
||||
self.object:remove()
|
||||
boom(self.lastpos)
|
||||
end
|
||||
if self.lastpos.x~=nil then
|
||||
if node.name ~= "air" and node.name ~= "throwing:firework_trail" then
|
||||
self.object:remove()
|
||||
local node = minetest.get_node(newpos)
|
||||
if self.timer > 2 or node.name ~= "air" and node.name ~= "throwing:firework_trail" then
|
||||
boom(self.lastpos)
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
if node.name == 'air' then
|
||||
minetest.add_node(newpos, {name="throwing:firework_trail"})
|
||||
minetest.get_node_timer(newpos):start(0.1)
|
||||
end
|
||||
end
|
||||
if node.name == 'air' then
|
||||
minetest.add_node(pos, {name="throwing:firework_trail"})
|
||||
minetest.get_node_timer(pos):start(0.1)
|
||||
end
|
||||
self.lastpos={x=pos.x, y=pos.y, z=pos.z}
|
||||
self.lastpos={x=newpos.x, y=newpos.y, z=newpos.z}
|
||||
end
|
||||
|
||||
|
||||
|
||||
minetest.register_entity("throwing:arrow_fireworks_" .. color .. "_entity", THROWING_ARROW_ENTITY)
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_fireworks_' .. color .. ' 8',
|
||||
recipe = {
|
||||
{'default:stick', 'tnt:gunpowder', 'dye:' .. color},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'throwing:arrow_fireworks_' .. color .. ' 8',
|
||||
recipe = {
|
||||
|
Reference in New Issue
Block a user