<commit_before>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.
]]
--ID 107, Mummy of Madness, Level: 2, Armourtype: -, Weapontype: slashing

local mummies = require("monster.race_10_mummy.base")
local M = mummies.generateCallbacks()

local function isSpecialTime()
    if world:getTime("month") == 16 then
        return true -- It is Mas!
    end
    local hour = world:getTime("hour")
    -- "Special time" from 20:00 to 3:59
    return hour >= 20 or hour <= 3
end

local function spawnNewMummy(pos)
    local newMummy = world:createMonster(107, pos, 0)
    if newMummy ~= nil and isValidChar(newMummy) then
        world:gfx(5, newMummy.pos);
    end
end

-- The mummy of madness needs to spawn two new monsters of the same kind upon it's death.
local orgOnDeath = M.onDeath

function M.onDeath(monster)
    if isSpecialTime() then
        -- Special time! Respawn two new mummies to create more fun!
        for _ = 1, 2 do
            spawnNewMummy(monster.pos)
        end
    elseif orgOnDeath ~= nil then
        -- normal death, with drops and everything. Only in case the mummy is really killed.
        orgOnDeath(monster)
    end
end

return M<commit_msg>Fixing clean up for mummy of madness<commit_after>--[[
Illarion Server

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
details.

You should have received a copy of the GNU Affero General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.
]]
--ID 107, Mummy of Madness, Level: 2, Armourtype: -, Weapontype: slashing

local base = require("monster.base.base")
local mummies = require("monster.race_10_mummy.base")
local M = mummies.generateCallbacks()

local function isSpecialTime()
    if world:getTime("month") == 16 then
        return true -- It is Mas!
    end
    local hour = world:getTime("hour")
    -- "Special time" from 20:00 to 3:59
    return hour >= 20 or hour <= 3
end

local function spawnNewMummy(pos)
    local newMummy = world:createMonster(107, pos, 0)
    if newMummy ~= nil and isValidChar(newMummy) then
        world:gfx(5, newMummy.pos);
    end
end

-- The mummy of madness needs to spawn two new monsters of the same kind upon it's death.
local orgOnDeath = M.onDeath

function M.onDeath(monster)
    if isSpecialTime() then
        -- Special time! Respawn two new mummies to create more fun!
        for _ = 1, 2 do
            spawnNewMummy(monster.pos)
        end
        base.setNoDrop(monster)
    end

    if orgOnDeath ~= nil then
        orgOnDeath(monster)
    end
end

return M
{'fraction_non_alphanumeric': 0.0733764408209165, 'fraction_numerical': 0.014619061006466124, 'mean_word_length': 3.3284671532846715, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4215891', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1035, 'n_words': 460}