Thread: [Essentials Script] Illusion
View Single Post
  #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