Kedor
New Member
i dont know where to post it but any1 got Dreamer's Challenge Quest map? i mean the quest cuz i cant find it anywhere it can be even semi-custom part of map ofc
Hello everybody!
I've made this script by a request from Etheryn. Yet another quest idea token from Tibia!
The script works like this:
- Walk on tiles to push the pillows.
- Creates a teleport when the puzzle is finnished
- Puzzle will reset when you walk into the teleport, and the teleport will be removed.
How to handle the settings/config:
This is the actionid of all vertical tiles (When you have maped the area you will understand), don't forget to add this actionid to the tiles! Without the actionids on the correct tiles, the script won't work (properly).Code:local verticalTiles = 5400
This is the actionid of all horizontal tiles (When you have maped the area you will understand), don't forget to add this actionid to the tiles! Without the actionids on the correct tiles, the script won't work (properly).Code:local horizontalTiles = 5401
"normal" is the itemid of the ground tile when it's not used, which means when you don't stand on it. The other one, "used", is the itemid of the ground when you use it, which means when you're standing on it. These are the tiles who has the actionid mentioned in "verticalTiles" and "horizontalTiles"!Code:local ground = {normal = 426, used = 425}
"itemid" is the itemid and "actionid" is the actionid of the teleport that appears when you have finnished the puzzle.Code:local teleport = {itemid = 1387, actionid = 5408}
This is the position where the teleport will be spawned/created when you finnish the puzzle.Code:local teleportPosition = {x = 584, y = 371, z = 7}
This is the position where the teleport will send you (The one which spawns/creates when you finnish the puzzle).Code:local newPosition = {x = 595, y = 381, z = 7}
This should be the north west (top left) position of the puzzles area. Take a look at the image if you don't understand this.Code:local position = {x = 587, y = 374, z = 7}
This one is not so important, it will just send a effect on the player when he/she finnish the puzzle. To exclude it, please type "local magicEffect = nil" instead, because you might change your mind one dayCode:local magicEffect = 12
Please save this image, you might forget how to use this script later!
Notice the bright blue rectangle. That position is the position you are going to write in the variable "position", let's say for example in your map that position is: x = 200 and y = 350 and z = 7, then it would look like this in the script:
Now to the script.Code:local position = {x = 200, y = 350, z = 7}
data/movements/scripts
- pillow puzzle.lua
data/movementsCode:-- >>CREDITS<< -- -- Script 100% by COLANDUS -- Functions 100% by COLANDUS -- OPENLUA.COM -- -- >>CREDITS<< -- -- >>INFO<< -- -- Don't forget: Place 9 pillows of each color in different order in the mapeditor! -- Do you use a lever to teleport you to this room? Then you could make it randomize the puzzle when you press it! -- If you do that, you could remove the randomize part, so it doesn't randomize in this script, make it randomize only when you pull the lever. -- Your own choise, just giving you ideas! -- Pilow order to complete: -- BLUE, GREEN -- RED, YELLOW -- >>INFO<< -- -- >>CONFIG<< -- local verticalTiles = 5400 -- Action id of the vertical tiles. local horizontalTiles = 5401 -- Action id of the horizontal tiles. local ground = {normal = 426, used = 425} -- Itemid of the ground tile when it is normal or used (when you stand on it) local teleport = {itemid = 1387, actionid = 5408} -- Enter the itemid and the actionid of the teleport. local teleportPosition = {x = 584, y = 371, z = 7} -- Where should the teleport be spawned when you finnish the puzzle? local newPosition = {x = 595, y = 381, z = 7} -- Where should you get teleported when you enter the teleport? local position = {x = 587, y = 374, z = 7} -- Position of the north west (top left) side of the puzzle area. local magicEffect = 12 -- What effect will appear when you finnish the puzzle? Leave blank or write "nil" if you don't want any. -- >>CONFIG<< -- function onStepIn(cid, item, pos) teleportPosition.stackpos = 1 local getTeleport = getThingfromPos(teleportPosition) if getTeleport.itemid == teleport.itemid and getTeleport.actionid == teleport.actionid then doRemoveItem(getTeleport.uid, 1) end local getPillow = {} if item.actionid == verticalTiles then for i = 0, 5 do getPillow[i + 1] = getThingfromPos({x = position.x + (i * 1), y = getPlayerPosition(cid).y, z = position.z, stackpos = 1}) end elseif item.actionid == horizontalTiles then for i = 0, 5 do getPillow[i + 1] = getThingfromPos({x = getPlayerPosition(cid).x, y = position.y + (i * 1), z = position.z, stackpos = 1}) end end doTransformItem(getPillow[1].uid, getPillow[6].itemid) for i = 1, 5 do doTransformItem(getPillow[i + 1].uid, getPillow[i].itemid) end if checkPillows(position.x, position.y, 1686) == 1 and checkPillows(position.x + 3, position.y, 1688) == 1 and checkPillows(position.x, position.y + 3, 1687) == 1 and checkPillows(position.x + 3, position.y + 3, 1689) == 1 then local newTeleport = doCreateTeleport(teleport.itemid, newPosition, teleportPosition) doSetItemActionId(newTeleport, teleport.actionid) if magicEffect ~= nil then doSendMagicEffect(pos, magicEffect) end end doTransformItem(item.uid, ground.used) return 1 end function onStepOut(cid, item, pos) pos.stackpos = 1 local getPos = getThingfromPos(pos) teleportPosition.stackpos = 1 local getTeleport = getThingfromPos(teleportPosition) if comparePos(pos, teleportPosition) and getPos.itemid == getTeleport.itemid and getPos.actionid == getTeleport.actionid then teleportPosition.stackpos = 1 doRemoveItem(getTeleport.uid, 1) resetPuzzle() return 1 else doTransformItem(item.uid, ground.normal) return 1 end end function checkPillows(posx, posy, item) local returnValue = 1 for gx = posx, posx + 2 do for gy = posy, posy + 2 do if getThingfromPos({x = gx, y = gy, z = position.z, stackpos = 1}).itemid ~= item then returnValue = 0 break end end end return returnValue end function resetPuzzle() local availablePillows = {} for i = 0, 3 do local pillowId = 1686 + i for i = 1, 9 do table.insert(availablePillows, pillowId) end end availablePillows = shuffleTable(availablePillows) for gx = position.x, position.x + 5 do for gy = position.y, position.y + 5 do local pillow = math.random(1, #availablePillows) getItem = getThingfromPos({x = gx, y = gy, z = position.z, stackpos = 1}) doTransformItem(getItem.uid, availablePillows[pillow]) table.remove(availablePillows, pillow) end end end function shuffleTable(t) local newTable = {} for i = 1, #t do randomId = math.random(1, #t) table.insert(newTable, t[randomId]) table.remove(t, randomId) end return newTable end
- movements.xml
All you have to do in the mapeditor is making the pillow area, placing the pillows in a random order (not as the completed one), setting an actionid (you choose, write in the "config" which one you choosed), to each vertical tile, and another actionid to the horizontal tiles, and ofcourse you should change that in the "config" too. You could use the actionids that are already written in the "config" already, which is "5400" for the vertical tiles and "5401" for the horizontal tiles.Code:<movevent event="StepIn" actionid="5400" script="pillow puzzle.lua" /> <movevent event="StepOut" actionid="5400" script="pillow puzzle.lua" /> <movevent event="StepIn" actionid="5401" script="pillow puzzle.lua" /> <movevent event="StepOut" actionid="5401" script="pillow puzzle.lua" /> <movevent event="StepOut" actionid="5408" script="pillow puzzle.lua" />
Also, check your global.lua in the data folder, if this function is found:
If it isn't found, just add it =)Code:function comparePos(pos1, pos2) return (pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z) end
Note that this function, comparePos, was not made by me!
Note that if you use /clean, the puzzle will be cleaned aswell! Therefore, if you use a evolutions (based) server, you could use this one instead, which doesn't clean in PZ!
http://www.tibiafans.com/forums/showthread.php?t=5990
Please report any bugs, and tell me any way to improve this script (Only by the way of how Tibia does it). Also comment the script, what do you think about it, also tell me WHY do you think so?
Enjoy the script, please? =)
Regards,
Colandus