Advertiser Content

Error [SOLVED] Power Construct's script

Started by WolfPP November 21st, 2019 5:03 AM
  • 909 views
  • 6 replies

WolfPP

Discord: Wolf#1235

Male
Brazil
Seen 8 Hours Ago
Posted 1 Day Ago
1,063 posts
1.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:
attr_accessor :captured attr_accessor :startform # Greninja, Zygarde and Minior attr_accessor :originalhp # Zygarde
In ' def pbInitPokemon(pkmn,pkmnIndex)':
@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):
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:
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:

--------------------------- Pokemon Essentials --------------------------- [Pokémon Essentials version 17.2] Exception: RuntimeError Message: Script error within event 16 (coords 26,6), map 3 (Red's house): Exception: NoMethodError Message: PField_Battles:395:in `pbAfterBattle'undefined method `startform' for #<PokeBattle_Pokemon:0x9ae2ea8> ***Full pbWildBattle(:REGIGIGAS,55) Interpreter:243:in `pbExecuteScript' PField_Battles:390:in `each' PField_Battles:390:in `pbAfterBattle' PField_Battles:102:in `pbWildBattle' PField_Battles:98:in `pbBattleAnimation' PField_Battles:98:in `pbWildBattle' (eval):2:in `pbExecuteScript' Interpreter:1606:in `eval' Interpreter:243:in `pbExecuteScript' Interpreter:1606:in `command_355' Interpreter:276:in `pbExecuteScript' Interpreter:1606:in `command_355' Interpreter:494:in `execute_command' Interpreter:193:in `update' Interpreter:106:in `loop' Interpreter:198:in `update' Scene_Map:163:in `update' Scene_Map:161:in `loop' Scene_Map:170:in `update' Scene_Map:234:in `main'

What could be?

WolfPP

Discord: Wolf#1235

Male
Brazil
Seen 8 Hours Ago
Posted 1 Day Ago
1,063 posts
1.5 Years
Solved about change its form

In 'PokeBattle_Battler' script, paste 'attr_accessor :startform' and 'attr_accessor :originalhp', like:
  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:
    @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:

################################################################################
# Forms into End of Round
################################################################################
  def pbEndRoundCheckForm
    # Power Construct
    if isConst?(self.species,PBSpecies,:ZYGARDE) && !self.fainted?
      if self.hasWorkingAbility(:POWERCONSTRUCT) && @hp<=((@totalhp/2).floor)
        if self.form!=2
          self.startform=self.form
          self.form=2
          @battle.pbDisplay(_INTL("You sense the presence of many!"))
          @battle.pbCommonAnimation("PowerConstruct",self,nil)
          pbUpdate(true)
          @battle.scene.pbChangePokemon(self,@pokemon)
          @battle.pbCommonAnimation("PowerConstruct2",self,nil)
          @battle.pbDisplay(_INTL("{1} transformed into its Complete Forme!",pbThis))
          PBDebug.log("[Form changed] #{pbThis} changed to form #{self.form}")
        end
      end
    end
  end
  
  def pbResetFormEndRound
    if [email protected][PBEffects::Transform]
      if isConst?(self.species,PBSpecies,:ZYGARDE) && self.form==2
        self.originalhp = self.hp
        self.form = self.startform
        if !self.fainted?
          if self.originalhp>=self.totalhp
            self.hp = self.totalhp 
          else
            self.hp = self.originalhp
          end
        end
      end
    end
    pbUpdate(true)
  end

    
  def pbResetForm
    if [email protected][PBEffects::Transform]
      if isConst?(self.species,PBSpecies,:CASTFORM) ||


Then, inside 'PokeBattle_Battle' script, look for '# Form checks' and paste '@battlers[i].pbEndRoundCheckForm', like:
    # 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:
    # 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:

    # Pass on Pokérus within the party
    infected=[]
    for i in 0...$Trainer.party.length
      if $Trainer.party[i].pokerusStage==1
        infected.push(i)
      end
    end
    if infected.length>=1
      for i in infected
        strain=$Trainer.party[i].pokerusStrain
        if i>0 && $Trainer.party[i-1].pokerusStage==0
          $Trainer.party[i-1].givePokerus(strain) if rand(3)==0
        end
        if i<$Trainer.party.length-1 && $Trainer.party[i+1].pokerusStage==0
          $Trainer.party[i+1].givePokerus(strain) if rand(3)==0
        end
      end
    end
    @scene.pbEndBattle(@decision)
    for i in @battlers
      i.pbResetForm
      i.pbResetFormEndRound
      if i.hasWorkingAbility(:NATURALCURE)
        i.status=0
      end
    end


And finally, inside 'PokeBattle_Pokemon' add 'attr_reader(:startform)', like:
  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:
        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.
Advertiser Content