vindaca510

V's Reward Pop Up v0.3

Dec 11th, 2013
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 19.89 KB | None | 0 0
  1. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  2. #                                                                              #
  3. #                              V's  Reward Pop Up                              #
  4. #                                 Version  0.3                                 #
  5. #                                                                              #
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  7. #                               Written By: Vindaca                            #
  8. #                         Last Edited:  January 16, 2013                       #
  9. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  10. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  11.  
  12.  
  13. #==============================================================================#
  14. #------------------------------------------------------------------------------#
  15. # ** Disclaimer                                                                #
  16. #------------------------------------------------------------------------------#
  17. #                                                                              #
  18. # This script was intended for Non-commercial use only, if you wish to use     #
  19. # this script in a commercial game please PM me at which ever site you found   #
  20. # this script. Either way please give me credit in your game script as the     #
  21. # writer of this script, and send me a PM abuot the release of the game/demo.  #
  22. #                                                                              #
  23. #------------------------------------------------------------------------------#
  24. # ** How To Use                                                                #
  25. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  26. #                                                                              #
  27. # * This script has two script calls:                                          #
  28. #                                                                              #
  29. #     This script call should be used at the beginning of the event before     #
  30. #     any reward a given out to ensure no icon is repeated without reason.     #
  31. #                                                                              #
  32. #         * clear_reward                                                       #
  33. #                                                                              #
  34. #     This script call should be used after the last reward has been given.    #
  35. #                                                                              #
  36. #          * reward                                                            #
  37. #                                                                              #
  38. # * There is a customizable are below.                                         #
  39. #                                                                              #
  40. #------------------------------------------------------------------------------#
  41. # ** Updates / Version Notes                                                   #
  42. #------------------------------------------------------------------------------#
  43. #                                                                              #
  44. #  v0.1                                                                        #
  45. # ~=~=~=~                                                                      #
  46. #  * This script allows you to create a pop-up that displays rewards given on  #
  47. #    the game map via events.                                                  #
  48. #                                                                              #
  49. #  v0.2                                                                        #
  50. # ~=~=~=~                                                                      #
  51. #  * I added a Font_Size & Font_Outline Options Below.                         #
  52. #                                                                              #
  53. #  v0.3                                                                        #
  54. # ~=~=~=~                                                                      #
  55. #  * This script is now compatible with V's Lucky Gold Find v0.2+.             #
  56. #                                                                              #
  57. #------------------------------------------------------------------------------#
  58. #==============================================================================#
  59. #==============================================================================
  60. # ** V's Reward Pop Up
  61. #------------------------------------------------------------------------------
  62. #  This module manages customizable features and methods.
  63. #==============================================================================
  64. module V_Reward_Pop_Up
  65.   module Specs
  66. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  67. #                                                                              #
  68. #                           Start Customizable Area.                           #
  69. #                                                                              #
  70. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
  71. #                                                                              #
  72. #                        ONLY EDIT THE DESIGNATED AREAS.                       #
  73. #                                                                              #
  74. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  75.  
  76.  
  77.  
  78.   #=============================================================================
  79.   # * Pop-up Options
  80.   #=============================================================================
  81.  
  82.     #------------------------------------------------------------------------
  83.     # * Font Options
  84.     #------------------------------------------------------------------------
  85.       Font_Size = 16
  86.       Use_Outline = true
  87.  
  88.     #------------------------------------------------------------------------
  89.     # * Reward Sound Effect
  90.     #------------------------------------------------------------------------
  91.       Reward_SE = ["Item1", 80, 100]
  92.  
  93.     #------------------------------------------------------------------------
  94.     # * Gold Icon
  95.     #------------------------------------------------------------------------
  96.       Gold_Icon = 361
  97.  
  98.     #------------------------------------------------------------------------
  99.     # * Amount of time (in frames) the reward should be displayed.
  100.     #------------------------------------------------------------------------
  101.       Display_Time = 90
  102.  
  103.  
  104.    
  105.    
  106. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  107. #                                                                              #
  108. #         DO NOT EDIT PAST THIS POINT UNLESS YOU KNOW WHAT YOUR DOING.         #
  109. #                                                                              #
  110. #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.   end
  133. end #<--- End Module===========================================================
  134.  
  135.  
  136. #==============================================================================
  137. # ** Game_Party
  138. #------------------------------------------------------------------------------
  139. #  This class handles parties. Information such as gold and items is included.
  140. # Instances of this class are referenced by $game_party.
  141. #==============================================================================
  142.  
  143. class Game_Party < Game_Unit
  144.  
  145.   #--------------------------------------------------------------------------
  146.   # * Public Instance Variables
  147.   #--------------------------------------------------------------------------
  148.   attr_accessor :rewards                                   # Rewards
  149.   attr_accessor :give_rewards                              # Give Rewards?
  150.  
  151.   #--------------------------------------------------------------------------
  152.   # * Aliasing Method: Object Initialization
  153.   #--------------------------------------------------------------------------
  154.   alias :i000040454245400400454 :initialize
  155.  
  156.   #--------------------------------------------------------------------------
  157.   # * Object Initialization
  158.   #--------------------------------------------------------------------------
  159.   def initialize
  160.     @rewards = []
  161.     @give_rewards = false
  162.     i000040454245400400454()
  163.   end
  164.  
  165.   #--------------------------------------------------------------------------
  166.   # * Add Reward
  167.   #--------------------------------------------------------------------------
  168.   def add_reward(type, value, id = nil)
  169.     @rewards.push [type, value, id]
  170.   end
  171.  
  172.   #--------------------------------------------------------------------------
  173.   # * Current Reward
  174.   #--------------------------------------------------------------------------
  175.   def current_reward
  176.     @rewards.last
  177.   end
  178.  
  179.   #--------------------------------------------------------------------------
  180.   # * Remove Rewards
  181.   #--------------------------------------------------------------------------
  182.   def remove_reward
  183.     @rewards.delete_at @rewards.size - 1
  184.   end
  185.  
  186. end
  187.  
  188.  
  189. #==============================================================================
  190. # ** Game_Interpreter
  191. #------------------------------------------------------------------------------
  192. #  An interpreter for executing event commands. This class is used within the
  193. # Game_Map, Game_Troop, and Game_Event classes.
  194. #==============================================================================
  195.  
  196. class Game_Interpreter
  197.  
  198.   #--------------------------------------------------------------------------
  199.   # * Include Module
  200.   #--------------------------------------------------------------------------
  201.   if $imported["V_Lucky_Gold_Find"] == true
  202.     include V_Lucky_Gold_Find::Specs
  203.   end
  204.  
  205.   #--------------------------------------------------------------------------
  206.   # * Aliasing Method: Change Gold
  207.   #--------------------------------------------------------------------------
  208.   alias :cmnd1254754534452453434 :command_125
  209.  
  210.   #--------------------------------------------------------------------------
  211.   # * Change Gold
  212.   #--------------------------------------------------------------------------
  213.   def command_125
  214.     value = operate_value(@params[0], @params[1], @params[2])
  215.     if $imported["V_Lucky_Gold_Find"] == true
  216.       s = $game_party.battle_members[0].param(7)
  217.       sba = s*Bonus_Rate
  218.       pb = 0
  219.       t = $game_party.battle_members.size
  220.       t.times { |i| pb += $game_party.battle_members[i - 1].param(7) }
  221.       pba = pb*Bonus_Rate
  222.       value = (value * sba).to_i if Solo_Bonus
  223.       value = (value * pba).to_i if Solo_Bonus == false
  224.     end
  225.     $game_party.add_reward(0, value)
  226.     cmnd1254754534452453434()
  227.   end
  228.  
  229.   #--------------------------------------------------------------------------
  230.   # * Aliasing Method: Change Items
  231.   #--------------------------------------------------------------------------
  232.   alias :cmnd126452434333453434 :command_126
  233.  
  234.   #--------------------------------------------------------------------------
  235.   # * Change Items
  236.   #--------------------------------------------------------------------------
  237.   def command_126
  238.     value = operate_value(@params[1], @params[2], @params[3])
  239.     $game_party.add_reward(1, value, @params[0])
  240.     cmnd126452434333453434()
  241.   end
  242.  
  243.   #--------------------------------------------------------------------------
  244.   # * Aliasing Method: Change Weapons
  245.   #--------------------------------------------------------------------------
  246.   alias :cmnd1274524744004053434 :command_127
  247.  
  248.   #--------------------------------------------------------------------------
  249.   # * Change Weapons
  250.   #--------------------------------------------------------------------------
  251.   def command_127
  252.     value = operate_value(@params[1], @params[2], @params[3])
  253.     $game_party.add_reward(2, value, @params[0])
  254.     cmnd1274524744004053434()
  255.   end
  256.  
  257.   #--------------------------------------------------------------------------
  258.   # * Aliasing Method: Change Armor
  259.   #--------------------------------------------------------------------------
  260.   alias :cmnd128452658646453464434 :command_128
  261.  
  262.   #--------------------------------------------------------------------------
  263.   # * Change Armor
  264.   #--------------------------------------------------------------------------
  265.   def command_128
  266.     value = operate_value(@params[1], @params[2], @params[3])
  267.     $game_party.add_reward(3, value, @params[0])
  268.     cmnd128452658646453464434()
  269.   end
  270.  
  271.   #--------------------------------------------------------------------------
  272.   # * Give Rewards
  273.   #--------------------------------------------------------------------------
  274.   def reward
  275.     $game_party.give_rewards = true
  276.   end
  277.  
  278.   #--------------------------------------------------------------------------
  279.   # * Clear Last Reward
  280.   #--------------------------------------------------------------------------
  281.   def clear_reward
  282.     $game_party.remove_reward if $game_party.rewards.size > 0
  283.   end
  284.  
  285. end
  286.  
  287.  
  288. #==============================================================================
  289. # ** Scene_Map
  290. #------------------------------------------------------------------------------
  291. #  This class performs the map screen processing.
  292. #==============================================================================
  293.  
  294. class Reward_Window < Window_Base
  295.  
  296.   #--------------------------------------------------------------------------
  297.   # * Include Module
  298.   #--------------------------------------------------------------------------
  299.   include V_Reward_Pop_Up::Specs
  300.  
  301.   #--------------------------------------------------------------------------
  302.   # * Refresh Processing
  303.   #--------------------------------------------------------------------------
  304.   def refresh(enabled = false)
  305.     contents.clear
  306.     draw_reward if enabled
  307.   end
  308.  
  309.   #--------------------------------------------------------------------------
  310.   # * Returns Character Graphic Dimensions
  311.   #--------------------------------------------------------------------------
  312.   def character_bitmap_width
  313.     character_name = $game_party.members[0].character_name
  314.     bitmap = Cache.character(character_name)
  315.     sign = character_name[/^[\!\$]./]
  316.     if sign && sign.include?('$')
  317.       cw = bitmap.width / 3
  318.     else
  319.       cw = bitmap.width / 12
  320.     end
  321.     return cw
  322.   end
  323.  
  324.   #--------------------------------------------------------------------------
  325.   # * Draw Reward
  326.   #--------------------------------------------------------------------------
  327.   def draw_reward
  328.     reward = $game_party.current_reward
  329.     case reward[0]
  330.     when 0
  331.       string = ("+" + reward[1].to_s + " " + Vocab.currency_unit)
  332.     when 1
  333.       item_name =  $data_items[reward[2]].name
  334.       string = ("+" + reward[1].to_s + " " + item_name)
  335.     when 2
  336.       item_name =  $data_weapons[reward[2]].name
  337.       string = ("+" + reward[1].to_s + " " + item_name)
  338.     when 3
  339.       item_name =  $data_armors[reward[2]].name
  340.       string = ("+" + reward[1].to_s + " " + item_name)
  341.     end
  342.     x = ($game_player.screen_x - (character_bitmap_width / 2)) - 5
  343.     y = $game_player.screen_y - 96
  344.     draw_icon(x, y, reward[0], reward[2])
  345.     draw_sizable_text((x - (Graphics.width / 2)) + 10, y - 170, Graphics.width, Graphics.height, string, 1, Font_Size)
  346.   end
  347.  
  348.   #--------------------------------------------------------------------------
  349.   # * Draw Sizeable Text
  350.   #--------------------------------------------------------------------------
  351.   def draw_sizable_text(x, y, width, height, text, alignment, font_size)
  352.     reset_font_settings
  353.     contents.font.size = font_size
  354.     contents.font.outline = Use_Outline
  355.     contents.draw_text(x, y, width, height, text, alignment)
  356.     reset_font_settings
  357.   end
  358.    
  359.   #--------------------------------------------------------------------------
  360.   # * Draw Icon
  361.   #--------------------------------------------------------------------------
  362.   def draw_icon(x, y, type, id)
  363.     case type
  364.     when 0
  365.       icon_index = Gold_Icon
  366.     when 1
  367.       icon_index = $data_items[id].icon_index
  368.     when 2
  369.       icon_index = $data_weapons[id].icon_index
  370.     when 3
  371.       icon_index = $data_armors[id].icon_index
  372.     end
  373.     bitmap = Cache.system("Iconset")
  374.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  375.     contents.blt(x, y, bitmap, rect, 255)
  376.   end
  377.  
  378.  
  379. end
  380.  
  381. #==============================================================================
  382. # ** Scene_Map
  383. #------------------------------------------------------------------------------
  384. #  This class performs the map screen processing.
  385. #==============================================================================
  386.  
  387. class Scene_Map < Scene_Base
  388.  
  389.   #--------------------------------------------------------------------------
  390.   # * Include Module
  391.   #--------------------------------------------------------------------------
  392.   include V_Reward_Pop_Up::Specs
  393.  
  394.   #--------------------------------------------------------------------------
  395.   # * Aliasing Method: Object Initialization
  396.   #--------------------------------------------------------------------------
  397.   alias :i7777775552244155232511 :initialize
  398.  
  399.   #--------------------------------------------------------------------------
  400.   # * Object Initialization
  401.   #--------------------------------------------------------------------------
  402.   def initialize
  403.     @timer_completed = true
  404.     @reward_frame = 0
  405.     i7777775552244155232511()
  406.   end
  407.  
  408.   #--------------------------------------------------------------------------
  409.   # * Aliasing Method: Create All Windows
  410.   #--------------------------------------------------------------------------
  411.   alias :caw524042400 :create_all_windows
  412.  
  413.   #--------------------------------------------------------------------------
  414.   # * Create All Windows
  415.   #--------------------------------------------------------------------------
  416.   def create_all_windows
  417.     create_map_reward_window
  418.     caw524042400()
  419.   end
  420.  
  421.   #--------------------------------------------------------------------------
  422.   # * Create Icon Window
  423.   #--------------------------------------------------------------------------
  424.   def create_map_reward_window
  425.     @reward_window = Reward_Window.new(0,0,544,416)
  426.     @reward_window.opacity = 0
  427.   end
  428.  
  429.   #--------------------------------------------------------------------------
  430.   # * Refresh Rewards
  431.   #--------------------------------------------------------------------------
  432.   def refresh_rewards(wait_time)
  433.     show_icon = true
  434.     if @reward_frame < wait_time
  435.       @reward_frame += 1
  436.     else
  437.       $game_party.remove_reward
  438.       show_icon = false
  439.       @reward_frame = 0
  440.       @timer_completed = true
  441.     end
  442.       @reward_window.refresh(show_icon)
  443.   end
  444.  
  445.   #--------------------------------------------------------------------------
  446.   # * Create Icon Window
  447.   #--------------------------------------------------------------------------
  448.   def update_rewards
  449.     if $game_party.rewards.size > 0
  450.       case
  451.       when @timer_completed == true
  452.         @reward_window.refresh(true)
  453.         RPG::SE.new(Reward_SE[0], Reward_SE[1], Reward_SE[2]).play
  454.         @timer_completed = false
  455.       when @timer_completed == false
  456.         refresh_rewards(Display_Time)
  457.       end
  458.     else
  459.       $game_party.give_rewards = false
  460.     end
  461.   end
  462.  
  463.   #--------------------------------------------------------------------------
  464.   # * Aliasing Method: Process Updating
  465.   #--------------------------------------------------------------------------
  466.   alias :u45245045045204 :update
  467.  
  468.   #--------------------------------------------------------------------------
  469.   # * Process Updating
  470.   #--------------------------------------------------------------------------
  471.   def update
  472.     u45245045045204
  473.     update_rewards if $game_party.give_rewards == true
  474.   end
  475.  
  476. end
Advertisement
Add Comment
Please, Sign In to add comment