Advertisement
AngryPacman

PAC Utility 1.6

Jul 29th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.38 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Pacman Advanced Creative (PAC) Engine - Utility Engine v1.6
  4. # Updated 15/6/2011
  5. # Type: Utility
  6. # Installation: Configuration, script calls, tags.
  7. # Level: Simple, Average
  8. #
  9. #===============================================================================
  10. #
  11. # Hi! This is the PAC Utility Engine, designed to give the user more control
  12. # over menial things in their game. You'll find quite a few features in here,
  13. # but not nearly as many as PAC Battle Addons. The reason the engine is in
  14. # bulk now is simply for organization's sake, and to give you, the user, all
  15. # the instructions and configurables of the features in one place. So, with
  16. # the administrative side out of the way, I'll give you some instructions on
  17. # what to do with this script.
  18. #
  19. #===============================================================================
  20. #
  21. # INSTALLATION
  22. # Paste this script anywhere below materials and above main in the script editor
  23. # (F11) of your game. Read the instructions below on how to use the Utility
  24. # Engine.
  25. #
  26. #===============================================================================
  27. #
  28. # SCRIPT CALLS AND TAGS
  29. # $game_system.skin = 'File name'
  30. # Use a script call with this syntax to change the current in-game windowskin.
  31. # File extensions may be ommited. Example:
  32. # $game_system.skin = 'Red'
  33. # Will change the windowskin to the file named 'Red' in the Graphics\System
  34. # folder.
  35. #
  36. #===============================================================================
  37. #
  38. # INSTRUCTIONS AND CONFIGURATION
  39. # Follow the instructions beside each configurable to alter the engine to your
  40. # liking. Make sure you read through everything to use the engine to the
  41. # maximum capacity.
  42. #
  43. #===============================================================================
  44.  
  45. module PAC
  46.   module UTILITY
  47.  
  48. #===============================================================================
  49. # BEGIN EDITING
  50. #===============================================================================
  51.  
  52. RECOVER_HEALTH = true   # Recover health on level up?
  53. RECOVER_MAGIC = true    # Recover MP on level up?
  54. RECOVER_STATES = true   # Recover states on level up?
  55. GOLD_VARIANCE = 24      # Variance (+/-) the gold can change for all enemies.
  56. BATTLE_HEAL_HP = 10     # Heal x% health after each battle.
  57. BATTLE_HEAL_MP = 10     # Heal x% MP after each battle.
  58. BATTLE_HEAL_STATES = false    # Heal all states after each battle?
  59. USE_FIX = true  # If you must, set this to false to not use the system.
  60. # Prefixes used for enemies of which there are more than one of. Syntax:
  61. # LETTER_TABLE = [' Prefix', ' Prefix2', ' Prefix3']
  62. LETTER_TABLE = [' 1', ' 2', ' 3', ' 4', ' 5', ' 6', ' 7', ' 8', ' 9', ' 10',
  63.                 ' 11', ' 12', ' 13', ' 14', ' 15', ' 16', ' 17', ' 18',
  64.                 ' 19', ' 20', ' 21', ' 22', ' 23', ' 24', ' 25', '26']
  65. BB_TYPE = 2   # Type of battleback feature used. 1 or 2, 0 for none.
  66.    
  67. #===============================================================================
  68. # This section of config is only used if BB_TYPE is set to 1.
  69. #===============================================================================
  70.  
  71. BB_DIRECTORY = "Graphics/Battlebacks/"# Directory of the battlebacks.
  72. BB_MAPS = {                           # Hash to change battleback for maps:
  73. 1 => "Grassland",                     # BB_MAPS = {
  74. }   # Don't touch this.               # MAPID => "Battleback Name",
  75. BB_TEST = "Grassland"                 # Battleback used in battle test.
  76. CREATE_FLOOR = true                   # Create battle floor?
  77.    
  78. #===============================================================================
  79. # This section of config is only used if BB_TYPE is set to 2.
  80. #===============================================================================
  81.    
  82. WIDTH  = 640          # Width of the battleback.
  83. HEIGHT = 480          # Height of the battleback.
  84. BLUR_INTENSITY = 1    # Intensity of blur (higher = possible lag)
  85. FLOOR_X = 0           # X-coordinate of floor.
  86. FLOOR_Y = 192         # Y-coordinate of floor.
  87. FLOOR_O = 128         # Opacity of floor.
  88. CREATE_FLOOR = true   # Create battle floor?
  89.  
  90. #===============================================================================
  91. # END EDITING
  92. #===============================================================================
  93.  
  94.   end
  95. end
  96. #==============================================================================
  97. # ** Game_Actor
  98. #------------------------------------------------------------------------------
  99. #  This class handles actors. It's used within the Game_Actors class
  100. # ($game_actors) and referenced by the Game_Party class ($game_party).
  101. #==============================================================================
  102.  
  103. class Game_Actor < Game_Battler
  104.   #--------------------------------------------------------------------------
  105.   # alias listing
  106.   #--------------------------------------------------------------------------
  107.   alias pac_level_up level_up
  108.   #--------------------------------------------------------------------------
  109.   # * Level Up
  110.   #--------------------------------------------------------------------------
  111.   def level_up
  112.     pac_level_up
  113.     @hp = maxhp if PAC::UTILITY::RECOVER_HEALTH
  114.     @mp = maxmp if PAC::UTILITY::RECOVER_MAGIC
  115.     if PAC::UTILITY::RECOVER_STATES
  116.       @states.clone.each {|i| remove_state(i) }
  117.     end
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # * After battle heal
  121.   #--------------------------------------------------------------------------
  122.   def battle_heal
  123.     if PAC::UTILITY::BATTLE_HEAL_STATES
  124.       for state in states do remove_state(state.id) end
  125.     end
  126.     return if dead?
  127.     self.hp += maxhp * PAC::UTILITY::BATTLE_HEAL_HP / 100
  128.     self.mp += maxmp * PAC::UTILITY::BATTLE_HEAL_MP / 100
  129.   end
  130. end
  131.  
  132. #==============================================================================
  133. # ** Game_Enemy
  134. #------------------------------------------------------------------------------
  135. #  This class handles enemy characters. It's used within the Game_Troop class
  136. # ($game_troop).
  137. #==============================================================================
  138.  
  139. class Game_Enemy < Game_Battler
  140.   #--------------------------------------------------------------------------
  141.   # alias listing
  142.   #--------------------------------------------------------------------------
  143.   alias initialize_ae initialize unless $@
  144.   #--------------------------------------------------------------------------
  145.   # * Get Gold
  146.   #--------------------------------------------------------------------------
  147.   def gold
  148.     default_gold = enemy.gold
  149.     variation = PAC::UTILITY::GOLD_VARIANCE
  150.     lower = Integer(default_gold * (100 - variation) / 100)
  151.     upper = Integer(default_gold * (100 + variation) / 100)
  152.     value = lower + rand(upper - lower + 1)
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # * Object Initialization
  156.   #--------------------------------------------------------------------------
  157.   def initialize(index, enemy_id)
  158.     if $data_enemies[enemy_id].swaps != []
  159.       swaps = $data_enemies[enemy_id].swaps
  160.       enemy_id = swaps[rand(swaps.size)]
  161.     end
  162.     initialize_ae(index, enemy_id)
  163.   end
  164. end
  165.  
  166. #==============================================================================
  167. # ** Scene_Battle
  168. #------------------------------------------------------------------------------
  169. #  This class performs battle screen processing.
  170. #==============================================================================
  171.  
  172. class Scene_Battle < Scene_Base
  173.  
  174.   alias pac_hab_battle_end battle_end unless $@
  175.   def battle_end(result)
  176.     pac_hab_battle_end(result)
  177.     if result != 2
  178.       for member in $game_party.members
  179.         member.battle_heal
  180.       end
  181.     end
  182.   end
  183. end
  184.  
  185. #==============================================================================
  186. # ** Game_Troop
  187. #------------------------------------------------------------------------------
  188. #  This class handles enemy groups and battle-related data. Also performs
  189. # battle events. The instance of this class is referenced by $game_troop.
  190. #==============================================================================
  191.  
  192. class Game_Troop < Game_Unit
  193.   #--------------------------------------------------------------------------
  194.   # Letter Table
  195.   #--------------------------------------------------------------------------
  196.   if PAC::UTILITY::USE_FIX == true  # If use table system...
  197.     LETTER_TABLE = PAC::UTILITY::LETTER_TABLE
  198.   else  # If no system...
  199.     LETTER_TABLE = ['']
  200.   end
  201. end
  202.  
  203. #==============================================================================
  204. # ** Game_System
  205. #------------------------------------------------------------------------------
  206. #  This class handles system-related data. Also manages vehicles and BGM, etc.
  207. # The instance of this class is referenced by $game_system.
  208. #==============================================================================
  209.  
  210. class Game_System
  211.   #-----------------------------------------------------------------------------
  212.   # public instance variables
  213.   #-----------------------------------------------------------------------------
  214.   attr_accessor :battleback if PAC::UTILITY::BB_TYPE == 1
  215.   #-----------------------------------------------------------------------------
  216.   # alias listing
  217.   #-----------------------------------------------------------------------------
  218.   alias pac_initialize initialize
  219.   #--------------------------------------------------------------------------
  220.   # * Object Initialization
  221.   #--------------------------------------------------------------------------
  222.   def initialize
  223.     pac_initialize
  224.     @battle_back = nil if PAC::UTILITY::BB_TYPE == 1
  225.   end
  226. end
  227.  
  228. #===============================================================================
  229. #
  230. # PAC BATTLEBACK SYSTEM
  231. #
  232. #===============================================================================
  233.  
  234. if PAC::UTILITY::BB_TYPE == 1 # Run ABB.
  235.  
  236. #==============================================================================
  237. # ** Cache
  238. #------------------------------------------------------------------------------
  239. #  This module loads each of graphics, creates a Bitmap object, and retains it.
  240. # To speed up load times and conserve memory, this module holds the created
  241. # Bitmap object in the internal hash, allowing the program to return
  242. # preexisting objects when the same bitmap is requested again.
  243. #==============================================================================
  244.  
  245. module Cache
  246.   #--------------------------------------------------------------------------
  247.   # * Get Battleback Graphic
  248.   #     filename : Filename
  249.   #--------------------------------------------------------------------------
  250.   def self.battleback(filename)
  251.     load_bitmap(PAC::UTILITY::BB_DIRECTORY, filename)
  252.   end
  253. end
  254.  
  255. #==============================================================================
  256. # ** Spriteset_Battle
  257. #------------------------------------------------------------------------------
  258. #  This class brings together battle screen sprites. It's used within the
  259. # Scene_Battle class.
  260. #==============================================================================
  261.  
  262. class Spriteset_Battle
  263.   #--------------------------------------------------------------------------
  264.   # alias listing
  265.   #--------------------------------------------------------------------------
  266.   alias pac_abb_create_battleback create_battleback
  267.   alias pac_abb_create_battlefloor create_battlefloor
  268.  
  269.   #--------------------------------------------------------------------------
  270.   # * Create Battleback Sprite
  271.   #--------------------------------------------------------------------------
  272.   def create_battleback
  273.     if $BTEST # If Battletest
  274.       if PAC::UTILITY::BB_TEST != nil # If BB_TEST is set
  275.         @battleback_sprite = Sprite.new(@viewport1)
  276.         @battleback_sprite.bitmap = Cache.battleback(PAC::UTILITY::BB_TEST)
  277.         return
  278.       else
  279.         pac_abb_create_battleback # The usual.
  280.       end
  281.     end
  282.     if $game_system.battleback != nil # If battleback is set...
  283.       @battleback_sprite = Sprite.new(@viewport1)
  284.       @battleback_sprite.bitmap = Cache.battleback($game_system.battleback)    
  285.     elsif PAC::UTILITY::BB_MAPS.key?($game_map.map_id)
  286.       @battleback_sprite = Sprite.new(@viewport1)
  287.       @battleback_sprite.bitmap = Cache.battleback(PAC::UTILITY::BB_MAPS[$game_map.map_id])
  288.     else
  289.       pac_abb_create_battleback # The. Usual. Method.
  290.     end
  291.   end
  292.   #--------------------------------------------------------------------------
  293.   # * Create Battlefloor Sprite
  294.   #--------------------------------------------------------------------------
  295.   unless PAC::UTILITY::CREATE_FLOOR == true # Check if rewrite is needed...
  296.     def create_battlefloor
  297.       if PAC::UTILITY::BB_MAPS.key?($game_map.map_id) or $game_system.battleback != nil
  298.         @battlefloor_sprite = Sprite.new(@viewport1)
  299.         return
  300.       end
  301.       if $BTEST
  302.         if PAC::UTILITY::BB_TEST != nil
  303.           @battlefloor_sprite = Sprite.new(@viewport1)
  304.           return
  305.         end
  306.       end
  307.       pac_abb_create_battlefloor  # The usual.
  308.     end
  309.     def update_battlefloor
  310.     end # Do not rewrite battlefloor sprite.
  311.   end
  312. end
  313.  
  314. elsif PAC::UTILITY::BB_TYPE == 2  # Run SBB.
  315.  
  316. #==============================================================================
  317. # ** Spriteset_Battle
  318. #------------------------------------------------------------------------------
  319. #  This class brings together battle screen sprites. It's used within the
  320. # Scene_Battle class.
  321. #==============================================================================
  322.  
  323. class Spriteset_Battle
  324.   #-----------------------------------------------------------------------------
  325.   # * Create Battleback Sprite
  326.   #-----------------------------------------------------------------------------
  327.   def create_battleback
  328.     source = $game_temp.background_bitmap
  329.     width = PAC::UTILITY::WIDTH
  330.     height = PAC::UTILITY::HEIGHT
  331.     bitmap = Bitmap.new(width, height)
  332.     bitmap.stretch_blt(bitmap.rect, source, source.rect)
  333.     PAC::UTILITY::BLUR_INTENSITY.times do bitmap.blur end
  334.     @battleback_sprite = Sprite.new(@viewport1)
  335.     @battleback_sprite.bitmap = bitmap
  336.     @battleback_sprite.ox = width/2
  337.     @battleback_sprite.oy = height/2
  338.     @battleback_sprite.x = Graphics.width/2
  339.     @battleback_sprite.y = (Graphics.height-128)/2+64
  340.   end
  341.   #-----------------------------------------------------------------------------
  342.   # * Create Battlefloor Sprite
  343.   #-----------------------------------------------------------------------------
  344.   if PAC::UTILITY::CREATE_FLOOR == true # Rewrite method?
  345.     def create_battlefloor
  346.       @battlefloor_sprite = Sprite.new(@viewport1)
  347.       @battlefloor_sprite.bitmap = Cache.system("BattleFloor")
  348.       @battlefloor_sprite.x = PAC::UTILITY::FLOOR_X
  349.       @battlefloor_sprite.y = PAC::UTILITY::FLOOR_Y
  350.       @battlefloor_sprite.z = 1
  351.       @battlefloor_sprite.opacity = PAC::UTILITY::FLOOR_O
  352.     end
  353.   end
  354. end
  355. elsif PAC::UTILITY::BB_TYPE == 0
  356. else  # If you fucked it up...
  357.   p "The PAC says: BB_TYPE not set to 1 or 2. Check your Battle Back script."
  358.   $scene = nil
  359. end
  360.  
  361. #===============================================================================
  362. #
  363. # END OF SCRIPT
  364. #
  365. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement