• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Custom Feature Question] Script for Diguise

10
Posts
7
Years
  • I'm not very good with creating scripts and I have been trying to implement disguise into my game. If anyone has created the script and could give me a hand with implementing it, it would be much appreciated. Thanks!
     
    971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    I'm not very good with creating scripts and I have been trying to implement disguise into my game. If anyone has created the script and could give me a hand with implementing it, it would be much appreciated. Thanks!

    Do you still want the animation of the move to play and the damaging effect but just have it do 0 damage, (as in the original game) or do you want it to fail right away? If the latter, you can add it to "def pbSuccessCheck"
     
    10
    Posts
    7
    Years
  • Do you still want the animation of the move to play and the damaging effect but just have it do 0 damage, (as in the original game) or do you want it to fail right away? If the latter, you can add it to "def pbSuccessCheck"
    If you know how to do it the first way, I would prefer it
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    Create a PBEffect called Disguise in PBEffects and initialise it in PokeBattle_Battler, def pbInitEffects:
    Code:
        [COLOR=Red]@effects[PBEffects::Disguise] = false
    [/COLOR][COLOR=Red][COLOR=Red][COLOR=Green]    # Disguise causes the ability-suppressing effect to fade[/COLOR][/COLOR][COLOR=Green]
        # if it was passed on through Baton Pass[/COLOR]
        if isConst?(self.ability,PBAbilities,:DISGUISE)
          @effects[PBEffects::GastroAcid] = false
        end
        [COLOR=Black]if isConst?(self.ability,PBAbilities,:ILLUSION) #Illusion
          [email protected](@index)
          party=party.find_all {|item| item && !item.egg? && item.hp>0 }
          if party[party.length-1] != @pokemon
            @effects[PBEffects::Illusion] = party[party.length-1]
          else
            @effects[PBEffects::Illusion]      = nil
          end
        else
          @effects[PBEffects::Illusion]        = nil
        end [COLOR=Green]#Illusion[/COLOR]
    [/COLOR][/COLOR]

    In PokeBattle_Battler, def pbCheckForm:
    Code:
        [COLOR=Green]# Mimikyu[/COLOR]
        [COLOR=Red]if self.hasWorkingAbility(:DISGUISE) &&
           isConst?(self.species,PBSpecies,:MIMIKYU) &&
           !self.isFainted?
          if self.form!=1
            self.form=1
            self.type1=getID(PBTypes,:GHOST)
            self.type2=getID(PBTypes,:FAIRY)
          end
        end[/COLOR]

    in PokeBattle_Battler, def pbAbilitiesOnSwitchIn:
    Code:
        if onactive
         [COLOR=Green] # weather ability scripts[/COLOR]
          [COLOR=Red]if self.hasWorkingAbility(:DISGUISE) && onactive
            @effects[PBEffects::Disguise]=true
          end
    [COLOR=Black]
    [/COLOR]
    [/COLOR]
    In PokeBattle_Move, def pbReduceHPDamage insert this code:
    Code:
        if opponent.effects[PBEffects::Substitute]>0 && (!attacker || attacker.index!=opponent.index) &&
          !attacker.hasWorkingAbility(:INFILTRATOR) && !isSoundBased?
          PBDebug.log("[#{opponent.pbThis}'s substitute took the damage]")
          damage=opponent.effects[PBEffects::Substitute] if damage>opponent.effects[PBEffects::Substitute]
          opponent.effects[PBEffects::Substitute]-=damage
          opponent.damagestate.substitute=true
          @battle.scene.pbDamageAnimation(opponent,0)
          @battle.pbDisplayPaused(_INTL("The substitute took damage for {1}!",opponent.name))
          if opponent.effects[PBEffects::Substitute]<=0
            opponent.effects[PBEffects::Substitute]=0
            @battle.pbDisplayPaused(_INTL("{1}'s substitute faded!",opponent.name))
            PBDebug.log("[#{opponent.pbThis}'s substitute faded]")
          end
          opponent.damagestate.hplost=damage
          damage=0
        else
          opponent.damagestate.substitute=false
          [COLOR=Red]if opponent.effects[PBEffects::Disguise] && !attacker.hasBypassingAbility()
            @battle.pbDisplayEffect(opponent)
            @battle.pbDisplay(_INTL("Its disguise served it as a decoy!"))
            opponent.effects[PBEffects::Disguise]=false
            opponent.form=1
            opponent.pbCheckForm
            @battle.pbDisplay(_INTL("{1}'s disguise was busted!"))
            damage=0
          end[/COLOR]

    Moves that swap, copy, change or suppress abilities will fail and abilities that copy other abilities will not trigger if Disguise is the targeted ability. Mummy will only change Mimikyu's ability if its Disguise is busted.
     
    5
    Posts
    6
    Years
    • Seen Oct 25, 2017
    Hello, I'm having trouble with Mimikyu changing its sprite to 778_1
    The ability works just fine but it ain't changing to busted form.
    I've done everything I could and I don't really know what else to do. I've done exactly the same thing described here.
    Is there any help you could give me? Thanks in advance.
     
    1
    Posts
    8
    Years
    • Seen Oct 2, 2017
    hi, i keep getting errors in "PokeBattle_Battler" and i don't understand what i'm doing wrong can i have some help? i think what i'm doing wrong is the first text about "pbInitEffects" but i can't seem to figure out why.
     
    26
    Posts
    5
    Years
    • Seen Oct 17, 2023
    ---------------------------
    Pokemon Topaz
    ---------------------------
    Exception: NoMethodError

    Message: undefined method `hasBypassingAbility' for #<PokeBattle_Battler:0xaa73258>

    PokeBattle_Move:1166:in `pbReduceHPDamage'

    PokeBattle_Move:1281:in `pbEffect'

    PokeBattle_MoveEffects:6569:in `pbEffect'

    PokeBattle_Battler:2797:in `pbProcessMoveAgainstTarget_ebs'

    PokeBattle_Battler:2753:in `each'

    PokeBattle_Battler:2753:in `pbProcessMoveAgainstTarget_ebs'

    EliteBattle_0:475:in `pbProcessMoveAgainstTarget'

    PokeBattle_Battler:3229:in `pbUseMove_ebs'

    PokeBattle_Battler:3209:in `loop'

    PokeBattle_Battler:3232:in `pbUseMove_ebs'



    This exception was logged in

    C:\Users\Peggy\Saved Games/Pokemon Topaz/errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------


    My Mimikyu just got hit with an attack and this happened, if anyone is still here could you help me out? I did everything that @James Davy said.
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    For people who find this thread in the future, the code as-written does not work with Essentials v17.2. Which isn't a massive surprise because it's been a while.

    However there are many threads that talk about this problem, so maybe you can find some help from there. #1, #2,

    It appears James Davy hasn't been online for a while. As per one of those other threads, you can use hasMoldBreaker instead, but your sprite won't change to busted form in-battle. Legend has it that NewAgeSteel has a working implementation but doesn't remember exactly the changes he made. Try to get in contact with him, and then if you work it out for the love of God post the solution here for the future. (If you're reading this in 2019 and there's no solution it's safe to assume that NewAgeSteel and PyroGazeZX didn't find one).
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    Edit: DISCLAIMER
    This is no longer my recommended solution. Check this thread for a better version which is more faithful to the official games. The version below still functions, but it resets anytime Mimikyu switches out of battle.

    Here's the version of this script I have assembled for v17.2, which is working alright.

    As in the original suggestion, I added a new effect called "Disguise", right below Yawn

    Next, in the PokeBattle_Battler script section, I added Disguise to the pbInitEffects:
    Code:
        @effects[PBEffects::HyperBeam]        = 0
        [COLOR="Red"]@effects[PBEffects::Disguise]         = false
        if isConst?(self.ability,PBAbilities,:DISGUISE)
          @effects[PBEffects::GastroAcid]     = false
        end[/COLOR]
        @effects[PBEffects::Illusion]         = nil

    and Mimikyu to pbCheckForm script:
    Code:
    # Mimikyu
        if self.hasWorkingAbility(:DISGUISE) &&
          isConst?(self.species,PBSpecies,:MIMIKYU) && !self.isFainted?
          if self.form==1
            self.type1=getID(PBTypes,:GHOST)
            self.type2=getID(PBTypes,:FAIRY)
            transformed=true
          end
          if transformed
            pbUpdate(true)
            @battle.scene.pbChangePokemon(self,@pokemon)
          end
        end

    and to the bottom of the pbAbilitiesOnSwitchIn script below that:
    Code:
    # Mimikyu
        if self.hasWorkingAbility(:DISGUISE) && onactive && self.form==0
            @effects[PBEffects::Disguise]=true
        end

    Finally, in the PokeBattle_Move script section, I added disguise to pbReduceHPDamage:
    Code:
        else
          opponent.damagestate.substitute=false
          [COLOR="red"]if opponent.effects[PBEffects::Disguise] && !attacker.hasMoldBreaker
            @battle.scene.pbDamageAnimation(opponent,0)
            @battle.pbDisplay(_INTL("Its disguise served it as a decoy!"))
            opponent.effects[PBEffects::Disguise]=false
            opponent.form=1
            opponent.pbCheckForm
            @battle.pbDisplay(_INTL("#{opponent.pbThis}'s disguise was busted!"))
            damage=0
          end[/COLOR]
          if damage>=opponent.hp

    All of this is pretty close to the original solution, just with some tweaks to get it to work more smoothly.
    The only problem with it currently is that if Mimikyu is switched out and switched back in, Disguise resets. I haven't yet figured out a way to maintain its Busted form.
     
    Last edited:
    172
    Posts
    7
    Years
    • Seen Sep 6, 2022
    Yeah, I just checked mine and I didn't realize it at the time but mine does the same thing. when I switch the pokemon out its decoy comes back. Although I don't so much mind that being the way disguise works in my game haha.
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    Although I don't so much mind that being the way disguise works in my game haha.
    Yeah, I have some ideas on how I might approach fixing it, but I think I'm okay with giving Mimikyu that buff in my game too, so I'll probably leave it.
     
    172
    Posts
    7
    Years
    • Seen Sep 6, 2022
    Yeah, I have some ideas on how I might approach fixing it, but I think I'm okay with giving Mimikyu that buff in my game too, so I'll probably leave it.
    yeah because when you think about it the only way to exploit it in a battle is by continuing to switch it out, which just damages your other pokemon, so while it may give mimikyu a buff, exploiting it just hurts everything else. so it seems decently balanced to me.
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Here's the version of this script I have assembled for v17.2, which is working alright.

    As in the original suggestion, I added a new effect called "Disguise", right below Yawn

    Next, in the PokeBattle_Battler script section, I added Disguise to the pbInitEffects:
    Code:
        @effects[PBEffects::HyperBeam]        = 0
        [COLOR="Red"]@effects[PBEffects::Disguise]         = false
        if isConst?(self.ability,PBAbilities,:DISGUISE)
          @effects[PBEffects::GastroAcid]     = false
        end[/COLOR]
        @effects[PBEffects::Illusion]         = nil

    and Mimikyu to pbCheckForm script:
    Code:
    # Mimikyu
        if self.hasWorkingAbility(:DISGUISE) &&
          isConst?(self.species,PBSpecies,:MIMIKYU) && !self.isFainted?
          if self.form==1
            self.type1=getID(PBTypes,:GHOST)
            self.type2=getID(PBTypes,:FAIRY)
            transformed=true
          end
          if transformed
            pbUpdate(true)
            @battle.scene.pbChangePokemon(self,@pokemon)
          end
        end

    and to the bottom of the pbAbilitiesOnSwitchIn script below that:
    Code:
    # Mimikyu
        if self.hasWorkingAbility(:DISGUISE) && onactive && self.form==0
            @effects[PBEffects::Disguise]=true
        end

    Finally, in the PokeBattle_Move script section, I added disguise to pbReduceHPDamage:
    Code:
        else
          opponent.damagestate.substitute=false
          [COLOR="red"]if opponent.effects[PBEffects::Disguise] && !attacker.hasMoldBreaker
            @battle.scene.pbDamageAnimation(opponent,0)
            @battle.pbDisplay(_INTL("Its disguise served it as a decoy!"))
            opponent.effects[PBEffects::Disguise]=false
            opponent.form=1
            opponent.pbCheckForm
            @battle.pbDisplay(_INTL("#{opponent.pbThis}'s disguise was busted!"))
            damage=0
          end[/COLOR]
          if damage>=opponent.hp

    All of this is pretty close to the original solution, just with some tweaks to get it to work more smoothly.
    The only problem with it currently is that if Mimikyu is switched out and switched back in, Disguise resets. I haven't yet figured out a way to maintain its Busted form.

    Let's analyze that with the Greninja (Battle Bond) and Zygarde (100% with Power Construct) the same thing happens: when it changes of pokemon, it returns the original form.
    I noticed the mega evolutions (until the "Primal Reversion"). They have this in common:
    Code:
      def getUnmegaForm
        return -1 if !isMega?
        dexdata = pbOpenDexData
        pbDexDataOffset(dexdata,self.fSpecies,37)
        unmegaform = dexdata.fgetb
        dexdata.close
        return unmegaform   # form number
      end
    
      def hasMegaForm?
        mf = self.getMegaForm
        return mf>0 && mf!=self.species
      end
    
      def isMega?
        mf = self.getMegaForm
        return mf!=self.species && mf==self.fSpecies
      end
    
      def makeMega
        fsp = self.getMegaForm
        if fsp>0
          f = pbGetSpeciesFromFSpecies(fsp)[1]
          self.form = f
        end
      end
    
      def makeUnmega
        newf = self.getUnmegaForm
        self.form = newf if newf>=0
      end
    
      def megaName
        formname = pbGetMessage(MessageTypes::FormNames,self.fSpecies)
        return (formname && formname!="") ? formname : _INTL("Mega {1}",PBSpecies.getName(@species))
      end
    
      def megaMessage
        dexdata = pbOpenDexData
        pbDexDataOffset(dexdata,self.getMegaForm,58)
        message = dexdata.fgetb
        dexdata.close
        return message   # 0=default message, 1=Rayquaza message
      end
    
    
    
    
    
      def hasPrimalForm?
        v=MultipleForms.call("getPrimalForm",self)
        return v!=nil
      end
    
      def isPrimal?
        v=MultipleForms.call("getPrimalForm",self)
        return v!=nil && v==@form
      end
    
      def makePrimal
        v=MultipleForms.call("getPrimalForm",self)
        self.form=v if v!=nil
      end
    
      def makeUnprimal
        v=MultipleForms.call("getUnprimalForm",self)
        if v!=nil; self.form=v
        elsif isPrimal?; self.form=0
        end
      end
    end
    So, maybe if we create a 'makeUnForm' or something to them (Mimikyu, Zygarde, Greninja etc), it will works....
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    So, maybe if we create a 'makeUnForm' or something to them (Mimikyu, Zygarde, Greninja etc), it will works....
    Yeah, that's sort of what I had in mind to try. At this point, I still don't have a thorough understanding of all the code involved in mega evolution, but there are some key differences in what triggers it compared to disguise (and power construct and battle bond) that prevent it from being a simple task of replicating their structure. It's still a good place to look though.
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    I have found a new solution to this question that fixes the shortcomings from my script in this thread. I've posted it as a new thread in the Scripts, Tutorials, and Tools thread here. Check it out!
     
    Back
    Top