• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Dynamic Trainer Card

68
Posts
3
Years
    • Age 35
    • Seen today
    Hello,

    My name is SpeedyAggron and I have recently started to plan my semi open-world fan game. Before I continued with the details, I wanted to make sure certain aspects needed to work. Those are level scaling based on the number of gym badges and a trainer cards that changes depending on the order of the earned badges. I was successful after some trial and error and I want to share these with this forum. You'll need to edit in several places, but the changes are surprisingly simple. I use the BW Essentials version, so some details can be different.

    1. First you have to split up the badges image file in the 'Pictures\Trainer Card' folder. Every gym badge needs to have the same size and a simple file name such as "badgeGrass".

    2. We follow with defining an array at the 'Settings' section in the script editor with empty string values that will represent your badges. In my case there will be twenty, so you can change this to the total of badges your region has.

    Code:
    #===============================================================================
    # * An array that sets the order of the gym badges.
    #===============================================================================
    BADGEORDER = ["","","","","","","","","","","","","","","","","","","",""]

    3. Next up is to fill in this array and this happens when you have defeated a gym leader in the second tab of the event. Here you insert the value of the filename of his badge after you added the badge total. You can place them in a cluster of conditional branches based on the order you want to beat the gym leaders. In my example you can choose between the second, third and fourth gym leaders.

    Gym event example.png

    4. The final step is to add this to the trainer card using the array. You simply replace the section where the badges will be displayed with this snippet in the Trainer Card script. This is based on the script to have multiple rows of badges so it will change from your situation. The x and y positions will differ for your trainer card off course and the array will be used to insert all the different badge images.

    Code:
        x=5
        y=605
        imagePositions=[]
        for j in 0...2
          for i in 0...10
            if $Trainer.badges[i+j*10]
              imagePositions.push(["Graphics/Pictures/TrainerCard/"+BADGEORDER[i+j*10],x,y,0,0,50,50])
            end
            x+=50
          end
          x=5
          y+=50
        end

    5. Now that we have our dynamic trainer card, we also need to make the levels of the trainers increase according to the amount of badges we have. For this to work, I have modified this script so the levels won't randomly increase. The levels are pulled from the Trainers.txt file and you can change the level gaps between gym leaders. With this, you won't need clusters of conditional branches and several versions of the same trainer in Trainers.txt. You just need to place the script above 'Main' in the editor and it will automatically change.

    Code:
    GYME4_TEAM_LIST = [
      :LEADER_Cilan,
      :LEADER_Cress,
      :LEADER_Chili,
    ]
    
    Events.onTrainerPartyLoad+=proc {|sender,e|
       if e[0] # Trainer data should exist to be loaded, but may not exist somehow
         trainer=e[0][0] # A PokeBattle_Trainer object of the loaded trainer
         items=e[0][1]   # An array of the trainer's items they can use
         party=e[0][2]   # An array of the trainer's Pokémon
      # Gym Leader / E4 Battles 
      ids=GYME4_TEAM_LIST
      balance=false
        ids.each{|item|balance|=isConst?(trainer.trainertype,PBTrainers,item)
         }
          if balance
            party.each{|poke|
               mean = poke.level if $Trainer.numbadges == 0
               mean = poke.level+2 if $Trainer.numbadges == 1
               mean = poke.level+4 if $Trainer.numbadges == 2
               mean = poke.level+6 if $Trainer.numbadges == 3
            level=mean
               poke.level=level
               poke.calcStats
           }
          end
       end
    }

    I hope this will help people with problems implementing open world fan games. If you find any improvements with if clusters or other aspects, please inform me.

    EDIT: I edited step 5 to be more like the original balancer script now that I understand it better. I also forgot to add calcStats in the previous version, so I apologize for people who tried to test that.
     
    Last edited:
    68
    Posts
    3
    Years
    • Age 35
    • Seen today
    Over a year has passed since I posted this thread, but I wanted to address the fact that the badges in the trainer card won't be remembered when you save and quit. At this point, I have upgraded my game to V19, but not too much has changed compared to the old script. I still use the array BADGEORDER in the settings class and the gym leader events plus the code in the trainercard need small edits. I now use the customizable method Events.onTrainerPartyLoad in the class Overworld_EncounterModifiers for easier access in the trainer parties. The only major change is how I call the data before I can compare the current map to the ones in the arrays.

    Code:
    firstisland_scaling = []
    secondisland_scaling = []
    postgame_scaling = []
    
    Events.onTrainerPartyLoad += proc { |_sender, trainer|
      if trainer   # An NPCTrainer object containing party/items/lose text, etc.
        party = trainer[0].party
        mapid = $game_map.map_id
        party.each{|poke|
          if firstisland_scaling.include?(mapid)
            poke.level += 4 if $Trainer.badge_count == 2
            poke.level += 8 if $Trainer.badge_count == 3
            poke.level += 12 if $Trainer.badge_count >= 4
          else
            if secondisland_scaling.include?(mapid)
              poke.level += 3 if $Trainer.badge_count == 5
              poke.level += 6 if $Trainer.badge_count == 6
              poke.level += 9 if $Trainer.badge_count == 7
              poke.level += 12 if $Trainer.badge_count == 8
              poke.level += 15 if $Trainer.badge_count == 9
              poke.level += 18 if $Trainer.badge_count >= 10
            else
              if postgame_scaling.include?(mapid)
    
              end
            end
          end
          poke.calc_stats
        } 
      end
    }

    Now that everything has been updated to V19, there is an additional sixth step required to remember the data in BADGEORDER. For this you'll need to add extra code in the class Game_SaveValues, so make sure you have an extra backup before you edit. All you need to do is add this code at the end, but you'll need to restart your save since it will be corrupted.

    Code:
    SaveData.register(:badge_order) do
      load_in_bootup
      ensure_class :Array
      save_value { $badge_order }
      load_value { |value| $badge_order = value }
      new_game_value { Settings::BADGEORDER }
    end

    The only changes left to make is to replace every mention of BADGEORDER in the events or script and replace it with $badge_order. This makes the script very adaptable and you can have many possibilities depending on your if-clusters.

    You can even edit Marin's Fancy Badges script with this so you can have the badge animations in different orders. You can just delete the config.rb file and inside script.rb, you'll need to replace "FancyBadges::NAMES[badge_number]" with "$badge_order[badge_number]". A few lines below you can replace "bmp = pbBitmap("Graphics/Transitions/getBadge#{badge_number}")" with "bmp = pbBitmap("Graphics/Transitions/"+$badge_order[badge_number])". I don't know if other scripts can be adjusted by my method, so feel free to try if you have any ideas.
     
    Back
    Top