Advertisement
TechSkylander1518

Fluid Badges (v20, plug-and-play form)

Dec 19th, 2022
1,139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.37 KB | None | 0 0
  1. #The one thing this doesn't include is correcting the stat-boosting badge mechanic, because aliasing that was more hassle than it was
  2. #worth. (especially seeing as it's never used) If you want to include that, see the Stat Boosts (optional) section in Instructions.
  3.  
  4. class GameStats
  5.   alias oldinitialize initialize
  6.  
  7.   def initialize
  8.     oldinitialize
  9.     @times_to_get_badges           = {}   # Set with set_time_to_badge(number) in Gym Leader events
  10.   end
  11. end
  12.  
  13. class Player < Trainer
  14.   alias oldinitialize initialize
  15.  
  16.   def initialize(name, trainer_type)
  17.     oldinitialize(name, trainer_type)
  18.     @badges                = []
  19.   end
  20.  
  21.   # @return [Integer] the number of Gym Badges owned by the player
  22.   def badge_count
  23.     return @badges.length
  24.   end
  25.  
  26. end
  27.  
  28.  
  29. def pbGiveBadge(badge)
  30.   badgename = badge.to_s.capitalize
  31.   raise "#{badgename} Badge has no graphic" if !pbResolveBitmap("Graphics/Pictures/Trainer Card/#{badgename}")
  32.   $player.badges.push(badge)
  33. end
  34.  
  35. def pbHasBadge?(badge)
  36.   return $player.badges.include?(badge)
  37. end
  38.  
  39. def pbCheckHiddenMoveBadge(badge = -1, showmsg = true)
  40.   if (badge.is_a?(Integer))
  41.     return true if badge < 0   # No badge requirement
  42.   end
  43.   return true if $DEBUG
  44.   if (badge.is_a?(Symbol)) ? $player.badges.include?(badge) : $player.badge_count >= badge
  45.     return true
  46.   end
  47.   msg = (badge.is_a?(Symbol)) ? _INTL("Sorry, a new Badge is required.") : _INTL("Sorry, more Badges are required.")
  48.   pbMessage(msg) if showmsg
  49.   return false
  50. end
  51.  
  52. class PokemonTrainerCard_Scene
  53.   def pbDrawTrainerCardFront
  54.     overlay = @sprites["overlay"].bitmap
  55.     overlay.clear
  56.     baseColor   = Color.new(72, 72, 72)
  57.     shadowColor = Color.new(160, 160, 160)
  58.     totalsec = $stats.play_time.to_i
  59.     hour = totalsec / 60 / 60
  60.     min = totalsec / 60 % 60
  61.     time = (hour > 0) ? _INTL("{1}h {2}m", hour, min) : _INTL("{1}m", min)
  62.     $PokemonGlobal.startTime = pbGetTimeNow if !$PokemonGlobal.startTime
  63.     starttime = _INTL("{1} {2}, {3}",
  64.                       pbGetAbbrevMonthName($PokemonGlobal.startTime.mon),
  65.                       $PokemonGlobal.startTime.day,
  66.                       $PokemonGlobal.startTime.year)
  67.     textPositions = [
  68.       [_INTL("Name"), 34, 70, 0, baseColor, shadowColor],
  69.       [$player.name, 302, 70, 1, baseColor, shadowColor],
  70.       [_INTL("ID No."), 332, 70, 0, baseColor, shadowColor],
  71.       [sprintf("%05d", $player.public_ID), 468, 70, 1, baseColor, shadowColor],
  72.       [_INTL("Money"), 34, 118, 0, baseColor, shadowColor],
  73.       [_INTL("${1}", $player.money.to_s_formatted), 302, 118, 1, baseColor, shadowColor],
  74.       [_INTL("Pokédex"), 34, 166, 0, baseColor, shadowColor],
  75.       [sprintf("%d/%d", $player.pokedex.owned_count, $player.pokedex.seen_count), 302, 166, 1, baseColor, shadowColor],
  76.       [_INTL("Time"), 34, 214, 0, baseColor, shadowColor],
  77.       [time, 302, 214, 1, baseColor, shadowColor],
  78.       [_INTL("Started"), 34, 262, 0, baseColor, shadowColor],
  79.       [starttime, 302, 262, 1, baseColor, shadowColor]
  80.     ]
  81.     pbDrawTextPositions(overlay, textPositions)
  82.     x = 72
  83.     for i in 0...$player.badges.length
  84.       badge = $player.badges[i].to_s
  85.       @sprites["badge#{i}"] = IconSprite.new(x, 310, @viewport)
  86.       @sprites["badge#{i}"].setBitmap("Graphics/Pictures/Trainer Card/#{badge}")
  87.       x += 48
  88.     end
  89.     pbDrawImagePositions(overlay, imagePositions)
  90.   end
  91.  
  92. end
  93.  
  94.  
  95. MenuHandlers.add(:debug_menu, :set_badges, {
  96.   "name"        => _INTL("Set Badges"),
  97.   "parent"      => :player_menu,
  98.   "description" => _INTL("Toggle possession of Gym Badges."),
  99.   "effect"      => proc {
  100.     badgecmd = 0
  101.     loop do
  102.       badgecmds = []
  103.       badgecmds.push(_INTL("Give individual Badge"))
  104.       badgecmds.push(_INTL("Remove all"))
  105.       badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd)
  106.       break if badgecmd < 0
  107.       case badgecmd
  108.       when 0   # Give specific badge
  109.         badge = pbMessageFreeText("Give which Badge?",_INTL(""),false,20)
  110.         badge = badge.upcase
  111.         if pbResolveBitmap("Graphics/Pictures/Trainer Card/#{badge}")
  112.           pbGiveBadge(badge.to_sym)
  113.           pbMessage(_INTL("Gave the {1} Badge.", badge.capitalize))
  114.         else
  115.           pbMessage(_INTL("{1} Badge does not exist.", badge.capitalize))
  116.         end
  117.       when 1   # Remove all
  118.         $player.badges = []
  119.           pbMessage(_INTL("Cleared all Badges."))
  120.       end
  121.     end
  122.   }
  123. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement