Advertisement
Guest User

Pro Achievement Script for VX Ace

a guest
Dec 8th, 2014
1,437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.26 KB | None | 0 0
  1. #____________________________________________________________________________#
  2. #         ProAchievements System
  3. #                         V1.0
  4. #
  5. #         Free for commercial and non-commercial use.                      
  6. #___________________________________________________________________________#
  7.  
  8.  
  9. #[Usage]-------------------------------------------------------------------#
  10. #    This script allows you to make achievements! This allows the player   #
  11. #    to look for the achievements to feel rewareded.                      
  12. #--------------------------------------------------------------------------#
  13.  
  14. #[Configuration]-----------------------------------------------------------#
  15. #
  16. #--------------------------------------------------------------------------#
  17.  
  18. $Gold_Achievement_Icon=125
  19. $Silver_Achievement_Icon=126
  20. $Bronze_Achievement_Icon=127
  21.  
  22. $Gold_Achievement_Value=15
  23. $Silver_Achievement_Value=5
  24. $Bronze_Achievement_Value=1
  25.  
  26. $Get_Sound_Effect="Audio/SE/Bell3"
  27.  
  28.  
  29.  
  30. #[Variables]-------------------------------------------------------------#
  31. #
  32.  
  33.         #$Max_Achievements=50
  34. #------------------------------------------------------------------------#
  35.  
  36. $ProPoints=0
  37.  
  38. $Max_Achievements=4
  39. $Ach_ID = Array.new($Max_Achievements)
  40. $ach_id=0
  41.  
  42. $Ach_Title=Array.new($Max_Achievements)
  43. $Ach_Purpose=Array.new($Max_Achievements)
  44. $Ach_Star=Array.new($Max_Achievements)
  45. $Ach_Earned=Array.new($Max_Achievements)
  46.  
  47.  
  48. #[Module DataManager]---------------------------------------------------#
  49. #
  50. #-----------------------------------------------------------------------#
  51.  
  52. module DataManager
  53.   class << self
  54.     alias :old_make_save_contents :make_save_contents
  55.     alias :old_extract_save_contents :extract_save_contents
  56.   end
  57.   def self.make_save_contents
  58.     contents = old_save_contents
  59.     contents[:ach_title] = $Ach_Title
  60.     contents[:ach_purpose] = $Ach_Purpose
  61.     contents[:ach_star] = $Ach_Star
  62.     contents[:ach_earned] = $Ach_Earned
  63.     contents
  64.   end
  65.  
  66.   def self.extract_save_contents(contents)
  67.     old_extract_save_contents(contents)
  68.     $Ach_Title = contents[:ach_title]
  69.     $Ach_Purpose = contents[:quest_desc]
  70.     $Ach_Star = contents[:quest_sender]
  71.     $Ach_Earned = contents[:ach_earned]
  72.   end
  73. end
  74.  
  75.  
  76.  
  77.  
  78.  
  79. #[Achievements Window]--------------------------------------------------#
  80. #
  81. #-----------------------------------------------------------------------#
  82.  
  83. class Window_Achievements < Window_Base
  84.   def initialize
  85.     super(16, 16, Graphics.width-32, Graphics.height-32)
  86.     refresh
  87.   end
  88.  
  89.   def refresh
  90.     contents.clear
  91.     change_color(system_color)
  92.     if $Ach_Title[$ach_id]!=nil
  93.    
  94.     contents.fill_rect(160, line_height, contents.width-160, line_height*3, darker)
  95.     draw_text(160, 0, contents.width, line_height, $Ach_Title[$ach_id])
  96.     draw_text(160, line_height*5, contents.width, line_height, "Value:")
  97.     change_color(normal_color)
  98.     #draw_text(160, line_height, contents.width, line_height, $Ach_Purpose[$ach_id])
  99.     draw_icon($Gold_Achievement_Icon, 160, line_height*4) if $Ach_Star[$ach_id]==2
  100.     draw_icon($Silver_Achievement_Icon, 160, line_height*4) if $Ach_Star[$ach_id]==1
  101.     draw_icon($Bronze_Achievement_Icon, 160, line_height*4) if $Ach_Star[$ach_id]==0
  102.     draw_text(160+24, line_height*4, contents.width, line_height, "Gold") if $Ach_Star[$ach_id]==2
  103.     draw_text(160+24, line_height*4, contents.width, line_height, "Silver") if $Ach_Star[$ach_id]==1
  104.     draw_text(160+24, line_height*4, contents.width, line_height, "Bronze") if $Ach_Star[$ach_id]==0
  105.    
  106.     draw_text(160, line_height*6, contents.width, line_height, $Gold_Achievement_Value) if $Ach_Star[$ach_id]==2
  107.     draw_text(160, line_height*6, contents.width, line_height, $Silver_Achievement_Value) if $Ach_Star[$ach_id]==1
  108.     draw_text(160, line_height*6, contents.width, line_height, $Bronze_Achievement_Value) if $Ach_Star[$ach_id]==0
  109.    
  110.     draw_text(160, line_height*7, contents.width, line_height, "Achievement is not yet earned.") if $Ach_Earned[$ach_id]!=1
  111.     draw_text(160, line_height*7, contents.width, line_height, "Achievement is earned.") if $Ach_Earned[$ach_id]==1
  112.    
  113.     draw_text(160, line_height*13, contents.width, line_height, "Total Points:")
  114.     draw_text(160, line_height*14, contents.width, line_height, $ProPoints)
  115.    
  116.    
  117.     text=sprintf("%s", $Ach_Purpose[$ach_id])
  118.     ypos = line_height
  119.     change_color(normal_color)
  120.     text.split(/\n/).each do |t|
  121.       draw_text(160, ypos, contents.width, line_height, t)
  122.       ypos += line_height
  123.     end
  124.    
  125.   end
  126.    
  127.   end
  128.  
  129.   def darker
  130.     color=Color.new(0, 0, 0, 75)
  131.     color
  132.   end
  133.  
  134.   def update
  135.     super
  136.     refresh
  137.   end
  138. end
  139.  
  140. #[Achievements Selection List]------------------------------------------#
  141. #
  142. #-----------------------------------------------------------------------#
  143. class Achievement_List < Window_Command
  144.   def initialize
  145.     super(16, 16)
  146.     self.opacity=0
  147.   end
  148.  
  149.   def make_command_list
  150.     $i=0
  151.     while $i<$Max_Achievements
  152.       add_command($Ach_Title[$i], :see) if $Ach_Title[$i] != nil
  153.       add_command("Ach-Not Set", :no_set) if $Ach_Title[$i]==nil
  154.       $i+=1
  155.     end
  156.   end
  157.  
  158.   def update
  159.     super
  160.     $ach_id=index
  161.   end
  162. end
  163.    
  164.    
  165. #[Achievements Scene]---------------------------------------------------#
  166. #
  167. #-----------------------------------------------------------------------#
  168.  
  169. class Scene_Achievements < Scene_Base
  170.   def start
  171.     super
  172.     make_stuff
  173.   end
  174.  
  175.   def make_stuff
  176.     @win=Window_Achievements.new
  177.     @cmd=Achievement_List.new
  178.     @cmd.height=@win.height
  179.     @cmd.set_handler(:cancel, method(:return_scene))
  180.   end
  181. end
  182.  
  183. #[Menu Edit]------------------------------------------------------------#
  184. #
  185. #-----------------------------------------------------------------------#
  186.  
  187. class Window_MenuCommand < Window_Command
  188.   alias old_add_original_commands add_original_commands
  189.   def add_original_commands
  190.     old_add_original_commands
  191.     add_command("Achievements", :achievements)
  192.   end
  193. end
  194.  
  195. class Scene_Menu < Scene_MenuBase
  196.   alias old_create_command_window create_command_window
  197.   def create_command_window
  198.     old_create_command_window
  199.     @command_window.set_handler(:achievements, method(:achievements))
  200.   end
  201.  
  202.   def achievements
  203.     SceneManager.call(Scene_Achievements)
  204.   end
  205. end
  206.  
  207. #[Map Popup]------------------------------------------------------------#
  208. #
  209. #-----------------------------------------------------------------------#
  210.  
  211. class Map_Popup < Window_Base
  212.   def initialize
  213.     super(Graphics.width-160, 0, 160, line_height*3)
  214.     $timer=0
  215.     self.hide
  216.     refresh
  217.   end
  218.  
  219.   def refresh
  220.     contents.clear
  221.     draw_text(0, 0, contents.width, line_height, "Achievement Earned!")
  222.     draw_text(0, line_height, contents.width, line_height, $Ach_Title[$ach_id])
  223.   end
  224.  
  225.   def update
  226.     super
  227.     if $Show_Ach_Win==1
  228.       self.show
  229.       if $timer==0
  230.         Audio.se_play($Get_Sound_Effect, 100, 0)
  231.       end
  232.       $timer+=1
  233.      
  234.       if $timer==120
  235.         $Show_Ach_Win=0
  236.         self.hide
  237.         $timer=0
  238.       end
  239.     end
  240.     refresh
  241.   end
  242. end
  243.  
  244. class Scene_Map < Scene_Base
  245.  
  246.   alias old_create_all_windows create_all_windows
  247.   def create_all_windows
  248.     old_create_all_windows
  249.     @Ach_Popup = Map_Popup.new
  250.   end
  251. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement