The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Illusion

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Reply
 
Thread Tools
  #1    
Old December 8th, 2014 (10:22 AM).
trueegee trueegee is offline
     
    Join Date: Dec 2014
    Gender: Male
    Posts: 8
    I haven't tested it 100%, but I know it works in singles (haven't had the time to test it for double battles, but it should theoretically work, but you know how it is with code :) )
    Anyway, here it is:
    Spoiler:
    In PBEffects, before
    Code:
    # These effects apply to a side
    add (change 91 to whatever the next effect number is avaliable)
    Code:
    Illusion          = 91 #Illusion
    In PokeBattle_Battler:
    in def pbInitEffects(batonpass) after
    Code:
        @effects[PBEffects::Yawn]             = 0
    add
    Code:
        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]
          end
        end #Illusion
    replace
    Code:
      def pbThis(lowercase=false)
        if @battle.pbIsOpposing?(@index)
          if @battle.opponent
            return lowercase ? _INTL("the foe {1}",@name) : _INTL("The foe {1}",@name)
          else
            return lowercase ? _INTL("the wild {1}",@name) : _INTL("The wild {1}",@name)
          end
        elsif @battle.pbOwnedByPlayer?(@index)
          return _INTL("{1}",self.name)
        else
          return lowercase ? _INTL("the ally {1}",@name) : _INTL("The ally {1}",@name)
        end
      end
    with
    Code:
      def pbThis(lowercase=false)
        if @battle.pbIsOpposing?(@index)
          if @battle.opponent
            return lowercase ? _INTL("the foe {1}",self.name) : _INTL("The foe {1}",self.name)
          else
            return lowercase ? _INTL("the wild {1}",self.name) : _INTL("The wild {1}",self.name)
          end
        elsif @battle.pbOwnedByPlayer?(@index)
          return _INTL("{1}",self.name)
        else
          return lowercase ? _INTL("the ally {1}",self.name) : _INTL("The ally {1}",self.name)
        end
      end
    
      def name #Illusion
        return @effects[PBEffects::Illusion] != nil  ? @effects[PBEffects::Illusion].name : @name
      end #Illusion
    after
    Code:
            # Illusion goes here
    put
    Code:
            if isConst?(target.ability,PBAbilities,:ILLUSION) #ILLUSION
              if target.effects[PBEffects::Illusion]!=nil
                # Break the illusion
                # Animation should go here
                target.effects[PBEffects::Illusion]=nil
                @battle.scene.pbChangePokemon(target,target.pokemon)
                @battle.pbDisplay(_INTL("{1}'s {2} was broken!",target.pbThis,
                    PBAbilities.getName(target.ability)))
              end
            end #ILLUSION
    In PokeBattle_ActualScene
    in class PokemonDataBox < SpriteWrapper in def refresh
    after
    add
    Code:
        [email protected] #ILLUSION
        if @battler.effects[PBEffects::Illusion] != nil #ILLUSION
          [email protected][PBEffects::Illusion].gender #ILLUSION
        end #ILLUSION
    in class PokeballSendOutAnimation in def initialize
    replace
    Code:
       def initialize(sprite,spritehash,pkmn,doublebattle)
    with
    Code:
       def initialize(sprite,spritehash,pkmn,doublebattle,illusionpoke)
    replace
    Code:
        @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
    with
    Code:
        @illusionpoke = illusionpoke #ILLUSION
        if illusionpoke != nil #ILLUSION
          @endspritey=adjustBattleSpriteY(sprite,illusionpoke.species,pkmn.index)
        else
          @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
        end #ILLUSION
    replace
    Code:
        @shadowVisible=showShadow?(pkmn.species)
    with
    Code:
        if illusionpoke != nil #ILLUSION
          @shadowVisible=showShadow?(illusionpoke.species)
        else
          @shadowVisible=showShadow?(pkmn.species)
        end #ILLUSION
    in def update
    replace
    Code:
    pbPlayCry(@pkmn.pokemon ? @pkmn.pokemon : @pkmn.species)
    with
    Code:
          if @illusionpoke != nil #ILLUSION
            pbPlayCry(@illusionpoke)
          else
            pbPlayCry(@pkmn.pokemon ? @pkmn.pokemon : @pkmn.species)
          end #ILLUSION
    in class PokeballPlayerSendOutAnimation in def initialize
    replace
    Code:
      def initialize(sprite,spritehash,pkmn,doublebattle)
    with
    Code:
      def initialize(sprite,spritehash,pkmn,doublebattle,illusionpoke)
    replace
    Code:
        @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
    with
    Code:
        @illusionpoke = illusionpoke #ILLUSION
        if illusionpoke != nil #ILLUSION
          @endspritey=adjustBattleSpriteY(sprite,illusionpoke.species,pkmn.index)
        else
          @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
        end #ILLUSION
    in def update
    replace
    Code:
          pbPlayCry(@pkmn.pokemon ? @pkmn.pokemon : @pkmn.species)
    with
    Code:
          if @illusionpoke != nil #ILLUSION
            pbPlayCry(@illusionpoke)
          else
            pbPlayCry(@pkmn.pokemon ? @pkmn.pokemon : @pkmn.species)
          end #ILLUSION
    in def pbTrainerSendOut
    replace
    Code:
        sendout=PokeballSendOutAnimation.new(@sprites["pokemon#{battlerindex}"], 
        @sprites,@battle.battlers[battlerindex],@battle.doublebattle)
    with
    Code:
        if @battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil #Illusion
          @sprites["pokemon#{battlerindex}"].setPokemonBitmap(
          @battle.battlers[battlerindex].effects[PBEffects::Illusion],false)
        end
        sendout=PokeballSendOutAnimation.new(@sprites["pokemon#{battlerindex}"],
           @sprites,@battle.battlers[battlerindex],@battle.doublebattle,
           @battle.battlers[battlerindex].effects[PBEffects::Illusion]) #Illusion
    replace
    Code:
        if @battle.battlers[battlerindex].pokemon.isShiny? && @battle.battlescene
    with
    Code:
        if @battle.battlers[battlerindex].pokemon.isShiny? && @battle.battlescene || 
           (@battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil && 
           @battle.battlers[battlerindex].effects[PBEffects::Illusion].isShiny?) #ILLUSION
    in def pbSendOut
    replace
    Code:
        sendout=PokeballPlayerSendOutAnimation.new(@sprites["pokemon#{battlerindex}"], 
           @sprites,@battle.battlers[battlerindex],@battle.doublebattle)
    with
    Code:
        if @battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil #Illusion
          @sprites["pokemon#{battlerindex}"].setPokemonBitmap(
          @battle.battlers[battlerindex].effects[PBEffects::Illusion],true)
        end 
        sendout=PokeballPlayerSendOutAnimation.new(@sprites["pokemon#{battlerindex}"],
           @sprites,@battle.battlers[battlerindex],@battle.doublebattle,
           @battle.battlers[battlerindex].effects[PBEffects::Illusion]) #Illusion
    replace
    Code:
        if @battle.battlers[battlerindex].pokemon.isShiny? && @battle.battlescene
    with
    Code:
        if @battle.battlers[battlerindex].pokemon.isShiny? && @battle.battlescene || 
           (@battle.battlers[battlerindex].effects[PBEffects::Illusion] != nil && 
           @battle.battlers[battlerindex].effects[PBEffects::Illusion].isShiny?) #ILLUSION
    In PokeBattle_Battle
    after
    Code:
            if !pbIsOpposing?(index) || (@opponent && pbIsOpposing?(index)) 
              newenemy=pbSwitchInBetween(index,false,false)
    add
    Code:
              if isConst?(@party2[newenemy].ability,PBAbilities,:ILLUSION) #ILLUSION
                [email protected]_all {|item| item && !item.egg? && item.hp>0 }
                if party3[@party2.length-1] != @party2[newenemy]
                  illusionpoke = party3[party3.length-1]
                end
              end #ILLUSION
              newname = illusionpoke != nil ? illusionpoke.name : @party2[newenemy].name #ILLUSION
    replace
    Code:
                pbDisplayPaused(_INTL("{1} is about to send in {2}.",opponent.fullname,@party2[newenemy].name))
    with
    Code:
                pbDisplayPaused(_INTL("{1} is about to send in {2}.",opponent.fullname,newname)) #ILLUSION
    replace
    Code:
          [email protected][index].pbOppositeOpposing
          if opposing.isFainted? || opposing.hp==opposing.totalhp
            pbDisplayBrief(_INTL("Go! {1}!",party[newpoke].name))
          elsif opposing.hp>=(opposing.totalhp/2)
            pbDisplayBrief(_INTL("Do it! {1}!",party[newpoke].name))
          elsif opposing.hp>=(opposing.totalhp/4)
            pbDisplayBrief(_INTL("Go for it, {1}!",party[newpoke].name))
          else
            pbDisplayBrief(_INTL("Your foe's weak!\nGet 'em, {1}!",party[newpoke].name))
          end
    with
    Code:
          if isConst?(party[newpoke].ability,PBAbilities,:ILLUSION) #ILLUSION
            party2=party.find_all {|item| item && !item.egg? && item.hp>0 }
            if party2[party.length-1] != party[newpoke]
              illusionpoke = party[party.length-1]
            end
          end #ILLUSION
          newname = illusionpoke != nil ? illusionpoke.name : party[newpoke].name
          [email protected][index].pbOppositeOpposing
          if opposing.hp<=0 || opposing.hp==opposing.totalhp
            pbDisplayBrief(_INTL("Go! {1}!",newname))
          elsif opposing.hp>=(opposing.totalhp/2)
            pbDisplayBrief(_INTL("Do it! {1}!",newname))
          elsif opposing.hp>=(opposing.totalhp/4)
            pbDisplayBrief(_INTL("Go for it, {1}!",newname))
          else
            pbDisplayBrief(_INTL("Your foe's weak!\nGet 'em, {1}!",newname))
          end
    replace
    Code:
          owner=pbGetOwner(index) 
          pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",owner.fullname,party[newpoke].name))
    with
    Code:
          if isConst?(party[newpoke].ability,PBAbilities,:ILLUSION) #ILLUSION
            party2=party.find_all {|item| item && !item.egg? && item.hp>0 }
            if party2[party.length-1] != party[newpoke]
              illusionpoke = party[party.length-1]
            end
          end #ILLUSION
          newname = illusionpoke != nil ? illusionpoke.name : party[newpoke].name #ILLUSION
          owner=pbGetOwner(index)
          pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",owner.fullname,newname)) #ILLUSION
    after
    #=======================================
    # Initialize opponents in double battles
    #=======================================
    replace
    Code:
        pbSendOut(1,@party2[sendout1]) 
            pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent[1].fullname,@party2[sendout2].name))
    with
    Code:
            @battlers[1].pbInitialize(@party2[sendout1],sendout1,false)
            @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
            pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent[0].fullname,@battlers[1].name)) #ILLUSION
            pbSendOut(1,@party2[sendout1])
            pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent[1].fullname,@battlers[3].name)) #ILLUSION
    replace
    Code:
            pbDisplayBrief(_INTL("{1} sent\r\nout {2} and {3}!",
               @opponent.fullname,@party2[sendout1].name,@party2[sendout2].name)) 
            @battlers[1].pbInitialize(@party2[sendout1],sendout1,false) 
            @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
    with
    Code:
            @battlers[1].pbInitialize(@party2[sendout1],sendout1,false) #ILLUSION
            @battlers[3].pbInitialize(@party2[sendout2],sendout2,false)
            pbDisplayBrief(_INTL("{1} sent\r\nout {2} and {3}!",
               @opponent.fullname,@battlers[1].name,@battlers[3].name)) #ILLUSION
    after
    #======================================
    # Initialize opponent in single battles
    #======================================
    replace
    Code:
          pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent.fullname,trainerpoke.name))
          @battlers[1].pbInitialize(trainerpoke,sendout,false)
    with
    Code:
        @battlers[1].pbInitialize(trainerpoke,sendout,false) #ILLUSION 
        pbDisplayBrief(_INTL("{1} sent\r\nout {2}!",@opponent.fullname,@battlers[1].name))
    after
    #=====================================
    # Initialize players in double battles
    #=====================================
    replace
    Code:
        pbDisplayBrief(_INTL("{1} sent\r\nout {2}! Go! {3}!", 
               @player[1].fullname,@party1[sendout2].name,@party1[sendout1].name))
    with
    Code:
            @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) #ILLUSION 
            @battlers[2].pbInitialize(@party1[sendout2],sendout2,false) 
            pbDisplayBrief(_INTL("{1} sent\r\nout {2}!  Go! {3}!", 
        @player[1].fullname,@battlers[2].name,@battlers[0].name))#ILLUSION
    replace
    Code:
            pbDisplayBrief(_INTL("Go! {1} and {2}!",@party1[sendout1].name,@party1[sendout2].name))
          end 
          @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) 
          @battlers[2].pbInitialize(@party1[sendout2],sendout2,false)
    with
    Code:
        @battlers[0].pbInitialize(@party1[sendout1],sendout1,false) #ILLUSION 
        @battlers[2].pbInitialize(@party1[sendout2],sendout2,false) 
            pbDisplayBrief(_INTL("Go! {1} and {2}!",@battlers[0].name,@battlers[2].name)) #ILLUSION 
        end
    after
    #====================================
    # Initialize player in single battles
    #====================================
    replace
    Code:
          pbDisplayBrief(_INTL("Go! {1}!",playerpoke.name))
          @battlers[0].pbInitialize(playerpoke,sendout,false)
    with
    Code:
          @battlers[0].pbInitialize(playerpoke,sendout,false) #Illusion 
          pbDisplayBrief(_INTL("Go! {1}!",@battlers[0].name))
    In PokeBattle_MoveEffects
    in class PokeBattle_Move_063 < PokeBattle_Move
    after
    Code:
        @battle.pbDisplay(_INTL("{1} acquired {2}!",opponent.pbThis,abilityname))
    put
    Code:
        if opponent.effects[PBEffects::Illusion]!=nil #ILLUSION
          # Animation should go here
          # Break the illusion
          opponent.effects[PBEffects::Illusion]=nil
          @battle.scene.pbChangePokemon(opponent,opponent.pokemon)
          @battle.pbDisplay(_INTL("{1}'s {2} was broken!",opponent.pbThis,
              PBAbilities.getName(opponent.ability)))
        end #ILLUSION
    in class PokeBattle_Move_064 < PokeBattle_Move
    after
    Code:
        @battle.pbDisplay(_INTL("{1} acquired {2}!",opponent.pbThis,abilityname))
    put
    Code:
        if opponent.effects[PBEffects::Illusion]!=nil #ILLUSION
          # Animation should go here
          # Break the illusion
          opponent.effects[PBEffects::Illusion]=nil
          @battle.scene.pbChangePokemon(opponent,opponent.pokemon)
          @battle.pbDisplay(_INTL("{1}'s {2} was broken!",opponent.pbThis,
              PBAbilities.getName(opponent.ability)))
        end #ILLUSION
    in class PokeBattle_Move_068 < PokeBattle_Move
    after
    Code:
        @battle.pbDisplay(_INTL("{1}'s ability was suppressed!",opponent.pbThis))
    put
    Code:
        if opponent.effects[PBEffects::Illusion]!=nil #ILLUSION
          # Animation should go here
          # Break the illusion
          opponent.effects[PBEffects::Illusion]=nil
          @battle.scene.pbChangePokemon(opponent,opponent.pokemon)
          @battle.pbDisplay(_INTL("{1}'s {2} was broken!",opponent.pbThis,
              PBAbilities.getName(opponent.ability)))
        end #ILLUSION


    I know this should probably go to the Gen 6 project but I haven't had the time to check out the compiled scripts file, though I don't think there should be any conflicts, but I just wanted to post the script so people could test it.
    Reply With Quote

    Relevant Advertising!

      #2    
    Old December 9th, 2014 (10:09 AM).
    mej71's Avatar
    mej71 mej71 is offline
       
      Join Date: Mar 2014
      Location: Omnipresence
      Gender: Male
      Posts: 1,226
      Had to change a part to make the gender be correct, but everything else is awesome! Works in double battles.
      Reply With Quote
        #3    
      Old December 9th, 2014 (1:38 PM).
      trueegee trueegee is offline
         
        Join Date: Dec 2014
        Gender: Male
        Posts: 8
        Oh, you mean this:
        Code:
            if genderA==0 # Male
              textpos.push([_INTL("♂"),genderX,6,false,Color.new(48,96,216),shadow])
            elsif genderA==1 # Female
              textpos.push([_INTL("♀"),genderX,6,false,Color.new(248,88,40),shadow])
            end
        Yeah, that was a small oversight on my part, I forgot to copy these lines of code too.

        Anyway, I've also made a little AI snippet to make it so that the AI doesn't completely see through your Illusion: (all it affects is the type-related stuff, but at least it makes the AI looks like it cheats less than it actually does :P - though it will only affect higher level trainers due to how the AI works)
        Spoiler:
        in PokeBattle_Batler, after
        Code:
          def pbHasType?(type)
            if type.is_a?(Symbol) || type.is_a?(String)
              ret=isConst?(self.type1,PBTypes,type.to_sym) ||
                  isConst?(self.type2,PBTypes,type.to_sym)
              return ret
            else
              return (self.type1==type || self.type2==type)
            end
          end
        add
        Code:
          def pbHasTypeAI?(type)
            if @effects[PBEffects::Illusion] != nil 
              if type.is_a?(Symbol) || type.is_a?(String)
                ret=isConst?(@effects[PBEffects::Illusion].type1,PBTypes,type.to_sym) ||
                    isConst?(@effects[PBEffects::Illusion].type2,PBTypes,type.to_sym)
                return ret
              else
                return (@effects[PBEffects::Illusion].type1==type || 
                        @effects[PBEffects::Illusion].type2==type)
              end
            end
            if type.is_a?(Symbol) || type.is_a?(String)
              ret=isConst?(self.type1,PBTypes,type.to_sym) ||
                  isConst?(self.type2,PBTypes,type.to_sym)
              return ret
            else
              return (self.type1==type || self.type2==type)
            end
          end
        then in PokeBattle_AI replace all occurrences of
        Code:
        opponent.pbHasType?
        with
        Code:
        opponent.pbHasTypeAI?
        and in PokeBattle_AI in def pbTypeModifier(type,attacker,opponent)
        after
        Code:
            otype1=opponent.type1
            otype2=opponent.type2
        add
        Code:
            if opponent.effects[PBEffects::Illusion] != nil 
               otype1=opponent.effects[PBEffects::Illusion].type1
               otype2=opponent.effects[PBEffects::Illusion].type2     
            end
        Reply With Quote
          #4    
        Old December 9th, 2014 (4:31 PM).
        DarkGrey's Avatar
        DarkGrey DarkGrey is offline
           
          Join Date: Sep 2011
          Gender: Female
          Posts: 47
          Don't forget to make Imposter fail if the opponent has Illusion.
          Reply With Quote
            #5    
          Old December 10th, 2014 (9:20 AM).
          trueegee trueegee is offline
             
            Join Date: Dec 2014
            Gender: Male
            Posts: 8
            Oh yeah, thanks for pointing that out, it should also make Transform not work as well.
            Spoiler:

            in PokeBattle_Battler

            after
            Code:
                if self.hasWorkingAbility(:IMPOSTER) && [email protected][PBEffects::Transform] && onactive
                  choice=pbOppositeOpposing
                  blacklist=[
                     0xC9,    # Fly
                     0xCA,    # Dig
                     0xCB,    # Dive
                     0xCC,    # Bounce
                     0xCD,    # Shadow Force
                     0xCE     # Sky Drop
                  ]
                  if choice.effects[PBEffects::Substitute]>0 ||
                     choice.effects[PBEffects::Transform] ||
                     choice.effects[PBEffects::SkyDrop] ||
            add
            Code:
                     choice.effects[PBEffects::Illusion]!=nil || #Illusion
            in PokeBattle_MoveEffects
            in class PokeBattle_Move_069 < PokeBattle_Move

            after
            Code:
                if attacker.effects[PBEffects::Transform] ||
                   opponent.effects[PBEffects::Transform] ||
                   opponent.effects[PBEffects::Substitute]>0 ||
            add
            Code:
                   opponent.effects[PBEffects::Illusion]!=nil || #Illusion
            Reply With Quote
              #6    
            Old December 12th, 2014 (3:04 PM).
            trueegee trueegee is offline
               
              Join Date: Dec 2014
              Gender: Male
              Posts: 8
              Sorry for the double post, but here is a quick fix from mej71:

              In PokeBattle_Battler replace
              Code:
                  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]
                     end
                   end #Illusion
              with
              Code:
                  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 #Illusion
              Reply With Quote
                #7    
              Old February 10th, 2018 (10:22 AM).
              Ekulchu's Avatar
              Ekulchu Ekulchu is offline
              Team Ink Leader
                 
                Join Date: Jan 2018
                Gender: Male
                Nature: Lax
                Posts: 2
                What are you using to edit abilities?
                I couldn't find anything but name changing when I looked...
                Reply With Quote
                Reply

                Quick Reply

                Join the conversation!

                Create an account to post a reply in this thread, participate in other discussions, and more!

                Create a PokéCommunity Account

                Sponsored Links
                Thread Tools

                Posting Rules
                You may not post new threads
                You may not post replies
                You may not post attachments
                You may not edit your posts

                BB code is On
                Smilies are On
                [IMG] code is On
                HTML code is Off

                Forum Jump


                All times are GMT -8. The time now is 10:07 PM.