Added the shape "add_entity"
20
appunti
|
@ -15,3 +15,23 @@ Per ogni bomba bisogna definire:
|
|||
Aggiuntivi:
|
||||
-> velocity
|
||||
-> recipe_number
|
||||
|
||||
|
||||
Bombe presenti:
|
||||
mobs_examples.lua:
|
||||
- stone_wall_bomb
|
||||
- Cubic Ice Shell bomb
|
||||
- Fire circle
|
||||
- Lava pool
|
||||
- schematic bomb
|
||||
|
||||
Nssm_weapons:
|
||||
- cobweb_bomb
|
||||
- cubic mantis clay shell bomb
|
||||
-
|
||||
|
||||
nssbombs:register_throwitem("nssm:", "", {
|
||||
textures = "",
|
||||
recipe_number = ,
|
||||
recipe = ,
|
||||
})
|
||||
|
|
118
bombs_api.lua
|
@ -1,25 +1,30 @@
|
|||
function nssbombs:register_throwitem(name, descr, def)
|
||||
|
||||
minetest.register_craftitem("nssbombs:"..name.."_bomb", {
|
||||
minetest.register_craftitem(name, {
|
||||
description = descr,
|
||||
inventory_image = def.textures,
|
||||
on_use = function(itemstack, placer, pointed_thing)
|
||||
local velocity = def.velocity or 15
|
||||
|
||||
local dir = placer:get_look_dir()
|
||||
local playerpos = placer:getpos()
|
||||
local obj = minetest.env:add_entity({x=playerpos.x+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+dir.z}, "nssbombs:"..name.."_bomb_flying")
|
||||
local obj = minetest.add_entity({x=playerpos.x+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+dir.z}, name.."_flying")
|
||||
local vec = {x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}
|
||||
local acc = {x=0, y=-9.8, z=0}
|
||||
|
||||
obj:setvelocity(vec)
|
||||
obj:setacceleration(acc)
|
||||
obj:get_luaentity().placer = placer
|
||||
|
||||
itemstack:take_item()
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_entity("nssbombs:"..name.."_bomb_flying",{
|
||||
minetest.register_entity(name.."_flying",{
|
||||
textures = {def.textures},
|
||||
hp_max = 50,
|
||||
placer = nil,
|
||||
collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1},
|
||||
visual_size = def.visual_size or {x=1, y=1},
|
||||
explosion = def.explosion or {},
|
||||
|
@ -31,13 +36,17 @@ function nssbombs:register_throwitem(name, descr, def)
|
|||
if def.hit_node then
|
||||
def.hit_node(self, pos)
|
||||
else
|
||||
default_hit_node(self, self.explosion, vec)
|
||||
if self.explosion then
|
||||
default_hit_node(self, self.explosion)
|
||||
else
|
||||
minetest.chat_send_player(self.placer, "No hit_node function defined")
|
||||
end
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local recepy
|
||||
if def.recipe_block then
|
||||
recepy = {
|
||||
{def.recipe_block, def.recipe_block, def.recipe_block},
|
||||
|
@ -48,13 +57,14 @@ function nssbombs:register_throwitem(name, descr, def)
|
|||
|
||||
local number = def.recipe_number or 1
|
||||
minetest.register_craft({
|
||||
output = "nssbombs:"..name.."_bomb "..number,
|
||||
output = name.." "..number,
|
||||
type = def.recipe_type or nil,
|
||||
recipe = def.recipe or recepy
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
function perpendicular_vector(vec) --returns a vector rotated of 90° in 2D
|
||||
function perpendicular_vector(vec) --returns a vector rotated of 90° in 2D (x and z directions)
|
||||
local ang = math.pi/2
|
||||
local c = math.cos(ang)
|
||||
local s = math.sin(ang)
|
||||
|
@ -79,10 +89,6 @@ function default_hit_node(self, explosion)
|
|||
center = {x=p.x, y=p.y+radius, z=p.z}
|
||||
end
|
||||
|
||||
if particles then
|
||||
add_effects(center, radius, block)
|
||||
end
|
||||
|
||||
if shape == "cube" then
|
||||
for dx = -radius,radius do
|
||||
for dy = 0,2*radius do
|
||||
|
@ -94,6 +100,17 @@ function default_hit_node(self, explosion)
|
|||
end
|
||||
end
|
||||
end
|
||||
elseif shape == "pool" then
|
||||
for dx = -radius,radius do
|
||||
for dy = -1,0 do
|
||||
for dz = -radius,radius do
|
||||
local pos1 = {x = p.x+dx, y=p.y+dy, z=p.z+dz}
|
||||
if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
|
||||
minetest.set_node(pos1, {name=block})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif shape == "sphere" then
|
||||
for dx = -radius,radius do
|
||||
for dy = 0,2*radius do
|
||||
|
@ -107,12 +124,40 @@ function default_hit_node(self, explosion)
|
|||
end
|
||||
end
|
||||
end
|
||||
elseif shape == "sphere_shell" then
|
||||
for dx = -radius,radius do
|
||||
for dy = 0,2*radius do
|
||||
for dz = -radius,radius do
|
||||
local pos1 = {x = p.x+dx, y=p.y+dy, z=p.z+dz}
|
||||
if round(math.abs(vector.length(vector.subtract(pos1,center)))) == radius then
|
||||
if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
|
||||
minetest.set_node(pos1, {name=block})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif shape == "cubic_shell" then
|
||||
local y = p.y + radius
|
||||
for dx = -radius,radius do
|
||||
for dy = -radius,radius do
|
||||
for dz = -radius,radius do
|
||||
local pos1 = {x = p.x+dx, y=y+dy, z=p.z+dz}
|
||||
if ((math.abs(dz)==radius)or(math.abs(dx)==radius)or(math.abs(dy)==radius)) then
|
||||
--if math.abs(vector.length(vector.subtract(pos1,center))) == radius then
|
||||
if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
|
||||
minetest.set_node(pos1, {name=block})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif shape == "column" then
|
||||
local base_side = 1
|
||||
local base_side = 0
|
||||
if round(radius/4) > 1 then
|
||||
base_side = round(radius/4)
|
||||
end
|
||||
local height = 2*radius
|
||||
local height = radius
|
||||
for dx = -base_side,base_side do
|
||||
for dy = 0,height do
|
||||
for dz = -base_side,base_side do
|
||||
|
@ -126,11 +171,13 @@ function default_hit_node(self, explosion)
|
|||
elseif shape == "circle" then
|
||||
center = {x=p.x, y=p.y+1, z=p.z}
|
||||
for dx = -radius,radius do
|
||||
for dz = -radius,radius do
|
||||
local pos1 = {x = p.x+dx, y=p.y+1, z=p.z+dz}
|
||||
if round(math.abs(vector.length(vector.subtract(pos1,center)))) == radius then
|
||||
if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
|
||||
minetest.set_node(pos1, {name=block})
|
||||
for dy = 0, 1 do
|
||||
for dz = -radius,radius do
|
||||
local pos1 = {x = p.x+dx, y=p.y+1+dy, z=p.z+dz}
|
||||
if round(math.abs(vector.length(vector.subtract(pos1,center)))) == radius then
|
||||
if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
|
||||
minetest.set_node(pos1, {name=block})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -151,12 +198,43 @@ function default_hit_node(self, explosion)
|
|||
if not minetest.is_protected(pp, "") or not minetest.get_item_group(minetest.get_node(pp).name, "unbreakable") == 1 then
|
||||
minetest.set_node(pp, {name=block})
|
||||
end
|
||||
if radius >= 10 then
|
||||
local pp2 = vector.add(pp,vec)
|
||||
if not minetest.is_protected(pp2, "") or not minetest.get_item_group(minetest.get_node(pp2).name, "unbreakable") == 1 then
|
||||
minetest.set_node(pp2, {name=block})
|
||||
end
|
||||
end
|
||||
end
|
||||
p = vector.add(p,pr)
|
||||
end
|
||||
elseif shape == "schematic" then
|
||||
--Adds a defined schematic in the landing position of the bomb
|
||||
minetest.place_schematic(p, block, "0", {}, true)
|
||||
--[[
|
||||
Adds a defined schematic in the landing position of the bomb.
|
||||
If you want the schematic appear with its center in the landing pos of the bomb
|
||||
you have to specify the dimensione of the base of the schematic using
|
||||
explosion.radius parameter
|
||||
--]]
|
||||
if radius then
|
||||
center = {x = p.x - radius/2, y = p.y, z = p.z - radius/2}
|
||||
minetest.place_schematic(center, block, "0", {}, true)
|
||||
else
|
||||
minetest.place_schematic(p, block, "0", {}, true)
|
||||
end
|
||||
elseif shape == "add_entity" then
|
||||
--[[
|
||||
Adds an entity in the landing position.
|
||||
In this case block contains the name of the entity
|
||||
to be added.
|
||||
]]
|
||||
minetest.add_entity(p, block)
|
||||
elseif shape == "tnt_explosion" then
|
||||
tnt.boom(p, {damage_radius=radius,radius=radius,ignore_protection=false})
|
||||
end
|
||||
|
||||
|
||||
|
||||
if particles and block and center and not shape == "tnt_explosion" then
|
||||
add_effects(center, radius, block)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,20 +1,34 @@
|
|||
--Ice bomb
|
||||
nssbombs:register_throwitem("ice", "Ice Bomb", {
|
||||
--Stone Wall bomb
|
||||
nssbombs:register_throwitem("nssbombs:stone_wall_bomb", "Stone Wall Bomb", {
|
||||
textures = "ice_bomb.png",
|
||||
recipe_number = 8,
|
||||
recipe_block = "default:cobble",
|
||||
explosion = {
|
||||
shape = "wall",
|
||||
radius = 10,
|
||||
block = "default:stone",
|
||||
particles = true,
|
||||
},
|
||||
})
|
||||
|
||||
--Cubic Ice Shell bomb
|
||||
nssbombs:register_throwitem("nssbombs:ice_bomb", "Cubic Ice Shell bomb", {
|
||||
textures = "ice_bomb.png",
|
||||
recipe_number = 8,
|
||||
recipe_block = "default:ice",
|
||||
explosion = {
|
||||
shape = "wall",
|
||||
radius = 20,
|
||||
shape = "cubic_shell",
|
||||
radius = 2,
|
||||
block = "default:ice",
|
||||
particles = true,
|
||||
},
|
||||
})
|
||||
|
||||
--Fire bomb
|
||||
nssbombs:register_throwitem("fire", "Fire Bomb", {
|
||||
--Fire Circle bomb
|
||||
nssbombs:register_throwitem("nssbombs:fire_bomb", "Fire Bomb", {
|
||||
textures = "fire_bomb.png",
|
||||
recipe_block = "bucket:lava_bucket",
|
||||
recipe_block = "fire:flint_and_steel",
|
||||
recipe_number = 4,
|
||||
explosion = {
|
||||
shape = "circle",
|
||||
radius = 6,
|
||||
|
@ -23,15 +37,41 @@ nssbombs:register_throwitem("fire", "Fire Bomb", {
|
|||
},
|
||||
})
|
||||
|
||||
--Schematic bomb
|
||||
nssbombs:register_throwitem("schematic", "Schematic Bomb", {
|
||||
textures = "fire_bomb.png",
|
||||
--Lava pool
|
||||
nssbombs:register_throwitem("nssbombs:lava_bomb", "Lava Bomb", {
|
||||
textures = "lava_bomb.png",
|
||||
recipe_block = "bucket:lava_bucket",
|
||||
recipe_number = 3,
|
||||
explosion = {
|
||||
shape = "pool",
|
||||
radius = 2,
|
||||
block = "default:lava_source",
|
||||
particles = false,
|
||||
}
|
||||
})
|
||||
|
||||
--Water column
|
||||
nssbombs:register_throwitem("nssbombs:water_column_bomb", "Water Colun Bomb", {
|
||||
textures = "water_column_bomb.png",
|
||||
recipe_block = "bucket:water_bucket",
|
||||
recipe_number = 6,
|
||||
explosion = {
|
||||
shape = "column",
|
||||
radius = 5,
|
||||
block = "default:water_source",
|
||||
particles = false,
|
||||
}
|
||||
})
|
||||
|
||||
--Schematic bomb
|
||||
nssbombs:register_throwitem("nssbombs:schematic_bomb", "Schematic Bomb", {
|
||||
textures = "fire_bomb.png",
|
||||
recipe_block = "bucket:empty_bucket",
|
||||
explosion = {
|
||||
shape = "schematic",
|
||||
--radius = 5,
|
||||
block = minetest.get_modpath("nssb").."/schems/piccoghiaccio.mts",
|
||||
--particles = true,
|
||||
radius = 9,
|
||||
block = minetest.get_modpath("nssbombs").."/schems/simple_house.mts",
|
||||
particles = true,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
tnt
|
||||
bucket
|
||||
fire
|
||||
|
|
After Width: | Height: | Size: 867 B |
After Width: | Height: | Size: 928 B |
After Width: | Height: | Size: 871 B |
After Width: | Height: | Size: 739 B |
After Width: | Height: | Size: 620 B |
After Width: | Height: | Size: 944 B |
After Width: | Height: | Size: 884 B |
After Width: | Height: | Size: 742 B |
After Width: | Height: | Size: 837 B |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 854 B |
After Width: | Height: | Size: 942 B |
After Width: | Height: | Size: 915 B |
After Width: | Height: | Size: 834 B |
After Width: | Height: | Size: 870 B |
After Width: | Height: | Size: 862 B |
After Width: | Height: | Size: 872 B |
After Width: | Height: | Size: 777 B |
After Width: | Height: | Size: 885 B |
After Width: | Height: | Size: 865 B |