Guest User

eddited

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