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
SojaBird
Does the script work without Achievements?
If so... ... Perhaps put the script in a spoiler so I can check it out tongue.gif


xx
SojaBird.
Dreamerboy07
QUOTE (SojaBird @ Nov 8 2010, 06:27 PM) *
Does the script work without Achievements?
If so... ... Perhaps put the script in a spoiler so I can check it out tongue.gif


xx
SojaBird.



Hey thanks for a quisk reply, i have been playing around and reading everything i can find, and i noticed your NEW MENU ITEMS scripts i have now copy and pasted that into place,

i dont have pictures on my menu now tho sad.gif i did have pictures next to each word e.g (picture) items, (picture) skills etc.

they work now tho, when i click on skills or equip i have to press it twice, the first click freezes the screen and the second click opens the selection eg skills.

so all i need now is icons to appear and get rid of this freeze i can send script f you want for the place that is having error (as i shown in picture?)




UPDATE: i just tryed doing a spoiler but getting error for some reason i will post a link to down load the script kk if thats kk?


total script, i then added caterpiller script and your achivement script? :S
http://www.mediafire.com/?37eyl9bk9v9mfci
Dreamerboy07
ok im not so much bothered any more of the icons not there iv got used to it biggrin.gif

i also got rid of the freeze and having to double click all the time to open things....

my final thing is something SIMPLE probably....

NO.1.....i have this :

Start_Buyables = [
[10, "The 5th Time", "Slay the Ogre 5 times", 131]

Start_Conditions = [
["The 5th Time", "kills('Ogre') >= 5"]

Start_Points = [
["The 5th Time", 25]

Start_Labels = [
["The 5th Time", "Battle"]

When i open achivements up in the game i get the correct layout and everything except i get the fill bar empty of course but it says -999/5
and i cant seem to get that -999 to 0? its rather annoying? could someone please help?

and the second thing is super simple....but....

How do i make a shop....not a normal shop....but the shop or whatever so i can buy achivements in the game such as the one i just showed, as i tryed it as a normal achivement from start and found out about the -999 thing. if someone could explain in NOOB term how to make the shop thing etc

much appreciated thank you!!
SojaBird
Make sure you also close the things.
CODE
Start_Buyables = [
[10, "The 5th Time", "Slay the Ogre 5 times", 131]
]

Start_Conditions = [
["The 5th Time", "kills('Ogre') >= 5"]
]

Start_Points = [
["The 5th Time", 25]
]

Start_Labels = [
["The 5th Time", "Battle"]
]


Lucky you don't care 'bout the icons.
I might change the script so it also supports icons smile.gif New Menu Items that is biggrin.gif


Greatzz xx,
SojaBird.
leongon
...And actor selection. I ended making my own cuz you never upgrade yours Soja. I invite you to check mine, and if you include all that mine can do, yours will be the best menu manager ever.
SojaBird
Hey,

I had a look at your script... DANG it's awsome! biggrin.gif
Think I have to rewrite the whole NMI and get a new easy format with more features smile.gif

Well tnx for the awsome example.
You might want to pick the few things I have that you like 'bout the script (auto-add?) and incorporate them in your script?
Good luck!


Greatzz,
SojaBird.
leongon
I tried to understand back then how you made the auto add thing, but I'm not that good haha. That's why I tell you: If you add all that mine can do into yours, it will be the best one.
InfinateX
good job on ur script! The only problem I found was it was hard to use... I'm gonna stick with Omegas7's achievement script...
Deathtouch
alright, I have one achieve, work with step counter..

It WORKS, but there's a problem..

when I try to open the achievement menu in game, BEFORE the achievement is complete, i get a Syntax Error..

but I walk # steps, and the achievement completes, and NOW I can open the menu...

how to stop syntax error?
(This is all I've changed so far, except the ~show on startup~ thing.. but that has no effect..
CODE
  #-----------#
  # Start-up: #
  #-----------#
    Start_Achievements = [
     #["Name", "Description", *Icon, *Hidden, *Hide_Icon, *Completed]
      ["3sum", "Finish at least 3 achievements", 94, true],
      ["Started ones", "Complete '3sum' and 'Nr.4'", 85, true, false],
      ["Marathon Man", "Walk 5 steps.", 142],
      ["Money!!", "Gain at least 500 gold", 147]
    ]

CODE
    Start_Conditions = [
     #["Name", "Condition"]
      ["Started ones", "completed('3sum', 'Nr.4')"],
      ["3sum", "completed >= 3"],
      ["Marathon Man", "$game_party.steps >= 5"],
      ["Money!!", "gold >= 500"],
      ["High level: Ralph", "lvl(0) >= 6"],
      ["High level: Ulrika", "lvl(1) >= 6"],
      ["High level: Bennett", "lvl(2) >= 6"],
      ["High level: Ylva", "lvl(3) >= 6"],
      ["Imp Slayer", "kills('imp') >= 3"]
    ]

CODE
    Start_Colors = [
     #["Name", Color.new(red, green, blue, alpha = 255)]
      ["3sum", Color.new(100, 200, 30, 100)],
      ["Marathon Man", Color.new(130, 0, 125, 100)]
    ]
dricc
I was searching for a quest script ... this one is incredible . If i don't have compatibility issue , i will use it .

Just one thing : there is a small bug in the demo . The quest "Looser" is sometimes with one "o" and sometimes with 2 . So , we cannot complete the demo .

And a small advice : put the word "Quest" somewhere in the title of this topic wink.gif because when someone is searching for a script like yours , he put "quest script" in the search box .

I have some questions :
- Is there a newer version than this Beta 4.0 ?
- Why is there an image achief_new.png ? it seems it is not used .

Thanks .
SojaBird
Hey people,

Sorry that I haven't been responding in some time.
I've been quite buzy with other things and have kind of dropped the rpgmaker scene sadly enough sad.gif

Anyway, let's go ahead and see what I could do with the latest post.


@leongon
Tnx for al the fame and what not smile.gif
The auto-add thing... yea well I think it wasn't as hard to make though I'm not sure anymore since it's been such a long time ago.
Though I'm sure if you'll try to figure it out, you'll be gonna be a even more awsome scripter then you are today biggrin.gif Keep it up, don't loose fate smile.gif

@RPGMakerVX52
Thanks that you've tried out the script.
You're kind of right that it can be quite hard sometimes, specialy since it's not so very forgiving at sertain points.
Luckly you are oke with Omegas7, he's a great scripter as well (or well he was back in my active RRR days).

@Deathtouch
I'm gonna start up the thing and see if I can replicate your error smile.gif Just a sec
...*is looking at the codezzz*...
After looking at the code I just tried to fix it.
Seems that it can't be fixed with the current version so I've updated it to a BETA 4.0.c wich now can count steps.
Just use steps instead of the $game_party.steps and you'll be fine smile.gif

@dricc
Hey thanks for all the good words as a starter.
Sorry for the bug in the demo, it's that I'm dyslextic and also a not native english speaker wich most possible has caused this error.
It's just an other example of how unforgiving this script can be.
Tnx for the advie with the Quest thing, I'll put it in the topic-title right away.
I think it just dind't come to mind since the intention of the script wasn't to be used as a quest-log at first, though I do see the potential of the script being used as questting log smile.gif
Now on to the questions:
- Beta 4.0 currently is the newest version. Don't be fooled by the name though, it's fully functional as it is now though it can allways be improved. The name Beta is just a little thing I've added since it has passed alpha realy. It's just that I've never and will never set a marker on when a script is/was completed since I'd allways upgrade or expand it smile.gif
- The achief_new.png image was something I've had put in as experiment for a new feature. It would be put on ever new not seen achievement in the menu so the player could see wich achievements were new. After closing the menu the tag would go away, they had been seen after all. I'm not sure if I'll give this an other try, since I've got the pop-up system working now. Though just give a shout if you'd like to have this anyways and I'll see what I can do.


That's it for now smile.gif

Greatzz,
SojaBird.
lylat
hello, first of all congrats for your excellent script

I have a little problem with the achievements, when load a savegame the achievements are not updated, but when I start a new game if updated

Is there any way to fix this?

PD:sorry for my poor english
Suppercut
Nice script, but whenever I try to add my own achievements it kinda just dies on me. I get the following error:

Script 'Achievements' line 1286: RangeError occured.
float -1.#IND out of range of integer

My achievements list:
CODE
#-----------#
  # Start-up: #
  #-----------#
    Start_Achievements = [
     #["Name", "Description", *Icon, *Hidden, *Hide_Icon, *Completed]
      ["3sum", "Finish at least 3 achievements", 94, true],
      ["Started ones", "Complete '3sum' and 'Nr.4'", 85, true, false],
      ["Travel Power!", "Get any partymember up to level 12", 142],
      ["It Was Long Trip", "Walk 500 steps.", 142],
      ["OMFGMAN!", "Get brought back from stasis.", 94]
    ]
    
    Start_Buyables = [
     #[Price, "Name", "Description", Icon]
      [6, "Saving for Something Big", "Gain at least 1,000,000 dollars", 147],
      [8, "High level: Ralph", "Get Ralph to level 6", 14],
      [8, "High level: Ulrika", "Get Ulrika to level 6", 14],
      [8, "High level: Bennett", "Get Bennett to level 6", 14],
      [8, "High level: Ylva", "Get Ylva to level 6", 14],
      [5, "Imp Slayer", "Slay at least 3 Imp's", 131]
    ]
    
    Start_Conditions = [
     #["Name", "Condition"]
      ["Started ones", "completed('3sum', 'Nr.4')"],
      ["3sum", "completed >= 3"],
      ["Travel Power!", "lvl(-1) >= 12"],
      ["Saving for Something Big", "gold >= 500"],
      ["High level: Ralph", "lvl(0) >= 6"],
      ["High level: Ulrika", "lvl(1) >= 6"],
      ["High level: Bennett", "lvl(2) >= 6"],
      ["High level: Ylva", "lvl(3) >= 6"],
      ["Imp Slayer", "kills('imp') >= 3"],
      ["It Was Long Trip", "steps >= 500"],
      ["OMFGMAN!", "switch(81)==true"]
    ]
    
    Start_Rewards = [
     #["Name", "Reward"]
      ["3sum", "switch(3, true)"],
      ["Money!!", "item(4, 3)"],
      ["High level: Ralph", "gold(25)"],
      ["High level: Ulrika", "gold(25)"],
      ["High level: Bennett", "gold(25)"],
      ["High level: Ylva", "gold(25)"]
    ]
    
    Start_Points = [
     #["Name", Points]
      ["3sum", 3],
      ["Started ones", 7.5],
      ["Travel Power!", 4],
      ["Money!!", 10],
      ["Imp Slayer", 15],
      ["OMFGMAN!", 3]
    ]
    
    Start_Labels = [
     #["Name", "Label"]
      ["Travel Power!", "Character"],
      ["High level: Ralph", "Character"],
      ["High level: Ulrika", "Character"],
      ["High level: Bennett", "Character"],
      ["High level: Ylva", "Character"],
      ["Imp Slayer", "Battle"]
    ]
    
    Start_Colors = [
     #["Name", Color.new(red, green, blue, alpha = 255)]
      ["3sum", Color.new(100, 200, 30, 100)],
      ["Travel Power!", Color.new(130, 0, 125, 100)],
      ["It Was Long Trip", Color.new(130, 0, 125, 100)],
      ["OMFGMAN!", Color.new(100, 200, 30, 100)]
    ]
    
end
#-------------#
# Module: End #
#-------------#
SojaBird
@lylat
Hey hey.
Did you added the script and the loaded a older save game without the achievement script?
Try and start a new game to see if that helps.
If not, what other scripts are you using.

@Suppercut
That truely is quite odd.
I can't find it right away now.
Could you sent me the whole script or mark where the 1286 line is smile.gif


Cheers,
SojaBird.
Suppercut
It appears to be having the problem here:

CODE
def draw_progress_bar(fill, x, y)
    gw  = @draw_width2 * fill
    gc0 = Bar_Back_Color
    gc1 = Bar_Fill_Color_1
    gc2 = Bar_Fill_Color_2
    self.contents.fill_rect(         x, y + WLH - 8, @draw_width2, 6, gc0)
    self.contents.gradient_fill_rect(x, y + WLH - 8, gw,           6, gc1, gc2) # << 1286 is where the error points to
  end


Is it possibly because the achievement is a switch?

Also, how can I check if a specific party member has equipped a specific weapon or armor?
lylat
QUOTE (SojaBird @ May 17 2011, 01:12 PM) *
@lylat
Hey hey.
Did you added the script and the loaded a older save game without the achievement script?
Try and start a new game to see if that helps.
If not, what other scripts are you using.

@Suppercut
That truely is quite odd.
I can't find it right away now.
Could you sent me the whole script or mark where the 1286 line is smile.gif


Cheers,
SojaBird.


not a problem of another script, also I tried with the demo,I created a new savegame and one new achievement ,later I load the savegame but this new achievement does not appear sad.gif
SojaBird
@Supercut
You might be right about the error, cause it's a switch.
I know this isn't quite neat from my side, though seems like you just can't have a progressionbar with a switch since it only has TRUE or FALSE as value, not a integer (like a number).

For the equip things, you can't right now.
Not sure if I'm going to add it, sorry.


@lylat
If you want to add a achievement in the scriptwindow, they will only be created on start-up.
Addition achievements can be added during the game using events.
If you go into the demo, then save, then go back to the script editor and add achievements there, and load the savegame, the add ones won't appear in your loadgame since they haven't been created during the start of the game.
That might be your problem.
So what you should do:
- Add achievements in the script editor.
- Start a new game.
- Save.
- Load.

If you want to add achievements during the game, use events like shown in the demo.



Greatings and good luck,
SojaBird.
Suppercut
Please please please please please please PLEASE fix it. Or even better, move the option for no progress bar to individual achievements, cuz I really need achievements with switches, so I can have for example "find so-and-so" or "do such-and-such" achievements.

And yes, I seem to be having the problem only with switches. All other achievements (STICKEH: Aquire stick; ...or an Exceedingly Rare Item!: Get a King's sword; etc etc) are fine.

Also, quick question...How do you make the achievements shop sell items like weapons, armor, etc?
Dogghy
Can someone help me?
What's wrong with this part of the script?

CODE
   Start_Achievements = [
     #["Name", "Description", *Icon, *Hidden, *Hide_Icon, *Completed]
      ["3sum", "Finish at least 3 achievements", 94, true],
      ["Nr.4", "Get any partymember up to level 4", 142],
      ["Argilla!", "Elemento Scoperto", 0, true],
      ["Mattone!", "Elemento Scoperto", 0, true],
      ["Isola!", "Elemento Scoperto", 0, true]
    ]
    
    Start_Buyables = [
     #[Price, "Name", "Description", Icon]
      [6, "Money!!", "Gain at least 500 gold", 147],
      [8, "High level: Ralph", "Get Ralph to level 6", 14],
      [8, "High level: Ulrika", "Get Ulrika to level 6", 14],
      [8, "High level: Bennett", "Get Bennett to level 6", 14],
      [8, "High level: Ylva", "Get Ylva to level 6", 14],
      [5, "Imp Slayer", "Slay at least 3 Imp's", 131]
    ]
    
    Start_Conditions = [
     #["Name", "Condition"]
      ["3sum", "completed >= 3"],
      ["Nr.4", "lvl(-1) >= 4"],
      ["Money!!", "gold >= 500"],
      ["Argilla!", "item(005) >= 1"],
      ["Mattone!" , "item(006) >= 1"],
      ["Isola!" , "item(009) >= 1"],
      ["High level: Ralph", "lvl(0) >= 6"],
      ["High level: Ulrika", "lvl(1) >= 6"],
      ["High level: Bennett", "lvl(2) >= 6"],
      ["High level: Ylva", "lvl(3) >= 6"],
      ["Imp Slayer", "kills('imp') >= 3"]
    ]
    
    Start_Rewards = [
     #["Name", "Reward"]
      ["3sum", "switch(3, true)"],
      ["Money!!", "item(4, 3)"],
      ["Argilla!", "gold(50)"],
      ["Mattone!", "gold(50)"],
      ["Isola!", "gold(50)"],
      ["High level: Ralph", "gold(25)"],
      ["High level: Ulrika", "gold(25)"],
      ["High level: Bennett", "gold(25)"],
      ["High level: Ylva", "gold(25)"]
    ]
    
    Start_Points = [
     #["Name", Points]
      ["3sum", 3],
      ["Started ones", 7.5],
      ["Nr.4", 4],
      ["Money!!", 10],
      ["Imp Slayer", 15]
    ]
    
    Start_Labels = [
     #["Name", "Label"]
      ["Nr.4", "Character"],
      ["High level: Ralph", "Character"],
      ["High level: Ulrika", "Character"],
      ["High level: Bennett", "Character"],
      ["High level: Ylva", "Character"],
      ["Imp Slayer", "Battle"]
    ]
    
    Start_Colors = [
     #["Name", Color.new(red, green, blue, alpha = 255)]
      ["3sum", Color.new(100, 200, 30, 100)],
      ["Nr.4", Color.new(130, 0, 125, 100)]
    ]
    
end


When I press "New Game" i got "SyntaxError occurred while running script".
Why?
SmexiCrayon
I get this error:
"Script 'Achievements' line 2071: NoMethodError occurred.

undefined method 'each_value' for nil:NilClass."
I haven't changed anything in the script.
Suppercut
QUOTE (Dogghy @ Jun 14 2011, 02:42 PM) *
Can someone help me?
What's wrong with this part of the script?

CODE
   Start_Achievements = [
     #["Name", "Description", *Icon, *Hidden, *Hide_Icon, *Completed]
      ["3sum", "Finish at least 3 achievements", 94, true],
      ["Nr.4", "Get any partymember up to level 4", 142],
      ["Argilla!", "Elemento Scoperto", 0, true],
      ["Mattone!", "Elemento Scoperto", 0, true],
      ["Isola!", "Elemento Scoperto", 0, true]
    ]
    
    Start_Buyables = [
     #[Price, "Name", "Description", Icon]
      [6, "Money!!", "Gain at least 500 gold", 147],
      [8, "High level: Ralph", "Get Ralph to level 6", 14],
      [8, "High level: Ulrika", "Get Ulrika to level 6", 14],
      [8, "High level: Bennett", "Get Bennett to level 6", 14],
      [8, "High level: Ylva", "Get Ylva to level 6", 14],
      [5, "Imp Slayer", "Slay at least 3 Imp's", 131]
    ]
    
    Start_Conditions = [
     #["Name", "Condition"]
      ["3sum", "completed >= 3"],
      ["Nr.4", "lvl(-1) >= 4"],
      ["Money!!", "gold >= 500"],
      ["Argilla!", "item(005) >= 1"],
      ["Mattone!" , "item(006) >= 1"],
      ["Isola!" , "item(009) >= 1"],
      ["High level: Ralph", "lvl(0) >= 6"],
      ["High level: Ulrika", "lvl(1) >= 6"],
      ["High level: Bennett", "lvl(2) >= 6"],
      ["High level: Ylva", "lvl(3) >= 6"],
      ["Imp Slayer", "kills('imp') >= 3"]
    ]
    
    Start_Rewards = [
     #["Name", "Reward"]
      ["3sum", "switch(3, true)"],
      ["Money!!", "item(4, 3)"],
      ["Argilla!", "gold(50)"],
      ["Mattone!", "gold(50)"],
      ["Isola!", "gold(50)"],
      ["High level: Ralph", "gold(25)"],
      ["High level: Ulrika", "gold(25)"],
      ["High level: Bennett", "gold(25)"],
      ["High level: Ylva", "gold(25)"]
    ]
    
    Start_Points = [
     #["Name", Points]
      ["3sum", 3],
      ["Started ones", 7.5],
      ["Nr.4", 4],
      ["Money!!", 10],
      ["Imp Slayer", 15]
    ]
    
    Start_Labels = [
     #["Name", "Label"]
      ["Nr.4", "Character"],
      ["High level: Ralph", "Character"],
      ["High level: Ulrika", "Character"],
      ["High level: Bennett", "Character"],
      ["High level: Ylva", "Character"],
      ["Imp Slayer", "Battle"]
    ]
    
    Start_Colors = [
     #["Name", Color.new(red, green, blue, alpha = 255)]
      ["3sum", Color.new(100, 200, 30, 100)],
      ["Nr.4", Color.new(130, 0, 125, 100)]
    ]
    
end


When I press "New Game" i got "SyntaxError occurred while running script".
Why?


Take off those extra 0's in the conditions, it should just be item(5)==1.
Dogghy
QUOTE (Suppercut @ Jun 14 2011, 05:51 PM) *
QUOTE (Dogghy @ Jun 14 2011, 02:42 PM) *
Can someone help me?
What's wrong with this part of the script?

CODE
   Start_Achievements = [
     #["Name", "Description", *Icon, *Hidden, *Hide_Icon, *Completed]
      ["3sum", "Finish at least 3 achievements", 94, true],
      ["Nr.4", "Get any partymember up to level 4", 142],
      ["Argilla!", "Elemento Scoperto", 0, true],
      ["Mattone!", "Elemento Scoperto", 0, true],
      ["Isola!", "Elemento Scoperto", 0, true]
    ]
    
    Start_Buyables = [
     #[Price, "Name", "Description", Icon]
      [6, "Money!!", "Gain at least 500 gold", 147],
      [8, "High level: Ralph", "Get Ralph to level 6", 14],
      [8, "High level: Ulrika", "Get Ulrika to level 6", 14],
      [8, "High level: Bennett", "Get Bennett to level 6", 14],
      [8, "High level: Ylva", "Get Ylva to level 6", 14],
      [5, "Imp Slayer", "Slay at least 3 Imp's", 131]
    ]
    
    Start_Conditions = [
     #["Name", "Condition"]
      ["3sum", "completed >= 3"],
      ["Nr.4", "lvl(-1) >= 4"],
      ["Money!!", "gold >= 500"],
      ["Argilla!", "item(005) >= 1"],
      ["Mattone!" , "item(006) >= 1"],
      ["Isola!" , "item(009) >= 1"],
      ["High level: Ralph", "lvl(0) >= 6"],
      ["High level: Ulrika", "lvl(1) >= 6"],
      ["High level: Bennett", "lvl(2) >= 6"],
      ["High level: Ylva", "lvl(3) >= 6"],
      ["Imp Slayer", "kills('imp') >= 3"]
    ]
    
    Start_Rewards = [
     #["Name", "Reward"]
      ["3sum", "switch(3, true)"],
      ["Money!!", "item(4, 3)"],
      ["Argilla!", "gold(50)"],
      ["Mattone!", "gold(50)"],
      ["Isola!", "gold(50)"],
      ["High level: Ralph", "gold(25)"],
      ["High level: Ulrika", "gold(25)"],
      ["High level: Bennett", "gold(25)"],
      ["High level: Ylva", "gold(25)"]
    ]
    
    Start_Points = [
     #["Name", Points]
      ["3sum", 3],
      ["Started ones", 7.5],
      ["Nr.4", 4],
      ["Money!!", 10],
      ["Imp Slayer", 15]
    ]
    
    Start_Labels = [
     #["Name", "Label"]
      ["Nr.4", "Character"],
      ["High level: Ralph", "Character"],
      ["High level: Ulrika", "Character"],
      ["High level: Bennett", "Character"],
      ["High level: Ylva", "Character"],
      ["Imp Slayer", "Battle"]
    ]
    
    Start_Colors = [
     #["Name", Color.new(red, green, blue, alpha = 255)]
      ["3sum", Color.new(100, 200, 30, 100)],
      ["Nr.4", Color.new(130, 0, 125, 100)]
    ]
    
end


When I press "New Game" i got "SyntaxError occurred while running script".
Why?


Take off those extra 0's in the conditions, it should just be item(5)==1.


Thank you mate, it works.
SojaBird
@Suppercut
You can actualy set the bar for each achievement individualy.
For some reason I though that it used to be working for the auto-bar, since it recognize what type of condition it is... odd.
Guess I'm wrong.

I'll have a look at this later this month.


@SmexiCrayon
This is just a wild guess but... are you using other scripts?
It seems that the achievement-list hasn't been loaded yet when the game starts, make sure you have achievements below any script which might modify the the main-menu (this would meen that script menuscript that is used isn't scripted properly to be compatible whith any other script).



Cheers,
SojaBird.
SmexiCrayon
I have it under everything. Oh well, I'm working on a new game and I'll see if it works with just that as a script.
Suppercut
QUOTE (SojaBird @ Jun 15 2011, 01:15 AM) *
You can actualy set the bar for each achievement individualy.

How?
SojaBird
Something when setting the condition, add a true statement at the end.
Read the help in the script to fiddle it out wink.gif
InfinateX
This seems more like a quest system form the demo >.>
Nariakei
Okay, there's this one syntax error i get when I use this script... But i found the problem by myself and i wondered if it could be fixed for future users of the script o:
So, when I put the script into my scriptdatabase (without modifing it) and I start a new game, I get a syntax error because I started the game without a character.
I always start my rpgs without characters, for intros and stuff.
And that's where the problem lies, when I start a new game with a character in the party, I don't get an error and it works fine. smile.gif
I don't know how to script, so i don't know how i could fix this, but at least i can tell you people about this.
Thanks for the script, it's one of my favorite RPXP scripts biggrin.gif
Kouta
teamtns
Hey...I am teamTNS...obviously.
Anyways I have been wanting to use something like your script...and I think your script is awesome XD...but for some reason when I try to alter it I get the following error: NoMethodError occurred. undefined method 'bg_color=' for nil:NilClass
now it is line 460-469 (somewhere in there I forget now...The thing is I have no idea whats wrong...I am somewhat of a programmer (not much experience with Ruby or RGSS2, mostly C++)...anyways I have looked through it a couple times but I have no idea where to even look, mostly just because I wasn't the one who wrote this script lol. Its not a huge deal or anything I'm just trying to figure it out, I want to finish my game because I want to work on something else (mostly because I want to work on a different engine) but I hate not finishing things and I think this would be a nice touch to it. Well enough rambling here is your script edited by me and I will show the line that is coming up with errors.

CODE
=begin
New in the BETA update:
- NMI bug
- Menu_Enabled option
- Shop message BG remove
- Multiple classes (tabs)
- Call script message BG remove
- Enable/disable sort achievements
- Check monster kills /battles achievement
- Buy items/weapons/armor with points (but not sell items for points)
- Exchange points to gold (with custom change rate)
- Progression bar (works for 1st condition)
- Better integration when using the pointsystem with decimal amounts
- Option to custom backgroundcolor for achievements (also for label)
- Multible tab-rows
- New layout style to choose

New in the full-release (is being worked on, in order of relevance):
- Notificate new achievements when opening
- Exchange confirmation text (in rate-window)
- Describe more features (like add_points etc)
- Buy skills with points (as items/weapons/armor, but character choose)
- Buy achievements for money
- Factions achievements (add-on?)
=end

#------------------------------------------------------------------------------#
# Name:    Achievements                                                        #
# By:      SojaBird                                                            #
# Version: BETA 4.0.c                                                          #
#                                                                              #
# Date:    25-02-11                                                            #
#------------------------------------------------------------------------------#

$imported ||= {}
$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)
# - kills('note_tag') : >=, ==, !=     # (use Achief(note_tag) in the notefiels)
# - battle(result)    : >=, <=, ==, != # (0: win, 1: escape, 2:lose, 3:all)
# - steps             : >=, <=, ==, != #
# - 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)       : true               #
# - Achief.call_shop(*reveal_cost) : Common_Reveal_Cost #
# - Achief.point_shop              : > Normal shop setup but spent points, not G
#----------------------------------#--------------------#

#----------------------#
# Configuration Module #
#----------------------#
module SojaBird_Achievements
  
  #-------#
  # Menu: #
  #-------#
    Menu_Enabled       = true
    Menu_Location      = 4
    Menu_Title         = "Achievements"
    Menu_Counting      = false
    
  #---------------------#
  # Achievements Scene: #
  #---------------------#
    # 0-1
    Layout_Style       = 0
    
    Scroll_Speed       = 5
    Border_Size        = 5
    
    Auto_Scroll        = true
    Auto_Scroll_Speed  = 0.1
    Time_Span          = 4
    
    Alphabetic_Achiefs = false
    
    #-- Progression --#
    Auto_Bar_On        = true
    
    # Color.new(red, green, blue, alpha = 255)
    Bar_Back_Color     = Color.new(170, 170, 220)
    Bar_Fill_Color_1   = Color.new(255, 102, 0)
    Bar_Fill_Color_2   = Color.new(204, 255, 51)
    
    #-- Tab Control --#
    Name_Tabs          = ["Story","Extra"]
    Tab_Row_Amount     = 1
    All_Tab_Name       = "All"
    Hidden_in_All      = false
    Completed_in_All   = true
    Completed_in_Tabs  = false
    Enable_Completed   = true
    Completed_Tab      = "Completed"
    Enable_Hidden      = true
    Hidden_Tab         = "Secret"
    Alphabetic_Tabs    = false
    Enable_if_Empty    = false
    Label_Colors       = {
    #"Labelname" => Color.new(red, green, blue, alpha = 255),
      "Story" => Color.new(30, 200, 50, 100),
      "Extra" => Color.new(255, 90, 100, 100),
      "Secret" => Color.new(20, 20, 20, 100)
    }
    
    # Color.new(red, green, blue, alpha = 255)
    BG_Color           = Color.new(0, 190, 255, 100)
    Border_Color       = Color.new(0, 0, 0)
    Text_Color         = Color.new(255, 255, 255)
    
    Title_Size         = 20
    Description_Size   = 20
    
  #----------------------#
  # Hidden Achievements: #
  #----------------------#
    Hidden_Title       = "???"
    Hidden_Description = "Not enough completed."
    Hidden_Icon        = 152
    
  #----------------------#
  # Achievements Alerts: #
  #----------------------#
    Enable_Alerts      = true
  
    module SE_Found
      Name   = "" #place achievement sound file name here when done with music
      Volume = 0 #make 50
      Pitch  = 0
    end
    
    module SE_Complete
      Name   = "" #for when achievement is completed
      Volume = 0
      Pitch  = 0
    end
    
    # normal/up/down
    Alert_Display      = "normal"
    Alert_Opacity      = 200
    # left/center/right
    Alert_Position     = "center"
    Alert_Width        = 300
    Alert_Reward_Width = 544
    Alert_Font_Size    = 16
    
    Complete_Text      = "Achievement: %s!"
    Reward_Text        = "You've gained %s!"
    Find_Text          = "Achievement '%s' was found!"
    Hidden_Found       = "You've unlocked a hidden achievement!"
    
    # for normal display
    Time_Span_Text     = 4
    
    Display_StartUps   = false
    Reward_Prototype   = false
    
  #---------------#
  # Message Tags: #
  #---------------#
    Message_Points_Tag = "AP"
    #Use \Message_Points_Tag
    Message_Kills_Tag  = "AK"
    #Use \Message_Kills_Tag[note_tag]
    Message_Battle_Tag = "AB"
    #Use \Message_Battle_Tag[0(win)/1(escape)/2(lose)/3(all)]
    
  #---------------#
  # Point System: #
  #---------------#
    Use_Point_System   = true
    Point_Name         = "Kread"
    Point_Font_Size    = 12
    
    Shop_Buy           = "Gain"
    Shop_Reveal        = "Reveal"
    Common_Reveal_Cost = 5
    
    Status_Text        = "Completed: %s"
    
    #-- Exchange Control --#
    Show_Rate_Bar   = false
    Exchange_Rate   = "Rate: %s points to %s gold"
    Amount_Dispaly  = "%s > %s"
    Accept_Exchange = "Accept"
    Set_Exchange    = "Set"
    Cancel_Exchange = "Cancel"
    
  #-----------#
  # Start-up: #
  #-----------#
    Start_Achievements = [
     #["Name", "Description", *Icon, *Hidden, *Hide_Icon, *Completed]
      ["Started ones", "Complete '3sum' and 'Nr.4'", 85, true, false],
      ["Nr.4", "Get any partymember up to level 4", 142],
      ["Marathon Man", "Walk 5 steps.", 142]
    ]
    
    Start_Buyables = [
     #[Price, "Name", "Description", Icon]
      [6, "Money!!", "Gain at least 500 gold", 147],
      [8, "High level: Ralph", "Get Ralph to level 6", 14],
      [8, "High level: Ulrika", "Get Ulrika to level 6", 14],
      [8, "High level: Bennett", "Get Bennett to level 6", 14],
      [8, "High level: Ylva", "Get Ylva to level 6", 14],
      [5, "Imp Slayer", "Slay at least 3 Imp's", 131]
    ]
    
    Start_Conditions = [
     #["Name", "Condition"]
      ["Started ones", "completed('3sum', 'Nr.4')"],
      ["3sum", "completed >= 3"],
      ["Nr.4", "lvl(-1) >= 4"],
      ["Money!!", "gold >= 500"],
      ["High level: Ralph", "lvl(0) >= 6"],
      ["High level: Ulrika", "lvl(1) >= 6"],
      ["High level: Bennett", "lvl(2) >= 6"],
      ["High level: Ylva", "lvl(3) >= 6"],
      ["Imp Slayer", "kills('imp') >= 3"],
      ["Marathon Man", "steps >= 5"]
    ]
    
    Start_Rewards = [
     #["Name", "Reward"]
      ["3sum", "switch(3, true)"],
      ["Money!!", "item(4, 3)"],
      ["High level: Ralph", "gold(25)"],
      ["High level: Ulrika", "gold(25)"],
      ["High level: Bennett", "gold(25)"],
      ["High level: Ylva", "gold(25)"]
    ]
    
    Start_Points = [
     #["Name", Points]
      ["3sum", 3],
      ["Started ones", 7.5],
      ["Nr.4", 4],
      ["Money!!", 10],
      ["Imp Slayer", 15]
    ]
    
    Start_Labels = [
     #["Name", "Label"]
      ["Nr.4", "Character"],
      ["High level: Ralph", "Character"],
      ["High level: Ulrika", "Character"],
      ["High level: Bennett", "Character"],
      ["High level: Ylva", "Character"],
      ["Imp Slayer", "Battle"]
    ]
    
    Start_Colors = [
     #["Name", Color.new(red, green, blue, alpha = 255)]
      ["3sum", Color.new(100, 200, 30, 100)],
      ["Nr.4", Color.new(130, 0, 125, 100)],
      ["Marathon Man", Color.new(130, 0, 125, 100)]
    ]
    
end
#-------------#
# Module: End #
#-------------#

#--------------------#
# Call-script module #
#--------------------#
module Achief
  
  include SojaBird_Achievements
  #--------------------------------------------------------------------------#
  # 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 unless self.achievement(name).nil?
    $game_system.achievements[name] = Achievement.new(name, description, icon,
                                                      hidden, hide_icon,
                                                      completed)
    self.add_achief_order(name)
  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 unless self.achievement_buyable(name).nil?
    $game_system.achief_buyables[name] = Achievement_Buyable.new(price, name,
                                                                 description,
                                                                 icon)
  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))
  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) unless achief.rewarded
      self.gain_points(name) unless achief.points_gained and Use_Point_System
    end
  end
  
  #--------------------------------------------------------------------------#
  # Achief.condition(name, condition, *bar)                                  #
  #   - name:      Name of the achievement (string)                          #
  #   - condition: Set the condition when to complete a achievement (string) #
  #   - bar:       Enable the use of the progressionbar (boolean)            #
  #--------------------------------------------------------------------------#
  def self.condition(name, condition, bar = Auto_Bar_On)
    name.gsub!(/\n/) {""}
    achief   = self.achievement(name)
    achief ||= self.achievement_buyable(name)
    return if achief.nil?
    condition.gsub!(/\n/) {""}
    listener                   = Completion_Listener.new(condition)
    achief.completion_listener = listener
    achief.bar                 = listener.progression.nil? ? false : bar
  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)
    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)
    return if achief.nil?
    achief.points = amount
  end
  
  #--------------------------------------------------------------------------#
  # Achief.label(name, label)                                                #
  #   - name:  Name of the achievement (string)                              #
  #   - label: Type(s) of achievement to sort in menu-tabs (string/array)    #
  #--------------------------------------------------------------------------#
  def self.label(name, label)
    achief   = self.achievement(name)
    achief ||= self.achievement_buyable(name)
    return if achief.nil?
    achief.label = label
  end
  
  #--------------------------------------------------------------------------#
  # Achief.label_more(name, label)                                           #
  #   - names: Names of the achievements (array)                             #
  #   - label: Type(s) of achievement to sort in menu-tabs (string/array)    #
  #--------------------------------------------------------------------------#
  def self.label_more(names, label)
    names.each {|achief| self.label(achief, label)}
  end
  
  #--------------------------------------------------------------------------#
  # Achief.bg_color(name, color)                                             #
  #   - names: Name of the achievements (string)                             #
  #   - color: Backgroundcolor that the achievements should get (Color.new)  #
  #--------------------------------------------------------------------------#
  def self.bg_color(name, color)
    achief          = self.achievement(name)
    achief.bg_color = color
  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_labels if Achief.get_all_tabs.size > 1
    create_points if Use_Point_System
    create_achievements
    enable_states if Achief.get_all_tabs.size > 1
    new_open_time
    scroll_dir
  end
  
  def create_labels
    commands = Achief.get_all_tabs
    case Achief.get_layout
    when 0; width = Graphics.width
    when 1
      dummy = Window_Base.new(0, 0, Graphics.width, Graphics.height)
      array = []
      commands.each {|i| array.push(dummy.contents.text_size(i).width)}
      width = [array.max + 32, Graphics.width/3].min
      dummy.dispose
    end
    @labels       = Window_Command_Labels.new(commands, width)
    @labels.index = $game_system.achievements.size > 0 ? 0 : -1
  end
  
  def create_points
    case Achief.get_layout
    when 0
      x     = 0
      y     = Graphics.height - 56
      width = Graphics.width
    when 1
      x     = 0
      y     = @labels.height
      width = @labels.width
    end
    @point_system = Window_Point_Currency.new(x, y, width)
  end
  
  def create_achievements(label = All_Tab_Name)
    @achievements = Window_Achievements.new(label, @labels.width)
  end
  
  def enable_states
    if Enable_if_Empty
      return @labels.commands.each_index {|i| @labels.enables.push(i)}
    end
    @labels.commands.each_index do |index|
      enabled = (@achievements.enable?(@labels.commands[index]) > 0)
      @labels.draw_item(index, enabled)
      @labels.enables.push(index) if enabled
    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
    dispose_labels unless @labels.nil?
  end
  
  def dispose_achievements
    @achievements.dispose
    @point_system.dispose if Use_Point_System
  end
  
  def dispose_labels
    @labels.dispose
  end
  
  def update
    super
    update_menu_background
    update_achievements
    update_labels unless @labels.nil?
  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 update_labels
    refresh if @labels.commands[@labels.index] != @achievements.sort_label
    @labels.update
  end
  
  def refresh
    @achievements.dispose
    create_achievements(@labels.commands[@labels.index])
  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) or
            Input.press?(Input::LEFT) or
            Input.press?(Input::RIGHT))
  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
      #NMI included
        for a in 0..$Menu_Items.size - 1
          if $Menu_Items[a][0].include?(Menu_Title)
            break name = $Menu_Items[a][0]
          end
        end
        super(name)
      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)
    Achief.lose_points(item.price)
    $game_system.achievements[item.name] = item.clone
    buyable = $game_system.achief_buyables
    buyable.delete(buyable.index(item))
    Achief.add_achief_order(item.name)
  end
  
  def reveal_achievement(item)
    Achief.lose_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 > Achief.get_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 > Achief.get_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 #
#------------------------------#

#-------------------#
# Points shop class #
#-------------------#
class Scene_Shop_Points < Scene_Shop
  
  def start
    super
    create_menu_background
    create_command_window
    @help_window             = Window_Help.new
    @gold_window             = Window_Point_Currency.new(384, 56, 160, true)
    @dummy_window            = Window_Base.new(0, 112, 544, 304)
    @buy_window              = Window_ShopBuy_Points.new(0, 112)
    @buy_window.active       = false
    @buy_window.visible      = false
    @buy_window.help_window  = @help_window
    @sell_window             = Window_ShopSell.new(0, 112, 544, 304)
    @sell_window.active      = false
    @sell_window.visible     = false
    @sell_window.help_window = @help_window
    @number_window           = Window_ShopNumber_Points.new(0, 112)
    @number_window.active    = false
    @number_window.visible   = false
    @status_window           = Window_ShopStatus.new(304, 112)
    @status_window.visible   = false
  end
  
  alias points_ucs :update_command_selection
  def update_command_selection
    points_ucs
    if Input.trigger?(Input::B) or
      (Input.trigger?(Input::C) and @command_window.index == 2)
      $game_temp.point_currency = false
    end
  end
  
  def update_buy_selection
    @status_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @dummy_window.visible  = true
      @buy_window.active     = false
      @buy_window.visible    = false
      @status_window.visible = false
      @status_window.item    = nil
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      number = $game_party.item_number(@item)
      if @item.nil? or @item.price > Achief.get_points or number == 99
        Sound.play_buzzer
      else
        Sound.play_decision
        max = @item.price == 0 ? 99 : Achief.get_points / @item.price
        max = [max, 99 - number].min
        @buy_window.active  = false
        @buy_window.visible = false
        @number_window.set(@item, max, @item.price)
        @number_window.active  = true
        @number_window.visible = true
      end
    end
  end
  
  def decide_number_input
    Sound.play_shop
    @number_window.active  = false
    @number_window.visible = false
    case @command_window.index
    when 0 #Buy
      Achief.lose_points(@number_window.number * @item.price)
      $game_party.gain_item(@item, @number_window.number)
      @gold_window.refresh
      @buy_window.refresh
      @status_window.refresh
      @buy_window.active  = true
      @buy_window.visible = true
    when 1 #Sell
      Achief.add_points(@number_window.number * (@item.price / 2))
      $game_party.lose_item(@item, @number_window.number)
      @gold_window.refresh
      @sell_window.refresh
      @status_window.refresh
      @sell_window.active    = true
      @sell_window.visible   = true
      @status_window.visible = false
    end
  end
  
end
#------------------------#
# Scene_Shop_Points: End #
#------------------------#

#----------------------#
# Point exchange class #
#----------------------#
class Scene_Point_Exchange < Scene_Base
  
  include SojaBird_Achievements
  
  def initialize(rate, swap)
    @rate         = rate
    @display_rate = (swap ? !Show_Rate_Bar : Show_Rate_Bar)
  end
  
  def help_add
    return @display_rate ? 56 : 0
  end
  
  def start
    super
    @_w  = 172
    @r_h = 56
    @_y  = Graphics.height/2 - (@r_h + help_add + 104)/2
    @_x  = Graphics.width/2  -  @_w/2
    
    create_menu_background
    create_command_window
    @command_window.active = true
    @command_window.index  = 1
    @command_window.x      = @_x
    @rate_window           = Window_Point_Exchange.new(@rate,
                                                       @_x,
                                                       @_y + help_add,
                                                       @_w,
                                                       @r_h)
    @rate_window.active = false
    return unless @display_rate
    @help_window = Window_Exchange_Help.new(@_x, @_y, @_w)
    @help_window.set_text(sprintf(Exchange_Rate, @rate[0], @rate[1]), 1)
  end
  
  def create_command_window
    s1                = Accept_Exchange
    s2                = Set_Exchange
    s3                = Cancel_Exchange
    @command_window   = Window_Exchange_Command.new(@_w, [s1, s2, s3])
    @command_window.y = @_y + help_add + @r_h
  end
  
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @rate_window.dispose
    @help_window.dispose if @display_rate
  end
  
  def update
    super
    update_menu_background
    @command_window.update
    @rate_window.update
    if @command_window.active; update_command_selection
    elsif @rate_window.active; update_rate_selection
    end
  end
  
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0 #Accept
        return Sound.play_buzzer if @rate_window.amount == 0
        Sound.play_decision
        points_to_gold
        @rate_window.set(0)
        @command_window.index = 1
      when 1 #Set
        Sound.play_decision
        @old_amount            = @rate_window.amount
        @command_window.active = false
        @rate_window.active    = true
      when 2 #Cancel
        Sound.play_decision
        $scene = Scene_Map.new
      end
    end
  end
  
  def points_to_gold
    Achief.lose_points(@rate[0] * @rate_window.amount)
    $game_party.gain_gold(@rate[1] * @rate_window.amount)
  end
  
  def update_rate_selection
    if Input.trigger?(Input::B) or Input.trigger?(Input::C)
      @rate_window.active    = false
      @command_window.active = true
    end
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @rate_window.set(@old_amount)
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      @command_window.index = (@rate_window.amount == 0 ? 2 : 0)
    end
  end
  
end
#---------------------------#
# Scene_Point_Exchange: End #
#---------------------------#

#----------------------------#
# Achievements DISPLAY class #
#----------------------------#
class Window_Achievements < Window_Base
  
  include SojaBird_Achievements
  
  attr_reader :sort_label
  
  def initialize(sort_label, label_info = 0)
    @sort_label = sort_label
    x, y, width, height = 0, 0, Graphics.width, Graphics.height
    case Achief.get_layout
    when 0
      height -= 32 + WLH if Use_Point_System
      if Achief.get_all_tabs.size > 1
        y      += 32 + (WLH * Achief.tabs_row_amount)
        height -= 32 + (WLH * Achief.tabs_row_amount)
      end
    when 1
      if Achief.get_all_tabs.size > 1 or Use_Point_System
        x     += label_info
        width -= label_info
      end
    end
    super(x, y, width, height)
    @font_size = self.contents.font.size
    refresh
  end
  
  def refresh
    self.contents.clear
    @border             = 16
    @bar_height         = WLH
    @line_size          = Border_Size
    @line_size          = 16 if @line_size > @border
    @achievement_height = (2 * WLH) + (2 * @border) - @line_size
    @icon_displace      = 32 + @border
    make_sort_list
    height  = $game_temp.achievements.size * @achievement_height + @line_size
    height += bar_amount
    height  = 32 if height < 32
    self.contents = Bitmap.new(self.contents.width, height)
    draw_contents
  end
  
  def bar_amount
    bar_achiefs = 0
    $game_temp.achievements.each_value do |value|
      bar_achiefs += 1 if value.bar and !value.hidden
    end
    return bar_achiefs * @bar_height
  end
  
  def enable?(name)
    return make_sort_list(name)
  end
  
  def make_sort_list(sort_label = @sort_label)
    amount                  = 0
    $game_temp.achievements = {}
    $game_system.achievements.each_pair do |key, value|
      value = $game_system.achievements[key]
      next unless check_label(value, sort_label)
      $game_temp.achievements[key] = value if sort_label == @sort_label
      amount += 1
    end
    return amount
  end
  
  def check_label(item, sort_label)
    if sort_label == All_Tab_Name
      return Hidden_in_All     if item.hidden
      return Completed_in_All  if item.completed
      return true
    end
    return item.completed if (Enable_Completed and sort_label == Completed_Tab)
    return item.hidden    if (Enable_Hidden    and sort_label == Hidden_Tab)
    list = (item.label.is_a? String) ? [item.label] : item.label
    return Completed_in_Tabs if (item.completed and list.include?(sort_label))
    return list.include?(sort_label)
  end
  
  def draw_contents
    index  = 0
    holder = []
    $game_temp.achievements.sort.each {|pair| holder.push(pair[1])}
    holder.each_index {|i| holder.push(holder.delete_at(i)) if holder[i].hidden}
    unless Alphabetic_Achiefs
      new_holder = {}
      holder.each {|value| new_holder[value.order_ID] = value}
      holder.clear
      new_holder.sort.each {|pair| holder.push(pair[1])}
    end
    @prev_bars = 0
    holder.each do |value|
      icon = value.hide_icon ? Hidden_Icon : value.icon
      draw_achievement(index, value, icon)
      index += 1
    end
  end
  
  def draw_achievement(index, achief, icon)
    @index = index
    set_data(achief)
    set_values
    draw_border(@rect)
    draw_background(@rect)
    draw_title(pos_y(0))
    draw_description(pos_y(1))
    draw_icon(icon, @border, @y + 12 + @border, @completed)
    unless achief.hidden
      if @bar
        @prev_bars += 1
        data        = achief.completion_listener
        draw_progression(data, pos_y(2))
      end
      draw_points(achief.points) if Use_Point_System
    end
  end
  
  def set_data(achief)
    @name        = achief.name
    @description = achief.description
    @completed   = achief.completed
    @bar         = achief.bar
    @bg_color    = get_bg_color(achief)
    if achief.hidden
      @name        = Hidden_Title
      @description = Hidden_Description
      @completed   = false
      @bar         = false
    end
  end
  
  def get_bg_color(achief)
    rTurn = achief.bg_color
    rTurn = Label_Colors[achief.label] if  rTurn.nil?
    rTurn = Label_Colors[Hidden_Tab]   if (rTurn.nil? and achief.hidden)
    rTurn = BG_Color                   if  rTurn.nil?
    return rTurn
  end
  
  def set_values
    set_pos
    set_width
    set_height
    set_rect
  end
  
  def set_pos
    @y = @achievement_height * @index + (@bar_height * @prev_bars)
  end
  
  def set_width
    @draw_width1 = self.contents.width -  @icon_displace - @border
    @draw_width2 = self.contents.width - (@border * 2)
  end
  
  def set_height
    @temp_height  = @achievement_height
    @temp_height += 1 * @line_size if @index == $game_temp.achievements.size - 1
    @temp_height += @bar_height    if @bar
  end
  
  def set_rect
    @rect = Rect.new(0, @y, self.contents.width, @temp_height)
  end
  
  def pos_y(times)
    return @y + (WLH*times) + @border
  end
  
  def draw_border(rect)
    color = Border_Color
    self.contents.fill_rect(rect, color)
  end
  
  def draw_background(rect)
    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_temp.achievements.size - 1
    color        = @bg_color
    self.contents.fill_rect(rect, color)
  end
  
  def draw_title(y)
    self.contents.font.bold        = true
    self.contents.font.color       = Text_Color
    self.contents.font.color.alpha = @completed ? 255 : 128
    self.contents.font.size        = Title_Size
    self.contents.draw_text(@icon_displace, y, @draw_width1, WLH, @name)
  end
  
  def draw_description(y)
    self.contents.font.bold = false
    self.contents.font.size = Description_Size
    self.contents.draw_text(@icon_displace, y, @draw_width1, WLH, @description)
  end
  
  def draw_progression(data, y)
    cl   = data.progression
    cl2  = cl[1]
    cl1  = data.condition_ready? ? cl2 : eval(cl[0])
    fill = cl1.to_f / cl2.to_f
    text = sprintf("%s/%s", cl1, cl2)
    x    = @border
    draw_progress_bar( fill, x, y)
    draw_progress_text(text, x, y)
  end
  
  def draw_progress_bar(fill, x, y)
    gw  = @draw_width2 * fill
    gc0 = Bar_Back_Color
    gc1 = Bar_Fill_Color_1
    gc2 = Bar_Fill_Color_2
    self.contents.fill_rect(         x, y + WLH - 8, @draw_width2, 6, gc0)
    self.contents.gradient_fill_rect(x, y + WLH - 8, gw,           6, gc1, gc2)
  end
  
  def draw_progress_text(text, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, @draw_width2, WLH, "Progress")
    self.contents.font.color = normal_color
    self.contents.font.size  = @font_size
    self.contents.draw_text(x, y, @draw_width2, WLH, text, 1)
  end
  
  def draw_points(points)
    return if points == 0
    custom = "#{Point_Name}#{points.abs != 1 ? "s" : ""}"
    points = sprintf("%s %s", points, custom)
    self.contents.font.size = Point_Font_Size
    y                       = @y + (@border / 2)
    self.contents.draw_text(0, y, @draw_width2 + @border, WLH, points, 2)
  end
  
end
#--------------------------#
# Window_Achievements: End #
#--------------------------#

#----------------------------#
# Achievements Labels window #
#----------------------------#
class Window_Command_Labels < Window_Command
  
  include SojaBird_Achievements
  
  attr_accessor :enables
  
  def initialize(commands, width)
    @enables   = []
    row_max    = Achief.tabs_row_amount
    column_max = commands.size / row_max.to_f
    super(width, commands, column_max.ceil, row_max)
  end
  
  def cursor_right(xo)
    @index = next_enabled
  end
  
  def cursor_left(xo)
    @index = next_enabled(true)
  end
  
  def next_enabled(minus = false)
    pos             = enables.index(@index)
    if minus; rTurn = (pos == 0) ? enables[enables.size - 1] : enables[pos - 1]
    else;     rTurn = (pos == enables.size - 1) ? enables[0] : enables[pos + 1]
    end
    return rTurn
  end
  
  def cursor_up(  xo); end
  def cursor_down(xo); end
  
end
#----------------------------#
# Window_Command_Labels: 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
  
  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]*))?\)/
    @achief.reward.scan(str) {
      item = $data_items[$1.to_i].name unless $&.nil?
      sp_f = "%s %s#{"s" if $3.to_i.abs != 1}"
      last = sprintf(sp_f, $3.to_i, item) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Weapon
    str = /weapon\(([0-9]*)(,\s?([0-9]*))?\)/
    @achief.reward.scan(str) {
      weapon = $data_weapons[$1.to_i].name unless $&.nil?
      sp_f   = "%s %s#{"s" if $3.to_i.abs != 1}"
      last   = sprintf(sp_f, $3.to_i, weapon) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Armor
    str = /armor\(([0-9]*)(,\s?([0-9]*))?\)/
    @achief.reward.scan(str) {
      armor = $data_armor[$1.to_i].name unless $&.nil?
      sp_f  = "%s %s#{"s" if $3.to_i.abs != 1}"
      last  = sprintf(sp_f, $3.to_i, armor) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Gold
    str = /gold\(([0-9]*)\)/
    @achief.reward.scan(str) {
      sp_f = "%s#{Vocab::gold}"
      last = sprintf(sp_f, $1.to_i) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Lvl
    str = /lvl\((\-?[0-9]*)(,\s?([0-9]*))\)/
    @achief.reward.scan(str) {
      unless $&.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) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Exp
    str = /exp\((\-?[0-9]*)(,\s?([0-9]*))\)/
    @achief.reward.scan(str) {
      unless $&.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) unless $&.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)
    height = 32 + WLH
    case Achief.get_layout
    when 1; height += WLH unless shop
    end
    super(x, y, width, height)
    @shop = shop
    refresh
  end
  
  def refresh
    self.contents.clear
    draw_points
    draw_achief_amount unless @shop
  end
  
  def draw_points
    name = Point_Name.capitalize
    text = sprintf("#{name}s: %s", Achief.get_points)
    self.contents.draw_text(0, 0, self.contents.width, WLH, text)
  end
  
  def draw_achief_amount
    amount = "#{Achief.get_completed}"
    case Achief.get_layout
    when 0; y, align = 0,   2; amount += "/#{$game_system.achievements.size}"
    when 1; y, align = WLH, 0
    end
    text = sprintf(Status_Text, amount)
    self.contents.draw_text(0, y, self.contents.width, WLH, text, align)
  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 = []
    temp  = $game_system.achief_buyables
    temp.each {|both| @data.push(both[1])}
    @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 <= Achief.get_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 = []
    temp  = $game_system.achievements
    temp.each {|both| @data.push(both[1]) if both[1].hidden}
    @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 <= Achief.get_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 #
#---------------------------------#

#------------------------#
# Points shop buy window #
#------------------------#
class Window_ShopBuy_Points < Window_ShopBuy
  
  def refresh
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0; item = $data_items[goods_item[1]]
      when 1; item = $data_weapons[goods_item[1]]
      when 2; item = $data_armors[goods_item[1]]
      end
      @data.push(item.clone) unless (item.nil? or point_value?(item).nil?)
    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]
    item.price = point_value?(item)
    number     = $game_party.item_number(item)
    enabled    = (item.price <= Achief.get_points and number < 99)
    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 point_value?(item)
    item.note.gsub(/Points\(([0-9]+(.[0-9]+)?)\)/) { $& }
    return ($&.nil? ? nil : ($2.nil? ? $1.to_i : $1.to_f))
  end
  
end
#----------------------------#
# Window_ShopBuy_Points: End #
#----------------------------#

#---------------------------#
# Points shop number window #
#---------------------------#
class Window_ShopNumber_Points < Window_ShopNumber
  
  include SojaBird_Achievements
  
  def refresh
    fix_max
    y = 96
    self.contents.clear
    draw_item_name(@item, 0, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(212, y, 20, WLH, "�")
    self.contents.draw_text(248, y, 20, WLH, @number, 2)
    self.cursor_rect.set(   244, y, 28, WLH)
    draw_point_currency(@price * @number, 4, y + WLH * 2, 264)
  end
  
  def fix_max
    @max = @max.floor
  end
  
  def draw_point_currency(value, x, y, width)
    value = fix_price(value)
    text = " #{Point_Name}s"
    cx = contents.text_size(text).width
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width-cx-2, WLH, value, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, width, WLH, text, 2)
  end
  
  def fix_price(value)
    return (value == value.round) ? value.to_i : value
  end
  
end
#-------------------------------#
# Window_ShopNumber_Points: End #
#-------------------------------#

#------------------------------------#
# Exchange help (variable x-y-width) #
#------------------------------------#
class Window_Exchange_Help < Window_Base
  
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
  end
  
  def set_text(text, align = 0)
    if text != @text or align != @align
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
      @text  = text
      @align = align
    end
  end
  
end
#---------------------------#
# Window_Exchange_Help: End #
#---------------------------#

#---------------------------------#
# Exchange command (center align) #
#---------------------------------#
class Window_Exchange_Command < Window_Command
  
  def draw_item(index, enabled = true)
    rect        = item_rect(index)
    rect.x     += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color       = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index], 1)
  end
  
end
#------------------------------#
# Window_Exchange_Command: End #
#------------------------------#

#--------------------------#
# Exchange amount selector #
#--------------------------#
class Window_Point_Exchange < Window_Base
  
  include SojaBird_Achievements
  
  def initialize(rate, x, y, width, height)
    super(x, y, width, height)
    @rate   = rate
    @amount = 0
    @number = 0
    refresh
  end
  
  def refresh
    refresh_cursor(true)
    @max = Achief.get_points.floor / @rate[0]
    self.contents.clear
    self.contents.font.color = normal_color
    text = sprintf(Amount_Dispaly, @number * @rate[0], @number * @rate[1])
    self.contents.draw_text(0, 0, self.contents.width, WLH, text, 1)
  end
  
  def update
    super
    refresh_cursor
    if self.active
      last_number = @number
      @number += 1    if (Input.repeat?(Input::RIGHT) and @number < @max)
      @number -= 1    if (Input.repeat?(Input::LEFT)  and @number > 0)
      @number  = @max if  Input.repeat?(Input::UP)
      @number  = 0    if  Input.repeat?(Input::DOWN)
      if @number != last_number
        Sound.play_cursor
        refresh
      end
    end
  end
  
  def refresh_cursor(start = false)
    y = (self.active ? 0 : 100)
    y = 100 if start
    self.cursor_rect.set(0, y, self.contents.width, WLH)
  end
    
  def amount
    return @number
  end
  
  def set(new)
    @number = new
    refresh
  end
  
end
#----------------------------#
# Window_Point_Exchange: 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 :bar
  attr_accessor :reward
  attr_accessor :rewarded
  attr_accessor :completed_shown
  attr_accessor :found_shown
  attr_accessor :points
  attr_accessor :points_gained
  attr_accessor :label
  attr_accessor :order_ID
  attr_accessor :bg_color
  
  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
    @bar                 = false
    @reward              = nil
    @rewarded            = false
    @completed_shown     = false
    @found_shown         = false
    @points              = 0
    @points_gained       = false
    @label               = []
    @order_ID            = nil
    @bg_color            = nil
  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
  attr_reader   :progression
  
  def initialize(condition)
    @condition   = condition
    @progression = make_progression
  end
  
  def make_progression
    disables = ["swtich"]
    @condition.gsub(/([^><!=\s]*)\s?[>=]{2}\s?(.*[^\s])/) { @a = $1; @b = $2 }
    @a = "get_#{@a}" if (@a == "points" or @a == "completed")
    @b.slice!(/(\sand.*)/) unless @b.nil?
    if @a.nil?
      @condition.gsub(/(completed\((.*)\))/) {
        @a = "bar_get1_#{$1}"
        @b = eval("Achief.bar_get2_#{$1}")
      }
    end
    return nil if (disables.include?(@a) or @a.nil?)
    return ["Achief.#{@a}", @b]
  end
  
  def condition_ready?
    mod_it = @condition.dup
    str    = /(completed(\(\'.*\'(,\s?\'.*\')*?\))?)/
    mod_it.gsub!(str)                  { eval("Achief.get_#{$1.to_s}") }
    mod_it.gsub!(/(item\([0-9]*\))/)   { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(weapon\([0-9]*\))/) { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(armor\([0-9]*\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(var\([0-9]*\))/)    { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(switch\([0-9]*\))/) { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(gold)/)             { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(lvl\(-?[0-9]*\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(exp\(-?[0-9]*\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(kills\(\'.+\'\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(battle\([0-9]\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(steps)/)            { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(points)/)           { eval("Achief.get_#{$1.to_s}") }
    return eval(mod_it)
  end
  
end
#--------------------------#
# Completion_Listener: End #
#--------------------------#

#-------------------#
# Kill-amount check #
#-------------------#
class Game_Enemy < Game_Battler
  
  alias achief_collapse :perform_collapse
  def perform_collapse
    achief_collapse
    execute_note if @collapse
  end
  
  def execute_note
    @note = enemy.note
    get_code
  end
  
  def get_code
    @note.gsub(/Achief\((.+)\)/i) {@note_tag = $1.to_s}
    $game_system.achief_kills[@note_tag] ||= 0
    $game_system.achief_kills[@note_tag]  += 1
  end
  
end
#-----------------#
# Game_Enemy: End #
#-----------------#

#---------------------#
# Battle-data collect #
#---------------------#
class Scene_Battle < Scene_Base
  
  #Results, [0: win, 1: escape, 2:lose]
  alias achief_battle_end :battle_end
  def battle_end(result)
    store_battle_data(result)
    achief_battle_end(result)
  end
  
  def store_battle_data(result)
    $game_system.achief_battles[result] += 1
    $game_system.achief_battles[3]      += 1
  end
  
end
#-------------------#
# Scene_Battle: End #
#-------------------#

#---------------------#
# Update achievements #
#---------------------#
class Scene_Map < Scene_Base
  
  include SojaBird_Achievements
  
  alias achievements_update :update
  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 if Enable_Alerts
  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
  
  alias achievements_usc :update_scene_change
  def update_scene_change
    usc_achievements
    achievements_usc
  end
  
  def usc_achievements
    Achief.alerts_update(true) unless $game_temp.next_scene.nil?
    return if $game_player.moving?
    case $game_temp.next_scene
    when "achievements";      call_achievements
    when "achievements_shop"; call_achief_shop
    when "points_exchange";   call_points_exchange
    end
  end
  
  def call_achievements
    $game_temp.next_scene = nil
    $scene = Scene_Achievements.new($game_temp.return_map)
  end
  
  def call_achief_shop
    $game_temp.next_scene = nil
    $scene = Scene_Achievements_Shop.new($game_temp.reveal_price)
  end
  
  alias call_point_shop :call_shop
  def call_shop
    $game_temp.point_currency ? new_point_shop : call_point_shop
  end
  
  def call_points_exchange
    $game_temp.next_scene = nil
    rate   = $game_temp.pg_exchange_rate
    swap   = $game_temp.swap_show_rate
    $scene = Scene_Point_Exchange.new(rate, swap)
  end
      
  def new_point_shop
    $game_temp.next_scene = nil
    $game_temp.shop_purchase_only = true
    $scene = Scene_Shop_Points.new
  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
    Start_Labels.each do |value|
      Achief.start_label(value)
    end
    Start_Colors.each do |value|
      Achief.start_color(value)
    end
    $game_system.achievements.each_value do |value|
      value.found_shown = true unless Display_StartUps
    end
  end
  
end
#------------------#
# Scene_Title: End #
#------------------#

#--------------------------#
# Achievements STORE class #
#--------------------------#
class Game_System
  
  attr_accessor :achievements
  attr_accessor :achief_buyables
  attr_accessor :achief_alerts
  attr_accessor :achief_points
  attr_accessor :achief_kills
  attr_accessor :achief_battles
  
  alias achievements_initialize :initialize
  def initialize
    achievements_initialize
    @achievements    = {}
    @achief_buyables = {}
    @achief_alerts   = []
    @achief_points   = 0.0
    @achief_kills    = {}
    @achief_battles  = [0, 0, 0, 0]
  end
  
end
#------------------#
# Game_System: End #
#------------------#

#-----------------------#
# Shop-info STORE class #
#-----------------------#
class Game_Temp
  
  include SojaBird_Achievements
  
  attr_accessor :achievements
  attr_accessor :return_map
  attr_accessor :reveal_price
  attr_accessor :point_currency
  attr_accessor :pg_exchange_rate
  attr_accessor :swap_show_rate
  
  alias achievements_initialize :initialize
  def initialize
    achievements_initialize
    @achievements     = {}
    @return_map       = true
    @reveal_price     = Common_Reveal_Cost
    @point_currency   = false
    @pg_exchange_rate = []
    @swap_show_rate   = Show_Rate_Bar
  end
  
end
#----------------#
# Game_Temp: 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
    points_tag
    kills_tag
    battle_tag
  end
  
  def points_tag
    tag    = Message_Points_Tag
    points = Achief.get_points
    sub    = "#{points} #{Point_Name}#{points.abs != 1 ? "s" : ""}"
    @text.gsub!(/\\#{tag}/i) { sub }
  end
  
  def kills_tag
    tag = Message_Kills_Tag
    @text.gsub!(/\\#{tag}\[(.+)\]/i) { $game_system.achief_kills[$1.to_s] }
  end
  
  def battle_tag
    tag = Message_Battle_Tag
    @text.gsub!(/\\#{tag}\[([0-9])\]/i) { $game_system.achief_battles[$1.to_i] }
  end
  
end
#---------------------#
# Window_Message: End #
#---------------------#

#-------------------------#
# Add to menu-items (NMI) #
#-------------------------#
begin
#NMI included
  
  return unless SojaBird_Achievements::Menu_Enabled
  title  = SojaBird_Achievements::Menu_Title
  action = "$scene = Scene_Achievements.new"
  $Menu_Items.new(SojaBird_Achievements::Menu_Location, title, false, action)

#-------------------------------------#
# Rescue > Old fashioned way (no 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
  
  include SojaBird_Achievements
  #-------------#
  # Get correct #
  #-------------#
  def self.achievement(name)
    return $game_system.achievements[name]
  end
  
  def self.achievement_buyable(name)
    return $game_system.achief_buyables[name]
  end
  
  def self.add_achief_order(name)
    id_list = [1]
    $game_system.achievements.each_value {|value| id_list.push(value.order_ID)}
    self.achievement(name).order_ID = id_list.compact.max + 1
  end
  
  def self.get_all_tabs
    commands = Name_Tabs.clone
    commands.push(Completed_Tab) if Enable_Completed
    commands.push(Hidden_Tab)    if Enable_Hidden
    commands.sort!               if Alphabetic_Tabs
    commands.insert(0, All_Tab_Name)
    return commands
  end
  
  def self.tabs_row_amount
    case self.get_layout
    when 0; return [[Tab_Row_Amount, self.get_all_tabs.size].min, 1].max
    when 1; return self.get_all_tabs.size
    end
  end
  
  def self.get_layout
    return (self.get_all_tabs.size > 1) ? Layout_Style : 0
  end
  
  #------------------#
  # Condition/Reward #
  #------------------#
  def self.gain_reward(name)
    value          = self.achievement(name)
    value.rewarded = true
    self.give_rewards(name) unless value.reward.nil?
  end
  
  @gain = false
  def self.give_rewards(name)
    @gain = true
    value = self.achievement(name)
    #str   = /([^\s,\"\'][a-zA-Z0-9\s_]*(\(-?[a-zA-Z0-9\']*(,\s?[a-z0-9]*)?\)))/
    str   = /([^\s,\"\'][a-zA-Z0-9\s]*(\(-?[0-9]*(,\s?[a-z0-9]*)?\)))/
    value.reward.scan(str) { eval($1) }
    $game_map.need_refresh = true
    @gain = false
  end
  
  @bar_get = false
  def self.bar_get1_completed(*args)
    @bar_get = true
    rTurn    = self.get_completed(*args)
    @bar_get = false
    return rTurn
  end
  
  def self.bar_get2_completed(*args)
    return args.size
  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 @bar_get ? amount : (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
  
  def self.kills(note_tag)
    rTurn = $game_system.achief_kills[note_tag]
    return rTurn.nil? ? -999 : rTurn
  end
  
  #Results, [0: win, 1: escape, 2:lose, 3:all]
  def self.battle(result)
    return $game_system.achief_battles[result]
  end
  
  def self.steps
    return $game_party.steps
  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 (!Reward_Prototype and type == "c+r")
    return unless Enable_Alerts
    @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
    rTurn = $game_system.achief_points
    return (rTurn == rTurn.round) ? rTurn.to_i : rTurn
  end
  
  def self.gain_points(name)
    value = self.achievement(name)
    value.points_gained = true
    self.add_points(value.points) unless value.points.nil?
  end
  
  def self.add_points(value)
    $game_system.achief_points += value
  end
  
  def self.lose_points(value)
    self.add_points(-value)
  end
  
  #------------#
  # Open scene #
  #------------#
  def self.call(return_map = true)
    self.alerts_update(true)
    $game_temp.return_map = return_map
    $game_temp.next_scene = "achievements"
  end
  
  def self.call_shop(reveal_price = Common_Reveal_Cost)
    self.alerts_update(true)
    $game_temp.reveal_price = reveal_price
    $game_temp.next_scene   = "achievements_shop"
  end
  
  def self.point_shop
    $game_temp.point_currency = true
  end
  
  def self.call_exchange(p, g, swap = false)
    self.alerts_update(true)
    $game_temp.pg_exchange_rate = [p, g]
    $game_temp.swap_show_rate   = swap
    $game_temp.next_scene       = "points_exchange"
  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
    hide_icon     = hidden if hide_icon.nil?
    completed   ||= false
    self.new(name, description, icon, hidden, hide_icon, completed)
  end
  
  def self.start_buyables(array)
    price         = array[0]
    name          = array[1]
    description   = array[2]
    icon          = array[3]
    icon        ||= 0
    self.new_buyable(price, name, description, icon)
  end
  
  def self.start_points(array)
    name   = array[0]
    points = array[1]
    self.points(name, points)
  end
  
  def self.start_condition(array)
    name      = array[0]
    condition = array[1]
    bar       = array[2]
    bar     ||= Auto_Bar_On
    self.condition(name, condition, bar)
  end
  
  def self.start_reward(array)
    name   = array[0]
    reward = array[1]
    self.reward(name, reward)
  end
  
  def self.start_label(array)
    name  = array[0]
    label = array[1]
    self.label(name, label)
  end
  
  def self.start_color(array)
    name  = array[0]
    color = array[1]
    self.bg_color(name, color)
  end
  
end
#-------------#
# Module: End #
#-------------#


the faulty line is:
CODE
    achief.bg_color = color

which is line 467
SojaBird
@Nariakei
Hey I actualy haven't tried that jet, starting whithout a character.
I'll see if I can find the error and fix it in a hopefully quick-fix wink.gif

@teamtns
Well... seems like you've cracked up some pretty nasty error or bug I've put in...
It seems that for some reason no bg-colour is set for the achievementbar when used.
What you could do, is try to change the next:
CODE
    @label = []
    @order_ID = nil
    @bg_color = nil
  end
Swap it whith this: (I haven't tested this myself jet)
CODE
    @label = []
    @order_ID = nil
    @bg_color = Color.new()
  end

Let me know if it worked, if not... use [b]Color.new(0,0,0,0)[b] instead and see if that changes anything.


Greatzz,
SojaBird.
lecode234
Hello.
I have a problem.
How to delete the ALL Tab please ? sad.gif

Achievement can have multiple conditions ?
SojaBird
@lecode234

Hey hey,

Well that's one good question I haven't realy though about.
There is not yet a convenient way to remove the "All tab".
This might not work, but try to find the line
CODE
commands.insert(0, All_Tab_Name)
and put a # infront of it (so it is commented out).
Not sure if it will give you a error, but it's worth a try.

Yes achievements can have have multiple conditions smile.gif
Go with something like
CODE
Achief.condition("Multi Maker", "steps >= 100 and lvl(-1) >= 5")

If it doesn't work, show me what doesn't work and I'll try to figure it out wink.gif


Greatzz,
SojaBird.
lecode234
Okey tgank you biggrin.gif
I try

EDIT:
IT WORKS !!!
But i do a thing like this:
Achief.condition("Multi Maker", "steps >= 100 and lvl(-1) >= 3")
Not lvl(-1, 3)
dracoseeker1
thumbsup.gif Way to go on the script dude, i looked into omegas7's script for this kind of thing, but it just wasn't what i was looking for. thank you very much, and keep up the good work!
SojaBird
@lecode234
Oke cool, nice you've got it working.
Nicely spotted with the error I made wink.gif
Keep it up and have fun.

@dracoseeker1
Good to have you experience Achievements to correct way instantly :3
Hope it makes your games ever more epic than they would without wink.gif


Greatzz,
SojaBird.
lecode234
Hello.
SojaBird, i have a problem with this:

["Coral Killer", " kills('coral') >= 5 "],

On the progress bar , it show -999/5.
Can you help me, please ?
( Sorry for my bad english...i am french :$ )
SojaBird
Hey lecode234

Thanks for the reply, let's hope I can help you out.
Have you put the needed tag in the enemy note window in the database?
Make sure you have the following line at the notefield of your Coral enemy:
CODE
Achief('coral')
Let me know if this solves the problem wink.gif


Greatzz,
SojaBird.
lecode234
Already done, so it does not work sad.gif
lecode234
Up sad.gif
SojaBird
Did you had a chance to get the demo?
It used to have a working one in there :s
Eevee204
I'm trying to add in my own items I put this;
["Is it worth it?", "Stickman card >= 1"],

but I can't get it to reconise the item in the database, how can I do this? ohmy.gif

Thanks
SojaBird
Hey @Eevee204

So if I'm right you want to, say have the player achief something when they have 1 or more of a specific item, yea?
To do so, use the next code to set a condition
CODE
["Is it worth it?", "item(ID) >= 1"]
So instead of just go with the name of the item, go with item(ID) with ID being the database ID of the stickman card item.

Hope you'll be able to get it right now wink.gif


Have fun,
SojaBird.


PS. I've fixed the demo link and should be able to download again (not sure 'bout the version of that though, need confirmation on the version)
lecode234
On the demo i have the same probleme.
See Imp.png
SojaBird
Hey lecode234,

Did you changed something in the demo before you got this?
If so, what did you changed smile.gif?


Greatzz,
SojaBird.
lecode234
I have not changed.
To be sure, I re-download the demo.
Still the same problem.
Download the demo and try to find the error. I'm sure the problem come from the script. happy.gif
lecode234
Up.Someone noticed the same problem on his demo?
SojaBird
Whooh didn't got your prev respond, sorry 'bout that.
When I get back home saterday I'll have a look at it since it's on my other laptop.

See if I can fix it up.


Greatzz,
SojaBird.

Oh ps what version is the demo?
lecode234
4.0.b smile.gif
SojaBird
Could you go and try the newest version on the demo (copy over the start-up things), see what that does.

Greatzz,
SojaBird.
lecode234
It does not work.
Have you tested your script?
Why am I the only one to find the bug?
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.