[XP] Achievements Script

Started by G_G, April 20, 2009, 01:18:40 am

Previous topic - Next topic

G_G

April 20, 2009, 01:18:40 am Last Edit: January 14, 2013, 07:38:42 am by gameus
Achievements Script
Authors: game_guy
Version: 2.23
Type: A Goals Type Script
Key Term: Misc System



Introduction

A full blown achievement system. Keep track of events your players pull off and make them feel like they've really achieved something. Easy to setup, plenty of options to configure it the way you want.


Features

I'm gonna leave the old list here so you can see the comparison.
Quote from: Old Features

  • Use Achievements in your game!
  • Simple Plug and Play (besides setting up achievements)
  • Achievements Easy to Setup!
  • GamerScore is displayed.
  • You can change what the Score is named
  • Score is stored in a variable and you choose the number.
  • Theres an option to turn on the Print so it prints what achievement you unlocked.

New ones

  • Image/Text Achievement Notification

  • Show all achievements or only ones you unlocked

  • Change text font, size, and color

  • Option to keep track of score

  • Modify notification position

  • Modify text position if using an image

  • Modify popup time

  • Play sound when you unlock an achievement

  • Set return scene, scene you go to when exiting achievements menu

  • Custom queue system allowing you to display multiple achievements at a time

  • Much more compatible

  • Quickly open up achievements without interrupting the current scene

  • Block scenes from the Quick Open

  • See if user has a specific achievement

  • See how many achievements the player has

  • Custom Icon Size Support




Screenshots

Noticed all of my screenshots are down. Here's a video instead.
http://www.youtube.com/watch?v=96KIdAHoBhg


Demo

Demo v2.0 (Outdated and Possibly Bugged) (Broken Link, Lost Demo)
Unofficial Demo Provided by ThallionDarkshine


Script

Spoiler: ShowHide
#===============================================================================
# Achievements
# Version 2.23
# Author game_guy
#-------------------------------------------------------------------------------
# Intro:
# A full blown achievement system. Keep track of events your players pull off
# and make them feel like they've really achieved something. Easy to setup,
# plenty of options to configure it the way you want.
#
# Features:
# -Image/Text Achievement Notification
# -Show all achievements or only ones you unlocked
# -Change text font, size, and color
# -Option to keep track of score
# -Modify notification position
# -Modify text position if using an image
# -Modify popup time
# -Play sound when you unlock an achievement
# -Set return scene, scene you go to when exiting achievements menu
# -Custom queue system allowing you to display multiple achievements at a time
# -Much more compatible
# -Quickly open up achievements without interupting the current scene
# -Block scenes from the Quick Open
# -See if user has a specific achievement
# -See how many achievements the player has
# -Custom Icon Size Support
#
# Instructions:
# -Go down to Begin Config and edit all of your options there.
# -Instructions for creating achievements are also in the Config.
# -To gain an achievement, use Awards.gain(award_id)
# -Award id is set when creating awards.
# -To see if a user has an award use Awards.has?(award_id)
# -To see how many the player has use Awards.count
# -To open up the real achievements scene use
#  $scene = Scene_Achievements.new
#
# Compatibility:
# -Not tested with SDK.
# -Should work with everything.
# -May corrupt old save games.
#
# Credits:
# -game_guy ~ For creating it.
# -jragyn00 ~ For the new layout.
# -GAX72 ~ For test achievement image.
#===============================================================================

module Awards
#===============================================================
# Begin Config
#===============================================================
 #----------------------------------------------------------------------------
 # If true, it'll show all unlocked and locked achievements, else it'll just
 # show unlocked achievements
 #----------------------------------------------------------------------------
 Show_All      = true
 #----------------------------------------------------------------------------
 # If Show_All is on, all locked icons will be displayed with the below
 # icon
 #----------------------------------------------------------------------------
 Locked_Icon   = "locked"
 #----------------------------------------------------------------------------
 # This replaces the achievments description if Show_All is on and the
 # achievement is marked as hidden.
 #----------------------------------------------------------------------------
 Hidden_Info   = "This achievement is hidden. Unlock it to find out more."
 #----------------------------------------------------------------------------
 # The scene you go to when you exit the achievements menu
 #----------------------------------------------------------------------------
 Return_Scene  = Scene_Menu
 #----------------------------------------------------------------------------
 # If set to an Input key, it will open up a quick view window to view all
 # achievements, can be opened up from anywhere, and doesn't interupt the
 # current scene. Set to nil to turn it off.
 #----------------------------------------------------------------------------
 Quick_Access  = Input::A
 #----------------------------------------------------------------------------
 # Add scenes here that you want quick access blocked on. Example,
 # Scene_Title, wouldn't want users to view achievements there. Kinda odd.
 #----------------------------------------------------------------------------
 Block_Scenes  = [Scene_Title, Scene_Gameover, Scene_File, Scene_Register,
                  Scene_Login, Scene_Servers]
 #----------------------------------------------------------------------------
 # Keep track of score?
 #----------------------------------------------------------------------------
 Track_Score   = true
 #----------------------------------------------------------------------------
 # Text for "Score"
 #----------------------------------------------------------------------------
 Score_Text    = "Points"
 #----------------------------------------------------------------------------
 # Variable to store the score in. (hehe)
 #----------------------------------------------------------------------------
 Variable_Id   = 5
 #----------------------------------------------------------------------------
 # Font name
 # Place your font in string tags "font_here"
 # Or leave it as is to leave the default font.
 #----------------------------------------------------------------------------
 Text_Font     = Font.default_name
 #----------------------------------------------------------------------------
 # Font color : Color.new(red, green, blue)
 #----------------------------------------------------------------------------
 Text_Color    = Color.new(255, 255, 255)
 #----------------------------------------------------------------------------
 # Font size
 #----------------------------------------------------------------------------
 Text_Size     = 24
 #----------------------------------------------------------------------------
 # Where will the award show up on the screen. [X, Y]
 #----------------------------------------------------------------------------
 Award_Place   = [16, 16]
 #----------------------------------------------------------------------------
 # Use background image behind text?
 #----------------------------------------------------------------------------
 Use_Image     = true
 #----------------------------------------------------------------------------
 # File used to display behind the text.
 #----------------------------------------------------------------------------
 Image_File    = "award_background"
 #----------------------------------------------------------------------------
 # Offset for text drawn over the image. [X, Y]
 #----------------------------------------------------------------------------
 Image_Offset  = [72, 0]
 #----------------------------------------------------------------------------
 # Draw icon on notification image?
 #----------------------------------------------------------------------------
 Draw_Icon     = true
 #----------------------------------------------------------------------------
 # Offset for icon drawn over the image. [X, Y]
 #----------------------------------------------------------------------------
 Icon_Offset   = [20, 20]
 #----------------------------------------------------------------------------
 # Custom icon size. If you change these values, you'll have to change
 # Icon_Row and Icon_QuickRow. [WIDTH, HEIGHT]
 #----------------------------------------------------------------------------
 Icon_Size     = [24, 24]
 #----------------------------------------------------------------------------
 # How many icons are displayed in one column (across).
 #----------------------------------------------------------------------------
 Icon_Column   = 10
 #----------------------------------------------------------------------------
 # How many icons are in one column (across) in the Quick View scene.
 #----------------------------------------------------------------------------
 Icon_QColumn  = 8
 #----------------------------------------------------------------------------
 # Time the "Unlocked Achievement" pop up stays on screen in frames.
 #----------------------------------------------------------------------------
 Popup_Time    = 60
 #----------------------------------------------------------------------------
 # Sound played when an achievement pops up. ["sound", volume, pitch]
 #----------------------------------------------------------------------------
 Popup_Sound   = ["114-Remedy02", 100, 0]
 Award = []
 #----------------------------------------------------------------------------
 # To add a new award, add a new line:
 # Award[id] = ["name", "description", "icon", score_amount, hidden]
 # score_amount must be set even if Track_Score is off
 # hidden must be set even if Show_All is off
 # If you use Show_All and you want the description of achievements to be
 # hidden, set hidden to true. If its false, it'll tell the name and
 # description.
 #----------------------------------------------------------------------------
 Award[0] = ["New Game", "Start a new game!", "037-Item06", 10, false]
 Award[1] = ["Award 1", "Talk to guy 1.", "046-Skill03", 10, true]
 Award[2] = ["Award 2", "Talk to guy 1.", "046-Skill03", 10, false]
 Award[3] = ["500 Damage", "Deal 500 damage in one attack.", "004-Weapon04", 5, false]
 Award[4] = ["Am I rich?", "Have 1,000,000 gold at one time.", "035-Item04", 10, false]
 Award[5] = ["Window Shopper", "Spend 1,000,000 gold.", "032-Item01", 10, false]
 Award[6] = ["Longer Description", "OMGAR this has a longer description but carries on to the next line. I'm so sexy.", "033-Item02", 0, false]
 Award[7] = ["Log Jumper", "Jump over the log.", "048-Skill05", 5, false]
 Award[8] = ["Super Log Jumper", "Jump over the log 5 times", "048-Skill05", 25, false]
 Award[9] = ["I am hidden!", "Learn about hidden achievements.", "034-Item03", 10, true]
 Award[10] = ["GRRR!!!", "Brave enough to talk to a lion!", "019-Accessory04", 5, false]
 Award[11] = ["Invisible", "Found and talked to invisible person.", "049-Skill06", 50, false]
 Award[12] = ["Swiftly!", "Learn about the Quick Scene!", "020-Accessory05", 100, false]
#===============================================================
# End Config
#===============================================================
 def self.gain(id)
   return if $game_system.awards.include?(id)
   if Awards::Award[id] != nil
     $game_system.gain_award(id)
   end
 end
 def self.has?(id)
   return $game_system.awards.include?(id)
 end
 def self.count
   return $game_system.awards.size
 end
end

$gg_achievements = 2.23
#===============================================================================
# Sprite_Award
#-------------------------------------------------------------------------------
# Draws unlocked achievement.
#===============================================================================
class Sprite_Award < Sprite
 def initialize(award)
   super(nil)
   @award = award
   self.bitmap = Bitmap.new(1, 1)
   self.bitmap.font.size = Awards::Text_Size
   @text_width = self.bitmap.text_size(@award[0]).width + 8
   @text_height = self.bitmap.text_size(@award[0]).height
   self.bitmap.dispose
   if Awards::Use_Image
     @pic = RPG::Cache.picture(Awards::Image_File)
     @pic_width = @pic.width > @text_width ? @pic.width : @text_width
     @pic_height = @pic.height > @text_height ? @pic.height : @text_height
     self.bitmap = Bitmap.new(@pic_width, @pic_height)
     if Awards::Draw_Icon
       @icon = RPG::Cache.icon(@award[2])
     end
   else
     self.bitmap = Bitmap.new(@text_width, @text_height)
   end
   self.bitmap.font.color = Awards::Text_Color
   self.bitmap.font.name = Awards::Text_Font
   self.bitmap.font.size = Awards::Text_Size
   self.z = 20000
   self.x = Awards::Award_Place[0]
   self.y = Awards::Award_Place[1]
   refresh
 end
 def refresh
   self.bitmap.clear
   x = 0
   y = 0
   if @pic != nil
     self.bitmap.blt(0, 0, @pic, Rect.new(0, 0, @pic.width, @pic.height))
     x = Awards::Image_Offset[0]
     y = Awards::Image_Offset[1]
     if @icon != nil
       icon_off = Awards::Icon_Offset
       self.bitmap.blt(icon_off[0], icon_off[1], @icon, Rect.new(0, 0,
           Awards::Icon_Size[0], Awards::Icon_Size[1]))
     end
   end
   text = @award[0]
   if @text_width + x > self.bitmap.width
     text = self.bitmap.slice_text(@award[0], self.bitmap.width - x)
     text.each_index {|i|
       self.bitmap.draw_text(x, y + i * @text_height + 4,
           @text_width, @text_height, text[i])}
   else
     self.bitmap.draw_text(x, y, @text_width, @text_height, text)
   end
 end
 def dispose
   super
   if self.bitmap != nil
     self.bitmap.dispose
   end
 end
end
#===============================================================================
# Graphics
#-------------------------------------------------------------------------------
# **added method to control and draw all queued achievements.
#===============================================================================
module Graphics
 class << self
   alias gg_upd_awards_queue_lat update
 end
 def self.update
   @frame = 0 if @frame == nil
   if $game_system != nil && $game_system.queue.size > 0 && @frame < 1
     award = Awards::Award[$game_system.queue[0]]
     if award != nil
       @sprite = Sprite_Award.new(award)
       @frame = Awards::Popup_Time
       Audio.se_play("Audio/SE/#{Awards::Popup_Sound[0]}",
         Awards::Popup_Sound[1], Awards::Popup_Sound[2])
     end
   end
   if @frame > 0
     @frame -= 1
     if @frame < 1
       @sprite.dispose
       $game_system.queue.shift
     end
   end
   gg_upd_awards_queue_lat
 end
end
#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# **modded to keep track of queued and obtained achievements.
#===============================================================================
class Game_System
 attr_accessor :awards
 attr_accessor :queue
 alias gg_init_awards_sys_lat initialize
 def initialize
   @awards = []
   @queue = []
   gg_init_awards_sys_lat
 end
 def gain_award(id)
   return if @awards.include?(id) || Awards::Award[id] == nil
   if Awards::Track_Score
     $game_variables[Awards::Variable_Id] += Awards::Award[id][3]
   end
   @awards.push(id)
   @queue.push(id)
 end
end
#===============================================================================
# Bitmap
#===============================================================================
class Bitmap
 
 def slice_text(text, width)
   words = text.split(' ')
   return words if words.size == 1
   result, current_text = [], words.shift
   words.each_index {|i|
       if self.text_size("#{current_text} #{words[i]}").width > width
         result.push(current_text)
         current_text = words[i]
       else
         current_text = "#{current_text} #{words[i]}"
       end
       result.push(current_text) if i >= words.size - 1}
   return result
 end
 
end

#===============================================================================
# Window_QuickHelp
#===============================================================================
class Window_QuickHelp < Window_Base
 def initialize
   super(64, 32, 512, 160)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.z = 10000
 end
 def set_award(award)
   @award = award
   refresh
 end
 def refresh
   self.contents.clear
   self.contents.draw_text(0, 0, 512 / 2, 32, @award[0][0])
   if Awards::Track_Score
     text = "#{@award[0][3]} #{Awards::Score_Text}"
     self.contents.draw_text(0, 0, 512 - 32, 32, text, 2)
     text = "Total #{Awards::Score_Text}: #{$game_variables[Awards::Variable_Id]}"
     self.contents.draw_text(0, 32, 512 - 32, 32, text, 2)
   end
   text = self.contents.slice_text(@award[0][1], 512 - 32)
   if @award[0][4] && !$game_system.awards.include?(@award[1])
     text = self.contents.slice_text(Awards::Hidden_Info, 512 - 32)
   end
   text.each_index {|i|
     self.contents.draw_text(0, 64 + i * 32, 512 - 32, 32, text[i])}
 end
end
#===============================================================================
# Window_QuickAwards
#===============================================================================
class Window_QuickAwards < Window_Selectable
 def initialize
   super(64, 128 + 64, 512, 320 - 64)
   @column_max = Awards::Icon_QColumn
   self.z = 10000
   refresh
   self.index = 0
 end
 def item
   return @data[self.index]
 end
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   $game_system.awards.each {|i|
     @data.push([Awards::Award[i], i])}
   if Awards::Show_All
     @data = []
     @locked = []
     @unlocked = []
     Awards::Award.each_index {|i|
       if Awards::Award[i] != nil
         if $game_system.awards.include?(i)
           @unlocked.push([Awards::Award[i], i])
         else
           @locked.push([Awards::Award[i], i])
         end
       end}
     @unlocked.each {|i| @data.push(i)}
     @locked.each {|i| @data.push(i)}
   end
   @item_max = @data.size
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, row_max * Awards::Icon_Size[1])
     for i in 0...@item_max
       draw_item(i)
     end
   end
 end
 def draw_item(index)
   item = @data[index]
   width = Awards::Icon_Size[0] < 32 ? 32 : Awards::Icon_Size[0]
   height = Awards::Icon_Size[1] < 32 ? 32 : Awards::Icon_Size[1]
   x = 4 + index % @column_max * (width + 32)
   y = index / @column_max * (height + 4)
   rect = Rect.new(x, y, self.width / @column_max - 32, height)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   if $game_system.awards.include?(item[1])
     bitmap = RPG::Cache.icon(item[0][2])
   else
     bitmap = RPG::Cache.icon(Awards::Locked_Icon)
   end
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, Awards::Icon_Size[0],
       Awards::Icon_Size[1]))
 end
 def update_help
   @help_window.set_award(self.item)
 end
 def update_cursor_rect
   if @index < 0
     self.cursor_rect.empty
     return
   end
   row = @index / @column_max
   if row < self.top_row
     self.top_row = row
   end
   if row > self.top_row + (self.page_row_max - 1)
     self.top_row = row - (self.page_row_max - 1)
   end
   cursor_width = Awards::Icon_Size[0] < 32 ? 32 : Awards::Icon_Size[0]
   cursor_height = Awards::Icon_Size[1] < 32 ? 32 : Awards::Icon_Size[1]
   x = @index % @column_max * (cursor_width + 32)
   y = @index / @column_max * (Awards::Icon_Size[1] + 4) - self.oy
   self.cursor_rect.set(x, y, cursor_width, cursor_height + 4)
 end
end
#===============================================================================
# QScene_Awards
#===============================================================================
class QScene_Awards
 def initialize
   @awards = Window_QuickAwards.new
   @help = Window_QuickHelp.new
   @awards.help_window = @help
   loop do
     Graphics.update
     Input.update_old
     update
     if Input.trigger?(Input::B)
       $game_system.se_play($data_system.cancel_se)
       break
     end
   end
   @awards.dispose
   @help.dispose
 end
 def update
   @awards.update
   @help.update
 end
end
#===============================================================================
# Input
#===============================================================================
module Input
 class << self
   alias gg_init_quick_awards_lat update
 end
 def self.update_old
   gg_init_quick_awards_lat
 end
 def self.check_blocked
   Awards::Block_Scenes.each {|s|
     return true if $scene.is_a?(s)}
   return false
 end
 def self.update
   if Awards::Quick_Access != nil && Input.trigger?(Awards::Quick_Access) &&
         @scene == nil && !self.check_blocked
     if defined?(RMXOS) && $game_temp.chat_active == true
         return gg_init_quick_awards_lat
     end
     $game_system.se_play($data_system.decision_se)
     @scene = QScene_Awards.new
     @scene = nil
   end
   gg_init_quick_awards_lat
 end
end

#===============================================================================
# Window_Award
#===============================================================================
class Window_Award < Window_Base
 def initialize
   super(0, 320, 640, 160)
   self.contents = Bitmap.new(width - 32, height - 32)
 end
 def set_award(award)
   @award = award
   refresh
 end
 def refresh
   self.contents.clear
   self.contents.draw_text(0, 0, 640 / 2, 32, @award[0][0])
   if Awards::Track_Score
     text = "#{@award[0][3]} #{Awards::Score_Text}"
     self.contents.draw_text(0, 0, 640 - 32, 32, text, 2)
     text = "Total #{Awards::Score_Text}: #{$game_variables[Awards::Variable_Id]}"
     self.contents.draw_text(0, 32, 640 - 32, 32, text, 2)
   end
   text = self.contents.slice_text(@award[0][1], 640 - 32)
   if @award[0][4] && !$game_system.awards.include?(@award[1])
     text = self.contents.slice_text(Awards::Hidden_Info, 640 - 32)
   end
   text.each_index {|i|
     self.contents.draw_text(0, 64 + i * 32, 640 - 32, 32, text[i])}
 end
end
#===============================================================================
# Window_Awards
#===============================================================================
class Window_Awards < Window_Selectable
 def initialize
   super(0, 0, 640, 320)
   @column_max = Awards::Icon_Column
   refresh
   self.index = 0
 end
 def item
   return @data[self.index]
 end
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   $game_system.awards.each {|i|
     @data.push([Awards::Award[i], i])}
   if Awards::Show_All
     @data = []
     @locked = []
     @unlocked = []
     Awards::Award.each_index {|i|
       if Awards::Award[i] != nil
         if $game_system.awards.include?(i)
           @unlocked.push([Awards::Award[i], i])
         else
           @locked.push([Awards::Award[i], i])
         end
       end}
     @unlocked.each {|i| @data.push(i)}
     @locked.each {|i| @data.push(i)}
   end
   @item_max = @data.size
   if @item_max > 0
     height = Awards::Icon_Size[1] < 32 ? 32 : Awards::Icon_Size[1]
     self.contents = Bitmap.new(width - 32, row_max * height)
     for i in 0...@item_max
       draw_item(i)
     end
   end
 end
 def draw_item(index)
   item = @data[index]
   width = Awards::Icon_Size[0] < 32 ? 32 : Awards::Icon_Size[0]
   height = Awards::Icon_Size[1] < 32 ? 32 : Awards::Icon_Size[1]
   x = 4 + index % @column_max * (width + 32)
   y = index / @column_max * (height + 4)
   rect = Rect.new(x, y, self.width / @column_max - 32, Awards::Icon_Size[1])
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   if $game_system.awards.include?(item[1])
     bitmap = RPG::Cache.icon(item[0][2])
   else
     bitmap = RPG::Cache.icon(Awards::Locked_Icon)
   end
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, Awards::Icon_Size[0],
     Awards::Icon_Size[1]))
 end
 def update_help
   @help_window.set_award(self.item)
 end
 def update_cursor_rect
   if @index < 0
     self.cursor_rect.empty
     return
   end
   row = @index / @column_max
   if row < self.top_row
     self.top_row = row
   end
   if row > self.top_row + (self.page_row_max - 1)
     self.top_row = row - (self.page_row_max - 1)
   end
   cursor_width = Awards::Icon_Size[0] < 32 ? 32 : Awards::Icon_Size[0]
   cursor_height = Awards::Icon_Size[1] < 32 ? 32 : Awards::Icon_Size[1]
   x = @index % @column_max * (cursor_width + 32)
   y = @index / @column_max * (cursor_height + 4) - self.oy
   self.cursor_rect.set(x, y, cursor_width, cursor_height)
 end
end
#===============================================================================
# Scene_Achievements
#===============================================================================
class Scene_Achievements
 def main
   @help = Window_Award.new
   @awards = Window_Awards.new
   @awards.help_window = @help
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   @help.dispose
   @awards.dispose
 end
 def update
   @awards.update
   @help.update
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Awards::Return_Scene.new
     return
   end
 end
end


Here's an RMX-OS Compatibility Patch. You need this if you are using RMX-OS.
Spoiler: ShowHide
#===============================================================================
# Achievements RMX-OS Patch
# Version 1.0
# Author: game_guy
#-------------------------------------------------------------------------------
# Intro:
# This makes game_guy's Achievements script compatible with RMX-OS.
# -Requires game_guy's Achievements v2.0 or Above
# -Requires Blizzard's RMX-OS v1.18 or Above
#===============================================================================

if !defined?(RMXOS) || RMXOS::VERSION < 1.18 || $gg_achievements == nil || $gg_achievements < 2.0
 raise 'Achievements Patch requires RMX-OS 1.18 or higher and Achievements 2.0 or higher.'
end

module RMXOS

 module Options
   SAVE_DATA[Game_System].push('@awards')
 end

end


If you do use RMX-OS, place both of these scripts Below RMX-OS Options and RMX-OS Script but above Main of course.


ThallionDarkshine's Version

My good o' buddy Thallion has his own version which allows for different types of transitioning in/out styles for the achievement.
Spoiler: ShowHide
#===============================================================================
# Achievements
# Version 2.23
# Author game_guy
# Modified by ThallionDarkshine
#-------------------------------------------------------------------------------
# Intro:
# A full blown achievement system. Keep track of events your players pull off
# and make them feel like they've really achieved something. Easy to setup,
# plenty of options to configure it the way you want.
#
# Features:
# -Image/Text Achievement Notification
# -Show all achievements or only ones you unlocked
# -Change text font, size, and color
# -Option to keep track of score
# -Modify notification position
# -Modify text position if using an image
# -Modify popup time
# -Play sound when you unlock an achievement
# -Set return scene, scene you go to when exiting achievements menu
# -Custom queue system allowing you to display multiple achievements at a time
# -Much more compatible
# -Quickly open up achievements without interupting the current scene
# -Block scenes from the Quick Open
# -See if user has a specific achievement
# -See how many achievements the player has
# -Custom Icon Size Support
#
# Instructions:
# -Go down to Begin Config and edit all of your options there.
# -Instructions for creating achievements are also in the Config.
# -To gain an achievement, use Awards.gain(award_id)
# -Award id is set when creating awards.
# -To see if a user has an award use Awards.has?(award_id)
# -To see how many the player has use Awards.count
# -To open up the real achievements scene use
#  $scene = Scene_Achievements.new
#
# Compatibility:
# -Not tested with SDK.
# -Should work with everything.
# -May corrupt old save games.
#
# Credits:
# -game_guy ~ For creating it.
# -jragyn00 ~ For the new layout.
# -GAX72 ~ For test achievement image.
#===============================================================================

module Awards
#===============================================================
# Begin Config
#===============================================================
 #----------------------------------------------------------------------------
 # If true, it'll show all unlocked and locked achievements, else it'll just
 # show unlocked achievements
 #----------------------------------------------------------------------------
 Show_All      = true
 #----------------------------------------------------------------------------
 # If Show_All is on, all locked icons will be displayed with the below
 # icon
 #----------------------------------------------------------------------------
 Locked_Icon   = "034-Item03"
 #----------------------------------------------------------------------------
 # This replaces the achievments description if Show_All is on and the
 # achievement is marked as hidden.
 #----------------------------------------------------------------------------
 Hidden_Info   = "This achievement is hidden. Unlock it to find out more."
 #----------------------------------------------------------------------------
 # The scene you go to when you exit the achievements menu. Set to nil to
 # return to the previous scene.
 #----------------------------------------------------------------------------
 Return_Scene  = nil
 #----------------------------------------------------------------------------
 # If set to an Input key, it will open up a quick view window to view all
 # achievements, can be opened up from anywhere, and doesn't interupt the
 # current scene. Set to nil to turn it off.
 #----------------------------------------------------------------------------
 Quick_Access  = Input::A
 #----------------------------------------------------------------------------
 # Add scenes here that you want quick access blocked on. Example,
 # Scene_Title, wouldn't want users to view achievements there. Kinda odd.
 #----------------------------------------------------------------------------
 Block_Scenes  = [Scene_Title, Scene_Gameover, Scene_File, Scene_Register, Scene_Login, Scene_Servers]
 #----------------------------------------------------------------------------
 # Keep track of score?
 #----------------------------------------------------------------------------
 Track_Score   = true
 #----------------------------------------------------------------------------
 # Text for "Score"
 #----------------------------------------------------------------------------
 Score_Text    = "Points"
 #----------------------------------------------------------------------------
 # Variable to store the score in. (hehe)
 #----------------------------------------------------------------------------
 Variable_Id   = 5
 #----------------------------------------------------------------------------
 # Font name
 # Place your font in string tags "font_here"
 # Or leave it as is to leave the default font.
 #----------------------------------------------------------------------------
 Text_Font     = Font.default_name
 #----------------------------------------------------------------------------
 # Font color : Color.new(red, green, blue)
 #----------------------------------------------------------------------------
 Text_Color    = Color.new(255, 255, 255)
 #----------------------------------------------------------------------------
 # Font size
 #----------------------------------------------------------------------------
 Text_Size     = 24
 #----------------------------------------------------------------------------
 # Where will the award show up on the screen. [X, Y]
 #----------------------------------------------------------------------------
 Award_Place   = [64, 16]
 #----------------------------------------------------------------------------
 # Use background image behind text?
 #----------------------------------------------------------------------------
 Use_Image     = true
 #----------------------------------------------------------------------------
 # File used to display behind the text.
 #----------------------------------------------------------------------------
 Image_File    = "award_background"
 #----------------------------------------------------------------------------
 # Offset for text drawn over the image. [X, Y]
 #----------------------------------------------------------------------------
 Image_Offset  = [72, 0]
 #----------------------------------------------------------------------------
 # Draw icon on notification image?
 #----------------------------------------------------------------------------
 Draw_Icon     = true
 #----------------------------------------------------------------------------
 # Offset for icon drawn over the image. [X, Y]
 #----------------------------------------------------------------------------
 Icon_Offset   = [20, 20]
 #----------------------------------------------------------------------------
 # Custom icon size. If you change these values, you'll have to change
 # Icon_Row and Icon_QuickRow. [WIDTH, HEIGHT]
 #----------------------------------------------------------------------------
 Icon_Size     = [24, 24]
 #----------------------------------------------------------------------------
 # How many icons are displayed in one column (across).
 #----------------------------------------------------------------------------
 Icon_Column   = 10
 #----------------------------------------------------------------------------
 # How many icons are in one column (across) in the Quick View scene.
 #----------------------------------------------------------------------------
 Icon_QColumn  = 8
 #----------------------------------------------------------------------------
 # Time the "Unlocked Achievement" pop up stays on screen in frames.
 #----------------------------------------------------------------------------
 Popup_Time    = 60
 #----------------------------------------------------------------------------
 # What appearance animations to choose from.
 #   Template:
 #     [TYPE] or
 #     [TYPE, DURATION] or
 #     [TYPE, DURATION, EASE] or
 #     [TYPE, DURATION, ARGS] or
 #     [TYPE, DURATION, ARGS, EASE]
 #   TYPE:
 #     0 - Fade Animation
 #       Parameters: []
 #     1 - Zoom Animation
 #       Parameters: [ZOOM] or [ZOOM_X, ZOOM_Y]
 #         ZOOM - The zoom value to grow from.
 #         ZOOM_X, ZOOM_Y - The zoom x and y values to grow from.
 #           note - 100% zoom is a zoom value of 1.0
 #     2 - Spinning Zoom Animation
 #       Parameters: [ANGLE, ZOOM] or [ANGLE, ZOOM_X, ZOOM_Y]
 #         ANGLE - The amount of degrees to rotate.
 #         ZOOM - The zoom value to grow from.
 #         ZOOM_X, ZOOM_Y - The zoom x and y values to grow from.
 #           note - 100% zoom is a zoom value of 1.0
 #     3 - 3D-Spin Animation
 #       Parameters: [ZOOM, NUM_HALF_ROTATIONS]
 #         ZOOM - The zoom value to zoom from during the 3d-spin.
 #           note - 100% zoom is a zoom value of 1.0
 #         NUM_HALF_ROTATIONS - How many times to spin halfway around.
 #     4 - Slide-Out Animation
 #       Parameters: [DIRECTION]
 #         DIRECTION - If positive, then slide to the right, else slide to the left.
 #       note - for this animation, specifying duration doesn't do anything
 #       note - just don't use this animation, I'm pretty sure that there's a bug in it
 #     5 - Tile Swivel Animation
 #       Parameters: []
 #     6 - Shaking Animation
 #       Parameters: [X_SPEED_RANGE, X_POWER_RANGE, Y_SPEED_RANGE, Y_POWER_RANGE]
 #         X_SPEED_RANGE - The range for the x-speed of the shake effect.
 #         X_POWER_RANGE - The range for the x-power of the shake effect.
 #         Y_SPEED_RANGE - The range for the y-speed of the shake effect.
 #         Y_POWER_RANGE - The range for the y-power of the shake effect.
 #         note - this effect is pretty much a less powerful version of the shake
 #           screen effect
 #         note - all ranges are specified as MIN..MAX
 #   DURATION - How long the effect will take.
 #   EASE - Whether to ease in or out of the animation.
 #     -100 - Full Ease-In
 #     0 - No Ease
 #     100 - Full Ease-Out
 #   ARGS - The arguments for each effect.
 #----------------------------------------------------------------------------
 Appear_Anim = [
   [0, 20, 100], # this is a quick fade animation
   [1, 20, 100], # this is a quick grow animation
   [1, 20, [2.0, 0.0], 100], # this is another quick grow animation
   [1, 20, [1.1], 100], # this is a quick shrink animation
   [2, 20], # this is a quick spinning grow animation
   [3, 40], # this is a quick 3d-spin animation
   [5, 20], # this is a quick tile swivel animation
   [6, 20], # this is a quick shaking animation
 ]
 #----------------------------------------------------------------------------
 # What disappearance animations to choose from.
 #   Template:
 #     [TYPE] or
 #     [TYPE, DURATION] or
 #     [TYPE, DURATION, EASE] or
 #     [TYPE, DURATION, ARGS] or
 #     [TYPE, DURATION, ARGS, EASE]
 #   TYPE:
 #     1 - Fade Animation
 #       Parameters: []
 #     2 - Zoom Animation
 #       Parameters: [ZOOM] or [ZOOM_X, ZOOM_Y]
 #         ZOOM - The zoom value to zoom to.
 #         ZOOM_X, ZOOM_Y - The zoom x and y values to zoom to.
 #           note - 100% zoom is a zoom value of 1.0
 #     3 - Spinning Zoom Animation
 #       Parameters: [ANGLE, ZOOM] or [ANGLE, ZOOM_X, ZOOM_Y]
 #         ANGLE - The amount of degrees to rotate.
 #         ZOOM - The zoom value to zoom to.
 #         ZOOM_X, ZOOM_Y - The zoom x and y values to zoom to.
 #           note - 100% zoom is a zoom value of 1.0
 #     4 - 3D-Spin Animation
 #       Parameters: [ZOOM, NUM_HALF_ROTATIONS]
 #         ZOOM - The zoom value to zoom to during the 3d-spin.
 #           note - 100% zoom is a zoom value of 1.0
 #         NUM_HALF_ROTATIONS - How many times to spin halfway around.
 #     5 - Slide-In Animation
 #       Parameters: [DIRECTION]
 #         DIRECTION - If positive, then slide to the right, else slide to the left.
 #       note - for this animation, specifying duration doesn't do anything
 #       note - just don't use this animation, I'm pretty sure that there's a bug in it
 #     6 - Tile Swivel Animation
 #       Parameters: []
 #     7 - Shaking Animation
 #       Parameters: [X_SPEED_RANGE, X_POWER_RANGE, Y_SPEED_RANGE, Y_POWER_RANGE]
 #         X_SPEED_RANGE - The range for the x-speed of the shake effect.
 #         X_POWER_RANGE - The range for the x-power of the shake effect.
 #         Y_SPEED_RANGE - The range for the y-speed of the shake effect.
 #         Y_POWER_RANGE - The range for the y-power of the shake effect.
 #         note - this effect is pretty much a less powerful version of the shake
 #           screen effect
 #         note - all ranges are specified as MIN..MAX
 #     8 - Ripple Animation
 #       Parameters: [AMPLITUDE_X, WAVELENGTH_X, NUM_RIPPLES_X, AMPLITUDE_Y, WAVELENGTH_Y, NUM_RIPPLES_Y]
 #         AMPLITUDE_X, AMPLITUDE_Y - The amplitudes for the x and y ripple effects.
 #         WAVELENGTH_X, WAVELENGTH_Y - The wavelengths for the x and y ripple effects.
 #         NUM_RIPPLES_X, NUM_RIPPLES_Y - How many times to ripple the sprite in x and y.
 #         note - this is one of the most customizable animations. just play around
 #           with it until you find something really cool
 #     9 - Tile Color Change Animation
 #       Parameters: [FADE_DURATION] or
 #          [FADE_DURATION, SIZE_X, SIZE_Y, NEGATIVE?, TINT_AMOUNT, TINT_RED,
 #            TINT_GREEN, TINT_BLUE] or
 #          [FADE_DURATION, SIZE_X, SIZE_Y, NEGATIVE?, TINT_AMOUNT, TINT_RED,
 #            TINT_GREEN, TINT_BLUE, GRAYSCALE_AMOUNT]
 #          FADE_DURATION - The duration of the fading out of tinted sprite.
 #          SIZE_X, SIZE_Y - The x and y size of the tiles.
 #          NEGATIVE? - Whether to make the sprite's color negative.
 #          TINT_AMOUNT - How much to tint the sprite.
 #          TINT_RED, TINT_GREEN, TINT_BLUE - The color with which to tint the sprite.
 #          GRAYSCALE_AMOUNT - How much to grayscale the sprite.
 #     10 - Tile Erase Animation
 #       Parameters: [SIZE_X, SIZE_Y]
 #          SIZE_X, SIZE_Y - The x and y size of the tiles.
 #   DURATION - How long the effect will take.
 #   EASE - Whether to ease in or out of the animation.
 #     -100 - Full Ease-In
 #     0 - No Ease
 #     100 - Full Ease-Out
 #   ARGS - The arguments for each effect.
 #----------------------------------------------------------------------------
 Disappear_Anim = [
   [0, 20], # this is a quick slice animation
   [1, 20], # this is a quick fade animation
   [2, 20], # this is a quick shrink animation
   [2, 20, [2.0, 0.0]], # this is another quick shrink animation
   [2, 20, [1.1, 1.1]], # this is a quick shrink animation
   [3, 20], # this is a quick spinning shrink animation
   [4, 40], # this is a quick 3d-spin animation
   [5, 40], # this is a slide-in animation
   [6, 20], # this is a quick tile swivel animation
   [7, 20], # this is a quick shaking animation
   [8, 20], # this is a quick ripple animation
   [9, 30], # this is a quick bar color change animation
   [10, 20], # this is a quick bar disappear animation
 ]
 #----------------------------------------------------------------------------
 # Sound played when an achievement pops up. ["sound", volume, pitch]
 #----------------------------------------------------------------------------
 Popup_Sound   = ["114-Remedy02", 100, 0]
 Award = []
 #----------------------------------------------------------------------------
 # To add a new award, add a new line:
 # Award[id] = ["name", "description", "icon", score_amount, hidden]
 # score_amount must be set even if Track_Score is off
 # hidden must be set even if Show_All is off
 # If you use Show_All and you want the description of achievements to be
 # hidden, set hidden to true. If its false, it'll tell the name and
 # description.
 #----------------------------------------------------------------------------
 Award[0] = ["New Game", "Start a new game!", "037-Item06", 10, false]
 Award[1] = ["Award 1", "Talk to guy 1.", "046-Skill03", 10, true]
 Award[2] = ["Award 2", "Talk to guy 1.", "046-Skill03", 10, false]
 Award[3] = ["500 Damage", "Deal 500 damage in one attack.", "004-Weapon04", 5, false]
 Award[4] = ["Am I rich?", "Have 1,000,000 gold at one time.", "035-Item04", 10, false]
 Award[5] = ["Window Shopper", "Spend 1,000,000 gold.", "032-Item01", 10, false]
 Award[6] = ["Longer Description", "OMGAR this has a longer description but carries on to the next line. I'm so sexy.", "033-Item02", 0, false]
 Award[7] = ["Log Jumper", "Jump over the log.", "048-Skill05", 5, false]
 Award[8] = ["Super Log Jumper", "Jump over the log 5 times", "048-Skill05", 25, false]
 Award[9] = ["I am hidden!", "Learn about hidden achievements.", "034-Item03", 10, true]
 Award[10] = ["GRRR!!!", "Brave enough to talk to a lion!", "019-Accessory04", 5, false]
 Award[11] = ["Invisible", "Found and talked to invisible person.", "049-Skill06", 50, false]
 Award[12] = ["Swiftly!", "Learn about the Quick Scene!", "020-Accessory05", 100, false]
 Award[13] = ["Overpowered", "Deal 1000 damage in one attack.", "004-Weapon04", 20, false]
 Award[14] = ["That's a lot of damage", "Deal a total of 5000 damage.", "004-Weapon04", 15, false]
 Award[15] = ["Spend some money", "Spend 500 gold in one purchase.", "034-Item03", 5, false]
 Award[16] = ["Excessive Spender", "Spend 1000 gold in one purchase.", "034-Item03", 20, false]
 Award[17] = ["Shop-a-Holic", "Spend a total of 5000 gold.", "034-Item03", 15, false]
 Award[18] = ["A bunch of items", "Have 10 items in your inventory at one time.", "034-Item03", 5, false]
 Award[19] = ["Full Inventory", "Have 25 items in your inventory at one time.", "034-Item03", 15, false]
#===============================================================
# End Config
#===============================================================
 def self.gain(id)
   return if $game_system.awards.include?(id)
   if Awards::Award[id] != nil
     $game_system.gain_award(id)
   end
 end
 def self.has?(id)
   return $game_system.awards.include?(id)
 end
 def self.count
   return $game_system.awards.size
 end
end

$gg_achievements = 2.23
#===============================================================================
# Sprite_Award
#-------------------------------------------------------------------------------
# Draws unlocked achievement.
#===============================================================================
class Sprite_Award < Sprite
 def initialize(award)
   super(nil)
   @award = award
   self.bitmap = Bitmap.new(1, 1)
   self.bitmap.font.name = Awards::Text_Font
   self.bitmap.font.size = Awards::Text_Size
   @text_width = self.bitmap.text_size(@award[0]).width + 8
   @text_height = self.bitmap.text_size(@award[0]).height
   self.bitmap.dispose
   if Awards::Use_Image
     @pic = RPG::Cache.picture(Awards::Image_File)
     @pic_width = @pic.width > @text_width ? @pic.width : @text_width
     @pic_height = @pic.height > @text_height ? @pic.height : @text_height
     self.bitmap = Bitmap.new(@pic_width, @pic_height)
     if Awards::Draw_Icon
       @icon = RPG::Cache.icon(@award[2])
     end
   else
     self.bitmap = Bitmap.new(@text_width, @text_height)
   end
   self.bitmap.font.color = Awards::Text_Color
   self.bitmap.font.name = Awards::Text_Font
   self.bitmap.font.size = Awards::Text_Size
   self.z = 20000
   self.x = Awards::Award_Place[0]
   self.y = Awards::Award_Place[1]
   refresh
 end
 def refresh
   self.bitmap.clear
   x = 0
   y = 0
   if @pic != nil
     self.bitmap.blt(0, 0, @pic, Rect.new(0, 0, @pic.width, @pic.height))
     x = Awards::Image_Offset[0]
     y = Awards::Image_Offset[1]
     if @icon != nil
       icon_off = Awards::Icon_Offset
       self.bitmap.blt(icon_off[0], icon_off[1], @icon, Rect.new(0, 0,
           Awards::Icon_Size[0], Awards::Icon_Size[1]))
     end
   end
   text = @award[0]
   if @text_width + x > self.bitmap.width
     text = self.bitmap.slice_text(@award[0], self.bitmap.width - x)
     text.each_index {|i|
       self.bitmap.draw_text(x, y + i * @text_height + 4,
           @text_width, @text_height, text[i])}
   else
     self.bitmap.draw_text(x, y, @text_width, @text_height, text)
   end
 end
 def dispose
   super
   if self.bitmap != nil
     self.bitmap.dispose
   end
 end
end
#===============================================================================
# Graphics
#-------------------------------------------------------------------------------
# **added method to control and draw all queued achievements.
#===============================================================================
module Graphics
 class << self
   alias gg_upd_awards_queue_lat update
 end
 def self.update
   @frame = 0 if @frame == nil
   if $game_system != nil && $game_system.queue.size > 0 && @frame < 1
     award = Awards::Award[$game_system.queue[0]]
     if award != nil
       @sprite = Sprite_Award.new(award)
       @frame = Awards::Popup_Time
       unless Awards::Appear_Anim.empty?
         anim = Awards::Appear_Anim[rand(Awards::Appear_Anim.length)]
         if anim.length > 0
           @frame += (anim[1].nil? ? 40 : anim[1])
           Transitions.transition_in(@sprite, *anim)
         end
       end
       unless Awards::Disappear_Anim.empty?
         anim = Awards::Disappear_Anim[rand(Awards::Disappear_Anim.length)]
         if anim.length > 0
           @frame += (anim[1].nil? ? 40 : anim[1])
           @anim = anim
         else
           @anim = nil
         end
       end
       Audio.se_play("Audio/SE/#{Awards::Popup_Sound[0]}",
         Awards::Popup_Sound[1], Awards::Popup_Sound[2])
     end
   end
   if @frame > 0
     @frame -= 1
     if !@anim.nil? and @frame == (@anim[1].nil? ? 40 : @anim[1])
       Transitions.transition_out(@sprite, *@anim)
       @anim = nil
     elsif @frame < 1
       @sprite.dispose
       $game_system.queue.shift
     end
   end
   gg_upd_awards_queue_lat
 end
end
#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# **modded to keep track of queued and obtained achievements.
#===============================================================================
class Game_System
 attr_accessor :awards
 attr_accessor :queue
 alias gg_init_awards_sys_lat initialize
 def initialize
   @awards = []
   @queue = []
   gg_init_awards_sys_lat
 end
 def gain_award(id)
   return if @awards.include?(id) || Awards::Award[id] == nil
   if Awards::Track_Score
     $game_variables[Awards::Variable_Id] += Awards::Award[id][3]
   end
   @awards.push(id)
   @queue.push(id)
 end
end
#===============================================================================
# Bitmap
#===============================================================================
class Bitmap
 
 def slice_text(text, width)
   words = text.split(' ')
   return words if words.size == 1
   result, current_text = [], words.shift
   words.each_index {|i|
       if self.text_size("#{current_text} #{words[i]}").width > width
         result.push(current_text)
         current_text = words[i]
       else
         current_text = "#{current_text} #{words[i]}"
       end
       result.push(current_text) if i >= words.size - 1}
   return result
 end
 
end

#===============================================================================
# Window_QuickHelp
#===============================================================================
class Window_QuickHelp < Window_Base
 def initialize
   super(64, 32, 512, 160)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.z = 10000
 end
 def set_award(award)
   @award = award
   refresh
 end
 def refresh
   self.contents.clear
   if @award.nil?
     self.contents.draw_text(contents.rect, "No Awards to Display", 1)
   else
     self.contents.draw_text(0, 0, 512 / 2, 32, @award[0][0])
     if Awards::Track_Score
       text = "#{@award[0][3]} #{Awards::Score_Text}"
       self.contents.draw_text(0, 0, 512 - 32, 32, text, 2)
       text = "Total #{Awards::Score_Text}: #{$game_variables[Awards::Variable_Id]}"
       self.contents.draw_text(0, 32, 512 - 32, 32, text, 2)
     end
     text = self.contents.slice_text(@award[0][1], 512 - 32)
     if @award[0][4] && !$game_system.awards.include?(@award[1])
       text = self.contents.slice_text(Awards::Hidden_Info, 512 - 32)
     end
     text.each_with_index {|i, ind|
       self.contents.draw_text(0, 64 + ind * 32, 512 - 32, 32, i)
     }
   end
 end
end
#===============================================================================
# Window_QuickAwards
#===============================================================================
class Window_QuickAwards < Window_Selectable
 def initialize
   super(64, 128 + 64, 512, 320 - 64)
   @column_max = Awards::Icon_QColumn
   self.z = 10000
   refresh
   self.index = 0
 end
 def item
   return @data[self.index]
 end
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   $game_system.awards.each {|i|
     @data.push([Awards::Award[i], i])
   }
   if Awards::Show_All
     @data = []
     @locked = []
     @unlocked = []
     Awards::Award.each_with_index {|i, ind|
       unless i.nil?
         if $game_system.awards.include?(ind)
           @unlocked.push([i, ind])
         else
           @locked.push([i, ind])
         end
       end
     }
     @unlocked.each {|i| @data.push(i)}
     @locked.each {|i| @data.push(i)}
   end
   @item_max = @data.size
   if @item_max > 0
     height = [32, Awards::Icon_Size[1]].max
     self.contents = Bitmap.new(width - 32, row_max * (height + 4))
     (0...@item_max).each { |i|
       draw_item(i)
     }
   end
   if @data.empty?
     self.contents = Bitmap.new(width - 32, self.height - 32)
     contents.draw_text(contents.rect, "You have not unlocked any achievements yet.", 1)
   end
 end
 def draw_item(index)
   item = @data[index]
   width = [32, Awards::Icon_Size[0]].max
   height = [32, Awards::Icon_Size[1]].max
   x = 4 + index % @column_max * (width + 32)
   y = index / @column_max * (height + 4)
   rect = Rect.new(x, y, self.width / @column_max - 32, height)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   if $game_system.awards.include?(item[1])
     bitmap = RPG::Cache.icon(item[0][2])
   else
     bitmap = RPG::Cache.icon(Awards::Locked_Icon)
   end
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, Awards::Icon_Size[0],
       Awards::Icon_Size[1]))
 end
 def update_help
   @help_window.set_award(self.item)
 end
 def update_cursor_rect
   if @index < 0 or @data.empty?
     self.cursor_rect.empty
     return
   end
   row = @index / @column_max
   if row < self.top_row
     self.top_row = row
   end
   if row > self.top_row + (self.page_row_max - 1)
     self.top_row = row - (self.page_row_max - 1)
   end
   cursor_width = [32, Awards::Icon_Size[0]].max
   cursor_height = [32, Awards::Icon_Size[1]].max
   x = @index % @column_max * (cursor_width + 32)
   y = @index / @column_max * (cursor_height + 4) - self.oy
   self.cursor_rect.set(x, y, cursor_width, cursor_height + 4)
 end
end
#===============================================================================
# QScene_Awards
#===============================================================================
class QScene_Awards
 def initialize
   Graphics.freeze
   @awards = Window_QuickAwards.new
   @help = Window_QuickHelp.new
   @awards.help_window = @help
   Graphics.transition
   loop do
     Graphics.update
     Input.update_old
     update
     if Input.trigger?(Input::B)
       $game_system.se_play($data_system.cancel_se)
       break
     end
   end
   Graphics.freeze
   @awards.dispose
   @help.dispose
   Graphics.transition
 end
 def update
   @awards.update
   @help.update
 end
end
#===============================================================================
# Input
#===============================================================================
module Input
 class << self
   alias gg_init_quick_awards_lat update
 end
 def self.update_old
   gg_init_quick_awards_lat
 end
 def self.check_blocked
   Awards::Block_Scenes.each {|s|
     return true if $scene.is_a?(s)
   }
   return false
 end
 def self.update
   if Awards::Quick_Access != nil && Input.trigger?(Awards::Quick_Access) &&
         @scene == nil && !self.check_blocked
     if defined?(RMXOS) && $game_temp.chat_active == true
         return gg_init_quick_awards_lat
     end
     $game_system.se_play($data_system.decision_se)
     @scene = QScene_Awards.new
     @scene = nil
   end
   gg_init_quick_awards_lat
 end
end

#===============================================================================
# Window_Award
#===============================================================================
class Window_Award < Window_Base
 def initialize
   super(0, 320, 640, 160)
   self.contents = Bitmap.new(width - 32, height - 32)
 end
 def set_award(award)
   @award = award
   refresh
 end
 def refresh
   self.contents.clear
   if @award.nil?
     self.contents.draw_text(contents.rect, "No Awards to Display", 1)
   else
     self.contents.draw_text(0, 0, 640 / 2, 32, @award[0][0])
     if Awards::Track_Score
       text = "#{@award[0][3]} #{Awards::Score_Text}"
       self.contents.draw_text(0, 0, 640 - 32, 32, text, 2)
       text = "Total #{Awards::Score_Text}: #{$game_variables[Awards::Variable_Id]}"
       self.contents.draw_text(0, 32, 640 - 32, 32, text, 2)
     end
     text = self.contents.slice_text(@award[0][1], 640 - 32)
     if @award[0][4] && !$game_system.awards.include?(@award[1])
       text = self.contents.slice_text(Awards::Hidden_Info, 640 - 32)
     end
     text.each_with_index {|i, ind|
       self.contents.draw_text(0, 64 + ind * 32, 640 - 32, 32, i)
     }
   end
 end
end
#===============================================================================
# Window_Awards
#===============================================================================
class Window_Awards < Window_Selectable
 def initialize
   super(0, 0, 640, 320)
   @column_max = Awards::Icon_Column
   refresh
   self.index = 0
 end
 def item
   return @data[self.index]
 end
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   $game_system.awards.each {|i|
     @data.push([Awards::Award[i], i])
   }
   if Awards::Show_All
     @data = []
     @locked = []
     @unlocked = []
     Awards::Award.each_with_index {|i, ind|
       unless i.nil?
         if $game_system.awards.include?(ind)
           @unlocked.push([i, ind])
         else
           @locked.push([i, ind])
         end
       end
     }
     @unlocked.each {|i| @data.push(i)}
     @locked.each {|i| @data.push(i)}
   end
   @item_max = @data.size
   if @item_max > 0
     height = Awards::Icon_Size[1] < 32 ? 32 : Awards::Icon_Size[1]
     self.contents = Bitmap.new(width - 32, row_max * (height + 4))
     (0...@item_max).each { |i|
       draw_item(i)
     }
   end
   if @data.empty?
     self.contents = Bitmap.new(width - 32, self.height - 32)
     contents.draw_text(contents.rect, "You have not unlocked any achievements yet.", 1)
   end
 end
 def draw_item(index)
   item = @data[index]
   width = Awards::Icon_Size[0] < 32 ? 32 : Awards::Icon_Size[0]
   height = Awards::Icon_Size[1] < 32 ? 32 : Awards::Icon_Size[1]
   x = 4 + index % @column_max * (width + 32)
   y = index / @column_max * (height + 4)
   rect = Rect.new(x, y, self.width / @column_max - 32, Awards::Icon_Size[1])
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   if $game_system.awards.include?(item[1])
     bitmap = RPG::Cache.icon(item[0][2])
   else
     bitmap = RPG::Cache.icon(Awards::Locked_Icon)
   end
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, Awards::Icon_Size[0],
     Awards::Icon_Size[1]))
 end
 def update_help
   @help_window.set_award(self.item)
 end
 def update_cursor_rect
   if @index < 0 or @data.empty?
     self.cursor_rect.empty
     return
   end
   row = @index / @column_max
   if row < self.top_row
     self.top_row = row
   end
   if row > self.top_row + (self.page_row_max - 1)
     self.top_row = row - (self.page_row_max - 1)
   end
   cursor_width = [32, Awards::Icon_Size[0]].max
   cursor_height = [32, Awards::Icon_Size[1]].max
   x = @index % @column_max * (cursor_width + 32)
   y = @index / @column_max * (cursor_height + 4) - self.oy
   self.cursor_rect.set(x, y, cursor_width, cursor_height)
 end
end
#===============================================================================
# Scene_Achievements
#===============================================================================
class Scene_Achievements
 def initialize
   @prev_scene = $scene.class
 end
 
 def main
   @help = Window_Award.new
   @awards = Window_Awards.new
   @awards.help_window = @help
   Graphics.transition
   loop do
     Graphics.update
     Input.update_old
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   @help.dispose
   @awards.dispose unless @awards.nil?
 end
 def update
   @awards.update unless @awards.nil?
   @help.update
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     if Awards::Return_Scene.nil?
       $scene = @prev_scene.new
     else
       $scene = Awards::Return_Scene.new
     end
     return
   end
 end
end


Note, to use this, you'll need this script and this dll.


Snippets & Stuff

Damage Achievement Mod
This gives the player an achievement when an actor deals X amount of damage. Place below Achievements script. Allows for multiple achievements.
Spoiler: ShowHide
#===============================================================================
# X Damage Achievement Mod
# Author game_guy
# Modified by ThallionDarkshine
#-------------------------------------------------------------------------------
# Info:
# Small snippet to give the player an achievement when one attack deals X
# damage. It only works with any attack except items. Added code to allow total
# damage dealt to trigger achievements.
#
# Instructions:
# Edit list of awards below.
#
# Place below the achievements script.
#===============================================================================
DMG_AWARDS = []
# Add new lines here
# Type in
# DMG_AWARDS[number] = [award_id, total?, amount_of_damage]
DMG_AWARDS[0] = [3, false, 500]
DMG_AWARDS[1] = [13, false, 1000]
DMG_AWARDS[2] = [14, true, 5000]
if $gg_achievements == nil || $gg_achievements < 2.0
 raise 'Damage Achievement Mod requires game_guy\'s Achievements v2.0 or higher'
end
class Game_Battler
 alias gg_init_damage_award_lat attack_effect
 def attack_effect(attacker)
   if attacker.is_a?(Game_Actor)
     old_hp = self.hp
     result = gg_init_damage_award_lat(attacker)
     if result
       damage = self.damage.is_a?(String) ? 0 : self.damage
       $game_system.damage += damage
       DMG_AWARDS.each {|i|
         if !i[1] and damage > i[2]
           Awards.gain(i[0])
         elsif i[1] and $game_system.damage > i[2]
           Awards.gain(i[0])
         end
       }
     end
     return result
   else
     return gg_init_damage_award_lat(attacker)
   end
 end
 alias gg_init_damage_skill_award_lat skill_effect
 def skill_effect(user, skill)
   if user.is_a?(Game_Actor)
     old_hp = self.hp
     result = gg_init_damage_skill_award_lat(user, skill)
     if result
       damage = self.damage.is_a?(String) ? 0 : self.damage
       $game_system.damage += damage
       DMG_AWARDS.each {|i|
         if !i[1] and damage > i[2]
           Awards.gain(i[0])
         elsif i[1] and $game_system.damage > i[2]
           Awards.gain(i[0])
         end
       }
     end
     return result
   else
     return gg_init_damage_skill_award_lat(user, skill)
   end
 end
end

class Game_System
 attr_accessor :damage
 
 alias tdks_xdmg_init initialize
 def initialize
   tdks_xdmg_init
   @damage = 0
 end
end


Gold Spent Mod
Gives the player an achievement after spending X total gold.
Spoiler: ShowHide
#===============================================================================
# X Gold Spent Achievement Mod
# Author ThallionDarkshine
#-------------------------------------------------------------------------------
# Info:
# Small snippet to give the player an achievement when they spend a certain amount
# of gold either total or in a single purchase.
#
# Instructions:
# Edit list of awards below.
#
# Compatibility:
# Probably won't work with Scene_Shop scripts.
#
# Place below the achievements script.
#===============================================================================
GOLD_AWARDS = []
# Add new lines here
# Type in
# GOLD_AWARDS[number] = [award_id, total?, amount_of_gold]
GOLD_AWARDS[0] = [15, false, 500]
GOLD_AWARDS[1] = [16, false, 1000]
GOLD_AWARDS[2] = [17, true, 5000]
if $gg_achievements == nil || $gg_achievements < 2.0
 raise 'Gold Spent Achievement Mod requires game_guy\'s Achievements v2.0 or higher'
end

class Scene_Shop
 alias tdks_xgold_updt_num update_number
 def update_number
   gold = $game_party.gold
   tdks_xgold_updt_num
   if $game_party.gold < gold
     $game_system.gold_spent += gold - $game_party.gold
     GOLD_AWARDS.each { |i|
       if !i[1] and gold - $game_party.gold >= i[2]
         Awards.gain(i[0])
       elsif i[1] and $game_system.gold_spent >= i[2]
         Awards.gain(i[0])
       end
     }
   end
 end
end

class Game_System
 attr_accessor :gold_spent
 
 alias tdks_xgold_init initialize
 def initialize
   tdks_xgold_init
   @gold_spent = 0
 end
end


Items Gained Mod
Gives the player an achievement after gaining X total items.
Spoiler: ShowHide
#===============================================================================
# X Item Achievement Mod
# Author ThallionDarkshine
#-------------------------------------------------------------------------------
# Info:
# Small snippet to give players achievements when they have a certain number of
# items in their inventory.
#
# Instructions:
# Edit list of awards below.
#
# Compatibility:
# Probably won't work with Scene_Shop scripts.
#
# Place below the achievements script.
#===============================================================================
ITEM_AWARDS = []
# Add new lines here
# Type in
# ITEM_AWARDS[number] = [award_id, amount_of_items]
ITEM_AWARDS[0] = [18, 10]
ITEM_AWARDS[1] = [19, 25]
if $gg_achievements == nil || $gg_achievements < 2.0
 raise 'Item Achievement Mod requires game_guy\'s Achievements v2.0 or higher'
end

class Game_Party
 def num_items
   num = 0
   @items.each { |i| num += i[1] }
   @weapons.each { |i| num += i[1] }
   @armors.each { |i| num += i[1] }
   num
 end
 
 alias tdks_item_awrds_gain_item gain_item
 def gain_item(id, n)
   tdks_item_awrds_gain_item(id, n)
   if n > 0
     ITEM_AWARDS.each { |i|
       if num_items >= i[1]
         Awards.gain(i[0])
       end
     }
   end
 end
 
 alias tdks_item_awrds_gain_weapon gain_weapon
 def gain_weapon(id, n)
   tdks_item_awrds_gain_weapon(id, n)
   if n > 0
     ITEM_AWARDS.each { |i|
       if num_items >= i[1]
         Awards.gain(i[0])
       end
     }
   end
 end
 
 alias tdks_item_awrds_gain_armor gain_armor
 def gain_armor(id, n)
   tdks_item_awrds_gain_armor(id, n)
   if n > 0
     ITEM_AWARDS.each { |i|
       if num_items >= i[1]
         Awards.gain(i[0])
       end
     }
   end
 end
end



Instructions

All in the script.


Compatibility

-Not tested with SDK.
-Should work with everything.
-May corrupt old save games.


Credits and Thanks


    -game_guy ~ For creating it.
    -jragyn00 ~ For the new layout + testing.
    -GAX72 ~ For test achievement image.



Author's Notes

Enjoy! Post any bugs if you find any!


tSwitch

April 20, 2009, 09:19:33 am #2 Last Edit: April 20, 2009, 09:22:25 am by NAMKCOR
why in god's name is all that stuff in the class?

if you don't mind, I think I'm going to make a smaller version of this...maybe with my own little feature that I was hoping to figure out...


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

G_G

April 20, 2009, 09:29:59 am #3 Last Edit: April 21, 2009, 08:41:24 pm by game_guy
I'm working on removing alot of lines NAM. The new version I'm making also has an option of turning on GamerScore and have a different name for teh score. The score will also be stored in a variable. Its about done.


EDIT: Updates.
New features:
GamerScore is displayed.
You can change what the Score is named
Score is stored in a variable and you choose the number.
Theres an option to turn on the Print so it prints what achievement you unlocked.

EDIT2: *Updates* Added a video sample for those who dont really get what the script does and you dont want to download the demo.
http://www.youtube.com/watch?v=HanCYAw7RtE

Das oopdaytes shood beh wee thin eh dets beh cahz oof das roolez. (The updates should be within edits because of the rules.) ~Love, Starrodkirby86

EDIT 3: http://2ghwfa.blu.livefilestore.com/y1pJQuYCjUoeXSQEfc-1rqfJngXN2-jhz15-8zeT8v8w8scKOeVJKZzRZmi9Gwhz2-mrjbv2yXa_FcFM4grXczpkNZZVwJo-ui7/achievements.txt direct text link

tSwitch

ok I'm going to make a big suggestion.

don't make it pop up the alert window like that.  I can only imagine that being the most annoying thing in the world, that you get the 10,000 damage dealt achievement right in the middle of the big boss fight and a message window pops up, freezing your game.


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

G_G


Mightylink

Very nice script, nice and simple, I like the window layout of the achivements list, I can probably put an image in that black area, thanks for keeping it open. What I dont like though is the window poping up when you gain them, that should really be an in game window, not a windows window :P

I hope you dont mind I modify this a bit for my game, I'd like to get it to launch url's to update online stats for my website. You will get credits of course :)

Thanks for this wonderful script, some might say its too simple but it was very well needed.

tSwitch

Quote from: game_guy on April 22, 2009, 05:54:40 pm
Its an optional feature


still, I think I'm going to script up my own version of an Achievements system


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

G_G

This script is about done updating and soon you'lll just have to use the regular change item commands. The print feature will be removed and I'll add an option to have the GamerScore On/Off

tSwitch

April 23, 2009, 10:29:35 am #9 Last Edit: April 23, 2009, 10:34:16 am by NAMKCOR
hmm...been thinking about this a bit myself.
the most compatible way to make this script is to do the script call to add achievements, so that's a good idea
*hadn't been really thinking about it before*

however, there are still a few things I'd change, and some features I'd add myself, so if you don't mind competition, I'll probably fix up my own version today ;)

edit: well, the basics of it at least, there's a couple things I want to do that I'm not so certain I quite know how to do yet.


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Mightylink

April 23, 2009, 08:08:38 pm #10 Last Edit: April 23, 2009, 08:09:41 pm by Mightylink
I love the gamerscore, id probably change it to something else though so its not ripping xbox lol. For mine I think i will go Z-Points cause my webside is ZVC Studios.

But unlike microsoft have them actually worth something, either buy in game rewords or have it upload to a site to share the points across many games.

G_G

Well I could make an add on for this script. Converts Points to a certain amount of gold, or even setup a shop where it uses Points instead of gold. In fact thats exactly what I'll do!

Expect it in the next update!

tSwitch

Quote from: game_guy on April 23, 2009, 08:11:45 pm
Well I could make an add on for this script. Converts Points to a certain amount of gold, or even setup a shop where it uses Points instead of gold. In fact thats exactly what I'll do!

Expect it in the next update!


that's a pretty cool idea.


FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

Mightylink

I cant get this to work. Starting a new game and going to the event works but after saving and loading it crashes with undefined event gain_item

G_G

SHIT SHIT SHIT FORGOT TO FIX SOMETHING DAMMIT!

Need to fix somethign sorry.

Mightylink

May 02, 2009, 06:21:08 pm #15 Last Edit: May 02, 2009, 06:22:37 pm by Mightylink
I can wait, I like yours better cause it comes with a menu and I love the layout of it. I also like how it uses items as achivements so I can use icons in it too ^_^

What does bother me a bit though is how it shows the item count ":1" at the end, is it possible to remove that so only the name of the item shows?

G_G

I'll fix it next update I just gotta find the time to update it.

Punn

Achievement are kinda pointless, there's no compensation for completing 'em, only bragging rights.

Mightylink

Thats why I love this script, you can use the variable for rewards in the game, have like a vendor that uses gamerscore instead of money, but your totally right, those bigger companies should use them for something.

G_G

May 06, 2009, 11:11:03 pm #19 Last Edit: May 06, 2009, 11:16:03 pm by Youngster Gi Gi
I'm fixing the script right now Link. I completely forgot about it :P

EDIT: Done fixed the error now try it.
Spoiler: ShowHide
#===============================================================================
# Achievements Script
#===============================================================================
# Created By: Game_guy
# Date: April 19th, 2009
#===============================================================================
=begin
This is an achievements script. This is pretty much a system like off the
Xbox360. This is really easy to use its pretty much a simple plug and play!
You don't need to set anything up in the script at all!

Q: If I dont need to setup achievemnts in the script, where do I set them up?
A: Simple! Its all in teh database. With this script the achievements are
   items. You make an Item in the database with an Achievement Name and
   Description.
   
Q: That sounds easy! But how do I turn on/give achievemnts?
A: Easy! use this in a script call and enter this in
   $achieve.gain_item(item_id)
   
Q: So how do I view achievements?
A: $scene = Scene_Achievements.new

Q: How do we setup the achievements score?
A: Set the price in the item. That is the score.
=end
module GameGuy
  Print           = true # Message box comes up and says the achievement you unlocked
  ScoreName       = "GamerScore: " # The word you want the score to be called.
  ScoreVariable   = 1 # The variable that the score stays in.
  ItemStorageUsed = false # set it true if you use my item storage script
end
class Window_Score < Window_Base

  def initialize
    super(0, 0, 320, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end

  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, GameGuy::ScoreName.to_s)
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 32, 120, 32, $game_variables[GameGuy::ScoreVariable].to_s)
  end
end

class Achievements
  def initialize
    @items = {}
    @weapons = {}
    @armors = {}
  end

  def item_number(item_id)
    return @items.include?(item_id) ? @items[item_id] : 0
  end

  def weapon_number(weapon_id)
    return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
  end

  def armor_number(armor_id)
    return @armors.include?(armor_id) ? @armors[armor_id] : 0
  end

  def gain_item(item_id)
    if item_id > 0
      @items[item_id] = [[item_number(item_id) + 1, 0].max, 99].min
      print $data_items[item_id].name + " Unlocked" if GameGuy::Print == true
      $game_variables[GameGuy::ScoreVariable] += $data_items[item_id].price
    end
  end

  def gain_weapon(weapon_id)
    if weapon_id > 0
      @weapons[weapon_id] = [[weapon_number(weapon_id) + 1, 0].max, 99].min
    end
  end

  def gain_armor(armor_id)
    if armor_id > 0
      @armors[armor_id] = [[armor_number(armor_id) + 1, 0].max, 99].min
    end
  end

  def lose_item(item_id, n)
    gain_item(item_id, -n)
  end

  def lose_weapon(weapon_id, n)
    gain_weapon(weapon_id, -n)
  end

  def lose_armor(armor_id, n)
    gain_armor(armor_id, -n)
  end

  def item_can_use?(item_id)
    # If item quantity is 0
    if item_number(item_id) == 0
      # Unusable
      return false
    end
    # Get usable time
    occasion = $data_items[item_id].occasion
    # If in battle
    if $game_temp.in_battle
      # If useable time is 0 (normal) or 1 (only battle) it's usable
      return (occasion == 0 or occasion == 1)
    end
    # If useable time is 0 (normal) or 2 (only menu) it's usable
    return (occasion == 0 or occasion == 2)
  end
end

class Scene_Title
  alias re_new_game command_new_game
  def command_new_game
    $achieve = Achievements.new
    re_new_game
  end
end


class Window_Achievements < Window_Selectable

  def initialize
    super(0, 64, 320, 416)
    @column_max = 1
    refresh
    self.index = 0
    # If in battle, move window to center of screen
    # and make it semi-transparent
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end

  def item
    return @data[self.index]
  end

  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $achieve.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $achieve.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $achieve.armor_number(i) > 0
          @data.push($data_armors[i])
        end
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $achieve.item_number(item.id)
    when RPG::Weapon
      number = $achieve.weapon_number(item.id)
    when RPG::Armor
      number = $achieve.armor_number(item.id)
    end
    if item.is_a?(RPG::Item)
      self.contents.font.color = normal_color
    end
    x = 4 + index % @column_max * (288 + 32)
    y = index / @column_max * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  end

  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end
class Scene_Achievements
  def main
    @help_window = Window_Help.new
    @achieve_window = Window_Achievements.new
    @achieve_window.help_window = @help_window
    @score_window = Window_Score.new
    @score_window.x = 320
    @score_window.y = 384
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @achieve_window.dispose
    @score_window.dispose
  end
  def update
    @help_window.update
    @achieve_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(0)
      return
    end
  end
end

class Scene_Save < Scene_File
  def write_save_data(file)
    # Make character data for drawing save file
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end
    # Write character data for drawing save file
    Marshal.dump(characters, file)
    # Wrire frame count for measuring play time
    Marshal.dump(Graphics.frame_count, file)
    # Increase save count by 1
    $game_system.save_count += 1
    # Save magic number
    # (A random value will be written each time saving with editor)
    $game_system.magic_number = $data_system.magic_number
    # Write each type of game object
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
    Marshal.dump($achievements, file)
    Marshal.dump($game_chest, file) if GameGuy::ItemStorageUsed
  end
end
class Scene_Load < Scene_File
  def read_save_data(file)
    # Read character data for drawing save file
    characters = Marshal.load(file)
    # Read frame count for measuring play time
    Graphics.frame_count = Marshal.load(file)
    # Read each type of game object
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    $achievements = Marshal.load(file)
    $game_chest = Marshal.load(file) if GameGuy::ItemStorageUsed
    # If magic number is different from when saving
    # (if editing was added with editor)
    if $game_system.magic_number != $data_system.magic_number
      # Load map
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    # Refresh party members
    $game_party.refresh
  end
end



PLACE BELOW MY ITEM STORAGE SCRIPT IF YOU USE IT!!!!