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.

Skills can only be used with a certain weapon

I'm wondering, can anyone make a script that makes it so certain skills (defineable in the script) can only be used when certain weapons (defineable in the script) are equipped, either by letter the user write out the IDs of weapons in the script or making the "certain" weapons have an element and make it so 'Skill 1' can only work when 'Weapon with * element' is equipped.

This could be used for games where swords, axes, knives, e.t.c. can be equipped on a single character, thus preventing the player from using a knife skill when they have an axe equipped.

Thanks.
 
Ah, right you are :)

Thanks

But, I seem to be getting an error.

I have the following

Code:
  module Skills
    #---------------------------------------------------------------------
    # * Requirements
    #---------------------------------------------------------------------
    Actor          = {}
    Class          = {}
    Skill_All      = {}
    Skill_One      = {}
    Weapon         = {4 => 4}
    Armor_All      = {}
    Armor_One      = {}
    Level          = {}
    Stat_All       = {}
    Stat_One       = {}
    State_Have_All = {}
    State_Have_One = {}
    State_Dont_All = {}
    State_Dont_One = {}
    Switch_All     = {}
    Switch_One     = {}
    Variable_All   = {}
    Variable_One   = {}

But, when I go to the skills menu and check the skill (which is learned, but I don't have the weapon equipped), I get an error for line 484 (in bold)

Code:
  #--------------------------------------------------------------------------
  # * Requirements Test : Weapon
  #--------------------------------------------------------------------------
  def self.has_weapon?(weapon_id, list = [])
    [b]for id in list[/b]
      return true if weapon_id == id
    end
    return false
  end
 
I only used his earlier version in my RTAB demo, but after seeing this...
Code:
def self.has_weapon?(weapon_id, [B]list = [][/B])
It looks like you can specify 1 weapon to attach to multiple skills, like you would code...
Code:
Weapon         = {4 => [4,5,6]}
or just
Code:
Weapon         = {4 => [4]}

I could be wrong, but given that the def you posted is asking for a hash list where you tag multiple skills for the weapon...

MAN, I'm gonna have to grab this one from his TestBed tonight!
 
Bah, I knew the solution had to be simple...

I didn't do that because the comments section had this for weapon requirements

Code:
Setup : Weapon = { object_id => weapon_id, ... }
instead of
Code:
Setup : Weapon = { object_id => [weapon_id, ...] }

But, nevertheless, It's working now.

Thanks
 

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