1
0
Fork 0

Merge pull request 'performance_fix_raids' (#3092) from performance_fix_raids into release/0.81.1

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3092
Increases performance.
Tested by myself, and by other players.
release/0.81.1
Michieal 2022-12-11 23:29:13 +00:00
commit 997b6875a2
4 changed files with 33 additions and 14 deletions

View File

@ -102,6 +102,7 @@ function check_events(dtime)
for _,e in pairs(mcl_events.registered_events) do
local pp = e.cond_start()
if pp then
--minetest.log("It's gonna start the raid maybe")
for _,p in pairs(pp) do
local start = true
if e.exclusive_to_area then
@ -110,11 +111,14 @@ function check_events(dtime)
end
end
if start then
--minetest.log("It's gonna start the raid definitely")
start_event(p,e)
elseif DBG then
mcl_log("[mcl_events] Event "..e.readable_name.." already active at "..minetest.pos_to_string(vector.round(p.pos)))
end
end
else
--minetest.log("Do not start this raid")
end
end
for idx,ae in pairs(active_events) do

View File

@ -471,7 +471,7 @@ local set_yaw = function(self, yaw, delay, dtime)
if self.shaking and dtime then
yaw = yaw + (random() * 2 - 1) * 5 * dtime
end
update_roll(self)
--update_roll(self)
return yaw
end
@ -822,7 +822,7 @@ local update_tag = function(self)
nametag = tag,
})
update_roll(self)
--update_roll(self)
end
-- drop items
@ -4457,7 +4457,7 @@ local mob_step = function(self, dtime)
yaw = yaw + (random() * 2 - 1) * 5 * dtime
end
self.object:set_yaw(yaw)
update_roll(self)
--update_roll(self)
end
-- end rotation

View File

@ -217,7 +217,7 @@ function mcl_raids.find_villager(pos)
end
function mcl_raids.find_bed(pos)
return minetest.find_node_near(pos,128,{"mcl_beds:bed_red_bottom"})
return minetest.find_node_near(pos,32,{"mcl_beds:bed_red_bottom"})
end
function mcl_raids.find_village(pos)
@ -292,11 +292,13 @@ mcl_events.register_event("raid",{
exclusive_to_area = 128,
enable_bossbar = true,
cond_start = function(self)
--minetest.log("Cond start raid")
local r = {}
for _,p in pairs(minetest.get_connected_players()) do
if mcl_potions.player_has_effect(p,"bad_omen") then
local raid_pos = mcl_raids.find_village(p:get_pos())
if raid_pos then
--minetest.log("We have a raid position. Start raid")
table.insert(r,{ player = p:get_player_name(), pos = raid_pos })
end
end

View File

@ -10,10 +10,14 @@ local function spawn_zombies(self)
local p = vector.offset(nn[i%#nn],0,1,0)
if check_spawn_pos(p) then
local m = mcl_mobs.spawn(p,"mobs_mc:zombie")
local l = m:get_luaentity()
mcl_mobs:gopath(m:get_luaentity(),self.pos)
table.insert(self.mobs,m)
self.health_max = self.health_max + l.health
if m then
local l = m:get_luaentity()
mcl_mobs:gopath(m:get_luaentity(), self.pos)
table.insert(self.mobs, m)
self.health_max = self.health_max + l.health
else
--minetest.log("Failed to spawn zombie at location: " .. minetest.pos_to_string(p))
end
end
end
end
@ -26,15 +30,24 @@ mcl_events.register_event("zombie_siege",{
exclusive_to_area = 128,
enable_bossbar = false,
cond_start = function(self)
--minetest.log("Cond start zs")
local r = {}
local t = minetest.get_timeofday()
local pr = PseudoRandom(minetest.get_day_count())
local rnd = pr:next(1,10)
local t = minetest.get_timeofday()
local r = {}
for _,p in pairs(minetest.get_connected_players()) do
local village = mcl_raids.find_village(p:get_pos())
if t < 0.04 and village and rnd == 1 then
table.insert(r,{ player = p:get_player_name(), pos = village})
if t < 0.04 and rnd == 1 then
--minetest.log("Well, it's siege time")
for _,p in pairs(minetest.get_connected_players()) do
local village = mcl_raids.find_village(p:get_pos())
if village then
--minetest.log("Found village")
table.insert(r,{ player = p:get_player_name(), pos = village})
end
end
else
--minetest.log("Not night for a siege, or not success")
end
if #r > 0 then return r end
end,