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.

Passive Skills.

Passive Skills
Version 1.0
By Gando
Release Date: 4/5 - 2008


Introduction
Ever dreamed of being able to have skills that gives different bonuses such as str, dex, atk, exp and more?
Well this is your lucky day! This script will allow you to create passive skills.
Passive skills are skills that aren't used, they just give support and bonuses to the skills owner.

I know there are probably other, better passive skills scripts out there.
But the reason i made this was solely for practice. Then i figured that i might as well post the script here in case someone would need it.

Features
•Allows you to create passive skills that gives different bonuses such as:
  max_hp, max_sp, str, dex, agi, int, atk, pdef, mdef, gold and exp.
•Allows you to customize if you want to have the gold and exp bonus by percentage or multiplied by something.
•Removes the "0" in the skill window if the skill doesn't cost any sp.


Script
Code:
#==============================================================================
# ** Passive_Skills
#------------------------------------------------------------------------------
# By: Gando
# 4/5 2008
#------------------------------------------------------------------------------
#                              INTRODUCTION
#------------------------------------------------------------------------------
#
#  With this script you will be able to create Passive skills.
#  And for those of you that doesn't know what passive skills are,
#  here is a short explaination:
#
#  A passive skill is a skill that cannot be used.
#  It just gives "support" to the skills owner, like bonus str, dex, hp etc.
#
#---
#
#  I've also added a little feature that removes the "0" from the skill window,
#  when a skill doesn't cost any sp. If you for some reason don't want this 
#  feature, just remove the whole Window_Skill at the bottom of this script.
#
#------------------------------------------------------------------------------
#                                 SETUP
#------------------------------------------------------------------------------
#
#  PASSIVE_SKILLS - Here are all the passive skills. To add a new skill,
#                   put the skills id from the database here.
#
#  ATTRIBUTES - Here is where you do your passive skills setup.
#               The numbers to the left(1=>..., 2=>... etc.) are the id's
#               of the skills in PASSIVE_SKILLS. To add a new passive skill
#               in ATTRIBUTES, put a comma at the end of the last skill setup
#               and put this line below it, and set it up as you want it:
#  skill_id => [max_hp, max_sp, str, dex, agi, int, atk, pdef, mdef, gold, exp]
#               
#
#  max_hp - Increaces the max health.  
#  max_sp - Increaces the max mana.
#  str    - Increaces the strength.
#  dex    - Increaces the dexterity.
#  agi    - Increaces the agility.
#  int    - Increaces the intelligence.
#  atk    - Increaces the attack power.
#  pdef   - Increaces the  physical defence.
#  mdef   - Increaces the magical defence.
#  gold   - Increaces the gold gain in battle.
#  exp    - Increaces the exp gain in battle, (for the whole party).
#
#  GOLD_GAIN_PERCENT - If true, the gold number in ATTRUBUTES will be treated
#                      as percent,(20 would be 20% extra gold).
#                      If false, the gold gain will be multiplied by the gold
#                      number in ATTRIBUTES,(20 would be gold * 20).
#
#  EXP_GAIN_PERCENT  - If true, the exp number in ATTRIBUTES will be treated 
#                      as percent,(20 would be 20% extra exp).
#                      If false, the exp gain will be multiplied by the exp
#                      number in ATTRIBUTES,(20 would be exp * 20).
#
#------------------------------------------------------------------------------
#                               REMEMBER!
#------------------------------------------------------------------------------
#
# Since passive skills are supposed to be "support" skills, they are not meant
# to be used in battle or the menu. 
# So remember to Change the Database/Skills/Occasion to never.
# Also remember to change the sp cost of the skill to 0.
#
# Of course you can have regular, usable skills and still have the passive bonus.
# It's all up to you how you want the skills to work.
#
#------------------------------------------------------------------------------
#  CREDITS: Gando for making the script and khmp for helping with it.
#==============================================================================
  PASSIVE_SKILLS = [1, 2, 3, 4, 5]
  #skill_id => [max_hp, max_sp, str, dex, agi, int, atk, pdef, mdef, gold, exp]
  ATTRIBUTES =
  {
  1 => [999, 999, 999, 999, 999, 999, 999, 999, 999, 20, 20] ,
  2 => [0, 100, 0, 0, 0, 0, 0, 0, 0, 20, 20] ,  
  3 => [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0] ,
  4 => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ,
  5 => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  }
  
  GOLD_GAIN_PERCENT = true
  EXP_GAIN_PERCENT  = true
  
class Game_Actor < Game_Battler
  alias passive_skill_learn learn_skill
  alias passive_skill_forget forget_skill
  #--------------------------------------------------------------------------
  # * Get Actor ID
  #--------------------------------------------------------------------------
  def learn_skill(skill_id)
    passive_skill_learn(skill_id)
    if PASSIVE_SKILLS.include?(skill_id)
      @maxhp_plus += ATTRIBUTES[skill_id][0]
      @maxsp_plus += ATTRIBUTES[skill_id][1]
      @str_plus   += ATTRIBUTES[skill_id][2]
      @dex_plus   += ATTRIBUTES[skill_id][3]
      @agi_plus   += ATTRIBUTES[skill_id][4]
      @int_plus   += ATTRIBUTES[skill_id][5]
      @atk_plus   += ATTRIBUTES[skill_id][6]
      @pdef_plus  += ATTRIBUTES[skill_id][7]
      @mdef_plus  += ATTRIBUTES[skill_id][8]
      @goldt      += ATTRIBUTES[skill_id][9]
      @expt       += ATTRIBUTES[skill_id][10]
    end
  end
  def forget_skill(skill_id)
    passive_skill_forget(skill_id)
    if PASSIVE_SKILLS.include?(skill_id)
      @maxhp_plus -= ATTRIBUTES[skill_id][0]
      @maxsp_plus -= ATTRIBUTES[skill_id][1]
      @str_plus   -= ATTRIBUTES[skill_id][2]
      @dex_plus   -= ATTRIBUTES[skill_id][3]
      @agi_plus   -= ATTRIBUTES[skill_id][4]
      @int_plus   -= ATTRIBUTES[skill_id][5]
      @atk_plus   -= ATTRIBUTES[skill_id][6]
      @pdef_plus  -= ATTRIBUTES[skill_id][7]
      @mdef_plus  -= ATTRIBUTES[skill_id][8]
      @goldt      -= ATTRIBUTES[skill_id][9]
      @expt       -= ATTRIBUTES[skill_id][10]
    end
  end
end

class Game_Battler
  attr_accessor :goldt
  attr_accessor :expt
  alias parameter_init initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @atk_plus = 0
    @pdef_plus = 0
    @mdef_plus = 0
    @goldt = 0
    @expt = 0
    parameter_init
  end
  
  #--------------------------------------------------------------------------
  # * Get Attack
  #--------------------------------------------------------------------------
  def atk
    n = [[base_atk + @atk_plus, 1].max, 999].min
    for state in states do n *= state.atk_rate / 100.0 end
    n = [[Integer(n), 1].max, 999].min
    return n
  end

  #--------------------------------------------------------------------------
  # * Get Defense
  #--------------------------------------------------------------------------
  def pdef
    n = [[base_pdef + @pdef_plus, 1].max, 999].min
    for i in @states
      n *= $data_states[i].pdef_rate / 100.0
    end
    return Integer(n)
  end
  
  #--------------------------------------------------------------------------
  # * Get Defense
  #--------------------------------------------------------------------------
  def mdef
    n = [[base_mdef + @mdef_plus, 1].max, 999].min
    for i in @states
      n *= $data_states[i].mdef_rate / 100.0
    end
    return Integer(n)
  end
  
  #--------------------------------------------------------------------------
  # * Set Attack
  #     new_atk : new attack
  #--------------------------------------------------------------------------
  def atk=(new_atk)
    @atk_plus += new_atk - self.atk
    @atk_plus = [[@atk_plus, -999].max, 999].min
  end
  
  #--------------------------------------------------------------------------
  # * Set Defense
  #     new_def : new defense
  #--------------------------------------------------------------------------
  def pdef=(new_pdef)
    @pdef_plus += new_pdef - self.pdef
    @pdef_plus = [[@pdef_plus, -999].max, 999].min
  end
  
  #--------------------------------------------------------------------------
  # * Set Defense
  #     new_def : new defense
  #--------------------------------------------------------------------------
  def mdef=(new_mdef)
    @mdef_plus += new_mdef - self.mdef
    @mdef_plus = [[@mdef_plus, -999].max, 999].min
  end
end

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Determine if treasure appears
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    # Treasure is limited to a maximum of 6 items
    treasures = treasures[0..5]
    # Obtaining EXP
    gold_mult = 0
    exp_mult = 0
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      exp_mult += $game_party.actors[i].expt
    end
    if EXP_GAIN_PERCENT == true
      exp += (exp * exp_mult == 0? 0: exp * exp_mult / 100).to_i
    elsif EXP_GAIN_PERCENT == false
      exp = (exp * exp_mult == 0? 0: exp * exp_mult).to_i
    end
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      gold_mult += $game_party.actors[i].goldt
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    if GOLD_GAIN_PERCENT == true
      gold += (gold * gold_mult == 0? 0: gold * gold_mult / 100).to_i
    elsif GOLD_GAIN_PERCENT == false
      gold = (gold * gold_mult == 0? 0: gold * gold_mult).to_i
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Set wait count
    @phase5_wait_count = 100
  end
end
#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
#  This will hide the zero if the skill doesn't cost any SP.
#==============================================================================
class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    if @data[index].sp_cost != 0
    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
    end
  end
end
 Insert the script in an empty slot above main.
The comments at the top of the script will explain how you setup a new passive skill.


Demo
Well, Martinez wanted a demo.
And we all know that what Martinez wants, Martinez gets :wink:
It's not very well-made, but it should be enough for you to understand and see how you setup the skills.
Here is the: Demo


Author's Notes
You are free to use this script in any of your non-commercial games. If you want to use this in a commercial game please contact me.
If you wish to redistribute this script to any other forum please link to this topic.

Credit
Credit goes to me for creating the script, and to khmp for helping me with it.


Next version
•Item Gain - increase the chance of getting an item, and increase the amount of items you get.
•....
If you have any ideas, please share them! :tongue2:
 
This is a very good idea.  I do have a suggestion just for the sake of finding something to suggest.  You could also include and Item Gain section that would increase either the appearance of items and/or the number of items.

EX:
A monster usually has a 25% chance of dropping 1 Potion.  With the skill, the % chance would be 30% and 2 Potion would be dropped (number increase can be changed).  You'd probably want to make certain items unaffected so the player doesn't have 2 key items when they don't need the second.

I'd also like to see this script for VX if it's possible.  I can definitely think of a couple places I could use this in my VX game I'm working on.
 
I'm glad someone liked it! ^^
And i really like your suggestions, i actually never thought of it. But now that you mention it,
it does sound like a good idea to include an item gain bonus in the script. I'll try it and see what i can come up with!

And for the VX version, i guess i could give it a shot when i have time or when i've finished the item gain bonus! :thumb:

Over and out - Gando
 

McP

Member

What i would wish for this script, is having an skill which adds a state. So lets say you have the Skill Auto-Haste you'll always be in Haste-State. I know this can be done with the auto state feature but not permanentely.
 
MasterMind":2pqljg49 said:
Could you make it so it can also increase critical hit? I'm trying to make a targetting skill. Thanks very much.

Yeah sure, do you mean increase the chance of getting a critical hit, or increase the * multiplier?

McP":2pqljg49 said:
What i would wish for this script, is having an skill which adds a state. So lets say you have the Skill Auto-Haste you'll always be in Haste-State. I know this can be done with the auto state feature but not permanentely.

Yeah, that sounds like a good idea. I'll see what i can do^^




I have been quite buissy lately, so i haven't had the time to work on this.
But i'll try to spend more time on this now, and try to improve it. :thumb:
 

luvva

Member

hey-

how about about having weapons which automatically have the skills? that way you could have weapons that increase your max HP and such...
 
Gando":2cqfvuyk said:
MasterMind":2cqfvuyk said:
Could you make it so it can also increase critical hit? I'm trying to make a targetting skill. Thanks very much.

Yeah sure, do you mean increase the chance of getting a critical hit, or increase the * multiplier?

I have been quite buissy lately, so i haven't had the time to work on this.
But i'll try to spend more time on this now, and try to improve it. :thumb:

The chance please. I want to make it so that it raises the chance by a set amount each time. For example, a lock-on skill that increases the chance by 5% each time, but a maximum of 3 times.
 
A suggestion I have is to possibly add a percentage of resistance to statuses or elements (like 25%, 50%, 75% and at 100%, they become immune) to the character. I don't know how hard this would be, but I hadn't seen it suggested here, so I thought I'd throw this to you. Ciao.
 
Hey Gando, great script! It adds so much more to my game!

But, I just thought to let you know that I found an error.

Whenever one of the characters gets inflicted with a status ailment (specifically "venom" I haven't tried it with anything else) and then they go to use a skill this error pops up:

"Script 'Passive Skills' Line 150" NoMethodError occured.
Undefined Method 'Atk_Rate' for 3-Fixnum"

I do have some other scripts on there, so if you want me to tell you what they are just let me know.

Best Regards,

King Matthew

EDIT:  I also did the same thing (inflicting venom on one of my characters and then using a skill) in your demo, and it did the exact same thing.  Weird...
 

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