/search.phpscript?
Demon Oak Quest By Darkhaos [Tested in last The Forgotten Server Version = (Crying Damson) 0.3.6]
Update Log:
Code:[B]V0.4.2:[/B] - Added a code that checks if dead tree is inside the quest area positions (action script "demonOak.lua"). - onePerQuest works now with true or false [B]V0.4.1:[/B] - Changed little bugs in the script, now is working the chance to don't cut the tree part 11 times. - Fixed bug at the first cut in the tree. [B]v0.4:[/B] - Fixed a bug when player die in the demonOak Area, now player can enter to the quest again after died. - Fixed some errors in text with Oldrak. [B]v0.3:[/B] - A message is sended if player does not have the needed level. - Updated to 0.3.5 (Crying Damson) - Files changed: [data/actions/scripts/demonOak.lua, data/actions/scripts/demonOakGravestone.lua, data/actions/scripts/demonOakChests.lua, data/npc/scripts/oldrak.lua] [B]v0.2:[/B] - Fixed bug checking area, now is working "onePerQuest" - Fixed missing "end" in Oldrak.lua [B]v0.1:[/B] - Fixed bug with Oldrak.lua. - Fixed hallowed axe price. (Before 250,000 gold pieces, now 1,000) - Updated demonOakGravestone.lua (Now you need the confirmation from Oldrak to enter to the reward room)
![]()
Create files in actions called:
..data/actions/scripts/demonOak.lua
LUA:function onUse(cid, item, fromPosition, itemEx, toPosition) local onePerQuest = true local level = 120 local positions = { kick = { x = 571, y = 621, z = 7 }, summon = { {x=575, y=630, z=7}, {x=583, y=629, z=7}, {x=579, y=635, z=7}, {x=575, y=634, z=7} } } local 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"} } local areaPosition = { {x=568, y=624, z=7, stackpos = 255}, {x=589, y=640, z=7, stackpos = 255} } local demonOak = {8288, 8289, 8290, 8291} local storages = { done = 35700, cutTree = 36901 } local blockingTree = { [2709] = {32193, 3669} } if blockingTree[itemEx.itemid] and itemEx.uid == blockingTree[itemEx.itemid][1] then local tree = toPosition if isInRange(tree, areaPosition[1], areaPosition[2]) then print("[Warning - Error::Demon Oak] 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: " .. areaPosition[1].x .. ", y: " .. areaPosition[1].y .. ", z: " .. areaPosition[1].z .. ")\nSouth-West area position (x: " .. areaPosition[2].x .. ", y: " .. areaPosition[2].y .. ", z: " .. areaPosition[2].z .. ")\nScript will not work correctly, please fix it.") doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Something is wrong, please contact a gamemaster.") return false end if getPlayerLevel(cid) < level then doPlayerSendCancel(cid, "You need level " .. level .. " or more to enter this quest.") return true end if getPlayerStorageValue(cid, storages.done) > 0 then doPlayerSendCancel(cid, "You already done this quest.") return true end if getPlayerStorageValue(cid, storages.cutTree) > 0 then return false end if onePerQuest then local players = getPlayersOnline() for _, pid in ipairs(players) do if isInRange(getCreaturePosition(pid), areaPosition[1], areaPosition[2]) then doPlayerSendCancel(cid, "Wait until " .. getCreatureName(pid) .. " finish the quest.") return true end end end doTransformItem(itemEx.uid, blockingTree[itemEx.itemid][2]) doSendMagicEffect(toPosition, CONST_ME_POFF) doMoveCreature(cid, SOUTH) doPlayerSetStorageValue(cid, storages.cutTree, 1) return true elseif isInArray(demonOak, itemEx.itemid) then local get = getPlayerStorageValue(cid, itemEx.itemid) if get == -1 then doPlayerSetStorageValue(cid, itemEx.itemid, 1) end if(getPlayerStorageValue(cid, 8288) == 12 and getPlayerStorageValue(cid, 8289) == 12 and getPlayerStorageValue(cid, 8290) == 12 and getPlayerStorageValue(cid, 8291) == 12) then doTeleportThing(cid, positions.kick) doPlayerSetStorageValue(cid, storages.done, 1) return true end if getPlayerStorageValue(cid, itemEx.itemid) > 11 then doSendMagicEffect(toPosition, CONST_ME_POFF) return true end if(math.random(100) <= 1) then doPlayerSetStorageValue(cid, itemEx.itemid, 12) return true end if summons[get] then for i = 1, #summons[get] do doCreateMonster(summons[get][i], positions.summon[i]) 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 return false end end
..data/actions/scripts/demonOakGravestone.lua
LUA:function onUse(cid, item, fromPosition, itemEx, toPosition) local position = {x=586, y=630, z=8} -- reward room if getPlayerStorageValue(cid, 35700) > 1 then doTeleportThing(cid, position) doSendMagicEffect(position, CONST_ME_TELEPORT) else return false end return true end
..data/actions/scripts/demonOakChests.lua
LUA:function onUse(cid, item, fromPosition, itemEx, toPosition) 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) doPlayerSetStorageValue(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) doPlayerSetStorageValue(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) doPlayerSetStorageValue(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) doPlayerSetStorageValue(cid, 12900, 1) else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.") end end return true end
Add this to actions.xml
LUA:<action itemid="8293" event="script" value="demonOak.lua"/> <action fromuid="12901" touid ="12904" event="script" value="demonOakChests.lua"/> <action uniqueid="55100" event="script" value="demonOakGravestone.lua" />
..data/movements/scripts/demonOakTree.lua
LUA:function onStepOut(cid, item, position, fromPosition) if(item.uid == 32193) then doTransformItem(item.uid, 2709) end return true end
..data/movements/scripts/demonOakArea.lua
LUA:function onStepIn(cid, item, position, fromPosition) if isPlayer(cid) == true and math.random(1, 24) == 1 then doTargetCombatHealth(0, cid, COMBAT_EARTHDAMAGE, -270, -310, CONST_ME_BIGPLANTS) end return true end
Add this to movements.xml
LUA:<movevent type="StepOut" uniqueid="32193" event="script" value="demonOakTree.lua" /> <movevent type="StepIn" itemid="8292" event="script" value="demonOakArea.lua" />
..data/creaturescripts/scripts/demonOakLogout.lua
LUA:function onLogout(cid) if getPlayerStorageValue(cid, 36901) > 0 and getPlayerStorageValue(cid, 35700) < 1 then doPlayerSetStorageValue(cid, 36901, 0) end return true end
..data/creaturescripts/scripts/demonOakDeath.lua
LUA:function onDeath(cid, corpse) if getPlayerStorageValue(cid, 36901) > 0 and getPlayerStorageValue(cid, 35700) < 1 then doPlayerSetStorageValue(cid, 36901, 0) end return true end
Add this to login.lua
LUA:registerCreatureEvent(cid, "demonOakLogout") registerCreatureEvent(cid, "demonOakDeath")
And this to creaturescripts.xml
LUA:<event type="logout" name="demonOakLogout" event="script" value="demonOakLogout.lua"/> <event type="death" name="demonOakDeath" event="script" value="demonOakDeath.lua"/>
Npc by Mazen (Oldrak.xml)
..data/npc/Oldrak.xml
LUA:<npc name="Oldrak" script="data/npc/scripts/oldrak.lua" walkinterval="2000" floorchange="0" access="3" level="1" maglevel="1"> <health now="150" max="150"/> <look type="57" head="115" body="113" legs="31" feet="38" addons="3" corpse="2212"/> <parameters> <parameter key="message_greet" value="Hello, |PLAYERNAME|!" /> <parameter key="message_needmoremoney" value="Try again when you have more money."/> <parameter key="message_decline" value="Why would you tease me like that?"/> </parameters> </npc>
..data/npc/scripts/oldrak.lua
LUA:local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) -- OTServ event handling functions start function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end -- OTServ event handling functions end function creatureSayCallback(cid, type, msg) -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself. if (not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'hallowed axe') then npcHandler:say('Do you want to buy a Hallowed Axe from me?', cid) talk_state = 1 elseif msgcontains(msg, 'yes') and talk_state == 1 then local price = 1000 if getPlayerItemCount(cid, 2386) >= 1 and getPlayerMoney(cid) >= price then if doPlayerRemoveMoney(cid, price) == true then npcHandler:say('Here you are. You can now defeat the demon oak with this axe.', cid) doPlayerRemoveItem(cid, 2386, 1) doPlayerAddItem(cid, 8293, 1) talk_state = 0 end else npcHandler:say('I need an axe and ' .. price .. ' gold coins to make you a {hallowed axe}.', cid) talk_state = 0 end elseif msgcontains(msg, 'demon oak') then npcHandler:say('Did you defeat the demon oak?', cid) talk_state = 2 elseif msgcontains(msg, 'yes') and talk_state == 2 then if getPlayerStorageValue(cid, 35700) == 1 then npcHandler:say('Good job!', cid) doPlayerSetStorageValue(cid, 35700, 2) talk_state = 0 else npcHandler:say('Go defeat the demon oak first.', cid) talk_state = 0 end ------------------------------------------------ confirm no ------------------------------------------------ elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then npcHandler:say('Ok thanks.', cid) talk_state = 0 end -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself. return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Reserved ids:
Code:2709 --id of dead tree 3669 --when you use axe in the dead tree, it will be transformed to mthis item 35700 --storage when finish the quest 36901 --storage when you cut the tree 32193 --uniqueid of the dead tree 12901 to 12904 --unique ids for the chests 12900 --storage for the chests
Note: 11 cuts to each demon oak part, but there is a possibility of 10% that it is not necessary to do 11 cuts to that part, you can change the percentage here:
@0.3.6LUA:if(math.random(100) <= 10) then doPlayerSetStorageValue(cid, itemEx.itemid, 12) return true end
If you've a error in console when you're trying to cut the dead tree with the function "isInRange", go to data/lib/position.lua and replace:
With this:LUA:function isInRange(pos, fromPosition, toPosition)
LUA:function isInRange(position, fromPosition, toPosition)
That's a bug in the 0.3.6, report it to elf.
Enjoy!
local areaPosition =
(
(X = 568, y = 624, z = 7, stackpos = 255),
(X = 589, y = 640, z = 7, stackpos = 255)
I do not understand is part
Code:local areaPosition = ( (X = 568, y = 624, z = 7, stackpos = 255), (X = 589, y = 640, z = 7, stackpos = 255)