#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# EQUAP Skills by Blizzard
# Version: 4.2b
# Type: Skill System
# Date: 28.05.2006
# Date v2.0: 13.06.2006
# Date v2.02b: 16.1.2007
# Date v3.0b: 19.2.2007
# Date v3.02b: 7.3.2007
# Date v4.0b: 13.7.2008
# Date v4.1b: 19.10.2008
# Date v4.2b: 22.10.2009
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Explanation:
#
# This add-on will allow you to bound skills to equipment. Equip it and you
# learn the skill, unequip it and you will forget it. The AP system allows to
# gain AP for skills and learn the permanently if the max AP for the skill
# are gathered. (This system is a very similar one to FF9's AP Skill System.)
#
#
# v2.0:
# - fixed bug, that appeared, when more equipment parts had the same skill
# - new multi-skill support
#
# v2.02b:
# - improved coding a little bit
#
# v3.0b:
# - completely overworked and added optional AP system (similar to FF9)
# (I want to mention here I made this especially for blazinhandle =) )
#
# v3.02b:
# - fixed bugs
#
# v4.0b:
# - fixed a critical bug
# - no more EQUAP element
# - skills that have less than 0 max AP cannot be learned
# - compatible with Guilamme777's Multi-Slot Equipment System
# - works more convenient
# - better coding
#
# v4.1b:
# - fixed problems with gaining AP
#
# v4.2b:
# - added functionality to prevent some characters from learning certain
# skills
#
#
# Compatibility:
#
# 99% compatible with SDK v1.x. 60% compatible with SDK v2.x. WILL cause
# incompatibility with custom equipment scripts but there are instructions
# how to configure the script. Compatible with Guilamme777's Multi-Slot
# Equipment System. Please note, that this script depends on the layout of
# your Equip Screen and needs to be put UNDER a CMS script if you are using
# one. WILL corrupt your old savegames. Might not work with some CMS-es.
#
#
# Instructions:
#
# - Configuration:
#
# Press CRTL+SHIFT+F and type into the window one of the following:
#
# Start EQ Database
# Start MAXAP Database
# Start GAINAP Database
#
# You can jump now to the database directly. There are more instructions.
#
# - Merge with a Custom Equipment System:
#
# To make this system work with any custom equipment script, you need to
# edit the method "prepare_equap" which fetches all current weapon IDs and
# armor IDs.
#
#
# NOTE:
#
# DO NOT USE EQUAP SKILLS AS NORMAL SKILLS! THE SYSTEM WORKS WITH TEMPORARY
# LEARNING AND FORGETTING THE EQUAP SKILL. IF YOU LET YOUR CHARACTER LEARN AN
# EQUAP SKILL BY NORMAL MEANS, HE WILL FORGET IT AFTER HE UNEQUIPS THE
# APPROPRIATE EQUIPMENT!
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com/
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
if TONS_OF_ADDONS::EQUAP_SKILLS
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start EQUAP General Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DISPLAY_AP_GAIN = true # uses a modified Battle Result to display gained AP
DISPLAY_AP_REQ = true # shows CURRENT_AP/NEEDED_AP in the skill's name
DISPLAY_AP_ZERO = true # shows 0/0 if the skill can't be learned
GAIN_DEAD = false # dead actor also gain AP, no matter what
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# End EQUAP General Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#==============================================================================
# Game_System
#==============================================================================
class Game_System
def maxap(id)
case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start of MAXAP Database
#
# Here you can define the APs needed to learn a skill. If you add no skills
# here the AP system is automatically disabled. Configure it like this
# template:
#
# when SKILL_ID then return MAXAP
#
# SKILL_ID - the ID of the skill that will be learned with AP
# MAXAP - how many AP are required to learn the skill
#
# If you give a skill negative max AP, the skill will be completely bound to
# the equipment part and will be forgotten when it is unequipped.
#
# Note:
#
# Don't forget to assign your AP skills to equipment in the EQ Database
# below. Every skill with 0 AP (default) is a normal skill.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
when 1 then return -1
when 2 then return 10
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# End of MAXAP Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end
return 0
end
def gainap(id)
case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start of GAINAP Database
#
# Here you can define how many AP you will get from enemy troops. Configure
# it like this template:
#
# when TROOP_ID then return GAINAP
#
# TROOP_ID - the ID of the enemy troop
# GAINAP - how many AP will the player get from this troop.
#
# Note:
#
# This will automatically be disabled if there are no AP skills.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
when 1 then return 2
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# End of MAXAP Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end
return 0
end
def eq_database(id, weapon = true)
skill_ids = []
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start of EQ Database
#
# This is your equipment database. To add one or more new EQUAP skills to a
# weapon is very simple. Add another "when"-branch in the script snipplet
# below (they have comments next to it). Configure it like this template:
#
# when WEAPON_ID
# @skill_ids.push(EQUAP_SKILL_ID1)
# @skill_ids.push(EQUAP_SKILL_ID2)
#
# The same works for armors:
#
# when ARMOR_ID
# @skill_ids.push(EQUAP_SKILL_ID1)
# @skill_ids.push(EQUAP_SKILL_ID2)
#
# The lines are commented below so you should have no problems with the script.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if weapon
case id
when 1 # weapon ID
skill_ids.push(10) # EQUAP skill ID
skill_ids.push(11) # EQUAP skill ID
when 5
skill_ids.push(8)
skill_ids.push(12)
when 9
skill_ids.push(1)
skill_ids.push(3)
end
else
case id
when 1 # armor ID
skill_ids.push(1) # EQUAP skill ID
skill_ids.push(25) # EQUAP skill ID
when 3
skill_ids.push(7)
skill_ids.push(4)
when 5
skill_ids.push(15)
when 8
skill_ids.push(32)
skill_ids.push(29)
when 13
skill_ids.push(2)
skill_ids.push(25)
when 18
skill_ids.push(27)
when 19
skill_ids.push(25)
when 29
skill_ids.push(10)
end
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# End of EQ Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end
return skill_ids
end
def equap_nonlearnable_skills(id)
case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start of NONLEARNABLE SKILLS Database
#
# Here you can define skills that can't be learned by certain actors at all.
# Configure it like this template:
#
# when ACTOR_ID then return [SKILL_ID1, SKILL_ID2, ...]
#
# ACTOR_ID - the ID of the enemy troop
# SKILL_ID - the ID of the skill this actor can't learn through EQUAP
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
when 1 then return [59, 60]
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# End of NONLEARNABLE SKILLS Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end
return []
end
end
#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor
alias setup_equap_later setup
def setup(id)
@ap = {}
setup_equap_later(id)
test_equap
end
alias equip_equap_later equip
def equip(equip_type, id)
equip_equap_later(equip_type, id)
test_equap
end
def add_ap(val)
@skills.each {|id| @ap[id] = 0 if @ap[id] == nil}
@ap.each_key {|id|
@ap[id] = self.ap(id) + val
@ap[id] = 0 if self.ap(id) < 0
maxap = $game_system.maxap(id)
@ap[id] = maxap if self.ap(id) > maxap}
end
def ap(id)
return (@ap[id] == nil ? 0 : @ap[id])
end
def prepare_equap ### edit this method for custom equipment support
# Guilamme777 compatibility switch
return self.weapon_ids, self.armor_ids if defined?(G7_MS_MOD)
weapons = [@weapon_id]
armors = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
return weapons, armors
end
def test_equap
non_learnable = BlizzCFG.equap_nonlearnable_skills(self.id)
(@skills - non_learnable).each {|id|
maxap = $game_system.maxap(id)
forget_skill(id) if maxap < 0 || self.ap(id) < maxap}
weapons, armors = prepare_equap
skill_ids = []
weapons.each {|id| skill_ids += $game_system.eq_database(id, true)}
armors.each {|id| skill_ids += $game_system.eq_database(id, false)}
(skill_ids - non_learnable).each {|id| learn_skill(id)}
end
end
#==============================================================================
# Game_Troop
#==============================================================================
class Game_Troop
attr_reader :id
alias setup_equap_later setup
def setup(troop_id)
setup_equap_later(troop_id)
@id = troop_id
end
end
#==============================================================================
# Window_BattleResult
#==============================================================================
class Window_BattleResult
def refresh_extra(aps)
self.contents.fill_rect(0, 0, self.width, 32, Color.new(0, 0, 0, 0))
x = 4
self.contents.font.color = normal_color
cx = contents.text_size(@exp.to_s).width
self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
x += cx + 4
self.contents.font.color = system_color
cx = contents.text_size('EXP').width
self.contents.draw_text(x, 0, 64, 32, 'EXP')
x += cx + 16
self.contents.font.color = normal_color
cx = contents.text_size(@gold.to_s).width
self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
x += cx + 4
self.contents.font.color = system_color
cx = contents.text_size($data_system.words.gold).width
self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
x += cx + 16
self.contents.font.color = normal_color
cx = contents.text_size(aps.to_s).width
self.contents.draw_text(x, 0, cx, 32, aps.to_s)
x += cx + 4
self.contents.font.color = system_color
self.contents.draw_text(x, 0, 128, 32, 'AP')
end
end
#==============================================================================
# Window_Skill
#==============================================================================
class Window_Skill
alias draw_item_equap_later draw_item
def draw_item(index)
skill = @data[index]
aps = $game_system.maxap(skill.id)
if DISPLAY_AP_REQ && !$scene.is_a?(Scene_Battle) &&
(aps > 0 || aps != 0 && DISPLAY_AP_ZERO)
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x, y = 4+index%2*320, 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)
text = skill.name
if aps > 0
text += " (#{@actor.ap(skill.id)}/#{aps})"
elsif DISPLAY_AP_ZERO
text += ' (0/0)'
end
self.contents.draw_text(x + 28, y, 204, 32, text, 0)
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
else
draw_item_equap_later(index)
end
end
end
#==============================================================================
# Scene_Battle
#==============================================================================
class Scene_Battle
alias start_phase5_equap_later start_phase5
def start_phase5
start_phase5_equap_later
aps = $game_system.gainap($game_troop.id)
@result_window.refresh_extra(aps) if DISPLAY_AP_GAIN
$game_party.actors.each {|a| a.add_ap(aps) if !a.dead? || GAIN_DEAD}
end
end
end