Tachi
New Member
[MOD] Zombies Event w/ Rounds & Killing Quest & Killing Portal
OKk as the title states i am working on trying to get my scripts less cluttered, and i was wondering how i could go about my script iv crafted (PLEASE NOTE: i did copy paste alot of core functionality from mulitple other zombie events, although i recodded and moved things around to work, so i guess i cannot talk 100% credit, but i did do some of the coding....) without so much coding. I figure a lot of it can be done with loops or something of the like, i am just not sure how to do it. Also i was having problems creating a separate onKill function either in a separate mod or in creature-scripts so i made a three in one mod.
One question i have is, does anyone know why i couldn't get my second onKill function working properly, im usng TFS 0.3.7 Crying Damson.?
Another thing i want to add but not sure how, is that when a player die's, or is at like 1 hp, he will get sent to temple(exit pos) and receive full hp and mana.
Also, maybe instead of 2-3 round with same level creature, each round the monster get harder, so i guess with a counter after the zombie name, to get different zombies spawning or w/e.
Well here is my script, anyone got any ideas?...
- - - Updated - - -
BUMP, Still wanting to optimize this code...
OKk as the title states i am working on trying to get my scripts less cluttered, and i was wondering how i could go about my script iv crafted (PLEASE NOTE: i did copy paste alot of core functionality from mulitple other zombie events, although i recodded and moved things around to work, so i guess i cannot talk 100% credit, but i did do some of the coding....) without so much coding. I figure a lot of it can be done with loops or something of the like, i am just not sure how to do it. Also i was having problems creating a separate onKill function either in a separate mod or in creature-scripts so i made a three in one mod.
One question i have is, does anyone know why i couldn't get my second onKill function working properly, im usng TFS 0.3.7 Crying Damson.?
Another thing i want to add but not sure how, is that when a player die's, or is at like 1 hp, he will get sent to temple(exit pos) and receive full hp and mana.
Also, maybe instead of 2-3 round with same level creature, each round the monster get harder, so i guess with a counter after the zombie name, to get different zombies spawning or w/e.
Well here is my script, anyone got any ideas?...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Zombie" version="2.0" author="Gansir" enabled="yes">
<config name="ZombieConfig"><=!=[=C=D=A=T=A=[
config = {
beginPos = {x = 1557, y = 1390, z = 7},
temple = {x = 1307, y = 1377, 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
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 = "event zombie", -- Name of the zombie that should be summoned
zombieName2 = "event zombie2", -- Name of the zombie that should be summoned
zombieName3 = "event zombie3", -- Name of the zombie that should be summoned
fromPos = {x = 1274, y = 1351, z = 6}, -- Waiting Room
toPos = {x = 1281, y = 1353, z = 6}, -- Waiting Room
areaFromPos = {x = 1536, y = 1377, z = 7}, -- Arena
areaToPos = {x = 1574, y = 1396, z = 7}, -- Arena
message = "You killed a Zombie",
bosses = { -- Monster Name, Teleport To Position, Teleport Position, UID
["event zombie"] = { Storage = 2003 },
},
}
monsters = {
--name = storage
["troll"] = 55004,
["ghoul"] = 55005,
["orc"] = 55006,
["orc beserker"] = 55006,
["orc leader"] = 55006,
["orc spearsman"] = 55006,
["orc warlord"] = 55006,
["orc warrior"] = 55006,
["orc rider"] = 55006,
["orc shaman"] = 55006,
["minotaur"] = 55007,
["minotaur mage"] = 55007,
["minotaur archer"] = 55007,
["minotaur guard"] = 55007,
["dwarf"] = 55008,
["dwarf soldier"] = 55008,
["dwarf guard"] = 55008,
["dwarf geomancer"] = 55008,
["dragon"] = 55010,
["dragon lord"] = 55010,
["dragon hatchling"] = 55010,
["dragon lord hatchling"] = 55010,
}
inqconf = {
message = "Go into the teleporter with-in 1 minute, else it will disappear.",
timeToRemove = 30, -- seconds
teleportId = 1387,
MonStor = 48000,
monboss = { -- Monster Name, Teleport To Position, Teleport Position, UID
["igor the recruiter"] = { ptp={ x=1305, y=1377, z=6}, pp={ x=1470, y=1450, z=8, stackpos=1 }, uid=49100 },
}
}
]=]=></config>
<lib name="Zombielib"><=!=[=C=D=A=T=A=[
domodlib('ZombieConfig')
function zombieSpawn()
if getGlobalStorageValue(config.rounds) <= 2 then
if getGlobalStorageValue(config.zombieCount) <= 9 then
pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
doSummonCreature(config.zombieName, pos)
doSendMagicEffect(pos, CONST_ME_MORTAREA)
setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
else
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
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)
elseif getGlobalStorageValue(config.rounds) <= 3 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)
end
end
end
end
end
end
end
addEvent(zombieSpawn, 1 * 1000)
elseif getGlobalStorageValue(config.rounds) <= 5 and getGlobalStorageValue(config.rounds) >= 3 then
if getGlobalStorageValue(config.zombieCount) <= 9 then
pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
doSummonCreature(config.zombieName2, pos)
doSendMagicEffect(pos, CONST_ME_MORTAREA)
setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
else
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
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) <= 5 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)
end
end
end
end
end
end
end
addEvent(zombieSpawn, 1 * 1000)
elseif getGlobalStorageValue(config.rounds) <= 9 and getGlobalStorageValue(config.rounds) >= 6 then
if getGlobalStorageValue(config.zombieCount) <= 9 then
pos = {x = math.random(config.areaFromPos.x, config.areaToPos.x), y = math.random(config.areaFromPos.y, config.areaToPos.y), z = math.random(config.areaFromPos.z, config.areaToPos.z)}
doSummonCreature(config.zombieName3, pos)
doSendMagicEffect(pos, CONST_ME_MORTAREA)
setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)+1)
else
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
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) <= 5 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)
end
end
end
end
end
end
end
addEvent(zombieSpawn, 1 * 1000)
else
addEvent(endingEvent, 1 * 1000)
end
return true
end
function startEvent()
for _, cid in ipairs(getPlayersOnline()) do
if isInRange(getThingPos(cid), config.fromPos, config.toPos) then
doTeleportThing(cid, config.beginPos, true)
doPlayerSetStorageValue(cid, config.inGamecheck, 1)
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
areapos = {x = x, y = y, z = z, stackpos = 253}
getPlayers = getThingfromPos(areapos)
if isPlayer(getPlayers.uid) then
doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The First round is about to begin!")
addEvent(zombieSpawn, 1000)
zombieSpawn()
end
end
end
end
else
doBroadcastMessage(" The Zombies event has been canceled due to the lack of players.", MESSAGE_STATUS_WARNING)
end
end
return true
end
function broadcasting()
setGlobalStorageValue(config.NumZombieEvents, getGlobalStorageValue(config.NumZombieEvents)+1)
addEvent(doBroadcastMessage, 1000, "Zombies will begin in 5 minutes.")
addEvent(doBroadcastMessage, 120 * 1000, "Zombies will begin in 3 minutes.")
addEvent(doBroadcastMessage, 240 * 1000, "Zombies will begin in 1 minute. Hurry up to the Mini-Game Waiting Room!")
addEvent(doBroadcastMessage, 299 * 1000, "Zombie Event has started.")
addEvent(startEvent, 300 * 1000)
return true
end
function endingEvent()
for _, cid in ipairs(getPlayersOnline()) do
if isInRange(getThingPos(cid), config.areaFromPos, config.areaToPos) then
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
areapos = {x = x, y = y, z = z, stackpos = 253}
getPlayers = getThingfromPos(areapos)
if isPlayer(getPlayers.uid) then
doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "You have just survived " .. getGlobalStorageValue(config.rounds)+1 .. " waves of zombies. Good Job Man! That was the last wave!")
end
end
end
end
setGlobalStorageValue(config.rounds, 0)
setGlobalStorageValue(config.zombieCount, 0)
setGlobalStorageValue(config.zombieCounter, 0)
doPlayerSetStorageValue(cid, config.inGamecheck, 0)
addEventPoints(cid, 10)
doBroadcastMessage("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 = doPlayerAddItem(cid, config.goblet, 1)
doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for surviving the Zombie event.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doTeleportThing(cid, config.temple, false)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
for _,items in ipairs(config.moneyReward) do
if config.moneyReward[3] == 1 then
doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
end
end
end
setGlobalStorageValue(config.zombieCount, 0)
end
return true
end
]=]=></lib>
<event type="kill" name="Zombies" event="script"><=!=[=C=D=A=T=A=[
domodlib('ZombieConfig')
domodlib('Zombielib')
function onKill(cid, target)
local name = getCreatureName(target):lower()
local monster = monsters[getCreatureName(target):lower()]
local t = inqconf.monboss[getCreatureName(target):lower()]
if isInRange(getThingPos(cid), {x = 1536, y = 1377, z = 7}, {x = 1574, y = 1396, z = 7}) then
setGlobalStorageValue(config.zombieCounter, getGlobalStorageValue(config.zombieCounter)-1)
if getGlobalStorageValue(config.zombieCounter) == 0 then
doCreatureSay(cid, "There are no Zombie Left. Please wait for the next round.", TALKTYPE_ORANGE_1)
elseif getGlobalStorageValue(config.zombieCounter) == 1 then
doCreatureSay(cid, "There is "..getGlobalStorageValue(config.zombieCounter).. " Zombie Left.", TALKTYPE_ORANGE_1)
else
doCreatureSay(cid, "There are "..getGlobalStorageValue(config.zombieCounter).. " Zombies Left.", TALKTYPE_ORANGE_1)
end
elseif (name == "troll" and getPlayerStorageValue(cid, 76669) == 2) then
if getPlayerStorageValue(cid, monster) < 60 then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
if(killedMonsters == 0) then
killedMonsters = 1
end
setPlayerStorageValue(cid, monster, killedMonsters + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 60 Trolls.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 60 trolls.")
setPlayerStorageValue(cid, 76669, 3)
end
elseif (name == "ghoul" and getPlayerStorageValue(cid, 76669) == 5) then
if getPlayerStorageValue(cid, monster) < 100 then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
if(killedMonsters == 0) then
killedMonsters = 1
end
setPlayerStorageValue(cid, monster, killedMonsters + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 100 Ghouls.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 100 ghouls.")
setPlayerStorageValue(cid, 76669, 6)
end
elseif ((name == "orc" or name == "orc beserker" or name == "orc leader" or name == "orc spearsman" or name == "orc warlord" or name == "orc warrior" or name == "orc rider" or name == "orc shaman") and getPlayerStorageValue(cid, 76669) == 8) then
if getPlayerStorageValue(cid, monster) < 150 then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
if(killedMonsters == 0) then
killedMonsters = 1
end
setPlayerStorageValue(cid, monster, killedMonsters + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 150 Orcs.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 150 orcs.")
setPlayerStorageValue(cid, 76669, 9)
end
elseif ((name == "minotaur" or name == "minotaur archer" or name == "minotaur guard" or name == "minotaur mage") and getPlayerStorageValue(cid, 76669) == 11) then
if getPlayerStorageValue(cid, monster) < 200 then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
if(killedMonsters == 0) then
killedMonsters = 1
end
setPlayerStorageValue(cid, monster, killedMonsters + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 200 minotaurs.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 200 minotaurs.")
setPlayerStorageValue(cid, 76669, 12)
end
elseif ((name == "dwarf" or name == "dwarf soldier" or name == "dwarf guard" or name == "dwarf geomancer") and getPlayerStorageValue(cid, 76669) == 14) then
if getPlayerStorageValue(cid, monster) < 300 then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
if(killedMonsters == 0) then
killedMonsters = 1
end
setPlayerStorageValue(cid, monster, killedMonsters + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 300 Dwarfs.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 300 dwarfs.")
setPlayerStorageValue(cid, 76669, 15)
end
elseif ((name == "dragon" or name == "dragon lord" or name == "dragon hatchling" or name == "dragon lord hatchling") and getPlayerStorageValue(cid, 76669) == 17) then
if getPlayerStorageValue(cid, monster) < 500 then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
if(killedMonsters == 0) then
killedMonsters = 1
end
setPlayerStorageValue(cid, monster, killedMonsters + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. (killedMonsters) .. " of 500 Dragons.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed 500 dragons.")
setPlayerStorageValue(cid, 76669, 18)
end
elseif(name == "igor the recruiter" and getPlayerStorageValue(cid, 76670) == 7) then
local teleport = doCreateTeleport(inqconf.teleportId, t.ptp, t.pp)
doItemSetAttribute(teleport, "uid", t.uid)
doCreatureSay(cid, inqconf.message, TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, 76670, 8)
addEvent(removeTeleport, 60 * 1000)
end
return true
end
function removeTeleport()
local teleport = getTileItemById({x=1470, y=1450, z=8, stackpos=1}, 1387)
if teleport.uid > 0 then
doRemoveItem(teleport.uid)
end
end
]=]=></event>
<event type="login" name="Zombielog" event="script"><=!=[=C=D=A=T=A=[
domodlib('ZombieConfig')
domodlib('Zombielib')
function onLogin(cid)
registerCreatureEvent(cid, "Zombies")
registerCreatureEvent(cid, "ZombieGlobal")
registerCreatureEvent(cid, "ZombieGlobal2")
return true
end
]=]=></event>
<talkaction log="yes" words="/zombies" access="5" event ="script"><=!=[=C=D=A=T=A=[
domodlib("ZombieConfig")
domodlib('Zombielib')
function onSay(cid, words, param)
if(string.lower(param) == string.lower(config.passageKey)) then
doPlayerSendCancel(cid, "You have selected to start the Zombie Event!.")
setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
setGlobalStorageValue(config.zombieCount, 0)
setGlobalStorageValue(config.zombieCounter, 0)
setGlobalStorageValue(config.rounds, 0)
setGlobalStorageValue(config.NumZombieEvents, 0)
broadcasting()
elseif(string.lower(param) == string.lower(config.countKey)) then
if getGlobalStorageValue(config.counts)+1 == 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has not been ran yet.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The Zombies Event has been ran: "..(getGlobalStorageValue(config.counts)+1).." times.")
end
elseif(string.lower(param) == string.lower(config.startNow)) then
doPlayerSendCancel(cid, "You have selected to start the Zombie Event RIGHT NOW!.")
setGlobalStorageValue(config.zombieCount, 0)
setGlobalStorageValue(config.zombieCounter, 0)
setGlobalStorageValue(config.rounds, 0)
setGlobalStorageValue(config.NumZombieEvents, 0)
setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
startEvent()
else
doPlayerSendCancel(cid, "You must say the correct word to start the Zombie Event!.")
end
return true
end
]=]=></talkaction>
<globalevent name="ZombieGlobal" time="17:55" event="script"><=!=[=C=D=A=T=A=[
domodlib('ZombieConfig')
domodlib('Zombielib')
function onTime(time)
setGlobalStorageValue(config.zombieCount, 0)
setGlobalStorageValue(config.zombieCounter, 0)
setGlobalStorageValue(config.rounds, 0)
setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
addEvent(broadcasting, 1 * 1000)
end
]=]=></globalevent>
<globalevent name="ZombieGlobal2" time="07:55" event="script"><=!=[=C=D=A=T=A=[
domodlib('ZombieConfig')
domodlib('Zombielib')
function onTime(time)
setGlobalStorageValue(config.zombieCount, 0)
setGlobalStorageValue(config.zombieCounter, 0)
setGlobalStorageValue(config.rounds, 0)
setGlobalStorageValue(config.NumZombieEvents, 0)
setGlobalStorageValue(config.counts, getGlobalStorageValue(config.counts)+1)
addEvent(broadcasting, 1 * 1000)
end
]=]=></globalevent>
</mod>
- - - Updated - - -
BUMP, Still wanting to optimize this code...
Last edited: