Ir para conteúdo
  • Cadastre-se

AJUDA SCRIPT Bloquear ataque NPC Ginásio


Posts Recomendados

Bom dia, estou adaptando o npc Ginásio do PDA para meu servidor, terminei o npc, porém precisava bloquear para quem não estiver em batalha com o npc não poder atacar o summon do npc, alguém pode me ajudar?

 

Script do npc

local focus = 0
local max_distance = 8
local talk_start = 0
local conv = 0
local fighting = false
local challenger = 0
local pokeNpc = nil
local pokeChalenger = nil
local afk_limit_time = 300	-- seconds
local afk_time = 0		-- don't change
local battle_turn = 0		-- don't change
local challenger_turn = 0	-- don't change

local pokemons = {
	{name = "Rattata", optionalLevel = 300, sex = SEX_MALE, nick = "", ball = "normal"},
	{name = "Pidgey", optionalLevel = 300, sex = SEX_MALE, nick = "", ball = "normal"},
	-- {name = "Vaporeon", optionalLevel = 300, sex = SEX_FEMALE, nick = "", ball = "normal"},
	-- {name = "Golduck", optionalLevel = 300, sex = SEX_MALE, nick = "", ball = "normal"},
	-- {name = "Blastoise", optionalLevel = 300, sex = SEX_MALE, nick = "", ball = "normal"},
	-- {name = "Starmie", optionalLevel = 300, sex = SEX_FEMALE, nick = "", ball = "normal"},
}


local function doSummonGymPokemon(npc)
	battle_turn = battle_turn + 1
	local this = npc
	if #getCreatureSummons(this) >= 1 or focus == 0 then return true end
	local it = pokemons[battle_turn]
	pokeNpc = doSummonCreature(it.name, getThingPos(this))
	local summon = getCreatureSummons(this)[1]
	local balleffect = pokeballs["normal"].effect
	if it.ball and pokeballs[it.ball] then
		balleffect = pokeballs[it.ball].effect
	end
	doSendMagicEffect(getThingPos(pokeNpc), balleffect)

	setPlayerStorageValue(pokeNpc, 990, this)
	setPlayerStorageValue(pokeNpc, 991, "battle")
	setPlayerStorageValue(pokeNpc, 8595, 1)
	setPlayerStorageValue(this, 990, 1)
	addEvent(adjustWildPoke, 15, pokeNpc, it.optionalLevel)
	mgo = gobackmsgs[math.random(1, #gobackmsgs)].go:gsub("doka", it.name)
	doCreatureSay(this, mgo, 1)
	fighting = true
end

local function doWinDuel(cid, npc)
	if not isCreature(cid) then return true end
	local this = npc
	local a = gymbadges[getCreatureName(this)] + 8
	doCreatureSay(npc, "You won the duel! Congratulations, take this "..getItemNameById(a - 8).." as a prize.", 1)
	local b = getPlayerItemById(cid, true, a)
	if b.uid > 0 then doTransformItem(b.uid, b.itemid - 8) end
	doPlayerSendCancel(cid, "#getBadges# "..getCreatureName(this).." "..getPlayerItemCount(cid, gymbadges[getCreatureName(this)]))
end

function onCreatureSay(cid, type, msg)
	local msg = string.lower(msg)

	if focus == cid then
		talk_start = os.clock()
	end

	if msgcontains(msg, 'hi') and focus == 0 and getDistanceToCreature(cid) <= 4 then
		focus = cid
		talk_start = os.clock()
		conv = 1
		selfSay("Hello "..getCreatureName(cid)..", my name is Misty and I'm Cerulean's Gym Leader. How may I help you?")
		return true
	end

	if isDuelMsg(msg) and conv == 1 and focus == cid then
		--if getPlayerItemCount(cid, gymbadges[getCreatureName(getThis())]) >= 1 then
		--	selfSay("You have already won my Cascade Badge, maybe some other day we can fight.")
		--	focus = 0
		--return true
		--end

		-- if not hasPokemon(cid) then
			-- selfSay("To battle agains't a gym leader you need pokemons.")
		-- return true
		-- end

		selfSay("You are challenging me to a battle. It will be a "..#pokemons.." pokemon limit battle, let's start?")
		conv = 2

	return true
	end

	if isConfirmMsg(msg) and conv == 2 and focus == cid then
		challenger = focus
		setPlayerStorageValue(cid, 990, 1)
		setPlayerStorageValue(cid, 999, 1)
		selfSay("Yea, let's fight!")
		talk_start = os.clock()
		setPlayerStorageValue(getThis(), 990, 1)
		addEvent(doSummonGymPokemon, 5, getThis())
		conv = 3
	return true
	end

	if isNegMsg(msg) and conv == 2 and focus == cid then
		focus = 0
		selfSay("It is better for you to refuse a battle against me!")
	return true
	end

	local function doRemove(npc)
	local it = pokemons[battle_turn]
		local balleffect = pokeballs["normal"].effect
	if it.ball and pokeballs[it.ball] then
		balleffect = pokeballs[it.ball].effect
	end
	doSendMagicEffect(getThingPos(pokeNpc), balleffect)
	doRemoveCreature(pokeNpc)
	end

	if msgcontains(msg, 'bye') and focus == cid then
		selfSay('Bye and do your best trainer!')
		setPlayerStorageValue(focus, 990, -1)
		setPlayerStorageValue(focus, 999, -1)
		addEvent(doRemove, 50, this)
		focus = 0
	return true
	end
end

local afk_warning = false

function checkPoke(player, poke)

end

function onThink()

	if focus == 0 then
		selfTurn(2)
		fighting = false
		challenger = 0
		challenger_turn = 0
		battle_turn = 0
		afk_time = 0
		afk_warning = false
		setPlayerStorageValue(getThis(), 990, -1)
		return true
	else
		if not isCreature(focus) then
			focus = 0
			return true
		end
		if fighting then
			talk_start = os.clock()

			if #getCreatureSummons(challenger) >= 1 then
				if pokeChalenger == nil then
					pokeChalenger = getCreatureName(getCreatureSummons(challenger)[1])
					afk_time = 0
					challenger_turn = challenger_turn + 1
				elseif pokeChalenger == getCreatureName(getCreatureSummons(challenger)[1]) then
					afk_time = 0
				else
					afk_time = 0
					challenger_turn = challenger_turn + 1
					pokeChalenger = getCreatureName(getCreatureSummons(challenger)[1])
				end
			else
					afk_time = afk_time + 0.5
			end

			if afk_time > afk_limit_time then
				setPlayerStorageValue(focus, 990, -1)
				focus = 0
				selfSay("I have waited too long, come back when you are ready!")
			return true
			end

			if not afk_warning and afk_time > afk_limit_time / 2 then
				selfSay("Where's your pokemon? Let's fight!")
				afk_warning = true
			end


			if getPlayerStorageValue(getThis(), 990) == 0 then
				if battle_turn >= #pokemons then
					addEvent(doWinDuel, 1000, focus, getThis())
					setPlayerStorageValue(focus, 990, -1)
					focus = 0
				return true
				end
				setPlayerStorageValue(getThis(), 990, 1)
				addEvent(doSummonGymPokemon, 1000, getThis())
			end

			if challenger_turn >= 7 or challenger_turn > #pokemons then
				selfSay("You lost our duel! Maybe some other time you'll defeat me.")
				setPlayerStorageValue(focus, 990, -1)
				focus = 0
			return true
			end
		end

		local npcpos = getThingPos(getThis())
		local focpos = getThingPos(focus)

		if npcpos.z ~= focpos.z then
			setPlayerStorageValue(focus, 990, -1)
			focus = 0
			selfSay("Bye then.")
			return true
		end

		if (os.clock() - talk_start) > 30 then
			selfSay("Good bye and keep training!")
			setPlayerStorageValue(focus, 990, -1)
			focus = 0
		end

		if getDistanceToCreature(focus) > max_distance then
			setPlayerStorageValue(focus, 990, -1)
			focus = 0
		return true
		end

		local dir = doRedirectDirection(getDirectionTo(npcpos, focpos))
		selfTurn(dir)
	end
return true
end

Tentativa que fiz para bloquear o ataque para quem não estar em duel com o npc.

function onTarget(cid, target)

if getPlayerStorageValue(target, 990) ~= -1 then
if getPlayerStorageValue(target, getPlayerStorageValue(target, 999)) == 1 then
	if getPlayerStorageValue(cid, getPlayerStorageValue(target, 999)) ~= 1 then
	doPlayerSendCancel(cid, "You can't attack this pokemon.")
	return false
	end
end
end

                                                                                               1zcn2mb.jpg

 

                                                                                                                       Danera Global Server

                                                                                                                       Versão: 10.77 - 10.79

                                                                                                                       Sem Items VIP

                                                                                                                       Venha se divertir

Link para o post
Compartilhar em outros sites
  • Respostas 5
  • Created
  • Última resposta

Top Posters In This Topic

Da pra você por para que players sem a storage que o NPC dá, não consiga atacar monstros com determinado nome, acho que fica mais simples de fazer.

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

@Adriano SwaTT

Não daria certo, pois os monstros do Ginásio tem o mesmo nome dos monstros selvagens.


up

                                                                                               1zcn2mb.jpg

 

                                                                                                                       Danera Global Server

                                                                                                                       Versão: 10.77 - 10.79

                                                                                                                       Sem Items VIP

                                                                                                                       Venha se divertir

Link para o post
Compartilhar em outros sites

Alguém ai tem uma solução?

                                                                                               1zcn2mb.jpg

 

                                                                                                                       Danera Global Server

                                                                                                                       Versão: 10.77 - 10.79

                                                                                                                       Sem Items VIP

                                                                                                                       Venha se divertir

Link para o post
Compartilhar em outros sites

Não testei, e nem tenho como testar. Estou confiando na sua base.

 

 

function onTarget(cid, target)
 
if not getPlayerStorageValue(cid, 990) == 1 then
doPlayerSendCancel(cid, "You can't attack this pokemon.")
end
return false
end
Editado por mateusak (veja o histórico de edições)

Não se esqueça de dar REP+ para quem te ajudou e caso seja a solução marcar como melhor resposta!

 

NÃO CLIQUE AQUI!

NEM AQUI!

________________________________________________________________________________________________________________________________________________________________________________________________________________________

 

A imaginação é mais importante que o conhecimento.” Albert Einstein

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.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por SlowK
      Pokémon Centurion
      (Tópico atualizado apenas para melhorar a aparência, servidor sem atualização desde 19/06/2014).
       
      Distro: Pokémon Dash Online Advanced 1.0 (PDA [Baseada na TFS 0.3.6])
      (Não tenho source).
       - Antigo cliente 8.54 -
       
      • Informações •
      - Ataques m1 ao m12
      - Sistema de bike
      - Sistema de boost
      - Trade Center
      - Mapa LunusOT
      - Sistema de profissões
      - Pokémons com níveis (com evolução)
      - Vários Shinies dentre eles da nova geração
      - Rocket (Giovani) e Police
      - Addons novos
      - Alguns Pokés com remakes
      - Várias quests escondidas
       
      • Algumas imagens •
      (Caso não estejam aparecendo, baixe aqui: IMAGENS)
       
      Senha do ADM: god/god
       
      • Links •
      Servidor
      Cliente
      (Mediafire já fornece scan semelhante ao vírustotal, basta descer a página um pouco).
       
      • Créditos •
      Cacaiu Alexandre
      Bruno Maciel
      Patrick Estrela
      SlowMCZ
       
       
      Obs: Servidor não será mais atualizado, nem darei ajuda, pois faz muito tempo que não mexo com tal server.
    • Por Nextbr
      Boa Noite Glaera, BLZ?
       
      Hoje Vou Postar Mais uma de minhas Ideias Loucas de Poketibia que eu particulamente achei legal ate que se Chama "Catch Channel"
       
      [+] Para que Serve o Catch Channel?
      - Simples Serve Para voce Ver todos os Catch do Servidor no Canal "Catch Channel"
      - O Script é Bem Basico!
       
       
      [+] Intao Vamos La:
       
      [+] Servidor Testado:
      Pokemon Dash Advanced (PDA V2.5 BY: BOLZ)
       
       
      Vai em data/lib/CATCHSYSTEM.LUA  e Procure por Essa funçao: 



       
      - Procure por essa Parte do Script:



       
      - Logo Abaixo Adiciona isso:



       
      Explicando:
       
      TALKTYPE_CHANNEL_W: Letra Branca 
      5 : Channel ID (No Caso é o Game-Chat)
       
      Depois vai em data/xml/channels.xml e troca seu Channel id "5" Para Esse:



       
      [+] Imagem:

      Hidden Content
      Give reaction to this post to see the hidden content.  
      Creditos: NextBR
    • Por Nextbr
      Boa Tarde Turma, Eu vou Postar o Sistema de Apricorns Feito Pelo "RicardoSohn"
      * Esse Sistema é para adicionar atributos (Forças) aos Pokemons!
       
      Server Usado: Pokemon Dash Advanced [servidor com Pokelevel system]
       
      vai em actions/apricorns.lua:
       



       
      *Editar:
      tabela_status = {
      [13365] = {name="offense", value = 10},
      [13366] = {name="defense", value = 10},
      [13367] = {name="speed", value = 10},
      [13368] = {name="vitality", value = 10},
      [13369] = {name="specialattack", value = 10},
      }
       
      *[iD DO APRICORN] = {name="offense", value = Quantia de atributo "offense" dado para o pokemon},
       
      XML: <action itemid="13365-13371" event="script" value="Apricorn.lua"/>
       
      O que o Script Faz?
      Simplesmente Adiciona o atributo no Status do Pokemon Selecionado Exemplo:
      14:14 You see a Saffari Ball.
      It contains a Charizard [level 1]. It is female. --- Status --- Offense: 11 Defense: 10 Agility: 0 Sp. Attack: 13 Vitality: 18   Agora vou aumentar os atributos do status do Pokemon Selecionado:   14:14 You see a Saffari Ball. It contains a Charizard [level 1]. It is female. --- Status --- Offense: 21 Defense: 20 Agility: 10 Sp. Attack: 23 Vitality: 28
    • Por Nextbr
      Eae Galera Tudo na Paz?

      [+] Hoje Vou Postar um Script de Catch Por Skill Configurado No "Sword Fighting" do Seu Old Client Intao vamos La:

      -Resumo: Quanto Maior o Skill "Catching" Maior a chance de Captura do Pokemon!

      [+] OBS: Eu nao Vou Postar o Script Completo Pois de Cada (PDA) ou (PDA - COM PokeLevel) é Diferente um do Outro, Eu So vou Ensinar a Voces a como Adicionar o Sistema em Seus Servidores!

      [+] Servidor Testado:
      - Pokemon Dash Advanced

      [+] Primeiro Vai em Data/Lib/catchsystem.lua e Procure por essa Funçao:






      [+] Na Parte aonde manda a MSG de que Voce "capturou um Pokemon" e "Capturou um Pokemon e Foi para o CP" add Isso Abaixo dessas Msg:




      - Resumo: doPlayerAddSkillTry(cid,2,10) --- Quando Capturar um Pokemon vai Ganhar 10% de Skill "2".
      - Obs: No meu Client o Skill Catching Esta no Skill "Sword Fighting"



      [+] Bom Logo Apos Voce vai em data/actions/catch.lua e no Começo do Script add isso:


        [+] Agora Procure essa Funçao: local catchinfo = {}

      - E Troca por Isso:




      -OBS: O Script é Bem Basico. Dar Para adicionar varios Coisas Como (Ganhar EXP Dependendo do Skill/Almentar Chance de Catch para Premium Account e etc...)

      [+] Imagens:

      Hidden Content
      Give reaction to this post to see the hidden content.

      [+] OBS: So vai ganhar Skill se Voce Capturar o Pokemon e Recomendo voces Deixar o Catch BAIXO! Por que o Script faz a Soma de Rate um Exemplo:
      Pokeball Rate: 50
      Skill Cathing Rate (com 25 de Skill Cathing) : 100
      Somar: 50+100 = 150 de Rate o Jogador vai ter  
      [script Atualizado Dia 25/01/2015]




      [+] Creditos: NextBR
    • Por Nextbr
      Boa Tarde Turma, Hoje vou Postar um sistema De Torneio Para Poketibia!
       
      Para que possa funcionar o sistema de Torneio verifique se na (area pvp-zone ) funciona o pvp, caso nao funciona tentem procurar um tutorial de como liberar o pvp-zone e talves tente mudar isso aki no config.lua de voces:
      worldType = "pvp-enforced"
      protectionLevel = 1   Bom Chega de Mimimi e vamos La:   data/lib/Torneio.lua e add isso:

        Depois vai em Globaleevents/Torneio.lua

        <globalevent name="TournamentStart" time="11:35" event="script" value="Torneio.lua"/>   Depois vai em Actions/Torneio.lua: Atençao: Voce faz uma area do Torneio no Map editor e Coloca PVP-Zone no Mapa editor  e coloca uma Alavanca com a uid "18279"

        XML: <action uniqueid="18279" event="script" value="Torneio.lua"/>   Agora o NPC TORNEIO NPCS/NPCS.XML:

       
      NPC/SCRIPTS/Torneio.lua:



       
       
      [*] Bom é so Isso Flw bj ;*
       
         
  • Estatísticas dos Fóruns

    96844
    Tópicos
    519603
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo