[XP] Skill Shop

Skill Shop Version: 1.8
By: Game_guy

Introduction

I've seen a few skill shop scripts but one that didnt really fit my need so instead I made my own.

Screenshots

Content Hidden Spoiler
Image
Image
Image


Demo

Version 1.8 Demo
Demo

Script

script Spoiler
  1. #===============================================================================
  2. # Skill Shop
  3. # Author: Game_guy
  4. # Date: June 7th, 2009
  5. # Version: 1.8
  6. #===============================================================================
  7. #
  8. # Intro:
  9. # What this script does is act as a shop but sells skills instead.
  10. #
  11. # Instructions:
  12. # 1: First how do you want it setup? Theres two ways
  13. #    1: -Any person can learn any skill
  14. #    or
  15. #    2: -Classes learn different skills then other classes
  16. #
  17. #    Go down to UseClasses and set it to false for 1: or true for 2:
  18.  
  19. # 2: Ok now that thats over lets move onto price. Go down to CONFIG PRICE and follow
  20. #    the instructions there.
  21. #  
  22. # 3: Skip this step if you set UseClasses to false.
  23. #    Go to CONFIG CLASS SKILLS and follow the instructions there.
  24. #    
  25. # 4: Ok so everythings setup now. Time to actually find out how to open the
  26. #    skillshop right? You use this line
  27. #    $scene = SkillShop.new([skill id's go here])
  28. #    example
  29. #    $scene = SkillShop.new([1, 2]) will make a shop with the skills
  30. #    Heal and Great Heal
  31. #
  32. # 5: Ok the script now is able to make it where only skills are learnable at
  33. #    certain levels. Go to CONFIG LEVEL and follow instructions there.
  34. #===============================================================================
  35. module GameGuy
  36.   #==========================
  37.   # BEGIN CONFIG
  38.   #==========================
  39.   UseClasses = true # if false anyone can learn any skill
  40.                      # if true only classes can learn the defined skills
  41. end
  42. module RPG
  43.   class Skill
  44.     def price
  45.       case id
  46.       #==========================
  47.       # CONFIG PRICE
  48.       #==========================
  49.       # use
  50.       # when skill_id then return price
  51.       when 1 then return 50
  52.       when 57 then return 75
  53.       end
  54.       return 10
  55.     end
  56.     def llevel
  57.       case id
  58.       #==========================
  59.       # CONFIG LEVEL
  60.       #==========================
  61.       # use
  62.       # when skill_id then return level
  63.       when 57 then return 2
  64.       end
  65.       return 1
  66.     end
  67.   end
  68.   class Class
  69.     def learnskills
  70.       case id
  71.       #==========================
  72.       # CONFIG CLASS SKILLS
  73.       #==========================
  74.       # use
  75.       # when class_id then return [skill id's here]
  76.       when 1 then return [57, 58, 59, 60]
  77.       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]
  78.       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]
  79.       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]
  80.       end
  81.       return []
  82.     end
  83.   #==========================
  84.   # END CONFIG
  85.   #==========================
  86.   end
  87. end
  88.  
  89. class Window_SkillCommand < Window_Selectable
  90.   def initialize
  91.     super(0, 64, 480, 64)
  92.     self.contents = Bitmap.new(width - 32, height - 32)
  93.     @item_max = 2
  94.     @column_max = 2
  95.     @commands = ["Learn", "Exit"]
  96.     refresh
  97.     self.index = 0
  98.   end
  99.   def refresh
  100.     self.contents.clear
  101.     for i in 0...@item_max
  102.       draw_item(i)
  103.     end
  104.   end
  105.   def draw_item(index)
  106.     x = 4 + index * 240
  107.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  108.   end
  109. end
  110.  
  111. class Window_SkillBuy < Window_Selectable
  112.   def initialize(shop_goods)
  113.     super(0, 128, 368, 352)
  114.     @skill_shop_goods = shop_goods
  115.     self.active = false
  116.     refresh
  117.     self.index = 0
  118.   end
  119.   def skill
  120.     return @data[self.index]
  121.   end
  122.   def refresh
  123.     if self.contents != nil
  124.       self.contents.dispose
  125.       self.contents = nil
  126.     end
  127.     @data = []
  128.     for i in 0...@skill_shop_goods.size
  129.       skill = $data_skills[@skill_shop_goods[i]]
  130.       if skill != nil
  131.         @data.push(skill)
  132.       end
  133.     end
  134.     @item_max = @data.size
  135.     if @item_max > 0
  136.       self.contents = Bitmap.new(width - 32, row_max * 32)
  137.       for i in 0...@item_max
  138.         draw_item(i)
  139.       end
  140.     end
  141.   end
  142.   def draw_item(index)
  143.     skill = @data[index]
  144.     price = skill.price
  145.     enabled = (price <= $game_party.gold)
  146.     if enabled
  147.       self.contents.font.color = normal_color
  148.     else
  149.       self.contents.font.color = disabled_color
  150.     end
  151.     x = 4
  152.     y = index * 32
  153.     rect = Rect.new(x, y, self.width - 32, 32)
  154.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  155.     bitmap = RPG::Cache.icon(skill.icon_name)
  156.     opacity = self.contents.font.color == normal_color ? 255 : 128
  157.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  158.     self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  159.     self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  160.   end
  161.   def update_help
  162.     @help_window.set_text(skill == nil ? "" : skill.description)
  163.   end
  164. end
  165.  
  166. class Window_SkillStatus2 < Window_Selectable
  167.   def initialize
  168.     super(368, 128, 272, 352)
  169.     self.contents = Bitmap.new(width - 32, height - 32)
  170.     refresh
  171.     self.z = 200
  172.     self.active = false
  173.     self.index = -1
  174.   end
  175.   def refresh
  176.     self.contents.clear
  177.     @item_max = $game_party.actors.size
  178.     for i in 0...$game_party.actors.size
  179.       x = 64
  180.       y = i * 80
  181.       actor = $game_party.actors[i]
  182.       classs = $data_classes[$game_actors[actor.id].class_id]
  183.       draw_actor_graphic(actor, x - 40, y + 60)
  184.       draw_actor_name(actor, x - 13, y + 10)
  185.       if actor.skill_learn?($thing.id)
  186.         self.contents.font.color = crisis_color
  187.         $text = "Aquired"
  188.       elsif GameGuy::UseClasses
  189.         if classs.learnskills.include?($thing.id) && $thing.llevel <= actor.level
  190.           self.contents.font.color = normal_color
  191.           $text = "Can Learn"
  192.         elsif classs.learnskills.include?($thing.id) && $thing.llevel > actor.level
  193.           self.contents.font.color = disabled_color
  194.           $text = "Can Learn At Level " + $thing.llevel.to_s
  195.         else
  196.           self.contents.font.color = disabled_color
  197.           $text = "Can't Learn"
  198.         end
  199.       else
  200.         if actor.level >= $thing.llevel
  201.           self.contents.font.color = normal_color
  202.           $text = "Can Learn"
  203.         else
  204.           self.contents.font.color = disabled_color
  205.           $text = "Can Learn At Level " + $thing.llevel.to_s
  206.         end
  207.       end
  208.       self.contents.draw_text(x - 13, y + 40, 200, 32, $text)
  209.     end
  210.   end
  211.   def update_cursor_rect
  212.     if @index < 0
  213.       self.cursor_rect.empty
  214.     else
  215.       self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  216.     end
  217.   end
  218. end
  219.  
  220. class SkillShop
  221.   def initialize(skills)
  222.     @skills = skills
  223.   end
  224.   def main
  225.     @command = Window_SkillCommand.new
  226.     @help_window = Window_Help.new
  227.     @skillbuy = Window_SkillBuy.new(@skills)
  228.     @skillbuy.active = false
  229.     @skillbuy.help_window = @help_window
  230.     $thing = @skillbuy.skill
  231.     @status = Window_SkillStatus2.new
  232.     #@status.visible = false
  233.     @gold = Window_Gold.new
  234.     @gold.x = 480
  235.     @gold.y = 64
  236.     
  237.     Graphics.transition
  238.     loop do
  239.       Graphics.update
  240.       Input.update
  241.       update
  242.       if $scene != self
  243.         break
  244.       end
  245.     end
  246.     Graphics.freeze
  247.     @gold.dispose
  248.     @skillbuy.dispose
  249.     @help_window.dispose
  250.     @command.dispose
  251.     @status.dispose
  252.   end
  253.   def update
  254.     @gold.update
  255.     @status.update
  256.     @gold.refresh
  257.     @command.update
  258.     @skillbuy.update
  259.     @help_window.update
  260.     $thing = @skillbuy.skill
  261.     @status.refresh
  262.     if @command.active
  263.       update_command
  264.       return
  265.     end
  266.     
  267.     if @status.active
  268.       update_status
  269.       return
  270.     end
  271.     
  272.     if @skillbuy.active
  273.       update_buy
  274.       return
  275.     end
  276.   end
  277.   
  278.   def update_buy
  279.     if Input.trigger?(Input::B)
  280.       $game_system.se_play($data_system.cancel_se)
  281.       @skillbuy.active = false
  282.       @command.active = true
  283.       return
  284.     end
  285.     if Input.trigger?(Input::C)
  286.       $game_system.se_play($data_system.decision_se)
  287.       @skillbuy.active = false
  288.       @status.active = true
  289.       @status.visible = true
  290.       @status.index = 0 if @status.index == -1
  291.     end
  292.   end
  293.   
  294.   def update_command
  295.     if Input.trigger?(Input::B)
  296.       $game_system.se_play($data_system.cancel_se)
  297.       $scene = Scene_Map.new
  298.       return
  299.     end
  300.     if Input.trigger?(Input::C)
  301.       $game_system.se_play($data_system.decision_se)
  302.       case @command.index
  303.       when 0
  304.         @command.active = false
  305.         @skillbuy.active = true
  306.       when 1
  307.         $game_system.se_play($data_system.cancel_se)
  308.         $scene = Scene_Map.new
  309.       end
  310.       return
  311.     end
  312.   end
  313.   
  314.   def update_status
  315.     if Input.trigger?(Input::B)
  316.       @status.active = false
  317.       @skillbuy.active = true
  318.       return
  319.     end
  320.     if Input.trigger?(Input::C)
  321.       price = @skillbuy.skill.price
  322.       @actort = $game_party.actors[@status.index]
  323.       enabled = (price <= $game_party.gold)
  324.       
  325.       if enabled
  326.         if @actort.skill_learn?(@skillbuy.skill.id)
  327.           $game_system.se_play($data_system.buzzer_se)
  328.           return
  329.         end
  330.         if GameGuy::UseClasses
  331.           if $data_classes[@actort.class_id].learnskills.include?(@skillbuy.skill.id) && @actort.level >= @skillbuy.skill.llevel
  332.             @actort.learn_skill(@skillbuy.skill.id)
  333.             $game_party.lose_gold(@skillbuy.skill.price)
  334.             $game_system.se_play($data_system.decision_se)
  335.             @skillbuy.active = true
  336.             @status.active = false
  337.             @status.refresh
  338.             return
  339.           else
  340.             $game_system.se_play($data_system.buzzer_se)
  341.             return
  342.           end
  343.         else
  344.           if @actort.level >= @skillbuy.skill.llevel
  345.             @actort.learn_skill(@skillbuy.skill.id)
  346.             $game_party.lose_gold(@skillbuy.skill.price)
  347.             $game_system.se_play($data_system.decision_se)
  348.             @skillbuy.active = true
  349.             @status.active = false
  350.             @status.refresh
  351.           else
  352.             $game_system.se_play($data_system.buzzer_se)
  353.             return
  354.           end
  355.           return
  356.         end
  357.         
  358.       else
  359.         $game_system.se_play($data_system.buzzer_se)
  360.         return
  361.       end
  362.     end
  363.   end
  364.  
  365. end
Expand to see the code.


Instructions

In the script

FAQ

None yet

Compatibility

Wont work with other skill shop scripts
Tested with SDK by Sirus01 and it works with all versions :)

Credits and Thanks

  • game_guy ~ For making it

Author's Notes

Give credits and enjoy!

Terms and Conditions

Use for whatever just give credits.
anyone like this at all? I know theres otehr skillshops even already one posted here but I'd at least like to get some feedback on it.
I like it. It looks nice and is easy to use. I was wondering if it's possible to have this deduct from a variable instead of gold when learning abilities, and if you could have new abilities unlock based on completing a quest instead of being a certain level.
Ive got it in use, its only that you must edit the script for every skill u want for higher lvl.
And if you wanna varie prices, you gotta edit the script too, did all that, half an hour of work for all prices and all skill lvls


But yet, game_guy, i love it :D
@posts: Thanks for the comments guys.

@ravenfire: Okay first I'd have to mod window gold a bit to display the variable. As for adding skills to shops upon quest completion add this above $scene = Scene_Title.new in main

$skills = []

then every completed quest do this
$skills.push(skill_id)

then when calling the skill shop do this

$scene = SkillShop.new($skills)

@dylan: You saw through my disguise D:
Amazing skillzshop I've seen yet. I've tested it and, according to my computer, it works with the old versions of SDK. I didn't not get any errors.

Is it possible to add price discounts via variables? I'd like there to be an option to raise price, or better yet change prices in the middle of the game via events.

Good Job! 🙂
Thanks ^_^ I'm not sure.

Try changing the prices of a skill to this
$game_variables[1]

then change the variable one to different prices and test it out!

Let me know the results and thnx for the comment :)
Love this! Best I've seen thus far in the RMXP community! I never really liked how you learnt skills as you leveled... Diden't seem too realistic to me.

By the way, this works will the SDK. All versions.
~Good Job!
Thanks for letting me know ^_^
i relly like this script but i have request.

i have achevievement book in my game, and u get achievement points after unlocking achievement. i would want to
be able use those achievement points for this shop. can u make it or do i have to keep searching for more experienced scripter?
Nice script! By the way, The Foxy character looks awesome. Could you post/upload it? :)

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=65534