Advertisement
Rafael_Sol_Maker

RAFAEL_SOL_MAKER's VX SUPER AREA UTILITIES v1.1

Nov 17th, 2011
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.73 KB | None | 0 0
  1. #===============================================================================
  2. #               RAFAEL_SOL_MAKER's VX SUPER AREA UTILITIES v1.1
  3. #-------------------------------------------------------------------------------
  4. # Description:  With this script you can set batlle backgrounds, like RPG Maker
  5. #               XP, for specific areas, assign a specified damage in each step,
  6. #               simulating the terrain damage, specify poison damage and healing
  7. #               rate from items, and others things, everything here.
  8. #               OBS.: It also erases the battlefloor, since it is unnecessary.
  9. #-------------------------------------------------------------------------------
  10. # How to Use:   Type the following commands in the names of areas:
  11. #               <battleback "filename"> to set a battle background; (no quotes!)
  12. #               <damage_area x> to damage 'x' HP points to all party members;
  13. #               Is it possible to put the two commands in the same area using
  14. #               ';' to separate them. Everything else configure below.
  15. #-------------------------------------------------------------------------------
  16. # Special Thanks: Moghunter
  17. #-------------------------------------------------------------------------------
  18. #===============================================================================
  19.  
  20. module PowerPackVX_General_Configs  
  21.   # BASIC ENGINE ADJUSTS
  22.   Minimum_HP = 1                # Min HP for poison/area damage (0 = dead)
  23.   Poison_Damage = 1             # Poison damage for each step
  24.   Recover_Rate = 1              # HP Recover for each step (special itens)
  25.   GameOver_on_Map = false       # If all party is dead on map, we got a Game Over?
  26.  
  27.   # DEFAULT GRAPHICS
  28.   Default_Battleback = 'Grassland01' # Default BattleBack filename
  29. end
  30.  
  31. module Cache    
  32.   # BattleBack directly from Cache
  33.   def self.battleback(filename)
  34.     load_bitmap('Graphics/Battlebacks/', filename)
  35.   end
  36. end
  37.  
  38. module PowerPackVX_Advanced_Configs
  39.   # FOR AREA NAMES (Don't change nothing here, or the commands could not work!)
  40.   TERRAIN_DAMAGE = /<(?:DAMAGE_AREA|damage area)\s*([\-]?\d+)>/i
  41.   BATTLEBACK_FILE = /<(?:BATTLEBACK|battleback)\s*(.*)>/i
  42. end
  43.  
  44. class Game_Party < Game_Unit
  45. include PowerPackVX_Advanced_Configs
  46. include PowerPackVX_General_Configs
  47.  
  48.   def on_player_walk
  49.    
  50.     for actor in members
  51.       if actor.slip_damage?
  52.         if (actor.hp - Poison_Damage) < Minimum_HP
  53.           actor.hp = Minimum_HP
  54.         else
  55.           actor.hp -= Poison_Damage
  56.         end        
  57.         $game_map.screen.start_flash(Color.new(255,0,0,64), 4)
  58.       end
  59.       if actor.auto_hp_recover and actor.hp > 0
  60.         actor.hp += Recover_Rate
  61.       end
  62.     end  
  63.  
  64.     in_area = false
  65.     for area in $data_areas.values
  66.       if $game_player.in_area?(area)
  67.         name = get_battleback_name(area.name)
  68.         if !name.nil? and !$game_map.battleback_lock
  69.           in_area = true; $game_map.battleback_name = name
  70.         end
  71.         damage = get_damage_area(area.name)        
  72.         unless damage.nil?
  73.           for actor in $game_party.members
  74.             if actor.hp > Minimum_HP
  75.               if (actor.hp - damage) < Minimum_HP
  76.                 actor.hp = Minimum_HP
  77.               else
  78.                 actor.hp -= damage
  79.               end  
  80.             end
  81.           end  
  82.           $game_map.screen.start_flash(Color.new(255,0,0,64), 4)      
  83.         end #unless      
  84.       end #if  
  85.     end #for
  86.    
  87.     $game_map.battleback_name = Default_Battleback if !in_area and !$game_map.battleback_lock
  88.     $scene = Scene_Gameover.new if $game_party.all_dead? and GameOver_on_Map == true
  89.    
  90.   end
  91.  
  92.   def get_battleback_name (area_name)
  93.     area_name.split(/[\r\n;]+/).each { |line|
  94.       if line =~ BATTLEBACK_FILE
  95.         a = line.split(/ /)[1]
  96.         d = ""
  97.         while ((c = a.slice!(/./m)) != nil)
  98.           d += c if c != ">"
  99.         end
  100.         return d      
  101.       end }    
  102.     return nil
  103.   end
  104.  
  105.   def get_damage_area (area_name)
  106.     area_name.split(/[\r\n;]+/).each { |line|      
  107.     return $1.to_i if line =~ TERRAIN_DAMAGE }
  108.     return nil
  109.   end
  110.  
  111. end
  112.  
  113. class Spriteset_Battle
  114. include PowerPackVX_General_Configs
  115.  
  116.   def create_battleback
  117.     @battleback_sprite = Sprite.new(@viewport1)
  118.     source = Cache.battleback($game_map.battleback_name) rescue Cache.battleback(Default_Battleback)
  119.     @battleback_sprite.x = (Graphics.width / 2) - (source.width / 2)
  120.     @battleback_sprite.bitmap = source
  121.   end
  122.  
  123.   # SINCE WE DON'T NEED, LET'S "KILL" THE BATTLE FLOOR
  124.   def create_battlefloor; end
  125.   def update_battlefloor; end
  126.   def dispose_battlefloor; end
  127.  
  128. end
  129.  
  130. class Game_Map
  131.   attr_accessor :battleback_name
  132.   attr_accessor :battleback_lock
  133. end
  134.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement