--PLEASE SPECIFY HERE WHAT DISTRO VERSION YOU ARE USING. IF YOU ARE USING (0.40/0.4.0)DEV SPECIFY IT AS 040
--IF YOU ARE USING 0.3.7/0.3.7PL1/0.3.6/0.3.5.... OR ANY OTHER VERSION OF 0.3, SPECIFY IT AS 037/036/035, ETC...
--THE IDEA IS TO SPECIFY IT WITHOUT ANY STRING CHARACTER, JUST NUMBERS
--MUST SPECIFY THIS PROPERLY TO MAKE SCRIPT WORKS CORRECTLY
DISTRO_VERSION = 040
--END
ITEM_DEADTREE = 2709
HALLOWEDAXE_PRICE = 1000
ERROR_NOERROR = 0
ERROR_TREEPOSITION = 1
ERROR_NOTENOUGHLEVEL = 2
ERROR_ALREADYDONE = 3
ERROR_ALREADYCUT = 4
ERROR_PLAYERINAREA = 5
ERROR_MISSINGINFO = 6
TYPE_PLAYER = 1
TYPE_MONSTER = 2
TYPE_NPC = 3
TYPE_ALL = 4
GET_COUNT = 1
GET_UID = 2
STORAGE_LIB = 11257
STORAGE_OAKTHINK = 11258
OAKTHINK_TIME = 10000
OAKTHINK_CHANCE = 30
oneInArea = true
killAllBeforeCut = true
oakThink = true
level = 120
waves = 11
positions =
{
kick = {x = 110, y = 75, z = 7},
summon =
{
{x = 104, y = 83, z = 7},
{x = 101, y = 82, z = 7},
{x = 105, y = 81, z = 7},
{x = 102, y = 78, z = 7},
{x = 103, y = 80, z = 7},
{x = 102, y = 82, z = 7},
{x = 103, y = 79, z = 7},
{x = 100, y = 78, z = 7}
},
rewardRoom = {x = 586, y = 630, z = 8},
demonOak = {x = 105, y = 82, z = 7}
}
summons =
{
[1] = {"demon", "grim reaper", "elder beholder", "demon skeleton"},
[2] = {"dark torturer", "banshee", "betrayed wraith", "blightwalker"},
[3] = {"bonebeast", "braindeath", "diabolic imp", "giant spider"},
[4] = {"hand of cursed fate", "lich", "undead dragon", "vampire"},
[5] = {"braindeath", "demon", "bonebeast", "diabolic imp"},
[6] = {"demon skeleton", "banshee", "elder beholder", "bonebeast"},
[7] = {"dark torturer", "undead dragon", "demon", "demon"},
[8] = {"elder beholder", "betrayed wraith", "demon skeleton", "giant spider"},
[9] = {"demon", "banshee", "blightwalker", "demon skeleton"},
[10] = {"grim reaper", "demon", "diabolic imp", "braindeath"},
[11] = {"banshee", "grim reaper", "hand of cursed fate", "demon"}
}
questAreaPosition =
{
{x = 94, y = 75, z = 7, stackpos = 255},
{x = 112, y = 86, z = 7, stackpos = 255}
}
demonOak = {8288, 8289, 8290, 8291}
storages =
{
done = 35712,
treeCut = 38551
}
blockingTree =
{
[ITEM_DEADTREE] = {32193, 3614}
}
floorDamage =
{
min = 270,
max = 310,
type = COMBAT_EARTHDAMAGE,
effect = CONST_ME_BIGPLANTS
}
rewards =
{
[12901] = {done = 12900, reward = 2495, count = 1},
[12902] = {done = 12900, reward = 8905, count = 1},
[12903] = {done = 12900, reward = 8918, count = 1},
[12904] = {done = 12900, reward = 8851, count = 1}
}
sounds =
{
[1] = --Messages shown when you wlak on special tiles
{
"Release me and you will be rewarded greatefully!",
"What is this? Demon Legs lying here? Someone might have lost them!",
"I'm trapped, come here and free me fast!!",
"I can bring your beloved back from the dead, just release me!",
"What a nice shiny golden armor. Come to me and you can have it!",
"Find a way in here and release me! Pleeeease hurry!",
"You can have my demon set, if you help me get out of here!"
},
[2] = --Messages shown when you use axe on Demon Oak
{
"MY ROOTS ARE SHARP AS A SCYTHE! FEEL IT?!?",
"CURSE YOU!",
"RISE, MINIONS, RISE FROM THE DEAD!!!!",
"AHHHH! YOUR BLOOD MAKES ME STRONG!",
"GET THE BONES, HELLHOUND! GET THEM!!",
"GET THERE WHERE I CAN REACH YOU!!!",
"ETERNAL PAIN AWAITS YOU! NICE REWARD, HUH?!?!",
"YOU ARE GOING TO PAY FOR EACH HIT WITH DECADES OF TORTURE!!",
"ARGG! TORTURE IT!! KILL IT SLOWLY MY MINION!!"
}
}
function canEnter(cid, tree)
if type(questAreaPosition) == "table" and type(questAreaPosition[1]) == "table" and type(questAreaPosition[2]) == "table" and level and type(storages) == "table" then
if isInRange(tree, questAreaPosition[1], questAreaPosition[2]) then
return ERROR_TREEPOSITION
elseif getPlayerLevel(cid) < level then
return ERROR_NOTENOUGHLEVEL
elseif getCreatureStorage(cid, storages.done) > 0 then
return ERROR_ALREADYDONE
elseif getCreatureStorage(cid, storages.treeCut) > 0 then
return ERROR_ALREADYCUT
elseif oneInArea then
if getCreaturesInQuestArea(TYPE_PLAYER, questAreaPosition[1], questAreaPosition[2], GET_COUNT) > 0 then
return ERROR_PLAYERINAREA
end
end
else
return ERROR_MISSINGINFO
end
return ERROR_NOERROR
end
function getError(data, tree)
if data == ERROR_TREEPOSITION then
return print("[!] --> [Warning - Action::Demon Oak Script] Dead tree position is inside the quest area positions.\nDead tree position: (x: " .. tree.x .. ", y: " .. tree.y .. ", z: " .. tree.z .. ")\nNorth-West area position (x: " .. questAreaPosition[1].x .. ", y: " .. questAreaPosition[1].y .. ", z: " .. questAreaPosition[1].z .. ")\nSouth-West area position (x: " .. questAreaPosition[2].x .. ", y: " .. questAreaPosition[2].y .. ", z: " .. questAreaPosition[2].z .. ")\nScript will not work correctly, please fix it.") and "Something is wrong, please contact a staff member."
elseif data == ERROR_NOTENOUGHLEVEL then
return "You need level " .. level .. " or higher to enter to the quest area."
elseif data == ERROR_ALREADYDONE then
return "You already done this quest."
elseif data == ERROR_ALREADYCUT then
return "You can not leave the quest area by here."
elseif data == ERROR_PLAYERINAREA then
return "Wait until the player inside the quest area finishes the quest."
elseif data == ERROR_MISSINGINFO then
return "Sorry, not possible."
end
return ""
end
function getCreaturesInQuestArea(type, fromPos, toPos, get, countSummon)
local types =
{
[TYPE_PLAYER] = isPlayer,
[TYPE_MONSTER] = isMonster,
[TYPE_NPC] = isNpc,
[TYPE_ALL] = isCreature
}
local tmp = {}
local t = types[type]
if not t then
return print("[!] --> [Warning - Function::getCreaturesInQuestArea] Unknow type " .. (type or "(nil value)"))
end
local thing
local pos
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
pos = {x = x, y = y, z = z}
thing = getTopCreature(pos)
if t(thing.uid) then
table.insert(tmp, thing.uid)
if not countSummon and isSummon(thing.uid) then
for i = 1, #tmp do
if tmp[i] == thing.uid then
table.remove(tmp, i)
break
end
end
end
end
end
end
end
return (get == GET_COUNT and #tmp or get == GET_UID and tmp or print("[Warning - Function::getCreaturesInQuestArea] Unknow type to get " .. (get or "(nil value)")))
end
function monsterExists(name)
local file = "data/monster/monsters.xml"
local openFile = io.open(file, "r")
local m_name, getName, getFile, m_file = 0, 0, 0, 0
local monsterExists, fileExists = false, false
if openFile ~= nil then
for line in io.lines(file) do
if line:find('name=".*".*') and line:find('file=".*".*') then
getName = string.match(line, 'name=".*".*')
getFile = string.match(line, 'file=".*".*')
if getName and getFile then
m_name = string.sub(getName, string.find(getName, '="') + 2, (string.find(getName, '" ') or string.find(getName, '"f') or 1) - 1)
m_file = string.sub(getFile, string.find(getFile, '="') + 2, (string.find(getFile, '"/') or string.find(getFile, '" ') or 1) - 1)
if m_name:lower() == name:lower() then
monsterExists = true
mfile = io.open("data/monster/" .. m_file, "r")
if mfile ~= nil then
fileExists = true
mfile:close()
end
end
end
end
end
openFile:close()
end
return monsterExists and fileExists or false
end
function isSummon(cid)
if DISTRO_VERSION < 040 then
return getCreatureMaster(cid) ~= cid or false
else
return getCreatureMaster(cid) ~= nil or false
end
end
function isLastCut(cid)
local k, s = 0, 0
if not demonOak or type(demonOak) ~= "table" then
return false
end
for i = demonOak[1], demonOak[#demonOak] do
if getCreatureStorage(cid, i) == #summons + 1 then
k = k + 1
end
if getCreatureStorage(cid, i) == #summons then
s = s + 1
end
end
return (k == 3 and s == 1 and true or false)
end
function demonOakThink()
if getGameState() == GAMESTATE_NORMAL then
if math.random(100) <= OAKTHINK_CHANCE then
if positions and positions.demonOak and type(positions.demonOak) == "table" and questAreaPosition and questAreaPosition[1] and type(questAreaPosition[1]) == "table" and questAreaPosition[2] and type(questAreaPosition[2]) == "table" then
local rangeX, rangeY = getDistanceBetween(positions.demonOak, questAreaPosition[1]) + 3, getDistanceBetween(positions.demonOak, questAreaPosition[2]) + 3
local list = getSpectators(positions.demonOak, rangeX, rangeY)
if list and #list > 0 then
for _, uid in ipairs(list) do
if isPlayer(uid) and not isInArea(getCreaturePosition(uid), questAreaPosition[1], questAreaPosition[2]) and getCreaturesInQuestArea(TYPE_PLAYER, questAreaPosition[1], questAreaPosition[2], GET_COUNT) == 0 then
doCreatureSay(uid, sounds[1][math.random(#sounds[1])], TALKTYPE_MONSTER_YELL, false, uid, positions.demonOak)
end
end
end
end
end
end
addEvent(demonOakThink, OAKTHINK_TIME)
end
if getStorage(STORAGE_OAKTHINK) < 1 and oakThink then
demonOakThink()
doSetStorage(STORAGE_OAKTHINK, 1)
end