Ir para conteúdo

[talkaction] sistema de ataque (m1,m2,m3...)


JacksonXx

Posts Recomendados

Iaew Galera, espero que este tutorial venha a ajuda-los.

 

Abra a pasta data/talkactions/scripts copie ou crie um novo arquivo chamado "move1.lua" , e nele cole o seguinte:

 

 

local msgs = {"use ", ""}

 

function doAlertReady(cid, id, movename, n, cd)

if not isCreature(cid) then return true end

local myball = getPlayerSlotItem(cid, 8)

if myball.itemid > 0 and getItemAttribute(myball.uid, cd) == "cd:"..id.."" then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPokeballName(myball.uid).." - "..movename.." (m"..n..") is ready!")

return true

end

local p = getPokeballsInContainer(getPlayerSlotItem(cid, 3).uid)

if not p or #p <= 0 then return true end

for a = 1, #p do

if getItemAttribute(p[a], cd) == "cd:"..id.."" then

if isInArray({"m1", "m2", "m3"}, n) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPokeballName(p[a]).." - "..movename.." (t"..n..") is ready!")

else

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPokeballName(p[a]).." - "..movename.." (m"..n..") is ready!")

end

return true

end

end

end

 

function onSay(cid, words, param, channel)

 

 

if param ~= "" then return true end

if string.len(words) > 3 then return true end

 

if #getCreatureSummons(cid) == 0 then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need a pokemon to use moves.")

return 0

end

--alterado v2.5

local mypoke = getCreatureSummons(cid)[1]

 

if getCreatureCondition(cid, CONDITION_EXHAUST) then return true end

if getCreatureName(mypoke) == "Evolution" then return true end

 

local name = getCreatureName(mypoke) == "Ditto" and getPlayerStorageValue(mypoke, 1010) or getCreatureName(mypoke)

 

local it = string.sub(words, 2, 3)

local move = movestable[name].move1

if getPlayerStorageValue(mypoke, 212123) >= 1 then

cdzin = "cm_move"..it..""

else

cdzin = "move"..it.."" --alterado v2.5

end

 

if it == "2" then

move = movestable[name].move2

elseif it == "3" then

move = movestable[name].move3

elseif it == "4" then

move = movestable[name].move4

elseif it == "5" then

move = movestable[name].move5

elseif it == "6" then

move = movestable[name].move6

elseif it == "7" then

move = movestable[name].move7

elseif it == "8" then

move = movestable[name].move8

elseif it == "9" then

move = movestable[name].move9

elseif it == "10" then

move = movestable[name].move10

elseif it == "11" then

move = movestable[name].move11

elseif it == "12" then

move = movestable[name].move12

elseif it == "13" then

move = movestable[name].move13

end

 

if isInArray({1,2,3,4,5,6,7,8,9,10,11,12,13}, it) then

mLevel = move.level

mCD = move.cd

mName = move.name

mTarget = move.target

mDist = move.dist

else

m = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "t"..it.."")

mLevel = tmList[m].level

mCD = tmList[m].cd

mName = m

mTarget = tmList[m].target

mDist = tmList[m].dist

end

 

if not move then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your pokemon doesn't recognize this move.")

return true

end

 

--if false and getLevel(mypoke) < mLevel then

if getLevel(mypoke) < mLevel then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your pokemon doesn't have enough level to use this move.")

return 0

end

 

if getCD(getPlayerSlotItem(cid, 8).uid, cdzin) > 0 and getCD(getPlayerSlotItem(cid, 8).uid, cdzin) < (mCD + 2) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to wait "..getCD(getPlayerSlotItem(cid, 8).uid, cdzin).." seconds to use "..mName.." again.")

return 0

end

 

if getTileInfo(getThingPos(mypoke)).protection then

doPlayerSendCancel(cid, "Your pokemon cannot use moves while in protection zone.")

return 0

end

 

if getPlayerStorageValue(mypoke, 3894) >= 1 then

return doPlayerSendCancel(cid, "You can't attack because you is with fear") --alterado v2.3

end

 

if (mName == "Team Slice" or mName == "Team Claw") and #getCreatureSummons(cid) < 2 then --alterado v2.5

doPlayerSendCancel(cid, "Your pokemon need be in a team for use this move!")

return 0

end

--alterado v2.6

if isCreature(getCreatureTarget(cid)) and isInArray(specialabilities["evasion"], getCreatureName(getCreatureTarget(cid))) and math.random(1, 100) <= 10 then

local target = getCreatureTarget(cid)

 

if isCreature(getMasterTarget(target)) then --alterado v2.6 --alterado v2.5

doSendMagicEffect(getThingPos(target), 211)

doSendAnimatedText(getThingPos(target), "TOO BAD", 215)

doTeleportThing(target, getClosestFreeTile(target, getThingPos(mypoke)), false)

doSendMagicEffect(getThingPos(target), 211)

doFaceCreature(target, getThingPos(mypoke))

return true --alterado v2.6

end

end

 

 

if mTarget == 1 then

 

if not isCreature(getCreatureTarget(cid)) then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don\'t have any targets.")

return 0

end

 

if getCreatureCondition(getCreatureTarget(cid), CONDITION_INVISIBLE) then

return 0

end

 

if getCreatureHealth(getCreatureTarget(cid)) <= 0 then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your have already defeated your target.")

return 0

end

 

if not isCreature(getCreatureSummons(cid)[1]) then

return true

end

 

if getDistanceBetween(getThingPos(getCreatureSummons(cid)[1]), getThingPos(getCreatureTarget(cid))) > mDist then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Get closer to the target to use this move.")

return 0

end

 

if not isSightClear(getThingPos(getCreatureSummons(cid)[1]), getThingPos(getCreatureTarget(cid)), false) then

return 0

end

end

 

local newid = 0

 

if isSleeping(mypoke) or isSilence(mypoke) then --alterado v2.5

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't do that right now.")

return 0

else

newid = setCD(getPlayerSlotItem(cid, 8).uid, cdzin, mCD)

end

 

doCreatureSay(cid, ""..getPokeName(mypoke)..", "..msgs[math.random(#msgs)]..""..mName.."!", TALKTYPE_SAY)

 

local summons = getCreatureSummons(cid) --alterado v2.6

 

addEvent(doAlertReady, mCD * 1000, cid, newid, mName, it, cdzin)

 

for i = 2, #summons do

if isCreature(summons) and getPlayerStorageValue(cid, 637501) >= 1 then

docastspell(summons, mName) --alterado v2.6

end

end

 

docastspell(mypoke, mName)

doCreatureAddCondition(cid, playerexhaust)

 

if useKpdoDlls then

doUpdateCooldowns(cid)

end

 

return 0

end

 

Agora em talkactions.xml adicione essas linhas:

 

<talkaction words="m1" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m2" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m3" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m4" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m5" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m6" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m7" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m8" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m9" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m10" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m11" case-sensitive="no" event="script" value="move1.lua"/>

<talkaction words="m12" case-sensitive="no" event="script" value="move1.lua"/>

 

Espero ter ajudado!

 

Creditos:

 

Gabrieltxu

Editado por JacksonXx
Link para o comentário
Compartilhar em outros sites

Jackson, favor postar tal tópico na seção Scripting, é um código comum e não um Tutorial.

 

E favor, melhorar o tópico formatando-o. Obrigado galerinha.

Link para o comentário
Compartilhar em outros sites

Olá XTibiano!

 

Infelizmente, seu tutorial foi reprovado.

Procure por ajuda na seção de como formular um bom tutorial.

 

Grato pela atenção.

Movido.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...