Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: G_G on April 20, 2009, 01:18:40 am

Title: [XP] Achievements Script
Post by: G_G on April 20, 2009, 01:18:40 am
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



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) (http://decisive-media.net/gameguy/Achievements.exe) (Broken Link, Lost Demo)
Unofficial Demo Provided by ThallionDarkshine (https://www.box.com/s/q5pn9ctai34wgdwy6wtm)


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 (http://pastebin.com/raw.php?i=P6YDaVzU) and this dll (https://www.box.com/s/ykkt0r1bsfz84p6khvq5).


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




Author's Notes

Enjoy! Post any bugs if you find any!
Title: Re: [XP] Achievements Script
Post by: Reno-s--Joker on April 20, 2009, 03:55:25 am
Lol! They're items. :xD:

Nice and neat little script G_G! ^_^
Title: Re: [XP] Achievements Script
Post by: tSwitch on April 20, 2009, 09:19:33 am
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...
Title: Re: [XP] Achievements Script
Post by: G_G on April 20, 2009, 09:29:59 am
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
Title: Re: [XP] Achievements Script
Post by: tSwitch on April 22, 2009, 09:06:15 am
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.
Title: Re: [XP] Achievements Script
Post by: G_G on April 22, 2009, 05:54:40 pm
Its an optional feature
Title: Re: [XP] Achievements Script
Post by: Mightylink on April 23, 2009, 01:30:04 am
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.
Title: Re: [XP] Achievements Script
Post by: tSwitch on April 23, 2009, 08:28:59 am
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
Title: Re: [XP] Achievements Script
Post by: G_G on April 23, 2009, 10:13:43 am
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
Title: Re: [XP] Achievements Script
Post by: tSwitch on April 23, 2009, 10:29:35 am
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.
Title: Re: [XP] Achievements Script
Post by: Mightylink on April 23, 2009, 08:08:38 pm
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.
Title: Re: [XP] Achievements Script
Post by: G_G 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!
Title: Re: [XP] Achievements Script
Post by: tSwitch on April 23, 2009, 08:16:21 pm
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.
Title: Re: [XP] Achievements Script
Post by: Mightylink on May 02, 2009, 03:11:13 am
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
Title: Re: [XP] Achievements Script
Post by: G_G on May 02, 2009, 03:15:22 am
SHIT SHIT SHIT FORGOT TO FIX SOMETHING DAMMIT!

Need to fix somethign sorry.
Title: Re: [XP] Achievements Script
Post by: Mightylink on May 02, 2009, 06:21:08 pm
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?
Title: Re: [XP] Achievements Script
Post by: G_G on May 02, 2009, 06:24:37 pm
I'll fix it next update I just gotta find the time to update it.
Title: Re: [XP] Achievements Script
Post by: Punn on May 06, 2009, 03:27:37 pm
Achievement are kinda pointless, there's no compensation for completing 'em, only bragging rights.
Title: Re: [XP] Achievements Script
Post by: Mightylink on May 06, 2009, 11:00:04 pm
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.
Title: Re: [XP] Achievements Script
Post by: G_G on May 06, 2009, 11:11:03 pm
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!!!!
Title: Re: [XP] Achievements Script
Post by: Murachacha on August 04, 2009, 08:09:39 am
Can anyone tell me how i can use the Archievement system to buy spaciel things... i mean when i have 5 archievements that gives 50 points than i can buy something... sry for my bad english^^
Title: Re: [XP] Achievements Script
Post by: Starrodkirby86 on August 04, 2009, 12:11:43 pm
I don't know how the script is used so much, so I'm taking a blind concept shot here.

Achievements give scores right? Kind of like how puzzles give picarats in Professor Layton?

Well, according to the script features, the scores are stored in a variable.

You can make a 'shop' via events that handles the scores variable as your currency. It might take a bit of Conditional Forking, but hey, that's what eventing's all about, no?

You can also create a variable which stores the amount of gold you have, then switch the player's G amount temporarily to the amount in your scores variable, and after the evented store is finished, you can switch it back.
Title: Re: [XP] Achievements Script
Post by: G_G on August 05, 2009, 09:37:39 am
To do what Srk said, here's the event.
Spoiler: ShowHide
(http://img44.imageshack.us/img44/5654/simpletrick.png) (http://img44.imageshack.us/i/simpletrick.png/)

Title: Re: [XP] Achievements Script
Post by: JEHINC. on September 26, 2009, 05:33:28 pm
Ok, this is a great script, and I really want to use it in my project, but When I load a saved game and try to open the Achievement Window I get this message       

Script 'Achievement Script' line156: NoMethodError occurred.
undefined method 'item_number' for nil:NilClass

Is there any way to fix this problem? :???:
Title: Re: [XP] Achievements Script
Post by: Aqua on September 26, 2009, 05:40:41 pm
Start a new game.
Don't use an old save file
Title: Re: [XP] Achievements Script
Post by: G_G on September 26, 2009, 05:42:50 pm
I'm also going to revamp this script as well.

And I'm going to add the option so when an achievement is gained text pops up instead of a window.
Any other suggestions?
Title: Re: [XP] Achievements Script
Post by: JEHINC. on September 26, 2009, 05:45:15 pm
I started a new game then saved/Quit. Then loaded the save and try to bring up the window, and I still get the same message. >:(
Title: Re: [XP] Achievements Script
Post by: G_G on September 26, 2009, 05:49:01 pm
Like I said I'm remaking the system...its going to be alot more compatible so if you can wait a couple of hours everything will be fixed
Title: Re: [XP] Achievements Script
Post by: JEHINC. on September 26, 2009, 05:51:40 pm
Thanks alot.  :)
Title: Re: [XP] Achievements Script
Post by: G_G on September 27, 2009, 03:59:23 am
Okay I'm remaking the system like I said earlier.

I'm replacing the pop up window with pop up text. Any other suggestions?
Title: Re: [XP] Achievements Script
Post by: Axerax on September 27, 2009, 01:22:57 pm
You should make a call script window so the player can view what their Achievements are, with acquired ones darkened out or HIDDEN for secret ones. Acquired ones would be in maybe a yellowish gold like font or white. Make point gaining optional, maybe some of us, like me, would just like stuff for people to try and achieve. Maybe allow rewards for having so many achievements. So like every 5 or 10 or even player specify in the script where the user gets the reward. Or even have some achievements give rewards, player specified obviously.

As for pop up text, Pop up on the bottom part of the screen (make this editable for users so they can have it where they want.) and fade away going up, that way if they get two in a row, it will flow nicely, without causing screen clutter. A good 5 second face time is good for displaying them imo.
Title: Re: [XP] Achievements Script
Post by: Jackolas on September 27, 2009, 04:29:38 pm
someone has played to much World of Warcraft  :naughty:
Title: Re: [XP] Achievements Script
Post by: Axerax on September 27, 2009, 05:41:00 pm
Only for 3 years when it first came out XD.

I stopped after they started adding achievements, I was trying to focus it around how XBOX360 does it.
Title: Re: [XP] Achievements Script
Post by: Jackolas on September 27, 2009, 06:06:17 pm
looks like it a general way of adding it to games/systems than.
Title: Re: [XP] Achievements Script
Post by: JEHINC. on October 01, 2009, 11:16:04 am
Yo, game_guy, done wit dis script yet? 8)
Title: Re: [XP] Achievements Script
Post by: G_G on October 01, 2009, 06:27:24 pm
Just about I'm working on it tonight I've been really busy with school work though so you gotta give me some time I'm sorry.
Title: Re: [XP] Achievements Script
Post by: JEHINC. on October 01, 2009, 06:56:44 pm
Alrighty then! :beer: Also when you post it and when I use in me project, I'll be sure to give Credit for yer hard work in the Credit Part at the end of my project! :clap:
Title: Re: [XP] Achievements Script
Post by: JEHINC. on October 07, 2009, 11:53:19 am
Done?
Title: Re: [XP] Achievements Script
Post by: G_G on October 07, 2009, 02:00:52 pm
look dude I'll be done when I'm done okay? I've been sick for awhile now and I'm trying to get it done.
Title: Re: [XP] Achievements Script
Post by: Magus on October 07, 2009, 06:58:15 pm
it wouldn't work for me, so i gave in  :???:
Title: Re: [XP] Achievements Script
Post by: PitBull on March 26, 2010, 05:03:03 pm
Can someone can add name on the same line so as ICON? and picture at the black sqare?

PS: What should i delete to remove pop up?
Title: Re: [XP] Achievements Script
Post by: G_G on March 26, 2010, 05:13:55 pm
set Print to false
Title: Re: [XP] Achievements Script
Post by: Naridar on July 20, 2010, 12:51:00 pm
I've got a problem.

Adds and displays achievements just fine. However, when I save and reload my game and try to access the achievement screen, it gives the following error:

Line 156 NoMethod error
undefined method "item_number" for Nil:NilClass

Any suggestions?
Title: Re: [XP] Achievements Script
Post by: G_G on July 20, 2010, 04:33:50 pm
God I knew this would come and bite me in the ass.

okay, this was made when I was an amatuer scripter. I can remake it and I promised I would. I wont get to it for awhile though. THe errors from save issues
Title: Re: [XP] Achievements Script
Post by: wauwie1 on October 17, 2010, 06:49:55 am
Hi. Im pretty noob. But i have a question. How can i add a reward?

Title: Re: [XP] Achievements Script
Post by: G_G on May 20, 2011, 05:00:19 pm
Finally decided to remake this. Yes, everyones been waiting. I've decided to implement some features and whatnot. If you have any lemme know.

Planned:
-Achievement Categories
-Use Background Image for Pop Up Achievements
-Change Color of Text
-Change Font of Text
-New Layout
-Better Compatibility
-Must Setup all Achievements in Script, No More Items
-In-Game Sorting Options
Title: Re: [XP] Achievements Script
Post by: G_G on May 22, 2011, 02:38:19 pm
Double posts and bumps because I can.

Updated to 2.0. Much sexier version. New demo, new features, new screenshots. Redid this script from scratch. I hope you guys check this out and enjoy it.
Title: Re: [XP] Achievements Script
Post by: ForeverZer0 on May 22, 2011, 03:42:50 pm
Mmmmm... Sexy.....
Title: Re: [XP] Achievements Script
Post by: Darkner on June 05, 2011, 06:17:17 pm
I get a NoMethodError saying: undefined method 'queue' for nil:NilClass. It refers to this line: "    if $game_system.queue.size > 0 && @frame < 1", although I'm guessing that this is not the problem.

What is wrong here? Is this something to do with my game? Savegame? I hate that error...  :<_<:
Title: Re: [XP] Achievements Script
Post by: G_G on June 06, 2011, 12:42:45 am
Will not work with old game saves.
Title: Re: [XP] Achievements Script
Post by: Darkner on June 06, 2011, 02:35:08 am
The problem is, there is no savegames. And the error pops already before showing the start-menu... What gives?
Title: Re: [XP] Achievements Script
Post by: G_G on June 06, 2011, 02:48:14 am
Should be fixed. Forgot to make a couple of things check to see if $game_system was created or not.
Title: Re: [XP] Achievements Script
Post by: Darkner on June 06, 2011, 04:43:17 am
And how do i check that? Sorry, I've been away from RMXP sooo long...  :)

I guess it's interferring with other scripts, but I've kept them at a minimum, and only have the Zer0 CMS and Blizz CCTS...
Title: Re: [XP] Achievements Script
Post by: Darkner on June 06, 2011, 05:00:19 am
Whoops, sorry! It works now... Didn't see you updated it... Thanks alot!
Title: Re: [XP] Achievements Script
Post by: G_G on June 19, 2011, 01:33:59 am
:facepalm: Forgot to add some instructions. Minor update is all.
Title: Re: [XP] Achievements Script
Post by: SilverShadow737 on June 24, 2011, 06:40:11 pm
Is there a way to some achievements carry over despite a gameover without saving.
For example say, there's an achievement called "Gameover" which unlocks when you get a gameover, is there a way to save the achievement so you still have it the next time you load up your save data?
Title: Re: [XP] Achievements Script
Post by: GridBoy32 on June 30, 2011, 07:36:31 pm
 :facepalm: I feel like an idiot.  I am new here, and for some reason I can't figure out how to get it to add an achievement.  Help please.  And once again,  :facepalm:
Title: Re: [XP] Achievements Script
Post by: G_G on June 30, 2011, 08:26:59 pm
# 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 achievements scene call $scene = Scene_Achievements.new


# -To gain an achievement, use Awards.gain(award_id)
Title: Re: [XP] Achievements Script
Post by: Melvin on July 04, 2011, 07:13:24 pm
Wow!
Nice script!

I have a one questions:
How to customize the icons size to 80x80? :P
Title: Re: [XP] Achievements Script
Post by: JellalFerd on July 04, 2011, 07:41:14 pm
Quote from: Melvin on July 04, 2011, 07:13:24 pm
Wow!
Nice script!

I have a one questions:
How to customize the icons size to 80x80? :P

Whenever you see the line
Rect.new(0, 0, 24, 24)

Change it to
Rect.new(0, 0, 80, 80)

But I see that causing a lot of problems.
Title: Re: [XP] Achievements Script
Post by: G_G on July 04, 2011, 08:16:33 pm
That won't even do it either. You have to edit several lines to get icons bigger then 24x24 to work. I plan on updating this script to allow users to have any size icon.
Title: Re: [XP] Achievements Script
Post by: JellalFerd on July 04, 2011, 09:26:57 pm
You sure?
Aside from the cursor's interference, it does show the full icon.
(http://img163.imageshack.us/img163/6197/examplem.png)
Title: Re: [XP] Achievements Script
Post by: G_G on July 04, 2011, 11:36:03 pm
Not always. First the bitmap's height is generated from the number of rows there are. By default its rows * 32. You have to modify that 32. Then you have to modify the cursor. Then you have to modify x and y positions. Its not too much work but just changing that line won't be enough. Try adding several achievements and you'll see the problems.
Title: Re: [XP] Achievements Script
Post by: Melvin on July 05, 2011, 04:37:51 am
So would have to modify the whole script for to the 80x80 icon?

24x24 it looks good. But I made an icon 80x80 :P
Title: Re: [XP] Achievements Script
Post by: G_G on July 05, 2011, 10:10:21 am
Updated to version 2.2! You can use custom icon sizes now.
Title: Re: [XP] Achievements Script
Post by: G_G on July 08, 2011, 03:14:02 am
Updated. Had to change some variable names.
Title: Re: [XP] Achievements Script
Post by: Rolandojis on July 08, 2011, 08:27:00 pm
When I open the game to test it it keeps telling me:
Script 'Archivements_game_guy' line 570: SyntaxError occurred.

please help me i really want to use this script
Title: Re: [XP] Achievements Script
Post by: G_G on July 08, 2011, 08:50:37 pm
Should be fixed now.
Title: Re: [XP] Achievements Script
Post by: Rolandojis on July 09, 2011, 12:11:06 am
sorry im new using scripts but i dont gt how to activate the quick check button cause in the script is A and nothing will happen
Title: Re: [XP] Achievements Script
Post by: G_G on July 09, 2011, 12:17:28 am
In RPG Maker A is actually Shift. It also might be the Z key but I know for sure its at least Shift.
Title: Re: [XP] Achievements Script
Post by: Rolandojis on July 09, 2011, 02:48:54 pm
Quote from: game_guy on August 05, 2009, 09:37:39 am
To do what Srk said, here's the event.
Spoiler: ShowHide
(http://img44.imageshack.us/img44/5654/simpletrick.png) (http://img44.imageshack.us/i/simpletrick.png/)




I dont seem to be able to see the pic, could you post it again pleeeeaaseeee (^_^)
Title: Re: [XP] Achievements Script
Post by: G_G on July 09, 2011, 05:57:31 pm
I can't get it. The picture was from an older site that no longer exists. Besides, the picture was for an older version.
Title: Re: [XP] Achievements Script
Post by: Rolandojis on July 09, 2011, 11:58:56 pm
could you tell me how to put a score store?
Title: Re: [XP] Achievements Script
Post by: G_G on July 10, 2011, 12:26:23 am
Spoiler: ShowHide
(http://decisive-media.net/gameguy/score.png)
Title: Re: [XP] Achievements Script
Post by: G_G on July 11, 2011, 02:34:02 pm
Fixed small bug.
Title: Re: [XP] Achievements Script
Post by: Taiine on July 15, 2011, 04:59:54 pm
Question! Can this give rewards for completing achivments? Like if you get all of them you unlock something rather a nice item or extra cash. Or if you complete a difficult one you get a reward for it?
Title: Re: [XP] Achievements Script
Post by: G_G on July 15, 2011, 06:14:20 pm
These script calls in the instructions.
# -To see if a user has an award use Awards.has?(award_id)
# -To see how many the player has use Awards.count


Basically use them in conditional branches and if it meets give the player an item. Or give the player an item the second he gains the achievement.
Title: Re: [XP] Achievements Script
Post by: Taiine on July 16, 2011, 01:30:37 pm
Small bug I think.
When setting
Quick_Access  = Input::nil
it comes back with this
(http://images.devs-on.net/Image/p2hsuOqijHWvbRz-Region.png)
Title: Re: [XP] Achievements Script
Post by: Twb6543 on July 16, 2011, 01:47:17 pm
I believe you should set it to:
Quick_Access = nil

As Inputs mainly refer to keys, nil input is not defined in the module (Module Input has keys like A and B, etc).
Title: Re: [XP] Achievements Script
Post by: G_G on July 16, 2011, 03:39:12 pm
Sorry if the instructions weren't clear enough. Yea you're supposed to just set it to 'nil' and it'll remove the quick access.
Title: Re: [XP] Achievements Script
Post by: Taiine on July 16, 2011, 03:50:58 pm
Yeah I realized my error AFTER I posted about it. XD
I am still very much a novice when it comes to scrips. I just barley was able to make my own one man CMS for my game, and even that I needed a -lot- of help with. (But it works, and is BABS compatible!)

Anyway thanks. This script offers more of a reason to do some of the optional side quests in my game by unlocking all achivs and getting a very useful award to get a very useful item and unlock a hidden ending. :3

Just going though what I have and adding them XD
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 11:15:03 am
is this compatible with RMX-OS? and BABS?
Title: Re: [XP] Achievements Script
Post by: G_G on August 18, 2011, 01:38:40 pm
Its compatible with Blizz-ABS. But I'll need to make a small add-on for RMX-OS.
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 02:59:41 pm
Quote from: game_guy on August 18, 2011, 01:38:40 pm
Its compatible with Blizz-ABS. But I'll need to make a small add-on for RMX-OS.


Do you haver any plans in the future to make that? it would be a awesome funtion to have with RMX-OS
Title: Re: [XP] Achievements Script
Post by: G_G on August 18, 2011, 03:14:32 pm
I could do it today. Its a very small add-on. In fact I'll go do it right now.

EDIT:
This should work. I can't properly test it so if you could that would be great. First place the achievements script under RMX-OS Options. Then place this add-on below the achievements script.
module RMXOS

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

end


To test, Give the player an achievement, view the achievement in the achievements scene. Logout, log back in, open the achievements menu and see if you still have it.
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 03:56:16 pm
Quote from: game_guy on August 18, 2011, 03:14:32 pm
I could do it today. Its a very small add-on. In fact I'll go do it right now.

EDIT:
This should work. I can't properly test it so if you could that would be great. First place the achievements script under RMX-OS Options. Then place this add-on below the achievements script.
module RXOS

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

end


To test, Give the player an achievement, view the achievement in the achievements scene. Logout, log back in, open the achievements menu and see if you still have it.



i did like you said, but it gave a error. please see this picture http://i54.tinypic.com/rs4n0n.jpg
Title: Re: [XP] Achievements Script
Post by: Blizzard on August 18, 2011, 03:57:44 pm
Should be "module RMXOS" on top there.
Title: Re: [XP] Achievements Script
Post by: G_G on August 18, 2011, 04:00:37 pm
Woops. Thanks Blizzard. Try it again if you could please. :3 If all goes well I'll add it to the main post.
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 04:06:00 pm
okay now i can open the game and join the server... but when i try to open the  Achievements menu then this happens http://i53.tinypic.com/dfvyh4.jpg i use this event to open it http://i56.tinypic.com/kao845.jpg and when i gain a reward then this shows up http://i55.tinypic.com/j5jkvl.jpg if you need it then i can give you a client that works for my server so you can test it...
Title: Re: [XP] Achievements Script
Post by: G_G on August 18, 2011, 04:14:07 pm
Yeah sure PM me the client and I'll work on it. :3 Also if its not too much trouble could you reset your database?
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 04:25:29 pm
pm send,  is it the mysql you want reseted? becorse i can do that :)
Title: Re: [XP] Achievements Script
Post by: G_G on August 18, 2011, 04:32:52 pm
I keep getting disconnected everytime I try to register. And yeah the MySql database.
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 04:36:17 pm
thats becorse i just fooled around with mysql. i think it will work now :)


Edit: i am online on it now
Title: Re: [XP] Achievements Script
Post by: G_G on August 18, 2011, 05:11:31 pm
Updated script to 2.23. Added a small compatibility check for RMX-OS that prevents people from opening the Quick Scene while the chat textbox is active. I had problems trying to type because I couldn't press shift. Also added the RMX-OS save patch.
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 07:12:51 pm
awesome. have a quick question, is the Achievements stored local or over mysql? if not mysql, would it be hard to  do so it run over mysql? i quess that would be a edit in both rmx-os script and Achievements script?
Title: Re: [XP] Achievements Script
Post by: G_G on August 18, 2011, 08:49:59 pm
RMX-OS is setup already so all data saved is stored over MySql. Thats what the patch was needed for.
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 09:07:21 pm
okay, i see you have made a quest system (http://forum.chaos-project.com/index.php/topic,3689.0.html) that works with RMX-OS dose that save on mysql too?
Title: Re: [XP] Achievements Script
Post by: Wizered67 on August 18, 2011, 09:15:59 pm
I'm pretty sure he just answered that question. RMX-OS is already set up to save the data on MySQL so as long as there is an RMX-OS plugin for a script it will most definitely save it on MySQL. Just look to see if the script has a plugin.
Title: Re: [XP] Achievements Script
Post by: GamerGeeks on August 18, 2011, 09:36:16 pm
sorry its just me who is stupid. ofcorse it will save on mysql
Title: Re: [XP] Achievements Script
Post by: bigace on November 14, 2011, 03:48:22 pm
Hey game_guy, I wanted to know if you could add a shop to the script that allows the player could spend the points on stuff not found normally in the game.
Title: Re: [XP] Achievements Script
Post by: G_G on November 20, 2011, 08:47:26 am
Its not needed. The points is kept in a variable. So what you do is this.

Store gold in Gold Variable 0001.
Remove Gold: 99999999
Add Gold: Variable 0002: Award Points
Open Shop
Store gold in Awards Points Variable 0002
Remove Gold: 9999999
Add Gold: Variable 0001: Gold


Damn I'm good. <3
Title: Re: [XP] Achievements Script
Post by: bigace on November 20, 2011, 02:47:49 pm
Okay cool straight :^_^': Thank you for the snippet.
Title: Re: [XP] Achievements Script
Post by: theneonheart on March 05, 2012, 10:51:21 am
Hey, I just put this in my game, and before I input any awards or anything, when I playtest the game I get this error:

Script 'Achievements' line 253: NoMethodError occurred.
undefined method 'queue' for nil:NilClass

Do I have to input something before it will even work? Because I was planning on taking a good long time to figure out how to script properly while I keep adding stuff to my game...

line 253 is:
    if $game_system.queue.size > 0 && @frame < 1

I really like how this script looks in the demo and would love to use it in my game if you can help. Thanks.
Title: Re: [XP] Achievements Script
Post by: G_G on March 05, 2012, 06:47:24 pm
The only reason I can think of you getting that error is either
A) You loaded an old game save.
B) You copied the script from the demo. Which is bugged.
Title: Re: [XP] Achievements Script
Post by: Helskyth on March 15, 2012, 05:37:07 pm
Hello. I've been using the Achievements script and am loving what it has to offer.

However, I've encountered one little problem that I just can't wrap my head around, and the strange thing is, it only occurs after I undertake one of the events I've set up to progress the game; which doesn't even have anything in it that relates to the Achievement Script.  :^_^':

Anyway, here's the pesky little error.
-----
NameError occurred while running script.

uninitialised constant Interpreter::Award
-----

Please and thank you for helping the newb peasant?  :P

(and unrelated, but also thanks for your Quest Log script, it's worked wonders!)
Title: Re: [XP] Achievements Script
Post by: G_G on March 15, 2012, 07:21:08 pm
The error is coming from one of your events. I can tell because of the "NameError occurred while running a script." So somewhere in your events, in a script call, you have "Award::" instead of "Awards::"
Title: Re: [XP] Achievements Script
Post by: Helskyth on March 15, 2012, 08:52:14 pm
That's what I was hoping it'd be when it originally popped up. Only problem is, it occurs even after I remove those events that did have a script call, and I can assure you that all of those ones were composed correctly to begin with. I wouldn't have reported the problem if it were so easy. ;)
What's puzzling me the most, is it occurs during an event that doesn't actually have a script call in it at all. It's just a  "talk to this NPC, they say some things, give you a couple of items" and then some switches turn on so you can move on to the next area.
For the moment, I'm re-making the event from scratch, changing its graphics, removing parts of it, etc, to see if I I can deduce why it's causing it. But so far, it's only this event that's causing it, so if I can't prevent the error from occurring then I'll just need to figure something else out.


-edit-
( :facepalm:^200 )
It's time for a holiday. A script call involving the awards made its way into a common event some-where else. Not sure how I heck I managed to put that in there, but I found it.  :facepalm:
Title: Re: [XP] Achievements Script
Post by: Moranon on September 20, 2012, 02:16:28 pm
Hey.

I'd like to use this awesome script but i seem to have a little problem here.

The Achievement Icons won't be shown completely at some point. In the last row they are gone completely although they're still selectable.
Maybe someone can help me with this.

That's what it looks like right now
http://www.freeimagehosting.net/6z1gv (http://www.freeimagehosting.net/6z1gv)

Thanks in Advance
Title: Re: [XP] Achievements Script
Post by: G_G on September 21, 2012, 07:51:11 am
I'll look at it after school. I believe this has something to do with allowing custom icon size. Can't say for sure. I can't even remember if I allowed custom icon size.
Title: Re: [XP] Achievements Script
Post by: Moranon on September 22, 2012, 02:05:58 pm
This is the only part i slightly changed
Spoiler: ShowHide
#===============================================================================
# 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 - 4, 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] < 28 ? 28 : Awards::Icon_Size[1]
   x = @index % @column_max * (cursor_width + 32)
   y = @index / @column_max * (Awards::Icon_Size[1] + 12) - self.oy
   self.cursor_rect.set(x, y, cursor_width, cursor_height + 4)
 end
end

i only changed some of the sizes and coordinates because the cursor wasn't directly behind the achievement icons.
maybe i f*cked something up here. i cant really tell.

maybe it helps you to find the error
Title: Re: [XP] Achievements Script
Post by: KK20 on September 22, 2012, 02:30:41 pm
I believe this line is the problem:
self.contents = Bitmap.new(width - 32, row_max * Awards::Icon_Size[1])
I noticed that in your picture, the sprites on the 3rd line are slightly cut off, so instantly I knew it had to be a bitmap size problem. You want to change that Awards::Icon_Size to something else. Originally it was height, so I don't know what you were trying to accomplish in changing that.
Title: Re: [XP] Achievements Script
Post by: Moranon on September 22, 2012, 02:39:54 pm
i cant remember changing that. but when i change width to height it looks like this
http://www.freeimagehosting.net/dhe3h (http://www.freeimagehosting.net/dhe3h)
Title: Re: [XP] Achievements Script
Post by: KK20 on September 22, 2012, 02:44:43 pm
"Changed width to height"? Why in the world would you want to do that? Unless you worded that wrong and you did this:
self.contents = Bitmap.new(width - 32, row_max * height)
Title: Re: [XP] Achievements Script
Post by: Moranon on September 22, 2012, 02:47:21 pm
i changed this
self.contents = Bitmap.new(width - 32, row_max * Awards::Icon_Size[1])


to
self.contents = Bitmap.new(height - 32, row_max * Awards::Icon_Size[1])


i'm kind of an idiot that way. unless someone tells me exactly what to change i'm screwed xD

edit:
with your
self.contents = Bitmap.new(width - 32, row_max * height)

it works just fine. thank you very much ^^
Title: Re: [XP] Achievements Script
Post by: exile360 on January 10, 2013, 10:28:26 am
Hi!

First of all, sorry if this is considered a necro-post or something, since it's been a while from the last reply. I'm not even sure I'll get a reply here but doesn't hurt to try, I guess. :)
Thank you for this awesome script! I've just recently returned to RMXP after a few years, and found RMX-OS which is slowly making all I ever wanted come true, haha. So many awesome additional scripts here as well, like this one. Sorry for my noobishness though, don't have the hang of everything yet as I've just returned.

Basically, I just have a few questions and suggestions/requests.
1) I have a problem with placing the achievement pop-up on my screen. I wanted to place it on the upper middle side of the screen and worked out some math. Everything should be in place, but the picture is the only thing that appears. No text or icon. Both worked fine in the default placing. I added a screenshot in the spoiler. How do I fix this?
Spoiler: ShowHide
(http://www.upload.ee/image/2973987/achievement_problem.PNG)

2) How to create and trigger achievements that require a certain amount of gold or damage dealt, like in your examples? I'm probably stupid and missing something, but meh lol. I'd play the demo (outdated or not) and find out myself, but it's down.

And the suggestions/requests:
1) Would it be possible to make the achievement gain picture fade in and out smoothly instead of appearing and disappearing instantly? It looks a bit unprofessional.
2) Would it be possible to create tabs to sort the achievements, such as Story related, Combat related, Secrets and whatnot. The little window to select tabs could be either between the 2 main windows, or on the left side. I made a screenshot and marked the areas to show what I mean, below in the spoiler. You could then just specify which tab they go to with another number in the configuration part of the script.
Spoiler: ShowHide
(http://www.upload.ee/image/2973729/achievements.PNG)


I know at this point it's very unlikely you'll even want to work on the script again, specially for one request, but I would be very thankful as it'd be perfect for my game. ^_^

Cheers! :)
Title: Re: [XP] Achievements Script
Post by: G_G on January 10, 2013, 03:00:20 pm
Hey, glad you like the script! For your first question, it's probably a glitch on my part. I'll look into it within the next couple of days. As for your 2nd question, I have a script add-on I posted beneath the actual script that deals with Damage Dealt Achievements. And for the gold, just have a common event run in the background checking for gold.

As for your requests, it's possible to do this, but it'd require editing the script and I've retired from RMXP for the most part. I don't really have the time or will to add those suggestions in, but they are great suggestions. You might be lucky if you posted in the Script Requests asking for those features.
Title: Re: [XP] Achievements Script
Post by: exile360 on January 10, 2013, 05:25:58 pm
I see, thank you very much for the reply. :) I completely forgot you can check for gold with a conditional branch. I kept looking for a way to store it in a variable or something, and then check for that.
I'll be looking forward to your post about the Achievement placing issue. I'm really sorry to bother you with this by the way, as you've retired. :( I know I'm kinda late to the party here, lol.
I will try the request forum for the suggestions. :)
Title: Re: [XP] Achievements Script
Post by: ThallionDarkshine on January 11, 2013, 10:43:46 am
Alright, ill work on this. Can you post your configuration b/c i don't see any problems in the script itself. And for the first request, ill do that very soon: i actually already have written most of the code for that in another script. There will be several different entry and exit methods for the sprite.
Title: Re: [XP] Achievements Script
Post by: exile360 on January 11, 2013, 07:48:31 pm
Hey. After reading your post I was going to post my configuration, but then I had an idea and tested it out. It appears that it was my mistake after all, I apologize. :facepalm:
I had assumed that the icon and text coordinates also correspond to the screen, but they actually count from the placement of the award picture. All I had to do was reduce the coordinates and align them with the image again, and voila, all fixed and working fine now, thanks! Looking forward to the suggestion edit though. :)
Title: Re: [XP] Achievements Script
Post by: ThallionDarkshine on January 11, 2013, 09:10:14 pm
Alright, i was guessing that that was what you had done. I finished the first part of the my edit, right now you can set up an array of possible animations for the notification appearing. I also found a number of bugs that would only appear if show_all is false. All i have to do now is add in disappear animations and properly document the config. Ill try to finish it tomorrow.
Title: Re: [XP] Achievements Script
Post by: G_G on January 11, 2013, 09:54:21 pm
Thanks for the help Thallion. :) And glad things worked out exile! Once you're done with your version Thallion, I'd be more than happy to add you to the credits and add it to the first post.
Title: Re: [XP] Achievements Script
Post by: ThallionDarkshine on January 12, 2013, 08:11:00 pm
Alright, done. Here is the modified script:
Script (http://pastebin.com/raw.php?i=5SCe4QXg)
And you will need this (http://pastebin.com/raw.php?i=P6YDaVzU) script and this (https://www.box.com/s/ykkt0r1bsfz84p6khvq5) dll for the script to work. The disappearance animations are not fully documented yet, but I'll get to that soon.

Edit - Added a little more functionality, as well as fixed a few errors in my Transitions module. Also properly documented the disappearance animations.

Edit2 - Fixed the Damage Achievement Mod, and also added a new mod for gold spent. Also added another mod for items in inventory. Here they are:
Spoiler: ShowHide

#===============================================================================
# X Damage Achievement Mod
# Author game_guy
#-------------------------------------------------------------------------------
# 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


#===============================================================================
# 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


#===============================================================================
# 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

Title: Re: [XP] Achievements Script
Post by: G_G on January 13, 2013, 10:31:43 am
Updated first post, added Thallion's three snippets and script. I just added your own section Thallion in case people don't want an extra dependency. :3
Title: Re: [XP] Achievements Script
Post by: ThallionDarkshine on January 13, 2013, 12:00:58 pm
Yeah, that makes sense. I wouldn't really want to have some random script in my project that just takes up space. And I'll be working on more snippets for this, because I really like how this script works.

Edit - Here's a demo that I made for the script:
Demo (https://www.box.com/s/q5pn9ctai34wgdwy6wtm)
Title: Re: [XP] Achievements Script
Post by: G_G on January 14, 2013, 07:38:58 am
Thanks Thallion! Added the demo to the first post.
Title: Re: [XP] Achievements Script
Post by: exile360 on January 16, 2013, 04:59:14 pm
Thanks, Thallion!
Strange though, I'm getting an error with the demo "This project is from an old version of RPG Maker and cannot be loaded". Never had this before. I'll try using the script itself in my project soon, after I get some other issues sorted out.
Title: Re: [XP] Achievements Script
Post by: G_G on January 16, 2013, 11:10:11 pm
All you have to do is replace the Game.rxproj file.
Title: Re: [XP] Achievements Script
Post by: exile360 on January 18, 2013, 12:18:03 pm
Worked, thanks. However, I keep getting this error randomly throughout the demo:
Spoiler: ShowHide
(http://www.upload.ee/image/2995943/ach.png)

At first it popped up as soon as I launched it, but I downloaded the .dll again and replaced it with the one in the folder and now I can sometimes play for like 10-30 seconds before it errors. Still, not very practical, lol.
Title: Re: [XP] Achievements Script
Post by: ThallionDarkshine on January 18, 2013, 07:57:19 pm
I tried to fix it, and edited the script that I linked to. Replace the Transitions Module from the demo with the new version.