cannons/cannonballs.lua

240 lines
6.7 KiB
Lua
Raw Normal View History

2013-10-12 12:24:24 +02:00
--++++++++++++++++++++++++++++++++++++
--+ Meseball +
--++++++++++++++++++++++++++++++++++++
local exploding={
2013-10-12 12:24:24 +02:00
physical = false,
timer=0,
textures = {"default_mese_block.png","default_mese_block.png","default_mese_block.png","default_mese_block.png","default_mese_block.png","default_mese_block.png"},
lastpos={},
damage=15,
visual = "cube",
visual_size = {x=0.5, y=0.5},
range=1,
gravity=10,
velocity=30,
name="cannons:exploding_bullet",
2013-10-12 12:24:24 +02:00
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
on_player_hit = function(self,pos,player)
local playername = player:get_player_name()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_mob_hit = function(self,pos,mob)
mob:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_node_hit = function(self,pos,node)
cannons.nodehitparticles(pos,minetest.registered_nodes[node.name].tiles[1])
2013-11-13 17:42:48 +01:00
cannons.destroy({x=pos.x, y=pos.y, z=pos.z},self.range)
minetest.sound_play("cannons_shot",
2013-10-12 12:24:24 +02:00
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
end,
}
2013-11-13 17:42:48 +01:00
if cannons.enable_explosion then
cannons.register_muni("cannons:ball_exploding",exploding)
2013-10-12 12:24:24 +02:00
end
local fire={
2013-10-12 12:24:24 +02:00
physical = false,
timer=0,
textures = {"default_tree.png","default_tree.png","default_tree.png","default_tree.png","default_tree.png","default_tree.png"},
lastpos={},
damage=10,
visual = "cube",
visual_size = {x=0.5, y=0.5},
range=2,
gravity=8,
velocity=35,
name="cannons:fire_bullet",
2013-10-12 12:24:24 +02:00
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
on_player_hit = function(self,pos,player)
local playername = player:get_player_name()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_mob_hit = function(self,pos,mob)
self.object:remove()
end,
on_node_hit = function(self,pos,node)
cannons.nodehitparticles(pos,node)
2013-10-12 12:24:24 +02:00
pos = self.lastpos
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="fire:basic_flame"})
minetest.sound_play("default_break_glass",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
end,
}
2013-11-13 17:42:48 +01:00
if cannons.enable_fire then
cannons.register_muni("cannons:ball_fire",fire)
2013-10-12 12:24:24 +02:00
end
--++++++++++++++++++++++++++++++++++++
--+ Wooden Cannon ball +
--++++++++++++++++++++++++++++++++++++
local ball_wood={
physical = false,
timer=0,
2013-11-13 17:42:48 +01:00
textures = {"cannons_wood_bullet.png"},
lastpos={},
damage=20,
range=1,
gravity=10,
velocity=40,
2013-11-13 17:42:48 +01:00
name="cannons:wood_bullet",
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
on_player_hit = function(self,pos,player)
local playername = player:get_player_name()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
2013-11-13 17:42:48 +01:00
minetest.chat_send_all(playername .." tried to catch a cannonball")
end,
on_mob_hit = function(self,pos,mob)
mob:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_node_hit = function(self,pos,node)
cannons.nodehitparticles(pos,node)
if node.name == "default:dirt_with_grass" then
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
elseif node.name == "default:water_source" then
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_splash",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
else
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
end
end,
}
2013-11-13 17:42:48 +01:00
cannons.register_muni("cannons:ball_wood",ball_wood)
--++++++++++++++++++++++++++++++++++++
--+ Stone Cannon ball +
--++++++++++++++++++++++++++++++++++++
local ball_stone={
physical = false,
timer=0,
2013-11-13 17:42:48 +01:00
textures = {"cannons_bullet.png"},
lastpos={},
damage=20,
range=2,
gravity=10,
velocity=40,
2013-11-13 17:42:48 +01:00
name="cannons:stone_bullet",
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
on_player_hit = function(self,pos,player)
local playername = player:get_player_name()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
2013-11-13 17:42:48 +01:00
minetest.chat_send_all(playername .." tried to catch a cannonball")
end,
on_mob_hit = function(self,pos,mob)
mob:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_node_hit = function(self,pos,node)
cannons.nodehitparticles(pos,node)
if node.name == "default:dirt_with_grass" then
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
elseif node.name == "default:water_source" then
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_splash",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
else
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
end
end,
}
2013-11-13 17:42:48 +01:00
cannons.register_muni("cannons:ball_stone",ball_stone)
--++++++++++++++++++++++++++++++++++++
--+ Steel Cannon ball +
--++++++++++++++++++++++++++++++++++++
local ball_steel={
physical = false,
timer=0,
2013-11-13 17:42:48 +01:00
textures = {"cannons_bullet_iron.png"},
lastpos={},
damage=30,
range=2,
gravity=5,
velocity=50,
2013-11-13 17:42:48 +01:00
name="cannons:iron_bullet",
collisionbox = {-0.25,-0.25,-0.25, 0.25,0.25,0.25},
on_player_hit = function(self,pos,player)
local playername = player:get_player_name()
player:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
minetest.chat_send_all(playername .." tried to catch a canonball")
end,
on_mob_hit = function(self,pos,mob)
mob:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.damage},
}, nil)
self.object:remove()
end,
on_node_hit = function(self,pos,node)
cannons.nodehitparticles(pos,node)
if node.name == "default:dirt_with_grass" then
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z},{name="default:dirt"})
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
elseif node.name == "default:water_source" then
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_splash",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
else
2013-11-13 17:42:48 +01:00
minetest.sound_play("cannons_hit",
{pos = pos, gain = 1.0, max_hear_distance = 32,})
self.object:remove()
end
end,
}
cannons.register_muni("cannons:ball_steel",ball_steel)