Help - Search - Members - Calendar
Full Version: Omegas7's Achievements
RPG RPG Revolution Forums > Scripting > Script Tutorials > RGSS2
Omegas7
Game Achievements
Author: Omegas7
Version: 1.1

Achievements. Why not? Your players might extend their gameplay time just to get these interesting challenges.
Well, today I bring you an Achievements script! A bit inspired in XBox live. Script & instructions in the demo.

Downloads:
Version 1.1:
http://www.megaupload.com/?d=KA6VEQBG

Version 1.0 is too old and too different. Not included. Enjoy!

Screenshots




zolaga
This looks mighty kickass I will probably download it later. Good work.
Omegas7
Thanks, hope you find it useful ~
Dyrnwyn
First of all, looks great, yet again, Omegas7! I played around with the demo and really like it.

However, I'm using a lot of Yanfly's Battle Engine Melody. When I try to set off an achievement in my game using that system, I get the following error:

Script "OmegaX Achievements" Line 485: NoMethodError occurred
undefined method 'size' for nil:NilClass

What do you think? Incompatible scripts or did i botch something?

Quick note: This is happening when it tries to execute the screen pop when the achievement is triggered.
Omegas7
Usually it is something wrongly done in the configuration section of the script (where you create the achievements). Post a copy of it.
Dyrnwyn
Sure thing. Here's the config section:

CODE
module AchievementsDATA
  MenuBackground = "AchievementBG"     # [Pictures] folder
  LockedTrohyGraphic = "LockedTrophy"  # [Pictures] folder 90x90
  TrophyCursorGraphic = "TrophyCursor" # [Pictures] folder 90x90
  DescriptionScreenGraphic = "DescriptionScreen" # [Pictures] folder
  AchievementBarGraphic = "AchievementBar"  # [Pictures] folder
  
  AchievementIsCompleteGraphic = "AchievementCompleted" # [Pictures] folder
  AchievementIsIncompleteGraphic = "AchievementIncomplete" # [Pictures] folder
  # That last two graphics will appear at the bottom right of the screen
  # when used *
  
  Achievements = []
  Descriptions = []
  
  Achievements[0] = ["Defeat the Ice Queen","Trophy",161]
  Descriptions[0] = ["Stop the Ice Hellion in Flore."]
  
  Achievements[1] = ["The Ranger","Trophy",162]
  Descriptions[1] = ["Have a Ranger join your party."]
  
  Achievements[2] = ["The Barmaid","Trophy",162]
  Descriptions[2] = ["Have a Barmaid join your party."]
end


I honestly haven't done much, yet.
SamuriFerret
Link is broken for me.
Kread-EX
Try again. The link works without problem.
DeadlySmash
Dude your awesome biggrin.gif I got all of your scripts to make my game(I will put you in the credits )
krains123
It Doesn't show up in the menu for me... Could it be because it doesn't work with the other scripts? I have bestiary, level up, ect. so could it be taking up the spot for the achievements.
BornAsunderVX
This will go great with the game we are creating.

You will be credited, of course. Thank you for your scripts.
Dyrnwyn
QUOTE (krains123 @ Nov 1 2010, 09:24 PM) *
It Doesn't show up in the menu for me... Could it be because it doesn't work with the other scripts? I have bestiary, level up, ect. so could it be taking up the spot for the achievements.


I don't think it is supposed to be in a menu. There is a script call that comes with it to load it, as well. Probably should use it.
krains123
Huh... Could Someone Make A Mod For It So It Does?
spitice
QUOTE (krains123 @ Nov 3 2010, 07:54 PM) *
Huh... Could Someone Make A Mod For It So It Does?


There is a script that allows you to add common events into the menu screen. You can use it to put the omega7's script in the menu along with anything else you'd like to add using common events. here
spitice
Oh and I keep getting this error "Script 'OmegaX Achievements' line 415: NoMethodError occurred. undefined method ` size ' for nil:NilClass"
So um what do i do about it. lol
new
how do you call it as a scene
using this : $scene = AchievementTrophyMenuManager.new is fail

so you use : $scene = Achievements.new lol
InfinateX
This is awesome...Aren't u also on RPGMakerVX.net?
JLCollier2005
I really think this is the best achievement system out there, but is there any way to give a reward and/or receive achievement points (built in) for completing them? Also, what about the ability to have an achievement only gained if multiple switches are activated? So say the achievement is that you have to beat 3 optional bosses in any order, is there a way to do that?

Thanks, other than those two things I really like this!
Omegas7
^ You're the one who has to manage all that, the conditions and rewards of achievements. My script is merely graphical.
Hoopsnake Games
Well, this has to be one of the best-looking achievement scripts I've used. smile.gif You are to be commended, sir!

Quick question:
I want to run a script-call event after closing the menu, but it runs immediately after the menu opens. I was wondering if there was any way to do this?
Omegas7
Exactly what script do you want to run after closing what menu (achievements or party menu)?
Hoopsnake Games
I am using Raoul_589's Lighting Script. (Link to RPG Maker VX.net)

Basically, before I open the Achievement screen from the menu (using the common event option from Yanfly's Main Menu Melody), I use the script call $lights.on, which reverts the screen back to normal, so I can see the Achievement Menu without the dark circle in the middle. I then call the Achievement screen, but when I place the script call
CODE
$lights.setlightlevel(0)
$lights.off
$lights.addplayersource
$lights.setlightlevel(80)

It is immediately called, placing a transparent circle in the middle while the rest of it is black. I am assuming that this is because it is a mainly picture-showing script, and not actually a menu. Now, I think there are two ways of going about this:
1) Make it so when the viewer is on "NONE" and presses "B", or presses "C" on "EXIT", if a particular switch is on, then it will initiate the script call. If not, then it would continue on to the map without calling any script.
2) I notice that the information menu of an achievemnet actually covers the lighting picture, and would I be right in assuming that this is because the "priority" of that menu is higher than the lighting picture? Because if so, is there any way to bring up the priority of the initial menu so it covers the lighting screen?

ShinGamix
QUOTE (Omegas7 @ Oct 18 2010, 09:44 PM) *
Game Achievements
Author: Omegas7
Version: 1.1

Achievements. Why not? Your players might extend their gameplay time just to get these interesting challenges.
Well, today I bring you an Achievements script! A bit inspired in XBox live. Script & instructions in the demo.

Downloads:
Version 1.1:
http://www.megaupload.com/?d=KA6VEQBG

Version 1.0 is too old and too different. Not included. Enjoy!

Screenshots







OMG I love This!
kayden997
Is it possible to change the trophy picture for different achievements? (inspired by xbox live)
jomarcenter
i will find a way to add achievement to the menu just give me a few hours or later...

Don't necropost. ~Kread
jasonb205
I have a question can you make a way to hide some achievement? Like for a locked one that I don't want them to know how to unlock
Pizzajazz
EDIT: Sorry, I did it, I just forgot the comma! =D
______________________________________________________________
I've got a little problem!
Didn't I understand something?
if I add an achievement, the bar doesn't appear.

This is the part in my script-base:
CODE
  Achievements = []
  Descriptions = []
  
  Achievements[0] = ["Ein verfressenes Vieh!","Trophy0_JuMade",481]
  Descriptions[0] = ["Besiege die Waldmampfe!"]
  
  Achievements[1] = ["Der große Zinh","Trophy1_JuMade",482]
  Descriptions[1] = ["Finde den versteckten Ort auf Hunyr!"]
  
  Achievements[2] = ["Der erste große Kampf","Trophy2_JuMade",483]
  Descriptions[2] = ["Besiege den Fliegenfänger."]
  
  Achievements[3] = ["Ein Kristall für alle Fälle","TrophyThree_JuMade",484]
  Descriptions[3] = ["Schaue dir das Erfolgs-Tutorial an."]
end


The first three are accepted and the Bar appears - like in your Demoversion.
But if I add an achievement, the Bar does NOT appear.
In the achievementmenu, there is the completed achievement. Yeah, I got it!
But where was the achievementbar?
WHERE?!

I don't understand, if i made something wrong.
Please help me!
laiducvu123
Help!
I has the error of line 434
Kread-EX
Mind being clearer? Which error? What does it say? Screenshot? Other scripts you are using?
laiducvu123
I Using RMVX platformer , LV Up Recovery and Save plus script
Here is the error:

When i Control Switched the SwitchID of the achievement,that error appear
say.id
excuse me,, is it possible to make this achievement journal in title??
Night_Runner
Yes, yes it is

code
CODE
# =============================================================================
# Game Achievements
# Version: 1.1
# Author: Omegas7 & tweaked by: Night_Runner
# Site: http://omegas7.blogspot.com    ||      http://omegadev.biz
#  & http://www.rpgrevolution.com/forums/index.php?showtopic=45809
# -----------------------------------------------------------------------------
# Features:
#      > 1.1
#          > Achievements linked to game switches
#          > Achievement Bar appears when achievement switch activated
#          > Menu showing achievements separated by All, Unlocked and Locked.
#          > Achievements descriptions
#          > Achievements descriptions can have a background image
#          > Each achievement is represented by a 90x90 image
#          > Menu background image
#          > Locked achievement image (90x90)
#          > Achievements menu cursor is an image (90x90)
#          > Achievement bar image
#          > Achievement complete & incomplete graphic for description screen
# -----------------------------------------------------------------------------
# Instructions
#    First, this will be the basic template for your achievement:
#
#    Achievements[ID] = ["Name","GaphicName",SwitchID]
#    Descriptions[ID] = ["Line1","Line2","Line3"]
#
#    ID = ID of achievement for the script to use. Each achievement has one
#    unique ID number. Starting from 0.
#    "Name" => Name displayed for the achievement. Inside quotes " "
#    "GraphicnName" => 90x90 graphic name located in [Pictures] folder
#                            inside quotes " "
#    SwitchID => ID of game switch you want to link this achievement to.
#    You can add as many Description lines as you want.
#    Each line is inside quotes " ", and each line is separated by a comma.
# =============================================================================

module AchievementsDATA
  FileName = "Data/Achievements.rvdata"     # Save game achievements
  ShowInTitle = true                   # Show Achievements in title (true/false)
  MenuBackground = "AchievementBG"     # [Pictures] folder
  LockedTrohyGraphic = "LockedTrophy"  # [Pictures] folder 90x90
  TrophyCursorGraphic = "TrophyCursor" # [Pictures] folder 90x90
  DescriptionScreenGraphic = "DescriptionScreen" # [Pictures] folder
  AchievementBarGraphic = "AchievementBar"  # [Pictures] folder
  
  AchievementIsCompleteGraphic = "AchievementCompleted" # [Pictures] folder
  AchievementIsIncompleteGraphic = "AchievementIncomplete" # [Pictures] folder
  # That last two graphics will appear at the bottom right of the screen
  # when used *
  
  Achievements = []
  Descriptions = []
  
  Achievements[0] = ["Greedy Ralph","Trophy",1]
  Descriptions[0] = ["Open 5 chests!","Commonly known as a noob-level achievement."]
  
  Achievements[1] = ["Defeat Gary","Trophy",2]
  Descriptions[1] = ["Beat evil Gary at the garden!"]
  
  Achievements[2] = ["LOVE OMEGAS7","Trophy",3]
  Descriptions[2] = ["Show your love for Omegas7 to a stranger."]
end

if $TEST and not FileTest.exist?(AchievementsDATA::FileName)
  save_data([],AchievementsDATA::FileName)
end

class Achievements < Scene_Base
  include AchievementsDATA
  def initialize(achievement_ids = nil)
    if achievement_ids == nil
      @achievement_ids = []
      for achievement in $game_party.achievements
        if achievement[1] == true
          for achdata in AchievementsDATA::Achievements
            if achdata[2] == achievement[0]
              @achievement_ids << AchievementsDATA::Achievements.index(achdata)
            end
          end
        end
      end
    else
      @achievement_ids = achievement_ids
    end
    @return_class = $scene.class
    create_background
    create_menu
    create_trohpies
    @view = 'NONE'
    @chosen = false
    @locked = 0
    @unlocked = 0
    for i in 0...Achievements.size
      if @achievement_ids.include?(i)
        @unlocked += 1
      else
        @locked += 1
      end
    end
  end
  def update
    updateInput
    updateMenus if !@chosen
    @chosen = false
  end
  def updateMenus
    case @view
    when 'NONE'
      @menu.update
    when 'TROPHIES'
      @trophyMenu.update
    end
  end
  def updateInput
    if Input.trigger?(Input::C) && @view == 'NONE'
      case @menu.index
      when 0  # All
        @view = 'TROPHIES'
        @trophyMenu.setView('all')
        @trophyMenu.setOpacity(255)
        Sound.play_decision
        @chosen = true
        return
      when 1  # Unlocked
        if @unlocked <= 0
          Sound.play_buzzer
          return
        end
        @view = 'TROPHIES'
        @trophyMenu.setView('unlocked')
        @trophyMenu.setOpacity(255)
        Sound.play_decision
        @chosen = true
        return
      when 2  # Locked
        if @locked <= 0
          Sound.play_buzzer
          return
        end
        @view = 'TROPHIES'
        @trophyMenu.setView('locked')
        @trophyMenu.setOpacity(255)
        Sound.play_decision
        @chosen = true
        return
      when 3  # Exit
        @trophyMenu.finish
        @bg.dispose
        @menu.dispose
        $scene = @return_class.new
        @chosen = true
        return
      end
    end
    if Input.trigger?(Input::B) && @view == 'NONE'
      @trophyMenu.finish
      @bg.dispose
      @menu.dispose
      $scene = @return_class.new
      @chosen = true
      return
    end
    if Input.trigger?(Input::B) && @view == 'TROPHIES' && !@trophyMenu.description?
      @view = 'NONE'
      @trophyMenu.setOpacity(0)
      Sound.play_cancel
    end
  end
  def create_background
    @bg = Sprite_Base.new
    @bg.bitmap = Cache.picture(MenuBackground)
    @bg.z = 0
  end
  def create_menu
    commands = ['All','Unlocked','Locked','Back']
    @menu = Window_Command.new(130,commands)
    @menu.contents.font.size = 20
    @menu.refresh
    @menu.opacity = 0
    @menu.z = 9
  end
  def create_trohpies
    @trophyMenu = AchievementTrophyMenuManager.new(@achievement_ids)
    @trophyMenu.setOpacity(0)
  end
end

class AchievementTrophyMenuManager
  include AchievementsDATA
  def initialize(achievement_ids)
    @achievement_ids = achievement_ids
    @trophies = []
    draw_trophies('all')
    @moved_y = 0
    if !@trophies.empty?
      @cursor = Sprite_Base.new
      @cursor.bitmap = Cache.picture(TrophyCursorGraphic)
      @cursor.z = 2
      @cursor.x,@cursor.y = @trophies[0].sprite.x,@trophies[0].sprite.y
    end
    @cursorIndex = 0
    @toBeY = 0
    @viewingDescription = false
    @description = Sprite_Base.new
    @description.bitmap = Cache.picture(DescriptionScreenGraphic)
    @description.z = 100
    @description.opacity = 0
    @descriptionwindow = Window_Base.new(30,90,544 - 60,270)
    @descriptionwindow.opacity = 0
    @name = Window_Base.new(12,-12,300,90)
    @name.contents.font.size = 18
    @name.opacity = 0
    @block = false
  end
  def draw_trophies(view)
    @trophies = []
    @chart = []
    trueIndex = 0
    for i in 0...Achievements.size
      if @achievement_ids.include?(i)
        if view == 'all' || view == 'unlocked'
          @trophies.push(AchievementTrophy.new(trueIndex,true,Achievements[i][0]))
          @chart.push(Descriptions[i])
          trueIndex += 1
        end
      else
        if view == 'all' || view == 'locked'
          @trophies.push(AchievementTrophy.new(trueIndex,false,Achievements[i][0]))
          @chart.push(Descriptions[i])
          trueIndex += 1
        end
      end
    end
  end
  def update
    if !@viewingDescription
      if Input.trigger?(Input::DOWN)
        Sound.play_cursor
        @cursorIndex += 4
      end
      if Input.trigger?(Input::UP)
        Sound.play_cursor
        @cursorIndex -= 4
      end
      if Input.trigger?(Input::RIGHT)
        Sound.play_cursor
        @cursorIndex += 1
      end
      if Input.trigger?(Input::LEFT)
        Sound.play_cursor
        @cursorIndex -= 1
      end
      checkCursorPosition
      if Input.trigger?(Input::C)
        @descriptionwindow.contents.clear
        @name.contents.clear
        @description.opacity = 255
        for i in 0...@chart[@cursorIndex].size
          @descriptionwindow.contents.draw_text(0,(20 * i),500,20,@chart[@cursorIndex][i].to_s)
        end
        @viewingDescription = true
        @block = true
        @name.contents.draw_text(0,0,300,20,@trophies[@cursorIndex].name)
        @completed = Sprite_Base.new
        if @trophies[@cursorIndex].obtained
          @completed.bitmap = Cache.picture(AchievementIsCompleteGraphic)
        else
          @completed.bitmap = Cache.picture(AchievementIsIncompleteGraphic)
        end
        @completed.x = 544 - @completed.width
        @completed.y = 416 - @completed.height
        @completed.z = 300
        return
      end
    else
      if (Input.trigger?(Input::C) || Input.trigger?(Input::B)) && !@block
        Sound.play_cancel
        @descriptionwindow.contents.clear
        @name.contents.clear
        @description.opacity = 0
        @viewingDescription = false
        @completed.dispose
        @completed = nil
        return
      end
    end
    @block = false
    if Input.trigger?(Input::L)
      print @description.opacity
    end
  end
  def description?
    return @viewingDescription
  end
  def checkCursorPosition
    if @cursorIndex < 0
      @cursorIndex = 0
    end
    if @cursorIndex > @trophies.size - 1
      @cursorIndex = @trophies.size - 1
    end
    @toBeY = @trophies[@cursorIndex].sprite.y
    a = false
    while @toBeY >= 10 + (90 * 4)
      moveY(-90)
      a = true
    end
    if !a
      while @toBeY < 10
        moveY(90)
      end
    end
    @cursor.x = @trophies[@cursorIndex].sprite.x
    @cursor.y = @trophies[@cursorIndex].sprite.y
  end
  def moveY(y)
    for i in 0...@trophies.size
      @trophies[i].sprite.y += y
      @toBeY += y
    end
  end
  def setOpacity(n)
    for i in 0...@trophies.size
      @trophies[i].sprite.opacity = n
    end
    @cursor.opacity = n
  end
  def setView(view)
    for i in 0...@trophies.size
      @trophies[i].sprite.dispose
      @trophies[i] = nil
    end
    @cursorIndex = 0
    @trophies.compact!
    @chart = []
    draw_trophies(view)
  end
  def finish
    @cursor.dispose
    for i in 0...@trophies.size
      @trophies[i].sprite.dispose
      @trophies[i] = nil
    end
    @trophies.compact!
    @description.dispose
    @descriptionwindow.dispose
    @name.dispose
  end
end

class AchievementTrophy
  include AchievementsDATA
  attr_accessor :sprite
  attr_reader :obtained
  attr_reader :name
  def initialize(index,obtained,name)
    @sprite = Sprite_Base.new
    if obtained
      @sprite.bitmap = Cache.picture(Achievements[index][1])
    else
      @sprite.bitmap = Cache.picture(LockedTrohyGraphic)
    end
    @sprite.z = 1
    @sprite.x = 180 + (90 * (index % 4))
    @sprite.y = 10 + (90 * (index / 4))
    @obtained = obtained
    @name = name
  end
end

class Game_Party
  alias omega_achievements_initialize initialize
  attr_accessor :achievements
  def initialize
    omega_achievements_initialize
    @achievements = []
    for i in 0...AchievementsDATA::Achievements.size
      @achievements.push([AchievementsDATA::Achievements[i][2],
      $game_switches[AchievementsDATA::Achievements[i][2]]])
    end
  end
end

class AchievementBar
  include AchievementsDATA
  attr_reader :finished
  def initialize(id)
    @sprite = Sprite_Base.new
    @sprite.bitmap = Cache.picture(AchievementBarGraphic)
    @sprite.z = 300
    @sprite.x = 272 - (@sprite.width/2)
    @sprite.y = 416 - @sprite.height
    @sprite.zoom_x = 0.1
    @sprite.zoom_y = 0.1
    @timer = -1
    @leaving = false
    @finished = false
  end
  def update
    if @sprite.zoom_x < 1.0
      @sprite.zoom_x += 0.05
      @sprite.zoom_y += 0.05
      if @sprite.zoom_x >= 1.0
        @timer = 140
      end
    end
    if @timer > 0
      @timer -= 1
    else
      if !@leaving && @sprite.zoom_x >= 1.0
        @leaving = true
      end
    end
    if @leaving
      @sprite.opacity -= 3
      if (@sprite.opacity <= 0) && (!@finished)
        finish
      end
    end
  end
  def finish
    @sprite.dispose
    @finished = true
  end
end

class Scene_Map
  alias omegaAchievementInitialize  initialize  unless $@
  alias omegaAchievementUpdate      update      unless $@
  alias omegaAachievementTerminate  terminate   unless $@
  def initialize
    omegaAchievementInitialize
    @achievements = []
  end
  def update
    omegaAchievementUpdate
    for i in 0...@achievements.size
      @achievements[i].update
      if @achievements[i].finished
        @achievements[i] = nil
      end
    end
    @achievements.compact!
  end
  def terminate
    omegaAachievementTerminate
    for i in 0...@achievements.size
      @achievements[i].finish
    end
  end
  def addAchievementBar(id)
    @achievements.push(AchievementBar.new(id))
  end
end

class Game_Interpreter
  alias omegaAchievementsSwitch command_121
  def command_121
    omegaAchievementsSwitch
    if $scene.is_a?(Scene_Map)
      for i in 0...$game_party.achievements.size
        if $game_party.achievements[i][1] != $game_switches[$game_party.achievements[i][0]]
          if $game_switches[$game_party.achievements[i][0].to_i]
            $game_party.achievements[i][1] = $game_switches[$game_party.achievements[i][0]]
            $scene.addAchievementBar(i)
            $achievements << i
            $achievements.uniq!
            save_data($achievements, AchievementsDATA::FileName)
            break
          end
        end
      end
    end
  end
end

class Scene_Title
  alias nr_achievements_load_database  load_database  unless $@
  alias nr_achievements_update         update         unless $@
  def load_database(*args)
    $achievements = load_data(AchievementsDATA::FileName)
    return nr_achievements_load_database(*args)
  end
  if AchievementsDATA::ShowInTitle
    def create_command_window
      s1 = Vocab::new_game
      s2 = Vocab::continue
      s3 = Vocab::shutdown
      s4 = "Achievements"
      @command_window = Window_Command.new(172, [s1, s2, s3, s4])
      @command_window.x = (544 - @command_window.width) / 2
      @command_window.y = 256
      if @continue_enabled
        @command_window.index = 1
      else
        @command_window.draw_item(1, false)
      end
      @command_window.openness = 0
      @command_window.open
    end
    def update(*args)
      nr_achievements_update(*args)
      if Input.trigger?(Input::C) and @command_window.index == 3
        Graphics.freeze
        $scene = Achievements.new($achievements)
      end
    end
  end
end


If you call the Achievement script as shown in the demo
CODE
$scene = Achievements.new

Then it will just show the local achievements for that save file, but to call it for all achievements by the party then I've used
CODE
$scene = Achievements.new($achievements)


You probably won't have to deal with it, but just letting you know smile.gif
say.id
QUOTE (Night_Runner @ Nov 9 2011, 03:24 PM) *
Yes, yes it is

code
CODE
# =============================================================================
# Game Achievements
# Version: 1.1
# Author: Omegas7 & tweaked by: Night_Runner
# Site: http://omegas7.blogspot.com    ||      http://omegadev.biz
#  & http://www.rpgrevolution.com/forums/index.php?showtopic=45809
# -----------------------------------------------------------------------------
# Features:
#      > 1.1
#          > Achievements linked to game switches
#          > Achievement Bar appears when achievement switch activated
#          > Menu showing achievements separated by All, Unlocked and Locked.
#          > Achievements descriptions
#          > Achievements descriptions can have a background image
#          > Each achievement is represented by a 90x90 image
#          > Menu background image
#          > Locked achievement image (90x90)
#          > Achievements menu cursor is an image (90x90)
#          > Achievement bar image
#          > Achievement complete & incomplete graphic for description screen
# -----------------------------------------------------------------------------
# Instructions
#    First, this will be the basic template for your achievement:
#
#    Achievements[ID] = ["Name","GaphicName",SwitchID]
#    Descriptions[ID] = ["Line1","Line2","Line3"]
#
#    ID = ID of achievement for the script to use. Each achievement has one
#    unique ID number. Starting from 0.
#    "Name" => Name displayed for the achievement. Inside quotes " "
#    "GraphicnName" => 90x90 graphic name located in [Pictures] folder
#                            inside quotes " "
#    SwitchID => ID of game switch you want to link this achievement to.
#    You can add as many Description lines as you want.
#    Each line is inside quotes " ", and each line is separated by a comma.
# =============================================================================

module AchievementsDATA
  FileName = "Data/Achievements.rvdata"     # Save game achievements
  ShowInTitle = true                   # Show Achievements in title (true/false)
  MenuBackground = "AchievementBG"     # [Pictures] folder
  LockedTrohyGraphic = "LockedTrophy"  # [Pictures] folder 90x90
  TrophyCursorGraphic = "TrophyCursor" # [Pictures] folder 90x90
  DescriptionScreenGraphic = "DescriptionScreen" # [Pictures] folder
  AchievementBarGraphic = "AchievementBar"  # [Pictures] folder
  
  AchievementIsCompleteGraphic = "AchievementCompleted" # [Pictures] folder
  AchievementIsIncompleteGraphic = "AchievementIncomplete" # [Pictures] folder
  # That last two graphics will appear at the bottom right of the screen
  # when used *
  
  Achievements = []
  Descriptions = []
  
  Achievements[0] = ["Greedy Ralph","Trophy",1]
  Descriptions[0] = ["Open 5 chests!","Commonly known as a noob-level achievement."]
  
  Achievements[1] = ["Defeat Gary","Trophy",2]
  Descriptions[1] = ["Beat evil Gary at the garden!"]
  
  Achievements[2] = ["LOVE OMEGAS7","Trophy",3]
  Descriptions[2] = ["Show your love for Omegas7 to a stranger."]
end

if $TEST and not FileTest.exist?(AchievementsDATA::FileName)
  save_data([],AchievementsDATA::FileName)
end

class Achievements < Scene_Base
  include AchievementsDATA
  def initialize(achievement_ids = nil)
    if achievement_ids == nil
      @achievement_ids = []
      for achievement in $game_party.achievements
        if achievement[1] == true
          for achdata in AchievementsDATA::Achievements
            if achdata[2] == achievement[0]
              @achievement_ids << AchievementsDATA::Achievements.index(achdata)
            end
          end
        end
      end
    else
      @achievement_ids = achievement_ids
    end
    @return_class = $scene.class
    create_background
    create_menu
    create_trohpies
    @view = 'NONE'
    @chosen = false
    @locked = 0
    @unlocked = 0
    for i in 0...Achievements.size
      if @achievement_ids.include?(i)
        @unlocked += 1
      else
        @locked += 1
      end
    end
  end
  def update
    updateInput
    updateMenus if !@chosen
    @chosen = false
  end
  def updateMenus
    case @view
    when 'NONE'
      @menu.update
    when 'TROPHIES'
      @trophyMenu.update
    end
  end
  def updateInput
    if Input.trigger?(Input::C) && @view == 'NONE'
      case @menu.index
      when 0  # All
        @view = 'TROPHIES'
        @trophyMenu.setView('all')
        @trophyMenu.setOpacity(255)
        Sound.play_decision
        @chosen = true
        return
      when 1  # Unlocked
        if @unlocked <= 0
          Sound.play_buzzer
          return
        end
        @view = 'TROPHIES'
        @trophyMenu.setView('unlocked')
        @trophyMenu.setOpacity(255)
        Sound.play_decision
        @chosen = true
        return
      when 2  # Locked
        if @locked <= 0
          Sound.play_buzzer
          return
        end
        @view = 'TROPHIES'
        @trophyMenu.setView('locked')
        @trophyMenu.setOpacity(255)
        Sound.play_decision
        @chosen = true
        return
      when 3  # Exit
        @trophyMenu.finish
        @bg.dispose
        @menu.dispose
        $scene = @return_class.new
        @chosen = true
        return
      end
    end
    if Input.trigger?(Input::B) && @view == 'NONE'
      @trophyMenu.finish
      @bg.dispose
      @menu.dispose
      $scene = @return_class.new
      @chosen = true
      return
    end
    if Input.trigger?(Input::B) && @view == 'TROPHIES' && !@trophyMenu.description?
      @view = 'NONE'
      @trophyMenu.setOpacity(0)
      Sound.play_cancel
    end
  end
  def create_background
    @bg = Sprite_Base.new
    @bg.bitmap = Cache.picture(MenuBackground)
    @bg.z = 0
  end
  def create_menu
    commands = ['All','Unlocked','Locked','Back']
    @menu = Window_Command.new(130,commands)
    @menu.contents.font.size = 20
    @menu.refresh
    @menu.opacity = 0
    @menu.z = 9
  end
  def create_trohpies
    @trophyMenu = AchievementTrophyMenuManager.new(@achievement_ids)
    @trophyMenu.setOpacity(0)
  end
end

class AchievementTrophyMenuManager
  include AchievementsDATA
  def initialize(achievement_ids)
    @achievement_ids = achievement_ids
    @trophies = []
    draw_trophies('all')
    @moved_y = 0
    if !@trophies.empty?
      @cursor = Sprite_Base.new
      @cursor.bitmap = Cache.picture(TrophyCursorGraphic)
      @cursor.z = 2
      @cursor.x,@cursor.y = @trophies[0].sprite.x,@trophies[0].sprite.y
    end
    @cursorIndex = 0
    @toBeY = 0
    @viewingDescription = false
    @description = Sprite_Base.new
    @description.bitmap = Cache.picture(DescriptionScreenGraphic)
    @description.z = 100
    @description.opacity = 0
    @descriptionWindow = Window_Base.new(30,90,544 - 60,270)
    @descriptionwindow.opacity = 0
    @name = Window_Base.new(12,-12,300,90)
    @name.contents.font.size = 18
    @name.opacity = 0
    @block = false
  end
  def draw_trophies(view)
    @trophies = []
    @chart = []
    trueIndex = 0
    for i in 0...Achievements.size
      if @achievement_ids.include?(i)
        if view == 'all' || view == 'unlocked'
          @trophies.push(AchievementTrophy.new(trueIndex,true,Achievements[i][0]))
          @chart.push(Descriptions[i])
          trueIndex += 1
        end
      else
        if view == 'all' || view == 'locked'
          @trophies.push(AchievementTrophy.new(trueIndex,false,Achievements[i][0]))
          @chart.push(Descriptions[i])
          trueIndex += 1
        end
      end
    end
  end
  def update
    if !@viewingDescription
      if Input.trigger?(Input::DOWN)
        Sound.play_cursor
        @cursorIndex += 4
      end
      if Input.trigger?(Input::UP)
        Sound.play_cursor
        @cursorIndex -= 4
      end
      if Input.trigger?(Input::RIGHT)
        Sound.play_cursor
        @cursorIndex += 1
      end
      if Input.trigger?(Input::LEFT)
        Sound.play_cursor
        @cursorIndex -= 1
      end
      checkCursorPosition
      if Input.trigger?(Input::C)
        @descriptionwindow.contents.clear
        @name.contents.clear
        @description.opacity = 255
        for i in 0...@chart[@cursorIndex].size
          @descriptionwindow.contents.draw_text(0,(20 * i),500,20,@chart[@cursorIndex][i].to_s)
        end
        @viewingDescription = true
        @block = true
        @name.contents.draw_text(0,0,300,20,@trophies[@cursorIndex].name)
        @completed = Sprite_Base.new
        if @trophies[@cursorIndex].obtained
          @completed.bitmap = Cache.picture(AchievementIsCompleteGraphic)
        else
          @completed.bitmap = Cache.picture(AchievementIsIncompleteGraphic)
        end
        @completed.x = 544 - @completed.width
        @completed.y = 416 - @completed.height
        @completed.z = 300
        return
      end
    else
      if (Input.trigger?(Input::C) || Input.trigger?(Input::B)) && !@block
        Sound.play_cancel
        @descriptionwindow.contents.clear
        @name.contents.clear
        @description.opacity = 0
        @viewingDescription = false
        @completed.dispose
        @completed = nil
        return
      end
    end
    @block = false
    if Input.trigger?(Input::L)
      print @description.opacity
    end
  end
  def description?
    return @viewingDescription
  end
  def checkCursorPosition
    if @cursorIndex < 0
      @cursorIndex = 0
    end
    if @cursorIndex > @trophies.size - 1
      @cursorIndex = @trophies.size - 1
    end
    @toBeY = @trophies[@cursorIndex].sprite.y
    a = false
    while @toBeY >= 10 + (90 * 4)
      moveY(-90)
      a = true
    end
    if !a
      while @toBeY < 10
        moveY(90)
      end
    end
    @cursor.x = @trophies[@cursorIndex].sprite.x
    @cursor.y = @trophies[@cursorIndex].sprite.y
  end
  def moveY(y)
    for i in 0...@trophies.size
      @trophies[i].sprite.y += y
      @toBeY += y
    end
  end
  def setOpacity(n)
    for i in 0...@trophies.size
      @trophies[i].sprite.opacity = n
    end
    @cursor.opacity = n
  end
  def setView(view)
    for i in 0...@trophies.size
      @trophies[i].sprite.dispose
      @trophies[i] = nil
    end
    @cursorIndex = 0
    @trophies.compact!
    @chart = []
    draw_trophies(view)
  end
  def finish
    @cursor.dispose
    for i in 0...@trophies.size
      @trophies[i].sprite.dispose
      @trophies[i] = nil
    end
    @trophies.compact!
    @description.dispose
    @descriptionwindow.dispose
    @name.dispose
  end
end

class AchievementTrophy
  include AchievementsDATA
  attr_accessor :sprite
  attr_reader :obtained
  attr_reader :name
  def initialize(index,obtained,name)
    @sprite = Sprite_Base.new
    if obtained
      @sprite.bitmap = Cache.picture(Achievements[index][1])
    else
      @sprite.bitmap = Cache.picture(LockedTrohyGraphic)
    end
    @sprite.z = 1
    @sprite.x = 180 + (90 * (index % 4))
    @sprite.y = 10 + (90 * (index / 4))
    @obtained = obtained
    @name = name
  end
end

class Game_Party
  alias omega_achievements_initialize initialize
  attr_accessor :achievements
  def initialize
    omega_achievements_initialize
    @achievements = []
    for i in 0...AchievementsDATA::Achievements.size
      @achievements.push([AchievementsDATA::Achievements[i][2],
      $game_switches[AchievementsDATA::Achievements[i][2]]])
    end
  end
end

class AchievementBar
  include AchievementsDATA
  attr_reader :finished
  def initialize(id)
    @sprite = Sprite_Base.new
    @sprite.bitmap = Cache.picture(AchievementBarGraphic)
    @sprite.z = 300
    @sprite.x = 272 - (@sprite.width/2)
    @sprite.y = 416 - @sprite.height
    @sprite.zoom_x = 0.1
    @sprite.zoom_y = 0.1
    @timer = -1
    @leaving = false
    @finished = false
  end
  def update
    if @sprite.zoom_x < 1.0
      @sprite.zoom_x += 0.05
      @sprite.zoom_y += 0.05
      if @sprite.zoom_x >= 1.0
        @timer = 140
      end
    end
    if @timer > 0
      @timer -= 1
    else
      if !@leaving && @sprite.zoom_x >= 1.0
        @leaving = true
      end
    end
    if @leaving
      @sprite.opacity -= 3
      if (@sprite.opacity <= 0) && (!@finished)
        finish
      end
    end
  end
  def finish
    @sprite.dispose
    @finished = true
  end
end

class Scene_Map
  alias omegaAchievementInitialize  initialize  unless $@
  alias omegaAchievementUpdate      update      unless $@
  alias omegaAachievementTerminate  terminate   unless $@
  def initialize
    omegaAchievementInitialize
    @achievements = []
  end
  def update
    omegaAchievementUpdate
    for i in 0...@achievements.size
      @achievements[i].update
      if @achievements[i].finished
        @achievements[i] = nil
      end
    end
    @achievements.compact!
  end
  def terminate
    omegaAachievementTerminate
    for i in 0...@achievements.size
      @achievements[i].finish
    end
  end
  def addAchievementBar(id)
    @achievements.push(AchievementBar.new(id))
  end
end

class Game_Interpreter
  alias omegaAchievementsSwitch command_121
  def command_121
    omegaAchievementsSwitch
    if $scene.is_a?(Scene_Map)
      for i in 0...$game_party.achievements.size
        if $game_party.achievements[i][1] != $game_switches[$game_party.achievements[i][0]]
          if $game_switches[$game_party.achievements[i][0].to_i]
            $game_party.achievements[i][1] = $game_switches[$game_party.achievements[i][0]]
            $scene.addAchievementBar(i)
            $achievements << i
            $achievements.uniq!
            save_data($achievements, AchievementsDATA::FileName)
            break
          end
        end
      end
    end
  end
end

class Scene_Title
  alias nr_achievements_load_database  load_database  unless $@
  alias nr_achievements_update         update         unless $@
  def load_database(*args)
    $achievements = load_data(AchievementsDATA::FileName)
    return nr_achievements_load_database(*args)
  end
  if AchievementsDATA::ShowInTitle
    def create_command_window
      s1 = Vocab::new_game
      s2 = Vocab::continue
      s3 = Vocab::shutdown
      s4 = "Achievements"
      @command_window = Window_Command.new(172, [s1, s2, s3, s4])
      @command_window.x = (544 - @command_window.width) / 2
      @command_window.y = 256
      if @continue_enabled
        @command_window.index = 1
      else
        @command_window.draw_item(1, false)
      end
      @command_window.openness = 0
      @command_window.open
    end
    def update(*args)
      nr_achievements_update(*args)
      if Input.trigger?(Input::C) and @command_window.index == 3
        Graphics.freeze
        $scene = Achievements.new($achievements)
      end
    end
  end
end


If you call the Achievement script as shown in the demo
CODE
$scene = Achievements.new

Then it will just show the local achievements for that save file, but to call it for all achievements by the party then I've used
CODE
$scene = Achievements.new($achievements)


You probably won't have to deal with it, but just letting you know smile.gif

wow,, it works..
but u put it wrong in this code @descriptionwindow.dispose and the others..,, it need to change the W to capital,,
so thanks for ur tweak,,hhooo biggrin.gif
Night_Runner
Wow, I don't even remember touching that.... welcome happy.gif
And I've fixed it in my post as well, I just used a lower case w, seemed easier to change it once smile.gif
chaco
This is a beautiful script! I love it a lot, it's simple to use and attractive to the eye!
The fact that there is no menu option is actually perfect for me, since in my game the NPC's control everything XD

Nice job! I'll be sure to credit ya in my game! laugh.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.