O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

Mix Skill System

Iniciado por LoboShow, 02/12/2012 às 20:28

Mix Skill System

Compativel com: RMVX
Compatibilidade : ?
Facilidade de uso: ?
Lag gerado: ?

[box class=titlebg]
Para que serve o script
[/box]
Ele junta duas magias para fazer outra.

[box class=titlebg]
[/box]
Da linha 101 até a 115 tem duas receitas (modifique as ou faça mais receitas)
data = Skill_Recipe.new
  data.skills = [id do item 1,id do item2]
  data.result = [resultado]
  data.user = [Quem pode usar essa skill] #coloque 0 para ser todos
  data.nonuser = [Quem não pode usar essa skill]
  data.replace = true
  RECIPE << data


Script:
#===============================================================
# ● [VX] ◦ Mix Skill System ◦ □
#--------------------------------------------------------------
# ◦ by Woratana
# Traduzido por ViniV
#------------------------------------------------- -------------
# ◦ Features: # ◦ Características:
# - Mix 2 ou mais aptidões para obter novas competências (s)
# - Escolha ator (s) que possa / não possa utilizar cada receita
# - Escolha a acrescentar novas competências (s), ou retirar-lhe competências utilizado para misturar também.
 # - Fácil de editar texto em Letras Mix Sistema janelas
 #------------------------------------------------- -------------
# ◦ Para chamar use:
#  $scene = Scene_Mixskill.new
#=================================================================

  #=============================================================
  # ** Constantes Inicialização (NÃO editar esta parte!)  **
  #-------------------------------------------------------------
class Skill_Recipe
  attr_accessor :result, :skills, :user, :nonuser, :replace
end
class Scene_Mixskill < Scene_Base
  RECIPE = []
  #=============================================================
 
  #=============================================================
  # ** TEXTOS
  #-------------------------------------------------------------
  ACTOR_LIST_WIDTH = 172 # Texto mostrar a janela quando começar Topo
 
  TOP_WINDOW_TEXT = '- Mix Skill System -' # Text show on Top window when start
  TOP_WINDOW_TEXT_WITH_ACTOR = '- Mix Skill System -: {name}'
  # Texto após mostrar escolheu ator, (nome) para a utilização do nome do ator
 
  BOTTOM_WINDOW_TEXT_ACTOR = 'Choose actor you want to mix skill'
  # Texto mostrar a janela quando começar Topo
 
  MIX_BUTTON = 'Start Mix Skills!' # Mix button
  MIX_BETWEEN = '---------------------------'
  # Texto do resultado entre receita e habilidades escolhidos
 
  EXIT_BUTTON = '- Exit -' # Exit button in Actors list window
 
  SE_FOUND_RECIPE = 'Chime1'
  # Efeitos sonoros para jogar quando encontrado receita para escolher as competências
  SE_FOUND_RECIPE_VOLUME = 80 # Sound Effect volume
 
  SE_MIXED = 'Chime2'
  # Efeitos sonoros para jogar quando misturado 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


[box class=titlebg]
Imagens
[/box]

[box class=titlebg]
Créditos e Avisos
[/box]
A Wotorama pelo script
A ViniV por traduzir