• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Kill 1000 monsters, spawn boss

Deepling

Just a spammer
Joined
Jun 29, 2015
Messages
1,835
Solutions
1
Reaction score
555
Location
Poland
Hello

I would like to request script that makes boss <ex. Mad Mage> (coords: 33348, 31901, 9) spawn when player killed 1000 monsters <Golden Servant/Diamond Servant/Iron Servant> with kill amount counter in Default chat. After killing 1000 servants kill counter restarts and need to kill 1000 servants again in order to spawn another Mad Mage.

Thanks!
 
Hello

I would like to request script that makes boss <ex. Mad Mage> (coords: 33348, 31901, 9) spawn when player killed 1000 monsters <Golden Servant/Diamond Servant/Iron Servant> with kill amount counter in Default chat. After killing 1000 servants kill counter restarts and need to kill 1000 servants again in order to spawn another Mad Mage.

Thanks!
Lua:
local monsters = {
    ['Golden Servant'] = {key = 2000, bossName = "Mad Mage", bossPos = Position(33348, 31901, 9), killsNeeded = 1000},
    ['Diamond Servant'] = {key = 2001, bossName = "Mad Mage", bossPos = Position(33348, 31901, 9), killsNeeded = 1000},
    ['Iron Servant'] = {key = 2002, bossName = "Mad Mage", bossPos = Position(33348, 31901, 9), killsNeeded = 1000}
}
  
function setCreatureKillCount(key, count)
    Game.setStorageValue(key, count)
end

function getCreatureKillCount(key)
    return Game.getStorageValue(key)
end

function onKill(creature, target)
    local monster = monsters[target:getName()]
    if monster and creature:isPlayer() then
        local count = getCreatureKillCount(monster.key)
        if count >= monster.killsNeeded then
            if Game.createMonster(monster.bossName, monster.bossPos) then
                setCreatureKillCount(monster.key, 0)
                creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have summoned "..monster.bossName..".")
            end
        else
            local total = count + 1
            setCreatureKillCount(monster.key, total)
            creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have killed ("..total.."/"..(monster.killsNeeded)..") "..target:getName()..".")
        end
    end
    return true
end
 
Last edited:
Lua:
local monsters = {
    ['Golden Servant'] = {key = 2000, bossName = "Mad Mage", bossPos = Position(33348, 31901, 9), killsNeeded = 1000},
    ['Diamond Servant'] = {key = 2001, bossName = "Mad Mage", bossPos = Position(33348, 31901, 9), killsNeeded = 1000},
    ['Iron Servant'] = {key = 2002, bossName = "Mad Mage", bossPos = Position(33348, 31901, 9), killsNeeded = 1000}
}
 
function setCreatureKillCount(key, count)
    Game.setStorageValue(key, count)
end

function getCreatureKillCount(key)
    return Game.getStorageValue(key)
end

function onKill(creature, target)
    local monster = monsters[target:getName()]
    if monster and creature:isPlayer() then
        local count = getCreatureKillCount(monster.key)
        if count >= monster.killsNeeded then
            if Game.createMonster(monster.bossName, monster.bossPos) then
                setCreatureKillCount(monster.key, 0)
                creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have summoned "..monster.bossName..".")
            end
        else
            local total = count + 1
            setCreatureKillCount(monster.key, total)
            creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have killed ("..total.."/"..(monster.killsNeeded)..") "..target:getName()..".")
        end
    end
    return true
end
It doesn't work. When you kill 1000 monsters monster doesn't spawn, also doesn't send message on World Chat
No errors in console.

That's what I've put in creaturescripts.xml :
<event type="kill" name="Mad Mage" script="madmage.lua"/>
 
Code:
local magePositions = {
    Position(33328, 31859, 9),
    Position(33367, 31873, 9),
    Position(33349, 31899, 9)
}

local positions = {
    Position(33313, 31852, 9),
    Position(33313, 31865, 9),
    Position(33313, 31881, 9),
    Position(33328, 31860, 9),
    Position(33328, 31873, 9),
    Position(33328, 31885, 9),
    Position(33308, 31873, 9),
    Position(33320, 31873, 9),
    Position(33335, 31873, 9),
    Position(33360, 31873, 9),
    Position(33336, 31914, 9),
    Position(33343, 31914, 9),
    Position(33353, 31914, 9),
    Position(33361, 31914, 9),
    Position(33345, 31900, 9),
    Position(33352, 31900, 9),
    Position(33355, 31854, 9),
    Position(33355, 31861, 9),
    Position(33355, 31885, 9),
    Position(33345, 31864, 9),
    Position(33345, 31881, 9),
    Position(33309, 31867, 9),
    Position(33317, 31879, 9),
    Position(33311, 31854, 9),
    Position(33334, 31889, 9),
    Position(33340, 31890, 9),
    Position(33347, 31889, 9)
}

local servants = {
    'iron servant',
    'golden servant',
    'diamond servant'
}

local function fillFungus(fromPosition, toPosition)
    for x = fromPosition.x, toPosition.x do
        for y = fromPosition.y, toPosition.y do
            local position = Position(x, y, 9)
            local tile = Tile(position)
            if tile then
                local item = tile:getItemById(13590)
                if item then
                    item:transform(math.random(13585, 13589))
                    position:sendMagicEffect(CONST_ME_YELLOW_RINGS)
                end
            end
        end
    end
end

local function summonServant(position)
    Game.createMonster(servants[math.random(#servants)], position)
    position:sendMagicEffect(CONST_ME_TELEPORT)
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if not isInArray(servants, targetMonster:getName():lower()) then
        return true
    end

    local wave, killedAmount = Game.getStorageValue(GlobalStorage.TheirMastersVoice.CurrentServantWave), Game.getStorageValue(GlobalStorage.TheirMastersVoice.ServantsKilled)
    if killedAmount == #positions and wave < 25 then
        Game.setStorageValue(GlobalStorage.TheirMastersVoice.ServantsKilled, 0)
        Game.setStorageValue(GlobalStorage.TheirMastersVoice.CurrentServantWave, wave + 1)

        for i = 1, #positions do
            addEvent(summonServant, 5 * 1000, positions[i])
        end

    elseif killedAmount < #positions and wave < 25 then
        Game.setStorageValue(GlobalStorage.TheirMastersVoice.ServantsKilled, killedAmount + 1)

    elseif killedAmount == #positions and wave == 25 then
        Game.createMonster('mad mage', magePositions[math.random(#magePositions)])
        targetMonster:say('The Mad Mage has been spawned!', TALKTYPE_MONSTER_SAY)
        fillFungus({x = 33306, y = 31847}, {x = 33369, y = 31919})
    end
    return true
end

It works on my tfs 1.3, so im using same script for the raging mage changing name of monsters, boss and xyz position.
:p
 
Code:
onKill creaturescript
local killedMonsters = Game.getStorageValue(MonstersStorage)

if creature:getName:lower ~= "monster name" then
return false
end

Game.setStorageValue(monstersStorage, killedMonsters + 1)

if killedMonsters >= 1000 then
Game.createMonster("name", pos")
Game.setStorageValue(monstersStorage, 0)
end

Thats just an example how can you get it done. Have fun(wrote it on the phone so no indendation)
 
Code:
onKill creaturescript
local killedMonsters = Game.getStorageValue(MonstersStorage)

if creature:getName:lower ~= "monster name" then
return false
end

Game.setStorageValue(monstersStorage, killedMonsters + 1)

if killedMonsters >= 1000 then
Game.createMonster("name", pos")
Game.setStorageValue(monstersStorage, 0)
end

Thats just an example how can you get it done. Have fun(wrote it on the phone so no indendation)
I also want it to display on default chat and support more monsters (Iron Servant, Golden Servant, Diamond Servant)
 
Back
Top