Help - Search - Members - Calendar
Full Version: Achievements
RPG RPG Revolution Forums > Scripting > Script Tutorials > RGSS2
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9
Lockheart
Alright, I've got three more requests for this script, I'm not sure how easy or hard they are to do though, I don't think they would be.

1: If more then one achievement is obtained, instead of having a ton of them take over the screen(be it the left side, right side or center) Instead combine all of them into one window, for example, lets say you earned three achievements while using the points system it could look like this:

Achievement Unlocked!
3 for 15 points

In the example, each of the achievements would be worth 5 points each, so it'd take the amount of each Achievement and combined it into a number like so.

2: If using the point system it'd be nice if the points could be shown when an achievement is earned, for example:

Achievement Unlocked!
Posting a message - 5 Points

shouldn't be hard to pull up that information right?

3: Allow the user to use a picture instead of the windowskins to make it more personalized for the creators games.

Hope you can get at least the first one, the others are just nice to have. Good luck with them, and thanks in advance.
SojaBird
Hey,

Well oke so I've not been very active scripting lately.
Probabely 'cause I've been buzzy with school a lot again.
I also don't feel the need to script.
So sorry for that.

Though I'll have a look at those things for you soon.
Only thing...can you explain nr 3 a bit more please.
Don't get the windowskins thing realy yet.


Greatzz,
SojaBird.
Lockheart
QUOTE (SojaBird @ Sep 16 2009, 02:21 PM) *
Hey,

Well oke so I've not been very active scripting lately.
Probabely 'cause I've been buzzy with school a lot again.
I also don't feel the need to script.
So sorry for that.

Though I'll have a look at those things for you soon.
Only thing...can you explain nr 3 a bit more please.
Don't get the windowskins thing realy yet.


Greatzz,
SojaBird.


Thats fine, life come before everything else, right?

As for the third one, what I mean by windowskins is the message window that pops up, I'm thinking I'd rather use a picture to show the achievements rather then a message box, that clearer or should I go into more detail?
SojaBird
Heyz,

Yea life 's number one biggrin.gif
I get the third one wink.gif
Try it some time.


Greatzz,
SojaBird.
Makin Kash
Hey sojabird i'm a big fan of your scripts, but sadly have absolutely no knowledge how to work them!!! sweat.gif
I was wondering if you could tell me what is wrong, i am trying to run the achivement scrip, and it says sintax error on line 135 on the achivement i entered
I was wondering if you could shed some light on what i am doing wrong to cause this!! I put in the area it fails on


130 #-----------#
131 # Start-up: #
132 #-----------#
134 Start_Achievements =
135 [Munckin, Hope it works ,38 ,false ,false ,Completed,]
136 [Munckin2, Hope it works ,38 ,false ,false ,Completed,]
137 [Munckin3, Hope it works ,38 ,false ,false ,Completed,]
138 [Munckin4, Hope it works ,38 ,false ,false ,Completed,]

SojaBird
If you can't find what's wrong try look at the demo.
I've included comments in there how to work with it.
Also, read the descriptions in the script.
I've placed a comment in there wich tell's the configuration or how to put things in, MAKE SURE YOU CHECK THOSE OUT.

Now for your problem (now I'm writing anyway), put the NAME and DESCRIPTION in as a string ("...").
The syntax to put it in is the next
CODE
Start_Achievments = [
["Munckin", "Hope it works", 38, false, false, true],
["Munckin2", "Hope it works", 38, false, false, true],
["Munckin3", "Hope it works", 38, false, false, true],
["Munckin4", "Hope it works", 38, false, false, true]
]

Let's hope that makes sence.

So one last time for the syntax...
Start_Achievments = [, leave the [ there!!
["name" (string), "description" (string)[/b], icon_id[/b] (number), hidden (*optional, boolean = true/false, default = false), icon_hidden (*optional, boolean = true/false, default = hidden), completed (*optional, boolean = true/false, default = false))
], leave the ] there!!


Greatzz,
SojaBird.
Makin Kash
QUOTE (SojaBird @ Oct 19 2009, 01:45 AM) *
If you can't find what's wrong try look at the demo.
I've included comments in there how to work with it.
Also, read the descriptions in the script.
I've placed a comment in there wich tell's the configuration or how to put things in, MAKE SURE YOU CHECK THOSE OUT.

Now for your problem (now I'm writing anyway), put the NAME and DESCRIPTION in as a string ("...").
The syntax to put it in is the next
CODE
Start_Achievments = [
["Munckin", "Hope it works", 38, false, false, true],
["Munckin2", "Hope it works", 38, false, false, true],
["Munckin3", "Hope it works", 38, false, false, true],
["Munckin4", "Hope it works", 38, false, false, true]
]

Let's hope that makes sence.

So one last time for the syntax...
Start_Achievments = [, leave the [ there!!
["name" (string), "description" (string)[/b], icon_id[/b] (number), hidden (*optional, boolean = true/false, default = false), icon_hidden (*optional, boolean = true/false, default = hidden), completed (*optional, boolean = true/false, default = false))
], leave the ] there!!


Greatzz,
SojaBird.





Thanks so much!
I added your scriptology bar to my sig see !

Sorry about weird achivement names I was just trying to get it to work!
SojaBird
Haha that's not a problem:)
I resently played Munckin tongue.gif

So anyway, cool 'bout the bar.
I might find some time soon to record a kind of intro and what's gonna happen with Scriptology.


Greatzz,
SojaBird.
BaryK
uhm for somebody that needs the Trophy Sound from the PS3 System

KLICK ME HARD!
Fawlcon
Very nice script!
One question thou....
Can you make it so that instead of the achievements scrolling from the bottom of the screen to the top when you get it,
can you make it appear in the upper right corner?
If it's too much to ask for, by all means ignore this request, it's just something i would want instead of the achievements
moving from the bottom of the screen to the top.
By other than that, i applaud you for this script, it's perfect!
SojaBird
Hey Fawlcon,

Thanks.
The request you want is allready included, just change the script it's setup.
You'll find info on how to do it in there as well.


Greatzz and enjoy,
SojaBird.
louistoba
What I would like this script to do is use your points to buy special Items, Weapons, Armors in the shop instead of revealing hidden Achievements.
Is it possible to do so?
SojaBird
Probable it is yes.

Though it requires some time wich I don't have at the moment.
Contact me to buy my time if you realy wish to have it, if you're not interested you can wait (sorry but it's going to be a long time)...perhaps I have some time someday.


Sorry,
SojaBird.
megamario
How do you make Acheivment Quests?
(sorry if its a noob question, but im not a scripter)
SojaBird
Oke late reaction though I'm back for a few awnsers...

How to make achievement quests?
Well you can make them by setting a condition wich will show completion on screen when it is completed.
Though how you set this up, you should check in the demo events.
There you'll find some examples wink.gif

Perhaps I'll make a video tutorial on that smile.gif


Greatzz,
SojaBird.
PolarTier
Could you make it for XP???
SojaBird
Hey,

No I'm sorry but I can not.
I can only script for RPG maker VX with RGSS2.


Greatzz,
SojaBird.
dejers
hey is there anyway to allow a message to overlap the menu
its for the tutorial of my game

srry kind of a scripting noooob biggrin.gif
SojaBird
Hey there,

There is a way to do this yes.
Though it does require a little scripting.
I'll make a tutorial for it soon I think.


Greatzz,
SojaBird.
leongon
Hello Soja, this script is beautiful *_*

Im not skilled at scripting, but so far have managed to understand most of them to manipulate'em and match my requirements, but Im stucked with this one. The game freezzes after the end of a battle in where I change a game switch that trigger an achievement... hope you can guide me where I must look to find the cause of the problem.

I really want to use this amazing script.
SojaBird
Mmm that's pretty strange.
How have you switched the trigger?
Cause sometimes it's freezing when you use a common event.

Let me know how you activate your trigger and I'll be able to help you further smile.gif
leongon
I'll try to explain what I did, hope my english is good enough:

When actor casts skill X, and the next immediate action is comrade actor casting skill Y that leads to a joint tech Z.
Skill Z action sequence's turns a game-switch(everything working fine 'till here) that I use as a trigger for completion of achievement "Discovered a new Coop-Tech!".

Then, if the skill Z was used and game-switch was turned on in battle, the game freezzes after returning to map only if I'm triggering the completion of an achievement from that game-switch.


I've seen how you track your posts, and help everyone who has questions or problems using your scripts, I really appreciate your effort.
SojaBird
Oke well I think I'll need some time to find that out... Specialy since you're using an other script.
Though if it just triggers an common event it should be working (I think).

I'll see what I can do.


Greatzz,
SojaBird.
leongon
You were right. If I control the game-switch through a common event in the skill it works fine.

Apparently the freezing is trouble only when controlling the achievement completing game-switch via a battlesystem sequence. Im using the sideview 3.3 with improved battlers if you wanna try to compatibilyze this issue.

Anyway thank you very much, SojaBird, your answers helped me to figure what was going wrong.
Dark Cape
The script is really good but there's one small problem. When I insert an achievement inside the appropriate part of the script and the following is said.

SyntaxError occoured while running script.

This is what I put in the script...

#-----------#
# Start-up: #
#-----------#
Start_Achievements = [
#[Name, Description, Icon, Hidden, Hide_Icon, Completed]
["Adventure Has Set!","Become an adventurer for the King.",41,false,false]

]

Start_Buyables = [
#[Price, Name, Description, Icon]

]

Start_Conditions = [
#[Name, Condition]
["Adventure Has Set!","switch(5)=true"]

]

Start_Rewards = [
#[Name, Reward]

]

Start_Points = [
#[Name, Points]
["Adventure Has Set!",10]

]

Please could you help SojaBird?

SojaBird
@leongon
Oke so you do know the problem...but did it also solve it?
I think it hasn't.
I'll have a look at it soon.

@Dark Cape
Oke so I'm not sertain what's wrong with that one.
I'm gonna try the same setup and look what it gives for me.
I'll report back here when I got some information wink.gif


Greatzz,
SojaBird.
leongon
@Dark Cape: I think this is the problem:

Start_Conditions = [
#[Name, Condition]
["Adventure Has Set!","switch(5)=true"]

Must be:

Start_Conditions = [
#[Name, Condition]
["Adventure Has Set!","switch(5) == true"]

:S

QUOTE (SojaBird @ Jan 7 2010, 04:44 AM) *
@leongon
Oke so you do know the problem...but did it also solve it?
I think it hasn't.
I'll have a look at it soon.

Greatzz,
SojaBird.

It's working fine, just not in the way I originally wanted to. It's simply a compatibility issue with sideview battle system script I think, that's why I said "if you wanna try to compatibilyze"... It'll be more a patch than a fix. Your script is great, I just have to control the switches outside the battlesequence... As a common event in the skills works fine.

You can add some setup options to set the font size for the "description" separatetly from title, or to change the back color of the menu list. I make my way through the script to modify some lines.

Looking like:


Of course that was to make it look how i wanted to, but would be good if you add customization for this kind of things on the first lines.

BTW I'm very happy cuz i'm starting to understand scripts now, my game looks like in my wet dreams. *3*
SojaBird
Hey leonge,

Thanks for helping me out.
I actualy think you are right about the problem of Dark Cape.
@Dark Cape, check if that fixes your problem. Report if it is or isn't.
So about the changing of those values...that's actualy a pretty neat thing you got there.
I'll work on this very soon after I got some time of my buzy school life -__-"

But yea, this actualy makes my want to get back to rgss2 again.
Also because this is one of my best scriptproject so far.
But yea, you can expect a new updated version soon wink.gif (in about 1 week from now).


Greatzz,
SojaBird.
leongon
Here is the clean script 2.2 plus a few custom modifications of my own, is a very lesser change that allows easy control for the menu border, background and fonsizes of the achievement list. Im far away from being a scripter, this is just some changes that I did to the script for my own game proyect, and maybe it can be useful for others, or even Soja to apply this features in the correct way in next versions.

Everything I touched is marked as "Simple mods by Leongon" so easy Control+F to find what I messed around.
[Show/Hide] Achievement 2.2+ part1

#------------------------------------------------------------------------------#
# Name: Achievements #
# By: SojaBird #
# Version: 2.2 (+lesser mods by Leongon) #
# i #
# Date: 21-08-09 #
#------------------------------------------------------------------------------#

$imported = {} if $imported == nil
$imported["SojaBird_Achievements"] = true

#---------------------#----------------#
# Condition List : comparison # (all can serve as conditional branch)
#---------------------#----------------#
# - completed : >=, <=, ==, != # ('get_completed' in conditional branch)
# - completed(list) : true, false # ('get_completed' in conditional branch)
# - item(item_id) : >=, <=, ==, != #
# - weapon(weapon_id) : >=, <=, ==, != #
# - armor(armor_id) : >=, <=, ==, != #
# - var(variable_id) : >=, <=, ==, != #
# - switch(switch_id) : true, false #
# - gold : >=, <=, ==, != #
# - lvl(actor_id) : >=, <=, ==, != # (if actor_id == -1, highest of members)
# - exp(actor_id) : >=, <=, ==, != # (if actor_id == -1, highest of members)
# - points : >=, <=, ==, != # ('get_points' in conditional branch)
#---------------------#----------------#
# (true/false in combo with == or !=) #
#--------------------------------------#

#------------------------------#----------#
# Reward List : *default #
#------------------------------#----------#
# - item(item_id, *amount) : 1 #
# - weapon(weapon_id, *amount) : 1 #
# - armor(armor_id, *amount) : 1 #
# - var(variable_id, *amount) : 1 #
# - switch(switch_id, *value) : toggle #
# - gold(amount) : #
# - lvl(actor_id, amount) : # (if actor_id == -1, all members)
# - exp(actor_id, amount) : # (if actor_id == -1, all members)
#------------------------------#----------#

#----------------------------------#--------------------#
# Scene Calls : *default #
#----------------------------------#--------------------#
# - Achief.call(*return_map) : false #
# - Achief.call_shop(*reveal_cost) : Common_Reveal_Cost #
#----------------------------------#--------------------#

#----------------------#
# Configuration module #
#----------------------#
module SojaBird_Achievements

#-------#
# Menu: #
#-------#
Menu_Location = 4
Menu_Title = "Achievements"
Menu_Counting = true

#---------------------#
# Achievements scene: #
#---------------------#
Scroll_Speed = 5
Border_Size = 5
#----------------------Simple mods by Leongon--------------------#
# - Setup - #
Border_R = 0 #Leongon, set list frame color R.
Border_G = 0 #Leongon, set list frame color G.
Border_B = 0 #Leongon, set list frame color B.
Border_A = 255 #Leongon, set list frame color Opacity.
Fill_R = 0 #Leongon, set list fill color R.
Fill_G = 200 #Leongon, set list fill color G.
Fill_B = 255 #Leongon, set list fill color B.
Fill_A = 100 #Leongon, set list fill color Opacity.
Title_Sizef = 20 #Leongon, set list title size.
Description_Sizef = 14 #Leongon, set list description size.
#----------------------------------------------------------------#

Auto_Scroll = true
Auto_Scroll_Speed = 0.1
Time_Span = 4

Status_Text = "Completed: %s"

#----------------------#
# Hidden achievements: #
#----------------------#
Hidden_Title = "???"
Hidden_Description = "Secrets beyond..."
Hidden_Icon = 152

#----------------------#
# Achievements alerts: #
#----------------------#
module SE_Found
Name = "Bell"
Volume = 50
Pitch = 0
end

module SE_Complete
Name = "Applause"
Volume = 50
Pitch = 0
end

# normal/up/down
alert_Display = "up"
alert_Opacity = 200
# left/center/right
alert_Position = "center"
alert_Width = 300
alert_Reward_Width = 544
alert_Font_Size = 16

Complete_Text = "Achievement '%s' was completed!"
Reward_Text = "You've gained %s!"
Find_Text = "Achievement '%s' was found!"
Hidden_Found = "You found a hidden achievement!"

# for normal display
Time_Span_Text = 4

Display_StartUps = true
Reward_Prototype = true

#--------------------#
# Message points-tag #
#--------------------#
Message_Tag = "AP"

#--------------#
# Point system #
#--------------#
Use_Point_System = true
Point_Name = "point"
Point_Font_Size = 12

Shop_Buy = "Buy"
Shop_Reveal = "Reveal"
Common_Reveal_Cost = 5

#-----------#
# Start-up: #
#-----------#
Start_Achievements = [
#[Name, Description, Icon, Hidden, Hide_Icon, Completed]

]

Start_Buyables = [
#[Price, Name, Description, Icon]

]

Start_Conditions = [
#[Name, Condition]

]

Start_Rewards = [
#[Name, Reward]

]

Start_Points = [
#[Name, Points]

]

end
#-------------#
# Module: End #
#-------------#

#--------------------#
# Call-script module #
#--------------------#
module Achief

#--------------------------------------------------------------------------#
# Achief.new(name, description, *icon, *hidden, *hide_icon, *completed) #
# - name: Name of the achievement (string) #
# - description: Descripition of the achievement (string) #
# - icon: Icon-id of icon for the achievement (number) #
# - hidden: Hide the whole achievement? (boolean) #
# - hide_icon: Hide the icon? (boolean) #
# - completed: Check the achievement to be completed (boolean) #
#--------------------------------------------------------------------------#
def self.new(name,
description,
icon = 0,
hidden = false,
hide_icon = hidden,
completed = false)
name.gsub!(/\n/) {""}
description.gsub!(/\n/) {""}
if completed
hidden = false
hide_icon = false
end
return if !self.achievement(name).nil?
for index in 0..999
if $game_system.achievements[index].nil?
break $game_system.achievements[index] = Achievement.new(
name, description, icon, hidden, hide_icon, completed)
end
end
end

#--------------------------------------------------------------------------#
# Achief.new_buyable(price, name, description, *icon) #
# - price: Price to buy the achievement (number) #
# - name: Name of the achievement (string) #
# - description: Descripition of the achievement (string) #
# - icon: Icon-id of icon for the achievement (number) #
#--------------------------------------------------------------------------#
def self.new_buyable(price, name, description, icon = 0)
name.gsub!(/\n/) {""}
description.gsub!(/\n/) {""}
return if !self.achievement_buyable(name).nil?
for index in 0..999
if $game_system.achief_buyables[index].nil?
break $game_system.achief_buyables[index] = Achievement_Buyable.new(
price, name, description, icon)
end
end
end

#--------------------------------------------------------------------------#
# Achief.del(name) #
# - name: Name of the achievement (string) #
#--------------------------------------------------------------------------#
def self.del(name)
name.gsub!(/\n/) {""}
return if self.achievement(name).nil?
$game_system.achievements.delete(self.achievement(name, true))
end

#--------------------------------------------------------------------------#
# Achief.hidden(name, *value) #
# - name: Name of the achievement (string) #
# - value: New value of the parameter (boolean) #
#--------------------------------------------------------------------------#
def self.hidden(name, value = false)
name.gsub!(/\n/) {""}
achief = self.achievement(name)
return if achief.nil?
achief.hidden = value
end

#--------------------------------------------------------------------------#
# Achief.hide_icon(name, *value) #
# - name: Name of the achievement (string) #
# - value: New value of the parameter (boolean) #
#--------------------------------------------------------------------------#
def self.hide_icon(name, value = false)
name.gsub!(/\n/) {""}
achief = self.achievement(name)
return if achief.nil?
achief.hide_icon = value
end

#--------------------------------------------------------------------------#
# Achief.completed(name, *value) #
# - name: Name of the achievement (string) #
# - value: New value of the parameter (boolean) #
#--------------------------------------------------------------------------#
def self.completed(name, value = true)
name.gsub!(/\n/) {""}
achief = self.achievement(name)
return if achief.nil?
achief.completed = value
if value
self.hidden(name, false)
self.hide_icon(name, false)
self.gain_reward(name) if !achief.rewarded
self.gain_points(name) if !achief.points_gained and
SojaBird_Achievements::Use_Point_System
end
end

#--------------------------------------------------------------------------#
# Achief.condition(name, condition) #
# - name: Name of the achievement (string) #
# - condition: Set the condition when to complete a achievement (string) #
#--------------------------------------------------------------------------#
def self.condition(name, condition)
name.gsub!(/\n/) {""}
achief = self.achievement(name)
achief = self.achievement_buyable(name) if achief.nil?
return if achief.nil?
condition.gsub!(/\n/) {""}
listener = Completion_Listener.new(condition)
achief.completion_listener = listener
end

#--------------------------------------------------------------------------#
# Achief.reward(name, reward) #
# - name: Name of the achievement (string) #
# - condition: Set the reward that's gain when completed (string) #
#--------------------------------------------------------------------------#
def self.reward(name, reward)
name.gsub!(/\n/) {""}
achief = self.achievement(name)
achief = self.achievement_buyable(name) if achief.nil?
return if achief.nil?
reward.gsub!(/\n/) {""}
achief.reward = reward
end

#--------------------------------------------------------------------------#
# Achief.points(name, amount) #
# - name: Name of the achievement (string) #
# - amount: Amount of points gained when completing (number) #
#--------------------------------------------------------------------------#
def self.points(name, amount)
achief = self.achievement(name)
achief = self.achievement_buyable(name) if achief.nil?
return if achief.nil?
achief.points = amount
end

#--------------------------------------------------------------------------#
# Achief.all_achievements(param, new_value) #
# - param: Parameter to change for all achievements (string) #
# - new_value: New value of the parameters (depends on parameter) #
#--------------------------------------------------------------------------#
def self.all_achievements(param, new_value)
$game_system.achievements.each_value do |value|
next if self.achievement(value.name).nil?
eval("self.#{param}(\"#{value.name}\", #{new_value})")
end
$game_system.achief_buyables.each_value do |value|
next if self.achievement(value.name).nil?
eval("self.#{param}(\"#{value.name}\", #{new_value})")
end
end

end
#-------------#
# Module: End #
#-------------#

#---------------------------#
# Achievements ENGINE class #
#---------------------------#
class Scene_Achievements < Scene_Base

include SojaBird_Achievements

def initialize(return_map = false)
@return_map = return_map
end

def start
super
create_menu_background
create_achievements
new_open_time
scroll_dir
end

def create_achievements
@achievements = Window_Achievements.new
if Use_Point_System
x, y, width = 0, Graphics.height - 56, Graphics.width
@point_system = Window_Point_Currency.new(0, y, width)
end
end

def new_open_time
@open_time = Graphics.frame_count
end

def scroll_dir
@dir = "down"
end

def terminate
super
dispose_menu_background
dispose_achievements
end

def dispose_achievements
@achievements.dispose
@point_system.dispose if Use_Point_System
end

def update
super
update_menu_background
update_achievements
end

def update_achievements
auto_scroll if Auto_Scroll
scroll_up if Input.press?(Input::UP)
scroll_down if Input.press?(Input::DOWN)
return_scene if Input.trigger?(Input::B)
new_open_time if break_time_span
end

def auto_scroll
time_span = (Graphics.frame_count - @open_time) / Graphics.frame_rate
loop_scroll if time_span >= Time_Span
end

def loop_scroll
@dir = "up" if @achievements.oy == @achievements.contents.height -
@achievements.height + 32
@dir = "down" if @achievements.oy == 0
case @dir
when "up"
until (@achievements.oy <= 0 or break_time_span)
scroll_up(Auto_Scroll_Speed)
Graphics.wait(1)
Input.update
end
if @achievements.oy >= 0
new_open_time
@dir = "down"
end
when "down"
until (@achievements.oy >= @achievements.contents.height -
@achievements.height + 32 or break_time_span)
scroll_down(Auto_Scroll_Speed)
Graphics.wait(1)
Input.update
end
if @achievements.oy <= @achievements.contents.height -
@achievements.height + 32
new_open_time
@dir = "up"
end
end
end

def break_time_span
return (Input.trigger?(Input::B) or
Input.press?(Input::UP) or
Input.press?(Input::DOWN))
end

def scroll_up(speed = Scroll_Speed)
for go in 0..speed
@achievements.oy -= 1 if @achievements.oy > 0
end
end

def scroll_down(speed = Scroll_Speed)
for go in 0..speed
@achievements.oy += 1 if @achievements.oy < @achievements.contents.height-
@achievements.height + 32
end
end

def return_scene
Sound.play_cancel
if @return_map
$game_temp.next_scene = nil
$scene = Scene_Map.new
else
begin
super(Menu_Title)
rescue
$scene = Scene_Menu.new(4)
end
end
end

end
#-------------------------#
# Scene_Achievements: End #
#-------------------------#

#-------------------------#
# Achievements shop class #
#-------------------------#
class Scene_Achievements_Shop < Scene_Base

include SojaBird_Achievements

def initialize(reveal_price = Common_Reveal_Cost)
@reveal_price = reveal_price
end

def start
super
create_menu_background
create_command_window
# Windows
@help_window = Window_Help.new
@point_window = Window_Point_Currency.new(384, 56, 160, true)
@dummy_window = Window_Base.new(0, 112, Graphics.width, 304)
@buy_window = Window_Achievements_Buy.new(0, 112)
@reveal_window = Window_Achievements_Reveal.new(@reveal_price,
0, 112, Graphics.width, 304)
# Active
@buy_window.active = false
@reveal_window.active = false
# Visible
@buy_window.visible = false
@reveal_window.visible = false
# Help-window
@buy_window.help_window = @help_window
@reveal_window.help_window = @help_window
end

def terminate
super
dispose_menu_background
dispose_command_window
@help_window.dispose
@point_window.dispose
@dummy_window.dispose
@buy_window.dispose
@reveal_window.dispose
end

def return_scene
$game_temp.next_scene = nil
$scene = Scene_Map.new
end

def update
super
update_menu_background
@help_window.update
@command_window.update
@point_window.update
@dummy_window.update
@buy_window.update
@reveal_window.update
if @command_window.active; update_command_selection
elsif @buy_window.active; update_buy_selection
elsif @reveal_window.active; update_reveal_selection
end
end

def create_command_window
s1 = Shop_Buy
s2 = Shop_Reveal
s3 = Vocab::ShopCancel
@command_window = Window_Command.new(384, [s1, s2, s3], 3)
@command_window.y = 56
end

def dispose_command_window
@command_window.dispose
end

def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 0 #Buy
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
when 1 #Reveal
@command_window.active = false
@dummy_window.visible = false
@reveal_window.active = true
@reveal_window.visible = true
@reveal_window.refresh
when 2; return_scene #Cancel
end
end
end

def buy_achievement(item)
$game_system.achief_points -= item.price
Achief.new(item.name, item.description, item.icon)
cl = item.completion_listener
Achief.condition(item.name, cl.condition) if !cl.nil?
Achief.reward(item.name, item.reward) if !item.reward.nil?
Achief.points(item.name, item.points) if !item.points.nil?
buyable = $game_system.achief_buyables
buyable.delete(buyable.index(item))
end

def reveal_achievement(item)
$game_system.achief_points -= @reveal_price
Achief.hidden(item.name)
Achief.hide_icon(item.name)
end

def update_buy_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
if @item == nil or @item.price > $game_system.achief_points
Sound.play_buzzer
else
Sound.play_shop
buy_achievement(@item)
@point_window.refresh
@buy_window.refresh
end
end
end

def update_reveal_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@reveal_window.active = false
@reveal_window.visible = false
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @reveal_window.item
if @item == nil or @reveal_price > $game_system.achief_points
Sound.play_buzzer
else
Sound.play_shop
reveal_achievement(@item)
@point_window.refresh
@reveal_window.refresh
end
end
end

end
#------------------------------#
# Scene_Achievements_Shop: End #
#------------------------------#

#----------------------------#
# Achievements DISPLAY class #
#----------------------------#
class Window_Achievements < Window_Base

include SojaBird_Achievements

def initialize
height = Use_Point_System ? Graphics.height - (32 + WLH) : Graphics.height
super(0, 0, Graphics.width, height)
@font_size = self.contents.font.size
refresh
end

def refresh
self.contents.clear
@border = 16
@achievement_height = 2 * WLH + 2 * @border
@line_size = Border_Size
@line_size = 16 if @line_size > @border
@icon_difference = 48
height = $game_system.achievements.size * @achievement_height
height = 32 if height == 0
self.contents = Bitmap.new(Graphics.width - 32, height)
draw_contents
end

def draw_contents
index = 0
$game_system.achievements.keys.sort!.each do |key|
value = $game_system.achievements[key]
icon = value.hide_icon ? Hidden_Icon : value.icon
draw_achievement(index, value, icon)
index += 1
end
end

def draw_achievement(index, achief, icon)
name = achief.name
description = achief.description
completed = achief.completed
if achief.hidden
name = Hidden_Title
description = Hidden_Description
completed = false
end
color = Color.new(Border_R, Border_G, Border_B, Border_A) #Simple mods by Leongon
rect = Rect.new(0,
@achievement_height * index,
self.contents.width,
@achievement_height)
self.contents.fill_rect(rect, color)
rect.x += 1 * @line_size
rect.y += 1 * @line_size
rect.width -= 2 * @line_size
rect.height -= 1 * @line_size
rect.height -= 1 * @line_size if index == $game_system.achievements.size - 1
color = Color.new(Fill_R, Fill_G, Fill_B, Fill_A) #Simple mods by Leongon
self.contents.fill_rect(rect, color)
self.contents.font.size = Title_Sizef #Simple mods by Leongon
self.contents.font.bold = true
self.contents.font.color.alpha = completed ? 255 : 128
self.contents.draw_text(@icon_difference,
@achievement_height * index + @border,
self.contents.width - @icon_difference - @border,
WLH,
name)
self.contents.font.size = Description_Sizef #Simple mods by Leongon
self.contents.font.bold = false
self.contents.draw_text(@icon_difference,
@achievement_height * index + WLH + @border,
self.contents.width - @icon_difference - @border,
WLH,
description)
draw_icon(icon,
@border,
@achievement_height * index + 12 + @border,
completed)
if Use_Point_System and !achief.hidden
self.contents.font.size = Point_Font_Size
points = achief.points
return if points == 0
custom = "#{Point_Name}#{points.abs != 1 ? "s" : ""}"
points = sprintf("%s %s", points, custom)
self.contents.draw_text(0,
@achievement_height * index,
self.contents.width - (@border / 2),
WLH,
points,
2)
end
end

end
#--------------------------#
# Window_Achievements: End #
#--------------------------#

#-----------------------#
# alerts display-window #
#-----------------------#
class Window_Achievement_Display < Window_Base

include SojaBird_Achievements

attr_reader :disp
attr_reader :start_control
attr_reader :close_control
attr_reader :delete

def initialize(achief, type)
@achief = achief
@type = type
@type = "c" if @type == "c+r" and reward.size < 1
@disp = alert_Display
lines = 1
lines = 2 if @type == "c+r"
width = alert_Width
width = alert_Reward_Width if @type == "c+r"
height = WLH + (32 * lines)
case alert_Position
when "left"; x = 0
when "center"; x = (Graphics.width / 2) - (width / 2)
when "right"; x = Graphics.width - width
end
y = next_open_spot(height)
super(x, y, width, height)
self.openness = 0
self.opacity = alert_Opacity
@start_control = false
@close_control = false
@delete = false
@wait_count = (Time_Span_Text * 60)
refresh
case @type
when "f"
if SE_Found::Name != ""
Audio.se_play("Audio/SE/#{SE_Found::Name}",
SE_Found::Volume,
SE_Found::Pitch)
end
else
if SE_Found::Name != ""
Audio.se_play("Audio/SE/#{SE_Complete::Name}",
SE_Complete::Volume,
SE_Complete::Pitch)
end
end
end

def next_open_spot(height)
case @disp
when "normal"
list = [0]
$game_system.achief_alerts.each do |alert|
list.push(alert.y + alert.height) if alert.disp == "normal"
end
return (list.max)
when "up"
list = [Graphics.height]
$game_system.achief_alerts.each do |alert|
list.push(alert.y + alert.height) if alert.disp == "up"
end
return (list.max)
when "down"
list = [-height]
$game_system.achief_alerts.each do |alert|
list.push(alert.y - height) if alert.disp == "down"
end
return (list.min)
end
end

def refresh
self.contents.clear
draw_achievement
end

[Show/Hide] Achievement 2.2+ part2

def draw_achievement
self.contents.font.size = alert_Font_Size
icon = @achief.hide_icon ? Hidden_Icon : @achief.icon
draw_icon(icon, 0, 0)
self.contents.draw_text(32, 0, self.contents.width - 32, WLH, get_string)
if @type == "c+r"
text = sprintf(Reward_Text, reward)
self.contents.draw_text(0, 32, self.contents.width, WLH, text)
end
end

def get_string
case @type
when "c", "c+r"; text = Complete_Text
when "f"; text = @achief.hidden ? Hidden_Found : Find_Text
end
return sprintf(text, @achief.name)
end

def reward
text = []
# Item
str = /item\(([0-9]*)(,\s?([0-9]*))?\)/i
@achief.reward.scan(str) {
item = $data_items[$1.to_i].name if !$&.nil?
sp_f = "%s %s#{"s" if $3.to_i.abs != 1}"
last = sprintf(sp_f, $3.to_i, item) if !$&.nil?
text.push(last, ", ")
last = ""
}
# Weapon
str = /weapon\(([0-9]*)(,\s?([0-9]*))?\)/i
@achief.reward.scan(str) {
weapon = $data_weapons[$1.to_i].name if !$&.nil?
sp_f = "%s %s#{"s" if $3.to_i.abs != 1}"
last = sprintf(sp_f, $3.to_i, weapon) if !$&.nil?
text.push(last, ", ")
last = ""
}
# Armor
str = /armor\(([0-9]*)(,\s?([0-9]*))?\)/i
@achief.reward.scan(str) {
armor = $data_armor[$1.to_i].name if !$&.nil?
sp_f = "%s %s#{"s" if $3.to_i.abs != 1}"
last = sprintf(sp_f, $3.to_i, armor) if !$&.nil?
text.push(last, ", ")
last = ""
}
# Gold
str = /gold\(([0-9]*)\)/i
@achief.reward.scan(str) {
sp_f = "%s#{Vocab::gold}"
last = sprintf(sp_f, $1.to_i) if !$&.nil?
text.push(last, ", ")
last = ""
}
# Lvl
str = /lvl\((\-?[0-9]*)(,\s?([0-9]*))\)/i
@achief.reward.scan(str) {
if !$&.nil?
name = $1.to_i == -1 ? "all members" : $game_party.members[$1.to_i].name
end
sp_f = "%s gained %s #{Vocab.level.downcase}#{"s" if $3.to_i.abs != 1}"
last = sprintf(sp_f, name, $3.to_i) if !$&.nil?
text.push(last, ", ")
last = ""
}
# Exp
str = /exp\((\-?[0-9]*)(,\s?([0-9]*))\)/i
@achief.reward.scan(str) {
if !$&.nil?
name = $1.to_i == -1 ? "all members" : $game_party.members[$1.to_i].name
end
sp_f = "%s gained %s EXP"
last = sprintf(sp_f, name, $3.to_i) if !$&.nil?
text.push(last, ", ")
last = ""
}
text.pop
text[text.size - 2] = " and " if text.size > 2
return text
end

def open
super
@start_control = true
end

def update
super
case @disp
when "normal"
if @wait_count > 0; @wait_count -= 1
else; @close_control = true
end
@delete = true if self.openness == 0
when "up"
self.y -= 1
@delete = true if self.y <= -self.height
when "down"
self.y += 1
@delete = true if self.y >= Graphics.height + self.height
end
end

end
#---------------------------------#
# Window_Achievement_Display: End #
#---------------------------------#

#----------------------#
# Point display-window #
#----------------------#
class Window_Point_Currency < Window_Base

include SojaBird_Achievements

def initialize(x, y, width, shop = false)
super(x, y, width, 32 + WLH)
@shop = shop
refresh
end

def refresh
self.contents.clear
draw_points
draw_achief_amount if !@shop
end

def draw_points
width = self.contents.width
width /= 2 if !@shop
name = Point_Name.capitalize
text = sprintf("#{name}s: %s", Achief.get_points)
self.contents.draw_text(0, 0, width, WLH, text)
end

def draw_achief_amount
width = self.contents.width / 2
amount = "#{Achief.get_completed}/#{$game_system.achievements.size}"
text = sprintf(Status_Text, amount)
self.contents.draw_text(width, 0, width, WLH, text, 2)
end

end
#--------------------------#
# Window_Point_System: End #
#--------------------------#

#------------------------------#
# Achievements shop buy window #
#------------------------------#
class Window_Achievements_Buy < Window_Selectable

def initialize(x, y)
super(x, y, Graphics.width, 304)
@column_max = 2
refresh
self.index = 0
end

def item
return @data[self.index]
end

def refresh
@data = []
for achief_buyable in $game_system.achief_buyables.values
@data.push(achief_buyable)
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end

def draw_item(index)
item = @data[index]
enabled = (item.price <= $game_system.achief_points)
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
self.contents.draw_text(rect, item.price, 2)
end

def draw_item_name(item, x, y, enabled = true)
if item != nil
draw_icon(item.icon, x, y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 24, y, 172, WLH, item.name)
end
end

def update_help
@help_window.set_text(item == nil ? "" : item.description)
end

end
#---------------------------------#
# Window_Achievements_Buy: End #
#---------------------------------#

#---------------------------------#
# Achievements shop reveal window #
#---------------------------------#
class Window_Achievements_Reveal < Window_Selectable

include SojaBird_Achievements

def initialize(reveal_price, x, y, width, height)
super(x, y, width, height)
@reveal_price = reveal_price
@column_max = 2
refresh
self.index = 0
end

def item
return @data[self.index]
end

def refresh
@data = []
for achievement in $game_system.achievements.values
@data.push(achievement) if achievement.hidden
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end

def draw_item(index)
item = @data[index]
enabled = (@reveal_price <= $game_system.achief_points)
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
self.contents.draw_text(rect, @reveal_price, 2)
end

def draw_item_name(item, x, y, enabled = true)
if item != nil
icon = item.hide_icon ? Hidden_Icon : item.icon
draw_icon(icon, x, y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 24, y, 172, WLH, Hidden_Title)
end
end

def update_help
@help_window.set_text(item == nil ? "" : Hidden_Description)
end

end
#---------------------------------#
# Window_Achievements_Reveal: End #
#---------------------------------#

#--------------------------#
# Achievement HOLDER class #
#--------------------------#
class Achievement

attr_accessor :name
attr_accessor :description
attr_accessor :icon
attr_accessor :hidden
attr_accessor :hide_icon
attr_accessor :completed
attr_accessor :completion_listener
attr_accessor :reward
attr_accessor :rewarded
attr_accessor :completed_shown
attr_accessor :found_shown
attr_accessor :points
attr_accessor :points_gained

def initialize(name, description, icon, hidden, hide_icon, completed)
@name = name
@description = description
@icon = icon
@hidden = hidden
@hide_icon = hide_icon
@completed = completed
@completion_listener = nil
@reward = nil
@rewarded = false
@completed_shown = false
@found_shown = false
@points = 0
@points_gained = false
end

end
#------------------#
# Achievement: End #
#------------------#

#----------------------------------#
# Achievement buyable HOLDER class #
#----------------------------------#
class Achievement_Buyable < Achievement

attr_accessor :price

def initialize(price, name, description, icon)
super(name, description, icon, false, false, false)
@price = price
end

end
#--------------------------#
# Achievement_Buyable: End #
#--------------------------#

#---------------------------------------#
# Achievement completion LISTENER class #
#---------------------------------------#
class Completion_Listener

attr_accessor :condition

def initialize(condition)
@condition = condition
end

def condition_ready?
mod_it = @condition.dup
str = /(completed(\(\'.*\'(,\s?\'.*\')*?\))?)/i
mod_it.gsub!(str) { eval("Achief.get_#{$1.to_s}") }
mod_it.gsub!(/(item\([0-9]*\))/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(weapon\([0-9]*\))/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(armor\([0-9]*\))/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(var\([0-9]*\))/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(switch\([0-9]*\))/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(gold)/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(lvl\(-?[0-9]*\))/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(exp\(-?[0-9]*\))/i) { eval("Achief.#{$1.to_s}") }
mod_it.gsub!(/(points)/i) { eval("Achief.get_#{$1.to_s}") }
return eval(mod_it)
end

end
#--------------------------#
# Completion_Listener: End #
#--------------------------#

#---------------------#
# Update achievements #
#---------------------#
class Scene_Map < Scene_Base

include SojaBird_Achievements

alias achievements_update update
alias achievements_usc update_scene_change

def update
achievements_update
update_achievements
end

def update_achievements
completion_listener
found_listener
get_reward
get_points if Use_Point_System
Achief.alerts_update
end

def completion_listener
$game_system.achievements.each_value do |value|
if (value.completed and !value.completed_shown)
type = value.reward.nil? ? "c" : "c+r"
Achief.alert(value, type)
end
cl = value.completion_listener
next if cl.nil?
Achief.completed(value.name) if (cl.condition_ready? and !value.completed)
end
end

def found_listener
$game_system.achievements.each_value do |value|
Achief.alert(value, "f") if (!value.completed and
!value.found_shown and
!value.completed_shown)
end
end

def get_reward
$game_system.achievements.each_value do |value|
Achief.gain_reward(value.name) if (value.completed and !value.rewarded)
end
end

def get_points
$game_system.achievements.each_value do |value|
Achief.gain_points(value.name) if (value.completed and
!value.points_gained)
end
end

def update_scene_change
usc_achievements
achievements_usc
end

def usc_achievements
Achief.alerts_update(true) if !$game_temp.next_scene.nil?
end

end
#----------------#
# Scene_Map: End #
#----------------#

#--------------------------#
# Achievements on start-up #
#--------------------------#
class Scene_Title < Scene_Base

include SojaBird_Achievements

alias achievements_cgo create_game_objects

def create_game_objects
achievements_cgo
Start_Achievements.each do |value|
Achief.start_new(value)
end
if Use_Point_System
Start_Buyables.each do |value|
Achief.start_buyables(value)
end
Start_Points.each do |value|
Achief.start_points(value)
end
end
Start_Conditions.each do |value|
Achief.start_condition(value)
end
Start_Rewards.each do |value|
Achief.start_reward(value)
end
$game_system.achievements.each_value do |value|
value.found_shown = true if !Display_StartUps
end
end

end
#------------------#
# Scene_Title: End #
#------------------#

#--------------------------#
# Achievements STORE class #
#--------------------------#
class Game_System

alias achievements_initialize initialize

attr_accessor :achievements
attr_accessor :achief_buyables
attr_accessor :achief_alerts
attr_accessor :achief_points

def initialize
achievements_initialize
@achievements = {}
@achief_buyables = {}
@achief_alerts = []
@achief_points = 0
end

end
#------------------#
# Game_System: End #
#------------------#

#----------------------------#
# Display points in messages #
#----------------------------#
class Window_Message < Window_Selectable

include SojaBird_Achievements

alias achievements_csc convert_special_characters

def convert_special_characters
achievements_csc
tag = Message_Tag
points = $game_system.achief_points
sub = "#{points} #{Point_Name}#{points.abs != 1 ? "s" : ""}"
@text.gsub!(/\\#{tag}/i) { sub }
end

end
#---------------------#
# Window_Message: End #
#---------------------#

#-------------------------#
# Add to menu-items (NMI) #
#-------------------------#
begin

title = SojaBird_Achievements::Menu_Title
if SojaBird_Achievements::Menu_Counting
title += " #{Achief.get_completed}/#{$game_system.achievements.size}"
end
action = "$scene = Scene_Achievements.new"
$Menu_Items.new(SojaBird_Achievements::Menu_Location, title, false, action)

#----------------------------------#
# Rescue > Old fashioned way (NMI) #
#----------------------------------#
rescue

class Scene_Menu < Scene_Base

include SojaBird_Achievements

def create_command_window
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Menu_Title
if Menu_Counting
s5 += " #{Achief.get_completed}/#{$game_system.achievements.size}"
end
s6 = Vocab::save
s7 = Vocab::game_end
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@command_window.index = @menu_index
if $game_party.members.size == 0
@command_window.draw_item(0, false)
@command_window.draw_item(1, false)
@command_window.draw_item(2, false)
@command_window.draw_item(3, false)
end
if $game_system.save_disabled
@command_window.draw_item(5, false)
end
end

def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and @command_window.index < 4
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 5
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0; $scene = Scene_Item.new
when 1,2,3; start_actor_selection
when 4; $scene = Scene_Achievements.new
when 5; $scene = Scene_File.new(true, false, false)
when 6; $scene = Scene_End.new
end
end
end

end


class Scene_File < Scene_Base

def return_scene
if @from_title; $scene = Scene_Title.new
elsif @from_event; $scene = Scene_Map.new
else; $scene = Scene_Menu.new(5)
end
end

end


class Scene_End < Scene_Base

def return_scene
$scene = Scene_Menu.new(6)
end

end

end
#-----------------#
# Begin(NMI): End #
#-----------------#

#-----------------------#
# Engine/Control module #
#-----------------------#
module Achief

#-------------#
# Get correct #
#-------------#
def self.achievement(name, index = false)
$game_system.achievements.each_pair do |key, value|
if $game_system.achievements[key].name == name
return key if index
return value
end
end
return nil
end

def self.achievement_buyable(name, index = false)
$game_system.achief_buyables.each_pair do |key, value|
if $game_system.achief_buyables[key].name == name
return key if index
return value
end
end
return nil
end

#------------------#
# Condition/Reward #
#------------------#
@gain = false

def self.gain_reward(name)
value = self.achievement(name)
value.rewarded = true
self.give_rewards(name) if !value.reward.nil?
end

def self.give_rewards(name)
@gain = true
value = self.achievement(name)
str = /([^\s,\"\'][a-zA-Z0-9\s]*(\(-?[0-9]*(,\s?[a-z0-9]*)?\)))/i
value.reward.scan(str) { eval($1) }
$game_map.need_refresh = true
@gain = false
end

def self.get_completed(*args)
return self.completed_nil if args == []
amount = 0
$game_system.achievements.each_value do |value|
amount += 1 if args.include?(value.name) and value.completed
end
return (amount == args.size)
end

def self.completed_nil
amount = 0
$game_system.achievements.each_value do |value|
amount += 1 if value.completed
end
return amount
end

def self.item(item_id, value = 1)
item = $data_items[item_id]
$game_party.gain_item(item, value) if @gain
return $game_party.item_number(item)
end

def self.weapon(weapon_id, value = 1)
weapon = $data_weapons[weapon_id]
$game_party.gain_item(weapon, value) if @gain
return $game_party.item_number(weapon)
end

def self.armor(armor_id, value = 1)
armor = $data_armors[armor_id]
$game_party.gain_item(armor, value) if @gain
return $game_party.item_number(armor)
end

def self.var(var_id, value = 1)
return $game_variables[var_id] += value if @gain
return $game_variables[var_id]
end

def self.switch(switch_id, value = !$game_switches[switch_id])
return $game_switches[switch_id] = value if @gain
return $game_switches[switch_id]
end

def self.gold(value = nil)
return $game_party.gain_gold(value) if @gain
return $game_party.gold
end

def self.lvl(actor, value = nil)
if actor == -1
lvl = []
$game_party.members.each do |act|
lvl.push(act.level)
act.change_level(act.level + value, false) if @gain
end
return lvl.max
end
act = $game_party.members[actor]
return act.change_level(act.level + value, false) if @gain
return act.nil? ? 0 : act.level
end

def self.exp(actor, value = nil)
if actor == -1
exp = []
$game_party.members.each do |act|
exp.push(act.exp)
act.gain_exp(value, false) if @gain
end
return exp.max
end
act = $game_party.members[actor]
return act.gain_exp(value, false) if @gain
return act.nil? ? 0 : act.exp
end

#----------#
# Messages #
#----------#
def self.alert(achief, type)
case type
when "c", "c+r"; achief.completed_shown = true
when "f"; achief.found_shown = true
end
type = "c" if (!SojaBird_Achievements::Reward_Prototype and type == "c+r")
@win = Window_Achievement_Display.new(achief, type)
$game_system.achief_alerts.push(@win)
end

def self.alerts_update(close = false)
@alerts = $game_system.achief_alerts
return if @alerts == []
@alerts.each do |alert|
if close
alert.visible = false
else
alert.open if (!$game_map.interpreter.running? and !alert.close_control)
alert.update if alert.start_control
alert.close if alert.close_control
@alerts.delete(alert) if alert.delete
end
end
@alerts.clear if close
end

#--------------#
# Point system #
#--------------#
def self.get_points
return $game_system.achief_points
end

def self.gain_points(name)
value = self.achievement(name)
value.points_gained = true
self.give_points(value.points) if !value.points.nil?
end

def self.give_points(value)
$game_system.achief_points += value
end

#------------#
# Open scene #
#------------#
def self.call(return_map = false)
self.alerts_update(true)
$game_temp.next_scene = "achievements"
$scene = Scene_Achievements.new(return_map)
end

def self.call_shop(reveal_price = SojaBird_Achievements::Common_Reveal_Cost)
self.alerts_update(true)
$game_temp.next_scene = "achievements_shop"
$scene = Scene_Achievements_Shop.new(reveal_price)
end

#----------#
# Start-up #
#----------#
def self.start_new(array)
name = array[0]
description = array[1]
icon = array[2]
hidden = array[3]
hide_icon = array[4]
completed = array[5]
hidden = false if hidden.nil?
hide_icon = hidden if hide_icon.nil?
completed = false if completed.nil?
self.new(name, description, icon, hidden, hide_icon, completed)
end

def self.start_condition(array)
name = array[0]
condition = array[1]
self.condition(name, condition)
end

def self.start_reward(array)
name = array[0]
reward = array[1]
self.reward(name, reward)
end

def self.start_points(array)
name = array[0]
points = array[1]
self.points(name, points)
end

def self.start_buyables(array)
price = array[0]
name = array[1]
description = array[2]
icon = array[3]
icon = 0 if icon.nil?
self.new_buyable(price, name, description, icon)
end

end
#-------------#
# Module: End #
#-------------#

I don't know why the spoiler doesn't work, moderator plz help!
SojaBird
Hey here,

Thanks for this.
I'll soon aply some new features including this one in a update.
I'll also add som extra features such as use the points for a different purpose instead of only the achievementshops.
Also more configuration will be added wink.gif

Let me know if there are more things people want to see in the upcomming version.
I'll be working on a scrpipt for a very long time so while I'm buzy I'll just do it.

Just reply here wink.gif


Greatzz,
SojaBird.
Dark Cape
It's working fine now. I did forget to put an extra =. Thanks leongon and SojaBird. wink.gif
Siyat
How do you add the menu label for "Achievements" while using your New Menu Items Engine? Or rather, how would you call your achievement script? Yeah, I'm a noob with Ruby. My background is C++ and Java.
SojaBird
Hey Siyat,

Nice to hear you are using my New Menu Items Engine.
When you use NMIengine and Achievements together, the menu-item is added through the script itself.
So you don't have to add that in the NMI confige yourself.


As for Dark Cape, good you fixed it.
Enjoy the script.


Greatzz,
SojaBird.
Dark Cape
I've got another slight problem. All the script is working fine but when I put in the script code:

Achief.new("My First Minigame!", "Complete your first minigame.", 63, false, false)

The alert window pops up to notify the achievement, but there is no icon. When I looked at the achievements menu, In the description was:

Complete your first minigame., 63, false, false,

Please help SojaBird.

EDIT: Sorted out the problem. Did the exact replica of screenshot 3, only I edited it to my customs. Thanks anyway, SojaBird.
SojaBird
Hey Dark Cape...

That's pretty odd realy.
When I put exactly the same code in my demo, it just works.
I'm not sure what causes the problemen sad.gif

Also a quick tip, if you add a new achievement with the Achief.new callscript, there are some default value's allready smile.gif
This is how it's set: Achief.new(NAME, DESCRIPTION, 0, false*, *, false)
Name and description must be set, icon is standard 0, hidden is standard false, icon hide is the same as the hidden (so if you set the achievment to be hidden, the icon is also by default), completed is also false by standard.

Anyway back to your question, I don't know realy what makes your problem to occure.
Make sue you got the right icon id, perhaps it's just a empty space?

Let me know.


Greatzz,
SojaBird.
XiaoGaGa
how do i customize it? after i copy it to the main script what do i do?
SojaBird
After you've copied the script before MAIN in the script-window, you should get in the script page you've just created and scroll down a little.
There you'll find the customazation part, wich have clear info how to change it.
The names will tell you what it's going to affect.

More customazation is comming soon in the new version.
I only need to add the shop option to buy real items and such with points.


Greatzz,
SojaBird.

ps. If there are more questions, I'll make a vid. tutorial soon wink.gif
Stickers
The script works great! But, I wanted to be able to access the page from a common event, not the menu. Is there a way for me to disable the menu link and call it with a script in a common event? Also, is there a way to have several databases so that you could have one for different type of tasks? I know its a lot, so you don't NEED to help me, but it would be much appreciated! thumbsup.gif
SojaBird
Hey hey,

Well I myself love this script as well smile.gif
So I like to work on this more!! So all suggestions are great biggrin.gif
Oke so yea, I could easely put an option in it that you can disable menu-linking.
The call-script will still be the same wink.gif
You can sure expect that in the next version wich will come realy soon.
The second request, that's more of a challenge but I'll still like to try it for sure biggrin.gif

Thanks for the tips and requests, I'll go and work on it smile.gif


Greatzz and enjoy,
SojaBird.
Whip Jr
i am new to scripting, i understand how to setup the achievement, but i wanna make it so you get achievements by beating a Rare enemy...say i had an achievement that was to kill a lynx, who was a rare enemy how would i code that? or rather where would i put the code i cant put it an an event can i?
SojaBird
Hey hey,

Oke so you can put a completion code in a event, that's totaly posible.
Though I'm not sure if it's posible from inside a monster event tab.
Have to check that.

Also I've tried to get some points for a tutorial, that's going to be out soon as well.
I'm going to cover all the seperate call-script codes in it, as well as the setup of the script.

@Whip Jr
The real awnser, put a call-script with Achief.complete("NAME") and it should complete the achievement when it runs that code.


Greatzz,
SojaBird.

ps. Got some more ideas for the script.
I'll have more time when I start with school again tomorrow biggrin.gif

ENJOY!!
Whip Jr
ph34r.gif that it does, i understand how to add+Complete using an event, i wanna know if you could setup a random encounter and still achieve the achievement? i am using the bestiary code if you know anything about that, maybe have a certain spot filled in? thanks for the help ph34r.gif
SojaBird
Hey hey,

Yea that is something I have to figure out.
Perhaps I'll have to write a new part off code for that, not sure though.
I'll have a look at it soon.
For now I can't find a sollution fast.

Keep your eye on the topic, it'll be included in the tutorial or the new update wink.gif


Greatzz,
SojaBird.
Whip Jr
coo thanks, im lookin forward to it thanks for the great work. thumbsup.gif
SojaBird
Oke so I am working on the version 3.0 of the script right now.
I found some interesting bugs with when I tried to combinate it with NewMenuItems.
So that one is getting an update as well so it can work correct again with Achievements.

A quick list what I need to do still:
  • NMI bug
  • Menu_Enabled option
  • Shop message BG remove
  • Moster kill achievement (use notefield)
  • Multiple classes (like Factions)
  • Points for items (use notefield)
  • (Money to buy new achievements?)


It's just a quick thing I pulled out of my script-help I made for myself to sort out the problems I have to fix.

Keep an sharp eye on the topic for the new version, it'll come soon.


Greatzz,
SojaBird.
Whip Jr
sounds sweet, i cant wait
SojaBird
Yea well I realy hope to be able to work on it again.
Luckly I got weekend right now so perhaps I'll go and sit for it sometime soon again.

For now make sure you check out this awsome movie: http://www.youtube.com/watch?v=dbaxoi-xlYc
I'm (a bit) sure you are going to like it for the time being tongue.gif

Enjoy (it's a school project of mine I made in 5-10 minutes).


Greatzz,
SojaBird.
Whip Jr
lol i like it, that is my kind of humor...lol, so hows it coming?
SojaBird
Haha good you like it.
I'll be posting a new project soon again.
This time it'll going to be me, flying in an airfighterjetplanething tongue.gif
Made with greenscreen smile.gif

For the script, I've worked on it a little.
Though I have some trouble with the ShopBG removal, have to find something for that still.
Though I'll think I start with the more easy parts soon first, so they are done and so the ShopBG can wait for some next minor update.

Anyway, keep an eye, I'll be posting that vid soon and the script will come as well (tomorrow I've got a day off again. Only have to pull myself from BioShock2 and I'll be fine and making scripts tomorrow biggrin.gif)


Greatzz,
SojaBird.
Whip Jr
QUOTE (SojaBird @ Feb 10 2010, 02:57 PM) *
Anyway, keep an eye, I'll be posting that vid soon and the script will come as well (tomorrow I've got a day off again. Only have to pull myself from BioShock2 and I'll be fine and making scripts tomorrow biggrin.gif)
.



sweet, i got it too, though i don't have a day off, I'm about to go and play right now...good so far
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.