[REVIEW] Quick and Easy Skill Shop

Quick And Easy Skill ShopVersion: 1.0
By: LegacyX


Introduction
This script enables you to have a shop you can buy/learn skills from.

Features
  • Learn Skills
  • Individual Hero Skills
  • Learn Skills On Level

Screenshots
none yet sorry.

Script

script Spoiler
  1. #==============================================================================
  2. # ** Quick and Easy Skill Shop
  3. #==============================================================================
  4. #   Author: LegacyX
  5. #   Version: 1.0
  6. #   Build Date: 26.02.09
  7. #==============================================================================
  8. #  
  9. #==============================================================================
  10. =begin
  11. =============================
  12. * Info:
  13. =============================
  14.     After seeing Sephirothspawn's Skill Shop script i decided to make my own....so here it is,
  15.  i will try to comment this script alot for Newbs but it isn't hard to figure out what goes where.
  16. ==============================
  17.   * How to Use:                        
  18. ==============================
  19.     You will need to call "$skill_shop =[i]"   i = ID of skill...you must call the code for it to work!.
  20.  You will also need to call "$scene = Scene_Skill_Shop.new" to open up the Skill shop main window.
  21. ===============================
  22.  * Example:
  23. ===============================
  24.  
  25.   $skill_shop = [1,2,3,6,7]
  26.   $scene = Scene_Skill_Shop.new
  27.  
  28.  To set the text that appears in the Skill shop main windows Find   "# Skill Shop Config
  29. You can set Skill Price under "# Price Data".
  30. You can allow skills to be learnt by individual heros by finding "# Skill data".
  31.  
  32. This is the layout:
  33. [ID of skill, Level requirement for learn]
  34.  
  35. ==============================
  36.  * Special Thanks & Credits:
  37. ==============================
  38.  
  39.      Sephirothspawn: For all the coding help and the Skill Shop script which inspired me
  40.                     to make my own.
  41.  
  42. =end
  43. #===================================================
  44. # ^ Module SkillShop_Config Begins
  45. #===================================================
  46. module Skill_Shop
  47.  # Skill Shop Config
  48.      #Edit here
  49.     Shop_Message = "Welcome how can i help?"
  50.     How_Learn = "Who would you like to teach?"   #Text shown above Characters in shop window
  51.     Can_Learn = "Learn!"                                    #Text shown when a hearo can learn the skill
  52.     Can_Learn_Lv = "Learn on Lv"                        #text shown when a hero CAN learn the skill
  53.     Cant_Learn = "Unable to learn"                     #Text shown if a hero is unable to learn that perticular skill
  54.     Learnt = "Learned!"                                     #text shown when a hero has learnt a skill
  55.     Teach = "Teach!"                                          #Command (Buy in normal shops)
  56.     Cancel = "Exit"                                           #Command (Cancel in normal shops)
  57.  
  58.   # Add Prices Here
  59.   PRICE = {
  60.   0 => 100,   #Defualt price for skills with no price set
  61.   1 => 150,   #Price for Skill ID   1
  62.   2 => 550,
  63.   3 => 450,
  64.   }
  65.  
  66.   # Skill Data
  67.   # add the skills that each individual hero can learn.
  68.   #Layout is mentioned above.
  69.   SKILL_BUY = {
  70. 1 => [
  71.   [1,4],[2,3],[3,1],[7,1],
  72. ],
  73.  
  74. 2 => [
  75.   [1,4],[2,3],[3,1],[7,5],
  76. ],
  77.  
  78. 3 => [
  79.   [1,4],[2,3],[3,1],[7,5],
  80. ],
  81.  
  82. }
  83.   # Add Price
  84.   def self.skill_price(id)
  85.      if PRICE.include?(id)
  86.         return PRICE[id]
  87.      else
  88.         return PRICE[0]
  89.      end
  90.   end
  91.   # Add Hero id
  92.   def self.skill_buy(id)
  93.      if SKILL_BUY.include?(id)
  94.         return SKILL_BUY[id]
  95.      else
  96.         return []
  97.      end
  98.   end
  99. end
  100. #==============================================================================
  101. # ** Class Game_Actor
  102. #------------------------------------------------------------------------------
  103. #   This class handles the actor array. Refer to "$game_actors" for each
  104. #   instance of this class.
  105. #==============================================================================
  106. class Game_Actor < Game_Battler
  107.   def learn?(skill)
  108.      learn = skill_learn?(skill.id)
  109.      if learn
  110.         return false
  111.      else
  112.         return true
  113.      end
  114.   end
  115. end
  116. #==============================================================================
  117. #class Window_Skill_ShopCommand
  118. #==============================================================================
  119. class Window_Skill_ShopCommand < Window_Selectable
  120.   #--------------------------------------------------------------------------
  121.   # * Object Initialization
  122.   #--------------------------------------------------------------------------
  123.   def initialize
  124.      super(0, 64, 480, 64)
  125.      self.contents = Bitmap.new(width - 32, height - 32)
  126.      self.contents.font.name = "Tahoma"
  127.      self.contents.font.size = 21
  128.      @item_max = 2
  129.      @column_max = 2
  130.      #Commands Setup... if you wish to add more commands edit here.
  131.      s1 = Skill_Shop::Teach
  132.      s2 = Skill_Shop::Cancel
  133.      @commands = [s1, s2]
  134.      refresh
  135.      self.index = 0
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Refresh
  139.   #--------------------------------------------------------------------------
  140.   def refresh
  141.      self.contents.clear
  142.      for i in 0...@item_max
  143.         draw_item(i)
  144.      end
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   def draw_item(index)
  148.      x = 4 + index * 240
  149.      self.contents.draw_text(x, 0, 128, 32, @commands[index])
  150.   end
  151. end
  152. #==============================================================================
  153. #class Window_Skill_ShopBuy
  154. #==============================================================================
  155. class Window_Skill_ShopBuy < Window_Selectable
  156.   #--------------------------------------------------------------------------
  157.   # * Object Initialization
  158.   #--------------------------------------------------------------------------
  159.   def initialize(shop_goods)
  160.      super(0, 128, 368, 352)
  161.      @skill_shop_goods = $skill_shop
  162.      refresh
  163.      self.index = 0
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   def skill
  167.      return @data[self.index]
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # * Refresh
  171.   #--------------------------------------------------------------------------
  172.   def refresh
  173.      if self.contents != nil
  174.         self.contents.dispose
  175.         self.contents = nil
  176.      end
  177.      @data = []
  178.      for i in 0...@skill_shop_goods.size
  179.         skill = $data_skills[@skill_shop_goods[i]]
  180.         if skill != nil
  181.            @data.push(skill)
  182.         end
  183.      end
  184.      # If the number of items is not 0, it draws up bit map, drawing all item
  185.      @item_max = @data.size
  186.      if @item_max > 0
  187.         self.contents = Bitmap.new(width - 32, row_max * 32)
  188.      self.contents.font.name = "Tahoma"
  189.      self.contents.font.size = 21
  190.         for i in 0...@item_max
  191.            draw_item(i)
  192.         end
  193.      end
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   def draw_item(index)
  197.      skill = @data[index]
  198.      # Acquiring the frequency of possession of the item
  199.      price = Skill_Shop.skill_price(skill.id)
  200.      enabled = (price <= $game_party.gold)
  201.      # If price is not below the money in hand, at the same time the frequency of possession 99, usually in letter color
  202.      # So if is not, it sets to invalid letter color
  203.      if enabled
  204.         self.contents.font.color = normal_color
  205.      else
  206.         self.contents.font.color = disabled_color
  207.      end
  208.      x = 4
  209.      y = index * 32
  210.      rect = Rect.new(x, y, self.width - 32, 32)
  211.      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  212.      bitmap = RPG::Cache.icon(skill.icon_name)
  213.      opacity = self.contents.font.color == normal_color ? 255 : 128
  214.      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  215.      self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  216.      self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   def update_help
  220.      @help_window.set_text(skill == nil ? "" : skill.description)
  221.   end
  222. end
  223. #==============================================================================
  224. #class Window_Skill_ShopStatus
  225. #==============================================================================
  226. class Window_Skill_ShopStatus < Window_Selectable
  227.   #--------------------------------------------------------------------------
  228.   # * Object Initialization
  229.   #--------------------------------------------------------------------------
  230.   def initialize
  231.      super(368, 128, 272, 352)
  232.      self.contents = Bitmap.new(width - 32, height - 32)
  233.      self.contents.font.name = "Tahoma"
  234.      self.contents.font.size = 21
  235.      @item = nil
  236.      refresh
  237.      self.active = false
  238.      self.index = -1
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # * Refresh
  242.   #--------------------------------------------------------------------------
  243.   def refresh
  244.      self.contents.clear
  245.      @item_max = $game_party.actors.size
  246.      if @item == nil
  247.         return
  248.      end
  249.      self.contents.font.color = system_color
  250.      self.contents.draw_text(4, 0, self.width - 32, 32, Skill_Shop::How_Learn)
  251.      self.contents.font.color = normal_color
  252.      # Equipment supplementary information
  253.      for i in 0...$game_party.actors.size
  254.         # Acquiring the actor
  255.         can = false
  256.         lv = false
  257.         ac_lv = 0
  258.         actor = $game_party.actors[i]
  259.         can_learn = Skill_Shop.skill_buy(actor.id)
  260.         id = @item.id
  261.         for e in 0...can_learn.size
  262.            if can_learn[e][0] == id
  263.               can = true
  264.               if can_learn[e][1] <= actor.level
  265.                  lv = true
  266.               else
  267.                  lv = false
  268.                  ac_lv = can_learn[e][1]
  269.               end
  270.               break
  271.            else
  272.               can = false
  273.            end
  274.         end
  275.         enabled = (can and lv and actor.learn?(@item))
  276.         # If equipment possibility if usually in letter color, the impossibility, it sets to invalid letter color
  277.         if enabled
  278.            self.contents.font.color = normal_color
  279.         else
  280.            self.contents.font.color = disabled_color
  281.         end
  282.         #Draw Character Pic
  283.         bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  284.         cw = bitmap.rect.width / 4
  285.         ch = bitmap.rect.height / 4
  286.         src_rect = Rect.new(0, 0, cw, ch)
  287.         cx = contents.text_size(actor.name).width
  288.         self.contents.blt(cx, 64 + 64 * i, bitmap, src_rect)
  289.         # Drawing the name of the actor
  290.         self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  291.         # Check Skill
  292.         if can == false
  293.            text = Skill_Shop::Cant_Learn
  294.         elsif can == true and lv == false
  295.            ac = ac_lv.to_s
  296.            text = Skill_Shop::Can_Learn_Lv + " " + ac + "+"
  297.         elsif actor.learn?(@item) == false
  298.            text = Skill_Shop::Learnt
  299.         else
  300.            text = Skill_Shop::Can_Learn
  301.         end
  302.         # Drawing the item
  303.         self.contents.draw_text(124, 64 + 64 * i, 112, 32, text, 2)
  304.      end
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   def item=(item)
  308.      if @item != item
  309.         @item = item
  310.         refresh
  311.      end
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   def update_cursor_rect
  315.      # Cursor position as for -1 all selection, -2 below independence selection (user himself)
  316.      if @index < 0
  317.         self.cursor_rect.empty
  318.      else
  319.         self.cursor_rect.set(0, 62 + @index * 64, self.width - 32, 50)
  320.      end
  321.   end
  322. end
  323. #==============================================================================
  324. #class Scene_Skill_Shop
  325. #==============================================================================
  326. #
  327. #
  328. #-----I advise you not to touch anything past here unless you know what you are doing.-------
  329. #
  330. #
  331. class Scene_Skill_Shop
  332.   #--------------------------------------------------------------------------
  333.   def main
  334.      # Drawing up the help window
  335.      @help_window = Window_Help.new
  336.      # Drawing up the command window
  337.      @command_window = Window_Skill_ShopCommand.new
  338.      # Drawing up the Goldwyn dough
  339.      @gold_window = Window_Gold.new
  340.      @gold_window.x = 480
  341.      @gold_window.y = 64
  342.      # Drawing up the dummy window
  343.      @dummy_window = Window_Base.new(0, 128, 640, 352)
  344.      # Drawing up the purchase window
  345.      @buy_window = Window_Skill_ShopBuy.new($game_temp.shop_goods)
  346.      @buy_window.active = false
  347.      @buy_window.visible = false
  348.      @buy_window.help_window = @help_window
  349.      # Drawing up the status window
  350.      @status_window = Window_Skill_ShopStatus.new
  351.      @status_window.visible = false
  352.      @status_window.active
  353.      # Transition execution
  354.      Graphics.transition
  355.      # Main loop
  356.      loop do
  357.         # Renewing the game picture
  358.         Graphics.update
  359.         # Updating the information of input
  360.         Input.update
  361.         # Frame renewal
  362.         update
  363.         # When the picture changes, discontinuing the loop
  364.         if $scene != self
  365.            break
  366.         end
  367.      end
  368.      # Transition preparation
  369.      Graphics.freeze
  370.      # Releasing the window
  371.      @help_window.dispose
  372.      @command_window.dispose
  373.      @gold_window.dispose
  374.      @dummy_window.dispose
  375.      @buy_window.dispose
  376.      @status_window.dispose
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   def update
  380.      # Renewing the window
  381.      @help_window.update
  382.      @command_window.update
  383.      @gold_window.update
  384.      @dummy_window.update
  385.      @buy_window.update
  386.      @status_window.update
  387.      # When the command window is active,: Update_command is called
  388.      if @command_window.active
  389.         update_command
  390.         return
  391.      end
  392.      # When the purchase window is active,: Update_buy is called
  393.      if @buy_window.active
  394.         update_buy
  395.         return
  396.      end
  397.      # When the target window is active,: Update_target is called
  398.      if @status_window.active
  399.         update_target
  400.         return
  401.      end
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   def update_command
  405.      # The B when button is pushed
  406.      if Input.trigger?(Input::B)
  407.         # Performing cancellation SE
  408.         $game_system.se_play($data_system.cancel_se)
  409.         # Change to map picture
  410.         $scene = Scene_Map.new
  411.         return
  412.      end
  413.      # When C button is pushed
  414.      if Input.trigger?(Input::C)
  415.         # Eliminating the help text
  416.         @help_window.set_text("")
  417.         # It diverges at cursor position of the command window
  418.         case @command_window.index
  419.         when 0   # It purchases
  420.            # Performing decision SE
  421.            $game_system.se_play($data_system.decision_se)
  422.            # State of window to purchase mode
  423.            @command_window.active = false
  424.            @dummy_window.visible = false
  425.            @buy_window.active = true
  426.            @buy_window.visible = true
  427.            @buy_window.refresh
  428.            @status_window.visible = true
  429.         when 1   # It stops
  430.            # Performing decision SE
  431.            $game_system.se_play($data_system.decision_se)
  432.            # Change to map picture
  433.            $scene = Scene_Map.new
  434.         end
  435.         return
  436.      end
  437.   end
  438.   #--------------------------------------------------------------------------
  439.   def update_buy
  440.      # Setting the item of the status window
  441.      @status_window.item = @buy_window.skill
  442.      # The B when button is pushed
  443.      if Input.trigger?(Input::B)
  444.         # Performing cancellation SE
  445.         $game_system.se_play($data_system.cancel_se)
  446.         # State of window to early mode
  447.         @command_window.active = true
  448.         @dummy_window.visible = true
  449.         @buy_window.active = false
  450.         @buy_window.visible = false
  451.         @status_window.visible = false
  452.         @status_window.item = nil
  453.         # Eliminating the help text
  454.         @help_window.set_text("")
  455.         return
  456.      end
  457.      # When C button is pushed
  458.      if Input.trigger?(Input::C)
  459.         # Acquiring the item
  460.         @item = @buy_window.skill
  461.         @price = Skill_Shop.skill_price(@item.id)
  462.         enabled = (@price <= $game_party.gold)
  463.         # When the item is invalid, or when price it is on from the money in hand
  464.         unless   enabled
  465.            # Performing buzzer SE
  466.            $game_system.se_play($data_system.buzzer_se)
  467.            return
  468.         end
  469.         # Performing decision SE
  470.         $game_system.se_play($data_system.decision_se)
  471.         @buy_window.active = false
  472.         @status_window.active = true
  473.         @status_window.index = 0
  474.      end
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   def update_target
  478.      # The B when button is pushed
  479.      if Input.trigger?(Input::B)
  480.         # Performing cancellation SE
  481.         $game_system.se_play($data_system.cancel_se)
  482.         # Eliminating the target window
  483.         @buy_window.active = true
  484.         @status_window.index =- 1
  485.         @status_window.active = false
  486.         return
  487.      end
  488.      # When C button is pushed
  489.      if Input.trigger?(Input::C)
  490.         @actor = $game_party.actors[@status_window.index]
  491.         can = false
  492.         lv = false
  493.         can_learn = Skill_Shop.skill_buy(@actor.id)
  494.         id = @item.id
  495.         for i in 0...can_learn.size
  496.            if can_learn[i][0] == id
  497.               can = true
  498.               if can_learn[i][1] <= @actor.level
  499.                  lv = true
  500.               else
  501.                  lv = false
  502.               end
  503.               break
  504.            else
  505.               can = false
  506.            end
  507.         end
  508.         enabled = (can and lv and @actor.learn?(@item))
  509.         # When with SP and so on is cut off and it becomes not be able to use
  510.         unless enabled
  511.            # Performing buzzer SE
  512.            $game_system.se_play($data_system.buzzer_se)
  513.            return
  514.         end
  515.         # Performing shop SE
  516.         $game_system.se_play($data_system.shop_se)
  517.         @actor.learn_skill(@item.id)
  518.         $game_party.lose_gold(@price)
  519.         @buy_window.refresh
  520.         @gold_window.refresh
  521.         @status_window.refresh
  522.         @buy_window.active = true
  523.         @status_window.index =- 1
  524.         @status_window.active = false
  525.        end
  526.   end
  527. end
  528.  
  529.  
Expand to see the code.


Instructions
Place above MAin and Below Scene_Debug, futher intructions in code.
Use $scene = Scene_Skill_Shop.new to call Skill Shop window
(if there any problems Just ask.)

Compatibility
Cannot be used with RMVX yet.

Credits and Thanks
Sephirothspawn: For all the coding help you have given me. And for your Skill Shop script which has inspired me
to make my own.
Author's Notes
I will be making the script compatible with the SDK soon.. that will be version 1.1
and i will be also trying to make it compatible with RMVX.

Terms and Conditions
No limits....but i would like some credit if you use this script in your game.
So..what do you think ???
You actually made the silliest mistake of ruby/programming ever. You gave the module the name Skill_Shop, while ALL the other module calls on the whole script are going with SKILL_SHOP::*the variable name here*. Just change the module name and you have a working script.

Besides that, the script is quite good actually, and it's useful to some people. Good job with!
oh... im sorry about that..

but thanks for the comment =]

Edit:

I have changed it to Config... will you let me know if any errors accure please...ass well as what you did you make the error accure?
I didn't manage to test the script with the changed name, but I advise you to change the module's name to something like SkillShop_Config, as Config is a pretty common term used when you start something.
Can you make a VX version of this script? I see it is interesting
:grin: :grin: :grin:
When you have more than four heroes in your party, the window does not scroll. It would be more user friendly if it did so that users don't have to set up their party every time.

Also, can it be set up to run on AP?
@Khoa

im already trying to make it so that its compatible with VX...

@Sol_fury..
I can try to make it run on AP and.. im not sure about the party thing...but ill have a play around ok.

@cairn
thanks.. il change it right away.

Edit:

changed module Config to; Module SkillShop_Config
Someone named Nechigawara Sanzenin made this almost exact script a while back. Even the typos are the same. Are you that person by chance?
no...but somone did help me make this...so that could have been him.
Im now 25% completed with the VX conversion...shouldn't be very long now. :grin:
Nice (: . I think it looks kinda interesting
:grin:
thanks :thumb:
I wonder why all those stupid 's came from, so i decided to remove them. But after i removed the 's it worked to playtest but when i entered the Teach! an error occoured. and it dint work for me so i changed the module, hope that was okay? And then it worked.


So now its working,

I think its great, very useful to me and my game, Thanks!


Edit: So i wont post it if you dont think its okay, I mean, in this topic like a reply :-) Or in PM
No, you can post it :)

ill aslo edit it later and have a look see :P
LegacyX wrote:
No, you can post it :)

ill aslo edit it later and have a look see :P


Alright...

Here it goes:
  1. #==============================================================================
  2. # ** Quick and Easy Skill Shop By FF12_master **
  3. #==============================================================================
  4. #   Author: FF12_master
  5. #   Version: 1.0
  6. #   Build Date: 26.02.09
  7. #==============================================================================
  8. #  
  9. #==============================================================================
  10. =begin
  11. =============================
  12. * Info:
  13. =============================
  14.      After seeing Sephirothspawn's Skill Shop script i decided to make my own....so here it is,
  15.   i will try to comment this script alot for Newbs but it isn't hard to figure out what goes where.
  16. ==============================
  17.    * How to Use:                        
  18. ==============================
  19.      You will need to call "$skill_shop =[i]"   i = ID of skill...you must call the code for it to work!.
  20.   You will also need to call "$scene = Scene_Skill_Shop.new" to open up the Skill shop main window.
  21. ===============================
  22.   * Example:
  23. ===============================
  24.  
  25.    $skill_shop = [1,2,3,6,7]
  26.    $scene = Scene_Skill_Shop.new
  27.  
  28.   To set the text that appears in the Skill shop main windows Find   "# Skill Shop Config
  29. You can set Skill Price under "# Price Data".
  30. You can allow skills to be learnt by individual heros by finding "# Skill data".
  31.  
  32. This is the layout:
  33. [ID of skill, Level requirement for learn]
  34.  
  35. ==============================
  36.   * Special Thanks & Credits:
  37. ==============================
  38.  
  39.       Sephirothspawn: For all the coding help and the Skill Shop script which inspired me
  40.                      to make my own.
  41.  
  42. =end
  43. #===================================================
  44. # ^ Module SkillShop_Config Begins
  45. #===================================================
  46. module SkillShop_Config
  47.   # Skill Shop Config
  48.       #Edit here
  49.      Shop_Message = "Welcome how can i help?"
  50.      How_Learn = "Who would you like to teach?"   #Text shown above Characters in shop window
  51.      Can_Learn = "Learn"                                    #Text shown when a hearo can learn the skill
  52.      Can_Learn_Lv = "Learn On Lv"                        #text shown when a hero CAN learn the skill
  53.      Cant_Learn = "Unable To Learn"                     #Text shown if a hero is unable to learn that perticular skill
  54.      Learnt = "Learned"                                     #text shown when a hero has learnt a skill
  55.      Teach = "Teach"                                          #Command (Buy in normal shops)
  56.      Cancel = "Exit"                                           #Command (Cancel in normal shops)
  57.  
  58.    # Add Prices Here
  59.    PRICE = {
  60.    0 => 100,   #Defualt price for skills with no price set
  61.    1 => 150,   #Price for Skill ID   1
  62.    2 => 550,
  63.    3 => 450,
  64.    4 => 746,
  65.    5 => 765,
  66.    6 => 765,
  67.    7 => 765,
  68.    8 => 765,
  69.    9 => 765,
  70.    10 => 765,
  71.    11 => 765,
  72.    12 => 765,
  73.    13 => 765,
  74.    14 => 765,
  75.    15 => 765,
  76.    16 => 765,
  77.    17 => 765,
  78.    18 => 765,
  79.    19 => 765,
  80.    20 => 765,
  81.    }
  82.    # Skill Data
  83.    # add the skills that each individual hero can learn.
  84.    #Layout is mentioned above.
  85.    SKILL_BUY = {
  86. 1 => [
  87.    [1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],
  88. ],
  89.  
  90. 2 => [
  91.    [1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],
  92. ],
  93.  
  94. 3 => [
  95.    [1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1],[10,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],
  96. ],
  97.  
  98. }
  99.    # Add Price
  100.    def self.skill_price(id)
  101.       if PRICE.include?(id)
  102.          return PRICE[id]
  103.       else
  104.          return PRICE[0]
  105.       end
  106.    end
  107.    # Add Hero id
  108.    def self.skill_buy(id)
  109.       if SKILL_BUY.include?(id)
  110.          return SKILL_BUY[id]
  111.       else
  112.          return []
  113.       end
  114.    end
  115. end
  116. #==============================================================================
  117. # ** Class Game_Actor
  118. #------------------------------------------------------------------------------
  119. #   This class handles the actor array. Refer to "$game_actors" for each
  120. #   instance of this class.
  121. #==============================================================================
  122. class Game_Actor < Game_Battler
  123.    def learn?(skill)
  124.       learn = skill_learn?(skill.id)
  125.       if learn
  126.          return false
  127.       else
  128.          return true
  129.       end
  130.    end
  131. end
  132. #==============================================================================
  133. #class Window_Skill_ShopCommand
  134. #==============================================================================
  135. class Window_Skill_ShopCommand < Window_Selectable
  136.    #--------------------------------------------------------------------------
  137.    # * Object Initialization
  138.    #--------------------------------------------------------------------------
  139.    def initialize
  140.       super(0, 64, 480, 64)
  141.       self.contents = Bitmap.new(width - 32, height - 32)
  142.       self.contents.font.name = "Tahoma"
  143.       self.contents.font.size = 21
  144.       @item_max = 2
  145.       @column_max = 2
  146.       #Commands Setup... if you wish to add more commands edit here.
  147.       s1 = SkillShop_Config::Teach
  148.       s2 = SkillShop_Config::Cancel
  149.       @commands = [s1, s2]
  150.       refresh
  151.       self.index = 0
  152.    end
  153.    #--------------------------------------------------------------------------
  154.    # * Refresh
  155.    #--------------------------------------------------------------------------
  156.    def refresh
  157.       self.contents.clear
  158.       for i in 0...@item_max
  159.          draw_item(i)
  160.       end
  161.    end
  162.    #--------------------------------------------------------------------------
  163.    def draw_item(index)
  164.       x = 4 + index * 240
  165.       self.contents.draw_text(x, 0, 128, 32, @commands[index])
  166.    end
  167. end
  168. #==============================================================================
  169. #class Window_Skill_ShopBuy
  170. #==============================================================================
  171. class Window_Skill_ShopBuy < Window_Selectable
  172.    #--------------------------------------------------------------------------
  173.    # * Object Initialization
  174.    #--------------------------------------------------------------------------
  175.    def initialize(shop_goods)
  176.       super(0, 128, 368, 352)
  177.       @skill_shop_goods = $skill_shop
  178.       refresh
  179.       self.index = 0
  180.    end
  181.    #--------------------------------------------------------------------------
  182.    def skill
  183.       return @data[self.index]
  184.    end
  185.    #--------------------------------------------------------------------------
  186.    # * Refresh
  187.    #--------------------------------------------------------------------------
  188.    def refresh
  189.       if self.contents != nil
  190.          self.contents.dispose
  191.          self.contents = nil
  192.       end
  193.       @data = []
  194.       for i in 0...@skill_shop_goods.size
  195.          skill = $data_skills[@skill_shop_goods[i]]
  196.          if skill != nil
  197.             @data.push(skill)
  198.          end
  199.       end
  200.       # If the number of items is not 0, it draws up bit map, drawing all item
  201.       @item_max = @data.size
  202.       if @item_max > 0
  203.          self.contents = Bitmap.new(width - 32, row_max * 32)
  204.       self.contents.font.name = "Tahoma"
  205.       self.contents.font.size = 21
  206.          for i in 0...@item_max
  207.             draw_item(i)
  208.          end
  209.       end
  210.    end
  211.    #--------------------------------------------------------------------------
  212.    def draw_item(index)
  213.       skill = @data[index]
  214.       # Acquiring the frequency of possession of the item
  215.       price = SkillShop_Config.skill_price(skill.id)
  216.       enabled = (price <= $game_party.gold)
  217.       # If price is not below the money in hand, at the same time the frequency of possession 99, usually in letter color
  218.       # So if is not, it sets to invalid letter color
  219.       if enabled
  220.          self.contents.font.color = normal_color
  221.       else
  222.          self.contents.font.color = disabled_color
  223.       end
  224.       x = 4
  225.       y = index * 32
  226.       rect = Rect.new(x, y, self.width - 32, 32)
  227.       self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  228.       bitmap = RPG::Cache.icon(skill.icon_name)
  229.       opacity = self.contents.font.color == normal_color ? 255 : 128
  230.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  231.       self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
  232.       self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  233.    end
  234.    #--------------------------------------------------------------------------
  235.    def update_help
  236.       @help_window.set_text(skill == nil ? "" : skill.description)
  237.    end
  238. end
  239. #==============================================================================
  240. #class Window_Skill_ShopStatus
  241. #==============================================================================
  242. class Window_Skill_ShopStatus < Window_Selectable
  243.    #--------------------------------------------------------------------------
  244.    # * Object Initialization
  245.    #--------------------------------------------------------------------------
  246.    def initialize
  247.       super(368, 128, 272, 352)
  248.       self.contents = Bitmap.new(width - 32, height - 32)
  249.       self.contents.font.name = "Tahoma"
  250.       self.contents.font.size = 21
  251.       @item = nil
  252.       refresh
  253.       self.active = false
  254.       self.index = -1
  255.    end
  256.    #--------------------------------------------------------------------------
  257.    # * Refresh
  258.    #--------------------------------------------------------------------------
  259.    def refresh
  260.       self.contents.clear
  261.       @item_max = $game_party.actors.size
  262.       if @item == nil
  263.          return
  264.       end
  265.       self.contents.font.color = system_color
  266.       self.contents.draw_text(4, 0, self.width - 32, 32,  SkillShop_Config::How_Learn)
  267.       self.contents.font.color = normal_color
  268.       # Equipment supplementary information
  269.       for i in 0...$game_party.actors.size
  270.          # Acquiring the actor
  271.          can = false
  272.          lv = false
  273.          ac_lv = 0
  274.          actor = $game_party.actors[i]
  275.          can_learn =  SkillShop_Config.skill_buy(actor.id)
  276.          id = @item.id
  277.          for e in 0...can_learn.size
  278.             if can_learn[e][0] == id
  279.                can = true
  280.                if can_learn[e][1] <= actor.level
  281.                   lv = true
  282.                else
  283.                   lv = false
  284.                   ac_lv = can_learn[e][1]
  285.                end
  286.                break
  287.             else
  288.                can = false
  289.             end
  290.          end
  291.          enabled = (can and lv and actor.learn?(@item))
  292.          # If equipment possibility if usually in letter color, the impossibility, it sets to invalid letter color
  293.          if enabled
  294.             self.contents.font.color = normal_color
  295.          else
  296.             self.contents.font.color = disabled_color
  297.          end
  298.          #Draw Character Pic
  299.          bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  300.          cw = bitmap.rect.width / 4
  301.          ch = bitmap.rect.height / 4
  302.          src_rect = Rect.new(0, 0, cw, ch)
  303.          cx = contents.text_size(actor.name).width
  304.          self.contents.blt(cx, 64 + 64 * i, bitmap, src_rect)
  305.          # Drawing the name of the actor
  306.          self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  307.          # Check Skill
  308.          if can == false
  309.             text =  SkillShop_Config::Cant_Learn
  310.          elsif can == true and lv == false
  311.             ac = ac_lv.to_s
  312.             text =  SkillShop_Config::Can_Learn_Lv + " " + ac + "+"
  313.          elsif actor.learn?(@item) == false
  314.             text =  SkillShop_Config::Learnt
  315.          else
  316.             text =  SkillShop_Config::Can_Learn
  317.          end
  318.          # Drawing the item
  319.          self.contents.draw_text(124, 64 + 64 * i, 112, 32, text, 2)
  320.       end
  321.    end
  322.    #--------------------------------------------------------------------------
  323.    def item=(item)
  324.       if @item != item
  325.          @item = item
  326.          refresh
  327.       end
  328.    end
  329.    #--------------------------------------------------------------------------
  330.    def update_cursor_rect
  331.       # Cursor position as for -1 all selection, -2 below independence selection (user himself)
  332.       if @index < 0
  333.          self.cursor_rect.empty
  334.       else
  335.          self.cursor_rect.set(0, 62 + @index * 64, self.width - 32, 50)
  336.       end
  337.    end
  338. end
  339. #==============================================================================
  340. #class Scene_Skill_Shop
  341. #==============================================================================
  342. #
  343. #
  344. #-----I advise you not to touch anything past here unless you know what you are doing.-------
  345. #
  346. #
  347. class Scene_Skill_Shop
  348.    #--------------------------------------------------------------------------
  349.    def main
  350.       # Drawing up the help window
  351.       @help_window = Window_Help.new
  352.       # Drawing up the command window
  353.       @command_window = Window_Skill_ShopCommand.new
  354.       # Drawing up the Goldwyn dough
  355.       @gold_window = Window_Gold.new
  356.       @gold_window.x = 480
  357.       @gold_window.y = 64
  358.       # Drawing up the dummy window
  359.       @dummy_window = Window_Base.new(0, 128, 640, 352)
  360.       # Drawing up the purchase window
  361.       @buy_window = Window_Skill_ShopBuy.new($game_temp.shop_goods)
  362.       @buy_window.active = false
  363.       @buy_window.visible = false
  364.       @buy_window.help_window = @help_window
  365.       # Drawing up the status window
  366.       @status_window = Window_Skill_ShopStatus.new
  367.       @status_window.visible = false
  368.       @status_window.active
  369.       # Transition execution
  370.       Graphics.transition
  371.       # Main loop
  372.       loop do
  373.          # Renewing the game picture
  374.          Graphics.update
  375.          # Updating the information of input
  376.          Input.update
  377.          # Frame renewal
  378.          update
  379.          # When the picture changes, discontinuing the loop
  380.          if $scene != self
  381.             break
  382.          end
  383.       end
  384.       # Transition preparation
  385.       Graphics.freeze
  386.       # Releasing the window
  387.       @help_window.dispose
  388.       @command_window.dispose
  389.       @gold_window.dispose
  390.       @dummy_window.dispose
  391.       @buy_window.dispose
  392.       @status_window.dispose
  393.    end
  394.    #--------------------------------------------------------------------------
  395.    def update
  396.       # Renewing the window
  397.       @help_window.update
  398.       @command_window.update
  399.       @gold_window.update
  400.       @dummy_window.update
  401.       @buy_window.update
  402.       @status_window.update
  403.       # When the command window is active,: Update_command is called
  404.       if @command_window.active
  405.          update_command
  406.          return
  407.       end
  408.       # When the purchase window is active,: Update_buy is called
  409.       if @buy_window.active
  410.          update_buy
  411.          return
  412.       end
  413.       # When the target window is active,: Update_target is called
  414.       if @status_window.active
  415.          update_target
  416.          return
  417.       end
  418.    end
  419.    #--------------------------------------------------------------------------
  420.    def update_command
  421.       # The B when button is pushed
  422.       if Input.trigger?(Input::B)
  423.          # Performing cancellation SE
  424.          $game_system.se_play($data_system.cancel_se)
  425.          # Change to map picture
  426.          $scene = Scene_Map.new
  427.          return
  428.       end
  429.       # When C button is pushed
  430.       if Input.trigger?(Input::C)
  431.          # Eliminating the help text
  432.          @help_window.set_text("")
  433.          # It diverges at cursor position of the command window
  434.          case @command_window.index
  435.          when 0   # It purchases
  436.             # Performing decision SE
  437.             $game_system.se_play($data_system.decision_se)
  438.             # State of window to purchase mode
  439.             @command_window.active = false
  440.             @dummy_window.visible = false
  441.             @buy_window.active = true
  442.             @buy_window.visible = true
  443.             @buy_window.refresh
  444.             @status_window.visible = true
  445.          when 1   # It stops
  446.             # Performing decision SE
  447.             $game_system.se_play($data_system.decision_se)
  448.             # Change to map picture
  449.             $scene = Scene_Map.new
  450.          end
  451.          return
  452.       end
  453.    end
  454.    #--------------------------------------------------------------------------
  455.    def update_buy
  456.       # Setting the item of the status window
  457.       @status_window.item = @buy_window.skill
  458.       # The B when button is pushed
  459.       if Input.trigger?(Input::B)
  460.          # Performing cancellation SE
  461.          $game_system.se_play($data_system.cancel_se)
  462.          # State of window to early mode
  463.          @command_window.active = true
  464.          @dummy_window.visible = true
  465.          @buy_window.active = false
  466.          @buy_window.visible = false
  467.          @status_window.visible = false
  468.          @status_window.item = nil
  469.          # Eliminating the help text
  470.          @help_window.set_text("")
  471.          return
  472.       end
  473.       # When C button is pushed
  474.       if Input.trigger?(Input::C)
  475.          # Acquiring the item
  476.          @item = @buy_window.skill
  477.          @price =  SkillShop_Config.skill_price(@item.id)
  478.          enabled = (@price <= $game_party.gold)
  479.          # When the item is invalid, or when price it is on from the money in hand
  480.          unless   enabled
  481.             # Performing buzzer SE
  482.             $game_system.se_play($data_system.buzzer_se)
  483.             return
  484.          end
  485.          # Performing decision SE
  486.          $game_system.se_play($data_system.decision_se)
  487.          @buy_window.active = false
  488.          @status_window.active = true
  489.          @status_window.index = 0
  490.       end
  491.    end
  492.    #--------------------------------------------------------------------------
  493.    def update_target
  494.       # The B when button is pushed
  495.       if Input.trigger?(Input::B)
  496.          # Performing cancellation SE
  497.          $game_system.se_play($data_system.cancel_se)
  498.          # Eliminating the target window
  499.          @buy_window.active = true
  500.          @status_window.index =- 1
  501.          @status_window.active = false
  502.          return
  503.       end
  504.       # When C button is pushed
  505.       if Input.trigger?(Input::C)
  506.          @actor = $game_party.actors[@status_window.index]
  507.          can = false
  508.          lv = false
  509.          can_learn =  SkillShop_Config.skill_buy(@actor.id)
  510.          id = @item.id
  511.          for i in 0...can_learn.size
  512.             if can_learn[i][0] == id
  513.                can = true
  514.                if can_learn[i][1] <= @actor.level
  515.                   lv = true
  516.                else
  517.                   lv = false
  518.                end
  519.                break
  520.             else
  521.                can = false
  522.             end
  523.          end
  524.          enabled = (can and lv and @actor.learn?(@item))
  525.          # When with SP and so on is cut off and it becomes not be able to use
  526.          unless enabled
  527.             # Performing buzzer SE
  528.             $game_system.se_play($data_system.buzzer_se)
  529.             return
  530.          end
  531.          # Performing shop SE
  532.          $game_system.se_play($data_system.shop_se)
  533.          @actor.learn_skill(@item.id)
  534.          $game_party.lose_gold(@price)
  535.          @buy_window.refresh
  536.          @gold_window.refresh
  537.          @status_window.refresh
  538.          @buy_window.active = true
  539.          @status_window.index =- 1
  540.          @status_window.active = false
  541.         end
  542.    end
  543. end
Expand to see the code.
Cheers. Im thinking of Tweaking it a little bit, Making it "Compact" and nicer too look at.

But thanks for the tweak Naith
LegacyX wrote:
Cheers. Im thinking of Tweaking it a little bit, Making it "Compact" and nicer too look at.

But thanks for the tweak Naith


No problem :thumb:
Right, hopefully that's all the errors corrected.

if its not please inform me :thumb:

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