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.

Accesories that teach skills

I'm searching for a script that allows accessories to learn skills to the hero that equips it. For example, if you equip a red ring, you will learn the skill Fire. But if you unequip the red ring, you will also forget on how to use the skill fire. I thought there were some scripts on hbgames, that could do this, but i can't find them.
 
Code:
class Scene_Equip

  alias main2 main

  def main

    main2

    if @actor.armor2_id == 9 #Armor ID

      @actor.learn_skill(81) #Skill ID

    else

 

        @actor.forget_skill(81)

         end

        if @actor.armor2_id == 10 #Armor ID

      @actor.learn_skill(10) #Skill ID

    else

 

 

        @actor.forget_skill(10)

         end

        if @actor.armor2_id == 11 #Armor ID

      @actor.learn_skill(7) #Skill ID

    else

 

        @actor.forget_skill(7)

         end

 

      end

    end

 
I'm not sure who made this, but it wasn't me. If I had to guess it would be zeriab since he helped me with a lot of scripts for my game. (Not like it matters, its more of a scriptlette than a script)
 

Atoa

Member

There's a problem with this script: of an actor learn an skill via level up (or other means) then equip an equipment that teach this skillm removing this equip will make the actor forget the skill.

I don't know if thos might be a problem for you, if that is a problem, you could try my equipment skill script:
Code:
#==============================================================================

# Equipamentos Com Habilidades

# Por Atoa

#==============================================================================

# Este script permite configurar equipamentos que adicionam habilidades aos

# personagens quando são equipados, você pode também configurar um nível

# mínimo para que estas habilidades estejam disponíveis.

#==============================================================================

 

module Atoa

  # Não apague ou altere estas linhas

  Equip_Skills = {}

  Skill_Restriction = {}

  # Não apague ou altere estas linhas

 

  # Equip_Skills[Equip_Type] = {Equip_ID => {Min_Level => Skill_ID}}

  #  Equip_Type = 'Weapon' para armas, 'Armor' para armaduras

  #  Equips_ID = ID do equipamento

  #  Min_Level = nível minimo requirido para se aprender a skill

  #  Skill_ID = ID da skill aprendida

  Equip_Skills['Weapon'] = {1 => {1 => 1, 15 => 2, 30 => 3}}

 

  Equip_Skills['Armor'] = {1 => {1 => 1, 15 => 2, 30 => 3}}

 

  # Definir habilidades que o personagem não pode aprender com equipamentos.

  # Skill_Restriction[Actor_ID] = [Skill_IDs]

  Skill_Restriction[1] = []

 

  #=============================================================================

 

end

 

#==============================================================================

# ■ Atoa Module

#==============================================================================

$atoa_script = {} if $atoa_script.nil?

$atoa_script['Atoa Equiment Skill'] = true

 

#==============================================================================

# ■ RPG::Weapon

#==============================================================================

class RPG::Weapon

  #--------------------------------------------------------------------------

  def type_name

    return 'Weapon'

  end

end

 

#==============================================================================

# ■ RPG::Armor

#==============================================================================

class RPG::Armor

  #--------------------------------------------------------------------------

  def type_name

    return 'Armor'

  end

end

 

#==============================================================================

# ■ Game_Actor

#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------

  include Atoa

  #--------------------------------------------------------------------------

  alias initialize_equiskill initialize

  def initialize(actor_id)

    @equipment_skills = []

    initialize_equiskill(actor_id)

    gain_equip_skills

  end

  #-------------------------------------------------------------------------- 

  def weapons

    return [$data_weapons[@weapon_id]]

  end

  #-------------------------------------------------------------------------- 

  def armors

    armor = []

    armor << $data_armors[@armor1_id]

    armor << $data_armors[@armor2_id]

    armor << $data_armors[@armor3_id]

    armor << $data_armors[@armor4_id]

    return armor

  end

  #-------------------------------------------------------------------------- 

  def equips

    return weapons + armors

  end

  #--------------------------------------------------------------------------

  alias exp_equiskill exp=

  def exp=(exp)

    lose_equip_skills

    exp_equiskill(exp)

    gain_equip_skills

  end

  #--------------------------------------------------------------------------

  alias forget_skill_equiskill forget_skill

  def forget_skill(skill_id)

    lose_equip_skills

    forget_skill_equiskill(skill_id)

    gain_equip_skills

  end

  #--------------------------------------------------------------------------

  alias learn_skill_equiskill learn_skill

  def learn_skill(skill_id)

    lose_equip_skills

    learn_skill_equiskill(skill_id)

    gain_equip_skills

  end

  #--------------------------------------------------------------------------

  alias equip_equiskill equip

  def equip(equip_type, id)

    equip_equiskill(equip_type, id)

    gain_equip_skills

  end

  #--------------------------------------------------------------------------

  def gain_equip_skills

    lose_equip_skills

    for eqp in equips

      next if eqp.nil?

      if Equip_Skills[eqp.type_name] != nil and

         Equip_Skills[eqp.type_name][eqp.id] != nil

        skills = Equip_Skills[eqp.type_name][eqp.id].dup

        for skill_level in skills.keys

          next if Skill_Restriction[@actor_id] != nil and

                  Skill_Restriction[@actor_id].include?(skills[skill_level])

          get_new_equip_skill(skills[skill_level]) if skill_level <= @level

        end

      end

    end

  end

  #--------------------------------------------------------------------------

  def lose_equip_skills

    for skill_id in @equipment_skills

      @skills.delete(skill_id)

    end

    @equipment_skills.clear

  end

  #--------------------------------------------------------------------------

  def get_new_equip_skill(skill)

    unless self.skill_learn?(skill) or @equipment_skills.include?(skill)

      @equipment_skills << skill

      @skills.push(skill)

      @skills.sort!

    end

  end

end
This avoid losing skills that the actor learned naturally and also you can set an level to the skill to appera
 
Well, with common events called from the accessories your character should be able to learn new skills. If your heroes don't need to forget the skills learned this way once they unequip the accessories, you'd only need a single condition per accessory asking if it's equipped. That'd be all you need to do then. IF they should forget them, you'd need a common event call and create 2 conditions (if equipped and else) for every single accessory.
 

Atoa

Member

@kyonides
Too much work when you have an simple script that do this.
Also events only process on map, so it would be needed to leave the menu to learn the skill. what is a minus in the game good looking.
 

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