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