• 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.

[Error] [SOLVED] Power Construct's script

WolfPP

Spriter/ Pixel Artist
1,309
Posts
5
Years
  • SOLVED! SOLUTION HERE:
    Click Here

    Guys, trying to make a better script for Power Construct, I added '@startform' and '@originalhp':

    In 'PokeBattle_Battler' was added:
    Code:
    attr_accessor :captured attr_accessor :startform # Greninja, Zygarde and Minior attr_accessor :originalhp # Zygarde

    In ' def pbInitPokemon(pkmn,pkmnIndex)':
    Code:
    @iv[4] = pkmn.iv[4] @iv[5] = pkmn.iv[5] @startform = @form # Minior @originalhp = @hp # Zygarde end Inside ' def pbFaint(showMessage=true)': @pokemon.makeUnmega if self.isMega? @pokemon.makeUnprimal if self.isPrimal?
    if isConst?(self.species,PBSpecies,:ZYGARDE) && self.form==2 if self.startform>0; self.form=startform; else; self.form=rand(2); end end @fainted=true # reset choice
    And works perfectly when Pokémon dies inside the battle.
    To trigger the ability, I added below Moxie's code (inside PokeBattle_Battle script):
    Code:
    for i in priority 
      next if i.fainted?
    # Power Construct 
      if i.hasWorkingAbility(:POWERCONSTRUCT) && isConst?(i.species,PBSpecies,:ZYGARDE) 
        if i.hp<((i.totalhp/2).floor) && i.form!=2 
          i.startform=i.form
          i.originalhp=i.hp 
          i.form=2 pbDisplay(_INTL("You sense the presence of many!"))
        
      pbCommonAnimation("PowerConstruct",i,nil)
          i.pbUpdate(true) 
          scene.pbChangePokemon(i,i.pokemon) 
          pbCommonAnimation("PowerConstruct2",i,nil) 
          pbDisplay(_INTL("{1} transformed into its Complete Forme!",i.pbThis)) 
          PBDebug.log("[Form changed] #{i.pbThis} changed to form #{i.form}") 
          end 
        end
    end

    But if I add here:
    Code:
    def pbAfterBattle(decision,canlose) 
      for i in $Trainer.party
        (i.makeUnmega rescue nil); (i.makeUnprimal rescue nil)
        if isConst?(i.species,PBSpecies,:ZYGARDE) &&  i.form==2
          if i.startform>0; i.form=i.startform 
          else; i.form=rand(2)
          end
          if i.originalhp>i.totalhp; i.hp=i.totalhp
          else; i.hp=i.originalhp
          end
        end 
      end
    After battle, give me error because the game didn't recognize 'startform' (possibly originalhp too).

    Here the issue:
    Spoiler:

    What could be?
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Code:
    `pbAfterBattle'undefined method `startform' for #<PokeBattle_Pokemon:0x9ae2ea8>
    Like it says here, pbAfterBattle processes PokeBattle_Pokemon objects, but you have added startform to PokeBattle_Battler objects only.
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Even if I added 'attr_accessor(:startform)' in PokeBattle_Pokemon script, it doesn't work. Zygarde returns 50% form instead 10% (yeah, I had Zygarde 10% before battle).
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    That's because you never set startform on the PokeBattle_Pokemon object either. You'll need to have
    Code:
    i.pokemon.startform=i.startform=i.form
    Or something along those lines.
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Solved about change its form

    In 'PokeBattle_Battler' script, paste 'attr_accessor :startform' and 'attr_accessor :originalhp', like:
    Code:
      attr_accessor :movesUsed
      attr_accessor :currentMove
      attr_accessor :damagestate
      attr_accessor :captured
      attr_accessor :startform
      attr_accessor :originalhp

    Now inside 'def pbInitPokemon(pkmn,pkmnIndex)', paste '@startform = @form' and '@originalhp = @hp', like:
    Code:
        @participants = [] # Participants will earn Exp. Points if this battler is defeated
        @moves        = [
           PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[0]),
           PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[1]),
           PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[2]),
           PokeBattle_Move.pbFromPBMove(@battle,pkmn.moves[3])
        ]
        @iv           = []
        @iv[0]        = pkmn.iv[0]
        @iv[1]        = pkmn.iv[1]
        @iv[2]        = pkmn.iv[2]
        @iv[3]        = pkmn.iv[3]
        @iv[4]        = pkmn.iv[4]
        @iv[5]        = pkmn.iv[5]
        @startform    = @form
        @originalhp   = @hp
      end
    
      def pbInitDummyPokemon(pkmn,pkmnIndex)

    Now create two new defs, 'def pbEndRoundCheckForm' and 'pbResetFormEndRound' above 'def pbResetForm', like:
    Spoiler:


    Then, inside 'PokeBattle_Battle' script, look for '# Form checks' and paste '@battlers.pbEndRoundCheckForm', like:
    Code:
        # Slow Start's end message
        if i.hasWorkingAbility(:SLOWSTART) && i.turncount==6
          pbDisplay(_INTL("{1} finally got its act together!",i.pbThis))
        end
        # Form checks
        for i in 0...4
          next if @battlers[i].fainted?
          @battlers[i].pbCheckForm
          @battlers[i].pbEndRoundCheckForm
        end
        pbGainEXP
        pbSwitch

    Use CTRL+SHIF+F and search for '@pokemon.makeUnprimal if self.isPrimal?' to paste '@pokemon.pbResetFormEndRound' below, like:
    Code:
        # Reset status
        self.status=0
        self.statusCount=0
        if @pokemon && @battle.internalbattle
          @pokemon.changeHappiness("faint")
        end
        @pokemon.makeUnmega if self.isMega?
        @pokemon.makeUnprimal if self.isPrimal?
        self.pbResetFormEndRound

    And here:
    Spoiler:


    And finally, inside 'PokeBattle_Pokemon' add 'attr_reader(:startform)', like:
    Code:
      attr_accessor(:shinyflag)   # Forces the shininess (true/false)
      attr_accessor(:ribbons)     # Array of ribbons
      attr_accessor :cool,:beauty,:cute,:smart,:tough,:sheen   # Contest stats
      attr_reader(:startform)     # Previous form before change to other one
      attr_reader(:originalhp)    # Current health points for Complete Forme
    
      EVLIMIT     = 510   # Max total EVs

    Also, if the player caught wild Zygarde in form 2, we need add inside 'PokeBattle_Battle', where we have 'makeUnmega' thing, like:
    Code:
            BallHandlers.onCatch(ball,self,pokemon)
            pokemon.ballused=pbGetBallType(ball)
            ((pokemon.makeUnmega if pokemon.isMega?) rescue nil)
            pokemon.makeUnprimal rescue nil
            pokemon.form=rand(2) if isConst?(pokemon.species,PBSpecies,:ZYGARDE) && pokemon.form==2
            pokemon.pbRecordFirstMoves
            if GAINEXPFORCAPTURE
              battler.captured=true



    Give me credits if used.
     
    Last edited:
    37
    Posts
    6
    Years
  • Do like ultra necrozma, create a variable that memorizes its form before it becomes ultra, but in that case, remember if your HP is larger than half of the previous form.

    Code:
    attr_accessor(:necrozmaVar)     # Store the form Necrozma was in initially if it bursts
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • I don't think so because that code only use 'PokeBattle_Battle' script.
    Anyway, I solved and Power Construct works like a charm (click here to check).
    Thanks for attention!
     
    Last edited:
    Back
    Top