<?xml version="1.0" encoding="UTF-8"?>
<mod name="demonOakQuest" version="0.4" author="renancs" contact="[email protected]" enabled="yes">
<description>
NOT Working Demon Oak Quest for TFS 0.3.5
</description>
<lib name="demonOak_config"><![CDATA[
function doRemoveMonsterInArea()
local BlindField = {x=32715, y=32352, z=7, stackpos=1}
function mapArea(fromPos, toPos, stack)
-- Area iterator by Colandus.
local pos = {x=fromPos.x, y=fromPos.y-1, z=fromPos.z}
return function()
if (pos.y < toPos.y) then
pos.y = pos.y+1
elseif (pos.x <= toPos.x) then
pos.y = fromPos.y
pos.x = pos.x+1
else
pos.x = fromPos.x
pos.y = fromPos.y
pos.z = pos.z+1
end
if (pos.x <= toPos.x and pos.y <= toPos.y or pos.z < toPos.z) then
if (stack == nil) then
return pos
else
pos.stackpos = stack
--return pos, getTileThingByPos(pos)
return pos, getThingfromPos(pos)
end
end
end
end
function getMonstersfromArea(fromPos, toPos)
local monsters = {}
for _, thing in mapArea(fromPos, toPos, 253) do
if isMonster(thing.uid) == TRUE then
table.insert(monsters, thing.uid)
end
end
local bfm = getThingfromPos(BlindField)
if isMonster(bfm.uid) == TRUE then
table.insert(monsters, bfm.uid)
end
return monsters
end
local monsters = getMonstersfromArea(areaPosition[1], areaPosition[2])
local monsters1 = getMonstersfromArea(areaPosition[1], areaPosition[2])
for _, monster in pairs(monsters1) do
doRemoveCreature(monster)
end
end
onePerQuest = "yes"
level = 120
positions =
{
reward = {x=32786, y=32411, z=8},
kick = { x = 32715, y = 32339, z = 7 },
summon =
{
{x=32715, y=32348, z=7},
{x=32715, y=32355 , z=7},
{x=32711 , y=32352 , z=7},
{x=32719 , y=32352 , z=7},
{x=32712, y=32349, z=7},
{x=32718, y=32349 , z=7},
{x=32712 , y=32354 , z=7},
{x=32718 , y=32354 , z=7}
}
}
summons =
{
[1] = {"Demon", "Grim Reaper", "Elder Beholder", "Demon Skeleton", "Bonebeast", "Banshee", "Bonebeast", "Demon Skeleton"},
[2] = {"Dark Torturer", "Banshee", "Betrayed Wraith", "Demon Skeleton", "Bonebeast", "Braindeath", "Banshee", "Giant Spider"},
[3] = {"Bonebeast", "Braindeath", "Diabolic Imp", "Giant Spider", "Lich", "Lich", "Undead Dragon", "Vampire"},
[4] = {"Hand of Cursed Fate", "Lich", "Undead Dragon", "Vampire","braindeath", "Demon", "Bonebeast", "Diabolic Imp"},
[5] = {"braindeath", "Demon", "Bonebeast", "Diabolic Imp", "Demon Skeleton", "Banshee", "Elder Beholder", "Bonebeast"},
[6] = {"Demon Skeleton", "Banshee", "Elder Beholder", "Bonebeast", "Dark Torturer", "Undead Dragon", "Demon", "Demon"},
[7] = {"Dark Torturer", "Undead Dragon", "Demon", "Demon", "Elder Beholder", "Betrayed Wraith", "Demon Skeleton", "Giant Spider"},
[8] = {"Elder Beholder", "Betrayed Wraith", "Demon Skeleton", "Giant Spider", "Demon", "Banshee", "Blightwalker", "Demon Skeleton"},
[9] = {"Demon", "Banshee", "Blightwalker", "Demon Skeleton", "Grim Reaper", "Demon", "Diabolic Imp", "Braindeath"},
[10] = {"Grim Reaper", "Demon", "Diabolic Imp", "Braindeath", "Banshee", "Grim Reaper", "Hand of Cursed fate", "Demon"},
[11] = {"Undead Dragon", "Grim Reaper", "Hand of Cursed fate", "Demon", "Betrayed Wraith", "Dark Torturer", "Diabolic Imp", "Blightwalker"}
}
areaPosition =
{
{x=32707, y=32345, z=7, stackpos = 255},
{x=32726, y=32357, z=7, stackpos = 255}
}
demonOak = {8288, 8289, 8290, 8291}
storages =
{
done = 35700,
cutTree = 36901
}
blockingTree =
{
[2709] = {32193, 3669}
}
toPos = { x = 32716, y = 32346, z = 7 }
teleportPos = { x = 32714, y = 32345, z = 7 }
teleportToPos = { x = 32715, y = 32339, z = 7 }
]]></lib>
<action itemid="8293" event="buffer"><![CDATA[
domodlib('demonOak_config')
if isInArray(demonOak, itemEx.itemid) then
local get = getPlayerStorageValue(cid, itemEx.itemid)
if get == -1 then
get = 1
end
if(getPlayerStorageValue(cid, 8288) == 12 and getPlayerStorageValue(cid, 8289) == 12 and getPlayerStorageValue(cid, 8290) == 12 and getPlayerStorageValue(cid, 8291) == 12) then
doPlayerRemoveItem(cid, 8293, 1)
doPlayerAddItem(cid, 2386, 1)
doPlayerSetStorageValue(cid, storages.done, 1)
end
if getPlayerStorageValue(cid, itemEx.itemid) > 11 then
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
if(math.random(100) <= 10) then
doPlayerSetStorageValue(cid, itemEx.uid, 12)
end
if summons[get] then
for i = 1, #summons[get] do
doCreateMonster(summons[get][i], positions.summon[i])
doSendMagicEffect(positions.summon[i], CONST_ME_TELEPORT)
end
doSendMagicEffect(toPosition, CONST_ME_DRAWBLOOD)
doPlayerSetStorageValue(cid, itemEx.itemid, get + 1)
if math.random(100) >= 50 then
doTargetCombatHealth(0, cid, COMBAT_EARTHDAMAGE, -270, -310, CONST_ME_BIGPLANTS)
end
end
end
]]></action>
<action uniqueid="55100" event="buffer"><![CDATA[
domodlib('demonOak_config')
if getPlayerStorageValue(cid, storages.done) > 1 then
doTeleportThing(cid, positions.reward)
doSendMagicEffect(positions.reward, CONST_ME_TELEPORT)
else
return
end
]]></action>
<action uniqueid="12901-12904" event="buffer"><![CDATA[
if item.uid == 12901 then
queststatus = getPlayerStorageValue(cid, 12900)
if queststatus < 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Demon Legs.")
doPlayerAddItem(cid, 2495, 1)
setPlayerStorageValue(cid, 12900, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 12902 then
queststatus = getPlayerStorageValue(cid, 12900)
if queststatus < 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Rainbow Shield.")
doPlayerAddItem(cid, 8905, 1)
setPlayerStorageValue(cid, 12900, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 12903 then
queststatus = getPlayerStorageValue(cid, 12900)
if queststatus < 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Spellbook of Dark Mysteries.")
doPlayerAddItem(cid, 8918, 1)
setPlayerStorageValue(cid, 12900, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
end
elseif item.uid == 12904 then
queststatus = getPlayerStorageValue(cid, 12900)
if queststatus < 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Royal Crossbow.")
doPlayerAddItem(cid, 8851, 1)
setPlayerStorageValue(cid, 12900, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
end
end
]]></action>
<movevent type="StepIn" actionid="32193" event="buffer"><![CDATA[
domodlib('demonOak_config')
if isPlayer(cid) == TRUE then
if getPlayerLevel(cid) < level then
doPlayerSendCancel(cid, "You need level " .. level .. " or more to enter this quest.")
doTeleportThing(cid, teleportToPos)
doSendMagicEffect(cid, CONST_ME_TELEPORT)
elseif getPlayerStorageValue(cid, storages.done) > 0 then
doPlayerSendCancel(cid, "You already done this quest.")
doTeleportThing(cid, teleportToPos)
doSendMagicEffect(cid, CONST_ME_TELEPORT)
else
doTeleportThing(cid, toPos)
for i = 0, 4 do
posY = 32344 - i
pos = { x = 32716 , y = posY , z = 7}
player = getTopCreature( pos ).uid
if isPlayer(player) == TRUE then
doTeleportThing(player, teleportToPos)
end
if getThingfromPos(pos).itemid == 8009 then
doSendMagicEffect(pos, CONST_ME_POFF)
else
doCreateItem(8009, 1, pos)
doSendMagicEffect(pos, CONST_ME_HITBYPOISON)
end
end
doCreateTeleport(1387, {}, teleportPos)
teleportItem = getTileItemById(teleportPos,1387)
doSetItemActionId(teleportItem.uid, 12905)
doPlayerSetStorageValue(cid, storages.cutTree, 1)
end
end
]]></movevent>
<movevent type="StepIn" actionid="12905" event="buffer"><![CDATA[
domodlib('demonOak_config')
if isPlayer(cid) == TRUE then
if (getPlayerStorageValue(cid, 8288) == 12 and getPlayerStorageValue(cid, 8289) == 12 and getPlayerStorageValue(cid, 8290) == 12 and getPlayerStorageValue(cid, 8291) == 12) then
doTeleportThing(cid, teleportToPos)
if getTileItemById(teleportPos,1387).itemid == 1387 then
doRemoveItem(getTileItemById(teleportPos,1387).uid)
end
for i = 0, 4 do
posY = 32344 - i
pos = { x = 32716 , y = posY , z = 7}
if getTileItemById(pos,8009).itemid == 8009 then
doRemoveItem(getTileItemById(pos,8009).uid)
doSendMagicEffect(pos, CONST_ME_HITBYPOISON)
end
end
if getPlayerStorageValue(cid, 36901) > 0 and getPlayerStorageValue(cid, 35700) < 1 then
doPlayerSetStorageValue(cid, 36901, 0)
return TRUE
end
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Tell Oldrak about your great victory against the demon oak.")
doRemoveMonsterInArea()
return
elseif (getPlayerStorageValue(cid, 8288) == -1 and getPlayerStorageValue(cid, 8289) == -1 and getPlayerStorageValue(cid, 8290) == -1 and getPlayerStorageValue(cid, 8291) == -1) then
for i = 0, 4 do
posY = 32344 - i
pos = { x = 32716 , y = posY , z = 7}
if getTileItemById(pos,8009).itemid == 8009 then
doRemoveItem(getTileItemById(pos,8009).uid)
doSendMagicEffect(pos, CONST_ME_HITBYPOISON)
end
end
doTeleportThing(cid, teleportToPos)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "It seems that you have discovered an 'Ultimate Challenge'.")
if getPlayerStorageValue(cid, 36901) > 0 and getPlayerStorageValue(cid, 35700) < 1 then
doPlayerSetStorageValue(cid, 36901, -1)
return TRUE
end
return
else
doMoveCreature(cid, SOUTH)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You must defeat the demon oak, before leave the infected area.")
end
end
]]></movevent>
<movevent type="StepIn" itemid="8292" event="script">
if isPlayer(cid) == TRUE and math.random(1, 5) == 1 then
doTargetCombatHealth(0, cid, COMBAT_EARTHDAMAGE, -270, -310, CONST_ME_BIGPLANTS)
end
</movevent>
<event type="death" name="DemonOakDeath" event="script"><![CDATA[
domodlib('demonOak_config')
function onDeath(cid, corpse, deathList)
doRemoveMonsterInArea()
for i = 0, 4 do
posY = 32344 - i
pos = { x = 32716 , y = posY , z = 7}
if getTileItemById(pos,8009).itemid == 8009 then
doRemoveItem(getTileItemById(pos,8009).uid)
doSendMagicEffect(pos, CONST_ME_HITBYPOISON)
end
end
if getPlayerStorageValue(cid, 36901) > 0 and getPlayerStorageValue(cid, 35700) < 1 then
doPlayerSetStorageValue(cid, 36901, -1)
end
return TRUE
end
]]></event>
<event type="logout" name="DemonOakLogout" event="script"><![CDATA[
domodlib('demonOak_config')
doRemoveMonsterInArea()
if getPlayerStorageValue(cid, 36901) > 0 and getPlayerStorageValue(cid, 35700) < 1 then
doPlayerSetStorageValue(cid, 36901, -1)
return TRUE
end
]]></event>
</mod>