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.

Linking skills to items

Hi everyone!

I have a quick question so here goes;

Is there anyway to link the weapon/armor/shield etc with a skill? let me explain. like when you pick up a sword it grants you a certain skill, for instance "slice"; as soon as you unequip it, the skill becomes unavailable or grayed out. This way certain skills can only be performed by certain weapons for example the "backstab" move is only available if you have a dagger equipped.

I really appreciate your help. This issue has really halted the progress of my project so your support is greatly needed.

Thanks,  :thumb:
 
This requires scripting, yet also possible eventing.
Basically, what you would want to do (making things as simple as I can), is to make an event when a weapon/armor is gained which goes as follows:

Change Weapons: [Sword], + 1
Change Skills: [Aluxes], + [Slice]

This will make the player learn the skill as the weapon is gained.
Now, the next step, to make things simple, is to go into Game_System. Below line 22 (unless modified), add:
Code:
attr_accessor :weapon_skill
attr_accessor :armor_skill
Below line 37, add:
Code:
@weapon_skill = []
@armor_skill = []
Below the @armor_skill = [] line you can add all weapons and armor to skills. An example:
Code:
@weapon_skill[15] = 1
@armor_skill[20] = 1
To explain this code, skill number 15 (from the database) requires weapon number 1 to be equipped.
Skill number 20 requires armor number 20 to be equipped.

Next step is to fix the color for the skill if weapons are equipped, and allow/disallow it being used.
Unless modified, go into Window_Skill, and add this right below line 67:
Code:
    if $game_system.weapon_skill[skill.id] != nil or $game_system.armor_skill[skill.id] != nil
      if @actor.weapon_id == $game_system.weapon_skill[skill.id]
        self.contents.font.color = normal_color
      elsif @actor.armor1_id == $game_system.armor_skill[skill.id] or @actor.armor2_id == $game_system.armor_skill[skill.id] or @actor.armor3_id == $game_system.armor_skill[skill.id] or @actor.armor4_id == $game_system.armor_skill[skill.id]
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
    else
      self.contents.font.color = disabled_color
    end
That code is pretty messy, but it should work.

Now, as you can still use skills, we need to disallow or allow skills to be used based on such conditions.
Go into Scene_Skill. Right below line 95, add:
Code:
      if $game_system.weapon_skill[skill.id] != nil or $game_system.armor_skill[skill.id] != nil
        if @actor.weapon_id != $game_system.weapon_skill[skill.id]
          $game_system.se_play($data_system.buzzer_se)
          return
        elsif @actor.armor1_id != $game_system.armor_skill[skill.id] or @actor.armor2_id != $game_system.armor_skill[skill.id] or @actor.armor3_id != $game_system.armor_skill[skill.id] or @actor.armor4_id != $game_system.armor_skill[skill.id]
          $game_system.se_play($data_system.buzzer_se)
          return
        end
      else
        $game_system.se_play($data_system.buzzer_se)
        return
      end
Still a bit messy, but it should work perfectly fine.

If you experience any errors, please report them here.

Hope this helps.
 
Wow thank you so much! I'll be sure to try this as soon as possible. right now im viewing this with my iphone under the desk during a meeting lol. it looks fairly straight forward and should work.

I cant tell you how much i appreciate this!
 
Hmm okay well i put this code in and im getting an error massage;

Script 'Game_System line 38: NoMethodError occured.
undefined method '[]=' for nil:NilClass

Thats weird :/  Thanks in advance.
 
What Nickster said. Got to Database, click 'Common Events'. Set the common event to parallel process and put a switch (At the beginning of the game or whenever turn on that switch so it becomes active) Now. Put Condition Branch, click the 2nd Page and for Actor, select your character that you want this to happen with. Now where it says Weapon, click it and select the weapon you want him to wear to get the skill. Click 'Ok.' Then below that, put Change Skill: [Your character] +[Skill name here]. Then where the condition branch says 'else' put Change Skill: [Your Character] -[Skill name here]. There, done. I'll upload a picture if you don't get it.
 
Thermalburn":13rbaf9k said:
Hmm okay well i put this code in and im getting an error massage;

Script 'Game_System line 38: NoMethodError occured.
undefined method '[]=' for nil:NilClass

Thats weird :/   Thanks in advance.
Just make sure you choose New Game. Loading a previous game will cause the lists to not be defined as arrays.
 
All to make it simple and scriptless.
http://img264.imageshack.us/img264/9900/34444583rm2.png[/img]
its a simple conditional branch if  weapon is equiped that makes a character gain a skill. If it unequipes weapon, it forgets the skill.
 
Thank you Nickster, Danny2000 and Muffins.org I can incorporate that into my project aswell

@FireRaven: It wont even let me get to the main menu to choose a New Game...It looks like its initializing but then it just gives that error massage and terminates.

Thanks in advance! :thumb:
 
Can you post your initialize block? As the code I provided did not have any errors. By the looks of your error being at line 38, I think your code looks like this:
Code:
@weapon_skill[15] = 1
@armor_skill[20] = 1
Where it should be:
Code:
@weapon_skill = []
@armor_skill = []
@weapon_skill[15] = 1
@armor_skill[20] = 1

Hope this solves the problem.
 

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