Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #========================================================================
  2. #    Author:   Calestian VS RPG MAKER VN
  3. #    Name:     Achievement System vs RPG MAKER VN
  4. #    Created:  02-04-2015 (28/8/2017)
  5. #    Version:  1.4 ( 1.5 )
  6. #---------------------------------------------------------------------------
  7. #                       VERSION HISTORY
  8. #
  9. #    v1.0 - Initial Release
  10. #    v1.1 - Quick Bug Fix
  11. #    v1.2 - Added Repeatable Achievements
  12. #    v1.3 - Added Notification Sounds - Updated Prerequisites
  13. #    v1.4 - Quick Fixes - Updated Event Methods
  14. #    v1.5 - Font Baloo Bhaijaan Regular - Size window - Point Fix - Việt Hoá - Giao diện dễ sử dụng
  15. #    Link Font : https://fonts.google.com/specimen/Baloo
  16. #---------------------------------------------------------------------------
  17. #                       FEATURES
  18. #    
  19. #    * Achievement Categories
  20. #    * Locked Achievements (Prerequisites)
  21. #    * Completed Achievements (Colored)
  22. #    * Achievement Rewards
  23. #    * Achievement Point Rewards
  24. #    * Achievement Progression Track
  25. #    * Achievement Notification (Completed | Unlocked | Achievement Points Reached)
  26. #---------------------------------------------------------------------------
  27. #                       How to Setup
  28. #
  29. #    * Set in the Achievement_Categories array your Categories:
  30. #         Achievement_Categories[index] = ["CategoryName", "CategoryDescription"]
  31. #
  32. #    * Set in the Achievements hash your achievement info:
  33. #         :Prerequisite
  34. #             Set to :none means there is no prerequisite
  35. #             Set to [AchievementID, Repeated, Objective]
  36. #                e.g [0, 5, 200]
  37. #         :Item => [ItemType, ItemID, Amount]
  38. #             ItemType: 0 -> Item | 1 -> Armor | 2 -> Weapon
  39. #             ItemID: Taken from Database
  40. #             Amount: How many of the selected item to be given as a reward
  41. #         :Repeatable => false | value
  42. #             false -> One time Achievement
  43. #             value (eg. 50) -> Repeatable value(50) times
  44. #    
  45. #    * Set in the Achievement_Point_Rewards array your AP rewards:
  46. #         Achievement_Point_Rewards[index] = [[ItemType, ItemID, Amount], [ItemType, ItemID, Amount], ... , [ItemType, ItemID, Amount]
  47. #  
  48. #    * Edit Settings
  49. #---------------------------------------------------------------------------
  50. #                       How to Use
  51. #
  52. #    In the Event -> Script:
  53. #       * gain_achievement(amount, index) Thêm    # Index -> Achievements Hash Index
  54. #       * lose_achievement(amount, index) Trừ
  55. #       *  set_achievement(amount, index) Gán
  56. #      
  57. #       * gain_achievement_points(amount)
  58. #       * lose_achievement_points(amount)
  59. #       *  set_achievement_points(amount)
  60. #
  61. #       * achievement_name(index)
  62. #       * achievement_item(index)
  63. #       * achievement_gold(index)
  64. #       * achievement_points(index)
  65. #       * achievement_title(index)
  66. #       * achievement_repeated(index)
  67. #       * achievement_progress(index)
  68. #       * achievement_status(index)
  69. #       * party_achievement_points
  70. #---------------------------------------------------------------------------
  71. #                       LICENSE INFO
  72. #
  73. #    Free for non-commercial & commercial use, as long as credit is given
  74. #    to Calestian
  75. #===========================================================================
  76.  
  77. #===========================================================================
  78. # *** Editable Region
  79. #===========================================================================
  80. module Clstn_Achievement_System
  81.  
  82.   #--------------------------------------------------------------------------
  83.   # * Achievement Categories
  84.   #--------------------------------------------------------------------------
  85.   Achievement_Categories = []
  86.  
  87.   Achievement_Categories[0] = ["Sưu Tầm"      , "Sưu Tầm Vật Hiếm"]
  88.   Achievement_Categories[1] = ["Khám Phá"      , "Thành Tựu Khám Phá Map"           ]
  89.   Achievement_Categories[2] = ["Đánh Bại"       , "Giết Quái"                  ]
  90.   Achievement_Categories[3] = ["Trang Bị", "Sử Dụng Vũ Khí Mạnh"                 ]
  91.   Achievement_Categories[4] = ["Chế Tạo"  , "Chế Tạo Vật Hiếm"                 ]
  92.   Achievement_Categories[5] = ["PvP"          , "Vô Địch Vs Mọi Đối Thủ"            ]
  93.  
  94.   #--------------------------------------------------------------------------
  95.   # * Achievements
  96.   #--------------------------------------------------------------------------
  97.   Achievements = {
  98.  
  99.     0 => {
  100.       :Name              => "Máy X",
  101.       :Tiers             => [5],
  102.       :Help              => "Máy Do Tổ Chức XM Chế Tạo",
  103.       :Title             => "Tìm Kiếm",
  104.       :RewardItem        => [0, 005, 50],
  105.       :RewardGold        => 100,
  106.       :Category          => "Sưu Tầm",
  107.       :AchievementPoints => 100,
  108.       :Prerequisite      => :none,
  109.       :Repeatable        => 5,
  110.     },
  111.    
  112.     1 => {
  113.       :Name              => "Đồ Sơn",
  114.       :Tiers             => [50, 100, 150, 200, 250],
  115.       :Help              => "Khám Phá Đồ Sơn",
  116.       :Title             => :none,
  117.       :RewardItem        => :none,
  118.       :RewardGold        => :none,
  119.       :Category          => "Khám Phá",
  120.       :AchievementPoints => :none,
  121.       :Prerequisite      => [0, 2, 4],
  122.       :Repeatable        => 10,
  123.     },
  124.    
  125.     2 => {
  126.       :Name              => "Chơi Gái",
  127.       :Tiers             => [50, 100, 150, 200, 250],
  128.       :Help              => "Đánh Bại 10 Em",
  129.       :Title             => "Phê Là Được",
  130.       :RewardItem        => [0, 001, 50],
  131.       :RewardGold        => 100,
  132.       :Category          => "Đánh Bại",
  133.       :AchievementPoints => 100,
  134.       :Prerequisite      => :none,
  135.       :Repeatable        => false,
  136.     },
  137.    
  138.     3 => {
  139.       :Name              => "Mặc Mười Cái 10 Quần",
  140.       :Tiers             => [50],
  141.       :Help              => "Bạn Hãy Trang Bị 10 Cái Quần",
  142.       :Title             => "10 Cái Quần ",
  143.       :RewardItem        => [0, 001, 50],
  144.       :RewardGold        => 100,
  145.       :Category          => "Trang Bị",
  146.       :AchievementPoints => 100,
  147.       :Prerequisite      => :none,
  148.       :Repeatable        => false,
  149.     },
  150.    
  151.     4 => {
  152.       :Name              => "Chế Tạo SEXtoy",
  153.       :Tiers             => [50],
  154.       :Help              => "Hãy Mua Bên Nhật",
  155.       :Title             => "Sextoy",
  156.       :RewardItem        => [0, 001, 50],
  157.       :RewardGold        => 100,
  158.       :Category          => "Chế Tạo",
  159.       :AchievementPoints => 100,
  160.       :Prerequisite      => :none,
  161.       :Repeatable        => false,
  162.     },
  163.    
  164.     5 => {
  165.       :Name              => "Phòng Chóng Sửu Nhi",
  166.       :Tiers             => [50, 100, 150, 200],
  167.       :Help              => "Hãy giết người",
  168.       :Title             => "Sửu Nhi",
  169.       :RewardItem        => [0, 001, 50],
  170.       :RewardGold        => 100,
  171.       :Category          => "PvP",
  172.       :AchievementPoints => 100,
  173.       :Prerequisite      => :none,
  174.       :Repeatable        => 50,
  175.     },
  176.    
  177.    
  178.     6 => {
  179.       :Name              => "Tìm Kiếm Admin",
  180.       :Tiers             => [1],
  181.       :Help              => "Vào Quán Bar",
  182.       :Title             => "Tìm Boss",
  183.       :RewardItem        => [0, 001, 50],
  184.       :RewardGold        => 100,
  185.       :Category          => "Khám Phá",
  186.       :AchievementPoints => 100,
  187.       :Prerequisite      => :none,
  188.       :Repeatable        => 10,
  189.     },
  190.  
  191.     7 => {
  192.       :Name              => "Học Hỏi",
  193.       :Tiers             => [50, 100, 150, 200, 250],
  194.       :Help              => "Chém 10 Thằng Sạo ler",
  195.       :Title             => "Học Hỏi Chết Chóc",
  196.       :RewardItem        => [0, 001, 50],
  197.       :RewardGold        => 100,
  198.       :Category          => "PvP",
  199.       :AchievementPoints => 100,
  200.       :Prerequisite      => :none,
  201.       :Repeatable        => 50,
  202.     },
  203.    
  204.     8 => {
  205.       :Name              => "Xem Gái Tắm",
  206.       :Tiers             => [50, 100, 150, 200, 250],
  207.       :Help              => "Nơi Gái Tắm Nhiều Là Đồ Sơn",
  208.       :Title             => "Mở Mang Kiến Thức",
  209.       :RewardItem        => [1, 001, 50],
  210.       :RewardGold        => 100,
  211.       :Category          => "Khám Phá",
  212.       :AchievementPoints => 100,
  213.       :Prerequisite      => :none,
  214.       :Repeatable        => 50,
  215.     },
  216.    
  217.     9 => {
  218.       :Name              => "Phê Cần Xa",
  219.       :Tiers             => [50, 100, 150, 200, 250],
  220.       :Help              => "Hít Lá Cần",
  221.       :Title             => "Phê",
  222.       :RewardItem        => [2, 001, 50],
  223.       :RewardGold        => 100,
  224.       :Category          => "khám phá",
  225.       :AchievementPoints => 100,
  226.       :Prerequisite      => :none,
  227.       :Repeatable        => 50,
  228.     },
  229.    
  230.     10 => {
  231.       :Name              => "Thuốc Kích Dục",
  232.       :Tiers             => [50, 100, 150, 200, 250],
  233.       :Help              => "Bạn Hãy Qua Nhật Mua Nguyên Liệu Nhé",
  234.       :Title             => "Thuốc Kích Dục",
  235.       :RewardItem        => [0, 001, 50],
  236.       :RewardGold        => 100,
  237.       :Category          => "chế tạo",
  238.       :AchievementPoints => 100,
  239.       :Prerequisite      => :none,
  240.       :Repeatable        => 50,
  241.     },
  242.    
  243.   }
  244.  
  245.   Achievement_Point_Rewards    = []
  246.   Achievement_Point_Rewards[0] = [1000,   [[1, 001, 50], [0, 001, 10], [2, 001, 30]]]
  247.   Achievement_Point_Rewards[1] = [5000,   [[1, 001, 50], [0, 001, 10], [2, 001, 30]]]
  248.   Achievement_Point_Rewards[2] = [10000,  [[1, 001, 50], [0, 001, 10], [2, 001, 30]]]
  249.   Achievement_Point_Rewards[3] = [50000,  [[1, 001, 50], [0, 001, 10], [1, 001, 30]]]
  250.   Achievement_Point_Rewards[4] = [100000, [[1, 001, 50], [0, 001, 10], [1, 001, 30]]]
  251.  
  252.    
  253.   #-----------------------------------------------------------------------
  254.   # * Settings
  255.   #-----------------------------------------------------------------------
  256.   Achievement_Display        = :Both     # :Color | :Icon | :Both
  257.   Category_Icon_Disabled     = 337       # Category Icon when not Expanded
  258.   Category_Icon_Enabled      = 345       # Category Icon when Expanded
  259.   Achievement_Points_Icon    = 125       # Achievement_Points_Icon = IconID
  260.   Achievement_Unlocked_Icon  = 359       # Achievement_Unlocked_Icon = IconID
  261.   Achievement_Locked_Icon    = 243       # Achievement_Locked_Icon = IconID
  262.   Achievement_Completed_Icon = 431       # Achievement_Completed_Icon = IconID
  263.   Achievement_Points_color   = 21        # Achievement_Points_Color = ColorID
  264.   Notification_Sound         = "Absorb2" # "SoundName"
  265.   Notification_Window        = true      # Notification Window Enabled
  266.    
  267. #===========================================================================
  268. # *** End of Editable Region
  269. #===========================================================================
  270.  
  271.   #--------------------------------------------------------------------------
  272.   # * Get Achievement Categories
  273.   #--------------------------------------------------------------------------
  274.   def self.get_achievement_categories
  275.     @achievement_categories = []
  276.     Achievement_Categories.each { |value|
  277.       @achievement_categories.push(value[0])
  278.     }
  279.     return @achievement_categories
  280.   end
  281.  
  282.   #--------------------------------------------------------------------------
  283.   # * Get Category Achievements
  284.   #--------------------------------------------------------------------------
  285.   def self.get_category_achievements
  286.     category = []
  287.     Achievement_Categories.each { |key|
  288.       temp = []
  289.       Achievements.each_value { |value|
  290.         temp.push(value[:Name]) if value[:Category] == key[0]
  291.       }
  292.       category.push(temp.empty? ? 0 : temp)
  293.     }
  294.     return category
  295.   end
  296.  
  297.   #--------------------------------------------------------------------------
  298.   # * Tier?
  299.   #--------------------------------------------------------------------------
  300.   def self.tier?(item)
  301.     progress = $game_party.achievements[find_achievement_index(item[:Name])]
  302.     item[:Tiers].size.times { |i|
  303.       return item[:Tiers].size - 1 if item[:Tiers][-1] == progress
  304.       return i if item[:Tiers][i] > progress
  305.     }
  306.   end
  307.  
  308.   #--------------------------------------------------------------------------
  309.   # * Locked?
  310.   #--------------------------------------------------------------------------
  311.   def self.locked?(item)
  312.     item = Achievements[find_achievement_index(item)] if item.is_a?(String)
  313.     return false if item[:Prerequisite] == :none
  314.     return completed?(item) ? false : true
  315.   end
  316.  
  317.   #--------------------------------------------------------------------------
  318.   # * Completed?
  319.   #--------------------------------------------------------------------------
  320.   def self.completed?(item)
  321.     index = item[:Prerequisite][0]
  322.     limit = item[:Prerequisite][1]
  323.     tier  = item[:Prerequisite][2]
  324.     return $game_party.achievement_repeated[index] >= limit && $game_party.achievements[index] >= tier ? true : false
  325.   end
  326.  
  327.  
  328.   #--------------------------------------------------------------------------
  329.   # * Find Achievement Index
  330.   #--------------------------------------------------------------------------
  331.   def self.find_achievement_index(item)
  332.     Achievements.size.times { |index|
  333.       return index if item == Achievements[index][:Name]
  334.     }
  335.   end
  336.  
  337.   #--------------------------------------------------------------------------
  338.   # * Find Category Index
  339.   #--------------------------------------------------------------------------
  340.   def self.find_category_index(item)
  341.     Achievement_Categories.size.times { |index|
  342.       return index if item[index][0] == Achievement_Categories[index]
  343.     }
  344.   end
  345.  
  346.   #--------------------------------------------------------------------------
  347.   # * Get Achievement Point Rewards
  348.   #--------------------------------------------------------------------------
  349.   def self.get_point_rewards
  350.     Achievement_Point_Rewards.each { |value|
  351.       return value[0] if value[0] > $game_party.achievement_points
  352.     }
  353.     return Achievement_Point_Rewards[-1][0]
  354.   end
  355.  
  356.   #--------------------------------------------------------------------------
  357.   # * Get Achievement Status
  358.   #--------------------------------------------------------------------------
  359.   def self.get_achievement_status
  360.     status = []
  361.     Achievements.each_value { |value|
  362.       value[:Prerequisite] == :none ? status.push(:Unlocked) : status.push(:Locked)
  363.     }
  364.     return status
  365.   end
  366.  
  367. end
  368.  
  369. #===========================================================================
  370. # *** Window Menu Command
  371. #===========================================================================
  372. class Window_MenuCommand < Window_Command
  373.  
  374.   #--------------------------------------------------------------------------
  375.   # * Aliases
  376.   #--------------------------------------------------------------------------
  377.   alias :clstn_achievements_add_original_commands :add_original_commands
  378.   alias :clstn_achievements_initialize            :initialize
  379.  
  380.   #--------------------------------------------------------------------------
  381.   # * Initialize
  382.   #--------------------------------------------------------------------------
  383.   def initialize
  384.     clstn_achievements_initialize
  385.     $game_party.notifications.clear
  386.     $game_party.notification_enabled = false
  387.   end
  388.  
  389.   #--------------------------------------------------------------------------
  390.   # * Original Command
  391.   #--------------------------------------------------------------------------
  392.   def add_original_commands
  393.     clstn_achievements_add_original_commands
  394.     add_command("Thành Tựu", :achievements, true)
  395.   end
  396.  
  397. end
  398.  
  399. #===========================================================================
  400. # *** Window Achievement Header
  401. #===========================================================================
  402. class Window_AchievementHeader < Window_Base
  403.  
  404.   #--------------------------------------------------------------------------
  405.   # * Initialize
  406.   #--------------------------------------------------------------------------
  407.   def initialize
  408.     super(0, 0, Graphics.width, 50)
  409.     refresh
  410.   end
  411.  
  412.   #--------------------------------------------------------------------------
  413.   # * Refresh
  414.   #--------------------------------------------------------------------------
  415.   def refresh
  416.     contents.font.name = "Baloo Bhaijaan Regular"
  417.     contents.font.size = 22
  418.     next_reward = Clstn_Achievement_System::get_point_rewards
  419.     change_color(text_color(Clstn_Achievement_System::Achievement_Points_color))
  420.     draw_icon(Clstn_Achievement_System::Achievement_Points_Icon, 10, 0)
  421.     draw_text(35, 1, contents.width, contents.height, $game_party.achievement_points)
  422.     change_color(text_color(0))
  423.     draw_text( 0, 1, contents.width, contents.height, "Phần Thưởng Còn Lại : ", 1)
  424.     change_color(text_color(Clstn_Achievement_System::Achievement_Points_color))
  425.     draw_icon(Clstn_Achievement_System::Achievement_Points_Icon,160, 0)
  426.     draw_text(340, 2, contents.width, contents.height, next_reward)
  427.   end
  428.  
  429. end
  430.  
  431. #===========================================================================
  432. # *** Window Achievement Info
  433. #===========================================================================
  434. class Window_AchievementInfo < Window_Base
  435.  
  436.   #--------------------------------------------------------------------------
  437.   # * Initialize
  438.   #--------------------------------------------------------------------------
  439.   def initialize
  440.     super(Graphics.width - 250, 50, Graphics.width - 295, Graphics.height - 50)
  441.   end
  442.  
  443.   #--------------------------------------------------------------------------
  444.   # * Refresh
  445.   #--------------------------------------------------------------------------
  446.   def refresh(item, symbol)
  447.     contents.clear
  448.     @item = item
  449.     if symbol == :category
  450.       draw_name
  451.     elsif symbol == :achievement
  452.       @index = Clstn_Achievement_System::find_achievement_index(item[:Name])
  453.       draw_name(false)
  454.       draw_progress
  455.       draw_reward
  456.     end
  457.   end
  458.  
  459.   #--------------------------------------------------------------------------
  460.   # * Draw Name
  461.   #--------------------------------------------------------------------------
  462.   def draw_name(enabled = true)
  463.     draw_information(22, enabled ? 16 : 0, 0, 0, enabled ? @item[0] : @item[:Name], 1)
  464.     draw_information(20, enabled ? 0 : 16, 0, 30, enabled ? @item[1] : @item[:Help])
  465.   end
  466.  
  467.   #--------------------------------------------------------------------------
  468.   # * Draw Progress
  469.   #--------------------------------------------------------------------------
  470.   def draw_progress
  471.     contents.font.name = "Baloo Bhaijaan Regular"
  472.     tier = Clstn_Achievement_System::tier?(@item)
  473.     draw_information(22,  0,  0,  60, "Tiến Trình")
  474.     draw_horz_line(75)
  475.     draw_information(20,  0,  0,  90,      "Tầng : ")
  476.     draw_information(20, 16, 50,  90,          tier)
  477.     draw_information(20,  0,  0, 120, "Hoàn Thành : ")
  478.     draw_information(20, 16, 90, 120, $game_party.achievements[@index].to_s + "/" + @item[:Tiers][tier].to_s)
  479.     draw_gauge(0, 142, contents.width, get_achievement_rate(@item[:Tiers][tier], @index), text_color(22), text_color(23))
  480.   end
  481.  
  482.   #--------------------------------------------------------------------------
  483.   # * Draw Rewards
  484.   #--------------------------------------------------------------------------
  485.   def draw_reward
  486.     repeatable  = check_variable_condition(@item[:Repeatable],        false)
  487.     gold        = check_variable_condition(@item[:RewardGold],        :none)
  488.     points      = check_variable_condition(@item[:AchievementPoints], :none)
  489.     title       = check_variable_condition(@item[:Title],             :none)
  490.     item_reward = check_variable_condition(@item[:RewardItem],        :none)
  491.     draw_horz_line(185)
  492.     draw_information(22, 0, 0, 170, "Phần Thưởng")
  493.     draw_information(20, 0, 0, 200,  "Vật Phẩm : ")
  494.     if item_reward == "-"
  495.       draw_information(20, 16, 80, 200, "-")
  496.     else
  497.       draw_item_name($game_party.get_item(item_reward), 80, 204, true, 172)
  498.     end
  499.     draw_information(20,  0,  0, 230,     "Tiền : ")
  500.     draw_information(20, 16, 50, 230,         gold)
  501.     draw_information(20,  0,  0, 260,    "Mục Đích : ")
  502.     draw_information(20, 16, 80, 260,        title)
  503.     draw_information(20, 21, 25, 289,       points)
  504.     draw_icon(Clstn_Achievement_System::Achievement_Points_Icon, 0, 290)
  505.     draw_prerequisites(repeatable)
  506.   end
  507.  
  508.   #--------------------------------------------------------------------------
  509.   # * Draw Prerequisites
  510.   #--------------------------------------------------------------------------
  511.   def draw_prerequisites(repeatable)
  512.     draw_information(18, 16,  0, 320, "Nhận Thành Tựu Nhiều Lần") if repeatable && $game_party.achievement_repeated[@index] == -1 && $game_party.achievement_status[@index] != :Locked
  513.     draw_information(18, 16,  0, 320, "Số Lần " + "  " + $game_party.achievement_repeated[@index].to_s + "/" + Clstn_Achievement_System::Achievements[@index][:Repeatable].to_s) if repeatable && $game_party.achievement_repeated[@index] >= 0
  514.     pre_achievement = Clstn_Achievement_System::Achievements
  515.     if $game_party.achievement_status[@index] == :Locked
  516.       pre_achievement = Clstn_Achievement_System::Achievements
  517.       current_information = $game_party.achievement_repeated[@item[:Prerequisite][0]] >= @item[:Prerequisite][1] ? 2 : 1
  518.       time = (@item[:Prerequisite][current_information] - pre_achievement[@index][:Prerequisite][current_information]) == 1  ? "Một Lần" : " Lần"
  519.       prerequisite = time == "Một Lần" ? "" : @item[:Prerequisite][current_information]
  520.       draw_information(18, 16,  0, 320, line = current_information == 1 ? "Nhận Thành Tựu  " : "Cập Nhật ")
  521.       draw_information(18, 21, text_size(line).width, 320, name = pre_achievement[@item[:Prerequisite][0]][:Name])
  522.       draw_information(18, 13, text_size(line).width + text_size(name).width, 320, "   " + prerequisite.to_s + time)
  523.     end
  524.   end
  525.  
  526.   #--------------------------------------------------------------------------
  527.   # * Check Variable Condition
  528.   #--------------------------------------------------------------------------
  529.   def check_variable_condition(variable, condition)
  530.     return variable == condition ? condition == false ? false : "-" : condition == false ? true : variable
  531.   end
  532.  
  533.   #--------------------------------------------------------------------------
  534.   # * Draw Information
  535.   #--------------------------------------------------------------------------
  536.   def draw_information(font_size, color_id, x, y, text, allignment = 0)
  537.     contents.font.size = font_size
  538.     change_color(text_color(color_id))
  539.     draw_text(x, y, contents.width, 30, text, allignment)
  540.   end
  541.  
  542.   #--------------------------------------------------------------------------
  543.   # * Draw Item Name
  544.   #--------------------------------------------------------------------------
  545.   def draw_item_name(item, x, y, enabled = true, width = 172)
  546.     return unless item
  547.     draw_icon(item.icon_index, x, y, enabled)
  548.     change_color(text_color(16), enabled)
  549.     draw_text(x + 24, y, width, line_height, item.name)
  550.   end
  551.  
  552.   #--------------------------------------------------------------------------
  553.   # * To Tier Number
  554.   #--------------------------------------------------------------------------
  555.   def to_tier(tier)
  556.     case tier
  557.     when 0
  558.       return "I"
  559.     when 1
  560.       return "II"
  561.     when 2
  562.       return "III"
  563.     when 3
  564.       return "IV"
  565.     when 4
  566.       return "V"
  567.     when 5
  568.       return "VI"
  569.     when 6
  570.       return "VII"
  571.     when 7
  572.       return "VIII"
  573.     when 8
  574.       return "IX"
  575.     when 9
  576.       return "X"
  577.     end
  578.   end
  579.  
  580.   #--------------------------------------------------------------------------
  581.   # * Get Achievement Rate
  582.   #--------------------------------------------------------------------------
  583.   def get_achievement_rate(objective, index)
  584.     return ($game_party.achievements[index].to_f / objective.to_f)
  585.   end
  586.  
  587.   #--------------------------------------------------------------------------
  588.   # * Draw Horizontal Line
  589.   #--------------------------------------------------------------------------
  590.   def draw_horz_line(y)
  591.     line_y = y + line_height / 2 - 1
  592.     contents.fill_rect(0, line_y, contents_width, 2, text_color(16))
  593.   end
  594.  
  595. end
  596.  
  597. #===========================================================================
  598. # *** Window Achievements
  599. #===========================================================================
  600. class Window_Achievements < Window_Selectable
  601.  
  602.   #--------------------------------------------------------------------------
  603.   # * Initialize
  604.   #--------------------------------------------------------------------------
  605.   def initialize(x, y, width, height)
  606.     super
  607.     @achievement_info_window = Window_AchievementInfo.new
  608.     @data = []
  609.     @category = []
  610.     @achievements = []
  611.     @category_icons = []
  612.     set_category_icons
  613.     refresh
  614.     select(0)
  615.   end
  616.  
  617.   #--------------------------------------------------------------------------
  618.   # * Category Icons
  619.   #--------------------------------------------------------------------------
  620.   def set_category_icons
  621.     Clstn_Achievement_System::Achievement_Categories.each { |value|
  622.       @category_icons.push(Clstn_Achievement_System::Category_Icon_Disabled)
  623.     }
  624.   end
  625.  
  626.   #--------------------------------------------------------------------------
  627.   # * Get Item
  628.   #--------------------------------------------------------------------------
  629.   def item
  630.     @data && index >= 0 ? @data[index] : nil
  631.   end
  632.  
  633.   #--------------------------------------------------------------------------
  634.   # * Get Item Max
  635.   #--------------------------------------------------------------------------
  636.   def item_max
  637.     @data ? @data.size : 1
  638.   end
  639.  
  640.   #--------------------------------------------------------------------------
  641.   # * Make Item List
  642.   #--------------------------------------------------------------------------
  643.   def make_item_list
  644.     @category = Clstn_Achievement_System::get_achievement_categories     unless !@category.empty?
  645.     @achievements = Clstn_Achievement_System::get_category_achievements  unless !@achievements.empty?
  646.     @data = Clstn_Achievement_System::get_achievement_categories         unless !@data.empty?
  647.   end
  648.  
  649.   #--------------------------------------------------------------------------
  650.   # * Draw Item
  651.   #--------------------------------------------------------------------------
  652.   def draw_item(index)
  653.     contents.font.size = 22
  654.     @category_helper = index == 0 ? index : @category_helper
  655.     item = @data[index]
  656.     rect = item_rect(index)
  657.     change_color(text_color(0))
  658.     if item && category?(item)
  659.       draw_icon(@category_icons[@category_helper], rect.x + 10, rect.y)
  660.       draw_text(rect.x + 40, rect.y, contents.width - 40, line_height, item)
  661.       @category_helper += 1
  662.     elsif item
  663.       id = Clstn_Achievement_System::find_achievement_index(item)
  664.       temp = find_item_achievement(item)
  665.       change_color(text_color(21)) if $game_party.achievement_status[id] == :Completed && (Clstn_Achievement_System::Achievement_Display == :Color || Clstn_Achievement_System::Achievement_Display == :Both)
  666.       if Clstn_Achievement_System::Achievement_Display == :Icon || Clstn_Achievement_System::Achievement_Display == :Both
  667.         if $game_party.achievement_status[id] == :Completed
  668.           icon = Clstn_Achievement_System::Achievement_Completed_Icon
  669.         elsif $game_party.achievement_status[id] == :Locked
  670.           icon = Clstn_Achievement_System::Achievement_Locked_Icon
  671.         else
  672.           icon = Clstn_Achievement_System::Achievement_Unlocked_Icon
  673.         end
  674.         draw_icon(icon, rect.x + 7, rect.y)
  675.       else
  676.         draw_icon(Clstn_Achievement_System::Achievement_Unlocked_Icon, rect.x + 7, rect.y)
  677.       end
  678.       draw_text(rect.x + 35, rect.y, rect.width, line_height, item)
  679.       contents.font.size = 15
  680.       change_color(text_color(16))
  681.       draw_text(227, rect.y + 1, rect.width, line_height, "Bị Khoá") if $game_party.achievement_status[id] == :Locked
  682.       change_color(text_color(0))
  683.     end
  684.   end
  685.  
  686.   #--------------------------------------------------------------------------
  687.   # * Item Rect
  688.   #--------------------------------------------------------------------------
  689.   def item_rect(index)
  690.     update_info_window(@data[index])
  691.     x_spacing = category?(@data[index]) ? 0 : 20
  692.     rect = Rect.new
  693.     rect.width = item_width - x_spacing
  694.     rect.height = item_height
  695.     rect.x = index % col_max * (item_width + spacing) + x_spacing
  696.     rect.y = index / col_max * item_height
  697.     rect
  698.   end
  699.  
  700.   #--------------------------------------------------------------------------
  701.   # * Update Info Window
  702.   #--------------------------------------------------------------------------
  703.   def update_info_window(item)
  704.     if category?(item)
  705.       item = find_item_category(item)
  706.       symbol = :category
  707.     else
  708.       item = find_item_achievement(item)
  709.       symbol = :achievement
  710.     end
  711.     @achievement_info_window.refresh(item, symbol)
  712.   end
  713.  
  714.   #--------------------------------------------------------------------------
  715.   # * Find Item Achievement
  716.   #--------------------------------------------------------------------------
  717.   def find_item_achievement(item)
  718.     Clstn_Achievement_System::Achievements.each_value { |value|
  719.       return value if value[:Name] == item
  720.     }
  721.   end
  722.  
  723.   #--------------------------------------------------------------------------
  724.   # * Find Item Category
  725.   #--------------------------------------------------------------------------
  726.   def find_item_category(item)
  727.     Clstn_Achievement_System::Achievement_Categories.each { |value|
  728.       return value if value[0] == item
  729.     }
  730.   end
  731.  
  732.   #--------------------------------------------------------------------------
  733.   # * Expand
  734.   #--------------------------------------------------------------------------
  735.   def expand
  736.     data_index = get_data_index(item)
  737.     @category_index = get_category_index(item)
  738.     if category?(item)
  739.       @category_icons[@category_index] = @category_icons[@category_index] == Clstn_Achievement_System::Category_Icon_Enabled ? Clstn_Achievement_System::Category_Icon_Disabled : Clstn_Achievement_System::Category_Icon_Enabled
  740.       if @achievements[@category_index] != 0
  741.         @achievements[@category_index].size.times { |i|
  742.           expanded?(@category_index) ? @data.insert(data_index + 1 + i, @achievements[@category_index][i]) : @data.delete_at(data_index + 1)
  743.         }
  744.       end
  745.     end
  746.     refresh
  747.   end
  748.  
  749.   #--------------------------------------------------------------------------
  750.   # * Get Category Index
  751.   #--------------------------------------------------------------------------
  752.   def get_category_index(item)
  753.     @category.size.times { |index|
  754.       return index if @category[index] == item
  755.     }
  756.   end
  757.  
  758.   #--------------------------------------------------------------------------
  759.   # * Get Data Index
  760.   #--------------------------------------------------------------------------
  761.   def get_data_index(item)
  762.     @data.size.times { |index|
  763.       return index if @data[index] == item
  764.     }
  765.   end
  766.  
  767.   #--------------------------------------------------------------------------
  768.   # * Expanded?
  769.   #--------------------------------------------------------------------------
  770.   def expanded?(index)
  771.     return @category_icons[index] == Clstn_Achievement_System::Category_Icon_Enabled && @category[index] != 0 ? true : false
  772.   end
  773.  
  774.   #--------------------------------------------------------------------------
  775.   # * Category?
  776.   #--------------------------------------------------------------------------
  777.   def category?(item)
  778.     return @category.include?(item)
  779.   end
  780.  
  781.   #--------------------------------------------------------------------------
  782.   # * Refresh
  783.   #--------------------------------------------------------------------------
  784.   def refresh
  785.     make_item_list
  786.     create_contents
  787.     draw_all_items
  788.   end
  789.  
  790.   #--------------------------------------------------------------------------
  791.   # * Dispose
  792.   #--------------------------------------------------------------------------
  793.   def dispose
  794.     super
  795.     @achievement_info_window.dispose
  796.   end
  797.  
  798. end
  799.  
  800. #===========================================================================
  801. # *** Class Window_AchievementNotification
  802. #===========================================================================
  803. class Window_AchievementNotification < Window_Base
  804.  
  805.   #--------------------------------------------------------------------------
  806.   # * Initialize
  807.   #--------------------------------------------------------------------------
  808.   def initialize
  809.     @window = $game_party.notifications[0][1]
  810.     @item   = $game_party.notifications[0][0]
  811.     super(x, 0, width, height)
  812.     $game_party.notification_enabled = false
  813.     refresh
  814.   end
  815.  
  816.   #--------------------------------------------------------------------------
  817.   # * Aliases
  818.   #--------------------------------------------------------------------------
  819.   alias :clstn_update_windowbase :update
  820.  
  821.   #--------------------------------------------------------------------------
  822.   # * Get x
  823.   #--------------------------------------------------------------------------
  824.   def x
  825.     case @window
  826.     when :completed
  827.       return Graphics.width / 4
  828.     when :unlocked
  829.       return Graphics.width / 4 + 28
  830.     when :points
  831.       return Graphics.width / 4 - 3
  832.     end
  833.   end
  834.  
  835.   #--------------------------------------------------------------------------
  836.   # * Get Width
  837.   #--------------------------------------------------------------------------
  838.   def width
  839.     case @window
  840.     when :completed
  841.       return Graphics.width / 2
  842.     when :unlocked
  843.       return Graphics.width / 2 - 56
  844.     when :points
  845.       return Graphics.width / 2 + 6
  846.     end
  847.   end
  848.  
  849.   #--------------------------------------------------------------------------
  850.   # * Get Height
  851.   #--------------------------------------------------------------------------
  852.   def height
  853.     case @window
  854.     when :completed
  855.       return Graphics.height - 310
  856.     when :unlocked
  857.       return 0 if @item.empty?
  858.       return 50 + @item.size * 25
  859.     when :points
  860.       return 50 + @item[1].size * 26
  861.     end
  862.   end
  863.  
  864.   #--------------------------------------------------------------------------
  865.   # * Refresh
  866.   #--------------------------------------------------------------------------
  867.   def refresh
  868.     contents.clear
  869.     RPG::SE.new(Clstn_Achievement_System::Notification_Sound, 80, 100).play
  870.     case @window
  871.     when :completed
  872.       draw_completed
  873.     when :unlocked
  874.       draw_unlocked
  875.     when :points
  876.       draw_points
  877.     end
  878.   end
  879.  
  880.   #--------------------------------------------------------------------------
  881.   # * Notification: Achievement Completed
  882.   #--------------------------------------------------------------------------
  883.   def draw_completed
  884.     title = @item[:Title] == :none ? "-" : @item[:Title].to_s
  885.     points =  @item[:AchievementPoints] == :none ? "-" : @item[:AchievementPoints]
  886.     contents.font.size = 20
  887.     draw_text(0, 0, contents.width, 20, "Hoàn Thành Thành Tích !", 1)
  888.     draw_horz_line(10)
  889.     contents.font.size = 19
  890.     draw_text(0, 20, contents.width, 30, @item[:Name], 1)
  891.     draw_text(0, 40, contents.width, 30, "Mục Đích : " + title, 1)
  892.     change_color(text_color(16))
  893.     draw_icon(Clstn_Achievement_System::Achievement_Points_Icon, 90, 60)
  894.     change_color(text_color(21))
  895.     draw_text(115, 60, contents.width, 30, points, 0)
  896.   end
  897.  
  898.   #--------------------------------------------------------------------------
  899.   # * Notification: Achievement Unlocked
  900.   #--------------------------------------------------------------------------
  901.   def draw_unlocked
  902.     contents.font.size = 20
  903.     draw_text(0, 0, contents.width, 20, "Thành Tích Mở Khoá", 1)
  904.     draw_horz_line(10)
  905.     @item.size.times { |i|
  906.       draw_text(0, 30 + 25 * i, contents.width, 20, @item[i], 1)
  907.     }
  908.   end
  909.  
  910.   #--------------------------------------------------------------------------
  911.   # * Notification: Achievement Points Reached
  912.   #--------------------------------------------------------------------------
  913.   def draw_points
  914.     draw_text(0, 0, contents.width, 20, "Phần Thưởng Điểm Thành Tích", 1)
  915.     draw_horz_line(13)
  916.     i = 0
  917.     @item[1].each { |key|
  918.       item = key
  919.       draw_item_name($game_party.get_item(item), key[2], 0, 30 + 25 * i)
  920.       i += 1
  921.     }
  922.   end
  923.  
  924.   #--------------------------------------------------------------------------
  925.   # * Draw Item Name
  926.   #--------------------------------------------------------------------------
  927.   def draw_item_name(item, amount, x, y)
  928.     return unless item
  929.     contents.font.size = 21
  930.     draw_icon(item.icon_index, x, y)
  931.     draw_text(x + 24, y, contents.width, line_height, item.name)
  932.     change_color(text_color(16))
  933.     contents.font.size = 18
  934.     draw_text(0, y - 1, contents.width, 30, "x" + amount.to_s, 2)
  935.     change_color(text_color(0))
  936.   end
  937.  
  938.   #--------------------------------------------------------------------------
  939.   # * Draw Horizontal Line
  940.   #--------------------------------------------------------------------------
  941.   def draw_horz_line(y)
  942.     line_y = y + line_height / 2 - 1
  943.     contents.fill_rect(0, line_y, contents_width, 2, text_color(16))
  944.   end
  945.  
  946.   #--------------------------------------------------------------------------
  947.   # * Frame Update
  948.   #--------------------------------------------------------------------------
  949.   def update
  950.     if !disposed? && self.opacity > 0
  951.       self.opacity -= 1
  952.       self.contents_opacity -= 1
  953.       self.back_opacity -= 1
  954.     else
  955.       $game_party.notifications.delete_at(0) unless $game_party.notifications.empty?
  956.       if !$game_party.notifications.empty?
  957.         $game_party.notification_enabled = true
  958.         SceneManager.call(Scene_Map)
  959.       else
  960.         $game_party.notification_enabled = false
  961.       end
  962.     end
  963.   end
  964.  
  965. end
  966.  
  967. #===========================================================================
  968. # *** Scene Menu
  969. #===========================================================================
  970. class Scene_Menu < Scene_MenuBase
  971.  
  972.   #--------------------------------------------------------------------------
  973.   # * Aliases
  974.   #--------------------------------------------------------------------------
  975.   alias :clstn_create_command_window :create_command_window
  976.  
  977.   #--------------------------------------------------------------------------
  978.   # * Create Command Window
  979.   #--------------------------------------------------------------------------
  980.   def create_command_window
  981.     clstn_create_command_window
  982.     @command_window.set_handler(:achievements, method(:command_achievements))
  983.   end
  984.  
  985.   #--------------------------------------------------------------------------
  986.   # * Command Achievements
  987.   #--------------------------------------------------------------------------
  988.   def command_achievements
  989.     SceneManager.call(Scene_Achievements)
  990.   end
  991.  
  992. end
  993.  
  994. #===========================================================================
  995. # *** Scene Achievements
  996. #===========================================================================
  997. class Scene_Achievements < Scene_Base
  998.  
  999.   #--------------------------------------------------------------------------
  1000.   # * Start Processing
  1001.   #--------------------------------------------------------------------------
  1002.   def start
  1003.     create_main_viewport
  1004.     create_achievement_windows
  1005.   end
  1006.  
  1007.   #--------------------------------------------------------------------------
  1008.   # * Create Achievement Window
  1009.   #--------------------------------------------------------------------------
  1010.   def create_achievement_windows
  1011.     create_achievement_header_window
  1012.     create_achievement_window
  1013.   end
  1014.  
  1015.   #--------------------------------------------------------------------------
  1016.   # * Create Achievement Header Window
  1017.   #--------------------------------------------------------------------------
  1018.   def create_achievement_header_window
  1019.      @achievementheader_window = Window_AchievementHeader.new
  1020.   end
  1021.  
  1022.   #--------------------------------------------------------------------------
  1023.   # * Create Achievement Window
  1024.   #--------------------------------------------------------------------------
  1025.   def create_achievement_window
  1026.     @achievement_window = Window_Achievements.new(0, 50, Graphics.width - 250, Graphics.height - 50)
  1027.     @achievement_window.set_handler(:ok,     method(:expand_ok   ))
  1028.     @achievement_window.set_handler(:cancel, method(:return_scene))
  1029.     @achievement_window.activate
  1030.   end
  1031.  
  1032.   #--------------------------------------------------------------------------
  1033.   # * Expand [OK]
  1034.   #--------------------------------------------------------------------------
  1035.   def expand_ok
  1036.     @achievement_window.expand
  1037.     @achievement_window.activate
  1038.   end
  1039.  
  1040. end
  1041.  
  1042. #===========================================================================
  1043. # *** Class Scene_Map
  1044. #===========================================================================
  1045. class Scene_Map < Scene_Base
  1046.  
  1047.   #--------------------------------------------------------------------------
  1048.   # * Aliases
  1049.   #--------------------------------------------------------------------------
  1050.   alias :clstn_create_all_windows_scene_map :create_all_windows
  1051.  
  1052.   #--------------------------------------------------------------------------
  1053.   # * Create All Windows
  1054.   #--------------------------------------------------------------------------
  1055.   def create_all_windows
  1056.     clstn_create_all_windows_scene_map
  1057.     create_notification_window unless Clstn_Achievement_System::Notification_Window == false || $game_party.notification_enabled == false
  1058.   end
  1059.  
  1060.   #--------------------------------------------------------------------------
  1061.   # * Create Notification Window
  1062.   #--------------------------------------------------------------------------
  1063.   def create_notification_window
  1064.     @notification_window = Window_AchievementNotification.new
  1065.     @notification_window.viewport = @viewport
  1066.   end
  1067.  
  1068. end
  1069.  
  1070. #===========================================================================
  1071. # *** Class Game_Party
  1072. #===========================================================================
  1073. class Game_Party < Game_Unit
  1074.  
  1075.   attr_accessor :achievements
  1076.   attr_accessor :achievement_points
  1077.   attr_accessor :achievement_repeated
  1078.   attr_accessor :achievement_status
  1079.   attr_accessor :notification_enabled
  1080.   attr_accessor :notifications
  1081.   #--------------------------------------------------------------------------
  1082.   # * Aliased
  1083.   #--------------------------------------------------------------------------
  1084.   alias :clstn_achievements_gameparty_initialize :initialize
  1085.  
  1086.   #--------------------------------------------------------------------------
  1087.   # * Initialize
  1088.   #--------------------------------------------------------------------------
  1089.   def initialize
  1090.     clstn_achievements_gameparty_initialize
  1091.     @notification_enabled = false
  1092.     @achievement_points = 0
  1093.     @notifications = []
  1094.     @achievements = []
  1095.     @achievement_repeated = []
  1096.     @achievement_status = []
  1097.     init_achievements
  1098.     init_achievement_repeated
  1099.     init_achievement_status
  1100.   end
  1101.  
  1102.   #--------------------------------------------------------------------------
  1103.   # * Initialize Achievements
  1104.   #--------------------------------------------------------------------------
  1105.   def init_achievements
  1106.     Clstn_Achievement_System::Achievements.each_value { |value|
  1107.       @achievements.push(0)
  1108.     }
  1109.   end
  1110.  
  1111.   #--------------------------------------------------------------------------
  1112.   # * Initialize Achievement Repeated
  1113.   #--------------------------------------------------------------------------
  1114.   def init_achievement_repeated
  1115.     Clstn_Achievement_System::Achievements.each_value { |value|
  1116.       @achievement_repeated.push(-1)
  1117.     }
  1118.   end
  1119.  
  1120.   #--------------------------------------------------------------------------
  1121.   # * Initialize Achievement Status
  1122.   #--------------------------------------------------------------------------
  1123.   def init_achievement_status
  1124.     @achievement_status = Clstn_Achievement_System::get_achievement_status
  1125.   end
  1126.  
  1127.   #--------------------------------------------------------------------------
  1128.   # * Achievement Completed
  1129.   #--------------------------------------------------------------------------
  1130.   def achievement_completed(index)
  1131.     array = Clstn_Achievement_System::Achievements[index]
  1132.     if @achievements[index] >= array[:Tiers][-1]
  1133.       check_status_completed(index)
  1134.       @achievements[index] = array[:Tiers][array[:Tiers].size - 1]
  1135.       next_reward = Clstn_Achievement_System::get_point_rewards
  1136.       gain_gold(array[:RewardGold])                                     unless array[:RewardGold]        == :none
  1137.       gain_item(get_item(array[:RewardItem]), array[:RewardItem][2])    unless array[:RewardItem]        == :none
  1138.       @achievement_points += array[:AchievementPoints]                  unless array[:AchievementPoints] == :none
  1139.       notification(array, :completed)
  1140.       next_achievement(next_reward)
  1141.     end
  1142.     unlocked = check_unlock(index)
  1143.     notification(unlocked, :unlocked) unless unlocked.empty?
  1144.   end
  1145.  
  1146.   #--------------------------------------------------------------------------
  1147.   # * Next Achievement
  1148.   #--------------------------------------------------------------------------
  1149.   def next_achievement(next_reward)
  1150.     if @achievement_points >= next_reward
  1151.       array = Clstn_Achievement_System::Achievement_Point_Rewards
  1152.       index = find_achievement_reward_index(next_reward)
  1153.       array[index][1].each { |key|
  1154.         item = key
  1155.         gain_item(get_item(item), key[2])
  1156.       }    
  1157.       notification(array[index], :points)
  1158.     end
  1159.   end
  1160.  
  1161.   #--------------------------------------------------------------------------
  1162.   # * Find Achievement Reward Index
  1163.   #--------------------------------------------------------------------------
  1164.   def find_achievement_reward_index(next_reward)
  1165.     array = Clstn_Achievement_System::Achievement_Point_Rewards
  1166.     array.size.times { |index|
  1167.       return index if array[index][0] == next_reward
  1168.     }
  1169.   end
  1170.  
  1171.   #--------------------------------------------------------------------------
  1172.   # * Check Status Completed
  1173.   #--------------------------------------------------------------------------
  1174.   def check_status_completed(index)
  1175.     array = Clstn_Achievement_System::Achievements[index]
  1176.     if array[:Repeatable] == false
  1177.       @achievement_status[index] = :Completed if array[:Tiers][-1] == @achievements[index]
  1178.     else
  1179.       @achievement_status[index] = :Completed if array[:Tiers][-1] == @achievements[index] && @achievement_repeated[index] == array[:Repeatable]
  1180.     end
  1181.   end
  1182.  
  1183.   #--------------------------------------------------------------------------
  1184.   # * Check Unlocked
  1185.   #--------------------------------------------------------------------------
  1186.   def check_unlock(index)
  1187.     unlocked = []
  1188.     item = Clstn_Achievement_System::Achievements
  1189.     Clstn_Achievement_System::Achievements.size.times { |i|
  1190.       unlocked.push(item[i][:Name]) if completed?(item[i], index, i)
  1191.     }
  1192.     return unlocked
  1193.   end
  1194.  
  1195.   #--------------------------------------------------------------------------
  1196.   # * Completed?
  1197.   #--------------------------------------------------------------------------
  1198.   def completed?(item, index, i)
  1199.     return false if item[:Prerequisite] == :none
  1200.     if item[:Prerequisite][0] == index
  1201.       limit = item[:Prerequisite][1]
  1202.       tier  = item[:Prerequisite][2]
  1203.       if @achievements[index] >= tier && @achievement_repeated[index] >= limit && @achievement_status[i] == :Locked
  1204.         @achievement_status[i] = :Unlocked
  1205.         return true
  1206.       else
  1207.         return false
  1208.       end
  1209.     end
  1210.   end
  1211.  
  1212.   #--------------------------------------------------------------------------
  1213.   # * Get Item
  1214.   #--------------------------------------------------------------------------
  1215.   def get_item(item)
  1216.     case item[0]
  1217.     when 0; item = $data_items[item[1]]
  1218.     when 1; item = $data_weapons[item[1]]
  1219.     when 2; item = $data_armors[item[1]]
  1220.     end
  1221.     return item
  1222.   end
  1223.  
  1224.   #--------------------------------------------------------------------------
  1225.   # * Notifications [Trigger]
  1226.   #--------------------------------------------------------------------------
  1227.   def notification(item, symbol)
  1228.     @notification_enabled = true
  1229.     temp = [item, symbol]
  1230.     @notifications.push(temp)
  1231.     SceneManager.call(Scene_Map) unless @notifications.size > 1
  1232.   end
  1233.  
  1234. end
  1235.  
  1236. #===========================================================================
  1237. # *** Class Game_Interpreter
  1238. #===========================================================================
  1239. class Game_Interpreter
  1240.  
  1241.   #--------------------------------------------------------------------------
  1242.   # * Increase Achievements
  1243.   #--------------------------------------------------------------------------
  1244.   def gain_achievement(amount, index)
  1245.     item = Clstn_Achievement_System::Achievements[index]
  1246.     tier = Clstn_Achievement_System::tier?(Clstn_Achievement_System::Achievements[index])
  1247.     if $game_party.achievements[index] != item[:Tiers][-1]
  1248.       if !Clstn_Achievement_System::locked?(item)
  1249.         if amount <= item[:Tiers][tier]
  1250.           $game_party.achievements[index] += amount
  1251.           set_achievement(item[:Tiers][tier], index) if $game_party.achievements[index] > Clstn_Achievement_System::Achievements[index][:Tiers][tier]
  1252.         else
  1253.           set_achievement(item[:Tiers][tier], index)
  1254.         end
  1255.       end
  1256.       $game_party.achievement_completed(index)
  1257.       if $game_party.achievements[index] == item[:Tiers][-1] && item[:Repeatable] != false && item[:Repeatable] > $game_party.achievement_repeated[index]
  1258.         $game_party.achievements[index] = 0
  1259.         $game_party.achievement_repeated[index] += 1
  1260.       end
  1261.     end
  1262.   end
  1263.  
  1264.   #--------------------------------------------------------------------------
  1265.   # * Decrease Achievements
  1266.   #--------------------------------------------------------------------------
  1267.   def lose_achievement(amount, index)
  1268.     item = Clstn_Achievement_System::Achievements[index]
  1269.     if $game_party.achievements[index] != item[:Tiers][-1]
  1270.       $game_party.achievements[index] -= amount unless Clstn_Achievement_System::locked?(Clstn_Achievement_System::Achievements[index])
  1271.     end
  1272.   end
  1273.  
  1274.   #--------------------------------------------------------------------------
  1275.   # * Set Achievements
  1276.   #--------------------------------------------------------------------------
  1277.   def set_achievement(amount, index)
  1278.     item = Clstn_Achievement_System::Achievements[index]
  1279.     if $game_party.achievements[index] != item[:Tiers][-1]
  1280.       $game_party.achievements[index] = amount unless Clstn_Achievement_System::locked?(Clstn_Achievement_System::Achievements[index])
  1281.       $game_party.achievement_completed(index)
  1282.       if $game_party.achievements[index] == item[:Tiers][-1] && item[:Repeatable] != false && item[:Repeatable] > $game_party.achievement_repeated[index]
  1283.         $game_party.achievements[index] = 0
  1284.         $game_party.achievement_repeated[index] += 1
  1285.       end
  1286.     end
  1287.   end
  1288.  
  1289.   #--------------------------------------------------------------------------
  1290.   # * Gain Achievement Points
  1291.   #--------------------------------------------------------------------------
  1292.   def gain_achievement_points(amount)
  1293.     $game_party.achievement_points += amount
  1294.   end
  1295.  
  1296.   #--------------------------------------------------------------------------
  1297.   # * Lose Achievement Points
  1298.   #--------------------------------------------------------------------------
  1299.   def lose_achievement_points(amount)
  1300.     $game_party.achievement_points -= amount
  1301.   end
  1302.  
  1303.   #--------------------------------------------------------------------------
  1304.   # * Set Achievement Points
  1305.   #--------------------------------------------------------------------------
  1306.   def set_achievement_points(amount)
  1307.     $game_party.achievement_points = amount
  1308.   end
  1309.  
  1310.   #--------------------------------------------------------------------------
  1311.   # * Get Achievement Name
  1312.   #--------------------------------------------------------------------------
  1313.   def achievement_name(index)
  1314.     return Clstn_Achievement_System::Achievements[index][:Name]
  1315.   end
  1316.  
  1317.   #--------------------------------------------------------------------------
  1318.   # * Get Achievement Item Reward
  1319.   #--------------------------------------------------------------------------
  1320.   def achievement_item(index)
  1321.     return $game_party.get_item(Clstn_Achievement_System::Achievements[index][:RewardItem]).name
  1322.   end
  1323.  
  1324.   #--------------------------------------------------------------------------
  1325.   # * Get Achievement Gold Reward
  1326.   #--------------------------------------------------------------------------
  1327.   def achievement_gold(index)
  1328.     return Clstn_Achievement_System::Achievements[index][:RewardGold]
  1329.   end
  1330.  
  1331.   #--------------------------------------------------------------------------
  1332.   # * Get Achievement Points Reward
  1333.   #--------------------------------------------------------------------------
  1334.   def achievement_points(index)
  1335.     return Clstn_Achievement_System::Achievements[index][:AchievementPoints]
  1336.   end
  1337.  
  1338.   #--------------------------------------------------------------------------
  1339.   # * Disable Achievements
  1340.   #--------------------------------------------------------------------------
  1341.   def achievement_title(index)
  1342.     return Clstn_Achievement_System::Achievements[index][:Title]
  1343.   end
  1344.  
  1345.   #--------------------------------------------------------------------------
  1346.   # * Get Achievement Times Repeated
  1347.   #--------------------------------------------------------------------------
  1348.   def achievement_repeated(index)
  1349.     return $game_party.achievement_repeated[index]
  1350.   end
  1351.  
  1352.   #--------------------------------------------------------------------------
  1353.   # * Get Achievement Progress
  1354.   #--------------------------------------------------------------------------
  1355.   def achievement_progress(index)
  1356.     return $game_party.achievements[index]
  1357.   end
  1358.  
  1359.   #--------------------------------------------------------------------------
  1360.   # * Get Achievement Status
  1361.   #--------------------------------------------------------------------------
  1362.   def achievement_status(index)
  1363.     return false if Clstn_Achievement_System::Achievement[index][:Repeatable] == false
  1364.     return $game_party.achievement_status[index]
  1365.   end
  1366.  
  1367.   #--------------------------------------------------------------------------
  1368.   # * Get Party Achievement Points
  1369.   #--------------------------------------------------------------------------
  1370.   def party_achievement_points
  1371.     return $game_party.achievement_points
  1372.   end
  1373.  
  1374. end