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.

Simple Weapon-Dependant Skills

Okay, I am aware there are a few conditional skill scripts out there, but they are all WAY too complicated, in-depth, and all of them require the SDK, which I can't use because of the scripts I already have.

What I really need is just a script for RMXP that will disable certain skills when a certain type of weapon is not equipped, Basically, I need already learned skills to be hidden.

What I mean is, if the player is not holding a sword, they shouldn't be able to use a sword technique. I'm not worried about any other conditions, not even armor.

I'm not using any other equipment-modifying scripts, and the only skill-related script I have is a spellbook, which effects items more than skills.

So... Is there anyone who can help me with this...? I've just become REALLY frustrated with the unsuccessful search.
 
use a common event, set it to parallel process, and enter this in

if Actor sword equipped *its not exactly like that but you get it*
Actor Learn Skill [Skill Id]
else
Actor remove skill [skill id]
end
 
The problem is there will be several sword skills, but the player will have to learn them normally first of all. This will give them high-level sword skills whenver they have a sword equipped, which really won't work. And, I can't test if they know it before doing that, because once the weapon is unequipped, they forget the skill altogether.

EDIT: Okay, I think there's a way to be clearer and perhaps give some people an idea how to approach this:

With the spell book, you sort of have to give the items that teach these skills elements. So, I have elements in my database like 'Sword Technique', 'Axe Technique', etc. That might be useful.

But, it's also worth noting that the player can choose their character's class, and not all classes can learn each type of skill or use every type of weapon. So... I don't think it can really be based on actor unless you can check which skills that actor knows.

So... Maybe that will help a little. I know for a fact this can't be done with eventing.

Maybe something that could be done is to change a skill's usage to 'never' if the actor who knows it doesn't have the weapon needed... Just another suggestion.
 

Atoa

Member

Made in about 15 minutes ;D
Code:
 

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

# Module Atoa

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

module Atoa

  #dont remove this line

  Weapon_Need_Skills = {}

  #dont remove this line

  

  # Weapon_Need_Skills[skill_id] = [weapons_id]

  Weapon_Need_Skills[57] = [1,2,3,4]

  Weapon_Need_Skills[58] = [1,2,3,4]

  Weapon_Need_Skills[59] = [1,2,3,4]

  Weapon_Need_Skills[60] = [1,2,3,4]

end

 

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

# Game_Actor

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

class Game_Actor < Game_Battler

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

  include Atoa

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

  alias atoa_weapon_nedd_skill_can_use skill_can_use?

  def skill_can_use?(skill_id)

    if Weapon_Need_Skills.include?(skill_id) and Weapon_Need_Skills[skill_id] != nil and

      @weapon_id != 0

      unless Weapon_Need_Skills[skill_id].include?(@weapon_id)

        return false

      end

    end

    return atoa_weapon_nedd_skill_can_use(skill_id)

  end

end

 

This will grey out the skill if you don't have the weapons needed equiped.
The skills that you don't add can be used normally.

Give try and say if it worked
 

Zeriab

Sponsor

Here's a quick and dirty version based on elements
[rgss]class RPG::Skill
  ##
  # Generate a set containing the elements which requires special equipment
  #
  def generate_equipment_set
    pattern = /\[SKILL\]/i
    equipment_element_set = []
    for i in 0...$data_system.elements.size
      unless ($data_system.elements =~ pattern).nil?
        equipment_element_set << i
      end
    end
    return equipment_element_set
  end
 
  ##
  # Retrive the element set which requires special equipment
  #
  def equipment_element_set
    if @equipment_element_set.nil?
      @equipment_element_set = generate_equipment_set
    end
    return @equipment_element_set
  end
 
  ##
  # Check if this skill is valid for the given actor in regards to potential
  # equipment requirements
  #
  def valid?(actor)
    # Get the set of elements required for the actor's equipment
    required_skills = equipment_element_set & element_set
    # Return true if there are none
    return true if required_skills.empty?
    # Retrieve the weapon's element set
    equipment = []
    unless $data_weapons[actor.weapon_id].nil?
      equipment = $data_weapons[actor.weapon_id].element_set
    end
    # Retrieve the union of all the armor's element set
    armors =  []
    armors << $data_armors[actor.armor1_id]
    armors << $data_armors[actor.armor2_id]
    armors << $data_armors[actor.armor3_id]
    armors << $data_armors[actor.armor4_id]
    armors.compact!
    for armor in armors
      equipment |= armor.guard_element_set
    end
    # Return true if the equipment fulfilled all the requirements
    return true if (required_skills - equipment).empty?
    # Return false otherwise
    return false
  end
end
 
class Window_Skill
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills]
      if skill != nil && skill.valid?(@actor)
        @data.push(skill)
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
end
[/rgss]

Add new elements under the System tab
Just add [SKILL] in front of the elements you want to classify requirements of skills
If you add an element to a skill then the actor must have a weapon or an armor equipped which has the element in the element list.
You can have any number of these [SKILL] elements on a skill. The union of all [SKILL] elements of the weapon and all armor is considered when deciding whether the skill should be added or not.

*hugs*
- Zeriab

Edit: Whoops, didn't see Atoa posting there. (Quick reply doesn't tell you)
Atoa's version prevents use of the skills, but they can still be viewed.
My version hides them.
That's the basic difference
 
Atoa, I used yours and it's perfectly simple and exactly what I'm looking for for this! Awesome!

And Zeriab, I'm sitll in the process of developing the system behind my game, and I might yet need your script for something too if I need to do something based on elements, which it's looking like I might. So, I might end up using both of them.

Thanks you guys! You're great! ^_^
 

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