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.

[VX] Mix Skills System

Mix Skills System
Version 1.1
by Woratana
Release Date: 26/05/2008


Introduction
This script is requested by Rast.

It is the system that allow you to mix 2 or more skills to get 1 or more skills.
You can create unlimited recipes, and each recipe you can set what actor can/cannot use.

You also can edit text in the mix skills system's windows easily in SETUP PART.

Enjoy~  :lol:


Features
Code:
# - Mix 2 or more skills to get new skill(s)
# - Choose actor(s) that can/cannot use each recipe
# - Choose to just add new skill(s), or remove skills you used for mix too.
# - Easy to edit text in Mix Spell System windows


Screenshots
http://i28.tinypic.com/14m6zwy.jpg[/img]


Demo
Here is demo that will show you how to call/setup this script. :)
http://i28.tinypic.com/2m76dc4.jpg[/img]
Download file Mix_Skills_System.rar


Script
Place it above main
http://i28.tinypic.com/25thhqt.jpg[/img]
Code:
#===============================================================
# ● [VX] ◦ Mix Skill System ◦ □
#--------------------------------------------------------------
# â—¦ by Woratana [woratana@hotmail.com]
# â—¦ Thaiware RPG Maker Community
# â—¦ Released on: 25/05/2008
# â—¦ Version: 1.1
#--------------------------------------------------------------
# â—¦ Features:
# - Mix 2 or more skills to get new skill(s)
# - Choose actor(s) that can/cannot use each recipe
# - Choose to just add new skill(s), or remove skills you used for mix too.
# - Easy to edit text in Mix Spell System windows
#--------------------------------------------------------------
# â—¦ How to use:
# - Call Scene_MixSkill by call script:
#  $scene = Scene_Mixskill.new
#=================================================================

  #=============================================================
  # ** Constants Initialization (DO NOT EDIT THIS PART!) **
  #-------------------------------------------------------------
class Skill_Recipe
  attr_accessor :result, :skills, :user, :nonuser, :replace
end
class Scene_Mixskill < Scene_Base
  RECIPE = []
  #=============================================================
  
  #=============================================================
  # ** [SETUP] SCENE MIXSPELL WINDOWS & TEXTS
  #-------------------------------------------------------------
  ACTOR_LIST_WIDTH = 172 # Width of Actors list Window
  
  TOP_WINDOW_TEXT = '- Mix Skill System -' # Text show on Top window when start
  TOP_WINDOW_TEXT_WITH_ACTOR = '- Mix Skill System -: {name}'
  # Text show after chose actor, use {name} for actor's name
  
  BOTTOM_WINDOW_TEXT_ACTOR = 'Choose actor you want to mix skill'
  # Text show when player has to choose actor to mix skills
  
  MIX_BUTTON = 'Start Mix Skills!' # Mix button
  MIX_BETWEEN = '---------------------------'
  # Text between recipe's result and chosen skills
  
  EXIT_BUTTON = '- Exit -' # Exit button in Actors list window
  
  SE_FOUND_RECIPE = 'Chime1'
  # Sound Effect to play when found recipe for chosen skills
  SE_FOUND_RECIPE_VOLUME = 80 # Sound Effect volume
  
  SE_MIXED = 'Chime2'
  # Sound Effect to play when mixed skils
  SE_MIXED_VOLUME = 80
  #=============================================================
=begin
  #=============================================================
  # ** [SETUP] SKILL MIX RECIPE
  #-------------------------------------------------------------
  # .: RECIPE TEMPLATE :.
  #-------------------------------------------------
  data = Skill_Recipe.new
  data.skills = [skill ID, skill ID, ...]
  data.result = [skill ID, skill ID, ...]
  data.replace = true (or) false
  data.user = [Actor ID, Actor ID, ...]
  data.nonuser = [Actor ID, Actor ID, ...]
  RECIPE << data
  #-------------------------------------------------
  # * data = Skill_Recipe.new: create new blank recipe.
  
  # * data.skills: Skills that you have to mix to get data.result (line below)
  # You must have data.skills at least 2 skills (or recipe will not work).
  
  # * data.result: Skills that you will get when you mixed data.skills (line above)
  # You can have data.result 1 skill or more.
  
  # * data.user: Actors that can use this recipe, put 0 as Actor ID for ALL ACTORS.
  
  # * data.nonuser: Actors that cannot use this recipe.
  # You don't have to use data.nonuser if you didn't put 0 (usable for All actors)
  # in data.user. -- Put [] if you don't use this.
  
  # ** TIP: When system check to see if Actor can use each recipe,
  # It will check if Actor's ID is not included in data.nonuser first.
  # Next, it will check if Actor's ID include in data.user (or) recipe's data.user
  # is included 0 (usable for All actors).
  #
  # So, you can create recipe that will work with all actors, except for actors 2 and 4
  # by set data.user and data.nonuser like this:
  # data.user = [0]
  # data.nonuser = [2, 3]
  
  # * data.replace = true (or) false: If you want to remove skills in data.skills
  when you mixed this recipe, put 'true'. If not, put 'false'.
    
  # * RECIPE << data: Add new recipe to database.
  #-------------------------------------------------------------
=end
  #=============================================================
  data = Skill_Recipe.new
  data.skills = [56,44]
  data.result = [15]
  data.user = [0]
  data.nonuser = [1]
  data.replace = true
  RECIPE << data
  
  data = Skill_Recipe.new
  data.skills = [67,41,69]
  data.result = [81,82]
  data.user = [1,6]
  data.nonuser = []
  data.replace = false
  RECIPE << data
  #=============================================================
  
  def start
    super
    create_menu_background
    @help1 = Window_Help.new
    @help2 = Window_Help.new
    @help2.y = Graphics.height - @help2.height
    
    @sk = Window_MS_Skill.new(0, @help1.height, Graphics.width/2,
Graphics.height - (@help1.height*2))
    @sk.help_window = @help2
    @sk_chosen = Window_MS_SkillList.new(@sk.width, @sk.y + @help1.height,
@sk.width, @sk.height - @help1.height)
    
    @act_list = Window_MS_ActorList.new(ACTOR_LIST_WIDTH)
    @act_list.x = (Graphics.width - @act_list.width) / 2
    @act_list.y = (Graphics.height - @act_list.height) / 2
  
    @winmix = Window_Command.new(@sk.width, [MIX_BUTTON])
    @winmix.x = @sk.width
    @winmix.y = @help1.height
    
    runstep(0)
  end
  
  def update
    super
    if @act_list.active
      @act_list.update
      if Input.trigger?(Input::C)
        @act_list.visible = @act_list.active = false
        case @act_list.define[@act_list.index]
        when 'exit'
          Sound.play_cancel
          $scene = Scene_Map.new
        else
          runstep(1)
        end
      elsif Input.trigger?(Input::B)
        Sound.play_cancel
        $scene = Scene_Map.new
      end
    elsif @sk.active
      @sk.update
      if Input.trigger?(Input::C)
        if @sk_chosen.skills.include?(@sk.skill)
          Sound.play_cancel
          return
        end
        Sound.play_decision
        @sk_chosen.skills << @sk.skill
        refresh_chosen_data
      elsif Input.trigger?(Input::B)
        runstep(4)
      elsif Input.trigger?(Input::RIGHT)
        runstep(2)
      end
    elsif @winmix.active
      @winmix.update
      if Input.trigger?(Input::C)
        runstep(5)
      elsif Input.trigger?(Input::LEFT)
        runstep(3)
      elsif Input.trigger?(Input::B)
        runstep(4)
      end
    end
  end
  
  def terminate
    super
    @act_list.dispose
    @sk_chosen.dispose
    @sk.dispose
    @help1.dispose
    @help2.dispose
    dispose_menu_background
  end
  
  def refresh_chosen_data
    @sk.chosen = @sk_chosen.skills
    @sk_chosen.skills.uniq!
    @sk.chosen.uniq!
    data_mixable = spell_mixable(@sk_chosen.skills)
    @sk_chosen.result = data_mixable[0]
    @sk_chosen.result -= @sk.actor.skills
    @sk_chosen.replace = data_mixable[1]
    RPG::SE.new(SE_FOUND_RECIPE, SE_FOUND_RECIPE_VOLUME).play if !@sk_chosen.result.empty?
    @winmix.draw_item(0, !@sk_chosen.result.empty?)
    @sk_chosen.refresh
    @sk.refresh
  end
  
  def spell_mixable(chosen)
    skills = []
    chosen.each {|i| skills << i.id if i.is_a?(RPG::Skill) }
    RECIPE.each_index do |r|
      next if RECIPE[r].nil? or RECIPE[r].skills.size < 2 or
  RECIPE[r].skills.size != skills.size or RECIPE[r].skills.sort != skills.sort
      next if RECIPE[r].nonuser.include?(@sk.actor.id)
      if RECIPE[r].user.include?(@sk.actor.id) or RECIPE[r].user.include?(0)
        result = RECIPE[r].result
        result_skills = []
        result.each {|i| result_skills << $data_skills[i] unless $data_skills[i].nil? }
        return [result_skills, RECIPE[r].replace]
      end
    end
    return [[], true]
  end
  
  def runstep(id)
    case id
    when 0
      @sk.visible = @sk.active = false
      @sk_chosen.visible = @sk_chosen.active = false
      @act_list.active = @act_list.visible = true
      @winmix.visible = @winmix.active = false
      @help1.set_text(TOP_WINDOW_TEXT, 1)
      @help2.set_text(BOTTOM_WINDOW_TEXT_ACTOR, 1)
    when 1
      Sound.play_decision
      @act_list.active = @act_list.visible = false
      @sk.visible = @sk.active = true
      @sk_chosen.visible = true
      @sk_chosen.active = false
      @winmix.visible = true
      @winmix.active = false
      @winmix.index = -1
      @sk.set_actor(@act_list.define[@act_list.index])
      @help1.set_text(TOP_WINDOW_TEXT_WITH_ACTOR.gsub(/\{name\}/i){@sk.actor.name}, 1)
      @sk_chosen.clear
      @winmix.draw_item(0, !@sk_chosen.result.empty?)
    when 2
      if @sk_chosen.result.empty?
        Sound.play_cancel
      else
        Sound.play_decision
        @winmix.index = 0
        @winmix.active = true
        @sk.active = false
        @sk_lastindex = @sk.index
        @sk.index = -1
      end
    when 3
      Sound.play_decision
      @winmix.index = -1
      @winmix.active = false
      @sk.active = true
      @sk.index = @sk_lastindex
    when 4
      if @sk_chosen.skills.empty?
        Sound.play_decision
        runstep(0)
      else
        Sound.play_cancel
        @sk_chosen.skills.pop
        refresh_chosen_data
      end
    when 5
      if @sk_chosen.result.empty?
        Sound.play_cancel
      else
        RPG::SE.new(SE_MIXED,SE_MIXED_VOLUME).play
        actor = @sk.actor
        ingrad = @sk_chosen.skills
        result = @sk_chosen.result
        ingrad.each {|i| actor.forget_skill(i.id) } if @sk_chosen.replace
        result.each {|i| actor.learn_skill(i.id) }
        runstep(1)
      end
    end
  end
end

#==============================================================================
# ** Window_MS_Skill
#==============================================================================
class Window_MS_Skill < Window_Selectable
  attr_accessor :chosen, :actor
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @column_max = 1
    @chosen = []
    @data = []
    self.index = 0
  end

  def skill
    return @data[self.index]
  end

  def refresh
    @data = []
    for skill in @actor.skills
      @data.push(skill)
      if skill.id == @actor.last_skill_id
        self.index = @data.size - 1
      end
    end
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  
  def set_actor(actor)
    @actor = actor
    @chosen = []
    self.index = 0
    refresh
  end

  def draw_item(index)
    skill = @data[index]
    return if @chosen.include?(skill)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    if skill != nil
      rect.width -= 4
      draw_item_name(skill, rect.x, rect.y)
    end
  end

  def update_help
    @help_window.set_text(skill == nil ? '' : skill.description)
  end
end

#==============================================================================
# ** Window_MS_SkillList
#==============================================================================
class Window_MS_SkillList < Window_Selectable
  attr_accessor :result, :skills, :replace
  def initialize(x, y, width, height)
    super(x, y, width, height)
    clear
  end

  def refresh
    self.contents.clear
    @data = @result + [Scene_Mixskill::MIX_BETWEEN] + @skills
    @item_max = @data.size
    for i in 0...@item_max
      draw_item(i)
    end
  end

  def draw_item(index, enabled = true)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    skill = @data[index]
    rect.width -= 4
    if skill.is_a?(RPG::Skill)
      draw_icon(skill.icon_index, rect.x, rect.y, enabled)
      self.contents.font.color = @result.include?(skill) ? system_color : normal_color
      self.contents.draw_text(rect.x + 24, rect.y, rect.width-24, WLH, skill.name)
    else
      self.contents.font.color = normal_color
      self.contents.draw_text(rect.x, rect.y, rect.width, rect.height, skill, 1)
    end
  end
  
  def clear
    @result = []
    @skills = []
    @replace = true
    refresh
  end

  def cursor_movable?
    return false
  end
end

#==============================================================================
# ** Window_MS_ActorList
#==============================================================================
class Window_MS_ActorList < Window_Command
  attr_reader :define
  def initialize(width)
    commands = []
    @define = []
    $game_party.members.each do |i|
      commands << i.name
      @define << i
    end
    commands << Scene_Mixskill::EXIT_BUTTON
    @define << 'exit'
    super(width, commands)
  end
end


Instruction
Call Scene_MixSkill by call script:
Code:
$scene = Scene_Mixskill.new

The instruction to setup script is included in the script. :D


Author's Notes
Free for use in your work if credit is included.


Bug Report?
Please give me these informations:
- What is it says in error window?
- When is it get error? (Right after run game, when you choose something, etc.)
- Do you have any other scripts running in your game that may crash with this script?
 
This is really amazing! Just what I was looking for instead I want an item mix version.

Woratana, can you also make an item mix version of this if you have time?
 
this could be useful for an alchemy type character...

make a ton of different skills for him...
then say take...
gunpowder... and egg toss [throw an egg something like this for funny stuff]... and get Egg Bomb skill hehee

...

would be nice if someone would make an item requirement for skills too...
then you could make a really nice system for rpg's without magic

that way...

gunpowder :> uses 2 parts gunpowder
egg toss    :> uses 1 parts egg

new skill

EggBomb    :> uses 2 parts gunpowder, 1 parts egg, and 1 parts fuse or something to make it go boom in the first place

then you can have a lot of skills that might use gunpowder but only 1 skill that uses eggs...
 

Reliez

Member

darky000":34zpbct8 said:
This is really amazing! Just what I was looking for instead I want an item mix version.

Woratana, can you also make an item mix version of this if you have time?
Yeah, I agree with him, something like that would be really awesome. Is there a possibility for this, as well as an umixing of skills and/or items if combined and consumed?
 
Then I will hope for the best that you are in a good mood for scripting. :P

Maybe pray to give higher chance of possibility.
 
woratana":goapmchj said:
I may do an item mix. :D

Though, I can't promise if I will do that or not. :(

That would be so awesome!  If you do be sure to have the ability to excluse some items from the array though.
 
Item mixer would be awsome! I think it would be a good use in almost any game, exspetualy mine thats all about customization and secrets. That should be your next project.
 
Yeah, it's only for VX. :)

I may not do the Item Mix, since I heard someone already working on it.
And I feels a little lazy when thinking about the item quantity input. :P
 

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