Advertisement
LiTTleDRAgo

[RGSS] Multiple Treasure Info

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