# Script for Disguise

Pokémon Essentials Version
With a bit of trial and error, I've managed to put together a working script for Mimikyu's Disguise ability.

There have been a few threads about this topic over on the pokecommunity forums, and I posted a partial solution to this question here. However, there were some shortcomings with that script, mainly that Disguise was reset every time the Mimikyu switched out of battle, unlike in SM where it only works once per battle. My new script fixes that so that Disguise works a bit more like Mega Evolution - as a form change that lasts for the duration of battle and resets on end of battle, fainting, or capture. If you previously applied the steps from that linked thread, you'll want to undo them before trying this one, as this new approach uses an entirely different mechanic that is not compatible with the previous fix.

To pull off this ability, a number of crucial scripts have to be tweaked, so this is unfortunately not a plug & play script, but I will try to spell out the steps as clearly as possible:

#1 Check and Change the Pokemon's Form
When creating this script myself, I put this in the Pokemon_MegaEvolution script section around line 97 (right after the code for makeUnprimal) because it is modeled after the mega evo scripts. However, the key is that it is part of the PokeBattle_Pokemon class (which Pokemon_MegaEvolution extends), so it could go in the script section of that title as well.
The scripts to include are:

Code:
def makeBusted
f = self.getBustedForm
self.form = f
end

def isBusted?
bf = self.getBustedForm
if bf==self.form
return true
else
return false
end
end

def makeDisguised
df = self.getDisguiseForm
self.form = df if df>=0
end

def getDisguiseForm
return -1 if !isBusted?
disguiseform = self.form-1
return disguiseform   # form number
end

def hasBustedForm?
bf = self.getBustedForm
return bf>0 && bf!=self.form
end

def getBustedForm
if isConst?(self.species,PBSpecies,:MIMIKYU) && self.hasAbility?(:DISGUISE)
return 1
else
return-1
end
end
#2 Check and Change the Pokemon in Battle
These scripts will all affect the script section PokeBattle_Battler. First, around line 85, right after the methods hasMega? and isMega? Add the following:

Ruby:
#Mimikyu - Disguise
def hasBusted?
return false if @effects[PBEffects::Transform]
if @pokemon
return (@pokemon.hasBustedForm? rescue false)
end
return false
end

def isBusted?
if @pokemon
return (@pokemon.isBusted? rescue false)
end
return false
end

def pbBust
@battle.pbDisplay(_INTL("{1}'s disguise was busted!",pbThis))
@pokemon.makeBusted
if self.form!=@pokemon.form
self.form=@pokemon.form
end
self.pbUpdate(true)
@battle.scene.pbChangePokemon(self,@pokemon)
end
#3 Revert to Base Form
These are the scripts that make sure Mimikyu's disguise resets after battle. For the first, stay in PokeBattle_Battler. Look for the script for pbFaint and around line 790, right after the line @pokimon.makeUnprimal, add

Ruby:
@pokemon.makeDisguised if self.isBusted?

Next in the script section PokeBattle_Battle, you'll edit the script for pbThrowPokeBall. Around line 144, insert the line in red to revert a Mimikyu to its base form on capture:

Ruby:
BallHandlers.onCatch(ball,self,pokemon)
pokemon.ballused=pbGetBallType(ball)
((pokemon.makeUnmega if pokemon.isMega?) rescue nil)
[COLOR="Red"]((pokemon.makeDisguised if pokemon.isBusted?) rescue nil)[/COLOR]
pokemon.makeUnprimal rescue nil
pokemon.pbRecordFirstMoves

Then, in the script section Pfield_Battles, edit the script for pbAfterBattle. Around line 387, insert the code in red:

Ruby:
def pbAfterBattle(decision,canlose)
for i in $Trainer.party (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil); [COLOR="red"](i.makeDisguised rescue nil)[/COLOR] end if$PokemonGlobal.partner
pbHealAll
for i in \$PokemonGlobal.partner[3]
i.heal
(i.makeUnmega rescue nil); (i.makeUnprimal rescue nil); [COLOR="red"](i.makeDisguised rescue nil)[/COLOR]
#4 Break Disguise
Last but not least, we need to add the script that prevents damage when Mimikyu is disguised and then breaks that disguise. In PokeBattle_Move, find the script for pbReduceHPDamage. Around line 1165, after the code for substitute, insert the lines in red.
Ruby:
opponent.damagestate.substitute=false
[COLOR="red"]if opponent.hasWorkingAbility(:DISGUISE) && isConst?(opponent.species,PBSpecies,:MIMIKYU) && !attacker.hasMoldBreaker
if opponent.hasBusted? and !opponent.isBusted?
@battle.pbDisplay(_INTL("Its disguise served it as a decoy!"))
@battle.scene.pbDamageAnimation(opponent,0)
opponent.pbBust
damage=0
end
end[/COLOR]
if damage>=opponent.hp
Conclusion
With all that finished, you should now have functioning code for the Disguise ability. Enjoy and use responsibly!
And of course, credit is appreciated if you use it.
Credits
Poq
Author
Poq
Views
171
First release
Last update
Rating
1 ratings