Postado Abril 21, 2015 10 anos 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 Abril 21, 2015 10 anos por eskylo (veja o histórico de edições) facebook.com/PokeJota
Postado Abril 22, 2015 10 anos 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 Abril 22, 2015 10 anos por nociam (veja o histórico de edições)
Postado Abril 25, 2015 10 anos Autor 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
Postado Abril 25, 2015 10 anos 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...
Postado Novembro 11, 2015 9 anos 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.
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.