Skip to content

Commit

Permalink
remove redundant checks at spectator
Browse files Browse the repository at this point in the history
  • Loading branch information
Royalot committed Jul 18, 2014
1 parent cc1a8e3 commit f99ad83
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ local waves = {
function doClearAreaAzerus()
if Game.getStorageValue(982) == 1 then
local othermonsters = Game.getSpectators(Position({x = 32783, y = 31166, z = 10}), false, false, 10, 10, 10, 10)
if othermonsters ~= nil then
for _, othermonster in ipairs(othermonsters) do
if othermonster:isMonster() then
othermonster:getPosition():sendMagicEffect(CONST_ME_POFF)
othermonster:remove()
end
for _, othermonster in ipairs(othermonsters) do
if othermonster:isMonster() then
othermonster:getPosition():sendMagicEffect(CONST_ME_POFF)
othermonster:remove()
end
end
Game.setStorageValue(982, 0)
Expand All @@ -25,17 +23,15 @@ end

function doChangeAzerus()
local azeruses = Game.getSpectators(Position({x = 32783, y = 31166, z = 10}), false, false, 10, 10, 10, 10)
if azeruses ~= nil then
for _, azerus in ipairs(azeruses) do
if azerus:isMonster() and string.lower(azerus:getName()) == "azerus" then
azerus:say("No! I am losing my energy!", TALKTYPE_MONSTER_SAY)
local azeruspos = azerus:getPosition()
azerus:remove()
Game.createMonster("Azerus", azeruspos)
return true
end
end
for _, azerus in ipairs(azeruses) do
if azerus:isMonster() and string.lower(azerus:getName()) == "azerus" then
azerus:say("No! I am losing my energy!", TALKTYPE_MONSTER_SAY)
local azeruspos = azerus:getPosition()
azerus:remove()
Game.createMonster("Azerus", azeruspos)
return true
end
end
return false
end

Expand All @@ -44,12 +40,9 @@ function onUse(cid, item, fromPosition, itemEx, toPosition)
if Game.getStorageValue(982) ~= 1 then -- Fight
local amountOfPlayers = 1

This comment has been minimized.

Copy link
@dbjorkholm

dbjorkholm Jul 18, 2014

Owner

Fix indentation

local spectators = Game.getSpectators(Position({x = 32783, y = 31166, z = 10}), false, true, 10, 10, 10, 10)
local players = #spectators
if players < amountOfPlayers then
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
spectator:sendTextMessage(MESSAGE_INFO_DESCR, "You need atleast "..amountOfPlayers.." players inside the quest room.")
end
if #spectators < amountOfPlayers then

This comment has been minimized.

Copy link
@dbjorkholm

dbjorkholm Jul 18, 2014

Owner

Fix indentation

for _, spectator in ipairs(spectators) do
spectator:sendTextMessage(MESSAGE_INFO_DESCR, "You need atleast "..amountOfPlayers.." players inside the quest room.")
end
return true
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
function onKill(cid, target)
local monster = Monster(target)
local deathpos = monster:getPosition()
if monster then
if string.lower(monster:getName()) == "azerus" then
doCreateTeleport(1387, {x=32780, y=31168, z=14}, deathpos)
deathpos:sendMagicEffect(CONST_ME_TELEPORT)
monster:say("Azerus ran into teleporter! It will disappear in 2 minutes. Enter It!", TALKTYPE_MONSTER_SAY, 0, 0, deathpos)

--remove portal after 2 min
addEvent(function(target)
local portaltile = Tile(deathpos)
if portaltile:getItemById(1387) then
portaltile:getItemById(1387):remove()
deathpos:sendMagicEffect(CONST_ME_POFF)
end
end, 2 * 60 * 1000, target)

--clean arena of monsters
local othermonsters = Game.getSpectators(Position({x = 32783, y = 31166, z = 10}), false, false, 10, 10, 10, 10)
if othermonsters ~= nil then
for _, othermonster in ipairs(othermonsters) do
if othermonster:isMonster() then
othermonster:getPosition():sendMagicEffect(CONST_ME_POFF)
othermonster:remove()
end
end
local azerus = Monster(target)
if azerus and string.lower(azerus:getName()) == "azerus" then
local deathpos = azerus:getPosition()
doCreateTeleport(1387, {x=32780, y=31168, z=14}, deathpos)
deathpos:sendMagicEffect(CONST_ME_TELEPORT)
azerus:say("Azerus ran into teleporter! It will disappear in 2 minutes. Enter It!", TALKTYPE_MONSTER_SAY, 0, 0, deathpos)

--remove portal after 2 min
addEvent(function(target)

This comment has been minimized.

Copy link
@dbjorkholm

dbjorkholm Jul 18, 2014

Owner

target is not even used

local portaltile = Tile(deathpos)
if portaltile:getItemById(1387) then
portaltile:getItemById(1387):remove()
deathpos:sendMagicEffect(CONST_ME_POFF)
end
end, 2 * 60 * 1000, target)

--clean arena of monsters
local othermonsters = Game.getSpectators(Position({x = 32783, y = 31166, z = 10}), false, false, 10, 10, 10, 10)
for _, othermonster in ipairs(othermonsters) do
if othermonster:isMonster() then
othermonster:getPosition():sendMagicEffect(CONST_ME_POFF)
othermonster:remove()
end

end
end
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ function onKill(cid, target)
Game.setStorageValue(Storage.TheNewFrontier.Mission09, -1)
clearArena({x = 33053, y = 31024, z = 3}, {x = 33074, y = 31044, z = 3})
local spectators = Game.getSpectators(Position({x = 33063, y = 31034, z = 3}), false, true, 10, 10, 10, 10)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
spectator:teleportTo({x = 33053, y = 31022, z = 7})
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
spectator:say("You have won! As new champion take the ancient armor as reward before you leave.", TALKTYPE_MONSTER_SAY)
if spectator:getStorageValue(Storage.TheNewFrontier.Questline) == 25 then
spectator:setStorageValue(Storage.TheNewFrontier.Mission09, 2) --Questlog, The New Frontier Quest "Mission 09: Mortal Combat"
spectator:setStorageValue(Storage.TheNewFrontier.Questline, 26)
end
for _, spectator in ipairs(spectators) do
spectator:teleportTo({x = 33053, y = 31022, z = 7})
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
spectator:say("You have won! As new champion take the ancient armor as reward before you leave.", TALKTYPE_MONSTER_SAY)
if spectator:getStorageValue(Storage.TheNewFrontier.Questline) == 25 then
spectator:setStorageValue(Storage.TheNewFrontier.Mission09, 2) --Questlog, The New Frontier Quest "Mission 09: Mortal Combat"
spectator:setStorageValue(Storage.TheNewFrontier.Questline, 26)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@ local config = {
function doClearMissionArea()
Game.setStorageValue(Storage.ChildrenoftheRevolution.Mission05, -1)
local spectators = Game.getSpectators(Position({x = 33268, y = 31119, z = 7}), false, true, 26, 26, 20, 20)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
spectator:teleportTo({x = 33353, y = 31410, z = 8})
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
if spectator:getStorageValue(Storage.ChildrenoftheRevolution.Questline) == 19 then
spectator:setStorageValue(Storage.ChildrenoftheRevolution.Questline, 20)
end
end
for _, spectator in ipairs(spectators) do
spectator:teleportTo({x = 33353, y = 31410, z = 8})
spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
if spectator:getStorageValue(Storage.ChildrenoftheRevolution.Questline) == 19 then
spectator:setStorageValue(Storage.ChildrenoftheRevolution.Questline, 20)
end
end
local monsters = Game.getSpectators(Position({x = 33268, y = 31119, z = 7}), false, false, 26, 26, 20, 20)
if monsters ~= nil then
for _, monster in ipairs(monsters) do
monster:getPosition():sendMagicEffect(CONST_ME_POFF)
monster:remove()
end
end
for _, monster in ipairs(monsters) do
monster:getPosition():sendMagicEffect(CONST_ME_POFF)
monster:remove()
end
return true
end

Expand Down

0 comments on commit f99ad83

Please sign in to comment.