Advertisement
LiTTleDRAgo

[RGSS] Picture Index Modifier

Jun 29th, 2014
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.58 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # DRG - Picture Index Modifier
  3. # Version: 1.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #
  7. #  How to use :
  8. #
  9. #  @>Script: $game_temp.index_picture = 182 # (any integer above 0)
  10. #  @>Show_Picture: .......... # Command show picture,
  11. #                               picture index will be overwritten by
  12. #                               $game_temp.index_picture value)
  13. #
  14. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  15.  
  16. ($imported ||= {})[:drg_picture_index_modifier] = 1.00
  17. defined?(Window_ActorCommand) && raise("This script only for RMXP")
  18. #==============================================================================
  19. # ** Game_Pictures
  20. #------------------------------------------------------------------------------
  21. #  This is a wrapper for a picture array. This class is used within the
  22. # Game_Screen class. Map screen pictures and battle screen pictures are
  23. # handled separately.
  24. #==============================================================================
  25.  
  26. class Game_Pictures
  27.   #--------------------------------------------------------------------------
  28.   # * Get Data
  29.   #--------------------------------------------------------------------------
  30.   def [](num)(@data||=[])[num] ||= Game_Picture.new(num)                  end
  31.   def size() (@data||=[]).compact.size                                    end
  32.   def each() (@data||=[]).compact.each {|pic| yield pic } if block_given? end
  33. end
  34.  
  35. #==============================================================================
  36. # ** Game_Screen
  37. #------------------------------------------------------------------------------
  38. #  This class handles screen maintenance data, such as changes in color tone,
  39. # flashes, etc. It's used within the Game_Map and Game_Troop classes.
  40. #==============================================================================
  41.  
  42. class Game_Screen
  43.   #--------------------------------------------------------------------------
  44.   # * Pictures
  45.   #--------------------------------------------------------------------------
  46.   def pictures
  47.     @pictures.is_a?(Game_Pictures) || @pictures = Game_Pictures.new
  48.     $scene.is_a?(Scene_Battle) ? (@battle_pictures ||= Game_Pictures.new) :
  49.                                  (@pictures        ||= Game_Pictures.new)
  50.   end
  51. end
  52.  
  53. #==============================================================================
  54. # ** Spriteset_Map
  55. #------------------------------------------------------------------------------
  56. #  This class brings together map screen sprites, tilemaps, etc.
  57. #  It's used within the Scene_Map class.
  58. #==============================================================================
  59. ['Spriteset_Map','Spriteset_Battle'].each_with_index do |klass,index| eval "
  60.  class #{klass}
  61.    #--------------------------------------------------------------------------
  62.    # * Alias Listing
  63.    #--------------------------------------------------------------------------
  64.    alias_method :update_inf_picture, :update
  65.    #--------------------------------------------------------------------------
  66.    # * Object Initialization
  67.    #--------------------------------------------------------------------------
  68.    def update(*args)
  69.      adjust_picture_sprites(#{index})
  70.      update_inf_picture(*args)
  71.    end
  72.    #--------------------------------------------------------------------------
  73.    # * adjust_picture_sprites
  74.    #--------------------------------------------------------------------------
  75.    def adjust_picture_sprites(type = 0)
  76.      size = @picture_sprites.size
  77.      number = $game_screen.pictures.size
  78.      if number != size
  79.        @picture_sprites.each {|s| s.dispose }
  80.        @picture_sprites.clear
  81.        $game_screen.pictures.each do |num|
  82.          @picture_sprites.push(Sprite_Picture.new(type == 0 ? @viewport2 :
  83.          @viewport3,$game_screen.pictures[num.number]))
  84.        end
  85.      end
  86.    end
  87.  end#"
  88. end
  89.  
  90. #==============================================================================
  91. # ** Game_Temp
  92. #------------------------------------------------------------------------------
  93. #  This class handles temporary data that is not included with save data.
  94. #  Refer to "$game_temp" for the instance of this class.
  95. #==============================================================================
  96.  
  97. class Game_Temp
  98.   #--------------------------------------------------------------------------
  99.   # * Public Instance Variable
  100.   #--------------------------------------------------------------------------
  101.   attr_writer(:index_picture)
  102.   define_method(:index_picture) { @index_picture ||= 0 }
  103. end
  104.  
  105. #==============================================================================
  106. # ** Interpreter
  107. #------------------------------------------------------------------------------
  108. #  This interpreter runs event commands. This class is used within the
  109. #  Game_System class and the Game_Event class.
  110. #==============================================================================
  111.  
  112. class Interpreter
  113.   #--------------------------------------------------------------------------
  114.   # * Show Picture
  115.   #--------------------------------------------------------------------------
  116.   (231..235).each do |meth|
  117.     alias_method(:"command_#{meth}_inf_pic", :"command_#{meth}")
  118.     define_method(:"command_#{meth}") do
  119.       (index = $game_temp.index_picture).is_a?(Integer) &&
  120.       index > 0 && @parameters[0] = index
  121.       send(:"command_#{meth}_inf_pic")
  122.       return true
  123.     end
  124.   end
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement