SK
tfs 0.3.6

[Spells] Checando Interferências na Trajetória

Por Skulls, 14 de fev. de 2016 em Globalevents e Spells

spells
interferencia
trajetoria
magias
55
9.7k
jhonysavioJ
17 de março de 2016 às 02:25

coloquei esse script e não funcionou, entre tanto as runas de gfb nao ficaram em area, e todas as runas acertam no chao ( precisa ser exatamente em cima do monstro) o spell de exori sai apenas no sqm q o meu perssonagem esta... e o "exori grab vis" tbm nao funcionou... e todas as magias q alterei para bloquear.... elas nem saem e nem aparecem poff

SkullsS
17 de março de 2016 às 14:04

Você possivelmente implementou errado. Post aqui o que fez para que eu te ajude

jhonysavioJ
18 de março de 2016 às 16:51

muito obrigado, admiro muito seus scripts!!!

 

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
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true 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 getPositionsAround(pos)
return {
[1] = {x = pos.x, y = pos.y - 1, z = pos.z, stackpos = 0},
[2] = {x = pos.x + 1, y = pos.y - 1, z = pos.z, stackpos = 0},
[3] = {x = pos.x + 1, y = pos.y, z = pos.z, stackpos = 0},
[4] = {x = pos.x + 1, y = pos.y + 1, z = pos.z, stackpos = 0},
[5] = {x = pos.x, y = pos.y + 1, z = pos.z, stackpos = 0},
[6] = {x = pos.x - 1, y = pos.y + 1, z = pos.z, stackpos = 0},
[7] = {x = pos.x - 1, y = pos.y, z = pos.z, stackpos = 0},
[8] = {x = pos.x - 1, y = pos.y - 1, z = pos.z, stackpos = 0}
}
end
function checkInterceptions(cid, pos, toPos, cond)
local p = pos
local dir = getDirectionTo(pos, toPos)
local d = getDistanceBetween(pos, toPos)
if dir < SOUTHWEST then
while d > 0 do
dir = getDirectionTo(p, toPos)
p = getPosByDir(p, dir, 1)
d = getDistanceBetween(p, toPos)
if not isWalkable(p, true, true, true) then
return p
end
end
else
local creature = cond or true
local nextPositions = {pos}
local tam = 1
while d > 0 do
local i = tam
if tam > 2 then tam = 2 end
local positions = getPositionsAround(nextPositions[tam])
if (dir == SOUTHWEST and (nextPositions[tam].x < toPos.x or nextPositions[tam].y > toPos.y))
or (dir == NORTHEAST and (nextPositions[tam].x > toPos.x or nextPositions[tam].y < toPos.y)) then
positions = getPositionsAround(nextPositions[tam+1])
end
if dir == SOUTHEAST and (nextPositions[tam].x > toPos.x or nextPositions[tam].y > toPos.y)
or (dir == NORTHWEST and (nextPositions[tam].x < toPos.x or nextPositions[tam].y < toPos.y)) then
positions = getPositionsAround(nextPositions[tam-1])
end
d = getDistanceBetween(nextPositions[tam], toPos)
tam = 0
if d == 0 then break end
local sum = 0
if dir == SOUTHWEST then sum = 4
elseif dir == SOUTHEAST then sum = 2
elseif dir == NORTHWEST then sum = 6
elseif dir == SOUTHEAST then sum = 0 end
for j=1, 3 do
local index = j+sum
local check = 0
if index > #positions then index = 1 end
if dir == SOUTHWEST and (positions[index].x < toPos.x or positions[index].y > toPos.y)
or (dir == SOUTHEAST and (positions[index].x > toPos.x or positions[index].y > toPos.y))
or (dir == NORTHWEST and (positions[index].x < toPos.x or positions[index].y < toPos.y))
or (dir == NORTHEAST and (positions[index].x > toPos.x or positions[index].y < toPos.y)) then
check = 1
end
local dx, dy = math.abs(positions[index].x - toPos.x) , math.abs(positions[index].y - toPos.y)
if dx == dy and (positions[index].x == pos.x or positions[index].y == pos.y)
and ((getDistanceBetween(positions[index], pos) > 1 and getDistanceBetween(positions[index], toPos) > 1)
or getDistanceBetween(positions[index], pos) > 5 and getDistanceBetween(positions[index], toPos) > 0)then
check = 1
end
if getDistanceBetween(positions[index], toPos) == 0 then return toPos end
if getDistanceBetween(positions[index], toPos) < d and check == 0 then
if not isWalkable(positions[index], creature, true, true) then
return positions[index]
end
tam = tam + 1
nextPositions[tam] = positions[index]
end
end
end
end
return toPosend
function setSpellTarget(cid, var) if var.pos then
var.pos = checkInterceptions(cid, getPlayerPosition(cid), var.pos)
end
if isCreature(var.number) then
var.pos = checkInterceptions(cid, getPlayerPosition(cid), getCreaturePosition(var.number))--getMousePos(cid)
var.pos.stackpos = STACKPOS_TOP_MOVABLE_ITEM_OR_CREATURE
if getDistanceBetween(var.pos, getCreaturePosition(var.number)) ~= 0 and isCreature(getThingFromPos(var.pos).uid) then
var.number = getThingFromPos(var.pos).uid
elseif not isCreature(getThingFromPos(var.pos).uid) then
var.number = 0
doPlayerSendCancel(cid, "Target not reachable.")
end
end
return var
end
SkullsS
18 de março de 2016 às 17:43

Troca

return toPosend

 

Por

return toPos

end

jhonysavioJ
19 de março de 2016 às 01:18

ja agradeço muito a atenção rep+

alterei, n deu erro na hora de iniciar... mas a hora q uso as magias nao funciona, aparece "target not reachable"


tipo a spell do grab vis, e todas q tento usar com isso tenho q encostar no alvo pra usar... elas perdem a distancia

SkullsS
19 de março de 2016 às 08:28

Cara target not reachable eh pq bc ta usando com algo na frente ou a uma distância maior que a definida no script.

Tenta usar em um alvo perto (3/4sqm) e sem obstáculos na frente

jhonysavioJ
19 de março de 2016 às 23:58

sim eu tento mas não vai, vou ver se mando um giff aqui ou print, tenho q colar no monstro no caso pra conseguir usar... 1 sqm de distancia e ja não usa... e se tiver outro monstro na frente ele aparece isso em vez de priorizar o monstro d frente


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
function onCastSpell(cid, var)
return doCombat(cid, combat, setSpellTarget(cid, var))
end
a magia death striker esta assim... mas qualquer spells range q eu altere ... ele perde o range
SkullsS
20 de março de 2016 às 09:56

Engraçado, era pra funcionar.. posta a tag do spells.xml dessa magia, por favor?

jhonysavioJ
21 de março de 2016 às 00:55
<instant name="Death Strike" words="exori mort" lvl="16" mana="20" prem="0" range="3" casterTargetOrDirection="1" blockwalls="1" exhaustion="2000" groups="1,2000" icon="87" needlearn="0" event="script" value="attack/death strike.lua">

<vocation id="1"/>

<vocation id="5"/>

</instant>


<instant name="Energy Grab" words="exori grab vis" needtarget="1" lvl="10" mana="20" prem="1" range="6" blockwalls="1" exhaustion="2000" groups="1,2000" icon="122" needlearn="0" event="script" value="attack/energy grab.lua">

<vocation id="4"/>

<vocation id="8"/>

</instant>



A death striker e o exori grab estao assim no xml


SkullsS
21 de março de 2016 às 08:12

 

<instant name="Death Strike" words="exori mort" lvl="16" mana="20" prem="0" range="3" casterTargetOrDirection="1" blockwalls="1" exhaustion="2000" groups="1,2000" icon="87" needlearn="0" event="script" value="attack/death strike.lua">
<vocation id="1"/>
<vocation id="5"/>
</instant>
<instant name="Energy Grab" words="exori grab vis" needtarget="1" lvl="10" mana="20" prem="1" range="6" blockwalls="1" exhaustion="2000" groups="1,2000" icon="122" needlearn="0" event="script" value="attack/energy grab.lua">
<vocation id="4"/>
<vocation id="8"/>
</instant>
A death striker e o exori grab estao assim no xml

 

Realmente tinha um bug, mas agora acho que está resolvido.

Porém, tem que definir a range da spell no script da magia agora. Vou explicar certinho no topico.

Valeu!

Abraços,

jhonysavioJ
21 de março de 2016 às 15:06

ficaria assim?

 

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
local range = 5
function onCastSpell(cid, var)
if getCreatureTarget(cid) == 0 then
doPlayerSendCancel(cid, "Please choose a target.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
if getDistanceBetween(getPlayerPosition(cid), getCreaturePosition(getCreatureTarget(cid))) > range then
doPlayerSendCancel(cid, "Target is not reachable.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
return doCombat(cid, combat, setSpellTarget(cid, var))
end
... pq nao funcionou, da o mesmo erro e fica sem range... e se eu for no xml e retirar o casterTargetOrDirection="1". ele da erro, fica usando o spells no proprio player como se fosse um exura
SkullsS
21 de março de 2016 às 17:39

 

ficaria assim?

 

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
local range = 5
function onCastSpell(cid, var)
if getCreatureTarget(cid) == 0 then
doPlayerSendCancel(cid, "Please choose a target.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
if getDistanceBetween(getPlayerPosition(cid), getCreaturePosition(getCreatureTarget(cid))) > range then
doPlayerSendCancel(cid, "Target is not reachable.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
return doCombat(cid, combat, setSpellTarget(cid, var))
end
... pq nao funcionou, da o mesmo erro e fica sem range... e se eu for no xml e retirar o casterTargetOrDirection="1". ele da erro, fica usando o spells no proprio player como se fosse um exura

 

Você editou as funções? Pq eu reformulei elas, substitui todas pelas novas que coloquei no topico. Tem que funcionar.. ahehuaehuahue

jhonysavioJ
22 de março de 2016 às 15:30

;( aqui ainda n funcionou...da o mesmo erro...fica sem range

 

SkullsS
22 de março de 2016 às 15:40

;( aqui ainda n funcionou...da o mesmo erro...fica sem range

 

Você substituiu todas? Nao faz sentido, vc usa tfs? Que loucura oO
jhonysavioJ
22 de março de 2016 às 17:33

sim uso! yorots 9.81 global console

vou postar aqui o que fiz

 

na lib

 

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
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true 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 getPositionsAround(pos)
return {
[1] = {x = pos.x, y = pos.y - 1, z = pos.z, stackpos = 0},
[2] = {x = pos.x + 1, y = pos.y - 1, z = pos.z, stackpos = 0},
[3] = {x = pos.x + 1, y = pos.y, z = pos.z, stackpos = 0},
[4] = {x = pos.x + 1, y = pos.y + 1, z = pos.z, stackpos = 0},
[5] = {x = pos.x, y = pos.y + 1, z = pos.z, stackpos = 0},
[6] = {x = pos.x - 1, y = pos.y + 1, z = pos.z, stackpos = 0},
[7] = {x = pos.x - 1, y = pos.y, z = pos.z, stackpos = 0},
[8] = {x = pos.x - 1, y = pos.y - 1, z = pos.z, stackpos = 0}
}
end
function checkInterceptions(cid, pos, toPos, creature)
local p = pos
local dir = getDirectionTo(pos, toPos)
local d = getDistanceBetween(pos, toPos)
if dir < SOUTHWEST then
while d > 0 do
dir = getDirectionTo(p, toPos)
p = getPosByDir(p, dir, 1)
d = getDistanceBetween(p, toPos)
if not isWalkable(p, creature, true, true) then
return p
end
end
else
local nextPositions = {pos}
local tam = 1
while d > 0 do
local i = tam
if tam > 2 then tam = 2 end
local positions = getPositionsAround(nextPositions[tam])
if (dir == SOUTHWEST and (nextPositions[tam].x < toPos.x or nextPositions[tam].y > toPos.y))
or (dir == NORTHEAST and (nextPositions[tam].x > toPos.x or nextPositions[tam].y < toPos.y)) then
positions = getPositionsAround(nextPositions[tam+1])
end
if dir == SOUTHEAST and (nextPositions[tam].x > toPos.x or nextPositions[tam].y > toPos.y)
or (dir == NORTHWEST and (nextPositions[tam].x < toPos.x or nextPositions[tam].y < toPos.y)) then
positions = getPositionsAround(nextPositions[tam-1])
end
d = getDistanceBetween(nextPositions[tam], toPos)
tam = 0
if d == 0 then break end
local sum = 0
if dir == SOUTHWEST then sum = 4
elseif dir == SOUTHEAST then sum = 2
elseif dir == NORTHWEST then sum = 6
elseif dir == SOUTHEAST then sum = 0 end
for j=1, 3 do
local index = j+sum
local check = 0
if index > #positions then index = 1 end
if dir == SOUTHWEST and (positions[index].x < toPos.x or positions[index].y > toPos.y)
or (dir == SOUTHEAST and (positions[index].x > toPos.x or positions[index].y > toPos.y))
or (dir == NORTHWEST and (positions[index].x < toPos.x or positions[index].y < toPos.y))
or (dir == NORTHEAST and (positions[index].x > toPos.x or positions[index].y < toPos.y)) then
check = 1
end
local dx, dy = math.abs(positions[index].x - toPos.x) , math.abs(positions[index].y - toPos.y)
if dx == dy and (positions[index].x == pos.x or positions[index].y == pos.y)
and ((getDistanceBetween(positions[index], pos) > 1 and getDistanceBetween(positions[index], toPos) > 1)
or getDistanceBetween(positions[index], pos) > 5 and getDistanceBetween(positions[index], toPos) > 0)then
check = 1
end
if getDistanceBetween(positions[index], toPos) == 0 then return toPos end
if getDistanceBetween(positions[index], toPos) < d and check == 0 then
if not isWalkable(positions[index], creature, true, true) then
return positions[index]
end
tam = tam + 1
nextPositions[tam] = positions[index]
end
end
end
end
return toPos
end
function setSpellTarget(cid, var)
local target = getCreatureTarget(cid)
var.pos = checkInterceptions(cid, getPlayerPosition(cid), getCreaturePosition(target), true)
if isCreature(getThingFromPos(var.pos).uid) then
var.number = getThingFromPos(var.pos).uid
else
var.number = false
end
return var
end
no xml
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
local range = 5
function onCastSpell(cid, var)
if getCreatureTarget(cid) == 0 then
doPlayerSendCancel(cid, "Please choose a target.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
if getDistanceBetween(getPlayerPosition(cid), getCreaturePosition(getCreatureTarget(cid))) > range then
doPlayerSendCancel(cid, "Target is not reachable.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return false
end
return doCombat(cid, combat, setSpellTarget(cid, var))
end