Help - Search - Members - Calendar
Full Version: Equipment Skills Script
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS
lanifeibor
I was trying not to ask for help my first day on these forums, but I'm getting a bit frustrated and impatient, haha. So the script below is one I found on the net by a man named Krade that when a certain Armor/Accessory is equipped, it gives a skill, in this case an Antidote Seal gives the skill Purge. The only problem is the skill stays greyed out and unusuable, but if I don't use the script/Antidote Seal and give them the skill via leveling, it works just fine. Scripting is still brand new to me, so I don't know if It's a simple error or not, but if someone could look it over I'd greatly appreciate it.

Script
#============================================
# Equipment skills
#--------------------------------------------
# Scripted by: Krade
#============================================

module EQUIPMENT_SKILLS

# Initialize arrays
WEAPONS = []
ARMORS = []

# Weapon Skills
# Usage: WEAPONS[id] = skill_id

# Armor Skills
# Usage: ARMORS[id] = skill_id
ARMORS[500] = 1 # Antidote Seal teaches Purge

end

class Game_Actor

alias krade_es_setup setup
def setup(actor_id)
krade_es_setup(actor_id)
check_equipment_skills
end

alias krade_es_equip equip
def equip(equip_type, id)
krade_es_equip(equip_type, id)
# New weapon/armor equipped, recheck skills
check_equipment_skills
end

def check_equipment_skills
# Clear array
@equipment_skills = []
# Add the skills of the current equipment
@equipment_skills << EQUIPMENT_SKILLS::WEAPONS[@weapon_id] if EQUIPMENT_SKILLS::WEAPONS[@weapon_id] != nil
@equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor1_id] if EQUIPMENT_SKILLS::ARMORS[@armor1_id] != nil
@equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor2_id] if EQUIPMENT_SKILLS::ARMORS[@armor2_id] != nil
@equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor3_id] if EQUIPMENT_SKILLS::ARMORS[@armor3_id] != nil
@equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor4_id] if EQUIPMENT_SKILLS::ARMORS[@armor4_id] != nil
end

def skills
# Array containing all skills
all_skills = @skills.clone
# Add all equipment skills to the class skills if it doesn't have them yet
for s in @equipment_skills
all_skills << s if not all_skills.include? s
end
# Return all skills
return all_skills
end

end
Night_Runner
It's a simple mistake that I know I've made before happy.gif

code
CODE
#============================================
# Equipment skills
#--------------------------------------------
# Scripted by: Krade
#============================================

module EQUIPMENT_SKILLS
  
  # Initialize arrays
  WEAPONS = []
  ARMORS = []

  # Weapon Skills
  # Usage: WEAPONS[id] = skill_id
  
  # Armor Skills
  # Usage: ARMORS[id] = skill_id
  ARMORS[500] = 1 # Antidote Seal teaches Purge
  
end

class Game_Actor
  
  alias krade_es_setup setup
  def setup(actor_id)
    krade_es_setup(actor_id)
    check_equipment_skills
  end
  
  alias krade_es_equip equip
  def equip(equip_type, id)
    krade_es_equip(equip_type, id)
    # New weapon/armor equipped, recheck skills
    check_equipment_skills
  end
  
  def check_equipment_skills
    # Clear array
    @equipment_skills = []
    # Add the skills of the current equipment
    @equipment_skills << EQUIPMENT_SKILLS::WEAPONS[@weapon_id] if EQUIPMENT_SKILLS::WEAPONS[@weapon_id] != nil
    @equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor1_id] if EQUIPMENT_SKILLS::ARMORS[@armor1_id] != nil
    @equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor2_id] if EQUIPMENT_SKILLS::ARMORS[@armor2_id] != nil
    @equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor3_id] if EQUIPMENT_SKILLS::ARMORS[@armor3_id] != nil
    @equipment_skills << EQUIPMENT_SKILLS::ARMORS[@armor4_id] if EQUIPMENT_SKILLS::ARMORS[@armor4_id] != nil
  end
  
  def skills
    # Array containing all skills
    all_skills = @skills.clone
    # Add all equipment skills to the class skills if it doesn't have them yet
    for s in @equipment_skills
      all_skills << s if not all_skills.include? s
    end
    # Return all skills
    return all_skills
  end
  
  alias nr_es_skill_can_use? skill_can_use?
  def skill_can_use?(skill_id)
    # If it can use the skill, then do so
    return true if nr_es_skill_can_use?(skill_id)
    # If the skill can't normally be used, but the weapons allow it
    #  say it can be used
    for weapon_skill_id in @equipment_skills
      return true if weapon_skill_id == skill_id
    end
    # Otherwise, it's definitely false
    return false
  end
  
end


That should fix it up.
lanifeibor
Ahhhhhh it works! Thanks you kind sir, you are both a gentleman and a scholar. I appreciate this sooooo much. biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.