Skill Shop
Authors: game_guy
Version: 2.2
Type: Skill Buying Script
Key Term: Custom Shop System
IntroductionWhat this script does is act as a shop but sells skills instead that you can teach to your party members.
Features
- Sells Skills to teach Actors
- Make it any actor can learn any skill
- Make skills class specific
- Easy to configure then most skill shops I've seen
- Now skills can be level specific
- Sort skills in 6 different ways
Screenshots(http://i307.photobucket.com/albums/nn318/bahumat27/skillshoop.png)
(http://i307.photobucket.com/albums/nn318/bahumat27/skillshoop2.png)
(http://i307.photobucket.com/albums/nn318/bahumat27/skillshoop3.png)
DemoMediaFire (http://www.mediafire.com/download.php?wmmvtmt2yk1)
Script
#===============================================================================
# Skill Shop
# Author: Game_guy
# Date: June 7th, 2009
# Version: 2.2
#===============================================================================
#
# Intro:
# What this script does is act as a shop but sells skills instead.
#
# Instructions:
# 1: First how do you want it setup? Theres two ways
# 1: -Any person can learn any skill
# or
# 2: -Classes learn different skills then other classes
#
# Go down to UseClasses and set it to false for 1: or true for 2:
#
# 2: Ok now that thats over lets move onto price. Go down to CONFIG PRICE and
# follow the instructions there.
#
# 3: Skip this step if you set UseClasses to false.
# Go to CONFIG CLASS SKILLS and follow the instructions there.
#
# 4: Ok so everythings setup now. Time to actually find out how to open the
# skillshop right? You use this line
# $scene = SkillShop.new([skill id's go here])
# example
# $scene = SkillShop.new([1, 2]) will make a shop with the skills
# Heal and Great Heal
#
# 5: Ok the script now is able to make it where only skills are learnable at
# certain levels. Go to CONFIG LEVEL and follow instructions there.
#
# 6: Ok so now there's a new option that sorts the skills in the following.
# Alphabetical
# Reverse Alphabetical
# Numeric (Sorts it by Id)
# Reverse Numberic
# Price
# Reverse price
# At default its at numeric but to change it use this,
# $game_system.ssort = 0,1,2, or 3.
# 0 = Numeric, 1 = Reverse Numeric, 2 = Alphabetical,
# 3 = Reverse Alphabetical, 4 = Price, 5 = Reverse Price.
#===============================================================================
module GameGuy
#==========================
# BEGIN CONFIG
#==========================
UseClasses = true # if false anyone can learn any skill
# if true only classes can learn the defined skills
end
module RPG
class Skill
def price
case id
#==========================
# CONFIG PRICE
#==========================
# use
# when skill_id then return price
when 1 then return 50
when 57 then return 75
end
return 10
end
def llevel
case id
#==========================
# CONFIG LEVEL
#==========================
# use
# when skill_id then return level
when 57 then return 2
end
return 1
end
end
class Class
def learnskills
case id
#==========================
# CONFIG CLASS SKILLS
#==========================
# use
# when class_id then return [skill id's here]
when 1 then return [57, 58, 59, 60]
when 2 then return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 81]
when 7 then return [69, 70, 71, 72, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]
when 8 then return [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56]
end
return []
end
#==========================
# END CONFIG
#==========================
end
end
class Game_System
attr_accessor :ssort
alias sort_me_skillz initialize
def initialize
@ssort = 0
sort_me_skillz
end
end
class Window_SkillCommand < Window_Selectable
def initialize
super(0, 64, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 2
@column_max = 2
@commands = ["Learn", "Exit"]
refresh
self.index = 0
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index)
x = 4 + index * 240
self.contents.draw_text(x, 0, 128, 32, @commands[index])
end
end
class Window_SkillBuy < Window_Selectable
def initialize(shop_goods)
super(0, 128, 368, 352)
@skill_shop_goods = shop_goods
self.active = false
refresh
self.index = 0
end
def skill
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 0...@skill_shop_goods.size
skill = $data_skills[@skill_shop_goods[i]]
if skill != nil
@data.push(skill)
end
end
case $game_system.ssort
when 0
[@data].each {|ary| ary.sort! {|a, b| a.id <=> b.id}}
when 1
[@data].each {|ary| ary.sort! {|a, b| a.id <=> b.id}}
[@data].each {|ary| ary.reverse!}
when 2
[@data].each {|ary| ary.sort! {|a, b| a.name <=> b.name}}
when 3
[@data].each {|ary| ary.sort! {|a, b| a.name <=> b.name}}
[@data].each {|ary| ary.reverse!}
when 4
[@data].each {|ary| ary.sort! {|a, b| a.price <=> b.price}}
when 5
[@data].each {|ary| ary.sort! {|a, b| a.price <=> b.price}}
[@data].each {|ary| ary.reverse!}
else
[@data].each {|ary| ary.sort! {|a, b| a.id <=> b.id}}
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
skill = @data[index]
price = skill.price
enabled = (price <= $game_party.gold)
if enabled
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
end
def update_help
@help_window.set_text(skill == nil ? "" : skill.description)
end
end
class Window_SkillStatus2 < Window_Selectable
def initialize
super(368, 128, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.z = 200
self.active = false
self.index = -1
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 80
actor = $game_party.actors[i]
classs = $data_classes[$game_actors[actor.id].class_id]
draw_actor_graphic(actor, x - 40, y + 60)
draw_actor_name(actor, x - 13, y + 10)
if actor.skill_learn?($thing.id)
self.contents.font.color = crisis_color
$text = "Aquired"
elsif GameGuy::UseClasses
if classs.learnskills.include?($thing.id) && $thing.llevel <= actor.level
self.contents.font.color = normal_color
$text = "Can Learn"
elsif classs.learnskills.include?($thing.id) && $thing.llevel > actor.level
self.contents.font.color = disabled_color
$text = "Can Learn At Level " + $thing.llevel.to_s
else
self.contents.font.color = disabled_color
$text = "Can't Learn"
end
else
if actor.level >= $thing.llevel
self.contents.font.color = normal_color
$text = "Can Learn"
else
self.contents.font.color = disabled_color
$text = "Can Learn At Level " + $thing.llevel.to_s
end
end
self.contents.draw_text(x - 13, y + 40, 200, 32, $text)
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
end
end
end
class SkillShop
def initialize(skills)
@skills = skills
end
def main
@command = Window_SkillCommand.new
@help_window = Window_Help.new
@skillbuy = Window_SkillBuy.new(@skills)
@skillbuy.active = false
@skillbuy.help_window = @help_window
$thing = @skillbuy.skill
@status = Window_SkillStatus2.new
#@status.visible = false
@gold = Window_Gold.new
@gold.x = 480
@gold.y = 64
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@gold.dispose
@skillbuy.dispose
@help_window.dispose
@command.dispose
@status.dispose
end
def update
@gold.update
@status.update
@gold.refresh
@command.update
@skillbuy.update
@help_window.update
$thing = @skillbuy.skill
@status.refresh
if @command.active
update_command
return
end
if @status.active
update_status
return
end
if @skillbuy.active
update_buy
return
end
end
def update_buy
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@skillbuy.active = false
@skillbuy.index = -1
@command.active = true
@command.index = 0
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@skillbuy.active = false
@status.active = true
@status.visible = true
@status.index = 0 if @status.index == -1
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @command.index
when 0
@command.active = false
@command.index = -1
@skillbuy.active = true
@skillbuy.index = 0
when 1
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
end
return
end
end
def update_status
if Input.trigger?(Input::B)
@status.active = false
@status.index = -1
@skillbuy.active = true
return
end
if Input.trigger?(Input::C)
price = @skillbuy.skill.price
@actort = $game_party.actors[@status.index]
enabled = (price <= $game_party.gold)
if enabled
if @actort.skill_learn?(@skillbuy.skill.id)
$game_system.se_play($data_system.buzzer_se)
return
end
if GameGuy::UseClasses
if $data_classes[@actort.class_id].learnskills.include?(@skillbuy.skill.id) && @actort.level >= @skillbuy.skill.llevel
@actort.learn_skill(@skillbuy.skill.id)
$game_party.lose_gold(@skillbuy.skill.price)
$game_system.se_play($data_system.decision_se)
@status.refresh
@skillbuy.refresh
return
else
$game_system.se_play($data_system.buzzer_se)
return
end
else
if @actort.level >= @skillbuy.skill.llevel
@actort.learn_skill(@skillbuy.skill.id)
$game_party.lose_gold(@skillbuy.skill.price)
$game_system.se_play($data_system.decision_se)
@status.refresh
@skillbuy.refresh
else
$game_system.se_play($data_system.buzzer_se)
return
end
return
end
else
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
end
InstructionsIn the script
CompatibilityNot tested with SDK. Wont work with other skill shop scripts
Credits and Thanks
- game_guy ~ For making it
- Hellfire Dragon ~ Requesting a cool sorting feature
- Blizzard ~ Stormtronics CMS's Item sorting option
- dylanf3 ~ Requesting price sorting option
Author's NotesGive credits and enjoy!
awsome!! this is very good,
Anyone else like this script?
Put up a screenshot. xD
Oh yea huh xD
Ok here's some I completely forgot about adding them...sorry guys :(
(http://i307.photobucket.com/albums/nn318/bahumat27/skillshoop.png)
(http://i307.photobucket.com/albums/nn318/bahumat27/skillshoop2.png)
(http://i307.photobucket.com/albums/nn318/bahumat27/skillshoop3.png)
Is there a way to show in the level that is required for the skill, in the shop window?
I mean like this:
Description of skill
Skill Name Lvl needed Price
or something like this anyway. Or does it allready display that?
An all around useful script :)
Great script... only found 1 (i think really big) problem
when you bought a skill for a character you will see 3 selectable windows (the white boxes) at the same time
its really hard to see what 1 you are controlling
for example:
which 1 am I controlling atm:
(http://img249.imageshack.us/img249/3676/problem.png)
awnser:
the way to do it is:
show 1 cursor in total when your in the top menu
show only 2 cursors when your in the skill select menu
and only show 3 cursors when your controlling the window what char should learn a skill
see the one you're controlling is blinking if you want I'll set it so the windows that arent active the index will be -1
i know the 1 blinking is the 1 your controlling.. but I'm afraid a lot of peep will get confused. (even I got confused)
this problem is the only reason why i'm not switching to this skill shop
there updated see if thats how you want it?
there is a bug
when you learned a skill to character and press esc and select learn again the cursor is gone and you can't select anything anymore
but nvm my request.. I don't want to waist your time for little things like this. I will stick with my own script I have.
check to see if its fixed now
I have some skills, i dont want to be bought, how can i do that?
dont include the skills when you call the skillshop you call it this way
SkillShop.new([skills])
example
SkillShop.new([1, 2, 3, 4])
would sell skills 1-4
the bug is fixed...
but think u misunderstand me :S
the top window was not really of my consurn
it the most right window where u select the actor after you bought the skill.
if you buy a skill and selected the actor who learns it i would love to see the actor select window cursor been hidden until u buy the next skill
But if i do that, i cant get to skill no. 57.....
Isnt there a way to sell all excluding no. 58 and 59?
@dylan you do this
SkillShop.new([1, 2, 3, 4, 57, 89])
Just put any skill id's in there or do these
Hey G_G, is there a way to make a shop sell all skills without having to list every skill ID?
Okay so I decided to try this out and ran into a strange problem that is almost certainly my doing.
First, I used the script and set up 9 skills just to test them out. Then, I called the script to run the item shop and discovered there was no text. No skills names, no "Learn" and "Exit", and no character names. I figured I did something wrong in my configuring, so I made a new game which just called the script without any editing whatsoever, and got the same result:
(http://i3.photobucket.com/albums/y85/blobbyman/Problem.jpg)
Any advice or help to fix it?
I think it's most likely that's it's because your using a cracked version of rmxp :P Are you?
It seems to me that you are using Postality Knights Edition of RMXP, by the blue icon in the upper left instead of an orange one. Lots of scripts aren't compatible with it. It shouldn't been too hard to edit them though.
Quote from: Hellfire Dragon on July 25, 2009, 11:17:23 am
Hey G_G, is there a way to make a shop sell all skills without having to list every skill ID?
use this in a script call
skills = []
for i in 1...$data_skills.size
skill.push(i)
end
$scene = SkillShop.new(skills)
Quote
NameError occurred while running script.
undefined local variable or method 'skill' for #<Interpreter:0x4042ad8>
:(
skills = []
for i in 1...$data_skills.size
skills.push(i)
end
$scene = SkillShop.new(skills)
try that^^
woops silly me xD
Silly G_G, oh well, small mistake :haha: Thanks ;)
EDIT: Just a suggestions, it'd be cool if we could have the skills sorted in different ways other than by the ID number, looks kinda random :P Like alphabetical would be cool :)
Ok I'll see if I can do that.
Get Tons of Add-ons and turn on Ultimate Font Override.
What? Posted in the wrong thread Blizzy?
Have I? O_o
Quote from: TheBlob on July 25, 2009, 11:31:43 am
Okay so I decided to try this out and ran into a strange problem that is almost certainly my doing.
First, I used the script and set up 9 skills just to test them out. Then, I called the script to run the item shop and discovered there was no text. No skills names, no "Learn" and "Exit", and no character names. I figured I did something wrong in my configuring, so I made a new game which just called the script without any editing whatsoever, and got the same result:
(http://i3.photobucket.com/albums/y85/blobbyman/Problem.jpg)
Any advice or help to fix it?
:o You should've quoted or used @USER or something in your post :xD:
Yes, I should have. xD
Quote from: game_guy on July 25, 2009, 02:14:55 pm
Ok I'll see if I can do that.
Are you doing this G_G?
I'll start on it in about 30 minutes I forgot about it sorry ^_^
Updates* Okay HD I added 4 different sorting options just for you :)
Awesome :D
You think you could add the sorting option to the version you made me? If you don't have it I can send it to you ;)
Yea send me your version and I'll add it to it :)
Is it possible to add a Sort By Price? It would help more then names
Bug: When you buy a skill and you don't have enough money to buy another, the other skills don't get grayed out. You can fix it by adding a refresh call after buying a skill.
@dylanf3: I'll add it
@Blizzard: I'll fix it
*updates*
Fixed the bug blizz posted, and added sorting by pricing
Doesn't really work well with Mouse controller any way to edit it or fix?
Very nice. I can't believe nobody has done this yet. Lvl ++
Why was this excelnt script forgotten for so long? This is a great system.
Is there a way to make it so the shop will only show you skills that your class can use, instead of listing them all and saying which ones you can't learn.
I'm sorry for necroposting,
but I have a question regarding this script (and I think it's awesome by the way^^) !
The thing is:
I can buy the same skill over and over again with the same character !
I guess it's because I'm using a Skill Equipping system (by game_guy) ?!
Is there a way to only be able to learn a skill ONCE per character,
even though I'm using the skill equipping script (which means they don't appear directly in the skill menu) ?!
Try this.
class Game_Actor < Game_Battler
def skill_learn?(skill_id)
return @skills.include?(skill_id) or @eskills.include?(skill_id)
end
end
Oh wow, I hadn't realized the two scripts would even conflict. >.< Thanks again KK20 for fixing my scripts again. *levels up*
Quote from: Ezel Berbier on October 15, 2012, 01:36:38 pm
Try this.class Game_Actor < Game_Battler
def skill_learn?(skill_id)
return @skills.include?(skill_id) or @eskills.include?(skill_id)
end
end
Uuuhm sry for the dumb question,
but where do I have to input this?
@KK20: That snippet you provided has a syntax error. I dunno why but it errors out with "or" but when you use "||" instead, it works just fine.
@zottel: Just use my updated Skills Equipment Script and you'll be fine.
herp
Didn't know about that. I didn't test it (if that was any indication), it just looked logical to me. Probably would work if you use parenthesis around the statement.
return (@skills.include?(skill_id) or @eskills.include?(skill_id))
Glad to have pointed that out for you! All scripts must be perfect!
(http://fc02.deviantart.net/fs70/i/2012/005/b/2/mlp___two_sides_of_twilight_sparkle_by_tehjadeh-d4ht724.jpg)