• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[10.77][TFS 1.2] ORTS, a real map project

hey, I told you some time ago that I had the pillows mission of dreamer's challenge quest... here it is (it's from OTSL):

movements.xml
Code:
    <movevent type="StepIn" actionid="5400" event="script" value="pillow.lua" />
    <movevent type="StepOut" actionid="5400" event="script" value="pillow.lua" />
    <movevent type="StepIn" actionid="5401" event="script" value="pillow.lua" />
    <movevent type="StepOut" actionid="5401" event="script" value="pillow.lua" />
    <movevent type="StepOut" actionid="5408" event="script" value="pillow.lua" />

pillow.lua
Code:
-- >>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 config = {
    teleport_aid = 5408
}
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 = 32826, y = 32347, z = 9} -- Where should the teleport be spawned when you finnish the puzzle?
local newPosition = {x = 32764, y = 32273, z = 14} -- Where should you get teleported when you enter the teleport?
local position = {x = 32818, y = 32334, z = 9} -- Position of the north west (top left) side of the puzzle area.
local magicEffect = 49 -- 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, 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, 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)
          doItemSetAttribute(newTeleport, "aid", config.teleport_aid)
        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
 
thanks @guiismiti , I'll open an issue with this script so anyone can review it and add =)

btw can you kindly update your issue #602 if you are still using this project of course xD


@Romantix
I'll open an issue so we can check all party spells, they need to be remade =P thanks for pointing this out
 
Last edited by a moderator:
@Evil Puncker
It's been closed. I've been editting another distribution (only real map I could run on 1Gb RAM that had the exe in the pack, since I tried to compile other distributions but I just don't know how to).
There are other things I found in OTSL that haven't been implemented yet.

I also created the pillars at Ferumbras room (the ones that summon demons), and the bone archs that summon demons at shadow nexus, will be posting soon
 
@Evil Puncker
It's been closed. I've been editting another distribution (only real map I could run on 1Gb RAM that had the exe in the pack, since I tried to compile other distributions but I just don't know how to).
There are other things I found in OTSL that haven't been implemented yet.

I also created the pillars at Ferumbras room (the ones that summon demons), and the bone archs that summon demons at shadow nexus, will be posting soon

the pillars I've made them already, just need to add them to map =) the bone archs will be cool =)
 
I made the paralyze thrower from Madareth's room. I haven't opened that distro for over 1 month now, I really don't know what's already done.
So, about your pillars - I added the SD effect on itself on <defenses>. Also, they summon a max of 3 demons each at Ferumbras tower, and 1 demon each in Shadow Nexus.
I don't know how to make pull requests on github though ._. I posted as issue
 
Oh, and please check if this is compatible with the distro:
<attributekey="areaEffect"value="poff"/>
 
whats issue with NPC Avar Tar he will not respond when i ask for base, helmet, etc

here is code

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if msgcontains(msg, "outfit") then
if npcHandler.topic[cid] == 0 then
npcHandler:say({"I'm tired of all these young unskilled wannabe heroes. Every Tibian can show his skills or actions by wearing a special outfit. To prove oneself worthy of the demon outfit, this is how it goes: ...",
"The base outfit will be granted for completing the annihilator quest, which isn't much of a challenge nowadays, in my opinion. Anyway ...",
"The shield however will only be granted to those adventurers who have finished the demon helmet quest. ...",
"Well, the helmet is for those who really are tenacious and have hunted down all 6666 demons and finished the demon oak as well. ...",
"Are you interested?"
}, cid)
npcHandler.topic[cid] = 1
end
elseif msgcontains(msg, "base") then
if npcHandler.topic[cid] == 2 then
if player:getStorageValue(Storage.AnnihilatorDone) == 1 then
player:addOutfit(541, 0)
player:addOutfit(542, 0)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:setStorageValue(Storage.Annihilator.Done, 2)
npcHandler:say("Receive the base outfit, " .. player:getName() .. ".", cid)
npcHandler.topic[cid] = 0
end
end
elseif msgcontains(msg, "shield") then
if npcHandler.topic[cid] == 2 then
if player:getStorageValue(Storage.AnnihilatorDone) == 2 and player:getStorageValue(2217) == 1 then
player:addOutfitAddon(541, 1)
player:addOutfitAddon(542, 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
npcHandler:say("Receive the shield, " .. player:getName() .. ".", cid)
player:setStorageValue(2217, 2)
npcHandler.topic[cid] = 0
end
end
elseif msgcontains(msg, "helmet") then
if npcHandler.topic[cid] == 2 then
if player:getStorageValue(Storage.AnnihilatorDone) == 2 and player:getStorageValue(Storage.DemonOak.Done) == 3 then
player:addOutfitAddon(541, 2)
player:addOutfitAddon(542, 2)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:setStorageValue(Storage.DemonOak.Done, 4)
npcHandler:say("Receive the helmet, " .. player:getName() .. ".", cid)
end
end
elseif msgcontains(msg, "yes") then
if npcHandler.topic[cid] == 1 then
npcHandler:say("So you want to have the demon outfit, hah! Let's have a look first if you really deserve it. Tell me: {base}, {shield} or {helmet}?", cid)
npcHandler.topic[cid] = 2
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, "Greetings, traveller |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you later, |PLAYERNAME|.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you later, |PLAYERNAME|.")
npcHandler:addModule(FocusModule:new())
 
also getting a error with
when using bullseye, berserker potion etc
Code:
strengthening_potions.lua
 
Try this:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
     if not npcHandler:isFocused(cid) then
         return false
     end
     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local player = Player(cid)
if msgcontains(msg, "outfit") then
if npcHandler.topic[cid] == 0 then
npcHandler:say({"I'm tired of all these young unskilled wannabe heroes. Every Tibian can show his skills or actions by wearing a special outfit. To prove oneself worthy of the demon outfit, this is how it goes: ...",
"The base outfit will be granted for completing the annihilator quest, which isn't much of a challenge nowadays, in my opinion. Anyway ...",
"The shield however will only be granted to those adventurers who have finished the demon helmet quest. ...",
"Well, the helmet is for those who really are tenacious and have hunted down all 6666 demons and finished the demon oak as well. ...",
"Are you interested?"
}, cid)
npcHandler.topic[cid] = 1
end
elseif msgcontains(msg, "base") then
if npcHandler.topic[cid] == 2 then
if player:getStorageValue(Storage.AnnihilatorDone) == 1 then
player:addOutfit(541, 0)
player:addOutfit(542, 0)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:setStorageValue(Storage.Annihilator.Done, 2)
npcHandler:say("Receive the base outfit, " .. player:getName() .. ".", cid)
npcHandler.topic[cid] = 0
end
end
elseif msgcontains(msg, "shield") then
if npcHandler.topic[cid] == 2 then
if player:getStorageValue(Storage.AnnihilatorDone) == 2 and player:getStorageValue(2217) == 1 then
player:addOutfitAddon(541, 1)
player:addOutfitAddon(542, 1)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
npcHandler:say("Receive the shield, " .. player:getName() .. ".", cid)
player:setStorageValue(2217, 2)
npcHandler.topic[cid] = 0
end
end
elseif msgcontains(msg, "helmet") then
if npcHandler.topic[cid] == 2 then
if player:getStorageValue(Storage.AnnihilatorDone) == 2 and player:getStorageValue(Storage.DemonOak.Done) == 3 then
player:addOutfitAddon(541, 2)
player:addOutfitAddon(542, 2)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:setStorageValue(Storage.DemonOak.Done, 4)
npcHandler:say("Receive the helmet, " .. player:getName() .. ".", cid)
end
end
elseif msgcontains(msg, "yes") then
if npcHandler.topic[cid] == 1 then
npcHandler:say("So you want to have the demon outfit, hah! Let's have a look first if you really deserve it. Tell me: {base}, {shield} or {helmet}?", cid)
npcHandler.topic[cid] = 2
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, "Greetings, traveller |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you later, |PLAYERNAME|.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you later, |PLAYERNAME|.")
npcHandler:addModule(FocusModule:new())
 
Back
Top