mirror of
https://notabug.org/TenPlus1/lucky_block.git
synced 2024-08-21 05:34:14 +02:00
fix mob punch bug and truly randomize block selection
This commit is contained in:
parent
492177287f
commit
2e0a0cd3c7
30
init.lua
30
init.lua
@ -151,6 +151,25 @@ local effect = function(pos, amount, texture, min_size, max_size, radius, gravit
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- temp entity for mob damage
|
||||||
|
minetest.register_entity("lucky_block:temp", {
|
||||||
|
physical = true,
|
||||||
|
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||||
|
visual_size = {x = 0, y = 0},
|
||||||
|
visual = "sprite",
|
||||||
|
textures = {"tnt_smoke.png"},
|
||||||
|
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
|
||||||
|
self.timer = (self.timer or 0) + dtime
|
||||||
|
|
||||||
|
if self.timer > 0.5 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
-- modified from TNT mod to deal entity damage only
|
-- modified from TNT mod to deal entity damage only
|
||||||
local function entity_physics(pos, radius)
|
local function entity_physics(pos, radius)
|
||||||
|
|
||||||
@ -159,6 +178,9 @@ local function entity_physics(pos, radius)
|
|||||||
local objs = minetest.get_objects_inside_radius(pos, radius)
|
local objs = minetest.get_objects_inside_radius(pos, radius)
|
||||||
local obj_pos, dist
|
local obj_pos, dist
|
||||||
|
|
||||||
|
-- add temp entity to cause damage
|
||||||
|
local tmp_ent = minetest.add_entity(pos, "lucky_block:temp")
|
||||||
|
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
|
|
||||||
obj_pos = objs[n]:get_pos()
|
obj_pos = objs[n]:get_pos()
|
||||||
@ -174,13 +196,12 @@ local function entity_physics(pos, radius)
|
|||||||
|
|
||||||
else --if ent.health then
|
else --if ent.health then
|
||||||
|
|
||||||
objs[n]:punch(objs[n], 1.0, {
|
--objs[n]:punch(objs[n], 1.0, {
|
||||||
|
objs[n]:punch(tmp_ent, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = damage},
|
damage_groups = {fleshy = damage},
|
||||||
}, pos)
|
}, pos)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -233,6 +254,9 @@ end
|
|||||||
-- this is what happens when you dig a lucky block
|
-- this is what happens when you dig a lucky block
|
||||||
local lucky_block = function(pos, digger)
|
local lucky_block = function(pos, digger)
|
||||||
|
|
||||||
|
math.randomseed(os.time()) -- make sure it's really random
|
||||||
|
math.random()
|
||||||
|
|
||||||
local luck = math.random(1, #lucky_list) ; -- luck = 1
|
local luck = math.random(1, #lucky_list) ; -- luck = 1
|
||||||
local action = lucky_list[luck][1]
|
local action = lucky_list[luck][1]
|
||||||
local schem
|
local schem
|
||||||
|
Loading…
Reference in New Issue
Block a user