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
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:
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
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: