• 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!

GlobalEvent [TFS 1.0] Zombies Event - Waves

EverClaw

New Member
Joined
Apr 26, 2014
Messages
36
Reaction score
4
This is a custom coded zombie event i pieced and collected together to get working.

If you can think of any cool features to add please list!..

LOOKING FOR INFO ON / Additional items to add:
  1. Working Creature Health/Strenght Mod
  2. Relic's - Like the new Aliens C.o.D... Each has a speical bonus and each player chose's there own relic

The Following code should be added to a file named & located:
data/globalevents.xml
Code:
<globalevent name="Zombies Event" time="17:40:00" script="Zombies.lua" />

The Following code should be added to a file named & located:
data/globalevents/scripts/zombies.lua
Code:
local config = {
    beginPos = {x = 846, y = 1048, z = 7},
    temple = {x = 1019, y = 1037, z = 3},
    deathPos = {x = 894, y = 1279, z = 6},
    zombieCount = 2002, -- Global storage for counting the zombies in the event
    counts = 2004, -- Global storage for counting the zombies in the event
    zombieCounter = 2003, -- Global storage for counting the killed zombies in the event
    inGamecheck = 15000, -- Global storage for counting the players
    NumZombieEvents = 2006,
    rounds = 2001,  -- Global storage for counting the rounds
    goblet = 18422, -- id of the gold goblet you'll get when finishing the event.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2160, 10, 1},
    passageKey = "start", -- Talkaction to start Zombies event
    countKey = "count", -- Talkaction to start Zombies event
    startNow = "instastart", -- Talkaction to insta start Zombies event
    zombieName = "rotworm", -- Name of the zombie that should be summoned
    BaseHP = 500,
    fromPos = {x = 498, y = 1006, z = 4}, -- Waiting Room
    toPos = {x = 502, y = 1008, z = 4}, -- Waiting Room
    areaFromPos = {x = 823, y = 1032, z = 7, stackpos = 253}, -- Arena to see zombies killed in
    areaToPos = {x = 870, y = 1067, z = 7, stackpos = 253},       -- Arena to see zombies killed in
    zombiesFromPos = {x = 834, y = 1040, z = 7}, -- Arena to Spawn Zombies within
    zombiesToPos = {x = 860, y = 1057, z = 7},       -- Arena to Spawn Zombies within
    message = "You killed a Zombie",
}

local function endingEvent()
    local players = Game.getPlayers()
    for k, tmpPlayer in ipairs(players) do
        local player = getPlayerByName(tmpPlayer:getName())
        if isInRange(getThingPos(player), config.areaFromPos, config.areaToPos) then
            if isPlayer(player) then
                doPlayerSendTextMessage(player, MESSAGE_EVENT_ADVANCE, "You have just survived " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! That was the last wave!")
                setGlobalStorageValue(config.rounds, 0)
                setGlobalStorageValue(config.zombieCount, 0)
                setGlobalStorageValue(config.zombieCounter, 0)
                setPlayerStorageValue(player, config.inGamecheck, 0)
                broadcastMessage("The Zombies have been slayed! Congratz, thoes who lived won: 1 Event Tokens & 10 Event Points. Thoes who died earned 5 Event Points.", MESSAGE_STATUS_WARNING)
                local goblet = doCreateItem(player, 1, config.goblet)
                doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(player) .. " for surviving the Zombie event.")
                doSendMagicEffect(getPlayerPosition(player), CONST_ME_POFF)
                doTeleportThing(player, config.temple, true)
                doSendMagicEffect(getPlayerPosition(player), CONST_ME_TELEPORT)
                for _,items in ipairs(config.moneyReward) do
                    if config.moneyReward[3] == 1 then
                        doPlayerAddItem(player, config.moneyReward[1], config.moneyReward[2])
                    end
                end
            end
        end
        setGlobalStorageValue(config.zombieCount, 0)
    end
    return true
end

local function zombieSpawn()
    if (getGlobalStorageValue(config.zombieCount) <= 9) then

        --Removes All the Zombies in the Current Area.
        for x = config.areaFromPos.x, config.areaToPos.x do
            for y = config.areaFromPos.y, config.areaToPos.y do
                for z = config.areaFromPos.z, config.areaToPos.z do
                    pos = {x = x, y = y, z = z, stackpos = 253}
                    creature = getThingfromPos(pos)
                    if isMonster(creature.uid) then
                        doRemoveCreature(creature.uid)
                    end
                end
            end
        end

        -- Summons The Zombies Inside the Arena.
        while (getGlobalStorageValue(config.zombieCount) <= 10) do
            pos = {x = math.random(config.zombiesFromPos.x, config.zombiesToPos.x), y = math.random(config.zombiesFromPos.y, config.zombiesToPos.y), z = math.random(config.zombiesFromPos.z, config.zombiesToPos.z)}
            local zombiemonster = doForceSummonCreature(config.zombieName, pos)
            doCreatureAddHealth(zombiemonster, config.BaseHP*getGlobalStorageValue(config.rounds))
            doSendMagicEffect(pos, CONST_ME_MORTAREA)
            setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
            setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
        end

        -- Add the Spawn To Check if All Zombies Have Been Spawned, or Have all Been Killed.
        addEvent(zombieSpawn, 1 * 1000)
    else

        -- IF Player is inside Arena, Tell Wave Completion's
        for x = config.zombiesFromPos.x, config.zombiesToPos.x do
            for y = config.zombiesFromPos.y, config.zombiesToPos.y do
                for z = config.zombiesFromPos.z, config.zombiesToPos.z do
                    areapos = {x = x, y = y, z = z, stackpos = 253}
                    getPlayers = getThingfromPos(areapos)
                    if (isPlayer(getPlayers.uid)) then
                        if (getGlobalStorageValue(config.zombieCounter) <= 0) then
                            if (getGlobalStorageValue(config.rounds) == 0) then
                                doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed the first wave of zombies. Good Job Man! The next Wave is about to begin!")
                                setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                setGlobalStorageValue(config.zombieCount, 0)
                                setGlobalStorageValue(config.zombieCounter, 0)
                            elseif (getGlobalStorageValue(config.rounds) <= config.Total_Waves and getGlobalStorageValue(config.rounds) > 0) then
                                doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just completed " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! The next Wave is about to begin!")
                                setGlobalStorageValue(config.rounds, getGlobalStorageValue(config.rounds)+1)
                                setGlobalStorageValue(config.zombieCount, 0)
                                setGlobalStorageValue(config.zombieCounter, 0)
                            elseif (getGlobalStorageValue(config.rounds) > config.Total_Waves) then
                                addEvent(endingEvent, 1 * 1000)
                                return true
                            end
                        end
                    end
                end
            end
        end
    
        -- Add the Spawn To Check if All Zombies Have Been Spawned, or Have all Been Killed.
        addEvent(zombieSpawn, 1 * 1000)
        return true
    end
end

local function startEvent()
    local players = Game.getPlayers()
    for k, tmpPlayer in ipairs(players) do
        local player = getPlayerByName(tmpPlayer:getName())
        if isInRange(getThingPos(player), config.fromPos, config.toPos) then
            doTeleportThing(player, config.beginPos, true)
            setPlayerStorageValue(player, config.inGamecheck, 1)
            doPlayerSendTextMessage(player, MESSAGE_EVENT_ADVANCE, "The First round has began!")
            addEvent(zombieSpawn, 1 * 1000)
        else
            broadcastMessage(" The Zombies event has been canceled due to the lack of players.", MESSAGE_STATUS_WARNING)
        end
    end
end

local function Zombie_broadcasting()
    addEvent(broadcastMessage, 5 * 1000, "[Zombies Event] will begin in 3 minutes.", MESSAGE_STATUS_WARNING)
    addEvent(broadcastMessage, 10 * 1000, "[Zombies Event] will begin in 1 minute. Hurry up to the Mini-Game Waiting Room!", MESSAGE_STATUS_WARNING)
    addEvent(broadcastMessage, 15 * 1000, "[Zombies Event] has started.", MESSAGE_STATUS_WARNING)
    setGlobalStorageValue(config.NumZombieEvents, getGlobalStorageValue(config.NumZombieEvents)+1)
    addEvent(startEvent, 16 * 1000)
end

function onTime(interval)
    broadcastMessage("[Zombies Event] will begin in 5 minutes.", MESSAGE_STATUS_WARNING)
    setGlobalStorageValue(config.zombieCount, 0)
    setGlobalStorageValue(config.zombieCounter, 0)
    setGlobalStorageValue(config.rounds, 0)
    setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
    addEvent(Zombie_broadcasting, 1 * 1000)
    return true
end
 
Last edited:
Seems like your looking for a free-be handout, if you know a single thing about coding, you could determine that the file is a globalevent, due to the fact it has a Onthink function...


But alright ill make it EVER EASIER for you all xD

Main Post Has been edited to include more information.. The Script itself isn't really all that un-self explanatory!
 
Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/globalevents/scripts/zombies.lua:77: attempt to call global 'doForceSummonCreature' (a nil value)
stack traceback:
        [C]: in function 'doForceSummonCreature'
        data/globalevents/scripts/zombies.lua:77: in function <data/globalevents/scripts/zombies.lua:58>
 
Back
Top