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.

Limiting Skills to use depending on type of weapon equipped.

Razior

Member

I was wondering if there is a script, or a script is possible (for xp) that allows a character with certain skills learned only if he has the appropriate type (element) of weapon equipped. For an example: A character has both the use of swords and staffs, and several special skills for both swords and staffs, but when he has a sword equipped his staff skills are not available and when he has a staff equipped his sword skills are not available.
 

Atoa

Member

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

 
try it now
 

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