This thread contains the basic setup you need to create Skills that can only be used while a character is holding a certain type of Weapon.
As I was setting up a "Weapon Skills" system in my own game today, I realized that the Ruby modifications I needed to make were relatively simple, and could actually translate well to anyone's RPG, so I figured I'd share.
With a "Weapon Skills" system, your characters can slice through monsters with swords, pepper them with arrows, or crush foes with hammers... and you'll never have to worry about your player wondering why a character he just equipped with a sword can use "Hammer Smash"!
This system will allow any character who equips a weapon of a certain type (or even a specific weapon) to use the Skills that come with it, a la Disgaea or Phantom Brave. If you want to do something more complicated, like make level/skill requirements or have the character learn the skill permanently if she uses it enough (a la FF9), that can be done, but it is beyond the scope of this post.
If you guys have any questions or can't get it to work, feel free to ask here.
===
Here's how to do it!:
1) Before you start, open up the Database to the "Actors" tab and remove everyone's starting weapon. (Or, if it's important to you to start some characters with equipment, that's okay - but make sure they also start the game with the skills they should know based on their starting Weapon; you can do this on the "Classes" tab).
2) Open up the Script Editor and find the "Game_Actor" class.
3) Find the "Change Equipment" method. It starts with the line: def equip(equip_type, id)
4) Directly before the first "end" command in this method, add a new line and type weapon_skills or whatever you'd like to name the new Weapon Skills method you're about to create.
5) Directly before the last "end" command in the entire "Game_Actor" class, add your new method using the following code. If you called your method something besides weapon_skills in step 4, replace the blue method name with whatever you called it.
def weapon_skills
forget_skill(200)
forget_skill(201)
forget_skill(202)
forget_skill(203)
forget_skill(204)
forget_skill(205)
if @weapon_id > 0
if ($data_weapons[@weapon_id].icon_name == '001-Weapon01')
learn_skill(200)
learn_skill(201)
end
if ($data_weapons[@weapon_id].icon_name == '005-Weapon05')
learn_skill(202)
learn_skill(203)
end
if ($data_weapons[@weapon_id].icon_name == '008-Weapon08')
learn_skill(204)
learn_skill(205)
end
end
end
6) See those orange numbers and green icon names in the script above? You'll probably need to change those in your own game.
7) Make sure that all weapons of the same type use the same icon. All of your Swords should use the same icon if you want them to teach the same skills (and it should be the one you associated the Sword skills to above). All of your Bows should use the same icon if you want them to teach the same skills. And so on. One of the nice things about this system is that you can have dozens of different swords, and you don't need to do separate coding for each of them - just give them all the same icon and they'll all come with Sword skills!
You're done! Enjoy the new feature in your game.
===
Making it Your Own:
If you want to add more than three weapon types, here's how: copy that entire stanza that's in pink, above, and paste it below itself. Choose a different icon name and different skills. Now you have four weapon types! Rinse and repeat. Don't forget to add extra "forget_skill" lines for fourth weapon type's skills. (If you want to add extra skills to a weapon type, just add the appropriate "learn_skill" and "forget_skill" lines in the appropriate places.)
And finally, if you want to have specific weapons that teach a skill, rather than an entire type of weapon, use code like this:
where the green number is the ID of the weapon that comes with the skills (you can find this in the database), rather than code like this:
Everything else about the code should remain the same.
As I was setting up a "Weapon Skills" system in my own game today, I realized that the Ruby modifications I needed to make were relatively simple, and could actually translate well to anyone's RPG, so I figured I'd share.
With a "Weapon Skills" system, your characters can slice through monsters with swords, pepper them with arrows, or crush foes with hammers... and you'll never have to worry about your player wondering why a character he just equipped with a sword can use "Hammer Smash"!
This system will allow any character who equips a weapon of a certain type (or even a specific weapon) to use the Skills that come with it, a la Disgaea or Phantom Brave. If you want to do something more complicated, like make level/skill requirements or have the character learn the skill permanently if she uses it enough (a la FF9), that can be done, but it is beyond the scope of this post.
If you guys have any questions or can't get it to work, feel free to ask here.
===
Here's how to do it!:
1) Before you start, open up the Database to the "Actors" tab and remove everyone's starting weapon. (Or, if it's important to you to start some characters with equipment, that's okay - but make sure they also start the game with the skills they should know based on their starting Weapon; you can do this on the "Classes" tab).
2) Open up the Script Editor and find the "Game_Actor" class.
3) Find the "Change Equipment" method. It starts with the line: def equip(equip_type, id)
4) Directly before the first "end" command in this method, add a new line and type weapon_skills or whatever you'd like to name the new Weapon Skills method you're about to create.
5) Directly before the last "end" command in the entire "Game_Actor" class, add your new method using the following code. If you called your method something besides weapon_skills in step 4, replace the blue method name with whatever you called it.
def weapon_skills
forget_skill(200)
forget_skill(201)
forget_skill(202)
forget_skill(203)
forget_skill(204)
forget_skill(205)
if @weapon_id > 0
if ($data_weapons[@weapon_id].icon_name == '001-Weapon01')
learn_skill(200)
learn_skill(201)
end
if ($data_weapons[@weapon_id].icon_name == '005-Weapon05')
learn_skill(202)
learn_skill(203)
end
if ($data_weapons[@weapon_id].icon_name == '008-Weapon08')
learn_skill(204)
learn_skill(205)
end
end
end
6) See those orange numbers and green icon names in the script above? You'll probably need to change those in your own game.
- Change the green icon names to the name of the icon that the weapon type uses. For instance, above, 001-Weapon01 is the name of RPG Maker XP's default Sword Icon. You can find this information in the Database or Material Base. Make sure you get the name exactly right!
- Change the orange numbers to the ID of skills that you want to come with a type of weapon. For instance, 200 and 201 are the IDs of Sword skills (represented by the icon 001-Weapon01), whereas 204 and 202 and 203 are bow-and-arrow skills (represented by the icon 005-Weapon05). You can find this in the Database.
7) Make sure that all weapons of the same type use the same icon. All of your Swords should use the same icon if you want them to teach the same skills (and it should be the one you associated the Sword skills to above). All of your Bows should use the same icon if you want them to teach the same skills. And so on. One of the nice things about this system is that you can have dozens of different swords, and you don't need to do separate coding for each of them - just give them all the same icon and they'll all come with Sword skills!
You're done! Enjoy the new feature in your game.
===
Making it Your Own:
If you want to add more than three weapon types, here's how: copy that entire stanza that's in pink, above, and paste it below itself. Choose a different icon name and different skills. Now you have four weapon types! Rinse and repeat. Don't forget to add extra "forget_skill" lines for fourth weapon type's skills. (If you want to add extra skills to a weapon type, just add the appropriate "learn_skill" and "forget_skill" lines in the appropriate places.)
And finally, if you want to have specific weapons that teach a skill, rather than an entire type of weapon, use code like this:
if @weapon_id == 154
learn_skill(202)
learn_skill(203)
end
learn_skill(202)
learn_skill(203)
end
if ($data_weapons[@weapon_id].icon_name == '005-Weapon05')
learn_skill(202)
learn_skill(203)
end
learn_skill(202)
learn_skill(203)
end





Comment