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 won't add!

GEXROX

Member

Hi, this may have been asked before but I couldn't find it...
I put in a line of code in the equip menu, which calls common event with id of 1. It adds a skill to the actor. However when I go to the Skills menu, it doesn't show up. I exit the menu, go back in and THEN the skill shows up.
I think it's because the menu only refreshes the skill lists when the menu is created (when the menu button is pressed while on the map). How can i fix this issue?
 

Atoa

Member

i found this issue when i was trying to use materia system with invidual battle command.
To fix it, paste this code above main.
Code:
class Scene_Battle
  alias phase3_setup_command_window_skill_fix phase3_setup_command_window
  def phase3_setup_command_window
    @update_skills_commands = Window_Skill.new(@active_battler)
    @update_skills_commands.refresh
    @update_skills_commands.update
    @update_skills_commands.dispose
    phase3_setup_command_window_skill_fix
  end
end
this will intialize and dispose skill window alway before command window shows up.
 

Atoa

Member

Oh you mean that you created an coomon event do add skills when you equip an item?
Well, even if you add an common event in the script, common event only process in map.

If you want to add skills once you equip an item, and lose the skill once you remove it. you can try this script i've made:
Code:
#===============================================================================
# Equips with skills
# r Atoaby atoa
#===============================================================================
module Atoa
  Weapon_Skills = [] #do not chage this line
  Armor_Skills  = []  #do not chage this line
  
  # Weapon_Skills[Weapon_ID] = [Skill_ID]
  Weapon_Skills[1] = [1]
  Weapon_Skills[2] = [2]

  # Armor_Skills[Armor_ID] = [Skill_ID]
  Armor_Skills[1]  = [7]
  Armor_Skills[2]  = [10]
  Armor_Skills[29] = [8]
  
  #Adicione quantas linhas para armas ou armaduras você quiser
end


#===============================================================================
# Game_Actor
#===============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  alias equip_learn_skill_initialize initialize
  alias equip_learn_skill_equip equip
  #--------------------------------------------------------------------------
  def initialize(*args)
    @equipment_skills = []
    equip_learn_skill_initialize(*args)
    gain_equip_skills
  end
  #--------------------------------------------------------------------------
  def equip(equip_type, id)
    lose_equip_skills
    equip_learn_skill_equip(equip_type, id)
    gain_equip_skills
  end
  #--------------------------------------------------------------------------
  def lose_equip_skills
    for lose_skills in @equipment_skills
      self.forget_skill(lose_skills)
    end
    @equipment_skills = []
  end
  #--------------------------------------------------------------------------
  def gain_equip_skills
    new_skills = Atoa::Weapon_Skills[@weapon_id]
    get_new_equip_skill(new_skills)
    new_skills = Atoa::Armor_Skills[@armor1_id]
    get_new_equip_skill(new_skills)
    new_skills = Atoa::Armor_Skills[@armor2_id]
    get_new_equip_skill(new_skills)
    new_skills = Atoa::Armor_Skills[@armor3_id]
    get_new_equip_skill(new_skills)
    new_skills = Atoa::Armor_Skills[@armor4_id]
    get_new_equip_skill(new_skills)
  end
  #--------------------------------------------------------------------------
  def get_new_equip_skill(new_skills)
    if new_skills != nil
      for learning in new_skills
        if !self.skill_learn?(learning) and !@equipment_skills.include?(learning)
          @equipment_skills.push(learning)
          self.learn_skill(learning)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  def exp=(exp)
    lose_equip_skills
    @exp = [[exp, 9999999].min, 0].max
    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
      @level += 1
      for j in $data_classes[@class_id].learnings
        if j.level == @level
          learn_skill(j.skill_id)
        end
      end
    end
    while @exp < @exp_list[@level]
      @level -= 1
    end
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
    gain_equip_skills
  end
end
 

GEXROX

Member

thanks, this is exactly what i'm looking for.
but i tried it with a multiple armor script, and nothing happens. i tried editing these lines:

new_skills = Atoa::Weapon_Skills[@weapon_id]
get_new_equip_skill(new_skills)
new_skills = Atoa::Armor_Skills[@armor1_id]
get_new_equip_skill(new_skills)
new_skills = Atoa::Armor_Skills[@armor2_id]
get_new_equip_skill(new_skills)
new_skills = Atoa::Armor_Skills[@armor3_id]
get_new_equip_skill(new_skills)
new_skills = Atoa::Armor_Skills[@armor4_id]
get_new_equip_skill(new_skills)

and added this:

new_skills = Atoa::Armor_Skills[@armor5_id]
get_new_equip_skill(new_skills)

but it didn't work. do you know how to change it so that it does work?
 

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