Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Aqua on July 29, 2009, 02:04:12 pm

Title: [XP] Weapon Specific Skills
Post by: Aqua on July 29, 2009, 02:04:12 pm
Weapon Specific Skills
Authors: Aqua
Version: 1.1
Type: Skill Limitation Add-on
Key Term: Custom Skill System



Introduction

This script makes it so that some skills can only be used when a certain weapon type is equipped.
For example, it shouldn't be possible to use a skill that shoots a bullet when you're equipped with a sword.


Features




Screenshots

Spoiler: ShowHide
(http://img22.imageshack.us/img22/5926/screenshotsnp.png)



Demo

[link] (http://starrodkirby86.web44.net/AquasStuff/Aqua_Holding_Bin/RGSS/WeaponSpecificSkills.zip)


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=#
# Weapon Specific Skills Script by TerreAqua
# Version: 1.1
# Type: Skill Limitation Add-on
# Key Term: Custom Skill System
# Date: 7/29/09
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=#

#===============================================================================
# Information
#-------------------------------------------------------------------------------
#
#   This script makes it so that some skills can only be used when a certain
#   weapon type is equipped.
#   For example, it shouldn't be possible to use a skill that shoots a bullet
#   when you're equipped with a sword.
#
#   Note: Should be compatible with all battle systems.
#
#   If you need to contact me about this script, please go to:
#   http://forum.chaos-project.com
#
#   You should have only gotten this script from http://chaos-project.com
#   Please let me know if you have found it somewhere else.
#===============================================================================
module Aqua
  module WeaponSpecificSkills
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~::~:~:~: Instructions :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#===============================================================================
#
# Configure DUMMY_ELEMENT to include all the elements that are used for weapon
# types.
# Each weapon should have at least one of the dummy elements.
#
# Skills without a dummy element can be used with any weapon.
# Skills with 1 dummy element can only be used by that weapon type.
# Skills with multiple dummy elements can be used by multiple weapon types.
#
#===============================================================================

DUMMY_ELEMENT = [17, 18, 19, 20]

#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~:~:~  End Configure Area  :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
  end
end

#===============================================================================
# Credits:
# Aqua (aka TerreAqua) for making this.
# vacancydenied for requesting it.
# Starrodkirby86 for just being him :)
#===============================================================================

#===============================================================================
#  This work is protected by the following license:
# #-----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #-----------------------------------------------------------------------------
#===============================================================================

class Game_Actor
  alias aqua_weapon_specific_skill_can_use? skill_can_use?
  def skill_can_use?(skill_id)
    for i in 0...Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.size
      dummyele = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT[i]
      weapon = $data_weapons[self.weapon_id]
      if weapon == nil && $data_skills[skill_id].element_set.include?(dummyele)
        return false
      end
      if $data_skills[skill_id].element_set.include?(dummyele) &&
          weapon.element_set.include?(dummyele)
       return super
      end
    end
    a = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.any? {|e|
        $data_skills[skill_id].element_set.include?(e)}
    return false if a == true
    aqua_weapon_specific_skill_can_use?(skill_id)
  end
end

if $DUMMY_ELEMENTS != nil
  $DUMMY_ELEMENTS |= Aqua::WeaponSpecificSkills::DUMMY_ELEMENT
else
  $DUMMY_ELEMENTS = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.clone
end

class Game_Battler
  #--------------------------------------------------------------------------
  # * Fix Elements
  #--------------------------------------------------------------------------
  def elements_correct(elements)
    multiplier = size = 0
    elements.each {|i|
        unless $DUMMY_ELEMENTS.include?(i)
          multiplier += self.element_rate(i)
          size += 1
        end}
    return (size == 0 ? 100 : multiplier/size)
  end
 
end


Put in new slot above name, probably best right under the RTP scripts.


Instructions

Configure DUMMY_ELEMENT to include all the elements that are used for weapon types.
Each weapon should have at least one of the dummy elements.

Skills without a dummy element can be used with any weapon.
Skills with 1 dummy element can only be used by that weapon type.
Skills with multiple dummy elements can be used by multiple weapon types.


Compatibility

Should be compatible with all battle systems


Credits and Thanks




Author's Notes

This was much easier than I thought :P
Title: Re: [XP] Weapon Specific Skills
Post by: winkio on July 29, 2009, 02:11:16 pm
 :clap: an all around useful little script.  Always good to see more of these types of scripts going up.
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on July 29, 2009, 02:12:47 pm
I find it kinda funny how I have more comments than actual script :x
Title: Re: [XP] Weapon Specific Skills
Post by: Subsonic_Noise on July 29, 2009, 02:17:09 pm
I didn't know how much I needed this for my game before I saw this thread^^
Thanks + level up
Title: Re: [XP] Weapon Specific Skills
Post by: G_G on July 29, 2009, 02:19:23 pm
*levels up*

This should go in tons
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on July 29, 2009, 02:34:16 pm
Eep... there's a bug... major bug :P

So don't use it yet D:


Edit:
Bug fixed :P
Title: Re: [XP] Weapon Specific Skills
Post by: Ryex on July 30, 2009, 12:38:48 am
lol! so simple!
Title: Re: [XP] Weapon Specific Skills
Post by: Fantasist on July 31, 2009, 05:37:07 am
You beat me to it! I was going to complete a slightly different version of this same script. I planned this for my game... Anyway, good work Aqua :) *wants to level up but already did in an other topic just now, so can't*

EDIT: Wait, you used dummy elements for this? Wow, I never thought of that. I made an elaborate configuration for defining weapon types. But I prefer my way, I like to leave my elements as elements.

Anyway, I'll explain my ideas about this feature so maybe you can expand it. Every weapon type has a certain set of skills the user can master. When a certain weapon type has been used a certain number of times, the actor's weapon level increases and new skills are learned. Basically, it's just another class system with certain skills for certain weapon classes and higher levels teach you more abilities. And as always, you can only use the acquired skills if you're wielding a certain weapon type.
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on July 31, 2009, 01:35:16 pm
Haha thanks.

Nice idea, Fanta
Looking foward to it.
Title: Re: [XP] Weapon Specific Skills
Post by: Fantasist on July 31, 2009, 03:36:16 pm
Oh, don't look forward to it. I just wanted to share the idea but since this is already out, there's no need for me to do it again, not until I start working on my game again. And oh, *levels up*
Title: Re: [XP] Weapon Specific Skills
Post by: vacancydenied on August 01, 2009, 01:59:29 am
I can't wait to make full use of this with my project. Hopefully I can learn a thing or two from this =). Thank you for making this script =D
Title: Re: [XP] Weapon Specific Skills
Post by: C.C. rOyAl on August 12, 2009, 02:00:51 pm
im  a noob, wat do u mean by dummy element lol  :^_^':
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on August 12, 2009, 02:32:12 pm
Configure DUMMY_ELEMENT to include all the elements that are used for weapon types.
Each weapon should have at least one of the dummy elements.

Skills without a dummy element can be used with any weapon.
Skills with 1 dummy element can only be used by that weapon type.
Skills with multiple dummy elements can be used by multiple weapon types.

You know... in System how there are elements...
And how there are elemental properties for weapons/armors/items/skills? :P
Title: Re: [XP] Weapon Specific Skills
Post by: C.C. rOyAl on August 12, 2009, 02:37:31 pm
oh ya! srry i hadnt actually been RMing much so i had to go to database. so i just make an element for weapons such as bullets and switch it to A?
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on August 12, 2009, 02:50:17 pm
On the weapons part of the DB, you just checkmark stuff...

So if it's a gun, you checkmark Gun and stuff... XD
Title: Re: [XP] Weapon Specific Skills
Post by: C.C. rOyAl on August 12, 2009, 02:55:06 pm
ok i think i get it. so say i wanted a skill called sure shot for guns only. for the weapon guns i would make an element named guns and in skills where i put sure shot i would check guns?
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on August 12, 2009, 03:01:01 pm
Yes, you would.
You know... I put up a demo for a reason :P
Title: Re: [XP] Weapon Specific Skills
Post by: C.C. rOyAl on August 12, 2009, 03:11:47 pm
lol oops i didnt even realize there was one. sorry  :^_^':
Title: Re: [XP] Weapon Specific Skills
Post by: samsonite789 on September 28, 2009, 04:47:11 am
I'm having a bit of trouble implementing this script.  I'm trying to use it for my RMXP game but it's not working correctly.

I placed it above main and under my other custom scripts.  I followed the directions in setting a dummy element and when I test it it works fine UNTIL I unequip the required weapon from my character and then go into the Skills menu.  When I do that, the game throws this at me and shuts down:

Script 'Weapon Specific Skills' line 101: NoMethodError occurred
undefined method 'element'set' for nil:NilClass

Not exactly sure what to do...if anyone could help me fix this it would be a terrific help and I would appreciate it very much.  I'll even bake you cookies.

Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on September 28, 2009, 02:49:42 pm
Are you saying that you don't have any weapon equipped when it throws the error?

Since... barehands isn't a weapon, and therefore, can't have an element set, that's where the error would be coming from.
Soo...
I'll fix that soon I guess
Title: Re: [XP] Weapon Specific Skills
Post by: samsonite789 on September 28, 2009, 07:13:52 pm
Yes, I do not have a weapon equipped when it throws the error.  That makes perfect sense.

I'm going to try adding Guillame's (sp?) multi-slot equipment script in and see if I can get them to work together, since that has the option of allowing barehanded weapons.  I don't know if that would fix the element set problem, but...

I'll play around with it and see if I can't cook something up.  But thanks for the insight!

Cookies coming your way.

Edit:
Me <-- Scripting n00b

What is the method or some such to check if a character has something equipped?  If I can just add another "if" in there checking if they have anything equipped, that might bypass the problem.
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on September 28, 2009, 07:27:30 pm
Don't double post within 24 hours; it's against the rules.

Lemme fix it right now.

Edit:
Posted edited.
Demo coming later... when my FTP host isn't so slow >.>
Title: Re: [XP] Weapon Specific Skills
Post by: samsonite789 on September 28, 2009, 09:08:03 pm
My apologies for the double-post.  I didn't realize it was against the rules.

Thank you for the edit!  I must admit, however, I messed around with it and came up with another solution as well.  I also figured out a way to make it work with more than one weapon slot (since barehanded having no element set was the problem).  I'd like to post that here so anyone else with similar problems can fix it as well:

IF USING ONE WEAPON SLOT:
Spoiler: ShowHide

class Game_Actor
  alias aqua_weapon_specific_skill_can_use? skill_can_use?
  def skill_can_use?(skill_id)
    unless $data_weapons[@weapon_id] == nil  <-----ADDED THIS LINE
      for i in 0...Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.size
      dummyele = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT
      weapon = $data_weapons[self.weapon_id]
        if $data_skills[skill_id].element_set.include?(dummyele) &&
             weapon.element_set.include?(dummyele)
          return super
        end
      end
    end
  end
   a = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.any? {|e|
        $data_skills[skill_id].element_set.include?(e)}
    return false if a == true
    aqua_weapon_specific_skill_can_use?(skill_id)
end


By adding the line:
Quoteunless $data_weapons[@weapon_id] == nil

It just bypasses the whole check if the player doesn't have anything equipped instead of thinking it needs an element set that isn't there.

TO MAKE IT WORK WITH MULTI SLOTS (SPECIFICALLY, GUILLAUME's):

When I tried it with multi-slot equipment (which I am using), there was another problem.  Although it wouldn't bug out, it assumed that if the first equipment slot == nil, then it didn't bother to check the second slot.  Therefore, if I equipped the required weapon in the first hand slot, the skill would work, but if it was in the second, it wouldn't.  So, I did the following:
Spoiler: ShowHide

class Game_Actor
  alias aqua_weapon_specific_skill_can_use? skill_can_use?
  def skill_can_use?(skill_id)
   
      unless $data_weapons[self.weapon_ids[0]] == nil
        for i in 0...Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.size
          dummyele = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT
          weapon = $data_weapons[self.weapon_ids[0]]
              if $data_skills[skill_id].element_set.include?(dummyele) &&
                weapon.element_set.include?(dummyele)
                return super
              end
        end
      end
   
      unless $data_weapons[self.weapon_ids[1]] == nil
        for i in 0...Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.size
          dummyele = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT
          weapon = $data_weapons[self.weapon_ids[1]]
              if $data_skills[skill_id].element_set.include?(dummyele) &&
                weapon.element_set.include?(dummyele)
                return super
              end
           
        end
      end
     
      a = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.any? {|e|
        $data_skills[skill_id].element_set.include?(e)}
      return false if a == true
      aqua_weapon_specific_skill_can_use?(skill_id)
     
  end
end


By making more than one unless block, it checks each slot independently.  Voila!

Hope this helps anyone else who has the same problem as I did.


Title: Re: [XP] Weapon Specific Skills
Post by: ShadowPierce on October 15, 2009, 06:28:39 am
->Hey, I have 0 scripting experience and I was wondering why this script doesn't work on my game? I currently have these scripts on my game...

Spoiler: ShowHide
Custom shop system by RPG advocate/ Fantasist(Where you can see what item can be equipped by your character & its effects)
Stat allocation system by Blizzard (Lets you customize what your character's stats are)
Ragnarok Online Skill System by Blizzard (Skill Tree system)
One man menu system by Rune (Menu where only the main character is displayed)


I have a hunch that it is in conflict with the stat allocation system but I really like those scripts & don't want to give them up, but I also need this script too... Pleas fix it...

Please & thanks!!! ^^


Title: Re: [XP] Weapon Specific Skills
Post by: Jackolas on October 15, 2009, 06:32:34 am
Quotebut I also need this script too

you never NEED a script, you could use it and it makes your game better (if you know what your doing)
also.. look at what order the scripts are placed.

Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on October 15, 2009, 05:33:06 pm
Did you set everything up correctly?
Like the Dummy Elements and stuffles?

This script shouldn't conflict with /anything/... O.o
Title: Re: [XP] Weapon Specific Skills
Post by: ShadowPierce on October 15, 2009, 08:10:17 pm
->Yep, I've made dummy elements for these weapon types:

Spoiler: ShowHide

*17- Sword
*18- Bow
*19- Javelin
*20- Rod
*21- Axe
*22- Dagger
*23- Fist
(Not sure about my numbering... Oh well...)


I also put their id in the script but when I try the game, the skills with Weapon requirements can't be used... If it's okay with you, I'll send it to you and tell me what's wrong... How can I send it to you?

Please and thanks!!! ^^


Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on October 15, 2009, 08:15:00 pm
Did you go to the Weapons & Skills tabs in the Database and then add a Checkmark next to the corresponding dummy element?


If you did and it's still not working,
It miiight be RO Skill System... but Iunno XD
Title: Re: [XP] Weapon Specific Skills
Post by: ShadowPierce on October 15, 2009, 08:20:18 pm
->Yep, I did all that and checked everything that might be wrong... I'll try removing my other scripts one by one and post here when it finally works...

Please wait for my reply, I'll tell you when it works...




Edit:
->I tried removing everything but it seems that it's still not working... Maybe It's in an event or something? I made an intro NPC that forces the character to learn all his chosen job's skills... Maybe it has something to do with that? By the way, what are those stuffle thing you just said?

Waiting for your reply... Thanks for even replying!!! ^^




Aqua Edit:
No double posting within 24 hr :)
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on October 15, 2009, 09:32:44 pm
Make a demo of your game with no music, no extra graphics, and only map.
Zip & upload it on sendspace.com, then give me the link here.

I'll look at it when I have the time.
Title: Re: [XP] Weapon Specific Skills
Post by: ShadowPierce on October 15, 2009, 10:36:07 pm
->I uploaded it here, please don't laugh, I'm just a noob...  :^_^': Anyway, here's the link:

Spoiler: ShowHide
http://www.sendspace.com/file/8ex69d (http://www.sendspace.com/file/8ex69d)


Please analyze and reply when you have the time...

Please & thanks!!! ^^


Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on October 18, 2009, 12:16:09 pm
Okay...First of all...
My script isn't in the demo you provided

And the problem isn't any of the scripts, it's your eventing.
You tried to equip a weapon to the actor when he doesn't have any weapons in the inventory.
You need to add the weapon to the inventory before forcing it to be equipped.
Title: Re: [XP] Weapon Specific Skills
Post by: ShadowPierce on October 19, 2009, 04:56:32 am
->The script wasn't there? Ooops... Very, very, very, very, very, very, very SORRY!!!!  :sorry:

So what's actually wrong is my intro event that forces the character to be equipped with a weapon? Well, I'll try it out now... Thanks for merely even replying...  :yesmaster:

BTW, (  :offtopic: ) what's your nationality?


Title: Re: [XP] Weapon Specific Skills
Post by: GAX on October 19, 2009, 05:16:57 am
*Gives Aqua an uber-hug*

I'VE BEEN LOOKING FOR SOMETHING LIKE THIS FOR A WHILE NOW, YOU HAVE ONCE AGAIN SAVED ME!  (And G_G too, I was gonna bug him for something like this XD)
Title: Re: [XP] Weapon Specific Skills
Post by: Aqua on October 19, 2009, 04:10:28 pm
Quote from: ShadowPierce on October 19, 2009, 04:56:32 am
->The script wasn't there? Ooops... Very, very, very, very, very, very, very SORRY!!!!  :sorry:

So what's actually wrong is my intro event that forces the character to be equipped with a weapon? Well, I'll try it out now... Thanks for merely even replying...  :yesmaster:

BTW, (  :offtopic: ) what's your nationality?




Yeah, you can't force the actor to equip a weapon when he doesn't have it in the inventory.
You need to add it first.

I'm Chinese

Quote from: GuardianAngelX72 on October 19, 2009, 05:16:57 am
*Gives Aqua an uber-hug*

I'VE BEEN LOOKING FOR SOMETHING LIKE THIS FOR A WHILE NOW, YOU HAVE ONCE AGAIN SAVED ME!  (And G_G too, I was gonna bug him for something like this XD)

*gasp*
An uber-hug?
Is that... contagious? D:
Title: Re: [XP] Weapon Specific Skills
Post by: Murd on June 24, 2010, 04:27:03 am
Is there any possibility to make skills that requires a shield (eg. Shield Slam, Shield Stun)? Or this script is only for weapons only..
Title: Re: [XP] Weapon Specific Skills
Post by: Silentknight72 on June 24, 2010, 05:10:46 am
Did you know that this topic is almost a year old? Maybe you could just change the script or ask someone to do it.
Title: Re: [XP] Weapon Specific Skills
Post by: WhiteRose on June 24, 2010, 10:12:00 am
His question was relevant and the author is still active, so his post doesn't break any rules.

As for your question, Murd, that is not possible with the script as it is now, but should be with a simple edit. Once Aqua gets back from her vacation, I'm sure she'll take a look at it for you.
Title: Re: [XP] Weapon Specific Skills
Post by: Silentknight72 on June 26, 2010, 08:35:46 am
But he can make a new topic instead of that, right? maybe.....
Title: Re: [XP] Weapon Specific Skills
Post by: Lanzer on October 07, 2010, 08:46:02 pm
hey aqua can you remake it to work with armors D=?
kinda shield slam (requires shield) , mighty guard (requires armor) etc
thanks ;3
Title: Re: [XP] Weapon Specific Skills
Post by: Wizered67 on October 07, 2010, 08:49:58 pm
In order to do that you would have to do some editing so that it checks your shield instead of your weapon.
Title: Re: [XP] Weapon Specific Skills
Post by: Lanzer on October 08, 2010, 08:18:13 pm
no, i tried everything it keeps me sending errors since i modded the weapons part for armor1, armor2 etc
besides the weapon database is only for weapon reading so i requested aqua to rework his addon =) to change the weapon for armor accessor
Title: Re: [XP] Weapon Specific Skills
Post by: Grogy on May 29, 2012, 10:39:47 am
hello, kinda retarded that this is a major necro post BUT
I've been searching for this kind of script, but that it works with armors, too (maybe by using the element defense things)
Anyway, thanks
Title: Re: [XP] Weapon Specific Skills
Post by: Imanton on January 06, 2013, 04:52:03 pm
Seems it is does not work with "Tankentai Sideview Battle System: Actor Advanced Status" for custom slots. i would like to add separate slot for a bot but wont work, i know it works because i got it to work on a different project on the shield slot. oh, and the demo link went down.
Title: Re: [XP] Weapon Specific Skills
Post by: gmaker808 on February 15, 2013, 07:56:54 pm
This script is awesome but i wanted to know what would it take to change this so that instead of using a specific weapon can you make it so it's a specific Class
Example: Squire and Knights use swords but Squires can use First Aid and knights can use Break Helmet. you can only use the skill if you are that class.
Title: Re: [XP] Weapon Specific Skills
Post by: ThallionDarkshine on February 15, 2013, 08:02:34 pm
Can't you set that up in the database by making a certain class learn a skill?
Title: Re: [XP] Weapon Specific Skills
Post by: gmaker808 on February 21, 2013, 06:53:16 am
oops i forgot to say im using tons of add on - Equap SKill Script so if i put a skill on the sword any one equiping the sword can learn the skill i want to be able to specify.
Title: Re: [XP] Weapon Specific Skills
Post by: ThallionDarkshine on February 23, 2013, 12:07:29 pm
Alright, I edited it for you. Just set the element efficiency of the class to anything other than C to allow that class to use the skill.

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=#
# Weapon Specific Skills Script by TerreAqua
# Version: 1.1
# Type: Skill Limitation Add-on
# Key Term: Custom Skill System
# Date: 7/29/09
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=#

#===============================================================================
# Information
#-------------------------------------------------------------------------------
#
#   This script makes it so that some skills can only be used when a certain
#   weapon type is equipped.
#   For example, it shouldn't be possible to use a skill that shoots a bullet
#   when you're equipped with a sword.
#
#   Note: Should be compatible with all battle systems.
#
#   If you need to contact me about this script, please go to:
#   http://forum.chaos-project.com
#
#   You should have only gotten this script from http://chaos-project.com
#   Please let me know if you have found it somewhere else.
#===============================================================================
module Aqua
  module WeaponSpecificSkills
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~::~:~:~: Instructions :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#===============================================================================
#
# Configure DUMMY_ELEMENT to include all the elements that are used for weapon
# types.
# Each weapon should have at least one of the dummy elements.
#
# Skills without a dummy element can be used with any weapon.
# Skills with 1 dummy element can only be used by that weapon type.
# Skills with multiple dummy elements can be used by multiple weapon types.
#
#===============================================================================

DUMMY_ELEMENT = [17, 18, 19, 20]

#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~:~:~  End Configure Area  :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
#:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~#
  end
end

#===============================================================================
# Credits:
# Aqua (aka TerreAqua) for making this.
# vacancydenied for requesting it.
# Starrodkirby86 for just being him :)
#===============================================================================

#===============================================================================
#  This work is protected by the following license:
# #-----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #-----------------------------------------------------------------------------
#===============================================================================

class Game_Actor
  alias aqua_weapon_specific_skill_can_use? skill_can_use?
  def skill_can_use?(skill_id)
    for i in 0...Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.size
      dummyele = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT[i]
      weapon = $data_weapons[self.weapon_id]
      clss = $data_classes[self.class_id]
      if weapon == nil && $data_skills[skill_id].element_set.include?(dummyele)
        return false
      end
      if $data_skills[skill_id].element_set.include?(dummyele) &&
          weapon.element_set.include?(dummyele) && clss.element_ranks[dummyele] != 3
       return super
      end
    end
    a = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.any? {|e|
        $data_skills[skill_id].element_set.include?(e)}
    return false if a == true
    aqua_weapon_specific_skill_can_use?(skill_id)
  end
end

if $DUMMY_ELEMENTS != nil
  $DUMMY_ELEMENTS |= Aqua::WeaponSpecificSkills::DUMMY_ELEMENT
else
  $DUMMY_ELEMENTS = Aqua::WeaponSpecificSkills::DUMMY_ELEMENT.clone
end

class Game_Battler
  #--------------------------------------------------------------------------
  # * Fix Elements
  #--------------------------------------------------------------------------
  def elements_correct(elements)
    multiplier = size = 0
    elements.each {|i|
        unless $DUMMY_ELEMENTS.include?(i)
          multiplier += self.element_rate(i)
          size += 1
        end}
    return (size == 0 ? 100 : multiplier/size)
  end
 
end
Title: Re: [XP] Weapon Specific Skills
Post by: Jotari on January 23, 2024, 09:58:58 am
Hey, so, pretty far in the future now, not sure if you're still around, but I have a question. What about enemies? Enemies don't have weapons, so if I set a skill up to work with only certain weapons it means enemies can't use that skill. That kind of sucks because my game has enemies using all the same skills as the player for the most part. I guess I could make two copies of every skill, one for players and one for enemies, but that's very troublesome if stats needed to be altered. Is there a way to give all enemies access to all skills without this limitation?
Title: Re: [XP] Weapon Specific Skills
Post by: KK20 on January 23, 2024, 02:06:27 pm
Did you try adding the script in a project? Looking at the code, the logic is only being applied to Game Actors, not Game Enemies. Your concern shouldn't be an issue.
Title: Re: [XP] Weapon Specific Skills
Post by: Jotari on January 24, 2024, 03:06:12 am
Quote from: KK20 on January 23, 2024, 02:06:27 pmDid you try adding the script in a project? Looking at the code, the logic is only being applied to Game Actors, not Game Enemies. Your concern shouldn't be an issue.
Yes, I tested it. Made a skill need an element and then gave an enemy only that skill and the enemy's turn just kept ending with nothing happening.
Title: Re: [XP] Weapon Specific Skills
Post by: KK20 on January 24, 2024, 09:29:46 pm
Worked for me on a new project.

You sure the enemy can naturally use the skill (e.g. has enough SP to satisfy the SP cost)? Remove the script from your project and confirm the enemy is still unable to use the skill.

Otherwise, will need your project files to investigate it further. Highly doubt it's a script compatibility issue; I think it's more of a database configuration issue.
Title: Re: [XP] Weapon Specific Skills
Post by: Jotari on January 25, 2024, 11:21:01 am
Opps. Yeah, the issue was just that the enemy I was testing with didn't have enough SP to use the skill in question. Sorry about that. Obvious in retrospect.