Ir para conteúdo

Featured Replies

Postado
  • Autor

Achei essa função e acho que daria pra fazer o que eu estava querendo.. Só n sei colocar. Alguem ajudar?

local function jumpBehindTarget(cid, target)
local player = Player(cid)
local target = Creature(target)
local targetPos = target:getPosition()
local targetPositions = {
north = Position(targetPos.x, targetPos.y-1, targetPos.z),
east = Position(targetPos.x+1, targetPos.y, targetPos.z),
west = Position(targetPos.x-1, targetPos.y, targetPos.z),
south = Position(targetPos.x, targetPos.y+1, targetPos.z)
}

local targetDir = target:getDirection()
if targetDir == NORTH then
dir = targetPositions.south
elseif targetDir == EAST then
dir = targetPositions.west
elseif targetDir == WEST then
dir = targetPositions.east
elseif targetDir == SOUTH then
dir = targetPositions.north
end
return dir
end

Editado por aq snuff (veja o histórico de edições)

  • Respostas 12
  • Visualizações 1.7k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Tente assim: vá em data/creaturescripts/target crie um arquivo chamado target  cole isso: agóra em creaturescripts.xml adiciona éssa linha em login.lua: OBS: apenas peguei o script do @xWhiteWol

  • cara não entendi nada doque vc falou/fez, ele não vira na diagonal pq não dá e não é bug porque se vc estiver com um player normal o bixo vai se movimentar ao seu redor e fazer você virar. Quando eu f

  • Ok, brigado.. Acho que da pra por se o player tiver em x sqm de distancia executar o scrpit todo, se nao, soh a mensagem de not possible ou simplesmente nada(que eh melhor melhor). De qualquer forma a

Postado

Achei essa função e acho que daria pra fazer o que eu estava querendo.. Só n sei colocar

Adicione à lib do seu servidor:

function jumpBehindTarget(cid, target)
    local player = Player(cid)
    local target = Creature(target)
    local targetPos = target:getPosition()
    local targetPositions = {
        north = Position(targetPos.x, targetPos.y-1, targetPos.z),
        east = Position(targetPos.x+1, targetPos.y, targetPos.z),
        west = Position(targetPos.x-1, targetPos.y, targetPos.z),
        south = Position(targetPos.x, targetPos.y+1, targetPos.z)
    }

    local targetDir = target:getDirection()
    if targetDir == NORTH then
        dir = targetPositions.south
    elseif targetDir == EAST then
        dir = targetPositions.west
    elseif targetDir == WEST then
        dir = targetPositions.east
    elseif targetDir == SOUTH then
        dir = targetPositions.north
    end
    return dir
end

 

Creature event attack:

function onAttack(cid, target)
    local vocs = {4, 8}
    if isCreature(cid) and isCreature(target) and isInArray(vocs, getPlayerVocation(cid)) then
        jumpBehindTarget(cid, target)
    end
    return true
end

não se esqueça de registrá-lo em login.lua

The corrupt fear us.

The honest support us.

The heroic join us.

Postado
  • Autor

n funcionou pq eu preciso de um setDirection(target:getDirection()) na função também...

Acho que a função do tibia lookAtPlayer pode ser util, quando fala hi o npc vira pra vc... 
 

Mas queria ver se dava pra adaptar pra que quando o player atacasse o bixo que está acima e direita o player virasse pra cima ou para direita, e assim nas demais directions.. Tipo:

if target == NORTHWEST then

dir = targetPositions.WEST or NORTH
 

if target == SOUTHEAST then

dir = targetPositions.EAST or SOUTH

 

O script q peguei eh esse:(Visualize só a parte de directions) 

function isWalkable(cid, pos)
local tile = Tile(pos)
if not tile then
return false
end

if tile:queryAdd(cid) == 1 and not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
return true
end
return false
end

local function jumpBehindTarget(cid, target)
local player = Player(cid)
local target = Creature(target)
local targetPos = target:getPosition()
local targetPositions = {
north = Position(targetPos.x, targetPos.y-1, targetPos.z),
east = Position(targetPos.x+1, targetPos.y, targetPos.z),
west = Position(targetPos.x-1, targetPos.y, targetPos.z),
south = Position(targetPos.x, targetPos.y+1, targetPos.z)
}

local targetDir = target:getDirection()
if targetDir == NORTH then
dir = targetPositions.south
elseif targetDir == EAST then
dir = targetPositions.west
elseif targetDir == WEST then
dir = targetPositions.east
elseif targetDir == SOUTH then
dir = targetPositions.north
end
return dir
end

local function oldPos(cid, oldPos)
local player = Player(cid)
if not player then
return
end

player:teleportTo(oldPos)
end

local function checkHasTarget(cid, count, oldPos)
local player = Player(cid)
if not player then
return
end

if count < 1 then
player:setGhostMode(false)
return
end

local target = player:getTarget()
if target then
local behindTarget = jumpBehindTarget(cid, target:getId())
if isWalkable(cid, behindTarget) then
player:teleportTo(behindTarget)
else
player:teleportTo(target:getPosition())
addEvent(backOldPos, 100, cid, oldPos)
end
player:setDirection(target:getDirection())
player:setGhostMode(false)
doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -20, -100, CONST_ME_FIREATTACK)
return true
end
addEvent(checkHasTarget, 1 * 100, cid, count - 1)
end

function onCastSpell(creature, var)
local playerPos = creature:getPosition()

creature:setGhostMode(true)
playerPos:sendMagicEffect(CONST_ME_POFF)
addEvent(checkHasTarget, 1 * 250, creature:getId(), 50, playerPos)
return false
end

Editado por aq snuff (veja o histórico de edições)

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo