Essentials Tutorial Dynamax tutorial

Started by fauno November 21st, 2019 4:05 PM
  • 14917 views
  • 78 replies

fauno

Non-binary
Brazil
Seen 5 Days Ago
Posted July 29th, 2020
37 posts
3.1 Years


Let's make a Dynamax function to your game! (Remember that the system is still incomplete, you will need to upgrade as new role information is released)

LOG: (last update:12/30/2019)
Spoiler:

• Compatible with single and double battles
• Compatible with double battles with Partner
• The Dynamax is verified by the number of the currenct map (remove 'return if !(@battlers[index].hasDynamax? rescue false)' and 'return false if [email protected][index].hasDynamax?' for change the map verification)
• The Dynamax system is a copy of Mega Evolution Method without the Pokemon having to hold an item
• The move list changes to Max Moves based on the move type in the Pokémon list.
12/30/2019
• Dynamax now multiplies the Pokémon's HP by its Dynamax Level.
• Gigantamax has been included in the scan, but there is no specific method for it (for now)
• Pokémon Dynamax cannot receive Flinch, be kicked out of the battle by moves like Roar (configured on the move itself, not tutorials).
• Max Moves are set in MoveEffects and not in this tutorial.
• IMPORTANT THING: The Dynamax system still has several HP multiplication related bugs (add to your project knowing that this will happen and please, if you find the solution to the correct calculations share here to improve the system and make it true to the original games).


Let's start this crap!

Inside Settings, search for "MEGARINGS" and bellow add:
DBANDS                = [:DYNAMAXBAND]
First we need to create some effects that will be used for Max Moves, Dynamax and Gigantamax.
Within the PBEffects script for battler effects, add (where XXX is the next numeric value):
Dynamax = XXX
DBoost = XXX
DButton = XXX
# Max Move Effects
MaxGuard = XXX
MaxKnuckle = XXX
MaxAirstream = XXX
MaxOoze = XXX
MaxQuake = XXX
MaxSteelspike = XXX
# Gigantamax
Gigantamax = XXX
MaxMove1 = XXX
MaxMove2 = XXX
MaxMove3 = XXX
MaxMove4 = XXX
Now we have the necessary effects to work on Dynamax mechanics and the like, continuing on PokeBattle_Battler (with R), among the "attr_acessor" put:
  attr_accessor :dynamax
  attr_accessor :gigantamax
Then continue and search for "def isMega?" and below put the following lines:
# Dynamax is compatible with large maps
 def hasDynamax?
    maps = [] # maps for allow Dynamax
    if $game_map && maps.include?($game_map.map_id) &&
      !(self.isConst?(species,PBSpecies,:ZACIAN) ||
      self.isConst?(species,PBSpecies,:ZAMAZENTA))
      return true
    end
    return false
  end
  
  def isDynamax?
    #return false if @effects[PBEffects::Transform]
    if @pokemon
      return (@pokemon.isDynamax? rescue false)
    end
    return false
  end
  
  def makeUnmax
    return pbUndynamax
  end
If you want to use Gigantamax, just remove "#" in lines
  
  def hasGigantamax?
    return false if @effects[PBEffects::Transform]
    if @pokemon # && @pokemon.dynamax_lvl==10
      if isConst?(species,PBSpecies,:CHARIZARD) # ||
        #isConst?(species,PBSpecies,:BUTTERFREE) ||
        #isConst?(species,PBSpecies,:PIKACHU) ||
        #isConst?(species,PBSpecies,:MEOWTH) ||
        #isConst?(species,PBSpecies,:MACHAMP) ||
        #isConst?(species,PBSpecies,:GENGAR) ||
        #isConst?(species,PBSpecies,:KINGLER) ||
        #isConst?(species,PBSpecies,:LAPRAS) ||
        #isConst?(species,PBSpecies,:EEVEE) ||
        #isConst?(species,PBSpecies,:SNORLAX) ||
        #isConst?(species,PBSpecies,:GARBODOR) ||
        #isConst?(species,PBSpecies,:MELMETAL) ||
        #isConst?(species,PBSpecies,:CORVIKNIGHT) ||
        #isConst?(species,PBSpecies,:ORBEETLE) ||
        #isConst?(species,PBSpecies,:DREDNAW) ||
        #isConst?(species,PBSpecies,:COALOSSAL) ||
        #isConst?(species,PBSpecies,:APPLETUN) ||
        #isConst?(species,PBSpecies,:SANDACONDA) ||
        #isConst?(species,PBSpecies,:TOXTRICITY) ||
        #isConst?(species,PBSpecies,:CENTISKORCH) ||
        #isConst?(species,PBSpecies,:HATTERENE) ||
        #isConst?(species,PBSpecies,:GRIMMSNARL) ||
        #isConst?(species,PBSpecies,:ALCREMIE) ||
        #isConst?(species,PBSpecies,:COPPERAJAH) ||
        #isConst?(species,PBSpecies,:DURALUDON) ||
        #isConst?(species,PBSpecies,:ETERNATUS)
        return true
      end
    end
    return false
  end
Continuing...
  
  def pbUndynamax
    if @pokemon
      @battle.pbDisplay(_INTL("{1}'s reversing the changes!",pbThis))
      @battle.pbCommonAnimation ("UnDynamaxAnimationHere",self,nil)
      @effects[PBEffects::DBoost] = false
      @effects[PBEffects::Dynamax] = 0
      @effects[PBEffects::DButton] = false
      # Only for Gigantamax
      if hasGigantamax?
        @pokemon.form=0
        @battle.scene.pbChangePokemon(self,@pokemon)
        @effects[PBEffects::Gigantamax]=0
      end
      @pokemon.makeUndynamax
      pbUnMaxMove(unmax=true)
      pbUpdate(true)
      @pokemon.pbReversing
      #@battle.scene.pbChangePokemon (self, @ pokemon) No need this line, cuz only check if Gigantamax up
      @battle.pbCommonAnimation ("UnDynamaxAnimation2Here",self,nil)
    end
  end
Now inside "pbInitEffects(battonpass)", put after the last line:
    # Dynamax / Gigantamax
    @effects[PBEffects::Dynamax] = 0
    @effects[PBEffects::DBoost] = false
    @effects[PBEffects::DButton] = false
    @effects[PBEffects::Gigantamax] = 0
    # Max Move Effects
    @effects[PBEffects::MaxGuard] = false
    @effects[PBEffects::MaxKnuckle] = false
    @effects[PBEffects::MaxAirstream] = false
    @effects[PBEffects::MaxOoze] = false
    @effects[PBEffects::MaxQuake] = false
    @effects[PBEffects::MaxSteelspike] = false
    # Max Special Usage
    @effects[PBEffects::MaxMove1] = 0
    @effects[PBEffects::MaxMove2] = 0
    @effects[PBEffects::MaxMove3] = 0
    @effects[PBEffects::MaxMove4] = 0
Search for "def isAirborne?" and below add:
# Dynamax
  def pbMaxMove
    imposter=isConst?(species,PBSpecies,:DITTO) && isConst?(ability,PBAbilities,:LIMBER)
     for i in 0...4 # [@moves[0],@moves[1],@moves[2],@moves[3]]
       if @moves[i].id>0 && !imposter
         if @moves[i] .pbIsStatus?
           @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXGUARD)))
         elsif @moves[i].type==0 # Normal
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXSTRIKE)))
         elsif @moves[i].type==1 # Fighting
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXKNUCKLE)))
         elsif @moves[i].type==2 # Flying
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXAIRSTREAM)))
         elsif @moves[i].type==3 # Poison
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXOOZE)))
         elsif @moves[i].type==4 # Ground
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXQUAKE)))
         elsif @moves[i].type==5 # Rock
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXROCKFALL)))
         elsif @moves[i].type==6 # Bug
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXFLUTTERBY)))
         elsif @moves[i].type==7 # Ghost
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXPHANTASM)))
         elsif @moves[i].type==8 # Steel
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXSTEELSPIKE)))
         elsif @moves[i].type==10 # Fire
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXFLARE)))
         elsif @moves[i].type==11 # Water
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXGEYSER)))
         elsif @moves[i].type==12 # Grass
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXOVERGROWTH)))
         elsif @moves[i].type==13 # Electric
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXLIGHTNING)))
         elsif @moves[i].type==14 # Psychic
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXMINDSTORM)))
         elsif @moves[i].type==15 # Ice
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXHAILSTORM)))
         elsif @moves[i].type==16 # Dragon
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXWYRMWIND)))
         elsif @moves[i].type==17 # Dark
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXDARKNESS)))
         elsif @moves[i].type==18 # Fairy
	   @moves[i]=PokeBattle_Move.pbFromPBMove(@battle,PBMove.new(getConst(PBMoves,:MAXSTARFALL)))
         end
       end
       @moves[i].pp=PokeBattle_Move.pbFromPBMove(@battle,@pokemon.moves[i]).pp
       @moves[i].totalpp=PokeBattle_Move.pbFromPBMove(@battle,@pokemon.moves[i]).totalpp
     end
   return false
  end
 
  def pbUnMaxMove(unmax=false)
    @moves = [
     PokeBattle_Move.pbFromPBMove(@battle,@pokemon.moves[0]),
     PokeBattle_Move.pbFromPBMove(@battle,@pokemon.moves[1]),
     PokeBattle_Move.pbFromPBMove(@battle,@pokemon.moves[2]),
     PokeBattle_Move.pbFromPBMove(@battle,@pokemon.moves[3])
     ]
    if unmax
      @pokemon.moves[0][email protected][PBEffects::MaxMove1]
      @pokemon.moves[1][email protected][PBEffects::MaxMove2]
      @pokemon.moves[2][email protected][PBEffects::MaxMove3]
      @pokemon.moves[3][email protected][PBEffects::MaxMove4]
      for i in 0...4
        @moves[i][email protected][i].pp
        @moves[i][email protected][i].totalpp
      end
    end
  end
In "pbFaint", just below "@pokemon.makeUnprimal if self.isPrimal?" add line:
    # Dynamax
    @pokemon.makeUnmax if self.isDynamax?
Now in PokeBattle_BattleEffects, search for "def pbFlinch(attacker=nil)" and replace with:
  def pbFlinch(attacker=nil)
    return false if @effects[PBEffects::Dynamax]>0 # Dynamax can't be flinched
    return false if (!attacker || !attacker.hasMoldBreaker) && hasWorkingAbility(:INNERFOCUS)
    @effects[PBEffects::Flinch]=true
    return true
  end
Now in PokeBattle_Move add to "attr_acessor":
attr_accessor (:dynamax)
Continue and search for "def pbCalcDamage(attacker,opponent,options=0)", search for:
  if attacker.hasWorkingItem(:CHOICEBAND) && pbIsPhysical?(type)
    atkmult=(atkmult*1.5).round
  end
  if attacker.hasWorkingItem(:CHOICESPECS) && pbIsSpecial?(type)
    atkmult=(atkmult*1.5).round
  end
And replace with these:
  if !attacker.isDynamax?
    if attacker.hasWorkingItem(:CHOICEBAND) && pbIsPhysical?(type)
      atkmult=(atkmult*1.5).round
    end
    if attacker.hasWorkingItem (:CHOICESPECS) && pbIsSpecial?(type)
      atkmult=(atkmult*1.5).round
    end
  end
In PokeBattle_Battle (without R), within "def initialize(scene,p1,p2,player,opponent)", search for "if @opponent.is_a?(Array)"
and just below put these lines:
    # DynaMax
    @dynaMax = []
    if @player.is_a? (Array)
      @dynaMax[0] = [-1]*@player.length
    else
      @dynaMax[0] = [-1]
    end
    if @opponent.is_a?(Array)
      @dynaMax[1] = [-1]*@opponent.length
    else
      @dynaMax[1] = [-1]
    end
Bellow "def pbHasMegaRing?(battlerIndex)" add:
  def pbHasDBand?(battlerIndex)
    return true if !pbBelongsToPlayer?(battlerIndex)
    for i in DBANDS
      next if !hasConst?(PBItems,i)
      return true if $PokemonBag.pbQuantity(i)>0
    end
    return false
  end
And bellow "def pbCanShowCommands?(idxPokemon)" add:
  def dynaMax
    return @dynaMax
  end
In "def pbRegisterSwitch(idxPokemon,idxOther)" add above "return true":
    # Dynamax
    if @dynaMax[side][owner]==idxPokemon
      @dynaMax[side][owner]=-1
    end
    # Reverse Dynamax if still on
    if @battlers[idxPokemon].isDynamax?
     @battlers[idxPokemon].pbUndynamax
    end
Now in "def pbRegisterItem(idxPokemon,idxItem,idxTarget=nil)", also add above "return true":
    # Dynamax
    if @dynaMax[side][owner]==idxPokemon
      @dynaMax[side][owner]=-1
    end
Search for "Mega Evolve Battler" using "CTRL + F" or "CTRL + Shift + F" and UP put Dynamax Battler:
################################################################################
# Dynamax battler.
################################################################################

  def pbCanDynamax?(index)
    return false if $game_switches[NO_DYNAMAX]
    return false if! @battlers[index].hasDynamax?
    return false if pbIsOpposing?(index) && [email protected]
    return false if !pbHasDBand?(index)
    # If a Poke holding a Mega Stone / Z-Crystal, Dynamax not be able
    # to activate for him!
    return false if @battlers[index].hasZMove? # Only if you are using Z-Moves addon, otherwise remove this line
    return false if @battlers[index].hasMega?
    side = (pbIsOpposing?(index)) ? 1 : 0
    owner = pbGetOwnerIndex(index)
    return false if @dynaMax[side][owner]!=-1
    return false if @battlers[index].effects[PBEffects::SkyDrop]
    # Only for AI get Max / G-Max Moves
    @battlers[index].pbMaxMove if !pbBelongsToPlayer?(index)
    return true
  end
  
  def pbRegisterDynamax(index)
    side = (pbIsOpposing?(index)) ? 1 : 0
    owner = pbGetOwnerIndex(index)
    @dynaMax[side][owner]=index
  end

  def pbDynamax(index)
    return if! @battlers[index] || [email protected][index].pokemon
    return if! (@ battlers [index] .hasDynamax? rescue false)
    return if (@battlers[index].isDynamax? rescue true)
    ownername = pbGetOwner(index).fullname
    ownername = pbGetOwner(index).name if pbBelongsToPlayer?(index)
    @battlers [index].effects[PBEffects::Dynamax]=3
    @battlers [index].effects[PBEffects::DBoost]=true
    @scene.pbRecall(index)
    # Checking Gigantamax
    if @battlers[index].hasGigantamax?
      @battlers[index].pokemon.makeGigantamax
      @battlers[index].effects[PBEffects::Gigantamax]=3
      @battlers[index][email protected][index].pokemon.form
      @ scene.pbChangePokemon(@battlers[index],@battlers[index].pokemon)
    end
    if pbBelongsToPlayer?(index) || @battlers[index].pbPartner && !pbIsOpposing?(index)
      @scene.pbSendOut index,@battlers[index].pokemon)
    elsif pbIsOpposing?(index)
      @scene.pbTrainerSendOut (index,@battlers[index].pokemon)
    end
    @battlers[index].pokemon.makeDynamax
    @battlers[index].pbUpdate(true)
    maxname=(@battlers[index].pokemon.maxName rescue nil)
    if! maxname || maxname ==""
      maxname = _INTL ("{1}",PBSpecies.getName(@battlers[index].pokemon.species))
    end
    #pbDisplay(_INTL("{1} has Mega Evolved into {2}!",@battlers[index].pbThis,meganame))
    PBDebug.log("[Dynamax] #{@battlers[index].pbThis} became Max #{maxname}")
    side = (pbIsOpposing?(index)) ? 1 : 0
    owner = pbGetOwnerIndex(index)
    @dynaMax[side][owner]=-2
    pbPlayCrySpecies(@battlers[index])
  end
Within "def pbCommandPhase" under "# Reset choices to perform Mega Evolution" add the lines:
    # Dynamax
    for i in [email protected][0].length
      @dynaMax[0][i]=-1 if @dynaMax[0][i]>=0
    end
    for i in [email protected][1].length
      @dynaMax[1][i]=-1 if @dynaMax[1][i]>=0
    end
Now let's configure Dynamax to interact with player turns and choices during battle:

Within "if cmd==0 # Fight" put:
    # Dynamax
    if @dynaMax[side][owner]==i
      @dynaMax[side][owner]=-1
    end
Below, in "@doublebattle" within "if target<0":
    # Dynamax
    @dynaMax[0][0]=-1 if @dynaMax[0][0]>=0
    @dynaMax[1][0]=-1 if @dynaMax[1][0]>=0
Also in "elsif target==PBTargets::UserOrPartner # Acupressure":
    # Dynamax
    @dynaMax[0][0]=-1 if @dynaMax[0][0]>=0
    @dynaMax[1][0]=-1 if @dynaMax[1][0]>=0
Go to "elsif cmd==3 # Run" and do the same:
    # Dynamax
    if @dynaMax[side][owner]==i
      @dynaMax[side][owner]=-1
    end
Now in "elsif cmd==-1 # Go back to the first battler's choice":
    # Dynamax
    @dynaMax[0][0]=-1 if @dynaMax[0][0]>=0
    @dynaMax[1][0]=-1 if @dynaMax[1][0]>=0
Within "def pbAttackPhase", just below "# Mega Evolution", add:
    # Dynamax
    dynamaxed = []
    for i in priority
      if @choices[i.index][0]== 1 && !i.effects[PBEffects::SkipTurn]
        side = (pbIsOpposing?(i.index)) ? 1 : 0
        owner = pbGetOwnerIndex (i.index)
        if @dynaMax[side][owner]==i.index
          pbDynamax(i.index)
          dynamaxed.push(i.index)
        end
      end
    end
And finalizing the modifications in PokeBattle_Battle (without R), look for "def pbEndOfRoundPhase" and inside "# Form checks" add:
    # Dynamax
    if @battlers[i].effects[PBEffects::Dynamax]>0
      @battlers[i].effects[PBEffects::Dynamax]-=1
      if @battlers[i].effects[PBEffects::Dynamax]==0
        @battlers[i].pbUndynamax
      end
    end
Now, inside of "def pbThrowPokeBall(idxPokemon,ball,rareness=nil,showplayer=false)", bellow this line "((pokemon.makeUnprimal if pokemon.isPrimal?) rescue nil)", add:
((pokemon.makeUnmax if pokemon.isDynamax?) rescue nil)
Now in PokeBattle_Scene, look for "def initialize(battler,viewport=nil)" and under "@megaButton=0 # 0 = don't show, 1 = show, 2 = pressed" add:
    # Dynamax
    @dButton=0 # 0 = don't show, 1 = show, 2 = pressed
In "def refresh":
Add "@dButton" to the parameters
    @buttons.refresh(self.index,@battler? @battler.moves : nil, @megaButton,@zButton,@ultraButton,@dButton) if @buttons
Just below within "def update" do the same:
   @buttons.update(self.index,moves,@megaButton,@zButton,@ultraButton,@dButton) # Dynamax
Jumping to "def initialize (index=0,moves=nil,viewport=nil)" under "@megaevobitmap=AnimatedBitmap.new (_INTL("Graphics/Pictures/Battle/cursor_mega"))" add:
   # Dynamax
   @dynamaxbitmap=AnimatedBitmap.new (_INTL("Graphics/Pictures/Battle/cursor_dynamax"))
* Note that you will need an image called "cursor_dynamax" in the Battle folder (I will leave the cursor I use at the end of the tutorial, don't skip the steps)

Just below "def dispose" under "@megaevobitmap.dispose", add the line:
   @dynamaxbitmap.dispose
Continuing, new below further replace your lines:
   def update(index=0,moves=nil,megaButton=0)
     refresh(index,moves,megaButton)
   end
  
   def refresh(index,moves,megaButton)
For these:
   def update(index=0,moves=nil,megaButton=0,dButton=0) # Dynamax
     refresh(index,moves,megaButton,dButton) # Dynamax
   end
  
   def refresh(index,moves,megaButton,dButton) # Dynamax
Under "if megaButton>0" put:
   # Dynamax
   if dButton>0
     self.bitmap.blt(146.0,@dynamaxbitmap.bitmap,Rect.new(0,(dButton-1)*46.96.46))
   end
Now look for the line "# Draw Mega Evolution" and above "elsif @battler.isPrimal?" add:
   elsif @battler.isDynamax?
     imagepos.push(["Graphics/Pictures/Battle/icon_dynamax",@spritebaseX+0.32,0,0,-1,-1))
* I will also leave at the end of the tutorial the Dynamax icon that I use

Now search for "def pbFightMenu (index)" and under "cw.megaButton=1 if (@battle.pbCanMegaEvolve?(Index) && [email protected]?(Index))", add the lines:
    # Dynamax
    cw.dButton = 0
    cw.dButton = 1 if (@battle.pbCanDynamax?(index) && [email protected]?(index) && [email protected]?(index) &&
    [email protected]?(index))
* Note that "[email protected]?(Index) && [email protected]?(Index))" should only be added if you have properly configured the Ultra Burst and
Z-Move, otherwise remove these commands!

Below, within "if Input.trigger?(Input::C) # Confirm choice" add the lines:
    if battler.effects [PBEffects::DButton]
      battler.effects [PBEffects::MaxMove1] += 1 if cw.index == 0
      battler.effects [PBEffects::MaxMove2] += 1 if cw.index == 1
      battler.effects [PBEffects::MaxMove3] += 1 if cw.index == 2
      battler.effects [PBEffects::MaxMove4] += 1 if cw.index == 3
    end
Within the "elsif Input.trigger?(Input::A) # Use Mega Evolution" command, add:
    if @ battle.pbCanDynamax?(index) # Use Dynamax
      battler.effects[PBEffects::DButton] = true
      battler.pbMaxMove
      @ battle.pbRegisterDynamax (index)
      pbPlayDecisionSE
      cw.dButton = 2
      pbUpdate
    end
And replace your "elsif Input.trigger?(Input :: B) # Cancel fight menu" with:
    elsif Input.trigger?(Input::B) # Cancel fight menu
      battler.effects[PBEffects::DButton] = false
      battler.pbUnMaxMove if! battler.isDynamax?
      @lastmove[index] = cw.index
      pbPlayCancelSE
      return -1
    end
In "def pbFainted(pkmn)" change:
    frames = pbCryFrameLength(pkmn.pokemon)
    pbPlayCry(pkmn.pokemon)
    frames.times do
      pbGraphicsUpdate
      pbInputUpdate
      pbFrameUpdate
    end
Per:
    # Dynamax Reversions if is fainted
    if @ battle.battlers[pkmn.index].isDynamax?
      @battle.battlers[pkmn.index].pbUndynamax
    else
      frames = pbCryFrameLength(pkmn.pokemon)
      pbPlayCry(pkmn.pokemon)
      frames.times do
        pbGraphicsUpdate
        pbInputUpdate
        pbFrameUpdate
      end
    end
To give Pokemon a boost to your HP you will need to create an attribute called Dynamax Level, add "attr_writer: dynamax_lvl at the start and then
search for "# Recalculates this Pokémon's stats.", swap for:
# Recalculates this Pokémon's stats.
  def calcStats
    nature=self.nature
    stats=[]
    pvalues??=[100,100,100,100,100]
    na5=(nature/5).floor
    nm5=(nature%5).floor
    if nd5!=nm5
      pvalues??[nd5]=110
      pvalues??[nm5]=90
    end
    level = self.level
    bs = self.baseStats
    for i in 0..5
      base = bs[i]
      if i==PBStats::HP
        stats[i]=calcHP(base,level,@iv[i],@ev[i])
      else
        stats[i]=calcStat(base,level,@iv[i],@ev[i],pvalues??[i-1])
      end
    end
    # Dynamax HP Boost
    if isDynamax?
      @totalhp=(stats[0]*pbDynamaxBoost).floor
      [email protected]@hp
      @hp=((@totalhp-diff)*pbDynamaxBoost).floor
      @hp=0 if @hp <= 0
      @[email protected] if @hp>@totalhp
    elsif isReversing?
      @totalhp=stats[0]
      @hp=(@hp/pbDynamaxBoost).floor
      @hp+1 if !self.isFainted? # Because complete the caltulation
      [email protected]@hp
      @hp=0 if @hp<=0
      @[email protected] if @hp>@totalhp
    else
      if! isReversing? # Original Essentials Calc for HP
        diff = @[email protected]
        @totalhp=stats[0]
        @[email protected]
        @hp=0 if @hp<= 0
        @[email protected] if @hp>@totalhp
      end
    end
    @attack=stats[1]
    @defense=stats[2]
    @speed=stats[3]
    @spatk=stats[4]
    @spdef=stats[5]
  end
Just below, add the lines:
################################################################################
# Dynamax Properties
################################################################################

  # Dynamax
  
  def makeDynamax
    @dynamax = true
    @needreverse = true
  end
  
  def makeUndynamax
    @dynamax = false
  end

  def isDynamax?
    return @dynamax
  end
  
  def hasGigantamax?
    return @gigantamax
  end
  
  def dynamax_lvl
    return @dynamax_lvl || 0
  end
  
  def pbReversing
    return @needreverse = false
  end
  
  def isReversing?
    if @needreverse
      return true
    end
    return false
  end
  
  def pbDynamaxBoost
    dynamaxboost=1.5+0.05*dynamax_lvl
  end
Okay, we have finished using Dynamax and its proper basic functions in battle.
Note that no individual move functions or items have been added to manipulate Dynamax Level. This will be done in another tutorial (maybe posted right here)

Now let's define the switch that will use to block the use of Dynamax. In Setings, find 'NO_MEGA_EVOLUTION' and place:
NO_DYNAMAX = XXX
Where 'XXX' is the switch number you want to block Dynamax activation

Okay, here we finish all the code!

Now let's create the Max Moves and Item Dynamax Band.
Navigate to the PBS folder and in 'move.txt' add the lines: (replace 'XXX' with the last numbar and and 'YYY' with the function of MoveEffectf personal move)
XXX,MAXFLARE,Max Flare,YYY,110,FIRE,Physical,100,10,0,00,0,,"This is a Fire-type attack Dynamax Pokémon use. The user intensifies the sun for five turns."
XXX,MAXFLUTTERBY,Max Flutterby,YYY,110,BUG,Physical,100,10,0,00,0,,"This is a Bug-type attack Dynamax Pokémon use. This lowers the target's Sp. Atk stat."
XXX,MAXLIGHTNING,Max Lightning,YYY,110,ELECTRIC,Physical,100,10,0,00,0,,"This is an Electric-type attack Dynamax Pokémon use. The user turns the ground into Electric Terrain for five turns."
XXX,MAXSTRIKE,Max Strike,YYY,110,NORMAL,Physical,100,10,0,00,0,,"This is a Normal-type attack Dynamax Pokémon use. This lowers the target's Speed stat."
XXX,MAXKNUCKLE,Max Knuckle,YYY,110,FIGHTING,Physical,100,10,0,00,0,,"This is a Fighting-type attack Dynamax Pokémon use. This raises ally Pokémon's Attack stats."
XXX,MAXPHANTASM,Max Phantasm,YYY,110,GHOST,Physical,100,10,0,00,0,,"This is a Ghost-type attack Dynamax Pokémon use. This lowers the target's Defense stat."
XXX,MAXHAILSTORM,Max Hailstorm,YYY,110,ICE,Physical,100,10,0,00,0,,"This is an Ice-type attack Dynamax Pokémon use. The user summons a hailstorm lasting five turns."
XXX,MAXOOZE,Max Ooze,YYY,110,POISON,Physical,100,10,0,00,0,,"This is a Poison-type attack Dynamax Pokémon use. This raises ally Pokémon's Sp. Atk stats."
XXX,MAXGEYSER,Max Geyser,YYY,110,WATER,Physical,100,10,0,00,0,,"This is a Water-type attack Dynamax Pokémon use. The user summons a heavy rain that falls for five turns."
XXX,MAXAIRSTREAM,Max Airstream,YYY,110,FLYING,Physical,100,10,0,00,0,,"This is a Flying-type attack Dynamax Pokémon use. This raises ally Pokémon's Speed stats."
XXX,MAXSTARFALL,Max Starfall,YYY,110,FAIRY,Physical,100,10,0,00,0,,"This is a Fairy-type attack Dynamax Pokémon use. The user turns the ground into Misty Terrain for five turns."
XXX,MAXWYRMWIND,Max Wyrmwind,YYY,110,DRAGON,Physical,100,10,0,00,0,,"This is a Dragon-type attack Dynamax Pokémon use. This lowers the target's Attack stat."
XXX,MAXMINDSTORM,Max Mindstorm,YYY,110,PSYCHIC,Physical,100,10,0,00,0,,"This is a Psychic-type attack Dynamax Pokémon use. The user turns the ground into Psychic Terrain for five turns."
XXX,MAXROCKFALL,Max Rockfall,YYY,110,ROCK,Physical,100,10,0,00,0,,"This is a Rock-type attack Dynamax Pokémon use. The user summons a sandstorm lasting five turns."
XXX,MAXQUAKE,Max Quake,YYY,110,GROUND,Physical,100,10,0,00,0,,"This is a Ground-type attack Dynamax Pokémon use. This raises ally Pokémon's Sp. Def stats."
XXX,MAXDARKNESS,Max Darkness,YYY,110,DARK,Physical,100,10,0,00,0,,"This is a Dark-type attack Dynamax Pokémon use. This lowers the target's Sp. Def stat."
XXX,MAXOVERGROWTH,Max Overgrowth,YYY,110,GRASS,Physical,100,10,0,00,0,,"This is a Grass-type attack Dynamax Pokémon use. The user turns the ground into Grassy Terrain for five turns."
XXX,MAXSTEELSPIKE,Max Steelspike,YYY,110,STEEL,Physical,100,10,0,00,0,,"This is a Steel-type attack Dynamax Pokémon use. This raises ally Pokémon's Defense stats."
XXX,MAXGUARD,Max Guard,YYY,0,NORMAL,Status,100,10,0,00,0,,"This is a Status category attack Dynamax Pokémon use. Protect against all move, include other Dynamax moves."
Regarding the item Dynamax Band, in 'items.txt' add: (replace 'XXX' with the last number)
XXX,DYNAMAXBAND,Dynamax Band,Dynamax Band's,8,0,"Allows the player's Pokémon to Dynamax and perform Max Moves.",0,0,6,
Here the Dynamax Button and Icon:


Credit Smogon's Project if you use this!

This tutorial was made in Version 17 of Essentials, may contain errors and if necessary some methods must be adapted to work in later or earlier versions.
If you use, please remember to give credit for: Me
And for support: WolfPP, Zeak, Vendily, MGriffin and Luka S.J
Male
Far, far away
Seen 2 Weeks Ago
Posted October 15th, 2020
29 posts
2.6 Years
Thanks for sharing!
However, I do have a question since it was rather difficult following all the steps and always asking yourself where exactly do you have to put it.
Anyway, for some reason I don't understand, I still get the following message:

Spoiler:

[Pokémon Essentials version 17.2]
Exception: NoMethodError
Message: undefined method `dButton=' for #<FightMenuDisplay:0xeaaef50>
PokeBattle_Scene:2499:in `pbFightMenu'
PokeBattle_Battle:2825:in `pbCommandPhase'
PokeBattle_Battle:2819:in `loop'
PokeBattle_Battle:2929:in `pbCommandPhase'
PokeBattle_Battle:2808:in `each'
PokeBattle_Battle:2808:in `pbCommandPhase'
PokeBattle_Battle:2745:in `pbStartBattleCore'
PokeBattle_Battle:2744:in `logonerr'
PokeBattle_Battle:2744:in `pbStartBattleCore'
PokeBattle_Battle:2734:in `loop'


I looked for every "dButton", but unless I misplaced it, it doesn't seem like I missed anyone.
Do you know what I missed or where my error lies?
I already have an icon for the item "dynamax band" and have a cursor_dynamax.

mgriffin

Seen 2 Weeks Ago
Posted 2 Weeks Ago
1,336 posts
6.6 Years
Spoiler:

[Pokémon Essentials version 17.2]
Exception: NoMethodError
Message: undefined method `dButton=' for #<FightMenuDisplay:0xeaaef50>
PokeBattle_Scene:2499:in `pbFightMenu'
PokeBattle_Battle:2825:in `pbCommandPhase'
PokeBattle_Battle:2819:in `loop'
PokeBattle_Battle:2929:in `pbCommandPhase'
PokeBattle_Battle:2808:in `each'
PokeBattle_Battle:2808:in `pbCommandPhase'
PokeBattle_Battle:2745:in `pbStartBattleCore'
PokeBattle_Battle:2744:in `logonerr'
PokeBattle_Battle:2744:in `pbStartBattleCore'
PokeBattle_Battle:2734:in `loop'
Maybe you need
attr_accessor :dButton
In the FightMenuDisplay class?
(But if that doesn't work you should wait for fauno, because I'm just guessing based on the code and the error message, I haven't tried making the change).
Male
Alola Reigon
Seen 7 Hours Ago
Posted 7 Hours Ago
491 posts
3.8 Years
Is the size change really necessary in the non-EBS version? The screen in already pretty crammed and then the Giant Sprites will make it much worse. I think a red semi-transparent cloud overlay might be better at conveying the Dynamax effect.

Gigantamax just requires a few extra checks in the hasDyanamax? part for Species of Pokémon and some more checks for the G-Max Moves in the Move AI & Player Move part (I can't code all this myself but I know fauno may be able to do this in a day or two)

Its amazing that in just a week of SwSh's release, a whole new system has been coded, and that to in such a way that everyone can use it (unlike the Z-Move Addon) so props to you fauno!
Male
Far, far away
Seen 2 Weeks Ago
Posted October 15th, 2020
29 posts
2.6 Years
Maybe you need
attr_accessor :dButton
In the FightMenuDisplay class?
(But if that doesn't work you should wait for fauno, because I'm just guessing based on the code and the error message, I haven't tried making the change).
Thanks for telling me! I already did that when I noticed that OP probably forgot to mention it. Now that I checked again, the only mistake I made was calling it dynamaxButton instead of dButton in attr_accessor.
Anyway, when I did that the error disappeared but I still can't seem to activate the dynamax function during a battle. The button for it doesn't appear either.
Let's see if OP knows anything about it.

fauno

Non-binary
Brazil
Seen 5 Days Ago
Posted July 29th, 2020
37 posts
3.1 Years
Thanks for telling me! I already did that when I noticed that OP probably forgot to mention it. Now that I checked again, the only mistake I made was calling it dynamaxButton instead of dButton in attr_accessor.
Anyway, when I did that the error disappeared but I still can't seem to activate the dynamax function during a battle. The button for it doesn't appear either.
Let's see if OP knows anything about it.
This is due to the fact that you did not include Dynamax maps in the required 'def', I said in the code that the system checks if the player is on a certain map that you set to enable the function, remove the lines in Dynamax battler:
In 'def pbCanDynamax?(index)'
return false if [email protected][index].hasDynamax?
and in 'def pbDynamax(index)':

return if !(@battlers[index].hasDynamax? rescue false)
for cancel that verification.

Soccersam

Hilbert is Badass

Male
Seen June 28th, 2020
Posted May 31st, 2020
177 posts
4.1 Years
I know this is off-topic, but I just had to ask- how on earth did you get the trainer to speak in-battle? I am guessing the question mark before the Weezing Dynamax form change was the trainer sprite, so how did you get it to speak during the battle? I've been looking around to implement this feature, but with no luck so far.
F.R.I.E.N.D.S.

fauno

Non-binary
Brazil
Seen 5 Days Ago
Posted July 29th, 2020
37 posts
3.1 Years
I know this is off-topic, but I just had to ask- how on earth did you get the trainer to speak in-battle? I am guessing the question mark before the Weezing Dynamax form change was the trainer sprite, so how did you get it to speak during the battle? I've been looking around to implement this feature, but with no luck so far.
Well, this code is not part of Dynamax as you know, I just customized it to use in my project, I believe there is some tutorial about it, you can include it inside 'Dynamax Battler' in 'PokeBattle_Battle'.

Soccersam

Hilbert is Badass

Male
Seen June 28th, 2020
Posted May 31st, 2020
177 posts
4.1 Years
Well, this code is not part of Dynamax as you know, I just customized it to use in my project, I believe there is some tutorial about it, you can include it inside 'Dynamax Battler' in 'PokeBattle_Battle'.
Well, yes, that's the thing. I can't find that tutorial/script anywhere, either here or in the RC forums, so I was wondering where you got your hands on that.
F.R.I.E.N.D.S.

Diegou18

Forever Chandelure lover.

Age 21
Male
Seen 1 Day Ago
Posted September 2nd, 2020
75 posts
2.7 Years
Hola necesito ayuda, al momento de usar el movimiento lo ejecuta como un movimiento normal, tengo equipada la DBAND, pero no aparece el cursor


sorry i can't english.
(This method was given by fauno. I only translated it to make it understandable for the guy of the post before mine).

Quita las líneas en Dinamax battler:

-Dentro de 'def pbCanDynamax?(index)' borra esto:
return false if [email protected][index].hasDynamax?
Y en 'def pbDynamax(index)' borra esto:
return if !(@battlers[index].hasDynamax? rescue false)

#Not Important

All hail the wishmaker

He/Him
Hoenn
Seen 14 Hours Ago
Posted 14 Hours Ago
829 posts
1 Years
Does this work for v17.2...
Last time I checked this i couldnt find some things and messaged u as pfrompallet...

fauno

Non-binary
Brazil
Seen 5 Days Ago
Posted July 29th, 2020
37 posts
3.1 Years
Does this work for v17.2...
Last time I checked this i couldnt find some things and messaged u as pfrompallet...
I created the script based on version 17, so probably some methods are different, just rename them if applicable. I don't usually look at my personal messages often.

#Not Important

All hail the wishmaker

He/Him
Hoenn
Seen 14 Hours Ago
Posted 14 Hours Ago
829 posts
1 Years
Ok, I copied the scripts the way you said but I am getting this error:
--------------------------------------
Script Pokebattle_Battler line 3535: SyntaxError occured
--------------------------------------
Please help...

#Not Important

All hail the wishmaker

He/Him
Hoenn
Seen 14 Hours Ago
Posted 14 Hours Ago
829 posts
1 Years
I got the same error im also confused
Could you just give your Scripts.rxdata file to us...
please...