iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> Passive Skill Benefits, Param increases, etc.
dividedbyzero
post Mar 30 2010, 08:28 PM
Post #1



Group Icon


Type: Coder
Alignment: Unaligned





DBZ_PassiveSkill v1.0
by dividedbyzero


Introduction
I created this script simply because I'm not smart enough to comprehend KGC_PassiveSkill and I wanted passive skills to be compatible with my SkillLevel script. For those unfamiliar with passive skills, it allows you to implement bonuses on skills such as parameter increases and special actor and equipment options. When paired with my script "DBZ_SkillLevel", this script has extra functionality like curves and skill level requirements.

Features
- Enables parameter increase when a skill is learned.
- Enables skills to grant special abilities such as dual attack.
- Allows parameter increase curves when combined with DBZ_SkillLevel.
- Allows ability skill level requirements when combined with DBZ_SkillLevel.

How to Use
Simply edit the note tag of a skill to include any supported tags.

PARAMETER TAG:
<param (+/-)number[%][ curve (+/-)number[%]]>
This modifies "param" to either add or subtract "number".
e.g. <atk +10>

If a percent sign is appended to the number, it will be set to that percentage of the parameter's total.
e.g. <maxhp -10%>

If you also have my script, "DBZ_SkillLevel", you may use the second section of the parameter tag. It follows the same syntax as the first.
e.g. <cri +10 curve +5>

Accepted parameters include the following:
maxhp, maxmp, atk, def, spi, agi, hit, eva, cri, and odds.

EXTRA TAG:
<extra extra_function[ at level]>
This has different effects depending on "extra function".

<extra two_swords_style>
Would enable dual-wielding weapons.

Once again, if you have "DBZ_SkillLevel", an extra feature is unlocked: skill level requirement.

<extra dual_attack at 10>
Would enable dual attack at skill level 10.

Accepted functions are as follows:
- two_swords_style: Enables wielding of two weapons.
- fix_equipment: Locks equipment. Not sure why you'd use this.
- super_guard: Defending becomes twice as effective.
- pharmacology: Doubles recovery effects from items.
- fast_attack: Always attacks at beginning of turn.
- dual_attack: Attacks twice.
- prevent_critical: Prevents critical hits against actor.
- half_mp_cost: Halves MP cost of everything.
- double_exp_gain: Doubles EXP gain.

Demo
v1.0

Script
Spoiler:
CODE
# ============================================================================ #
#
#     * DBZ_PassiveSkill *
#     Author: dividedbyzero
#     Version: 1.0
#
# ============================================================================ #
# Introduction:
# ---------------------------------------------------------------------------- #
#   This script allows you to implement bonuses on skills such as parameter
# increases and special actor and equipment options. When paired with my script
# "DBZ_SkillLeve", this script has extra functionality like curves and skill
# level requirements.
# ============================================================================ #
# Change Log:
# ---------------------------------------------------------------------------- #
# v1.0  - The Cube!
# ============================================================================ #
# Features:
# ---------------------------------------------------------------------------- #
#   - Enables parameter increase when a skill is learned.
#   - Enables skills to grant special abilities such as dual attack.
#   - Allows parameter increase curves when combined with DBZ_SkillLevel.
#   - Allows ability skill level requirements when combined with DBZ_SkillLevel.
# ============================================================================ #
# How to Use:
# ---------------------------------------------------------------------------- #
# Simply edit the note tag of a skill to include any supported tags.
#
# PARAMETER TAG:
#   <param (+/-)number[%][ curve (+/-)number[%]]>
#     This modifies "param" to either add or subtract "number".
#       e.g. <atk +10>
#     If a percent sign is appended to the number, it will be set to that
#     percentage of the parameter's total.
#       e.g. <maxhp -10%>
#     If you also have my script, "DBZ_SkillLevel", you may use the second
#     section of the parameter tag. It follows the same syntax as the first.
#       e.g. <cri +10 curve +5>
#     Accepted parameters include the following:
#     maxhp, maxmp, atk, def, spi, agi, hit, eva, cri, and odds.
#
# EXTRA TAG:
#   <extra extra_function[ at level]>
#     This has different effects depending on "extra function".
#       <extra two_swords_style>
#       Would enable dual-wielding weapons.
#     Once again, if you have "DBZ_SkillLevel", an extra feature is unlocked:
#     skill level requirement.
#       <extra dual_attack at 10>
#       Would enable dual attack at skill level 10.
#     Accepted functions are as follows:
#       - two_swords_style: Enables wielding of two weapons.
#       - fix_equipment: Locks equipment. Not sure why you'd use this.
#       - super_guard: Defending becomes twice as effective.
#       - pharmacology: Doubles recovery effects from items.
#       - fast_attack: Always attacks at beginning of turn.
#       - dual_attack: Attacks twice.
#       - prevent_critical: Prevents critical hits against actor.
#       - half_mp_cost: Halves MP cost of everything.
#       - double_exp_gain: Doubles EXP gain.
# ============================================================================ #
$imported = {} if $imported == nil
$imported["DBZ_PassiveSkill"] = true
# ============================================================================ #
module DBZ
  module Regexp
    PASSIVE_PARAM = /<([A-Z0-9]*)\s(\+|\-)(\d*)(\%)?(?:\scurve\s(\+|\-)(\d*)(\%)?)?>/i
    PASSIVE_EXTRA = /<extra\s(.*?)(?:\sat(?:\slevel)?\s(\d+)?)?>/i
  end
end
# ============================================================================ #
# * Game_Actor *
# ============================================================================ #
class Game_Actor < Game_Battler
  def passive_param(stat, base=0)
    mod = 0
    @skills.each { |i|
      item = $data_skills[i].note
      item.split(/[\r\n]+/).each { |line|
        if line =~ DBZ::Regexp::PASSIVE_PARAM
          if $1 == stat
            rate = $4 ? true : false
            if rate
              mod = ($3.to_i * 0.01) * base
            else
              mod = ($2 + $3).to_i
            end
            if $imported["DBZ_SkillLevel"]
              if $5
                curve = $5 + $6
                rate = $7 ? true : false
                curve = passive_param_curve(stat, base, curve.to_i, rate, $data_skills[i])
                mod += curve
              end
            end
          end
        end
      }
    }
    return mod
  end
  
  def passive_param_curve(stat, base, curve, rate, skill=nil)
    if rate
      mod = ((curve.to_i * (skill_level(skill.id)-1)) * 0.01) * base
    else
      mod = (curve * (skill_level(skill.id)-1))
    end
    return mod
  end
  
  def passive_extra(opt)
    @skills.each { |i|
      skill = $data_skills[i]
      item = skill.note
      item.split(/[\r\n]+/).each { |line|
        if line =~ DBZ::Regexp::PASSIVE_EXTRA
          if $1 == opt
            req = $2 == nil ? 1 : $2.to_i
            return true if skill_level(skill.id) >= req
          end
        end
      }
    }
    return false
  end
  # ================================================== #
  # Extra modifications.
  # ================================================== #
  def two_swords_style
    if passive_extra("two_swords_style")
      unequip(1)
      return true
    end
    return actor.two_swords_style
  end
  
  def fix_equipment
    return true if passive_extra("fix_equipment")
    return actor.fix_equipment
  end
  
  def super_guard
    return true if passive_extra("super_guard")
    return actor.super_guard
  end
  
  def pharmacology
    return true if passive_extra("pharmacology")
    return actor.pharmacology
  end
  
  def fast_attack
    return true if passive_extra("fast_attack")
    for weapon in weapons.compact
      return true if weapon.fast_attack
    end
    return false
  end
  
  def dual_attack
    return true if passive_extra("dual_attack")
    for weapon in weapons.compact
      return true if weapon.dual_attack
    end
    return false
  end
  
  def prevent_critical
    return true if passive_extra("prevent_critical")
    for armor in armors.compact
      return true if armor.prevent_critical
    end
    return false
  end
  
  def half_mp_cost
    return true if passive_extra("half_mp_cost")
    for armor in armors.compact
      return true if armor.half_mp_cost
    end
    return false
  end
  
  def double_exp_gain
    return true if passive_extra("double_exp_gain")
    for armor in armors.compact
      return true if armor.double_exp_gain
    end
    return false
  end
  # ================================================== #
  # Parameter modifications.
  # ================================================== #
  def base_maxhp
    base = actor.parameters[0, @level]
    param = passive_param("maxhp", base)
    return param + base
  end
  
  def base_maxmp
    base = actor.parameters[1, @level]
    param = passive_param("maxmp", base)
    return param + base
  end
  
  def base_atk
    base = actor.parameters[2, @level]
    param = passive_param("atk", base)
    n = base + param
    for item in equips.compact do n += item.atk end
    return n
  end
  
  def base_def
    base = actor.parameters[3, @level]
    param = passive_param("def", base)
    n = base + param
    for item in equips.compact do n += item.def end
    return n
  end
  
  def base_spi
    base = actor.parameters[4, @level]
    param = passive_param("spi", base)
    n = base + param
    for item in equips.compact do n += item.spi end
    return n
  end
  
  def base_agi
    base = actor.parameters[5, @level]
    param = passive_param("agi", base)
    n = base + param
    for item in equips.compact do n += item.agi end
    return n
  end
  
  def hit
    if two_swords_style
      n1 = weapons[0] == nil ? 95 : weapons[0].hit
      n2 = weapons[1] == nil ? 95 : weapons[1].hit
      n = [n1, n2].min
    else
      n = weapons[0] == nil ? 95 : weapons[0].hit
    end
    base = n
    param = passive_param("hit", base)
    n = base + param
    return n
  end
  
  def eva
    n = 5
    base = n
    param = passive_param("eva", base)
    n = base + param
    for item in armors.compact do n += item.eva end
    return n
  end
  
  def cri
    n = 4
    n += 4 if actor.critical_bonus
    base = n
    param = passive_param("cri", base)
    n = base + param
    for weapon in weapons.compact
      n += 4 if weapon.critical_bonus
    end
    return n
  end
  
  def odds
    base = 4
    param = passive_param("hit", base)
    n = base + param
    return n - self.class.position
  end
  # ================================================== #
  # Snippet to unequip an item.
  # ================================================== #
  def unequip(slot)
    case slot
    when 0
      @weapon_id = 0
    when 1
      @armor1_id = 0
    when 2
      @armor2_id = 0
    when 3
      @armor3_id = 0
    when 4
      @armor4_id = 0
    end
  end
end


This post has been edited by dividedbyzero: Mar 31 2010, 08:08 AM
Go to the top of the page
 
+Quote Post
   
SirCumferance
post Jan 30 2011, 08:19 AM
Post #2



Group Icon


Type: Undisclosed




Awesome, thanks.
I was looking for something like this, it works great on the Skill Tree I use.


--------------------
Go to the top of the page
 
+Quote Post
   
Kurisu-San
post Jan 30 2011, 10:57 PM
Post #3


私は決して夢ではない
Group Icon


Type: Writer
Alignment: Chaotic Evil




omg thank you so much I was actually about to post a script request asking for someone to edit the passives so that it required a certain level to reach so the skill would unlock, thank you so much ^^

*delves into the script to start making edits*


EDIT:

Hey I was wondering what I would do to say use an ability such as.... Asuran Punch which is an 8 hit attack? Would I have to add another paramater inside your script to do so?

This post has been edited by Kurisu-San: Jan 30 2011, 10:59 PM


--------------------

Spoiler:
I Support:
Spoiler:




Current Projects:
Spoiler:

Future Projects:
Spoiler:
Star Wars: War of the Republic
Dragon Ball Z: Evolution
Avatar: Battle of the Four Nations
The Legend of Zelda: The New Force

Personality:
Spoiler:
Star Wars:

Final Fantasy:

Pokemon:

Color:

Legend of Zelda:

You are Ganondorf!

You are a mean, evil bastard! You hate Link, and are very greedy! You made your first appearance in The Legend Of Zelda!
Go to the top of the page
 
+Quote Post
   
roachman07
post Mar 8 2011, 02:28 PM
Post #4



Group Icon


Type: Undisclosed




hello this looks great
but is they anyway i can make it add more attacks per lvl like 2 attacks at lvl 5 and than attack 3 times at lvl 7
something like that

and is they a way i can make the number of attacks random

Go to the top of the page
 
+Quote Post
   
zanaram
post Feb 9 2012, 08:31 PM
Post #5



Group Icon


Type: Undisclosed
Alignment: Unaligned




This is an awesome script, i was pumped to use it in my game when i found it. But I'm having a problem with it. I have an event that grants you the passive skill for dual weapons, but then when i go to check out my skills to see if it's there a message pops up saying...

Script 'Passive Skill' line 121: NoMethodError orrurred.
undefined method 'skill_level' for #<Game_Actor:0x396df60>

I havn't played with this script since it doesn't seem to need any configuration and cause I don't know anything about scripting. Anyway, can anyone help me out with this error? please
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
8 User(s) are reading this topic (8 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 2nd September 2014 - 05:53 AM

RPGMakerVX.net is an Privacy Policy, Legal.