How to add second shiny form?

Obermarschall

Novice
Member
Joined
Jan 27, 2018
Posts
21
I'd like to add albino and melanite Pokémon, just like they exist in PokéFarm. They should not behave like a new form, but like a shiny Pokémon, with much lower odds of encountering them. Is it possible to do so? I hear in version 17 it isnt but 16.2 it is? How can I do it in 16.2?
 

Lord X-Giga-X

Sardonyx's Reaper
Member
Joined
Jun 28, 2017
Posts
46
As someone who did basically this for Sardonyx, I can assure you that this is possible in v16.2. It just takes a lot of looking into how Essentials processes Shiny Pokémon. Basically if you search through the script editor and look at how shiny Pokémon function, you're basically copying and editing their coding for this purpose. There are just a few things you need to keep in mind:

If you're doing this, one of the things you should set up first is set up a flag for it. Start by going into the PokeBattle_Pokemon section. One of the first things you should be seeing is a list of attr_accessor(:[inserttexthere]). Somewhere within this, add something along the lines of attr_accessor(:albinoflag).
Go down a bit and you'll see a section for shininess. For the most part, you're just going to be copying and pasting this and replacing all instance of shiny with albino. The major change here will be under def isAlbino? How this will be altered will depend on one major question: whether or not you want a Pokémon to be both shiny and albino at the same time. If not, then go down to return (d>SHINYPOKEMONCHANCE) and change it to something like return (d>numberhere). In this case, it's best for your number to be separate from the shiny chance. The general idea is to keep the range from your number to 65535 smaller than the shiny chance to ensure that it's less common to run into an albino Pokémon than a shiny. The actual value of the shiny chance is present in the Settings section.
However, if you're going for a Pokémon being able to be both shiny and albino, then def isAlbino? should be as simple as:
Code:
def isAlbino?
  return @albinoflag
end
Then you're going to want to scroll down until you see the section for initializing a new Pokémon object. Among the list of objects, you're gonna want to add something along the lines of the following:
Code:
@albinoflag=false
r=rand(65536)
@albinoflag=true if r
The number should be less than the shiny chance. This ensures a separate method of making a Pokémon albino, which will also allow for it to potentially be shiny as well.

The other key thing is of course being able to load the graphics for albino Pokémon. To that end, you're gonna want to go into the PSystem_Utilities section and scroll down to about line 1067 for the section for that. It is mainly adding into the script to account for albino Pokémon, but I'll go into it.. First scroll down to find this:
Code:
bitmapFileName=pbCheckPokemonBitmapFiles([species,back,
(pokemon.isFemale?),
pokemon.isShiny?,
(pokemon.form rescue 0),
(pokemon.isShadow? rescue false)])
Edit that to this:
Code:
bitmapFileName=pbCheckPokemonBitmapFiles([species,back,
(pokemon.isFemale?),
pokemon.isShiny?,
(pokemon.form rescue 0),
(pokemon.isShadow? rescue false),
(pokemon.isAlbino? rescue false)])
Go down a bit further to the line that reads:
Code:
def pbLoadSpeciesBitmap(species,female=false,form=0,shiny=false,shadow=false,back=false,egg=false)
Change that to this:
Code:
def pbLoadSpeciesBitmap(species,female=false,form=0,shiny=false,shadow=false,back=false,egg=false,albino=false)
Find the line that reads:
Code:
bitmapFileName=pbCheckPokemonBitmapFiles([species,back,female,shiny,form,shadow])
Make that:
Code:
bitmapFileName=pbCheckPokemonBitmapFiles([species,back,female,shiny,form,shadow,albino])
This next part requires a lot of line adding, so to save you a bit of trouble, just replace this:
Code:
def pbCheckPokemonBitmapFiles(params)
  species=params[0]
  back=params[1]
  factors=[]
  factors.push([5,params[5],false]) if params[5] && params[5]!=false	 # shadow
  factors.push([2,params[2],false]) if params[2] && params[2]!=false	 # gender
  factors.push([3,params[3],false]) if params[3] && params[3]!=false	 # shiny
  factors.push([4,params[4].to_s,""]) if params[4] && params[4].to_s!="" &&
													  params[4].to_s!="0" # form
  tshadow=false
  tgender=false
  tshiny=false
  tform=""
  for i in 0...2**factors.length
	for j in 0...factors.length
	  case factors[j][0]
	  when 2   # gender
		tgender=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  when 3   # shiny
		tshiny=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  when 4   # form
		tform=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  when 5   # shadow
		tshadow=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  end
	end
	bitmapFileName=sprintf("Graphics/Battlers/%s%s%s%s%s%s",
	   getConstantName(PBSpecies,species),
	   tgender ? "f" : "",
	   tshiny ? "s" : "",
	   back ? "b" : "",
	   (tform!="" ? "_"+tform : ""),
	   tshadow ? "_shadow" : "") rescue nil
	ret=pbResolveBitmap(bitmapFileName)
	return ret if ret
	bitmapFileName=sprintf("Graphics/Battlers/%03d%s%s%s%s%s",
	   species,
	   tgender ? "f" : "",
	   tshiny ? "s" : "",
	   back ? "b" : "",
	   (tform!="" ? "_"+tform : ""),
	   tshadow ? "_shadow" : "")
	ret=pbResolveBitmap(bitmapFileName)
	return ret if ret
  end
  return nil
end
 
def pbLoadPokemonIcon(pokemon)
  return AnimatedBitmap.new(pbPokemonIconFile(pokemon)).deanimate
end
 
def pbPokemonIconFile(pokemon)
  bitmapFileName=nil
  bitmapFileName=pbCheckPokemonIconFiles([pokemon.species,
										  (pokemon.isFemale?),
										  pokemon.isShiny?,
										  (pokemon.form rescue 0),
										  (pokemon.isShadow? rescue false)],
										  pokemon.isEgg?)
  return bitmapFileName
end
 
def pbCheckPokemonIconFiles(params,egg=false)
  species=params[0]
  if egg
	bitmapFileName=sprintf("Graphics/Icons/icon%segg",getConstantName(PBSpecies,species)) rescue nil
	if !pbResolveBitmap(bitmapFileName)
	  bitmapFileName=sprintf("Graphics/Icons/icon%03degg",species) 
	  if !pbResolveBitmap(bitmapFileName)
		bitmapFileName=sprintf("Graphics/Icons/iconEgg")
	  end
	end
	return pbResolveBitmap(bitmapFileName)
  else
	factors=[]
	factors.push([4,params[4],false]) if params[4] && params[4]!=false	 # shadow
	factors.push([1,params[1],false]) if params[1] && params[1]!=false	 # gender
	factors.push([2,params[2],false]) if params[2] && params[2]!=false	 # shiny
	factors.push([3,params[3].to_s,""]) if params[3] && params[3].to_s!="" &&
														params[3].to_s!="0" # form
	tshadow=false
	tgender=false
	tshiny=false
	tform=""
	for i in 0...2**factors.length
	  for j in 0...factors.length
		case factors[j][0]
		when 1   # gender
		  tgender=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		when 2   # shiny
		  tshiny=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		when 3   # form
		  tform=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		when 4   # shadow
		  tshadow=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		end
	  end
	  bitmapFileName=sprintf("Graphics/Icons/icon%s%s%s%s%s",
		 getConstantName(PBSpecies,species),
		 tgender ? "f" : "",
		 tshiny ? "s" : "",
		 (tform!="" ? "_"+tform : ""),
		 tshadow ? "_shadow" : "") rescue nil
	  ret=pbResolveBitmap(bitmapFileName)
	  return ret if ret
	  bitmapFileName=sprintf("Graphics/Icons/icon%03d%s%s%s%s",
		 species,
		 tgender ? "f" : "",
		 tshiny ? "s" : "",
		 (tform!="" ? "_"+tform : ""),
		 tshadow ? "_shadow" : "")
	  ret=pbResolveBitmap(bitmapFileName)
	  return ret if ret
	end
  end
  return nil
end
With this:
Code:
def pbCheckPokemonBitmapFiles(params)
  species=params[0]
  back=params[1]
  factors=[]
  factors.push([5,params[5],false]) if params[5] && params[5]!=false	# shadow
  factors.push([2,params[2],false]) if params[2] && params[2]!=false	# gender
  factors.push([3,params[3],false]) if params[3] && params[3]!=false	# shiny
  factors.push([4,params[4].to_s,""]) if params[4] && params[4].to_s!="" &&
													  params[4].to_s!="0" # form
  factors.push([6,params[6],false]) if params[6] && params[6]!=false	# albino
  tshadow=false
  tgender=false
  tshiny=false
  talbino=false
  tform=""
  for i in 0...2**factors.length
	for j in 0...factors.length
	  case factors[j][0]
	  when 2  # gender
		tgender=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  when 3  # shiny
		tshiny=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  when 4  # form
		tform=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  when 5  # shadow
		tshadow=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  when 6  # albino
		talbino=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
	  end
	end
	bitmapFileName=sprintf("Graphics/Battlers/%s%s%s%s%s%s%s%s",
	  getConstantName(PBSpecies,species),
	  tgender ? "f" : "",
	  tshiny ? "s" : "",
	  talbino ? "a" : "",
	  back ? "b" : "",
	  (tform!="" ? "_"+tform : ""),
	  tshadow ? "_shadow" : "") rescue nil
	ret=pbResolveBitmap(bitmapFileName)
	return ret if ret
	bitmapFileName=sprintf("Graphics/Battlers/%s%03d%s%s%s%s%s%s",
	  folder, species,
	  tgender ? "f" : "",
	  tshiny ? "s" : "",
	  talbino ? "a" : "",
	  back ? "b" : "",
	  (tform!="" ? "_"+tform : ""),
	  tshadow ? "_shadow" : "")
	ret=pbResolveBitmap(bitmapFileName)
	return ret if ret
  end
  return nil
end
 
def pbPokemonIconFile(pokemon)
  bitmapFileName=nil
  bitmapFileName=pbCheckPokemonIconFiles([pokemon.species,
										  (pokemon.isFemale?),
										  pokemon.isShiny?,
										  (pokemon.form rescue 0),
										  (pokemon.isShadow? rescue false),
										  pokemon.isAlbino?],
										  pokemon.isEgg?)
  return bitmapFileName
end
 
def pbCheckPokemonIconFiles(params,egg=false)
  species=params[0]
  if egg
	bitmapFileName=sprintf("Graphics/Icons/icon%segg",getConstantName(PBSpecies,species)) rescue nil
	if !pbResolveBitmap(bitmapFileName)
	  bitmapFileName=sprintf("Graphics/Icons/icon%03degg",species)
	  if !pbResolveBitmap(bitmapFileName)
		bitmapFileName=sprintf("Graphics/Icons/iconEgg")
	  end
	end
	return pbResolveBitmap(bitmapFileName)
  else
	factors=[]
	factors.push([4,params[4],false]) if params[4] && params[4]!=false	# shadow
	factors.push([1,params[1],false]) if params[1] && params[1]!=false	# gender
	factors.push([2,params[2],false]) if params[2] && params[2]!=false	# shiny
	factors.push([5,params[5],false]) if params[5] && params[5]!=false	# albino
	factors.push([3,params[3].to_s,""]) if params[3] && params[3].to_s!="" &&
														params[3].to_s!="0" # form
	tshadow=false
	tgender=false
	tshiny=false
	talbino=false
	tform=""
	for i in 0...2**factors.length
	  for j in 0...factors.length
		case factors[j][0]
		when 1  # gender
		  tgender=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		when 2  # shiny
		  tshiny=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		when 3  # form
		  tform=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		when 4  # shadow
		  tshadow=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		when 5  # albino
		  talbino=((i/(2**j))%2==0) ? factors[j][1] : factors[j][2]
		end
	  end
	  bitmapFileName=sprintf("Graphics/Icons/icon%s%s%s%s%s%s",
		getConstantName(PBSpecies,species),
		tgender ? "f" : "",
		tshiny ? "s" : "",
		talbino ? "a" : "",
		(tform!="" ? "_"+tform : ""),
		tshadow ? "_shadow" : "") rescue nil
	  ret=pbResolveBitmap(bitmapFileName)
	  return ret if ret
	  bitmapFileName=sprintf("Graphics/Icons/icon%03d%s%s%s%s%s",
		species,
		tgender ? "f" : "",
		tshiny ? "s" : "",
		talbino ? "a" : "",
		(tform!="" ? "_"+tform : ""),
		tshadow ? "_shadow" : "")
	  ret=pbResolveBitmap(bitmapFileName)
	  return ret if ret
	end
  end
  return nil
end

It's a complicated process and yes, I did leave out a few things due to how it basically is just "copy lines of text, paste it, and edit for albino" or "add lines here for albino". In fact, there's basically so much to this that it may even be worth dedicating an entire section of script for this in order to leave the original sections of script unaltered. In which you should make sure to keep the lines in the first part contained within a class PokeBattle_Pokemon and end, like this:
Code:
class PokeBattle_Pokemon
  insertcodehere
end
I also feel like I could have explained this a bit better. In fact, I feel like there are other people that could explain this much better than I have. I just wanted to make sure the most important aspects of this are noted.
But my main point is that it's possible once you look at how shiny Pokémon and taking that and manipulating that in order to add albino. Or whatever you want your "second shiny" to be.

As for whether or not this is possible in v17, I'm not entirely sure on that since my codev and I use v16.2 for Sardonyx. Although my assumption is that it still could be possible despite differences in the scripts between the two versions of Essentials.
 

Obermarschall

Novice
Member
Joined
Jan 27, 2018
Posts
21
Thank you so much!

Don't worry you explained it very well and actually I tried copy-pasting it but without success.
Now the way you explained it I could add the albino version without that the game crashed.

The problem I have is that the additional forms (delta and alola) now don't work?
The types of my Pokémon are correct and all, but the sprites don't load for some reason?
Do you have an idea why that could be?
 

Lord X-Giga-X

Sardonyx's Reaper
Member
Joined
Jun 28, 2017
Posts
46
Hmm... That I'm not so sure. Although if you set this up as its own script, you're using also using the Delta script and it's only affecting delta forms, then what's likely happening is that it's overriding the alterations to that the Delta script is attempting to override the default script with, which would load the graphics for albino Pokémon but not any delta forms specified in that script. In which case it might actually be worth attempting to integrate the code for loading albino Pokémon into that script.

That's my best guess anyway. And really, it does depend on exactly how things have been set up and if the delta forms are the only forms affected.

... And to be honest, I'm looking at my post and noticing how some lines of code are formatted further to the right than I had intended. Not sure if that has any effect. My first guess says probably not, but idk... If anything, it just looks really weird to me...
 
Top