The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Custom trainer battles

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Reply
 
Thread Tools
  #1    
Old March 10th, 2014 (9:42 AM). Edited March 16th, 2014 by Stochastic.
Stochastic's Avatar
Stochastic Stochastic is offline
     
    Join Date: Dec 2013
    Location: Croatia
    Gender: Male
    Posts: 168
    This is the script I made that enables you to make custom trainer battles without editing the trainers
    PBS file.

    How to use
    Make a new script in the script editor, name it however you like, say CustomTrainers
    and copy and paste this code inside.

    Spoiler:

    Code:
    # ------------------------------------------------------------------------------
    # Written by Stochastic, except for customTrainerBattle method which is a
    # modified version of pbTrainerBattle method.
    # ------------------------------------------------------------------------------
    
    BR_DRAW = 5
    BR_LOSS = 2
    BR_WIN = 1
    
    # ------------------------------------------------------------------------------
    # species - Name of the species, e.g. "PIKACHU"
    # level - Level
    # moveset - Optional. Array of moves, e.g. [:MUDSLAP, :THUNDERBOLT, :VINEWHIP]
    # If not specified, pokemon will be created with moves learned by leveling.
    # The pokemon doesn't need to be able to learn the given moves, they can be
    # arbitary.
    # ------------------------------------------------------------------------------
    def createPokemon(species, level, moveset=nil)
      begin
        poke = PokeBattle_Pokemon.new(species, level)
        poke.moves = convertMoves(moveset) if moveset
        poke.shinyflag = false
        return poke
      rescue
        return PokeBattle_Pokemon.new("PIKACHU", 5)
      end
    end
    
    def convertMoves(moves)
      moves.map! {|m| PBMove.new(getMoveID(m))}
      return moves
    end
    
    # provide move like this; :TACKLE
    def getMoveID(move)
      return getConst(PBMoves,move)
    end
    
    # ------------------------------------------------------------------------------
    # Creates a trainer with specified id, name, party, and optionally, items.
    # Does not depend on defined trainers, only on trainer types
    # ------------------------------------------------------------------------------
    def createTrainer(trainerid,trainername,party,items=[])
      
      name = pbGetMessageFromHash(MessageTypes::TrainerNames, trainername)
      opponent = PokeBattle_Trainer.new(name, trainerid)
      opponent.setForeignID($Trainer) if $Trainer
      opponent.party = party
      
      return [opponent,items,party]
    end
    
    # ------------------------------------------------------------------------------
    # Initiates trainer battle. This is a modified pbTrainerBattle method.
    #
    # trainer - custom PokeBattle_Trainer provided by the user
    # endspeech - what the trainer says in-battle when defeated
    # doublebattle - Optional. Set it to true if you want a double battle
    # canlose - Optional. Set it to true if you want your party to be healed after battle,
    and if you don't want to be sent to a pokemon center if you lose
    # ------------------------------------------------------------------------------
    def customTrainerBattle(trainer,endspeech,doublebattle=false,canlose=false)
      trainerparty=0 # added by SH
      if $Trainer.pokemonCount==0
        Kernel.pbMessage(_INTL("SKIPPING BATTLE...")) if $DEBUG
        return BR_LOSS # changed by SH
      end
      if !$PokemonTemp.waitingTrainer && $Trainer.ablePokemonCount>1 &&
         pbMapInterpreterRunning?
        thisEvent=pbMapInterpreter.get_character(0)
        triggeredEvents=$game_player.pbTriggeredTrainerEvents([2],false)
        otherEvent=[]
        for i in triggeredEvents
          if i.id!=thisEvent.id && !$game_self_switches[[$game_map.map_id,i.id,"A"]]
            otherEvent.push(i)
          end
        end
        if otherEvent.length==1
          if trainer[2].length<=3
            $PokemonTemp.waitingTrainer=[trainer,thisEvent.id,endspeech,doublebattle]
            return BR_LOSS # changed by SH
          end
        end
      end
      
      if $PokemonGlobal.partner && ($PokemonTemp.waitingTrainer || doublebattle)
        othertrainer=PokeBattle_Trainer.new(
           $PokemonGlobal.partner[1],$PokemonGlobal.partner[0])
        othertrainer.id=$PokemonGlobal.partner[2]
        othertrainer.party=$PokemonGlobal.partner[3]
        playerparty=[]
        for i in 0...$Trainer.party.length
          playerparty[i]=$Trainer.party[i]
        end
        for i in 0...othertrainer.party.length
          playerparty[6+i]=othertrainer.party[i]
        end
        fullparty1=true
        playertrainer=[$Trainer,othertrainer]
        doublebattle=true
      else
        playerparty=$Trainer.party
        playertrainer=$Trainer
        fullparty1=false
      end
      if $PokemonTemp.waitingTrainer
        combinedParty=[]
        fullparty2=false
        if false
          if $PokemonTemp.waitingTrainer[0][2].length>3
            raise _INTL("Opponent 1's party has more than three Pokémon, which is not allowed")
          end
          if trainer[2].length>3
            raise _INTL("Opponent 2's party has more than three Pokémon, which is not allowed")
          end
        elsif $PokemonTemp.waitingTrainer[0][2].length>3 || trainer[2].length>3
          for i in 0...$PokemonTemp.waitingTrainer[0][2].length
            combinedParty[i]=$PokemonTemp.waitingTrainer[0][2][i]
          end
          for i in 0...trainer[2].length
            combinedParty[6+i]=trainer[2][i]
          end
          fullparty2=true
        else
          for i in 0...$PokemonTemp.waitingTrainer[0][2].length
            combinedParty[i]=$PokemonTemp.waitingTrainer[0][2][i]
          end
          for i in 0...trainer[2].length
            combinedParty[3+i]=trainer[2][i]
          end
          fullparty2=false
        end
        scene=pbNewBattleScene
        battle=PokeBattle_Battle.new(scene,playerparty,combinedParty,playertrainer,
           [$PokemonTemp.waitingTrainer[0][0],trainer[0]])
        trainerbgm=pbGetTrainerBattleBGM(
           [$PokemonTemp.waitingTrainer[0][0],trainer[0]])
        battle.fullparty1=fullparty1
        battle.fullparty2=fullparty2
        battle.doublebattle=battle.pbDoubleBattleAllowed?()
        battle.endspeech=$PokemonTemp.waitingTrainer[2]
        battle.endspeech2=endspeech
        battle.items=[$PokemonTemp.waitingTrainer[0][1],trainer[1]]
      else
        scene=pbNewBattleScene
        battle=PokeBattle_Battle.new(scene,playerparty,trainer[2],playertrainer,trainer[0])
        battle.fullparty1=fullparty1
        battle.doublebattle=doublebattle ? battle.pbDoubleBattleAllowed?() : false
        battle.endspeech=endspeech
        battle.items=trainer[1]
        trainerbgm=pbGetTrainerBattleBGM(trainer[0])
      end
      if Input.press?(Input::CTRL) && $DEBUG
        Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
        Kernel.pbMessage(_INTL("AFTER LOSING..."))
        Kernel.pbMessage(battle.endspeech)
        Kernel.pbMessage(battle.endspeech2) if battle.endspeech2
        if $PokemonTemp.waitingTrainer
          pbMapInterpreter.pbSetSelfSwitch(
             $PokemonTemp.waitingTrainer[1],"A",true
          )
          $PokemonTemp.waitingTrainer=nil
        end
        return BR_WIN # changed by SH
      end
      Events.onStartBattle.trigger(nil,nil)
      battle.internalbattle=true
      pbPrepareBattle(battle)
      restorebgm=true
      decision=0
      pbBattleAnimation(trainerbgm,trainer[0].trainertype,trainer[0].name) { 
         pbSceneStandby {
            decision=battle.pbStartBattle(canlose)
         }
         if $PokemonGlobal.partner
           pbHealAll
           for i in $PokemonGlobal.partner[3]; i.heal; end
         end
         if decision==2 || decision==5
           if canlose
             for i in $Trainer.party; i.heal; end
             for i in 0...10
               Graphics.update
             end
           else
             $game_system.bgm_unpause
             $game_system.bgs_unpause
             Kernel.pbStartOver
           end
         else
           Events.onEndBattle.trigger(nil,decision)
           if decision==1
             if $PokemonTemp.waitingTrainer
               pbMapInterpreter.pbSetSelfSwitch(
                  $PokemonTemp.waitingTrainer[1],"A",true
               )
             end
           end
         end
      }
      Input.update
      $PokemonTemp.waitingTrainer=nil
      return decision  # changed by SH
    end


    To use it in the game, make a new event that looks like this:

    Spoiler:




    The game will enter the conditional branch if you won against the trainer, and that's where we
    activate the self switch A on. And here's the second page of the event.

    Spoiler:




    The script code:
    Spoiler:

    Code:
    p0 = createPokemon("KLANG", 38)
    p1 = createPokemon("VOLTORB", 39)
    p2 = createPokemon("RAICHU", 39)
    party = [p0, p1, p2]
    trainer = createTrainer(137, "Rashad", party)
    result = customTrainerBattle(trainer, "Oh no, you defeated me!")
    pbSet(1, result == BR_WIN ? 0 : 1)


    You can change the number of pokemon the trainer has, the species, levels, everything. Once you
    created a pokemon with createPokemon method, you can edit the pokemon's hp, IVs, EVs, stats,
    and anything else.

    For example, let's make a trainer that has only one pokemon, a pikachu, on level 13, and let's give
    that pikachu some HP IVs, and let's make his hp half of his total hp. We'll set the id of the trainer
    to 7, and make her name "Alice". The part of the event that changes is the script:

    Spoiler:

    Code:
    p0 = createPokemon("PIKACHU", 13)
    p0.iv[0] = 27
    p0.hp = p0.totalhp / 2
    party = [p0]
    trainer = createTrainer(7, "Alice", party)
    result = customTrainerBattle(trainer, "...")
    pbSet(1, result == BR_WIN ? 0 : 1)


    Hope this comes in handy in your game too. I'm using this system instead of the original one.
    No credits needed since half of the code is copied from essentials, but if you want, you can
    give me half a credit!
    __________________


    Reply With Quote

    Relevant Advertising!

      #2    
    Old March 10th, 2014 (10:26 AM).
    miniking's Avatar
    miniking miniking is offline
       
      Join Date: Jul 2013
      Location: São paulo,Brazil
      Gender: Male
      Nature: Adamant
      Posts: 41
      work fine *-*

      thanks for this
      olny descript the all funcions on your post for initials makers
      __________________
      Reply With Quote
        #3    
      Old March 10th, 2014 (8:59 PM).
      Joltik's Avatar
      Joltik Joltik is offline
         
        Join Date: Jan 2010
        Gender: Male
        Nature: Modest
        Posts: 126
        Would it be hard to implement a way for the trainer to use a random pokemon from a predefined array {pokemon1, pokemon2, pokemon3, ...}.

        Thank you!
        __________________

        Check out my DeviantArt account! My game project is called Pokemon Subrosia.
        My DeviantArt | Old DeviantArt
        Reply With Quote
          #4    
        Old March 11th, 2014 (4:17 AM).
        miniking's Avatar
        miniking miniking is offline
           
          Join Date: Jul 2013
          Location: São paulo,Brazil
          Gender: Male
          Nature: Adamant
          Posts: 41
          Quote:
          Originally Posted by Giu View Post
          Would it be hard to implement a way for the trainer to use a random pokemon from a predefined array {pokemon1, pokemon2, pokemon3, ...}.

          Thank you!
          Use too this parameters:
          number poke into other number and add exetions
          use a fix group in the script ex:(....Gorup1= 5,32,65,25... random pokemon Group1)
          by Type (random pokemon(::FIRE,::BUG))

          all with exceptions

          thank you

          wait update*-*
          __________________
          Reply With Quote
            #5    
          Old March 11th, 2014 (4:55 AM).
          Stochastic's Avatar
          Stochastic Stochastic is offline
             
            Join Date: Dec 2013
            Location: Croatia
            Gender: Male
            Posts: 168
            Quote:
            Originally Posted by Giu View Post
            Would it be hard to implement a way for the trainer to use a random pokemon from a predefined array {pokemon1, pokemon2, pokemon3, ...}.

            Thank you!
            Sure, it's not hard. Insert this method in the script.

            Code:
            # ------------------------------------------------------------------------------
            # Returns a random element from a given array.
            # ------------------------------------------------------------------------------
            def randomElement(array)
              i = rand(array.length)
              return array[i]
            end
            Then, in the event, instead of writing createPokemon("PIKACHU", 13) you can write
            createPokemon(randomElement(SomePool), 13), and you'll need to define 'SomePool',
            either in the event script or in a global script (such as CustomTrainers) as,
            Code:
            SomePool = ["PIKACHU", "BULBASAUR", "SOME_OTHER_POKEMON"]
            Quote:
            work fine *-*

            thanks for this
            olny descript the all funcions on your post for initials makers
            Sorry, I don't understand. Do you want me to describe functions better?
            __________________


            Reply With Quote
              #6    
            Old March 11th, 2014 (5:39 AM).
            miniking's Avatar
            miniking miniking is offline
               
              Join Date: Jul 2013
              Location: São paulo,Brazil
              Gender: Male
              Nature: Adamant
              Posts: 41
              Quote:
              Originally Posted by Stochastic View Post
              Sure, it's not hard. Insert this method in the script.

              Code:
              # ------------------------------------------------------------------------------
              # Returns a random element from a given array.
              # ------------------------------------------------------------------------------
              def randomElement(array)
                i = rand(array.length)
                return array[i]
              end
              Then, in the event, instead of writing createPokemon("PIKACHU", 13) you can write
              createPokemon(randomElement(SomePool), 13), and you'll need to define 'SomePool',
              either in the event script or in a global script (such as CustomTrainers) as,
              Code:
              SomePool = ["PIKACHU", "BULBASAUR", "SOME_OTHER_POKEMON"]


              Sorry, I don't understand. Do you want me to describe functions better?

              Who add random pokes by Type?
              you can send a script to implement this?
              And with exceptions
              Example:
              createPokemon(randomType(SomePoolFire), 13)

              SomePoolFire= [ (::FIRE);'charmander' , 'charmilion','charizand'] *This poke is the exception, can create all other pokes, ecept in "[...]"

              Can make this?
              thanks
              __________________
              Reply With Quote
                #7    
              Old March 11th, 2014 (12:02 PM).
              Stochastic's Avatar
              Stochastic Stochastic is offline
                 
                Join Date: Dec 2013
                Location: Croatia
                Gender: Male
                Posts: 168
                @miniking

                Here, I've written a snippet that gives you all fire pokemon. Put it anywhere inside a global script, say CustomTrainers.

                Code:
                def allFireTypes
                  dexdata=pbOpenDexData
                  ret = []
                  for i in 1...649
                    pbDexDataOffset(dexdata, i, 8)
                    type1 = dexdata.fgetb
                    pbDexDataOffset(dexdata, i, 9)
                    type2 = dexdata.fgetb
                    if (isConst?(type1, PBTypes, :FIRE) || isConst?(type2, PBTypes, :FIRE))
                      ret.push(getConstantName(PBSpecies, i))
                    end
                  end
                  return ret
                end
                And then, to remove some pokemon from the array, that are listed in some other
                array, use this (in an NPC event script, for example):

                Code:
                fire = allFireTypes()
                except = ["RESHIRAM", "CHARIZARD"]
                fire2 = fire.select {|p| !except.include?(p)}
                p(fire2)
                Array 'fire2' will contain all fire-type pokemon except for Reshiram and Charizard. You
                can customize this however you wish :]
                __________________


                Reply With Quote
                  #8    
                Old March 11th, 2014 (5:53 PM). Edited March 11th, 2014 by Dylanrockin.
                Dylanrockin's Avatar
                Dylanrockin Dylanrockin is offline
                That guy
                   
                  Join Date: May 2011
                  Age: 23
                  Gender: Male
                  Nature: Timid
                  Posts: 276
                  Is there a possible way to edit their EV's as well? Nevermind I got a syntax error upon starting up the game :L on line 14 for some reason :L
                  Reply With Quote
                    #9    
                  Old March 12th, 2014 (2:34 AM).
                  Stochastic's Avatar
                  Stochastic Stochastic is offline
                     
                    Join Date: Dec 2013
                    Location: Croatia
                    Gender: Male
                    Posts: 168
                    Quote:
                    Originally Posted by Dylanrockin View Post
                    Is there a possible way to edit their EV's as well? Nevermind I got a syntax error upon starting up the game :L on line 14 for some reason :L
                    Yep, you can change anything you like :] Take a look at PokeBattle_Pokemon. Whatever you see
                    here (after attr_accessor) is changeable.

                    Spoiler:

                    Code:
                      attr_reader(:totalhp)       # Current Total HP
                      attr_reader(:attack)        # Current Attack stat
                      attr_reader(:defense)       # Current Defense stat
                      attr_reader(:speed)         # Current Speed stat
                      attr_reader(:spatk)         # Current Special Attack stat
                      attr_reader(:spdef)         # Current Special Defense stat
                      attr_accessor(:iv)          # Array of 6 Individual Values for HP, Atk, Def,
                                                  #    Speed, Sp Atk, and Sp Def
                      attr_accessor(:ev)          # Effort Values
                      attr_accessor(:species)     # Species (National Pokedex number)
                      attr_accessor(:personalID)  # Personal ID
                      attr_accessor(:trainerID)   # 32-bit Trainer ID (the secret ID is in the upper
                                                  #    16 bits)
                      attr_accessor(:hp)          # Current HP
                      attr_accessor(:pokerus)     # Pokérus strain and infection time
                      attr_accessor(:item)        # Held item
                      attr_accessor(:itemRecycle) # Consumed held item (used in battle only)
                      attr_accessor(:itemInitial) # Resulting held item (used in battle only)
                      attr_accessor(:mail)        # Mail
                      attr_accessor(:fused)       # The Pokémon fused into this one
                      attr_accessor(:name)        # Nickname
                      attr_accessor(:exp)         # Current experience points
                      attr_accessor(:happiness)   # Current happiness
                      attr_accessor(:status)      # Status problem (PBStatuses) 
                      attr_accessor(:statusCount) # Sleep count/Toxic flag
                      attr_accessor(:eggsteps)    # Steps to hatch egg, 0 if Pokémon is not an egg
                      attr_accessor(:moves)       # Moves (PBMove)
                      attr_accessor(:ballused)    # Ball used
                      attr_accessor(:markings)    # Markings
                      attr_accessor(:obtainMode)  # Manner obtained:
                                                  #    0 - met, 1 - as egg, 2 - traded,
                                                  #    4 - fateful encounter
                      attr_accessor(:obtainMap)   # Map where obtained
                      attr_accessor(:obtainText)  # Replaces the obtain map's name if not nil
                      attr_accessor(:obtainLevel) # Level obtained
                      attr_accessor(:hatchedMap)  # Map where an egg was hatched
                      attr_accessor(:language)    # Language
                      attr_accessor(:ot)          # Original Trainer's name 
                      attr_accessor(:otgender)    # Original Trainer's gender:
                                                  #    0 - male, 1 - female, 2 - mixed, 3 - unknown
                                                  #    For information only, not used to verify
                                                  #    ownership of the Pokemon
                      attr_accessor(:abilityflag) # Forces the first/second/hidden (0/1/2) ability
                      attr_accessor(:genderflag)  # Forces male (0) or female (1)
                      attr_accessor(:natureflag)  # Forces a particular nature
                      attr_accessor(:shinyflag)   # Forces the shininess (true/false)
                      attr_accessor(:ribbons)     # Array of ribbons
                      attr_accessor :cool,:beauty,:cute,:smart,:tough,:sheen # Contest stats


                    So, for example, to change their EVs, you would say: pokemon.ev[0] = 125 (this will make their HP
                    evs be 125). The IVs and EVs are ordered like this: HP, Atk, Def, Speed, Sp Atk, and Sp Def

                    Is it a syntax error in my script? If so, what's on line 14? If it's in an event, make sure you typed
                    the script correctly.
                    __________________


                    Reply With Quote
                      #10    
                    Old March 16th, 2014 (6:42 AM).
                    Radical Raptr's Avatar
                    Radical Raptr Radical Raptr is offline
                    #BAMFPokemonNerd
                       
                      Join Date: Mar 2011
                      Location: everywhere
                      Age: 23
                      Gender: Male
                      Nature: Sassy
                      Posts: 1,118
                      First, this is amazing, and I finally got around to using it, and it should most definitly save me time, thank you.

                      Secondly, as for the syntax error, the part where you have the comment description thing, eg:

                      # ------------------------------------------------------------------------------
                      # species - Name of the species, e.g. "PIKACHU"
                      # level - Level
                      # moveset - Optional. Array of moves, e.g. [:MUDSLAP, :THUNDERBOLT, :VINEWHIP]
                      # If not specified, pokemon will be created with moves learned by leveling.
                      # The pokemon doesn't need to be able to learn the given moves, they can be
                      # arbitary.
                      # ------------------------------------------------------------------------------
                      you are missing the red, I noticed and changed it and it works fine - I don't know if that was the problem, but it happened to me before I changed it, but not after :P
                      __________________

                      ~My Deviantart - Litharreon Wiki - Litharreon Game Download~

                      Reply With Quote
                        #11    
                      Old March 18th, 2014 (2:32 PM).
                      joeyhugg's Avatar
                      joeyhugg joeyhugg is offline
                         
                        Join Date: Apr 2013
                        Gender: Male
                        Posts: 378
                        Some of the lines with comments do not have "#" symbols. I had line 62, but apparently some had others. An alternate way of commenting multiple lines is a "=begin" command and an "=end" command. "=end" goes at the end of the section you want commented.
                        __________________
                        This signature has been disabled.
                        Signature exceeds height limit.
                        Please review and fix the issues by reading the signature rules.

                        You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

                        Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
                        Reply With Quote
                          #12    
                        Old May 6th, 2014 (11:11 AM).
                        miniking's Avatar
                        miniking miniking is offline
                           
                          Join Date: Jul 2013
                          Location: São paulo,Brazil
                          Gender: Male
                          Nature: Adamant
                          Posts: 41
                          Who Make double batles with this script?
                          __________________
                          Reply With Quote
                            #13    
                          Old May 6th, 2014 (12:01 PM).
                          FlexxGaming's Avatar
                          FlexxGaming FlexxGaming is offline
                          Pokemon XY PC Edition Developer
                             
                            Join Date: May 2014
                            Gender: Male
                            Posts: 78
                            Ooooh this is really nifty! Definitely going to use it for when I start programming the Battle Maison!
                            __________________


                            [CENTER]
                            Reply With Quote
                              #14    
                            Old May 7th, 2014 (11:30 PM).
                            indieoutloud's Avatar
                            indieoutloud indieoutloud is offline
                               
                              Join Date: Apr 2014
                              Gender: Male
                              Posts: 56
                              Quote:
                              Originally Posted by miniking View Post
                              Who Make double batles with this script?
                              I second this. Are double battles possible?
                              Reply With Quote
                                #15    
                              Old May 10th, 2014 (9:43 AM).
                              Stochastic's Avatar
                              Stochastic Stochastic is offline
                                 
                                Join Date: Dec 2013
                                Location: Croatia
                                Gender: Male
                                Posts: 168
                                Quote:
                                Originally Posted by indieoutloud View Post
                                I second this. Are double battles possible?
                                Yes, add another argument (true) to the customTrainerBattle call.
                                So instead of

                                Code:
                                customTrainerBattle(trainer, "Oh no!")
                                Write

                                Code:
                                customTrainerBattle(trainer, "Oh no!", true)
                                And you have a double battle :] Also make sure your opponent
                                has an even number of pokemon.
                                __________________


                                Reply With Quote
                                  #16    
                                Old May 10th, 2014 (10:19 AM).
                                indieoutloud's Avatar
                                indieoutloud indieoutloud is offline
                                   
                                  Join Date: Apr 2014
                                  Gender: Male
                                  Posts: 56
                                  Quote:
                                  Originally Posted by Stochastic View Post
                                  Yes, add another argument (true) to the customTrainerBattle call.
                                  So instead of

                                  Code:
                                  customTrainerBattle(trainer, "Oh no!")
                                  Write

                                  Code:
                                  customTrainerBattle(trainer, "Oh no!", true)
                                  And you have a double battle :] Also make sure your opponent
                                  has an even number of pokemon.
                                  Hmm, maybe I'm doing something wrong but it didn't work for me. Here is the instance I tried it on.

                                  p0 = createPokemon("EKANS", 2)
                                  p1 = createPokemon("RATTATA", 3)
                                  party = [p0, p1]
                                  trainer = createTrainer(37, "Dillon", party)
                                  result = customTrainerBattle(trainer, "Maybe I was wrong.", true)
                                  pbSet(1, result == BR_WIN ? 0 : 1)

                                  When I tried it only Ekans was used.

                                  Cheers!

                                  indieoutloud
                                  Reply With Quote
                                    #17    
                                  Old May 10th, 2014 (10:46 AM).
                                  Stochastic's Avatar
                                  Stochastic Stochastic is offline
                                     
                                    Join Date: Dec 2013
                                    Location: Croatia
                                    Gender: Male
                                    Posts: 168
                                    Quote:
                                    Originally Posted by indieoutloud View Post
                                    Hmm, maybe I'm doing something wrong but it didn't work for me. Here is the instance I tried it on.

                                    p0 = createPokemon("EKANS", 2)
                                    p1 = createPokemon("RATTATA", 3)
                                    party = [p0, p1]
                                    trainer = createTrainer(37, "Dillon", party)
                                    result = customTrainerBattle(trainer, "Maybe I was wrong.", true)
                                    pbSet(1, result == BR_WIN ? 0 : 1)

                                    When I tried it only Ekans was used.

                                    Cheers!

                                    indieoutloud
                                    Make sure you also have two pokemon on your party.
                                    I've tested it just now and it should work.
                                    __________________


                                    Reply With Quote
                                      #18    
                                    Old May 10th, 2014 (1:54 PM).
                                    indieoutloud's Avatar
                                    indieoutloud indieoutloud is offline
                                       
                                      Join Date: Apr 2014
                                      Gender: Male
                                      Posts: 56
                                      Quote:
                                      Originally Posted by Stochastic View Post
                                      Make sure you also have two pokemon on your party.
                                      I've tested it just now and it should work.
                                      I feel silly haha. Totally looked over how many Pokemon I had. This is fantastic thanks!
                                      Reply With Quote
                                        #19    
                                      Old May 11th, 2014 (12:57 AM). Edited May 11th, 2014 by greenOak.
                                      greenOak greenOak is offline
                                         
                                        Join Date: Apr 2009
                                        Posts: 5
                                        Hmmm, I'm having quite a few a problems with the pokemons stats. I have the following script to define a pokemon:

                                        p0 = createPokemon("TYRANITAR",100)
                                        p0.natureflag=PBNatures::JOLLY
                                        p0.iv[1]=31
                                        p0.ev[1]=252 (I've also set this to zero while experimenting)

                                        party = [p0]
                                        trainer = createTrainer(1,"Camila",party)
                                        result = customTrainerBattle(trainer,"..")
                                        pbSet(1, result == BR_WIN ? 0 : 1)

                                        A jolly Tyranitar should have 304 attack with 0 Atk EVs and 367 Attack with 252 EVs at level 100. The game currently tells me Tyranitar's attack stat is less than 304 which is wrong.

                                        Looking into where essentials calculates a pokemons stats I saw the found formula:

                                        ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor

                                        Apparently ev>>2 is the binary right shift operator (not sure how exactly this works) which didn't really make sense to me as I always seen the formula with ev/4 in it.

                                        Changing the formula to ev/4, I get that a jolly Tyranitar with 0EV's has an attack stat of 304 as desired. However, with 252 attacking EVs I still get the attack stat being 304.

                                        Any idea what's going on?

                                        P.S. After reading a bit, ev>>2 should be equivalent to ev/4 if I understand correctly, and I changed the forumla back to ev>>2 and it still yields the correct 304 stat, so I'm not sure what I did wrong to get an attack stat less than 304 was about. Regardless, the problem with the EVs not doing anything still exists.
                                        Reply With Quote
                                          #20    
                                        Old May 11th, 2014 (1:46 AM).
                                        greenOak greenOak is offline
                                           
                                          Join Date: Apr 2009
                                          Posts: 5
                                          Go figure, after hours of struggling with this problem, I figured it 30 minutes after posting.

                                          Not sure if everyone else here figured this out, but its not mentioned in the previous posts so I'll post it anyways. Basically, the game doesn't recalculate a pokemon's stats after editing IVs, EVs, or natures. Thus, if you edit any of these outside the "createPokemon()" function, none of these changes will effect its battle stats in anyway. I verified this in battle with damage calculations.

                                          I easily solved this problem by just adding the line "pokemon.calcStats" (or in the case I posted above p0.calcStats) after editing all the other stuff.
                                          Reply With Quote
                                            #21    
                                          Old May 25th, 2014 (1:50 AM).
                                          Lusus's Avatar
                                          Lusus Lusus is offline
                                             
                                            Join Date: Jan 2013
                                            Location: Ljubljana
                                            Age: 19
                                            Gender: Other
                                            Nature: Lonely
                                            Posts: 1,405
                                            You should put the example trainer type to a 1-71 number because otherwise people trying the script out without changing it will get an error saying the trainer type doesn't exist (in the most complicated error possible)

                                            Scripts works fine and i will def use it in my Pokemon game(with credit of course) to save time making trainer battles.
                                            Reply With Quote
                                              #22    
                                            Old August 16th, 2014 (9:33 PM).
                                            J the Gamer's Avatar
                                            J the Gamer J the Gamer is offline
                                               
                                              Join Date: Aug 2014
                                              Location: United States,Iowa
                                              Age: 17
                                              Gender: Male
                                              Nature: Relaxed
                                              Posts: 31
                                              What program are you using for this because it looks unfamiliar
                                              __________________
                                              This signature has been disabled.
                                              Too tall!
                                              Please review and fix the issues by reading the signature rules.

                                              You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

                                              Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
                                              Reply With Quote
                                                #23    
                                              Old August 17th, 2014 (3:57 AM).
                                              Lusus's Avatar
                                              Lusus Lusus is offline
                                                 
                                                Join Date: Jan 2013
                                                Location: Ljubljana
                                                Age: 19
                                                Gender: Other
                                                Nature: Lonely
                                                Posts: 1,405
                                                Quote:
                                                Originally Posted by J the Gamer View Post
                                                What program are you using for this because it looks unfamiliar
                                                RPG Maker XP, you need to double click the event for it's properties to show up.
                                                Reply With Quote
                                                  #24    
                                                Old August 17th, 2014 (8:21 AM).
                                                J the Gamer's Avatar
                                                J the Gamer J the Gamer is offline
                                                   
                                                  Join Date: Aug 2014
                                                  Location: United States,Iowa
                                                  Age: 17
                                                  Gender: Male
                                                  Nature: Relaxed
                                                  Posts: 31
                                                  Quote:
                                                  Originally Posted by Roaming Murkrow View Post
                                                  RPG Maker XP, you need to double click the event for it's properties to show up.
                                                  Thanks I thought you might be using Microsoft Script
                                                  __________________
                                                  This signature has been disabled.
                                                  Too tall!
                                                  Please review and fix the issues by reading the signature rules.

                                                  You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

                                                  Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
                                                  Reply With Quote
                                                    #25    
                                                  Old August 17th, 2014 (8:22 AM).
                                                  J the Gamer's Avatar
                                                  J the Gamer J the Gamer is offline
                                                     
                                                    Join Date: Aug 2014
                                                    Location: United States,Iowa
                                                    Age: 17
                                                    Gender: Male
                                                    Nature: Relaxed
                                                    Posts: 31
                                                    And is it worth paying $70 to get
                                                    __________________
                                                    This signature has been disabled.
                                                    Too tall!
                                                    Please review and fix the issues by reading the signature rules.

                                                    You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

                                                    Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
                                                    Reply With Quote
                                                    Reply

                                                    Quick Reply

                                                    Join the conversation!

                                                    Create an account to post a reply in this thread, participate in other discussions, and more!

                                                    Create a PokéCommunity Account

                                                    Sponsored Links
                                                    Thread Tools

                                                    Posting Rules
                                                    You may not post new threads
                                                    You may not post replies
                                                    You may not post attachments
                                                    You may not edit your posts

                                                    BB code is On
                                                    Smilies are On
                                                    [IMG] code is On
                                                    HTML code is Off

                                                    Forum Jump


                                                    All times are GMT -8. The time now is 4:33 AM.