[XP] Weapon Specific Skills

Started by Aqua, July 29, 2009, 02:04:12 pm

Previous topic - Next topic

Aqua

July 29, 2009, 02:04:12 pm Last Edit: September 28, 2009, 07:40:37 pm by Aqua
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


  • Easy Configuration
  • Skills can be set to be used by any weapon type, one weapon type, or only a few weapon types.
  • Should be compatible with all battle systems.



Screenshots

Spoiler: ShowHide



Demo

[link]


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


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



Author's Notes

This was much easier than I thought :P

winkio

 :clap: an all around useful little script.  Always good to see more of these types of scripts going up.

Aqua

I find it kinda funny how I have more comments than actual script :x

Subsonic_Noise

I didn't know how much I needed this for my game before I saw this thread^^
Thanks + level up

G_G

*levels up*

This should go in tons

Aqua

July 29, 2009, 02:34:16 pm #5 Last Edit: July 29, 2009, 02:37:28 pm by Aqua
Eep... there's a bug... major bug :P

So don't use it yet D:


Edit:
Bug fixed :P

Ryex

I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Fantasist

July 31, 2009, 05:37:07 am #7 Last Edit: July 31, 2009, 05:55:51 am by Fantasist
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.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Aqua

Haha thanks.

Nice idea, Fanta
Looking foward to it.

Fantasist

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*
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




vacancydenied

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
Nothing goes as planned but I keep going forward.

C.C. rOyAl

im  a noob, wat do u mean by dummy element lol  :^_^':
Spoiler: ShowHide

Aqua

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

C.C. rOyAl

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?
Spoiler: ShowHide

Aqua

On the weapons part of the DB, you just checkmark stuff...

So if it's a gun, you checkmark Gun and stuff... XD

C.C. rOyAl

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?
Spoiler: ShowHide

Aqua

Yes, you would.
You know... I put up a demo for a reason :P

C.C. rOyAl

lol oops i didnt even realize there was one. sorry  :^_^':
Spoiler: ShowHide

samsonite789

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.


Aqua

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