• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC [ai game] tic tac toe

sailorv5

Member
Joined
Oct 31, 2009
Messages
82
Reaction score
17
Obrigatório:
  • Nome: TIC TAC TOE GAME
  • Autor: eu mesmo ( eu ja usei tanto nome diferente ) rei vegeta hell firend sailorv5 endymion iamtoofast4you blablabla e a lista nao tem fim
  • Servidor Testado: Original Tibia 9.80 - Cliente 9.80
  • Descrição e/ou Informações Adicionais = e um NPC inteligente capaz de jogar o jogo da velha (3 niveis facil medio e pro )
  • Scripts e Como Instalar = ver abaixo

[video=youtube;Na66dJyVfZQ]http://www.youtube.com/watch?v=Na66dJyVfZQ[/video]





Como Instalar
vao no local indicado e criem as pasta ou arquivos necessario :



pasta data/npc/GM tic tac.xml
Code:
<?xml version="1.0"?>
<npc name="Master of tic tac toe" script="data/npc/scripts/games/tictactoe.lua" access="9" lookdir="3">
    <health now="1000000" max="1000000"/>
<look type="266" head="0" body="0" legs="0" feet="0"/>
</npc>

NPC BODY
data/npc/scripts/games/tictactoe.lua

Code:
    dofile(getDataDir() .. "npc/scripts/games/tictactoeVAR.lua")
    dofile(getDataDir() .. "npc/scripts/games/tictactoeFUNC.lua")

local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false



function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
      if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
      end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function creatureGetName    (cid)
        return getCreatureName(cid)
end


function onCreatureSay(cid, type, msg)
      msg = string.lower(msg)


      if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
    
            selfSay( getCreatureName(cid) ..' Isnt a good day today to play ?')
            doPlayerSendTextMessage(cid,18,"voce pode somente responder (yes,rules,bye)")
            focus = cid
            talk_start = os.clock()
      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
    
          selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
        doPlayerSendTextMessage(cid,18,"lamento mais tera que esperar!")

      elseif focus == cid then
        talk_start = os.clock()
        
        if msgcontains(msg, 'yes') then
        
            selfSay( creatureGetName(cid) ..' SO get ready the game start now.  ')
            doPlayerSendTextMessage(cid,18,"Playing")

        
        tokenPiecePlayer = doCreateItemEx(playerToken, 5)
        --    doItemSetAttribute(tokenPiecePlayer, "description", "GM VS " .. getCreatureName(cid) .. ".")
        doPlayerAddItemEx(cid, tokenPiecePlayer, 5, true)
        

tttturncount = 1
clearField( pos, field  )

            setPlayerStorageValue(cid, tttconfig.storage, tttconfig.storageData)
            selfSay('  Lets see who go First...'  )


        elseif msgcontains(msg, 'rules') and getDistanceToCreature(cid) < 4 then
            doPlayerSendTextMessage(cid,18,"BYE")
            selfSay('PLS Visit http://en.wikipedia.org/wiki/Tic-tac-toe')
            focus = 0
            talk_start = 0
            tttturncount = 0
        elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
            doPlayerSendTextMessage(cid,18,"BYE")
            selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
            focus = 0
            talk_start = 0
            tttturncount = 0
        end
    
    end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
    cid = focus
    
        if (os.clock() - talk_start) > 5
        and (tttturncount>0)  then

    ttPlayerMovesFt = tttPlayerMoves( pos, field , playerToken, true )
    ttNpcMoves = tttPlayerMoves( pos, field , npcToken, true )    --tttnpcMove
    tttlistofdanger= table.counter(goingtoWinPos, ttPlayerMovesFt)
    tttlistdotowin= table.counter(goingtoWinPos, ttNpcMoves)
    checkforcheater( pos, field, token)

        
            if tokenCount( pos, field , token ) > tttturncount  then
                selfSay('  I dont Play With Cheater like You' .. ' come back if u want to play for FUN. CHEATER...'  )
                focus = 0
                tttturncount = 0
            end
            if tttgamewinner(winnerPos, ttPlayerMovesFt) ~= false or tttgamewinner(winnerPos, ttNpcMoves) ~=false         then 
                selfSay(' Game Over Guess who won?  that was a nice game,  BUT a LOST one... bye '  )
                focus = 0
                tttturncount = 0
            else
                if playerTurn == 2  then
                    if tokenCount( pos, field , token  ) == tttturncount  then
                        selfSay('so easy  ' .. whoPlay[playerTurn] .. ' .'  )
                            playerTurn = 1
                            tttturncount = tttturncount +1
                            talk_start = os.clock()
                    else
--                        print (tokenCount( pos, field , token ))
                        selfSay(' Waitting...  Fast pls -.- ' ..tttturncount  )
                    end
                    
                else
                    selfSay('what u think?  ' .. whoPlay[playerTurn] .. ' .'.. creatureGetName(cid)  )
                    dofile(getDataDir() .. "npc/scripts/games/tictactoeLVhard.lua")
                    
--                    checkfield( cid,tttconfig, pos, field , playerToken , tttPlayerMoves( pos, field, playerToken ) )
                    
                    playerTurn = 2
                    tttturncount = tttturncount +1
                    talk_start = os.clock()
--                    print ("can u do better")
                end
              end
          if tttturncount > 9   then
                selfSay(' Game Over and NO Winner, u not that all BAD... bye '  )
                focus = 0
                tttturncount = 0
          end
--                print (tttturncount)
        end
    
      if (os.clock() - talk_start) > 40 then
          if focus > 0 then
              selfSay(' You make me sleep, BYE... ')
          end
              focus = 0
            tttturncount = 0
      end
    if focus ~= 0 then
         if getDistanceToCreature(focus) > 5 then
             selfSay('Good bye then.')
             focus = 0
            tttturncount = 0
         end
     end
end

FILE WITH GAME VAR
PLS ONLY CHANGE THE POS VAR
LOOK FOR
pos = {x = 994, y = 1512, z = 8}
inside tictactoeVAR.lua
and change it to the 1 square of ur field.


npc/scripts/games/tictactoeVAR.lua

Code:
pos = {x = 994, y = 1512, z = 8}
field = {    
        {
         {position ={x = pos.x+0, y = pos.y, z=pos.z,stackpos=1}},    -- field[1][1]    1st square
         {position ={x = pos.x+1, y = pos.y, z=pos.z,stackpos=1}},
         {position ={x = pos.x+2, y = pos.y, z=pos.z,stackpos=1}}    -- field[1][3]    last square of 1st line
        },
        {
         {position ={x = pos.x+0, y = pos.y+1, z=pos.z,stackpos=1}},
         {position ={x = pos.x+1, y = pos.y+1, z=pos.z,stackpos=1}},    -- field[2][2]  middle position
         {position ={x = pos.x+2, y = pos.y+1, z=pos.z,stackpos=1}}
        },
        {
         {position ={x = pos.x+0, y = pos.y+2, z=pos.z,stackpos=1}},    -- field[3][1]    1st square of last line
         {position ={x = pos.x+1, y = pos.y+2, z=pos.z,stackpos=1}},
         {position ={x = pos.x+2, y = pos.y+2, z=pos.z,stackpos=1}}
        }    --    field[3][3], last square
}
 



conner = {
            field[1][1],
            field[1][3],
            field[3][1],
            field[3][3]
}

goingtoWinPos = {
            
            { field[1][1], field[1][2] },        -- 1    
            { field[2][1], field[2][2] },
            { field[3][1], field[3][2] },
            
            { field[1][3], field[1][2] },
            { field[2][3], field[2][2] },
            { field[3][3], field[3][2] },
            
            { field[1][1], field[2][1] },        --    7
            { field[1][2], field[2][2] },        --    8
            { field[1][3], field[2][3] },
            
            { field[3][1], field[2][1] },
            { field[3][2], field[2][2] },
            { field[3][3], field[2][3] },
            
            { field[1][1], field[2][2] },        --    13
            { field[3][3], field[2][2] },
            
            { field[1][3], field[2][2] },        --    15
            { field[3][1], field[2][2] },
            
            { field[1][1], field[3][3] },        --    17
            { field[1][3], field[3][1] },
            
            { field[1][1], field[1][3] },
            { field[2][1], field[2][3] },
            { field[3][1], field[3][3] },

            { field[1][1], field[3][1] },
            { field[1][2], field[3][2] },
            { field[1][3], field[3][3] }
            
}


counterWinPos = {
            
            field[1][3],
            field[2][3],
            field[3][3],
            
            field[1][1],
            field[2][1],
            field[3][1],
            
            field[3][1],
            field[3][2],
            field[3][3],
            
            field[1][1],
            field[1][2],
            field[1][3],
            
            field[3][3],
            field[1][1],
            
            field[3][1],
            field[1][3],
            
            field[2][2],
            field[2][2],
            
            field[1][2],
            field[2][2],
            field[3][2],
            
            field[2][1],
            field[2][2],
            field[2][3]
            
            
}

npclv = {
            {
                { field[1][1], field[3][3], field[2][2], field[3][1] },
                { field[3][3], field[3][1], field[3][2], field[1][3] },
                { field[1][3], field[3][3], field[2][3], field[2][1] },        --3 1
                
                { field[1][1], field[3][3], field[1][3], field[2][3] },
                { field[1][2], field[1][3], field[3][1], field[3][2] },        --5 1
                { field[2][2], field[1][3], field[3][1], field[2][1] },        --6 1
                
                { field[2][1], field[3][1], field[3][3], field[2][1] },
                { field[3][2], field[2][3], field[3][3], field[3][2] },
                { field[2][1], field[3][1], field[3][3], field[2][1] }
            },
            {
                { field[3][1], field[1][3], field[1][1], field[2][1] },
                { field[3][1], field[1][3], field[1][1], field[1][2] },
                { field[3][1], field[1][3], field[3][3], field[2][3] },
                
                { field[3][1], field[1][3], field[3][3], field[3][2] },
                { field[3][1], field[1][1], field[3][3], field[2][3] },
                { field[3][1], field[1][1], field[3][3], field[3][2] },
                
                { field[3][1], field[3][3], field[1][3], field[3][2] },
                { field[3][1], field[3][3], field[1][3], field[2][3] },
                { field[3][1], field[3][3], field[1][3], field[2][3] }
            },
            {
                { field[3][3], field[1][1], field[3][1], field[2][1] },
                { field[3][3], field[1][1], field[3][1], field[3][2] },
                { field[3][3], field[1][1], field[1][3], field[1][2] },
                
                { field[3][3], field[1][1], field[1][3], field[2][3] },
                { field[3][3], field[1][3], field[3][1], field[3][2] },
                { field[3][3], field[1][3], field[3][1], field[2][3] },
                
                { field[3][3], field[3][1], field[1][1], field[2][1] },
                { field[3][3], field[3][1], field[1][1], field[3][2] },
                { field[3][3], field[3][1], field[1][1], field[3][2] }
            }
            

}

winnerPos = {
            field[1],
            field[2],
            field[3],
            
            { field[1][1], field[2][1], field[3][1] },
            { field[1][2], field[2][2], field[3][2] },
            { field[1][3], field[2][3], field[3][3] },
            
            { field[1][1], field[2][2], field[3][3] },
            { field[1][3], field[2][2], field[3][1] }
}




tttconfig = {
        storage = 931699  , -- change to your own storage value :)
        storageData= "ttt , " ..1 .. " , " .. 1
--        storageData= "ttt , " ..math.random(1,3) .. " , " .. 1            -- math.random(1,3) for random npc level 1 most hard 3 noob moves.

}




npcMove = {}
tttnpcMove = {}
ttPlayerMovesFt = {}
ttNpcMoves = {}

tttturncount = 0


token = { 2638, 2639 }    -- X  or O
playerToken =    token[2]
npcToken = token[1]

local notworkingdontknowhyif = [[
token = { 2638, 2639 }    -- X  or O
playerToken = token[math.random(1,2)]
playerToken == 1 then
    npcToken = token[2]
else
    npcToken = token[1]
end
]]






playerTurn = math.random(1,2)
if playerTurn == 2  then
    whoPlay = { 'Your turn', 'My turn' }
else
    whoPlay = { 'My turn', 'Your turn' }
end

LIB das functions do jogo
npc/scripts/games/tictactoeFUNC.lua

Code:
function getArrayStorageValue( cid, key )
    objProp = {}
    getArrayfromKey = getPlayerStorageValue(cid, key)
    index = 1
    for value in string.gmatch(getArrayfromKey,"%w+") do 
        objProp [index] = value
        index = index + 1
    end
    return objProp
end


function clearField( pos, field  )
    local i = true
    while i do
        i = false
        for _, col in ipairs(field) do
            for _, square in ipairs(col) do
                local item = getThingfromPos(square.position)
                if item.itemid ~= 0 then doRemoveItem(item.uid, 1) i = true    end
            end
        end
    end
    return true
end

function checkforcheater( pos, field, token)
    local i = true
    while i do
        i = false
        for _, col in ipairs(field) do
            for _, square in ipairs(col) do
                local item1 = getTileItemById(square.position, token[1])

                local item2 = getTileItemById(square.position, token[2])

                local item3 = getThingfromPos( square.position )

                if item1.itemid == token[1] and item2.itemid == token[2] then
                        if item3.itemid ~= 0 then doRemoveItem(item3.uid, 1)    end
                        i = true
                end
                if item3.itemid ~= 0 and not(item3.itemid == token[1] or item3.itemid == token[2])  then
                        doRemoveItem(item3.uid, 1)
                        i = true
                end
            end
        end
    end
        return i
end




function tokenCount(  pos, field , token   )
    tcount = 0
    for _, col in ipairs(field) do
        for _, square in ipairs(col) do
                local item = getThingfromPos(square.position)
                if item.itemid == token[1]  or item.itemid == token[2] then
                    tcount= tcount +1
                end
        end
    end
    return tcount
end




function table.contains(table, element)
  for _, value in pairs(table) do
    if value == element then
      return true
    end
  end
  return false
end



function table.counter(tctable, element)
    tttiii = {}
    for k1, v1 in pairs( element ) do
        for k2, v2 in pairs( tctable ) do
            if ( v2[1].position.x == v1.position.x ) and ( v2[1].position.y == v1.position.y ) then
              for _, v3 in pairs(element) do
                if v3.position.x == v2[2].position.x and ( v2[2].position.y == v3.position.y ) then
                    table.insert(tttiii,k2)
                end
              end
            end
        end
    end
    if next(tttiii) == nil then return false else return tttiii  end
end


function tttgamewinner(tctable, element)
    tttiii = {}
    for k1, v1 in pairs( element ) do
        for k2, v2 in pairs( tctable ) do
            if ( v2[1].position.x == v1.position.x ) and ( v2[1].position.y == v1.position.y ) then
--                print "v2"
              for _, v3 in pairs(element) do
                if v3.position.x == v2[2].position.x and ( v2[2].position.y == v3.position.y ) then
--                    print "v3"
                    for _, v4 in pairs(element) do
--                        print "looking for v4"
                        if v4.position.x == v2[3].position.x and ( v2[3].position.y == v4.position.y ) then
--                            print "v4"
                            table.insert(tttiii,k2)
                        end
                    end
                end
              end
            end
        end
    end
    if next(tttiii) == nil then return false else return tttiii  end
end


function    tttPlayerMoves( pos, field , playerToken, FET )    --    FET = [defalt = return empt table ]    [false = return false]
    playerMove = {}
    for _, col in ipairs(field) do
        for _, square in ipairs(col) do
            local item = getThingfromPos(square.position)
            if item.itemid == playerToken   and   table.contains(playerMove, square)  ~= true then
                table.insert(playerMove,square)
            end
        end
    end
    if next(playerMove) == nil then if FET==false then return false else return {} end else return playerMove  end    
end



 function tttnpcnextmove( cid, tttconfig, npclv, playerMove, npcMove )
tictacpara = getArrayStorageValue( cid, tttconfig.storage )
tictaclv = tonumber(tictacpara[2])
tictacstra = tonumber(tictacpara[3])

--        print (tictaclv .." " .. tictacstra )
--        print "_____"
    tttjjj = {}
    for i=1, 9 do
    
      for j=1,4 do
        if  i ==  tictacstra  then
--            print ( i .." j " ..j )
            if table.contains(playerMove, npclv[tictaclv][i][j]) ~= true and table.contains(npcMove, npclv[tictaclv][i][j]) ~= true     then
--                print "pt1"
--                print ("x " ..npclv[tictaclv][i][j].position.x .."y"..npclv[tictaclv][i][j].position.y .."z"..npclv[tictaclv][i][j].position.z    )
--                print "_____"
                return npclv[tictaclv][i][j]
            elseif table.contains(playerMove, npclv[tictaclv][i][j]) == true then
--                print "pt2"
--                print "_____"
                tictacstra = tictacstra +1
                storageData= "ttt , " ..tictaclv .. " , " .. tictacstra
                setPlayerStorageValue(cid, tttconfig.storage, storageData)
            else
--                print "pt3"
                i=i
            end
        end
      end
    end
--
    return {}    --    false
end


o modo em que o npc vai agir (seus movimentos )

npc/scripts/games/tictactoeLVhard.lua


Code:
            if tttlistdotowin ~= false then
                for i,line in ipairs(tttlistdotowin) do
                    gettoken = getThingfromPos( counterWinPos[line].position )
                    if  gettoken.itemid ~= npcToken then        --        i == #tttlistdotowin and 
                        tttplayheretowin = line
                    end
                end
            end







--    function checkfield( cid,tttconfig , pos, field , playerToken, playerMove )

-- print (tttnpcChose[1].position.x,tttnpcChose[1].position.y,tttnpcChose[1].position.z)
--        tttnpcMove     ttNpcMoves

tttnpcmaxtoken = 1


    if    tttturncount == 2 and  table.contains(ttPlayerMovesFt, field[2][2])  ~= true      then
        if tttnpcmaxtoken > 0 then
            tttnpcmaxtoken = tttnpcmaxtoken -1
            tttnpcChose = field[2][2]
            table.insert(tttnpcMove,tttnpcChose)
            tokenPieceNpc = doCreateItemEx(npcToken, 1)
            doTileAddItemEx( tttnpcChose.position, tokenPieceNpc)
        end
    else
        if tttturncount == 4  and table.contains(ttPlayerMovesFt, field[3][2])  ~= true and  table.contains(tttnpcMove, field[2][2])  == true and  table.contains(ttPlayerMovesFt, field[1][2])  ~= true    then 
                if tttlistofdanger ~= false         then 
                    for i,line in ipairs(tttlistofdanger) do
                      gettoken = getThingfromPos( counterWinPos[line].position )
                      if i == #tttlistofdanger and  gettoken.itemid == npcToken then
--                            print "turn 4 pt1"
                            if tttnpcmaxtoken > 0 then
                                tttnpcmaxtoken = tttnpcmaxtoken -1
                                tttnpcChose = field[3][2]
                                table.insert(tttnpcMove,tttnpcChose)
                                tokenPieceNpc = doCreateItemEx(npcToken, 1)
                                doTileAddItemEx( tttnpcChose.position, tokenPieceNpc)
                            end
                      else
--                        print "turn 4 pt2"
                          if  gettoken.itemid ~= npcToken or gettoken.itemid ~= playerToken        then
                            if tttnpcmaxtoken > 0 then
                                tttnpcmaxtoken = tttnpcmaxtoken -1
                                if gettoken.itemid ~= 0 then doRemoveItem(gettoken.uid, 1)    end
                                table.insert(tttnpcMove,counterWinPos[line])
                                tokenPieceNpc = doCreateItemEx(npcToken, 1)
                                doTileAddItemEx( counterWinPos[line].position, tokenPieceNpc)
                            end
                          end
                      end
                    end
                else
--                    print "turn 4 pt3"
                    if tttnpcmaxtoken > 0 then
                        tttnpcmaxtoken = tttnpcmaxtoken -1
                        tttnpcChose = field[3][2]
                        table.insert(tttnpcMove,tttnpcChose)
                        tokenPieceNpc = doCreateItemEx(npcToken, 1)
                        doTileAddItemEx( tttnpcChose.position, tokenPieceNpc)
                    end
                end
        else
-------

------------------        and (getThingfromPos( counterWinPos[tttplayheretowin].position ).itemid == npcToken)
            if tttlistdotowin ~= false and (getThingfromPos( counterWinPos[tttplayheretowin].position ).itemid ~= playerToken)          then 
                --    print ("winning  ! " ..tttnpcmaxtoken)
                    
--                        print (getThingfromPos( counterWinPos[tttplayheretowin].position ).itemid)

                    gettoken = getThingfromPos( counterWinPos[tttplayheretowin].position )
                    if  gettoken.itemid ~= npcToken or gettoken.itemid ~= playerToken then
                        if tttnpcmaxtoken > 0 then
                            tttnpcmaxtoken = tttnpcmaxtoken -1

                            if gettoken.itemid ~= 0 then doRemoveItem(gettoken.uid, 1)    end
                            table.insert(tttnpcMove,counterWinPos[tttplayheretowin])
                            tokenPieceNpc = doCreateItemEx(npcToken, 1)
                            doTileAddItemEx( counterWinPos[tttplayheretowin].position, tokenPieceNpc)
                            --    print ("danger pt 2 we did " ..tttnpcmaxtoken)
                        end
                    end
                        --    print " possibility of win "

------------------

            else
                if tttlistofdanger ~= false         then 
                    --    print ("danger  ! " ..tttnpcmaxtoken)
                        
                    for i,line in ipairs(tttlistofdanger) do
                        gettoken = getThingfromPos( counterWinPos[line].position )
                        
                        if   gettoken.itemid ~= npcToken then        --    i == #tttlistofdanger and
                            tttplayhere = line
                        end
                    end
--                        print (getThingfromPos( counterWinPos[tttplayhere].position ).itemid)
                        
                        if (getThingfromPos( counterWinPos[tttplayhere].position ).itemid == npcToken)         then 
                            tttnpcChose = tttnpcnextmove( cid, tttconfig , npclv, ttPlayerMovesFt, ttNpcMoves )
                            if tttnpcChose ~= nil then
                                --    print ("danger pt 1 " ..tttnpcmaxtoken)
                                gettoken = getThingfromPos( tttnpcChose.position )
                                if  gettoken.itemid ~= npcToken or gettoken.itemid ~= playerToken        then
                                    if tttnpcmaxtoken > 0 then
                                        tttnpcmaxtoken = tttnpcmaxtoken -1
                                        if gettoken.itemid ~= 0 then doRemoveItem(gettoken.uid, 1)    end
                                        table.insert(tttnpcMove, tttnpcChose )
                                        tokenPieceNpc = doCreateItemEx(npcToken, 1)
                                        doTileAddItemEx( tttnpcChose.position, tokenPieceNpc)
--                                        print ("danger pt 1 we did " ..tttnpcmaxtoken)
                                    end
                                end
                            end
                    --        print "danger contree"
                        else
                            gettoken = getThingfromPos( counterWinPos[tttplayhere].position )
                            if  gettoken.itemid ~= npcToken or gettoken.itemid ~= playerToken        then
--                            print ("danger pt 2 " ..tttnpcmaxtoken)
                                if tttnpcmaxtoken > 0 then
                                    tttnpcmaxtoken = tttnpcmaxtoken -1
                                    if gettoken.itemid ~= 0 then doRemoveItem(gettoken.uid, 1)    end
                                    table.insert(tttnpcMove,counterWinPos[tttplayhere])
                                    tokenPieceNpc = doCreateItemEx(npcToken, 1)
                                    doTileAddItemEx( counterWinPos[tttplayhere].position, tokenPieceNpc)
--                                    print ("danger pt 2 we did " ..tttnpcmaxtoken)
                                end
                            end
                        --    print "pas danger"
                        end
--                    end

                elseif table.counter(goingtoWinPos, ttPlayerMovesFt) ~= true     then
                    --    print ("atk pt 1 " ..tttnpcmaxtoken)
                    tttnpcChose = tttnpcnextmove( cid, tttconfig , npclv, ttPlayerMovesFt, ttNpcMoves )
                  if tttnpcChose ~= nil then
                    gettoken = getThingfromPos( tttnpcChose.position )
                    if  gettoken.itemid ~= npcToken or gettoken.itemid ~= playerToken        then
                        if tttnpcmaxtoken > 0 then
                            tttnpcmaxtoken = tttnpcmaxtoken -1
                            if gettoken.itemid ~= 0 then doRemoveItem(gettoken.uid, 1)    end
                            table.insert(tttnpcMove, tttnpcChose )
                            tokenPieceNpc = doCreateItemEx(npcToken, 1)
                            doTileAddItemEx( tttnpcChose.position, tokenPieceNpc)
                        end
                    end
                  end
                end
            end
            
        end
    end



--    return error("invalid data from npc.")
--end

VIDEO YOUTUBE
Tibia tic tac toe - YouTube
obs : eu nao fiz comentario somente PRINT out put que me ajudaram entender o npc estava fazendo.
 
Last edited:
Back
Top