Action [TFS0.3.5] Updated Demon Oak Quest

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Best answers
0
Reaction score
12
Location
Poland
Some days ago Szakal had posted here Demon Oak Quest. Now his script is outdated and may cause problems, so I have decided to rewrite it to fit with the newest updates of The Forgotten Server.

Here you are:

data/actions/scripts/demonOakChests.lua:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerStorageValue(cid, 50090) > 0) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
		return TRUE
	else
		if(item.uid == 12901) then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found demon legs.")
			doPlayerAddItem(cid, 2495, 1)
		elseif(item.uid == 12902) then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a rainbow shield.")
			doPlayerAddItem(cid, 8905, 1)
		elseif(item.uid == 12903) then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a royal crossbow.")
			doPlayerAddItem(cid, 8851, 1)
		elseif(item.uid == 12904) then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a spellbook of dark mysteries.")
			doPlayerAddItem(cid, 8918, 1)
		end
		setPlayerStorageValue(cid, 50090, 1)
	end
	return TRUE
end
data/actions/scripts/demonOakGravestone.lua:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local newPosition = {x=32718, y=32396, z=8}
	if(item.itemid == 1406 and getPlayerStorageValue(cid, 8585) > 0) then
		doTeleportThing(cid, newPosition, TRUE)
		doSendMagicEffect(newPosition, CONST_ME_TELEPORT)
		doSendMagicEffect(fromPosition, CONST_ME_POFF)
		setPlayerStorageValue(cid, 8585, -1)
	end
	return TRUE
end

data/actions/scripts/demonOak.lua:

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local blockingTreePosition = {x=32720, y=32345, z=7, stackpos=1}
	local firstMonsterSpawn = {x=32717, y=32347, z=7}
	local secondMonsterSpawn = {x=32724, y=32348, z=7}
	local thirdMonsterSpawn = {x=32716, y=32353, z=7}
	local fourthMonsterSpawn = {x=32724, y=32353, z=7}
	local blockingTree = getThingfromPos(blockingTreePosition).uid
	local randomizer = math.random(1,6)
	local firstQuestStatus = getPlayerStorageValue(cid, 8181)
	local secondQuestStatus = getPlayerStorageValue(cid, 8282)
	local thirdQuestStatus = getPlayerStorageValue(cid, 8383)
	local fourthQuestStatus = getPlayerStorageValue(cid, 8484)
	if(itemEx.itemid == 2709 and itemEx.actionid == 7787 and getPlayerLevel(cid) >= 120) then
		doRemoveItem(blockingTree)
		doTeleportThing(cid, toPosition, TRUE)
		setPlayerStorageValue(cid, 8181, 1)
	else
		doSendMagicEffect(toPosition, CONST_ME_POFF)
		return TRUE
	end
	if(itemEx.itemid == 2709 and itemEx.actionid == 7788) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Another player is already doing this quest.")
		return TRUE
	end
	if(itemEx.itemid == 8289 and itemEx.actionid == 8181 and randomizer == 1 and firstQuestStatus == 1) then
		doSummonCreature("Crypt Shambler", firstMonsterSpawn)
		doSummonCreature("Crypt Shambler", secondMonsterSpawn)
		doSummonCreature("Crypt Shambler", thirdMonsterSpawn)
		doSummonCreature("Crypt Shambler", fourthMonsterSpawn)
	elseif(itemEx.itemid == 8289 and itemEx.actionid == 8181 and randomizer == 2 and firstQuestStatus == 1) then
		doSummonCreature("Bone Beast", firstMonsterSpawn)
		doSummonCreature("Bone Beast", secondMonsterSpawn)
		doSummonCreature("Bone Beast", thirdMonsterSpawn)
		doSummonCreature("Bone Beast", fourthMonsterSpawn)
	elseif(itemEx.itemid == 8289 and itemEx.actionid == 8181 and randomizer == 3 and firstQuestStatus == 1) then
		doSummonCreature("Betrayed Wraith", firstMonsterSpawn)
		doSummonCreature("Lost Soul", secondMonsterSpawn)
		setPlayerStorageValue(cid, 8181, -1)
		setPlayerStorageValue(cid, 8282, 1)
	elseif(itemEx.itemid == 8289 and itemEx.actionid == 8181 and randomizer >= 4 and firstQuestStatus == 1) then
		doSendMagicEffect(fromPosition, 45)
		doCreatureAddHealth(cid, -300)
		doSendAnimatedText(fromPosition, '300', TEXTCOLOR_LIGHTGREEN)
	end
	if(itemEx.itemid == 8289 and itemEx.actionid == 8181 and firstQuestStatus < 1) then
		doSendMagicEffect(toPosition, CONST_ME_POFF)
		return TRUE
	end
	if(itemEx.itemid == 8288 and itemEx.actionid == 8282 and randomizer == 1 and secondQuestStatus == 1) then
		doSummonCreature("Crypt Shambler", firstMonsterSpawn)
		doSummonCreature("Mummy", secondMonsterSpawn)
		doSummonCreature("Mummy", thirdMonsterSpawn)
		doSummonCreature("Crypt Shambler", fourthMonsterSpawn)
	elseif(itemEx.itemid == 8288 and itemEx.actionid == 8282 and randomizer == 2 and secondQuestStatus == 1) then
		doSummonCreature("Giant Spider", firstMonsterSpawn)
		doSummonCreature("Giant Spider", fourthMonsterSpawn)
	elseif(itemEx.itemid == 8288 and itemEx.actionid == 8282 and randomizer == 3 and secondQuestStatus == 1) then
		doSummonCreature("Blightwalker", firstMonsterSpawn)
		doSummonCreature("Lost Soul", secondMonsterSpawn)
		setPlayerStorageValue(cid, 8282, -1)
		setPlayerStorageValue(cid, 8383, 1)
	elseif(itemEx.itemid == 8288 and itemEx.actionid == 8282 and randomizer >= 4 and secondQuestStatus == 1) then
		doSendMagicEffect(fromPosition, 45)
		doCreatureAddHealth(cid, -300)
		doSendAnimatedText(fromPosition, '300', TEXTCOLOR_LIGHTGREEN)
	end
	if(itemEx.itemid == 8288 and itemEx.actionid == 8282 and secondQuestStatus < 1) then
		doSendMagicEffect(toPosition, CONST_ME_POFF)
		return TRUE
	end
	if(itemEx.itemid == 8290 and itemEx.actionid == 8383 and randomizer == 1 and thirdQuestStatus == 1) then
		doSummonCreature("Crypt Shambler", firstMonsterSpawn)
		doSummonCreature("Crypt Shambler", secondMonsterSpawn)
		doSummonCreature("Crypt Shambler", thirdMonsterSpawn)
		doSummonCreature("Crypt Shambler", fourthMonsterSpawn)
	elseif(itemEx.itemid == 8290 and itemEx.actionid == 8383 and randomizer == 2 and thirdQuestStatus == 1) then
		doSummonCreature("Lich", firstMonsterSpawn)
		doSummonCreature("Lich", secondMonsterSpawn)
		doSummonCreature("Lich", thirdMonsterSpawn)
		doSummonCreature("Lich", fourthMonsterSpawn)
	elseif(itemEx.itemid == 8290 and itemEx.actionid == 8383 and randomizer == 3 and thirdQuestStatus == 1) then
		doSummonCreature("Plaguesmith", firstMonsterSpawn)
	      doSummonCreature("Plaguesmith", secondMonsterSpawn)
		setPlayerStorageValue(cid, 8383, -1)
		setPlayerStorageValue(cid, 8484, 1)
	elseif(itemEx.itemid == 8290 and itemEx.actionid == 8383 and randomizer >= 4 and thirdQuestStatus == 1) then
		doSendMagicEffect(fromPosition, 45)
		doCreatureAddHealth(cid, -300)
		doSendAnimatedText(fromPosition, '300', TEXTCOLOR_LIGHTGREEN)
	end
	if(itemEx.itemid == 8290 and itemEx.actionid == 8383 and thirdQuestStatus < 1) then
		doSendMagicEffect(toPosition, CONST_ME_POFF)
		return TRUE
	end
	if(itemEx.itemid == 8291 and itemEx.actionid == 8484 and randomizer == 1 and fourthQuestStatus == 1) then
		doSummonCreature("Nightmare", firstMonsterSpawn)
		doSummonCreature("Mummy", secondMonsterSpawn)
		doSummonCreature("Mummy", thirdMonsterSpawn)
		doSummonCreature("Nightmare", fourthMonsterSpawn)
	elseif(itemEx.itemid == 8291 and itemEx.actionid == 8484 and randomizer == 2 and fourthQuestStatus == 1) then
		doSummonCreature("Giant spider", firstMonsterSpawn)
		doSummonCreature("Undead Dragon", secondMonsterSpawn)
		doSummonCreature("Giant Spider", secondMonsterSpawn)
		doSummonCreature("Giant Spider", thirdMonsterSpawn)
	elseif(itemEx.itemid == 8291 and itemEx.actionid == 8484 and randomizer == 3 and fourthQuestStatus == 1) then
		doSummonCreature("Demon", firstMonsterSpawn)
		doSummonCreature("Juggernaut", secondMonsterSpawn)
		setPlayerStorageValue(cid, 8484, -1)
		setPlayerStorageValue(cid, 8585, 1)
	elseif(itemEx.itemid == 8291 and itemEx.actionid == 8484 and randomizer >= 4 and fourthQuestStatus == 1) then
		doSendMagicEffect(fromPosition, 45)
		doCreatureAddHealth(cid, -300)
		doSendAnimatedText(fromPosition, '300', TEXTCOLOR_LIGHTGREEN)
	end
	if(itemEx.itemid == 8291 and itemEx.actionid == 8484 and fourthQuestStatus < 1) then
		doSendMagicEffect(toPosition, CONST_ME_POFF)
		return TRUE
	end
	return TRUE
end
And movements..

data/movements/scripts/demonOakTree.lua:
Lua:
function onStepIn(cid, item, position, fromPosition)
	local blockingTreePosition = {x=32720, y=32345, z=7}
	local firstTree = doCreateItem(2709, 1, blockingTreePosition)
	local secondTree = doCreateItem(2709, 1, blockingTreePosition)
	if(item.itemid == 103) then
		doSetItemActionId(firstTree, 7788)		
		doSetItemActionId(secondTree, 7787)
	end
	return TRUE
end
data/movements/scripts/demonOakRemoveTree.lua:
Lua:
function onStepIn(cid, item, pos)
	local blockingTreePosition = {x=32720, y=32345, z=7, stackpos=2}
	local getBlockingTree = getThingfromPos(blockingTreePosition)
	if(isPlayer(cid) == TRUE) then
		doRemoveItem(getBlockingTree.uid)		
	end
	return TRUE
end

And now declaring time!
data/actions/actions.xml:
Code:
<action fromuid="12901" touid="12904" event="script" value="demonOakChests.lua" />
<action uniqueid="55100" event="script" value="demonOakGravestone.lua" />
<action itemid="8293" event="script" value="demonOak.lua"/>
data/movements/movements.xml:
Code:
<movevent type="StepIn" actionid="7789" event="script" value="demonOakTree.lua"/>
<movevent type="StepIn" uniqueid="14449" event="script" value="demonOakRemoveTree.lua"/>
And actionids&uniqueids used in scripts:
Code:
Left arm: 8181
Face: 8282
Right Arn: 8383
Crow: 8484
Tree blocking path: 7789
Gravestone: 55100
NOTE. If you are using older versions of TFS than 0.3.4 or even other engine, you should declare scripts in movements and actions xml files in other way:
actions.xml:
Code:
<action uniqueid="12901" script="demonOakChests.lua" />
<action uniqueid="12902" script="demonOakChests.lua" />
<action uniqueid="12903" script="demonOakChests.lua" />
<action uniqueid="12904" script="demonOakChests.lua" />
<action uniqueid="55100" script="demonOakGravestone.lua" />
<action itemid="8293" script="demonOak.lua"/>
movements.xml:
Code:
<movevent event="StepIn" actionid="7789" script="demonOakTree.lua"/>
<movevent event="StepIn" uniqueid="14449" script="demonOakRemoveTree.lua"/>
NOTE2. Script demonOak.lua IS NOT really optimized. But it will work like a charm.

Thanks,
Hermes
 
Last edited:

Gregor

New Member
Joined
Feb 29, 2008
Messages
770
Best answers
0
Reaction score
3
Location
UK/POLAND
Very nice! Thx :p
ps. what happen if someone die in demon oak area?
 

Fare

Well-Known Member
Joined
Apr 3, 2008
Messages
2,386
Best answers
0
Reaction score
92
Location
Ukraine
Can someone release map piece of that quest? :)
 
OP
Hermes

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Best answers
0
Reaction score
12
Location
Poland
@Gregor
Then Demon Oak Quest is blocked until server restart :p.

I don't really care. Just rewritten script.

On mine server it's really difficult to get there so I think players will prepare yourself to not die there :D

@Fare
Humm, I can't take it from my server because of plenty of actionids used there :f. If someone gonna release map there, I will include it into main post, and I will add actionids and uniqueids on map aswell.
 

Evan

A splendid one to behold
Premium User
Joined
May 6, 2009
Messages
7,017
Best answers
1
Reaction score
942
Location
United States
Very nice! Thx :p
ps. what happen if someone die in demon oak area?
The quest can only be done once per server save, I think it's the same in real Tibia, but prolly not per server save prolly once per week or so. So, its best to have the quest not be resetted.
 
OP
Hermes

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Best answers
0
Reaction score
12
Location
Poland
Yeah. Since that Cipsoft's fix it's almost impossible to do Demon Oak Quest :p
 

Zonet

Web Developer
Joined
Sep 1, 2008
Messages
4,375
Best answers
0
Reaction score
38
Location
realpath( dirname( __FILE__ ) );
@Gregor
Then Demon Oak Quest is blocked until server restart :p.

I don't really care. Just rewritten script.

On mine server it's really difficult to get there so I think players will prepare yourself to not die there :D
what about the function isInArea or isInArray :)?

Lua:
local frompos = the from pos....
local topos = the to pos
if isInArea(getPlayerPosition(cid), frompos, topos) then
Should be onPrepareDeath.
 
OP
Hermes

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Best answers
0
Reaction score
12
Location
Poland
And soon will be public..
 
Joined
Dec 22, 2007
Messages
1,984
Best answers
0
Reaction score
2
If you don't want it to be blocked because of someone's death you can use globalstorage (teleporting players from inside would be needed). It's not the perfect solution, but for an example 15 minutes for that quest is enough and the quest won't be blocked ;p
 

Mazen

Developer
Joined
Aug 20, 2007
Messages
612
Best answers
0
Reaction score
36
Location
Sweden
Nice script. But it's not similar to the rl tibia one. :eek:
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,327
Best answers
33
Reaction score
832
Location
Arica - Chile
Hey mazen.. can u release the ta4e demon oak system plz :)
is (90%) real :)
 
Top