Advertisement
LiTTleDRAgo

[RGSS] XAS Multiple Treasure Info

Oct 20th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.43 KB | None | 0 0
  1.     #==============================================================================#
  2.     # Multi Treasure Info                                                          #
  3.     # Version: 2.0                                                                 #
  4.     # By LiTTleDRAgo                                                               #
  5.     #==============================================================================#
  6.  
  7.     module DRG_TREASURE_INFO
  8.      
  9.       MTI_HUD_X = -20
  10.       MTI_HUD_Y = 420 - 100
  11.       MTI_TIME = 1
  12.       WINDOW_PRIORITY_Z = 99999
  13.       FONT = 'Monotype Corsiva'
  14.       SIZE = 20
  15.       ACT_SE = 'Mana - Menu-01'
  16.      
  17.     end
  18.  
  19.     #==============================================================================
  20.     # ■ MTI
  21.     #==============================================================================
  22.      class Mti < Sprite
  23.       include DRG_TREASURE_INFO
  24.     #--------------------------------------------------------------------------
  25.     # ● Initialize
  26.     #--------------------------------------------------------------------------
  27.       def init
  28.         setup
  29.         @inf = Sprite.new
  30.         @inf.bitmap = Bitmap.new(120,70)
  31.         @inf.z = 2 + WINDOW_PRIORITY_Z
  32.         @inf.oy = -MTI_HUD_Y + 50
  33.         @inf.bitmap.font.name  = 'Georgia'
  34.         @inf.bitmap.font.size  = 30
  35.         @inf.bitmap.font.italic  = true
  36.         @inf.bitmap.font.color = Color.new(255, 255, 128, 255)
  37.       #  @inf.bitmap.draw_circle_gradient(24, 24, 25, Color.gray,45,1)
  38.         @inf.bitmap.draw_text(5, 4, 120, 40, 'Get',0)
  39.         @inf.opacity = 0
  40.       end
  41.     #--------------------------------------------------------------------------
  42.     # ● Setup
  43.     #--------------------------------------------------------------------------
  44.       def setup
  45.         $game_temp.mti_text_x = 0
  46.         $game_temp.mti_text_y = 0
  47.         $game_temp.mti_text_zoom_x = 1.00
  48.         $game_temp.mti_text_zoom_y = 1.00
  49.         $game_temp.mti_text_opa = 0  
  50.       end
  51.     #--------------------------------------------------------------------------
  52.     # ● Update
  53.     #--------------------------------------------------------------------------
  54.       def update
  55.         super
  56.         update_start_move
  57.         refresh if $game_temp.mti_start
  58.       end
  59.     #--------------------------------------------------------------------------
  60.     # ● Dispose
  61.     #--------------------------------------------------------------------------
  62.       def dispose
  63.         return super if @text.nil?
  64.         @text.each {|i| i.dispose if !i.nil?}
  65.         @inf.dispose if !@inf.nil?
  66.         super
  67.       end
  68.     #--------------------------------------------------------------------------
  69.     # ● Refresh
  70.     #--------------------------------------------------------------------------
  71.       def refresh
  72.         $game_temp.mti_start = false
  73.         init if @inf.nil?
  74.         (@count.nil? || @count >= 5) ? @count = 0 : @count += 1
  75.         if @text[@count].nil?
  76.           @text[@count] = Sprite.new
  77.           @text[@count].bitmap = Bitmap.new(120,40)
  78.           @text[@count].z = 2 + WINDOW_PRIORITY_Z
  79.           @text[@count].bitmap.font.name = FONT
  80.           @text[@count].bitmap.font.size = SIZE
  81.         end
  82.         @text[@count].bitmap.clear
  83.         @text[@count].opacity = 100
  84.         @text[@count].zoom_x = 1.50
  85.         @text[@count].oy = -MTI_HUD_Y + 5 + $game_temp.mti_text_y
  86.         @text[@count].ox = -MTI_HUD_X - 50 + $game_temp.mti_text_x
  87.         @text[@count].zoom_x = $game_temp.mti_text_zoom_x
  88.         @text[@count].zoom_y = $game_temp.mti_text_zoom_y
  89.         @text[@count].bitmap.draw_text(0, 0, 120, 40, $game_temp.mti_text.to_s,0)
  90.         @text[@count].visible = true
  91.         @time[@count] = MTI_TIME * 40
  92.       end
  93.     #--------------------------------------------------------------------------
  94.     # ● Update Start Move
  95.     #--------------------------------------------------------------------------
  96.       def update_start_move
  97.         @text,@time = [],[] if @text.nil? or @time.nil?
  98.         v = @count.nil? ? 0 : @count
  99.         return if @text[v].nil?
  100.         if !@time[v].nil? and @time[v] > 0
  101.           if @text[v].opacity < 255
  102.             @text[v].oy = -MTI_HUD_Y + 5 + $game_temp.mti_text_y
  103.             @text.each_index {|i|
  104.               if v != i && !@text[i].nil?
  105.                 @text[i].oy += 1
  106.                 @text[i].opacity -= 5 if @text[v-i].opacity > 0
  107.               end}
  108.             @text[v].opacity += 10
  109.           end
  110.           @inf.opacity += 10 if @inf.opacity < 255
  111.         else
  112.           @text.each_index {|i|
  113.             if @text[i].opacity > 0
  114.               @text[i].opacity -= 5
  115.               @text[i].oy += 1
  116.             else
  117.               @text[i].visible = false
  118.             end}
  119.             @inf.opacity -= 10 if @inf.opacity > 0
  120.         end
  121.         @time[v] -= 1 if @time[v] > 0
  122.       end
  123.     end
  124.     #===============================================================================
  125.     # ■ Interpreter
  126.     #===============================================================================
  127.     class Interpreter
  128.      
  129.       #--------------------------------------------------------------------------
  130.       # ● multi_treasure_info_popup(text)
  131.       #--------------------------------------------------------------------------
  132.       def multi_treasure_info_popup(text)
  133.           $game_temp.mti_text = text
  134.           $game_temp.mti_text_time = 40 * DRG_TREASURE_INFO::MTI_TIME
  135.           $game_temp.mti_start = true    
  136.       end
  137.       #--------------------------------------------------------------------------
  138.       # ● Play SE
  139.       #--------------------------------------------------------------------------
  140.       def play_se_itm
  141.           Audio.se_play('Audio/SE/'+DRG_TREASURE_INFO::ACT_SE , 70, 100) rescue nil
  142.       end
  143.       #--------------------------------------------------------------------------
  144.       # ● Change Gold
  145.       #--------------------------------------------------------------------------
  146.       alias drgXp_command_125 command_125
  147.       def command_125
  148.           drgXp_command_125
  149.           value = operate_value(@parameters[0], @parameters[1], @parameters[2])
  150.           text = value.to_s + ' ' + $data_system.words.gold
  151.           multi_treasure_info_popup(text) if value > 0  
  152.       end
  153.      #--------------------------------------------------------------------------
  154.      # ● Display Item Animaton
  155.      #--------------------------------------------------------------------------
  156.       alias drgXp_display_item_animaton display_item_animaton
  157.       def display_item_animaton(damage_item,gold_effect,value,item_name)
  158.         drgXp_display_item_animaton(damage_item,gold_effect,value,item_name)
  159.         if damage_item == nil
  160.             text = value.to_s +  ' x ' + item_name
  161.             multi_treasure_info_popup(text) if value > 0
  162.             play_se_itm if value > 0
  163.         elsif gold_effect != nil
  164.             text = gold_effect.to_s + ' ' + $data_system.words.gold
  165.             multi_treasure_info_popup(text) if value > 0    
  166.             play_se_itm if value > 0
  167.         end
  168.       end
  169.      #--------------------------------------------------------------------------
  170.      # ● Command_127 (WEAPON)
  171.      #--------------------------------------------------------------------------
  172.       alias drgXp_item_command_127 command_127
  173.       def command_127
  174.         drgXp_item_command_127
  175.         value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  176.         item_name = load_data('Data/Weapons.rxdata')
  177.         text = value.to_s +  ' x ' + item_name[@parameters[0]].name
  178.         multi_treasure_info_popup(text) if value > 0        
  179.       end
  180.      #--------------------------------------------------------------------------
  181.      # ● Command_128 (ARMOR)
  182.      #--------------------------------------------------------------------------
  183.       alias drgXp_command_128 command_128
  184.       def command_128
  185.         drgXp_command_128
  186.         value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  187.         item_name = load_data('Data/Armors.rxdata')
  188.         text = value.to_s +  ' x ' + item_name[@parameters[0]].name
  189.         multi_treasure_info_popup(text) if value > 0        
  190.       end
  191.     end
  192.  
  193.     #==============================================================================
  194.     # ■ Scene_Map
  195.     #==============================================================================
  196.     class Scene_Map  
  197.      
  198.     #--------------------------------------------------------------------------
  199.     # ● Main
  200.     #--------------------------------------------------------------------------
  201.       alias drgXp_mti_main main
  202.       def main
  203.         drgXp_mti_main
  204.         @mti.dispose
  205.       end  
  206.     #--------------------------------------------------------------------------
  207.     # ● Update
  208.     #--------------------------------------------------------------------------
  209.       alias drgXp_mti_update update
  210.       def update
  211.         drgXp_mti_update
  212.         @mti.nil? ? @mti = Mti.new : @mti.update
  213.       end  
  214.     end
  215.  
  216.     #==============================================================================
  217.     # ■ Game_Temp
  218.     #==============================================================================
  219.     class Game_Temp
  220.         attr_accessor :mti_text_x,:mti_text_y,:mti_text_zoom_x,:mti_text_zoom_y,
  221.                 :mti_text_opa,:mti_text,:mti_text_time,:mti_start
  222.     end
  223.  
  224.  
  225.     $drago_multi_treasure_info = true
  226.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement