dynamite added:

This commit is contained in:
Kacper Kostka 2023-02-03 18:13:48 +01:00
parent 98a97f4aee
commit 4c21c72aba
3 changed files with 89 additions and 2 deletions

View File

@ -1,3 +1,3 @@
-- Load the entity's lua file
dofile(minetest.get_modpath("amogus_entities") .. "/entities/amogus_entity.lua")
dofile(minetest.get_modpath("amogus_entities") .. "/entities/mini_crewmate_entity.lua")
dofile(minetest.get_modpath("amogus_entities") .. "/entities/mini_crewmate_entity.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

View File

@ -15,6 +15,32 @@ minetest.register_item(":", { -- Hand
damage_groups = {fleshy = 1, snappy = 1, cracky=1},
}
})
local function explode(pos, radius)
local objects = minetest.get_objects_inside_radius(pos, radius)
for _, obj in pairs(objects) do
local obj_pos = obj:get_pos()
local dir = vector.normalize(vector.subtract(obj_pos, pos))
obj:set_velocity(vector.multiply(dir, 10))
obj:punch(obj, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 4},
})
end
for x = -radius, radius do
for y = -radius, radius do
for z = -radius, radius do
local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
local d = vector.distance(pos, p)
if d <= radius then
minetest.remove_node(p)
end
end
end
end
end
minetest.register_craftitem("amogus_items:amogus", {
description = "Mini Amogus friend",
inventory_image = "amogus_item.png",
@ -335,4 +361,65 @@ minetest.register_tool("amogus_items:obsussian_hammer", {
},
groups = {flammable = 2}
})
})
minetest.register_craftitem("amogus_items:pcb", {
description = "PCB",
inventory_image = "PCB.png",
})
minetest.register_craftitem("amogus_items:capacitor", {
description = "Capacitor",
inventory_image = "capacitor.png",
})
minetest.register_craftitem("amogus_items:sugar", {
description = "Sugar",
inventory_image = "sugar.png",
})
minetest.register_craftitem("amogus_items:iron_ingot", {
description = "Iron Ingot",
inventory_image = "iron_ingot.png",
})
minetest.register_tool("amogus_items:dynamite", {
description = "dynamite",
inventory_image = "dynamite.png",
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local pos = pointed_thing.above
minetest.add_entity(pos, "amogus_items:dynamite_entity")
end
return itemstack
end
})
minetest.register_entity("amogus_items:dynamite_entity", {
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "sprite",
textures = {"dynamite.png"},
on_step = function(self, dtime)
local pos = self.object:get_pos()
explode(pos,5)
minetest.add_particlespawner({
amount = 2900,
time = 0.5,
-- create 15 block radius of particles
minpos = {x=pos.x-5, y=pos.y-5, z=pos.z-5},
maxpos = {x=pos.x+5, y=pos.y+5, z=pos.z+5},
minvel = {x=-2, y=-2, z=-2},
maxvel = {x=2, y=2, z=2},
minacc = {x=0, y=-10, z=0},
maxacc = {x=0, y=-10, z=0},
minexptime = 1,
maxexptime = 3,
minsize = 1,
maxsize = 2,
texture = "plasma_effect.png",
})
self.object:remove()
end
})