Weapon Training System
Version: 1.00
Author: NAMKCOR
Date: April 06, 2008
Version History
Planned Future Versions
- v?.?? possible efficiency upgrades and bug fixes
Description
Think FF2 with this one. Characters all have 'skill levels' with types of weapons that grant them bonuses with those types of weapons. They gain experience every time they attack with the weapon, and each weapon skill level gives them bonus skill in determining attack damage, the accuracy, and the critical rate of that weapon type
Features
- Easy to configure bonus rates
- Easy to configure experience/level requirement
- Easy to configure default level values
- Uses weapon elements to make weapon categories a breeze
Screenshots
N/A for this type of script
Instructions
Comments and instructions for the individual customizations will be given right where they are located. Only real skills needed are reading, typing, and copy&paste
Script
#=================================================================
# Weapon Training System
#---------------------------------------------------------------------------------------------------------------------
# Created By: NAMKCOR
# Created for the Websites: Chaos Project, RPG Maker Resource Kit
# (www.chaosproject.co.nr; www.rmrk.net)
# If this script is hosted on any other website, then it is stolen, please contact
# me at the address given below
#--------------------------------------------------------------------------------------------------------------------
# If you find any Bugs/Incompatability issues with this script, please contact me at
# the following e-mail address: Rockman922@aol.com, and please be descriptive
# with your e-mail subject, as I delete spam on sight.
#--------------------------------------------------------------------------------------------------------------------
# Function:
# Think FF2 with this one. Characters all have 'skill levels' with types of weapons that
# grant them bonuses with those types of weapons. They gain experience every time
# they attack with the weapon, and each weapon skill level gives them bonus skill in
# determining attack damage, the accuracy, and the critical rate of that weapon type
#
# Compatability:
# 100% compatability with SDK (some things may conflict I dunno SDK well)
# 80% compatability with exotic CBSes
# uses own damage calculations that might cause errors in some cases (merge required)
# 0% compatibility with RTAB
# Unknown as of yet, but high possibility of corrupting old save files
#
# Instructions:
# Comments and instructions for the individual customizations will be given
# right where they are located. Only real skills needed are reading, typing,
# and copy&paste
#--------------------------------------------------------------------------------------------------------------------
# Version History:
# 1.0 - completed system
#=================================================================
#how much experience is given per attack
$WTSexp_rate = 5
#bonus rate formula is weapon level * bonus amount
$WTSattack_bonus = 10
$WTSaccuracy_bonus = 10
$WTScritical_bonus = 10
#==============================================================
# @exp_levels : how much experience is needed to reach the next level
#----------------------------------------------------------------------------------------------------------------
# this array functions quite simply, each element is a level, and the value in that
# element is the amount of experience needed to reach that level.
# so an array with values [15, 30, 45] would have 3 levels, level 1 needing 15xp
# level 2 needing 30xp and level 3 needing 45xp
#==============================================================
$WTSexp_levels = [10, 30, 60, 100, 150, 210, 280]
#==============================================================
# @elements : which elements are used to store weapon types
#----------------------------------------------------------------------------------------------------------------
# simply place the indexes of the elements you plan on using in the array below
# a REMINDER that only the first numerical value of an element will be taken
# into consideration. So if you make a weapon with elements 17 and 20, only
# element 17 will be taken into consideration.
# ALSO a weapon type -must- be set, or else you will get a range error
#==============================================================
$WTSelements = [17, 18, 19, 20]
class Game_Actor < Game_Battler
attr_accessor :WTSweapon_experience
attr_accessor :WTSweapon_levels
alias WTS_setup_after setup
def setup(actor_id)
WTS_setup_after(actor_id)
#==============================================================
# @WTSweapon_experience
#----------------------------------------------------------------------------------------------------------------
# by modifying the case-when, adding whens for every actor, you are able to
# set what amount of experience with a given weapon type teh character has
# at the start of your game. That way a swordsman could be good with swords
# or a sniper with rifles etc...
#----------------------------------------------------------------------------------------------------------------
# default: @WTSweapon_experience = [0,0,0,0]
# @WTSweapon_levels = [0,0,0,0]
# template when [actor_id] then
# @WTSweapon_experience = [0,0,0,...]
# @WTSweapon_levels = [0,0,0,...]
# end
# !!! WARNING !!! be sure to add an element to these arrays for every weapon
# element type used, or you may encounter bugs later on; and try to line up
# weapon levels with the appropriate amount of experience, or when it
# auto-corrects, it will appear very buggy
#==============================================================
case actor_id
when 1 then
@WTSweapon_experience = [0,0,0,0]
@WTSweapon_levels = [0,0,0,0]
when 2 then
@WTSweapon_experience = [0,0,0,0]
@WTSweapon_levels = [0,0,0,0]
end
end
#===================================================================
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
#===================================================================
def attack_bonus
@temp_element = $data_weapons[self.weapon_id].element_set
for i in 0...@temp_element.size
for j in 0...$WTSelements.size
if $WTSelements[j] == @temp_element[i]
return $WTSattack_bonus * @WTSweapon_levels[j]
end
end
end
end
def accuracy_bonus
@temp_element = $data_weapons[self.weapon_id].element_set
for i in 0...@temp_element.size
for j in 0...$WTSelements.size
if $WTSelements[j] == @temp_element[i]
return $WTSaccuracy_bonus * @WTSweapon_levels[j]
end
end
end
end
def critical_bonus
@temp_element = $data_weapons[self.weapon_id].element_set
for i in 0...@temp_element.size
for j in 0...$WTSelements.size
if $WTSelements[j] == @temp_element[i]
return $WTScritical_bonus * @WTSweapon_levels[j]
end
end
end
end
end
class Scene_Battle
alias make_basic_action_result_first make_basic_action_result
def make_basic_action_result
make_basic_action_result_first
if !$game_troop.enemies.include?(@active_battler)
@temp_element = $data_weapons[@active_battler.weapon_id].element_set
if @active_battler.current_action.basic == 0
for i in 0...@temp_element.size
for j in 0...$WTSelements.size
if $WTSelements[j] == @temp_element[i]
@active_battler.WTSweapon_experience[j] += $WTSexp_rate
if $WTSexp_levels[@active_battler.WTSweapon_levels[j]] != nil
while @active_battler.WTSweapon_experience[j] >=
$WTSexp_levels[@active_battler.WTSweapon_levels[j]]
@active_battler.WTSweapon_levels[j] += 1
end
end
end
end
end
end
end
end
end
class Game_Battler
alias attack_effect_old attack_effect
def attack_effect(attacker)
self.critical = false
if !$game_troop.enemies.include?(attacker)
hit_result = (rand(100) < (attacker.hit + attacker.accuracy_bonus))
if hit_result == true
atk = [(attacker.atk + attacker.attack_bonus) - self.pdef / 2, 0].max
self.damage = atk * (20 + attacker.str) / 20
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
if self.damage > 0
if rand(100) < 4 * (attacker.dex + attacker.critical_bonus) / self.agi
self.damage *= 2
self.critical = true
end
if self.guarding?
self.damage /= 2
end
end
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
if hit_result == true
remove_states_shock
self.hp -= self.damage
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
else
self.damage = "Miss"
self.critical = false
end
return true
end
attack_effect_old(attacker)
end
end
Credit
Thanks
- FF2 for inspiring the system
- Zeriab and Falcon for bits of help in IRC
Support
If you find any Bugs/Incompatability issues with this script, please contact me at the following e-mail addresses: Rockman922@aol.com and rockmanamkcor@yahoo.com, and please be descriptive with your e-mail subject, as I delete spam on sight.
Known Compatibility Issues
incompatible with RTAB, trying to figure out a merge or something
Demo
demo attached to bottom of post
Author's Notes
This is my first foray back into scripting for a while, I'm glad it finally worked, and I hope y'all like it \o/
Restrictions
Created for the Websites: Chaos Project, RPG Maker Resource Kit
(
www.chaosproject.co.nr; www.rmrk.net)
If this script is hosted on any other website, then it is stolen, please contact me at either of the locations given
If you use this script in your game, please link me to the topic
I love to see what my work is used for
do NOT use this script in a commercial game unless you get my permission first