mirror of
https://bitbucket.org/kingarthursteam/cannons.git
synced 2025-01-08 12:27:28 +01:00
added particles \n \n thanks to Hybrid Dog \n particles spawn now if the cannon is firing and if the cannonball hits a node.
This commit is contained in:
parent
14894b3dbf
commit
e7a90971fe
@ -30,6 +30,7 @@ local exploding={
|
|||||||
self.object:remove()
|
self.object:remove()
|
||||||
end,
|
end,
|
||||||
on_node_hit = function(self,pos,node)
|
on_node_hit = function(self,pos,node)
|
||||||
|
cannons.nodehitparticles(pos,minetest.registered_nodes[node.name].tiles[1])
|
||||||
cannons.destroy({x=pos.x, y=pos.y, z=pos.z},self.range)
|
cannons.destroy({x=pos.x, y=pos.y, z=pos.z},self.range)
|
||||||
minetest.sound_play("cannons_shot",
|
minetest.sound_play("cannons_shot",
|
||||||
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
||||||
@ -65,6 +66,7 @@ local fire={
|
|||||||
self.object:remove()
|
self.object:remove()
|
||||||
end,
|
end,
|
||||||
on_node_hit = function(self,pos,node)
|
on_node_hit = function(self,pos,node)
|
||||||
|
cannons.nodehitparticles(pos,minetest.registered_nodes[node.name].tiles[1])
|
||||||
pos = self.lastpos
|
pos = self.lastpos
|
||||||
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="fire:basic_flame"})
|
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="fire:basic_flame"})
|
||||||
minetest.sound_play("default_break_glass",
|
minetest.sound_play("default_break_glass",
|
||||||
@ -78,7 +80,7 @@ if cannons.enable_fire then
|
|||||||
end
|
end
|
||||||
|
|
||||||
--++++++++++++++++++++++++++++++++++++
|
--++++++++++++++++++++++++++++++++++++
|
||||||
--+ Stone Cannon ball +
|
--+ Wooden Cannon ball +
|
||||||
--++++++++++++++++++++++++++++++++++++
|
--++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
|
||||||
@ -110,6 +112,7 @@ local ball_wood={
|
|||||||
self.object:remove()
|
self.object:remove()
|
||||||
end,
|
end,
|
||||||
on_node_hit = function(self,pos,node)
|
on_node_hit = function(self,pos,node)
|
||||||
|
cannons.nodehitparticles(pos,minetest.registered_nodes[node.name].tiles[1])
|
||||||
if node.name == "default:dirt_with_grass" then
|
if node.name == "default:dirt_with_grass" then
|
||||||
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
|
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
|
||||||
minetest.sound_play("cannons_hit",
|
minetest.sound_play("cannons_hit",
|
||||||
@ -162,6 +165,7 @@ local ball_stone={
|
|||||||
self.object:remove()
|
self.object:remove()
|
||||||
end,
|
end,
|
||||||
on_node_hit = function(self,pos,node)
|
on_node_hit = function(self,pos,node)
|
||||||
|
cannons.nodehitparticles(pos,minetest.registered_nodes[node.name].tiles[1])
|
||||||
if node.name == "default:dirt_with_grass" then
|
if node.name == "default:dirt_with_grass" then
|
||||||
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
|
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
|
||||||
minetest.sound_play("cannons_hit",
|
minetest.sound_play("cannons_hit",
|
||||||
@ -214,6 +218,7 @@ local ball_steel={
|
|||||||
self.object:remove()
|
self.object:remove()
|
||||||
end,
|
end,
|
||||||
on_node_hit = function(self,pos,node)
|
on_node_hit = function(self,pos,node)
|
||||||
|
cannons.nodehitparticles(pos,minetest.registered_nodes[node.name].tiles[1])
|
||||||
if node.name == "default:dirt_with_grass" then
|
if node.name == "default:dirt_with_grass" then
|
||||||
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
|
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
|
||||||
minetest.sound_play("cannons_hit",
|
minetest.sound_play("cannons_hit",
|
||||||
@ -231,4 +236,4 @@ local ball_steel={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
cannons.register_muni("cannons:ball_steel",ball_steel)
|
cannons.register_muni("cannons:ball_steel",ball_steel)
|
||||||
|
@ -123,6 +123,24 @@ cannons.stand_nodebox = {
|
|||||||
function cannons.meseconsfire(pos,node)
|
function cannons.meseconsfire(pos,node)
|
||||||
cannons.fire(pos,node)
|
cannons.fire(pos,node)
|
||||||
end
|
end
|
||||||
|
function cannons.nodehitparticles(pos,texture)
|
||||||
|
minetest.add_particlespawner(
|
||||||
|
30, --amount
|
||||||
|
0.5, --time
|
||||||
|
{x=pos.x-0.3, y=pos.y+0.3, z=pos.z-0.3}, --minpos
|
||||||
|
{x=pos.x+0.3, y=pos.y+0.5, z=pos.z+0.3}, --maxpos
|
||||||
|
{x=0, y=2, z=0}, --minvel
|
||||||
|
{x=0, y=3, z=0}, --maxvel
|
||||||
|
{x=-4,y=-4,z=-4}, --minacc
|
||||||
|
{x=4,y=-4,z=4}, --maxacc
|
||||||
|
0.1, --minexptime
|
||||||
|
1, --maxexptime
|
||||||
|
1, --minsize
|
||||||
|
3, --maxsize
|
||||||
|
false, --collisiondetection
|
||||||
|
texture --texture
|
||||||
|
)
|
||||||
|
end
|
||||||
function cannons.fire(pos,node,puncher)
|
function cannons.fire(pos,node,puncher)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
@ -137,14 +155,12 @@ function cannons.fire(pos,node,puncher)
|
|||||||
if puncher ~= nil then
|
if puncher ~= nil then
|
||||||
dir=puncher:get_look_dir()
|
dir=puncher:get_look_dir()
|
||||||
meta:set_string("dir", minetest.serialize(dir))
|
meta:set_string("dir", minetest.serialize(dir))
|
||||||
pr(dir)
|
|
||||||
else
|
else
|
||||||
dir = {}
|
dir = {}
|
||||||
dir = minetest.deserialize(meta:get_string("dir"));
|
dir = minetest.deserialize(meta:get_string("dir"));
|
||||||
if dir == nil then
|
if dir == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
pr(dir)
|
|
||||||
end
|
end
|
||||||
minetest.sound_play("cannons_shot",
|
minetest.sound_play("cannons_shot",
|
||||||
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
||||||
@ -159,6 +175,13 @@ function cannons.fire(pos,node,puncher)
|
|||||||
local obj=minetest.env:add_entity(pos, cannons.get_entity(muni.name))
|
local obj=minetest.env:add_entity(pos, cannons.get_entity(muni.name))
|
||||||
obj:setvelocity({x=dir.x*settings.velocity, y=-1, z=dir.z*settings.velocity})
|
obj:setvelocity({x=dir.x*settings.velocity, y=-1, z=dir.z*settings.velocity})
|
||||||
obj:setacceleration({x=dir.x*-3, y=-settings.gravity, z=dir.z*-3})
|
obj:setacceleration({x=dir.x*-3, y=-settings.gravity, z=dir.z*-3})
|
||||||
|
minetest.add_particlespawner(50,0.5,
|
||||||
|
pos, pos,
|
||||||
|
{x=dir.x*settings.velocity, y=-1, z=dir.z*settings.velocity}, {x=dir.x*settings.velocity/2, y=-1, z=dir.z*settings.velocity/2},
|
||||||
|
{x=dir.x*-3/4, y=-settings.gravity*2, z=dir.z*-3/4}, {x=dir.x*-3/2, y=-settings.gravity, z=dir.z*-3/2},
|
||||||
|
0.1, 0.5,--time
|
||||||
|
0.5, 1,
|
||||||
|
false, "cannons_gunpowder.png")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user