Advertisement
cilerba

The Bro Codes v6

Mar 10th, 2024 (edited)
1,350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.22 KB | None | 0 0
  1. # ==========================================
  2. # The Bro Codes v6
  3. # ==========================================
  4. # Outputs the highest variable index of arguments 1-X in argument 0
  5.  
  6. # Usage:
  7. # pbHighestVar(var_out, vars...)
  8.  
  9. def pbHighestVar(*args)
  10.   # Store first variable argument before removing from Array
  11.   out_var = args[0]
  12.   args.delete_at(0)
  13.  
  14.   val = 0
  15.   i = 0
  16.   matches = []
  17.  
  18.   args.each do |var|
  19.     if $game_variables[var] > val
  20.       matches = [i]
  21.       val = $game_variables[var]
  22.     elsif $game_variables[var] == val
  23.       matches.push(i)
  24.     end
  25.     i += 1
  26.   end
  27.  
  28.   $game_variables[out_var] = args[matches[rand(matches.length)]]
  29. end
  30.  
  31. def pbMapLoop(x_offset)
  32.   $game_player.moveto($game_player.x + x_offset, $game_player.y)
  33.   $game_map.update
  34.   Graphics.frame_reset
  35.   Input.update
  36. end
  37.  
  38. class Game_Character
  39.  
  40.   def screen_z(height = 0)
  41.     return 0 if @character_name == "MTNSand"
  42.     return 999 if @always_on_top
  43.     z = screen_y_ground
  44.     if @tile_id > 0
  45.       begin
  46.         return z + (self.map.priorities[@tile_id] * 32)
  47.       rescue
  48.         raise "Event's graphic is an out-of-range tile (event #{@id}, map #{self.map.map_id})"
  49.       end
  50.     end
  51.     # Add z if height exceeds 32
  52.     return z + ((height > Game_Map::TILE_HEIGHT) ? Game_Map::TILE_HEIGHT - 1 : 0)
  53.   end
  54.  
  55. end
  56.  
  57. class Battle::Scene::PokemonDataBox < Sprite
  58.  
  59.   NAME_BASE_COLOR         = Color.new(72, 72, 72)
  60.   NAME_SHADOW_COLOR       = Color.new(184, 184, 184)
  61.   MALE_BASE_COLOR         = Color.new(48, 96, 216)
  62.   MALE_SHADOW_COLOR       = NAME_SHADOW_COLOR
  63.   FEMALE_BASE_COLOR       = Color.new(248, 88, 40)
  64.   FEMALE_SHADOW_COLOR     = NAME_SHADOW_COLOR
  65.  
  66.   def draw_level
  67.     pbDrawTextPositions(self.bitmap, [["Lv. ", @spriteBaseX + 140, 16, :left,
  68.                                      NAME_BASE_COLOR, NAME_SHADOW_COLOR, true]])
  69.        
  70.     pbDrawTextPositions(self.bitmap, [[@battler.level.inspect, @spriteBaseX + 166, 16, :left,
  71.                                      NAME_BASE_COLOR, NAME_SHADOW_COLOR, true]])
  72.   end
  73.  
  74.   def draw_name
  75.     # Sets the bitmap font to be small
  76.     pbSetSmallFont(self.bitmap)
  77.    
  78.     nameWidth = self.bitmap.text_size(@battler.name).width
  79.     nameOffset = 0
  80.     nameOffset = nameWidth - 116 if nameWidth > 116
  81.    
  82.     # Adds 'true' as the outline parameter
  83.     pbDrawTextPositions(self.bitmap, [[@battler.name, @spriteBaseX + 8 - nameOffset, 12, :left,
  84.                                        NAME_BASE_COLOR, NAME_SHADOW_COLOR, true]]
  85.     )
  86.   end
  87.  
  88.   def draw_gender
  89.     gender = @battler.displayGender
  90.     return if ![0, 1].include?(gender)
  91.     gender_text  = (gender == 0) ? _INTL("♂") : _INTL("♀")
  92.     base_color   = (gender == 0) ? MALE_BASE_COLOR : FEMALE_BASE_COLOR
  93.     shadow_color = (gender == 0) ? MALE_SHADOW_COLOR : FEMALE_SHADOW_COLOR
  94.     pbDrawTextPositions(self.bitmap, [[gender_text, @spriteBaseX + 126, 12, :left, base_color, shadow_color, true]])
  95.   end
  96.  
  97. end
  98.  
  99. # Returns false if party is full or no species are provided
  100. # Returns true if egg is successfully added
  101.  
  102. # Usage
  103. # Script command:
  104. #
  105. # $game_variables[10] = pbGrottoEgg(
  106. # :PIKACHU,
  107. # :JIGGLYPUFF
  108. # )
  109. def pbGrottoEgg(*species)
  110.   return false if $player.party_full?
  111.   return false if species.length == 0
  112.  
  113.   mon = species[rand(species.length)]
  114.   baby = GameData::Species.get(mon).get_baby_species(true, nil, nil)
  115.   pbGenerateEgg(baby, _I("Hidden Grotto"))
  116.  
  117.   egg = $player.last_party
  118.  
  119.   egg_moves = egg.species_data.egg_moves.clone
  120.  
  121.   index_a = rand(egg_moves.length)
  122.   move_a = egg_moves[index_a]
  123.   egg_moves.delete_at(index_a)
  124.  
  125.   index_b = rand(egg_moves.length)
  126.   move_b = egg_moves[index_b]
  127.  
  128.   egg.learn_move(move_a)
  129.   if rand(4) == 0
  130.     egg.learn_move(move_b)
  131.   end
  132.  
  133.   egg.shiny = true if rand(512) < 1
  134.   egg.ability_index = 2
  135.  
  136.   return true
  137. end
  138.  
  139. # Returns true if a party member has the matching ability
  140. def pbHasAbilityInParty?(check_ability = nil)
  141.   $player.party.each_with_index do |pkmn, i|
  142.     return true if pkmn.hasAbility?(check_ability)
  143.   end
  144.   return false
  145. end
  146.  
  147. # Returns true if player has a shiny in party
  148. def pbHasShinyInParty?
  149.   $player.party.each_with_index do |pkmn, i|
  150.     return true if pkmn.shiny?
  151.   end
  152.   return false
  153. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement