Individual Troop Battlebacks

Individual Troop Battlebacks
Version: 1


Introduction
This script allows game makers to give a specific Troop ID their own battleback and other stuff (hue, mirror, tone). I'm not sure what it would be useful for, actually.

Features
  • Give a specific troop ID their own battleback.
  • Set battleback file, hue, mirror and tone.

Screenshots
Image
Fighting Troop ID 1 in a modified grassland battleback.

Demo
No demo.

Script
  1. =begin
  2. ╔══════════════════════════════════════════════════════════════════════════════╗
  3. ║ Individual Troop Battleback                                                  ║
  4. ║ by PK8                                                                       ║
  5. ║ September 28th, 2009                                                         ║
  6. ║ http://rmvxp.com                                                             ║
  7. ╟──────────────────────────────────────────────────────────────────────────────╢
  8. ║ ■ Table of Contents                                                          ║
  9. ║ ├─ Author's Notes                - Line 16─18                                ║
  10. ║ ├─ Introduction & Description    - Line 20─23                                ║
  11. ║ ├─ Features                      - Line 25─27                                ║
  12. ║ ├─ How to Use                    - Line 29─38                                ║
  13. ║ ├─ Methods Aliased               - Line 40,41                                ║
  14. ║ └─ Thanks                        - Line 43,44                                ║
  15. ╟──────────────────────────────────────────────────────────────────────────────╢
  16. ║ ■ Author's Notes                                                             ║
  17. ║ This script was requested by a user in HBGames.org's IRC channel and I was   ║
  18. ║ interested in creating this script so... here you go!                        ║
  19. ╟──────────────────────────────────────────────────────────────────────────────╢
  20. ║ ■ Introduction & Description                                                 ║
  21. ║ This script allows game makers to give a specific Troop ID their own         ║
  22. ║ battleback and other stuff (hue, mirror, tone). I'm not sure what it would be║
  23. ║ useful for, actually.                                                        ║
  24. ╟──────────────────────────────────────────────────────────────────────────────╢
  25. ║ ■ Features                                                                   ║
  26. ║ ─ Give a specific troop ID their own battleback.                             ║
  27. ║ ─ Set battleback file, hue, mirror and tone.                                 ║
  28. ╟──────────────────────────────────────────────────────────────────────────────╢
  29. ║ ■ How to Use                                                                 ║
  30. ║ To give a troop ID their own battle theme, simply type this:                 ║
  31. ║ Troops_BB[id] = [file, hue, mirror, [red, green, blue, sat]]                 ║
  32. ║ file: Battleback Graphic name. (Should be in Graphics/Battlebacks directory) ║
  33. ║ hue:    Set battleback's hue.               [Min: 0 - Max: 360]              ║
  34. ║ mirror: Flip battleback horizontally?       [true or false]                  ║
  35. ║ red:    Set amount of red in battleback.    [Min: -255 - Max: 255]           ║
  36. ║ green:  Set amount of green in battleback.  [Min: -255 - Max: 255]           ║
  37. ║ blue:   Set amount of blue in battleback.   [Min: -255 - Max: 255]           ║
  38. ║ sat:    Set battleback saturation.          [Min: 0 - Max: 255 (grey)]       ║
  39. ╟──────────────────────────────────────────────────────────────────────────────╢
  40. ║ ■ Methods Aliased                                                            ║
  41. ║ ─ initialize of Spriteset_Battle                                             ║
  42. ╟──────────────────────────────────────────────────────────────────────────────╢
  43. ║ ■ Thanks                                                                     ║
  44. ║ ─ JoeYoung requested something like this in the HBGames.org's IRC channel.   ║
  45. ╚══════════════════════════════════════════════════════════════════════════════╝
  46. =end
  47.  
  48. #------------------------------------------------------------------------------
  49. # * Customise
  50. #------------------------------------------------------------------------------
  51. class PK8
  52.   Troops_BB = {} # Do not touch this.
  53.  
  54.   #       [id] = [Battleback, Hue, Flip, [Red, Green, Blue, Sat] ]
  55.   Troops_BB[1] = ["005-Beach01", 0, true, [0, 0, 0, 0]]
  56. end
  57.  
  58. #==============================================================================
  59. # ** Spriteset_Battle
  60. #------------------------------------------------------------------------------
  61. #  This class brings together battle screen sprites. It's used within
  62. #  the Scene_Battle class.
  63. #==============================================================================
  64. class Spriteset_Battle
  65.   alias_method(:pk8_troops_bb_initialize, :initialize)
  66.   def initialize
  67.     start_troop_battleback1
  68.     pk8_troops_bb_initialize
  69.     start_troop_battleback2
  70.   end
  71.  
  72.   #----------------------------------------------------------------------------
  73.   # * Start Troop BattleBack 1
  74.   #----------------------------------------------------------------------------
  75.   def start_troop_battleback1
  76.     PK8::Troops_BB.each_key { | i |
  77.     # If Troop ID equals the key.
  78.     if $game_temp.battle_troop_id == i
  79.       # If specified battleback File isn't nil or empty.
  80.       if PK8::Troops_BB[i][0] != nil and !PK8::Troops_BB[i][0].empty?
  81.         $game_temp.battleback_name = PK8::Troops_BB[i][0]
  82.       end
  83.       break
  84.     end }
  85.   end
  86.  
  87.   #----------------------------------------------------------------------------
  88.   # * Start Troop BattleBack 2
  89.   #----------------------------------------------------------------------------
  90.   def start_troop_battleback2
  91.     PK8::Troops_BB.each_key { | i |
  92.     # If Troop ID equals the key.
  93.     if $game_temp.battle_troop_id == i
  94.       # Sets Battleback's hue to 0 if nil.
  95.       PK8::Troops_BB[i][1] = 0 if PK8::Troops_BB[i][1] == nil
  96.       # If mirror is set to nil, sets it to false.
  97.       PK8::Troops_BB[i][2] = false if PK8::Troops_BB[i][2] == nil
  98.       # Sets tone to [0, 0, 0, 0] if battleback's tone is nil.
  99.       PK8::Troops_BB[i][3] = [0, 0, 0, 0] if PK8::Troops_BB[i][3] == nil
  100.       # Sets battleback's red tone to 0 if nil
  101.       PK8::Troops_BB[i][3][0] = 0 if PK8::Troops_BB[i][3][0] == nil
  102.       # Sets battleback's green tone to 0 if nil
  103.       PK8::Troops_BB[i][3][1] = 0 if PK8::Troops_BB[i][3][1] == nil
  104.       # Sets battleback's blue tone to 0 if nil
  105.       PK8::Troops_BB[i][3][2] = 0 if PK8::Troops_BB[i][3][2] == nil
  106.       # Sets battleback's saturation to 0 if nil
  107.       PK8::Troops_BB[i][3][3] = 0 if PK8::Troops_BB[i][3][3] == nil
  108.       # Changing Hue
  109.       @battleback_sprite.bitmap.hue_change(PK8::Troops_BB[i][1])
  110.       # Flipping battleback?
  111.       @battleback_sprite.mirror = PK8::Troops_BB[i][2]
  112.       # Changing Tone
  113.       @battleback_sprite.tone = Tone.new(PK8::Troops_BB[i][3][0],
  114.       PK8::Troops_BB[i][3][1], PK8::Troops_BB[i][3][2], PK8::Troops_BB[i][3][3])
  115.       break
  116.     end }
  117.   end
  118. end
Expand to see the code.


Instructions
Instructions are in the script.

FAQ
Awaiting question.

Compatibility
I'm not sure if it's compatible with any battle-related scripts or the SDK. Aliases Spriteset_Battle's initialize.

Credits and Thanks
JoeYoung for requesting something like this in HBGames.org's IRC channel.

Author's Notes
This script was requested by someone, I was interested, voila! :P

Terms and Conditions
Exclusive to RMVXP.com and HBGames.org.
OOOOOoooo, I like what youve done with this. This makes alot more options for battle backs, without having to make lots more, and it can be set for individual troops... SWEET!

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=68371