Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Skill Shop Job Point System

Rue

Member

Can I kindly request for a skill shop-like skill system.
This is how it should work.

*When a specific switch is turned on, you gain JP or Job Points.
Ex: If Switch (y) = On gain (x) JP for [Actor ID]
Switch 001 = On gain 5 JP for Arshes
Switch 002 = On gain 10 JP for Basil

*Job Points are then used for purchasing skills.

Here is the Shop Scene:

http://img30.picoodle.com/img/img30/8/6 ... 088a3f.png[/IMG]

There are Actor Tabs that will lead to their respective Shop Scenes.
There will be a switch that will make certain skills to be purchasable.

Ex: Switch 003= ON Heal,Greater Heal and Fire will be available.

*But as you can see, they are still Unknown skills and written as ????? but colored as white. Unpurchasable skills are colored gray. At the right is the JP cost. The right box contains informations about the skill exept the name of the skill.

If the skill is purchased:

http://img29.picoodle.com/img/img29/8/6/16/f_untitledm_14e71ba.png[/IMG]

Perfect way of gaining JP is by finishing Job Missions. So It will be good if this will be compatible with trickster's Advance Mission Shop Manager and also run with MACL 1.5 cause all my scripts use that version.
If there's a script already simillar to this, can someone redirect me?

EDIT: The Actor SP at the lower right supposed to be Actor JP.
I think it is also better to use call script than switches to gain JP.
 
Ops.... there is a bilion of bumps XD
I read only now your request and i want realize your dreams!!
I have made this system 1 months ago
Code:
#===============================================================================
# TSL Skill Development System
#===============================================================================
# The Sleeping Leonhart
# Version 1.0
# 26-7-2007
#===============================================================================
# Use $scene = Scene_SkillShop.new to call the skill shop,
# but before you must declarate the skill for each actor with this command:
# $game_temp.skill_goods[actor id] = [skill id 1,skill id 2,etc...]
# Example:
# $game_temp.skill_goods[1] = [4,5,6,7] sell to Aluxes the skill Remedy, Greater Remedy, Raise e Fire.
# To call the learning scene use this: $scene = Scene_SkillLearn.new.
#===============================================================================

module Leonhart_DS
  #number of AP gived by the monster Syntax:
  #ENEMY_AP_VALUES = {Monster Id => AP number}
  ENEMY_AP_VALUES = {1 => 5, 2 => 2}
  
  #the AP for non declarated monster
  DEFAULT_ENEMY_AP = 1
  
  #the AP price for each skill Syntax:
  #SKILL_AP = {Skill Id => Required AP}
  SKILL_AP = {1=>10}
  
  #the gold price for each skill Syntax:
  #SKILL_PRICE = {Skill Id => Required Gold}
  SKILL_PRICE = {1=>500,4=>400}
  
  #the AP price for non declarated skill
  SKILL_AP.default = 5
  
  #the gold price for non declarated skill
  SKILL_PRICE.default = 100
end

class Game_Temp
  attr_accessor :skill_goods
  alias tslds_gametemp_init initialize
  def initialize
    @skill_goods = []
    tslds_gametemp_init
  end
end

class Game_Actor < Game_Battler
  attr_reader   :ap
  attr_reader   :temp_skills
  attr_reader   :shop_skills
  alias tslds_gameactor_setup setup
  def setup(actor_id)
    @ap = 0
    @temp_skills = []
    @shop_skills = []
    tslds_gameactor_setup(actor_id)
  end
  def ap=(ap)
    @ap = [[ap, 9999999].min, 0].max
  end
  def learn_temp_skill(skill_id)
    if skill_id > 0 and not temp_skill_learned?(skill_id)
      @temp_skills.push(skill_id)
      @temp_skills.sort!
    end
  end
  def learn_skill(skill_id)
    if skill_id > 0 and not skill_learn?(skill_id)
      @skills.push(skill_id)
      @skills.sort!
    end
  end
  def temp_skill_learned?(skill_id)
    return @temp_skills.include?(skill_id)
  end
  def shop_skill_learned?(skill_id)
    return @shop_skills.include?(skill_id)
  end
end

module RPG
  class Skill
    def ap
      return Leonhart_DS::SKILL_AP[id]
    end
    def price
      return Leonhart_DS::SKILL_PRICE[id]
    end
  end
end

class Window_SkillShopCommand < Window_Selectable
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item_max = 2
    @column_max = 2
    @commands = ["Buy", "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_SkillLearnCommand < Window_Selectable
  def initialize
    super(0, 64, 640, 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 * 320
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end

class Window_SkillBuy < Window_Selectable
  def initialize(id , idx)
    super(0, 128, 368, 352)
    @idx = idx
    @shop_goods = $game_temp.skill_goods[id[idx]]
    refresh
    self.index = 0
  end
  def item
    return @data[self.index]
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0..@shop_goods.size
      item = $data_skills[@shop_goods[i].to_i]
      if item != nil
        @data.push(item)
      end
    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)
    item = @data[index]
    if item.price <= $game_party.gold
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    if $game_party.actors[@idx].temp_skill_learned?(@shop_goods[index].to_i)
      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(item.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, item.name, 0)
    self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  end
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

class Window_SkillLearn < Window_Selectable
  def initialize(actor)
    super(0, 128, 368, 352)
    @actor = $game_party.actors[actor]
    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...@actor.temp_skills.size
      skill = $data_skills[@actor.temp_skills[i]]
      if skill != nil
        @data.push(skill)
      end
    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)
    if skill.ap > @actor.ap or @actor.skill_learn?(@actor.temp_skills[index])
      self.contents.font.color = disabled_color
    else
      self.contents.font.color = normal_color
    end
    skill = @data[index]
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width / @column_max - 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, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 232, y, 48, 32, skill.ap.to_s, 2)
  end
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end

class Window_SkillLearnStatus < Window_Base
  def initialize(actor)
    super(368, 480-352, 272, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = $game_party.actors[actor]
    refresh
  end
  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 112)
    draw_actor_name(@actor, 4, 0)
    draw_actor_class(@actor, 4 + 144, 0)
    draw_actor_level(@actor, 0, 32)
    draw_actor_state(@actor, 148, 32)
    draw_actor_hp(@actor, 4, 112, 172)
    draw_actor_sp(@actor, 4, 144, 172)
    draw_actor_exp(@actor, 4,176)
    draw_actor_ap(@actor, 4,208)
  end
end

class Window_Base < Window
    def draw_actor_ap(actor, x, y)
      self.contents.font.color = system_color
      self.contents.draw_text(x, y, 24, 32, "AP")
      self.contents.font.color = normal_color
      self.contents.draw_text(x + 24, y, 84, 32, actor.ap.to_s, 2)
  end
end

class Window_BattleResult < Window_Base
  def initialize(exp, gold, ap, treasures)
    @exp = exp
    @gold = gold
    @ap = ap
    @treasures = treasures
    super(160, 0, 320, @treasures.size * 32 + 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.y = 160 - height / 2
    self.back_opacity = 160
    self.visible = false
    refresh
  end
  def refresh
    self.contents.clear
    x = 4
    self.contents.font.color = normal_color
    cx = contents.text_size(@exp.to_s).width
    self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
    x += cx + 4
    self.contents.font.color = system_color
    cx = contents.text_size("EXP").width
    self.contents.draw_text(x, 0, 64, 32, "EXP")
    x += cx + 16
    self.contents.font.color = normal_color
    cx = contents.text_size(@gold.to_s).width
    self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
    x += cx + 4
    self.contents.font.color = system_color
    self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
    y = 32
    x = 4
    self.contents.font.color = normal_color
    cx = contents.text_size(@ap.to_s).width
    self.contents.draw_text(x, y, cx, 32, @ap.to_s)
    x += cx + 4
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 128, 32, "AP")
    y = 64
    for item in @treasures
      draw_item_name(item, 4, y)
      y += 32
    end
  end
end

class Scene_Battle
include Leonhart_DS
  def start_phase5
    @phase = 5
    $game_system.me_play($game_system.battle_end_me)
    $game_system.bgm_play($game_temp.map_bgm)
    exp = 0
    gold = 0
    ap = 0
    treasures = []
    for enemy in $game_troop.enemies
      unless enemy.hidden
        exp += enemy.exp
        gold += enemy.gold        
        ap += (ENEMY_AP_VALUES.has_key?(enemy.id) ? ENEMY_AP_VALUES[enemy.id] : DEFAULT_ENEMY_AP)
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    treasures = treasures[0..5]
    @treasures = treasures
    @exp  = exp
    @gold = gold
    @ap = ap
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      actor.ap += ap
    end
    $game_party.gain_gold(gold)
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    @result_window = Window_BattleResult.new(exp, gold, ap, treasures)
    @phase5_wait_count = 10
  end
end

class Scene_SkillShop
  def main
    @help_window = Window_Help.new
    @party = []
    @id = []
    for i in 0...$game_party.actors.size
      @party.push($game_party.actors[i].name)
      @id.push($game_party.actors[i].id)
    end
    @character_window = Window_Command.new(160,@party)
    @character_window.y = 128
    @character_window.z = 101
    @character_window.active = @character_window.visible = false
    @command_window = Window_SkillShopCommand.new
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    @skills = $game_temp.skill_goods[@id[@character_window.index]]
    @buy_window = Window_SkillBuy.new(@id, @character_window.index)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    @status_window = Window_SkillLearnStatus.new(@character_window.index)
    @status_window.visible = false
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @character_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @status_window.dispose
  end
  def update
    @help_window.update
    @character_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @status_window.update
    if @character_window.active
      select_character
      return
    end
    if @command_window.active
      update_command
      return
    end
    if @buy_window.active
      update_buy
      return
    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)
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @character_window.visible = @character_window.active = true
      when 1
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end
  def select_character
    @help_window.set_text("Choose the character")
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @character_window.visible = @character_window.active = false
      @dummy_window.visible = false
      @buy_window.dispose
      @skills = $game_temp.skill_goods[@id[@character_window.index]] 
      @buy_window = Window_SkillBuy.new(@id,@character_window.index)      
      @buy_window.active = true
      @buy_window.visible = true
      @buy_window.refresh
      @buy_window.help_window = @help_window
      @status_window.dispose
      @status_window = Window_SkillLearnStatus.new(@character_window.index)
      @status_window.visible = true
      return
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.decision_se)
      @command_window.active = @dummy_window.visible = true
      @character_window.visible = @character_window.active = false
      @help_window.set_text("")
      return
    end
  end
  def update_buy
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @character_window.visible = @character_window.active = true
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        @help_window.set_text("No Money!")
        for i in 0..3
          sleep i*0.1
          Graphics.update
          Input.update
        end
        return
      end
      if not $game_party.actors[@character_window.index].temp_skill_learned?(@skills[@buy_window.index])
        $game_system.se_play($data_system.decision_se)
        $game_party.lose_gold(Leonhart_DS::SKILL_PRICE[@skills[@buy_window.index]])
        @gold_window.refresh
        $game_party.actors[@character_window.index].learn_temp_skill(@skills[@buy_window.index])
        @buy_window.refresh
      else
        @help_window.set_text("You know this skill!")
        $game_system.se_play($data_system.buzzer_se)
        for i in 0..3
          sleep i*0.1
          Graphics.update
          Input.update
        end
        return
      end
    end
  end
end

class Scene_SkillLearn
  def main
    @help_window = Window_Help.new
    @party = []
    @id = []
    for i in 0...$game_party.actors.size
      @party.push($game_party.actors[i].name)
      @id.push($game_party.actors[i].id)
    end
    @character_window = Window_Command.new(160,@party)
    @character_window.y = 128
    @character_window.z = 101
    @character_window.active = @character_window.visible = false
    @command_window = Window_SkillLearnCommand.new
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    @buy_window = Window_SkillLearn.new(@character_window.index)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
    @status_window = Window_SkillLearnStatus.new(@character_window.index)
    @status_window.visible = false
    @actor = $game_party.actors[@character_window.index]
    @skills = @actor.temp_skills[@buy_window.index]
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @character_window.dispose
    @command_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @status_window.dispose
  end
  def update
    @help_window.update
    @character_window.update
    @command_window.update
    @dummy_window.update
    @buy_window.update
    @status_window.update
    if @character_window.active
      select_character
      return
    end
    if @command_window.active
      update_command
      return
    end
    if @buy_window.active
      update_buy
      return
    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)
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @character_window.visible = @character_window.active = true
      when 1
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end
  def select_character
    @help_window.set_text("Choose the character")
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @character_window.visible = @character_window.active = false
      @dummy_window.visible = false
      @buy_window.dispose
      @buy_window = Window_SkillLearn.new(@character_window.index)      
      @buy_window.active = true
      @buy_window.visible = true
      @buy_window.refresh
      @buy_window.help_window = @help_window
      @status_window.dispose
      @status_window = Window_SkillLearnStatus.new(@character_window.index)
      @status_window.visible = true
      return
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.decision_se)
      @command_window.active = @dummy_window.visible = true
      @character_window.visible = @character_window.active = false
      @help_window.set_text("")
      return
    end
  end
  def update_buy
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @character_window.visible = @character_window.active = true
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.skill
      if @item == nil or @item.ap > $game_party.actors[@character_window.index].ap
        $game_system.se_play($data_system.buzzer_se)
        @help_window.set_text("No Ap")
        $game_system.se_play($data_system.buzzer_se)
        for i in 0..3
          sleep i*0.1
          Graphics.update
          Input.update
        end
        return
      end
      @actor = $game_party.actors[@character_window.index]
      @skills = @actor.temp_skills[@buy_window.index]
      if not @actor.skill_learn?(@actor.temp_skills[@buy_window.index])
        $game_system.se_play($data_system.decision_se)
        $game_party.actors[@character_window.index].ap -= $data_skills[@skills].ap
        @status_window.refresh
        @actor.learn_skill(@actor.temp_skills[@buy_window.index])
        @buy_window.refresh
      else
        @help_window.set_text("You know this skill!")
        $game_system.se_play($data_system.buzzer_se)
        for i in 0..3
          sleep i*0.1
          Graphics.update
          Input.update
        end
        return
      end
    end
  end
end

I never tested but if you have problem i can solve you
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top