Postado Agosto 30, 2016 8 anos Olá galera, gostaria de saber como adicionar para quando a magia reconhecer algo na frente do char ele desviar e tomar um novo caminho, como o script de empurrar no XWhiteWolfX Quote local distance = 25 -- distancia que anda (em sqm) local speed = 100 -- milisegundos entre cada passo (qnt menor = mais rapido) local invisible = createConditionObject(CONDITION_GAMEMASTER, (speed * distance) + 50, false, GAMEMASTER_INVISIBLE) local outfit = createConditionObject(CONDITION_INVISIBLE, (speed * distance) + 50, false) local function isWalkable(pos, creature, proj, pz)-- by Nord if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end local creature = getTopCreature(pos) if creature.type > 0 then return false end if getTilePzInfo(pos) and not pz then return false end local n = not proj and 3 or 2 for i = 0, 255 do pos.stackpos = i local tile = getTileThingByPos(pos) if tile.itemid ~= 0 and not isCreature(tile.uid) then if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then return false end end end return true end function onWalk(cid) local poslook = getCreatureLookPosition(cid) poslook.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE if isWalkable(poslook, false, false, false) then if not isCreature(getThingfromPos(poslook).uid) then doMoveCreature(cid, getPlayerLookDirection(cid)) doSendMagicEffect(getPlayerPosition(cid), 10) return true else doSendMagicEffect(getPlayerPosition(cid), 10) return true end else doSendMagicEffect(getPlayerPosition(cid), 2) end end function onCastSpell(cid, var) if exhaustion.get(cid, 13118) then doPlayerSendCancel(cid, "Poderá usar novamente dentro de " .. exhaustion.get(cid, 13118) .. " segundos.") doSendMagicEffect(getCreaturePosition(cid), 2) return false end exhaustion.set(cid, 13118, 15) doAddCondition(cid, invisible) doAddCondition(cid, outfit) for i = 0, distance do addEvent(onWalk, speed * i,cid) end return true end
Postado Dezembro 24, 2018 6 anos desculpa reativa esse tópico também estou procurando essa mesma spell UP
Postado Fevereiro 13 Fev 13 Aqui Esta 100% Funcionando. local distance = 25 -- Distance to move (in sqm) local speed = 100 -- Milliseconds between each step (lower values = faster) local invisible = createConditionObject(CONDITION_GAMEMASTER) setConditionParam(invisible, CONDITION_PARAM_TICKS, (speed * distance) + 50) local outfit = createConditionObject(CONDITION_INVISIBLE) setConditionParam(outfit, CONDITION_PARAM_TICKS, (speed * distance) + 50) -- Function to check if a position is "walkable" local function isWalkable(pos, creature, proj, pz) local tile = getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}) if tile.itemid == 0 then return false end local creature = getTopCreature(pos) if creature.type > 0 then return false end if getTilePzInfo(pos) and not pz then return false end local n = not proj and 3 or 2 for i = 0, 255 do pos.stackpos = i local item = getTileThingByPos(pos) if item.itemid ~= 0 and not isCreature(item.uid) then if hasProperty(item.uid, n) or hasProperty(item.uid, 7) then return false end end end return true end -- Function to find an alternative direction local function getAlternativeDirection(pos) local directions = { {x = pos.x + 1, y = pos.y, z = pos.z}, -- East {x = pos.x - 1, y = pos.y, z = pos.z}, -- West {x = pos.x, y = pos.y + 1, z = pos.z}, -- South {x = pos.x, y = pos.y - 1, z = pos.z}, -- North } for _, dirPos in ipairs(directions) do if isWalkable(dirPos, false, false, false) then return dirPos end end return nil -- No alternative path found end function onWalk(cid) local poslook = getCreaturePosition(cid) poslook.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE if isWalkable(poslook, false, false, false) then doMoveCreature(cid, getPlayerLookDirection(cid)) doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF) else local alternativePos = getAlternativeDirection(getPlayerPosition(cid)) if alternativePos then local direction = getDirectionTo(getPlayerPosition(cid), alternativePos) doMoveCreature(cid, direction) doSendMagicEffect(alternativePos, CONST_ME_MAGIC_BLUE) else doSendMagicEffect(getPlayerPosition(cid), CONST_ME_BLOCKHIT) -- Indicates a block end end end function onCastSpell(cid, var) if exhaustion.get(cid, 13118) then doPlayerSendCancel(cid, "You can use this spell again in " .. exhaustion.get(cid, 13118) .. " seconds.") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BLOCKHIT) return false end exhaustion.set(cid, 13118, 15) doAddCondition(cid, invisible) doAddCondition(cid, outfit) for i = 0, distance do addEvent(onWalk, speed * i, cid) end return true end
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.