[Resolvido] spawn de mega

marmita2
em Resolvidos

marmita2

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/02/19Posts: 30

Galera estou querendo que o mega spawna aleatório. tentei adaptar o spaw.lua e deixei assim porem não esta spawnando. alguem poderia me falar se é erro no codigo,

pois não for, ele não deve estar para spawnar 

Yan Oliveira

Yan18
avatar
Moderador
Moderador

INFOS

Grupo: ModeradorRegistrado: 05/06/12Posts: 2221Gênero: Masculino
23 horas atrás, marmita2 disse:
Versão do Servidor:
Tipo de Script: creaturescript
Código:
  Ocultar conteúdo

local shinys = {""}

local raros = {"Lucario", "Gyarados", "Gengar", "Blaziken", "Blastoise", "Beedrill", "Alakazam", "Charizard"}                               

local function MegaName(cid)
if isCreature(cid) then
   if string.find(tostring(getCreatureName(cid)), "Mega") then
      local newName = tostring(getCreatureName(cid)):match("Mega (.*)")             
      doCreatureSetNick(cid, newName)
      if isMonster(cid) then
         doSetCreatureDropLoot(cid, true)  
      end
   end
end
end

local function doSetRandomGender(cid)
	if not isCreature(cid) then return true end
	if isSummon(cid) then return true end
	local gender = 0
	local name = getCreatureName(cid)
	if not newpokedex[name] then return true end
	local rate = newpokedex[name].gender
		if rate == 0 then
			gender = 3
		elseif rate == 500 then
			gender = 4
		elseif rate == -1 then
			gender = 0
		elseif math.random(1, 500) <= rate then
			gender = 4
		else
			gender = 3
		end
	doCreatureSetSkullType(cid, gender)
end

local function doMega(cid)
if isCreature(cid) then
   if isSummon(cid) then return true end
   if getPlayerStorageValue(cid, 74469) >= 1 then return true end
   if getPlayerStorageValue(cid, 22546) >= 1 then return true end 
   if isNpcSummon(cid) then return true end
   if getPlayerStorageValue(cid, 637500) >= 1 then return true end  --alterado v1.9
   
if isInArray(megas, getCreatureName(cid)) then  --alterado v1.9 \/
   chance = 2.0    --1% chance        
elseif isInArray(raros, getCreatureName(cid)) then   --n coloquem valores menores que 0.1 !!
   chance = 1   --1% chance       
else
   return true
end    
    if math.random(1, 500) <= chance*10 then  
      doSendMagicEffect(getThingPos(cid), 18)               
      local name, pos = "Mega ".. getCreatureName(cid), getThingPos(cid)
      doRemoveCreature(cid)
      local shi = doCreateMonster(name, pos, false)
      setPlayerStorageValue(shi, 74469, 1)      
   else
       setPlayerStorageValue(cid, 74469, 1)
   end                                        --/\
else                                                            
return true
end
end
                                                                
function onSpawn(cid)

    registerCreatureEvent(cid, "Experience")
	registerCreatureEvent(cid, "GeneralConfiguration")
	registerCreatureEvent(cid, "DirectionSystem")
	registerCreatureEvent(cid, "CastSystem")
	
	if isSummon(cid) then
		registerCreatureEvent(cid, "SummonDeath")
	return true
	end
	
	addEvent(doMega, 10, cid)
	addEvent(MegaName, 15, cid)
	addEvent(adjustWildPoke, 5, cid)

return true
end

Galera estou querendo que o mega spawna aleatório. tentei adaptar o spaw.lua e deixei assim porem não esta spawnando. alguem poderia me falar se é erro no codigo,

pois não for, ele não deve estar para spawnar 

Mas a chance está baixa, talvez não tenha nascido porque a chance está pouca. Aumenta para 100 para testar e me fala se ainda não nasce.

marmita2

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/02/19Posts: 30

Não deu

Yan Oliveira

Yan18
avatar
Moderador
Moderador

INFOS

Grupo: ModeradorRegistrado: 05/06/12Posts: 2221Gênero: Masculino
5 horas atrás, marmita2 disse:

Não deu

Você não testou certo, pois eu testei aqui com o seu próprio script sem alterar nada e deu certo, confira:

image.thumb.png.08f7aca99c34032d8f70baa832c53e05.png

 

Pode ver que sumonei 1 Gengar e já nasceu como Mega, você não alterou a chance certo.

 

Substitua seu script do spawn.lua por esse:

 

local shinys = {""}

local raros = {"Lucario", "Gyarados", "Gengar", "Blaziken", "Blastoise", "Beedrill", "Alakazam", "Charizard"}                               

local function MegaName(cid)
if isCreature(cid) then
   if string.find(tostring(getCreatureName(cid)), "Mega") then
      local newName = tostring(getCreatureName(cid)):match("Mega (.*)")             
      doCreatureSetNick(cid, newName)
      if isMonster(cid) then
         doSetCreatureDropLoot(cid, true)  
      end
   end
end
end

local function doSetRandomGender(cid)
	if not isCreature(cid) then return true end
	if isSummon(cid) then return true end
	local gender = 0
	local name = getCreatureName(cid)
	if not newpokedex[name] then return true end
	local rate = newpokedex[name].gender
		if rate == 0 then
			gender = 3
		elseif rate == 500 then
			gender = 4
		elseif rate == -1 then
			gender = 0
		elseif math.random(1, 500) <= rate then
			gender = 4
		else
			gender = 3
		end
	doCreatureSetSkullType(cid, gender)
end

local function doMega(cid)
if isCreature(cid) then
   if isSummon(cid) then return true end
   if getPlayerStorageValue(cid, 74469) >= 1 then return true end
   if getPlayerStorageValue(cid, 22546) >= 1 then return true end 
   if isNpcSummon(cid) then return true end
   if getPlayerStorageValue(cid, 637500) >= 1 then return true end  --alterado v1.9
   
if isInArray(megas, getCreatureName(cid)) then  --alterado v1.9 \/
   chance = 1000    --1% chance        
elseif isInArray(raros, getCreatureName(cid)) then   --n coloquem valores menores que 0.1 !!
   chance = 1000   --1% chance       
else
   return true
end    
    if math.random(1, 500) <= chance*10 then  
      doSendMagicEffect(getThingPos(cid), 18)               
      local name, pos = "Mega ".. getCreatureName(cid), getThingPos(cid)
      doRemoveCreature(cid)
      local shi = doCreateMonster(name, pos, false)
      setPlayerStorageValue(shi, 74469, 1)      
   else
       setPlayerStorageValue(cid, 74469, 1)
   end                                        --/\
else                                                            
return true
end
end
                                                                
function onSpawn(cid)

    registerCreatureEvent(cid, "Experience")
	registerCreatureEvent(cid, "GeneralConfiguration")
	registerCreatureEvent(cid, "DirectionSystem")
	registerCreatureEvent(cid, "CastSystem")
	
	if isSummon(cid) then
		registerCreatureEvent(cid, "SummonDeath")
	return true
	end
	
	addEvent(doMega, 10, cid)
	addEvent(MegaName, 15, cid)
	addEvent(adjustWildPoke, 5, cid)

return true
end

E teste, verá que vai funcionar.

marmita2

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 24/02/19Posts: 30

eu alterei certo mas acabei de achar aqui, a base que eu criei o cara tinha feito outro script em cima que tava bloqueando. o spawn de mega.

Yan Liima

Scripter,Programador,WebMaster.
avatar
Diretor
Diretor

INFOS

Grupo: DiretorRegistrado: 12/05/12Posts: 818Gênero: MasculinoChar no Tibia: [ADM] Night
A questão neste tópico de suporte foi respondida e/ou o autor do tópico resolveu o problema. Este tópico está fechado e foi movido para Suporte - Resolvidos. Se você tiver outras dúvidas, crie um novo tópico.

════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═══╗

ALGUNS DOS MEUS TRABALHOS:

Spoiler

WODBOHS[DOWNLOAD]

Newstory dbo+nto+bleach[DOWNLOAD]

 

>> Mais infos <<

- Projetos lançados também feitos por mim {

DBO SKY

POKE SKY

WODBOWARS

Tic-tac-War

Dbo Universe(em desenvolvimento)

}

universe.thumb.png.6840320998d0fc1a4652b3db81a585c0.png

Separador.PNG

Te Ajudei? Rep + e ficamos Quits

imageproxy.png.84dce08dd18d31663a72aa1ce37b858a.png

Precisando de ajuda?

discord.png.1ecd188791d0141f74d99db371a2e0a4.pngDiscord: Yan Liima #3702

Programador Júnior de LUA, PHP e JavaScript

Juntos somos lendas, separados somos Mitos!

╚══════════════════════════ҳ̸Ҳ̸ҳஜ۩۞۩ஜҳ̸Ҳ̸ҳ═════════════════════════════╝