Hello,
well this is a update on my old Zombie event. Since the old one, was bit buggy and was bit messy.
Features:
Now into data/creaturescripts/scripts and create new lua and name it "zombieEventDeath.lua" and paste:
Paste these lines into data/movements/movements.xml:
Now in data/movements/scripts, create new lua and name it "zombieEventTeleport" and paste below:
Paste this into data/talkactions/talkactions.xml:
Now in data/talkactions/scripts, name it "zombieEventCommands" and paste this below:
Now go to data/global.lua and paste this:
Now create inside data folder a lua and name it "zombieEvent.lua" and paste this:
http://pastebin.com/frkjmi1v
Here is the monster file, make sure name it "Zombie Event.xml":
http://pastebin.com/3qMib0QG
Make sure add no-logout zone on the waiting room and also on the Zombie event arena.
well this is a update on my old Zombie event. Since the old one, was bit buggy and was bit messy.
Features:
- Highly optimized, with no intense onThink events!
- Min players/Max players/Max Zombies!
- Zombie does not get summoned into walls!
- Automatic Start through globalevent or command!
- Join on teleport or command!
- Zombie Count and Kill Count!
- 3 Trophy rewards with description and date!
Code:
<!-- Zombie Event -->
<event type="preparedeath" name="ZombiePlayerDeath" script="player/zombieEventDeath.lua" />
<event type="death" name="ZombieOnDeath" script="player/zombieEventDeath.lua" />
Now into data/creaturescripts/scripts and create new lua and name it "zombieEventDeath.lua" and paste:
Code:
function onDeath(monster, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
-- Send text and effect
monster:say("I WILL BE BACK!", TALKTYPE_MONSTER_YELL)
monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA)
-- Remove zombie count, when it dies
Game.setStorageValue(ze_zombieCountGlobalStorage, getZombieEventZombieCount() - 1)
-- Store player kills
local killerId = killer:getId()
if zombieKillCount[killerId] ~= nil then
zombieKillCount[killerId] = zombieKillCount[killerId] + 1
else
zombieKillCount[killerId] = 1
end
return true
end
function onPrepareDeath(player, killer)
-- Remove player from count
local count = getZombieEventJoinedCount()
Game.setStorageValue(ze_joinCountGlobalStorage, count - 1)
-- Reset player after death
player:teleportTo(player:getTown():getTemplePosition())
player:setStorageValue(ze_joinStorage, 0)
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
player:unregisterEvent("ZombiePlayerDeath")
-- Let's reward the 3 last players
if count <= 3 then
local playerName = player:getName()
local trophy = ze_trophiesTable[count]
local item = player:addItem(trophy.itemid, 1)
if item then
item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("%s %s\n%s.", playerName, trophy.description, os.date("%x")))
end
-- Store kill count and remove from table to avoid memory leak
local playerId, killCount = player:getId(), 0
if zombieKillCount[playerId] ~= nil then
killCount = zombieKillCount[playerId]
zombieKillCount[playerId] = nil
end
-- Broadcast
Game.broadcastMessage(string.format("%d place goes to %s of Zombie Event versus %d Zombies and slained %d Zombies.", count, playerName, getZombieEventZombieCount(), killCount))
-- The last player died, let's reset the event
if count <= 1 then
resetZombieEvent()
end
end
return false
end
Paste these lines into data/movements/movements.xml:
Code:
<!-- Zombie Event -->
<movevent event="StepIn" actionid="7000" script="zombieEventTeleport.lua" />
Now in data/movements/scripts, create new lua and name it "zombieEventTeleport" and paste below:
Code:
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player == nil then
return true
end
-- If it's a staff memeber, just teleport inside and do not count as participant
if player:getGroup():getAccess() then
player:teleportTo(ze_WaitingRoomStartPosition)
return true
end
-- If the event state is closed or started, then stop players from enter
if isInArray({ze_EVENT_CLOSED, ze_EVENT_STARTED}, getZombieEventState()) then
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end
-- Check if the event has already max players
if getZombieEventJoinedCount() >= ze_maxPlayers then
player:sendTextMessage(MESSAGE_INFO_DESCR, "The Zombie Event is already full.")
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end
-- Execute join event
player:joinZombieEvent()
return true
end
Paste this into data/talkactions/talkactions.xml:
Code:
<talkaction words="!zombie" separator=" " script="zombieEventCommands.lua" />
Now in data/talkactions/scripts, name it "zombieEventCommands" and paste this below:
Code:
function onSay(player, words, param)
local split = param:split(",")
if split[1] == "join" then
-- If it's a staff member, just teleport inside and do not count as a participant
if player:getGroup():getAccess() then
player:teleportTo(ze_WaitingRoomStartPosition)
return false
end
-- If the state of the event is closed or started, stop them from join
if isInArray({ze_EVENT_CLOSED, ze_EVENT_STARTED}, getZombieEventState()) then
return false
end
-- If player got pz, forbid them to join
if player:isPzLocked() then
player:sendCancelMessage("You cannot join while your in a fight.")
return false
end
-- If there is max players joined, stop them from join
if getZombieEventJoinedCount() >= ze_maxPlayers then
player:sendCancelMessage("The event is already full.")
return false
end
-- Execute join event
player:joinZombieEvent()
elseif split[1] == "start" then
-- If not staff member, they stop them from setup a event
if not player:getGroup():getAccess() then
return false
end
local minPlayers = tonumber(split[2])
local maxPlayers = tonumber(split[3])
local waitTime = tonumber(split[4])
local failStart = false
if minPlayers == nil or minPlayers < 1 then
failStart = true
elseif maxPlayers == nil or maxPlayers > Game.getPlayerCount() then
failStart = true
elseif waitTime == nil or waitTime < 1 then
failStart = true
end
if failStart then
player:sendCancelMessage("!zombie start, [minPlayers, maxPlayers, waitTime].")
return false
end
-- Set the new variables and setup the event
setupZombieEvent(minPlayers, maxPlayers, waitTime)
end
return false
end
Now go to data/global.lua and paste this:
Code:
dofile('data/zombieEvent.lua')
Now create inside data folder a lua and name it "zombieEvent.lua" and paste this:
http://pastebin.com/frkjmi1v
Here is the monster file, make sure name it "Zombie Event.xml":
http://pastebin.com/3qMib0QG
Make sure add no-logout zone on the waiting room and also on the Zombie event arena.
Last edited: