Advertiser Content
Male
Seen 3 Weeks Ago
Posted 4 Weeks Ago
153 posts
189 Days
Hello guys,

So I thought I was understanding this script but it proved me wrong, I tried this for a super long time and I can't manage to make it work.
My idea is if the dmg are more than the remaining hps of the target then the target should recover and change form except if the form is the last one.
I want the player to face a wild boss which would be really hard and this I make with a hypothetical ditto who would have learned the shape of different strong pokes.

    if damage>target.hp
          
          if target.form!=6
            target.form=(target.form+1)
            user.form=(target.form+1) #I also put this line because with all the tests I made I had the feeling that in some situations user works as target and the opposite.
            
            target.hp=1
          @battle.pbDisplay(_INTL("DITTO cures itself"))
          target.hp=target.totalhp
                  pbUpdate(true)
#without these below lines nothing is changing even with the above lines so I guess I need them but I don't understand what @pokemon refers at. 
        @battle.scene.pbChangePokemon(target,@pokemon)
        @battle.pbDisplay(_INTL("{1} changed to another Form!",pbThis))
        PBDebug.log("[Form changed] #{pbThis} changed to another Form!")
    
        end
        
      
    end
When I copied this code once and had only 2 different forms I managed to make it work and the poke was indeed changing from 1 to 2 and 2 to 1 each time but I had to use the same poke (in my tests 2 pichus, because I was affraid ditto's ability and move would create problems)

if anyone has ideas it would be awesome

thank you

Edit: I'll add some precision, with the above code, the variable seems to get implemented because the condition is verified 6 times and the pokemon is healed 6 times, however the form is never changing. I replaced "target" by "self" and it now works with my own poke. What is the word to talk about the opposite poke?
Male
Seen 3 Weeks Ago
Posted 4 Weeks Ago
153 posts
189 Days
Ok I solved it by doing this:

in pokebattle_battler under pbChekForm:
    #DITTO
    if isConst?(self.species,PBSpecies,:DITTO)
      if self.form>=2 && self.form!=4  
         if self.hp==1        
@battle.pbDisplay(_INTL("{1} survives!",pbThis))
          self.hp=self.totalhp
          @battle.pbDisplay(_INTL("{1} and recovers!",pbThis))
        self.form=(self.form+1); transformed=true
        @battle.pbDisplay(_INTL("{1} changed to another Form!",pbThis))
        end
      
      end
    end
    #
and in pokebattle_battler

    if damage>target.hp && isConst?(target.species,PBSpecies,:DITTO)
        if target.form>=2 && target.form!=4
         
      
          target.hp=1

 
        end
      
    end
to make it survive if it's a ditto of form 2





Then I did a new mutliform register and made it learn moves
MultipleForms.register(:DITTO,{
"onSetForm"=>proc{|pokemon,form|


moves=[
      :SURF,:ICEBEAM,:THUNDERBOLT,:AIRSLASH, #Mew
      :OVERHEAT,:PSYCHIC,:HYPERBEAM,:RECOVER, # Mewtwo
      :BLIZZARD,:BRAVEBIRD,:ROOST,:BRINE,  # Frost, Refrigerator
      :AIRSLASH,  # Fan
      :LEAFSTORM  # Mow, Lawnmower
   ]
   hasoldmove=-1


     
   if form>0


     newmove1 = moves[((form-2)*4)]  #this because the first form is number2
     newmove2 = moves[((form-2)*4)+1]
     newmove3 = moves[((form-2)*4)+2]
     newmove4 = moves[((form-2)*4)+3]
         # Try to learn the new form's special move
        pokemon.pbDeleteMoveAtIndex(0)
         pbLearnMove(pokemon,getID(PBMoves,newmove1),true)
        pokemon.pbDeleteMoveAtIndex(0)
         pbLearnMove(pokemon,getID(PBMoves,newmove2),true)
                 pokemon.pbDeleteMoveAtIndex(0)
         pbLearnMove(pokemon,getID(PBMoves,newmove3),true)
                 pokemon.pbDeleteMoveAtIndex(0)
         pbLearnMove(pokemon,getID(PBMoves,newmove4),true)
       
     
  
   end

}
})
this works nicely but I don't like the fact that it is telling which moves it is learning (it acts like it's my ditto, because of pbLearnMove) Is there a way to teach moves without using this function?
Male
Seen 3 Weeks Ago
Posted 4 Weeks Ago
153 posts
189 Days
solved this again with these lines
MultipleForms.register(:DITTO,{
"onSetForm"=>proc{|pokemon,form|


moves=[
      :SURF,:ICEBEAM,:THUNDERBOLT,:AIRSLASH, #Mew
      :OVERHEAT,:PSYCHIC,:HYPERBEAM,:RECOVER, # Mewtwo
      :BLIZZARD,:BRAVEBIRD,:ROOST,:BRINE,  # Frost, Refrigerator
      :AIRSLASH,  # Fan
      :LEAFSTORM  # Mow, Lawnmower
   ]



     
   if form>1




     for i in 0...4
       newmove = getID(PBMoves,(moves[((form-2)*4)+i]))
       
          pokemon.moves[i]=PBMove.new(newmove) # Replaces current/total PP
          pokemon.moves[i]=PokeBattle_Move.pbFromPBMove(self,pokemon.moves[i])
       
        end
        update=true
  
   end

}
})
the problem I now have (and actually I had it before already is that these changes on form change are occuring only once. even though my ditto is changing forms many times it keeps the moveset of form 2

any ideas?
Male
Seen 3 Weeks Ago
Posted 4 Weeks Ago
153 posts
189 Days
  def pbUpdate(fullchange=false)
    if @pokemon
      @pokemon.calcStats
      @level     = @pokemon.level
      @hp        = @pokemon.hp
      @totalhp   = @pokemon.totalhp
      @moves     = @pokemon.moves #added this line in pokebattle_battler on line 487
and now it kinda worked but i have this error message
---------------------------
Pokemon Essentials
---------------------------
[Pokémon Essentials version 17.2]

Exception: NoMethodError

Message: undefined method `pbDisplayBrief' for nil:NilClass

PokeBattle_Move:1296:in `pbDisplayUseMessage'

PokeBattle_Battler:3036:in `pbUseMove'

PokeBattle_Battler:3400:in `pbProcessTurn'

PokeBattle_Battler:3399:in `logonerr'

PokeBattle_Battler:3399:in `pbProcessTurn'

PokeBattle_Battle:2829:in `pbAttackPhase'

PokeBattle_Battle:2826:in `each'

PokeBattle_Battle:2826:in `pbAttackPhase'

PokeBattle_Battle:2814:in `times'

PokeBattle_Battle:2814:in `pbAttackPhase'



This exception was logged in 

C:\Users\Gwen\Saved Games\Pokemon Essentials\errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK   
---------------------------
which didn't close the game and so I could see the moves being updated
Male
Seen 3 Weeks Ago
Posted 4 Weeks Ago
153 posts
189 Days
SOLVED!

added this
     self.moves[i]=PokeBattle_Move.pbFromPBMove(
    @battle,PBMove.new(self.moves[i].id))
    end
in def pbupdate in pokebattle_battler

guess it now checks its own moves. So if someone is interested my pbupdate script looks like this now:

  def pbUpdate(fullchange=false)
    if @pokemon
      @pokemon.calcStats
      @level     = @pokemon.level
      @hp        = @pokemon.hp
      @totalhp   = @pokemon.totalhp
      #added everything between this
      @moves     = @pokemon.moves
    for i in 0...4
     self.moves[i]=PokeBattle_Move.pbFromPBMove(
    @battle,PBMove.new(self.moves[i].id))
    end
 #and this which forces the transformed=true to check the moves
      if !@effects[PBEffects::Transform]
        @attack    = @pokemon.attack
        @defense   = @pokemon.defense
        @speed     = @pokemon.speed
        @spatk     = @pokemon.spatk
        @spdef     = @pokemon.spdef
        if fullchange
          @ability = @pokemon.ability
          @type1   = @pokemon.type1
          @type2   = @pokemon.type2
        end
      end
    end
  end
Advertiser Content