MI
pedido

Concertar Essa Spell

Por milbradt, 22 de ago. de 2012 em Scripts

script
5
1.3k
milbradtM
22 de agosto de 2012 às 01:07

Olá.. estou com uma SPELL que o CRBM fes e postou em um outro Forum..

 

Se chama KAGEMANE, essa spell quando usada em um target fas ele seguir seus movimentos..

Ela funciona perfeitamente quando usada em MONSTERS... mas quando usada em PLAYERS não funciona.. os PLAYERS ao inves de andar apenas 1 sqm igual o Personagem que a Ativou.. anda uns 4 SQM =\

 

tag da spell:

<instant name="Kagemane No Jutsu" words="kagemane no jutsu" lvl="125" mana="3300" exhaustion="2000" blockwalls="1" needlearn="0" event="script" value="shikamaru/kagemane.lua"></instant>

 

spell:

local function move(cid, target, playerpos, targetpos, times)
if playerdir ~= getCreatureLookDirection(cid) then
	doCreatureSetLookDirection(target, getCreatureLookDirection(cid))
end

if playerpos ~= getCreaturePosition(cid) then
	if playerpos.z == getCreaturePosition(cid).z then
		local ntpos = getCreaturePosition(cid)
		local x,y,z = ntpos.x-playerpos.x,ntpos.y-playerpos.y,ntpos.z-playerpos.z
		ntpos = getCreaturePosition(target)
		ntpos.x, ntpos.y, ntpos.z = ntpos.x+x,ntpos.y+y,ntpos.z+z
		if queryTileAddThing(target, ntpos) == RETURNVALUE_NOERROR and getCreaturePosition(cid).z == getCreaturePosition(target).z then
			doMoveCreature(target, getCreatureLookDirection(cid))
		end
	end
end
local playerpos, targetpos = getCreaturePosition(cid), getCreaturePosition(target)
local times = times+1
if times < 100 then
	addEvent(move, 1, cid, target, playerpos, targetpos, times)
else
	doCreatureSetNoMove(target, 0)
	doSendDistanceShoot(targetpos, playerpos, 31)
	doSendAnimatedText(targetpos, "FREE!", math.random(1,255))
 doPlayerSendCancel(cid, "You have lost control of "..getCreatureName(target)..".")
	if (isPlayer(target)) then
  doPlayerSendCancel(cid, "You've been freed from "..getPlayerName(cid).."'s Shadow Imitation Technique.")
  setPlayerStorageValue(target, 14755, -1)
 end
end
end

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
if (isPlayer(target)) or (isMonster(target)) then
	if getPlayerStorageValue(cid, 14755) == -1 then
		doCreatureSetNoMove(target, 1)
  doPlayerSendCancel(cid, "You have possessed "..getCreatureName(target)..".")
		if (isPlayer(target)) then
doPlayerSendCancel(target, "You have been possessed by "..getPlayerName(cid)..".")
setPlayerStorageValue(target, 14755, 1)
  end
		doSendAnimatedText(getCreaturePosition(target), "POSSESSED!", math.random(1,255))
		local playerpos,playerdir,targetpos = getCreaturePosition(cid), getPlayerLookDir(cid), getCreaturePosition(target)
		doSendDistanceShoot(playerpos, targetpos, 31)
		doSendMagicEffect(getCreaturePosition(target), CONST_ME_SMALLCLOUDS)
		local times = 1
		addEvent(move, 1000, cid, target, playerpos, targetpos, times)
	else
		doPlayerSendCancel(cid, "Your Shadow Imitation Technique isn't worn out yet.")
	end
end
end

 

em creaturescripts/login.lua:

setPlayerStorageValue(cid, 14755, -1)

 

Agredeço desde JA!!

Editado Agosto 22 por milbradt

marciksM
22 de agosto de 2012 às 11:34

A tag da spell ta errada, repare que voce nao colocou "</instant>" no final (sem aspas)

pra poder usar ela voce tem que ter um target (tem que estar mirando em alguem)

milbradtM
22 de agosto de 2012 às 11:59

A tag esta certa, não coloquei certinha antes la por que não tinha nada a ver...

A spell funciona no servidor.. ela controla todos monsters perfeitamente, porem se usada em players não funciona direito, eu ando 1 SQM e o Player anda 4 sqm.

22 de agosto de 2012 às 21:17

 

local function move(cid, target, playerpos, targetpos, times)

if playerdir ~= getCreatureLookDirection(cid) then

doCreatureSetLookDirection(target, getCreatureLookDirection(cid))

end

 

if playerpos ~= getCreaturePosition(cid) then

if playerpos.z == getCreaturePosition(cid).z then

local ntpos = getCreaturePosition(cid)

local x,y,z = ntpos.x-playerpos.x,ntpos.y-playerpos.y,ntpos.z-playerpos.z

ntpos = getCreaturePosition(target)

ntpos.x, ntpos.y, ntpos.z = ntpos.x+x,ntpos.y+y,ntpos.z+z

if queryTileAddThing(target, ntpos) == RETURNVALUE_NOERROR and getCreaturePosition(cid).z == getCreaturePosition(target).z then

doMoveCreature(target, getCreatureLookDirection(cid))

end

end

end

local playerpos, targetpos = getCreaturePosition(cid), getCreaturePosition(target)

local times = times+1

if times < 100 then

addEvent(move, 1, cid, target, playerpos, targetpos, times)

else

doCreatureSetNoMove(target, 0)

doSendDistanceShoot(targetpos, playerpos, 15)

doSendAnimatedText(targetpos, "LIVRE!", math.random(1,255))

doPlayerSendCancel(cid, "Você perdeu o controle de "..getCreatureName(target)..".")

if (isPlayer(target)) then

doPlayerSendCancel(cid, "Você está liberto from "..getPlayerName(cid).."'s Shadow Imitation Technique.")

setPlayerStorageValue(target, 14755, -1)

end

end

end

 

function onCastSpell(cid, var)

local target = getCreatureTarget(cid)

if (isPlayer(target)) or (isMonster(target)) then

if getPlayerStorageValue(cid, 14755) == -1 then

doCreatureSetNoMove(target, 1)

doPlayerSendCancel(cid, "You have possessed "..getCreatureName(target)..".")

if (isPlayer(target)) then

doPlayerSendCancel(target, "Você foi possuido por "..getPlayerName(cid)..".")

setPlayerStorageValue(target, 14755, 1)

end

doSendAnimatedText(getCreaturePosition(target), "POSSUIDO!", math.random(1,255))

local playerpos,playerdir,targetpos = getCreaturePosition(cid), getPlayerLookDir(cid), getCreaturePosition(target)

doSendDistanceShoot(playerpos, targetpos, 15)

doSendMagicEffect(getCreaturePosition(target), 186)

local times = 1

addEvent(move, 1000, cid, target, playerpos, targetpos, times)

else

doPlayerSendCancel(cid, "Your Shadow Imitation Technique isn't worn out yet.")

end

end

end

 

Tenta asssim..

milbradtM
23 de agosto de 2012 às 01:34

Então isake..mesma coisa xD

 

A spell se usada em Player o alvo não segue corretamente os movimentos.. e sim anda uns 5 sqm a + =\