Ir para conteúdo
Propaganda

Posts Recomendados

Ola comunidade, alguem me pode ajudar a resolver o siguiente bug, quando o player esta em batalha e fazer back do pokemon ele server crashea e o pokemon do npc nao ataca o player. (Descupe se nao entendeu, pois nao falo bem portugues.)

 

Spoiler
local target = 0
local prevTarget = 0
local origPos = 0
local max_distance = 12
local fighting = false
local challenger = 0
local battle_turn = 1		-- don't change
local challenger_turn = 0	-- don't change
---
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
local function doPSetGym(target)
    if #getCreatureSummons(target) >= 1 then
		setPlayerStorageValue(target, 990, -1)
		doSetGym(getCreatureSummons(target)[1], 0)
	else
		setPlayerStorageValue(target, 990, -1)
	end
end

local function doSummonGymPokemon(npc)
	local this = npc
	if not isCreature(this) or not ehNPC(this) then return true end  --alterado v1.6
	if #getCreatureSummons(this) >= 1 or target == 0 then return true end
	local it = wildPolice[getPlayerStorageValue(this, 665461)][battle_turn]
	if not it then return true end
	doSummonMonster(this, it.name)              
	local summon = getCreatureSummons(this)[1]
	local summons = getCreatureSummons(target)[1]
	if not summon then                                              --alterado v1.6
       print("Error in npc: "..getCreatureName(this)..", tring to execute function 'doSummonGymPokemon', poke: "..it.name)
       battle_turn = battle_turn+1
       return true 
    end
	local balleffect = pokeballs["normal"].effect
		if it.ball and pokeballs[it.ball] then
			balleffect = pokeballs[it.ball].effect
		end
	doSendMagicEffect(getThingPos(summon), balleffect)
	setPlayerStorageValue(summon, 10000, balleffect)
	setPlayerStorageValue(summon, 10001, gobackmsgs[math.random(#gobackmsgs)].back:gsub("doka", it.nick ~= "" and it.nick or it.name))
	setPlayerStorageValue(summon, 1007, it.nick ~= "" and it.nick or it.name)
	doSetGym(summon, 1)
	if #getCreatureSummons(target) >= 1 then
	doSetMonsterGym(summon, summons)
        end
	addEvent(adjustWildPoke, 15, summon, it.optionalLevel)
	if it.nick ~= "" then doCreatureSetNick(summon, it.nick) end
	local name = it.nick ~= "" and it.nick or getCreatureName(this).."s "..it.name    --alterado v1.3
	doCreatureSay(this, gobackmsgs[math.random(#gobackmsgs)].go:gsub("doka", getPlayerStorageValue(summon, 1007)), 1)
	fighting = true
	battle_turn = battle_turn + 1
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
local function goToOrigPos()
target = 0
selfFollow(0)
fighting = false
challenger = 0
challenger_turn = 0
if #getCreatureSummons(getNpcCid()) >= 1 then
   setPlayerStorageValue(getCreatureSummons(getNpcCid())[1], 1006, 0)
   doCreatureAddHealth(getCreatureSummons(getNpcCid())[1], -getCreatureMaxHealth(getCreatureSummons(getNpcCid())[1]))
end
doChangeSpeed(getNpcCid(), -getCreatureSpeed(getNpcCid()))
doTeleportThing(getNpcCid(), origPos)
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
local function updateTarget()
if(target == 0) then
    local list = getSpectators(getNpcPos(), 9, 9, false)
    for i = 1, table.getn(list) do
        local _target = list[i]
        if(_target ~= 0) then
           if isPlayer(_target) and isRocket(_target) and not getTileInfo(getThingPos(_target)).protection then   --alterado v1.8
              selfSay(policeTalks[math.random(#policeTalks)])
              doNpcSetCreatureFocus(_target) 
              target = _target
              prevTarget = target
              break
           end
        end
    end
end
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
end

function onCreatureMove(creature, oldPos, newPos)
--
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
function onThink()
if not isCreature(getNpcCid()) then return false end  --alterado v1.6
if origPos == 0 then
   origPos = getNpcPos()
end
if getPlayerStorageValue(getNpcCid(), 665461) <= 0 then
   setPlayerStorageValue(getNpcCid(), 665461, math.random(1, 5))
   randOutfit(getNpcCid())
end
updateTarget()
------------------------------------------------------
if getDistanceBetween(getNpcPos(), origPos) >= max_distance or (isCreature(target) and getTileInfo(getThingPos(target)).protection) or getTileInfo(getThingPos(getNpcCid())).protection then  
goToOrigPos()                                                                                                                          --alterado v1.9
end
------------------------------------------------------
if(target == 0) then
if getPlayerStorageValue(getNpcCid(), 154788) <= 0 then
   setPlayerStorageValue(getNpcCid(), 154788, 1)
   doChangeSpeed(getNpcCid(), -getCreatureSpeed(getNpcCid()))
   addEvent(randWalk, 2000, getNpcCid(), 1000, getPlayerStorageValue(getNpcCid(), 154788), target)
end
return true
end 
------------------------------------------------------
local playerPos = getThingPosWithDebug(target)  --alterado v1.6
local myPos = getNpcPos()
------------------------------------------------------
if(myPos.z ~= playerPos.z) then
goToOrigPos()
battle_turn = battle_turn == 1 and battle_turn or battle_turn-1
return true
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) > max_distance then
goToOrigPos()
battle_turn = battle_turn == 1 and battle_turn or battle_turn-1
return true
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) >= 5 then
if getPlayerStorageValue(getNpcCid(), 154788) >= 1 then
   setPlayerStorageValue(getNpcCid(), 154788, -1)
   doRegainSpeed(getNpcCid()) 
   if isCreature(target) then
      selfFollow(target)
   end
end
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) <= 3 then
if getPlayerStorageValue(getNpcCid(), 154788) <= 0 then
   setPlayerStorageValue(getNpcCid(), 154788, 1)
   doChangeSpeed(getNpcCid(), -getCreatureSpeed(getNpcCid()))
   addEvent(randWalk, 2000, getNpcCid(), 1000, getPlayerStorageValue(getNpcCid(), 154788), target)
end
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) <= 5 then
   challenger = target
   setPlayerStorageValue(cid, 990, 1)
   addEvent(doSummonGymPokemon, 850, getNpcCid())

local change = false

if not isCreature(target) then
   target = 0
   battle_turn = battle_turn == 1 and battle_turn or battle_turn-1
   return true
end

if fighting then

   if not isCreature(getCreatureTarget(getNpcCid())) then
      if #getCreatureSummons(challenger) >= 1 then
  if getPlayerStorageValue(getCreatureSummons(challenger)[1], 990) == -1 then
     doSetMonsterGym(getCreatureSummons(getThis())[1], getCreatureSummons(challenger)[1])
	setPlayerStorageValue(getCreatureSummons(challenger)[1], 990, 1)
           doSetAttackGym(getCreatureSummons(getThis())[1], getCreatureSummons(challenger)[1])
		 change = true
	  else
	      if change then
		     change = false
	         challenger_turn = challenger_turn + 1
		  end
      end
   end
		
   if #getCreatureSummons(getNpcCid()) == 0 and isCreature(target) then
      if battle_turn > #wildRocket[getPlayerStorageValue(getNpcCid(), 665461)] then      
         addEvent(doCreateNpc, 300000, ".aPolice", myPos)  --alterado v1.5
         local outfit = getCreatureOutfit(getNpcCid())
         doRemoveCreature(getNpcCid())
         ----------------------------------------
         if outfit.lookType == 1184 then      --verifica se o npc eh female.. ;p
             monster = doCreateMonster("aPoliceFemale", myPos)
         else
             monster = doCreateMonster("aPolice", myPos)
         end
         ----------------------------------------
         doCloneOut(monster, outfit)
         addEvent(beDrunk, 100, monster)
      end
	     addEvent(doSummonGymPokemon, 1000, getNpcCid())
   end

   if #getCreatureSummons(challenger) <= 0 then
      doSetAttackGym(getCreatureSummons(challenger)[0])    --- (O ERROR PODE ESTAR AQUI)---
   end  
end
end

 

 

Captura.PNG

Captura.PNG

Editado por Drenks
error em console
Link para o comentário
https://tibiadevs.com/forums/topic/392-arrumar-wildtrainer/
Compartilhar em outros sites

  • 1 mês depois...
  • Moderador
Em 22/04/2024 em 23:54, Drenks disse:

Ola comunidade, alguem me pode ajudar a resolver o siguiente bug, quando o player esta em batalha e fazer back do pokemon ele server crashea e o pokemon do npc nao ataca o player. (Descupe se nao entendeu, pois nao falo bem portugues.)

 

  Mostrar conteúdo oculto
local target = 0
local prevTarget = 0
local origPos = 0
local max_distance = 12
local fighting = false
local challenger = 0
local battle_turn = 1		-- don't change
local challenger_turn = 0	-- don't change
---
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
local function doPSetGym(target)
    if #getCreatureSummons(target) >= 1 then
		setPlayerStorageValue(target, 990, -1)
		doSetGym(getCreatureSummons(target)[1], 0)
	else
		setPlayerStorageValue(target, 990, -1)
	end
end

local function doSummonGymPokemon(npc)
	local this = npc
	if not isCreature(this) or not ehNPC(this) then return true end  --alterado v1.6
	if #getCreatureSummons(this) >= 1 or target == 0 then return true end
	local it = wildPolice[getPlayerStorageValue(this, 665461)][battle_turn]
	if not it then return true end
	doSummonMonster(this, it.name)              
	local summon = getCreatureSummons(this)[1]
	local summons = getCreatureSummons(target)[1]
	if not summon then                                              --alterado v1.6
       print("Error in npc: "..getCreatureName(this)..", tring to execute function 'doSummonGymPokemon', poke: "..it.name)
       battle_turn = battle_turn+1
       return true 
    end
	local balleffect = pokeballs["normal"].effect
		if it.ball and pokeballs[it.ball] then
			balleffect = pokeballs[it.ball].effect
		end
	doSendMagicEffect(getThingPos(summon), balleffect)
	setPlayerStorageValue(summon, 10000, balleffect)
	setPlayerStorageValue(summon, 10001, gobackmsgs[math.random(#gobackmsgs)].back:gsub("doka", it.nick ~= "" and it.nick or it.name))
	setPlayerStorageValue(summon, 1007, it.nick ~= "" and it.nick or it.name)
	doSetGym(summon, 1)
	if #getCreatureSummons(target) >= 1 then
	doSetMonsterGym(summon, summons)
        end
	addEvent(adjustWildPoke, 15, summon, it.optionalLevel)
	if it.nick ~= "" then doCreatureSetNick(summon, it.nick) end
	local name = it.nick ~= "" and it.nick or getCreatureName(this).."s "..it.name    --alterado v1.3
	doCreatureSay(this, gobackmsgs[math.random(#gobackmsgs)].go:gsub("doka", getPlayerStorageValue(summon, 1007)), 1)
	fighting = true
	battle_turn = battle_turn + 1
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
local function goToOrigPos()
target = 0
selfFollow(0)
fighting = false
challenger = 0
challenger_turn = 0
if #getCreatureSummons(getNpcCid()) >= 1 then
   setPlayerStorageValue(getCreatureSummons(getNpcCid())[1], 1006, 0)
   doCreatureAddHealth(getCreatureSummons(getNpcCid())[1], -getCreatureMaxHealth(getCreatureSummons(getNpcCid())[1]))
end
doChangeSpeed(getNpcCid(), -getCreatureSpeed(getNpcCid()))
doTeleportThing(getNpcCid(), origPos)
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
local function updateTarget()
if(target == 0) then
    local list = getSpectators(getNpcPos(), 9, 9, false)
    for i = 1, table.getn(list) do
        local _target = list[i]
        if(_target ~= 0) then
           if isPlayer(_target) and isRocket(_target) and not getTileInfo(getThingPos(_target)).protection then   --alterado v1.8
              selfSay(policeTalks[math.random(#policeTalks)])
              doNpcSetCreatureFocus(_target) 
              target = _target
              prevTarget = target
              break
           end
        end
    end
end
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
end

function onCreatureMove(creature, oldPos, newPos)
--
end
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--
function onThink()
if not isCreature(getNpcCid()) then return false end  --alterado v1.6
if origPos == 0 then
   origPos = getNpcPos()
end
if getPlayerStorageValue(getNpcCid(), 665461) <= 0 then
   setPlayerStorageValue(getNpcCid(), 665461, math.random(1, 5))
   randOutfit(getNpcCid())
end
updateTarget()
------------------------------------------------------
if getDistanceBetween(getNpcPos(), origPos) >= max_distance or (isCreature(target) and getTileInfo(getThingPos(target)).protection) or getTileInfo(getThingPos(getNpcCid())).protection then  
goToOrigPos()                                                                                                                          --alterado v1.9
end
------------------------------------------------------
if(target == 0) then
if getPlayerStorageValue(getNpcCid(), 154788) <= 0 then
   setPlayerStorageValue(getNpcCid(), 154788, 1)
   doChangeSpeed(getNpcCid(), -getCreatureSpeed(getNpcCid()))
   addEvent(randWalk, 2000, getNpcCid(), 1000, getPlayerStorageValue(getNpcCid(), 154788), target)
end
return true
end 
------------------------------------------------------
local playerPos = getThingPosWithDebug(target)  --alterado v1.6
local myPos = getNpcPos()
------------------------------------------------------
if(myPos.z ~= playerPos.z) then
goToOrigPos()
battle_turn = battle_turn == 1 and battle_turn or battle_turn-1
return true
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) > max_distance then
goToOrigPos()
battle_turn = battle_turn == 1 and battle_turn or battle_turn-1
return true
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) >= 5 then
if getPlayerStorageValue(getNpcCid(), 154788) >= 1 then
   setPlayerStorageValue(getNpcCid(), 154788, -1)
   doRegainSpeed(getNpcCid()) 
   if isCreature(target) then
      selfFollow(target)
   end
end
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) <= 3 then
if getPlayerStorageValue(getNpcCid(), 154788) <= 0 then
   setPlayerStorageValue(getNpcCid(), 154788, 1)
   doChangeSpeed(getNpcCid(), -getCreatureSpeed(getNpcCid()))
   addEvent(randWalk, 2000, getNpcCid(), 1000, getPlayerStorageValue(getNpcCid(), 154788), target)
end
end
------------------------------------------------------
if getDistanceBetween(playerPos, myPos) <= 5 then
   challenger = target
   setPlayerStorageValue(cid, 990, 1)
   addEvent(doSummonGymPokemon, 850, getNpcCid())

local change = false

if not isCreature(target) then
   target = 0
   battle_turn = battle_turn == 1 and battle_turn or battle_turn-1
   return true
end

if fighting then

   if not isCreature(getCreatureTarget(getNpcCid())) then
      if #getCreatureSummons(challenger) >= 1 then
  if getPlayerStorageValue(getCreatureSummons(challenger)[1], 990) == -1 then
     doSetMonsterGym(getCreatureSummons(getThis())[1], getCreatureSummons(challenger)[1])
	setPlayerStorageValue(getCreatureSummons(challenger)[1], 990, 1)
           doSetAttackGym(getCreatureSummons(getThis())[1], getCreatureSummons(challenger)[1])
		 change = true
	  else
	      if change then
		     change = false
	         challenger_turn = challenger_turn + 1
		  end
      end
   end
		
   if #getCreatureSummons(getNpcCid()) == 0 and isCreature(target) then
      if battle_turn > #wildRocket[getPlayerStorageValue(getNpcCid(), 665461)] then      
         addEvent(doCreateNpc, 300000, ".aPolice", myPos)  --alterado v1.5
         local outfit = getCreatureOutfit(getNpcCid())
         doRemoveCreature(getNpcCid())
         ----------------------------------------
         if outfit.lookType == 1184 then      --verifica se o npc eh female.. ;p
             monster = doCreateMonster("aPoliceFemale", myPos)
         else
             monster = doCreateMonster("aPolice", myPos)
         end
         ----------------------------------------
         doCloneOut(monster, outfit)
         addEvent(beDrunk, 100, monster)
      end
	     addEvent(doSummonGymPokemon, 1000, getNpcCid())
   end

   if #getCreatureSummons(challenger) <= 0 then
      doSetAttackGym(getCreatureSummons(challenger)[0])    --- (O ERROR PODE ESTAR AQUI)---
   end  
end
end

 

 

Captura.PNG

Captura.PNG

Estou atrás dessa base contém srC chama aí no chat ficarei feliz te  ajudar  chama no chat que te passo meu whats.

Link para o comentário
https://tibiadevs.com/forums/topic/392-arrumar-wildtrainer/#findComment-2540
Compartilhar em outros sites

Crie uma conta ou entre para comentar

Você precisar ser um membro para fazer um comentário

Criar uma conta

Crie uma nova conta em nossa comunidade. É fácil!

Crie uma nova conta

Entrar

Já tem uma conta? Faça o login.

Entrar Agora
×
  • Criar Novo...