Ir para conteúdo
  • Cadastre-se

Programa%C3%A7%C3%A3o [C++] doCreatureCastSpell(creature, spellName)


Posts Recomendados

@Orochi

Duas perguntas para você:

  1. No caso ele vai pegar o nome da spell onde exatamente? Spells.xml? 
  2. Essa função é igual a que tem no  Pokémon Dash Advanced (PDA)? 
Link para o post
Compartilhar em outros sites

1. Sim, ele pega no spells.xml, se eu não me engano é o primeiro parametro da tag kkkk

 

2. Não, essa função eu nunca vi nenhum servidor que use-a. Porém, já ouvi boatos que o PStorm, ou PAdventures, eu não lembro direito, já fizeram um sistema de moves mais leve utilizando esta função, assim otimizando o desempenho do servidor.

Tony Araújo  ;D 

 

Link para o post
Compartilhar em outros sites

Magias não levam em consideração o ml e level do player ? isso não da bug ?

O mesmo BananaFight, mais com um novo Nick.

 

 
Abra sua mente, sangue suga não vive sem um hospedeiro, Não faça script para os outros, ensine-os a fazer.
Link para o post
Compartilhar em outros sites

Então parabéns +Rep, muito útil essa função.

O mesmo BananaFight, mais com um novo Nick.

 

 
Abra sua mente, sangue suga não vive sem um hospedeiro, Não faça script para os outros, ensine-os a fazer.
Link para o post
Compartilhar em outros sites

segura meu rep ai Tony haha

                                                                            FZhO4Uj.gif

                                                                             A mente que se abre a uma nova ideia jamais voltará ao seu tamanho original.

Link para o post
Compartilhar em outros sites

essa função esta melhor que as outras mas acabei reparando que ela só causa dano se você tiver com target na criatura, exemplo em uma magia em area ela só vai dar dano no target, mais por algum motivo ela causa o dano em area em outros summons seus 

Link para o post
Compartilhar em outros sites

essa função esta melhor que as outras mas acabei reparando que ela só causa dano se você tiver com target na criatura, exemplo em uma magia em area ela só vai dar dano no target, mais por algum motivo ela causa o dano em area em outros summons seus 

Rapaz, se ela vai dar dano nos outros ou não, não é problema da função kkkk. É só fazer o script para bloquear isso :)

 

 

Muito útil a função REP+

Faça bom uso :)

Tony Araújo  ;D 

 

Link para o post
Compartilhar em outros sites
  • 1 month later...

:accept:GOSTEI

 

Admiro muito qualquer trabalho feito em C++ para OTserv, costuma ser o mais difícil. Parabéns!

 

Realmente o bug já citado, existe, usando uma magia de área sem ter um target, a magia não causa dano em nenhum monstro que está perto. (@ edit Isso se o cid for um monstro, caso cid seja player o dano é sempre o mesmo, estou tentando adicionar dois parametros a funcao, dano minimo e dano maximo)

 

Estou lendo um pouco da sources pra ver o que eu consigo...

 

 

Obrigado.

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

 

 

facebook.com/PokeJota

Link para o post
Compartilhar em outros sites

Deixa de fazer uma pergunta no meu serve utilizo a funçao docastspell que no caso ja veio com o servidor no caso mudaria o que nisso ?

Ficaria melhor no desempenho?Valeria a pena mudar?

 

ex: na pasta spell vem assim

 

function onCastSpell(cid, var)



if isSummon(cid) then return true end
docastspell(cid, "Quick Attack")

return true
end

 

ai no caso ele vai pegar essa magia na pasta ta lib

 

const_distance_delay = 56


local function getSubName(cid, target)
if not isCreature(cid) then return "" end
if getCreatureName(cid) == "Ditto" and pokes[getPlayerStorageValue(cid, 1010)] and getPlayerStorageValue(cid, 1010) ~= "Ditto" then
return getPlayerStorageValue(cid, 1010)
elseif pokeHaveReflect(cid) and isCreature(target) then
return getCreatureName(target)
else
return getCreatureName(cid)
end
end

local function getThingName(cid)
if not isCreature(cid) then return "" end
return getCreatureName(cid)
end

function getTableMove(cid, move)
local backup = {f = 0, t = ""}
if getThingName(cid) == "Ditto" and pokes[getPlayerStorageValue(cid, 1010)] and getPlayerStorageValue(cid, 1010) ~= "Ditto" then
name = getPlayerStorageValue(cid, 1010)
else
name = getThingName(cid)
end
if not isCreature(cid) or name == "" or not move then return backup end
local x = movestable[name]
if not x then return "" end
local z = {x.move1, x.move2, x.move3, x.move4, x.move5, x.move6, x.move7, x.move8, x.move9, x.move10, x.move11, x.move12, x.passive1, x.passive2, x.passive3}
if getPlayerStorageValue(cid, 21103) ~= -1 then
local sto = getPlayerStorageValue(cid, 21103)
setPlayerStorageValue(cid, 21103, -1)
return {f = sto, t = ""}
end
for j = 1, 15 do
if z[j] and z[j].name == move then
return z[j]
end
end
return movesinfo[move]
end

function getMasterTarget(cid)
if isCreature(cid) and getPlayerStorageValue(cid, 21101) ~= -1 then
return getPlayerStorageValue(cid, 21101)
end
if isSummon(cid) then
return getCreatureTarget(getCreatureMaster(cid))
else
return getCreatureTarget(cid)
end
end
--////////////////////////////////////////////////////////////////////////////////////////////////////////--

function docastspell(cid, spell, mina, maxa)

local target = 0
local getDistDelay = 0
if not isCreature(cid) or getCreatureHealth(cid) <= 0 then return false end
if isSleeping(cid) and getPlayerStorageValue(cid, 21100) <= -1 then return true end

if isCreature(getMasterTarget(cid)) then
target = getMasterTarget(cid)
getDistDelay = getDistanceBetween(getThingPosWithDebug(cid), getThingPosWithDebug(target)) * const_distance_delay
end

if isMonster(cid) and not isSummon(cid) then
if getCreatureCondition(cid, CONDITION_EXHAUST) then
return true
end
doCreatureAddCondition(cid, wildexhaust)
end

local mydir = isCreature(target) and getCreatureDirectionToTarget(cid, target) or getCreatureLookDir(cid)
local table = getTableMove(cid, spell)

local min = 0
local max = 0

----------------------------
if mina and maxa then
min = math.abs(mina)
max = math.abs(maxa)
elseif not isPlayer(cid) then
if table ~= "" then

min = getSpecialAttack(cid) * table.f * 0.1
max = min + (isSummon(cid) and getMasterLevel(cid) or getPokemonLevel(cid))

if not isSummon(cid) and not isInArray({"Demon Puncher", "Demon Kicker"}, spell) then
doCreatureSay(cid, string.upper(spell).."!", TALKTYPE_MONSTER)
end
if isNpcSummon(cid) then
local mnn = {" use ", " "}
local use = mnn[math.random(#mnn)]
doCreatureSay(getCreatureMaster(cid), getPlayerStorageValue(cid, 1007)..","..use..""..doCorrectString(spell).."!", 1)
end
else
print("Error trying to use move "..spell..", move not specified in the pokemon table.")
end

end
---------------------------------------------------

if spell == "Quick Attack" then

doDanoWithProtect(cid, NORMALDAMAGE, getThingPosWithDebug(target), 0, -min, -max, 111)

elseif spell == "Razor Leaf" or spell == "Magical Leaf" then

local eff = spell == "Razor Leaf" and 8 or 21

local function throw(cid, target)
if not isCreature(cid) or not isCreature(target) then return false end
doSendDistanceShoot(getThingPosWithDebug(cid), getThingPosWithDebug(target), eff)
doDanoInTargetWithDelay(cid, target, GRASSDAMAGE, min, max, 245)
end

addEvent(throw, 0, cid, target)
addEvent(throw, 100, cid, target)

end


end
return true
end

Editado por nociam (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Seguinte, a função foi feita para você fazer a criatura usar a magia que existe la no spells.xml

O que ela faz depois, é você quem decide dentro do script.

 

Obrigado pelos elogios ^^

Tony Araújo  ;D 

 

Link para o post
Compartilhar em outros sites

Deixa de fazer uma pergunta no meu serve utilizo a funçao docastspell que no caso ja veio com o servidor no caso mudaria o que nisso ?

Ficaria melhor no desempenho?Valeria a pena mudar?

 

ex: na pasta spell vem assim

 

function onCastSpell(cid, var)

if isSummon(cid) then return true end

docastspell(cid, "Quick Attack")

return true

end

 

ai no caso ele vai pegar essa magia na pasta ta lib

 

const_distance_delay = 56

local function getSubName(cid, target)

if not isCreature(cid) then return "" end

if getCreatureName(cid) == "Ditto" and pokes[getPlayerStorageValue(cid, 1010)] and getPlayerStorageValue(cid, 1010) ~= "Ditto" then

return getPlayerStorageValue(cid, 1010)

elseif pokeHaveReflect(cid) and isCreature(target) then

return getCreatureName(target)

else

return getCreatureName(cid)

end

end

local function getThingName(cid)

if not isCreature(cid) then return "" end

return getCreatureName(cid)

end

function getTableMove(cid, move)

local backup = {f = 0, t = ""}

if getThingName(cid) == "Ditto" and pokes[getPlayerStorageValue(cid, 1010)] and getPlayerStorageValue(cid, 1010) ~= "Ditto" then

name = getPlayerStorageValue(cid, 1010)

else

name = getThingName(cid)

end

if not isCreature(cid) or name == "" or not move then return backup end

local x = movestable[name]

if not x then return "" end

local z = {x.move1, x.move2, x.move3, x.move4, x.move5, x.move6, x.move7, x.move8, x.move9, x.move10, x.move11, x.move12, x.passive1, x.passive2, x.passive3}

if getPlayerStorageValue(cid, 21103) ~= -1 then

local sto = getPlayerStorageValue(cid, 21103)

setPlayerStorageValue(cid, 21103, -1)

return {f = sto, t = ""}

end

for j = 1, 15 do

if z[j] and z[j].name == move then

return z[j]

end

end

return movesinfo[move]

end

function getMasterTarget(cid)

if isCreature(cid) and getPlayerStorageValue(cid, 21101) ~= -1 then

return getPlayerStorageValue(cid, 21101)

end

if isSummon(cid) then

return getCreatureTarget(getCreatureMaster(cid))

else

return getCreatureTarget(cid)

end

end

--////////////////////////////////////////////////////////////////////////////////////////////////////////--

function docastspell(cid, spell, mina, maxa)

local target = 0

local getDistDelay = 0

if not isCreature(cid) or getCreatureHealth(cid) <= 0 then return false end

if isSleeping(cid) and getPlayerStorageValue(cid, 21100) <= -1 then return true end

if isCreature(getMasterTarget(cid)) then

target = getMasterTarget(cid)

getDistDelay = getDistanceBetween(getThingPosWithDebug(cid), getThingPosWithDebug(target)) * const_distance_delay

end

if isMonster(cid) and not isSummon(cid) then

if getCreatureCondition(cid, CONDITION_EXHAUST) then

return true

end

doCreatureAddCondition(cid, wildexhaust)

end

local mydir = isCreature(target) and getCreatureDirectionToTarget(cid, target) or getCreatureLookDir(cid)

local table = getTableMove(cid, spell)

local min = 0

local max = 0

----------------------------

if mina and maxa then

min = math.abs(mina)

max = math.abs(maxa)

elseif not isPlayer(cid) then

if table ~= "" then

min = getSpecialAttack(cid) * table.f * 0.1

max = min + (isSummon(cid) and getMasterLevel(cid) or getPokemonLevel(cid))

if not isSummon(cid) and not isInArray({"Demon Puncher", "Demon Kicker"}, spell) then

doCreatureSay(cid, string.upper(spell).."!", TALKTYPE_MONSTER)

end

if isNpcSummon(cid) then

local mnn = {" use ", " "}

local use = mnn[math.random(#mnn)]

doCreatureSay(getCreatureMaster(cid), getPlayerStorageValue(cid, 1007)..","..use..""..doCorrectString(spell).."!", 1)

end

else

print("Error trying to use move "..spell..", move not specified in the pokemon table.")

end

end

---------------------------------------------------

if spell == "Quick Attack" then

doDanoWithProtect(cid, NORMALDAMAGE, getThingPosWithDebug(target), 0, -min, -max, 111)

elseif spell == "Razor Leaf" or spell == "Magical Leaf" then

local eff = spell == "Razor Leaf" and 8 or 21

local function throw(cid, target)

if not isCreature(cid) or not isCreature(target) then return false end

doSendDistanceShoot(getThingPosWithDebug(cid), getThingPosWithDebug(target), eff)

doDanoInTargetWithDelay(cid, target, GRASSDAMAGE, min, max, 245)

end

addEvent(throw, 0, cid, target)

addEvent(throw, 100, cid, target)

end

end

return true

end

onCastSpell é um evento e doCreatureCastSpell uma ação, são coisas diferentes...

Link para o post
Compartilhar em outros sites
  • 6 months later...

Excelente função...

Infelizmente não consegui convertê-la para 0.4.0 trunk_3884.

 

Tentei alterar de:

int32_t LuaScriptInterface::luaDoCreatureCastSpell(lua_State* L)

para:

int32_t LuaInterface::luaDoCreatureCastSpell(lua_State* L)

 

Porém, deu muitos erros na hora de compilar. :/

 

Se puder criar para minha source, serei eternamente grato manolo . :)

 

Abraços, vê se aparece mais no skype.

Gosta do meu trabalho?

Curta e siga a página do meu projeto de 2016 e 2017 (Lab Z Games) que trará vários servidores OTServs.

 

Atenciosamente,
Adriano Swatt'

 

Para ver meus tutoriais acesse meu perfil.

 

cbCyOSZ.png

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo