#-------------------------------------------------------------------------------
# Old FF Style Spells
# by Jaberwocky
#-------------------------------------------------------------------------------
SKILLTHINGYELEMENT = 20
SKILLTHINGYMAX = 6
class Game_Actor < Game_Battler
attr_accessor :spellsleft
attr_accessor :spellsmax
attr_accessor :spellslevels
alias moosemuffins setup
def setup(actor_id)
@spellsmax = [6, 3, 2, 1, 1, 1, 0, 0, 0, 0, 1]
@spellsleft = [4, 3, 2, 1, 1, 1, 0, 0, 0, 0, 1]
@spellslevels = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
moosemuffins(actor_id)
end
def learn_skill(skill_id)
if skill_id > 0 and not skill_learn?(skill_id)
if $data_skills[skill_id].element_set.include?(SKILLTHINGYELEMENT)
if @spellslevels[$data_skills[skill_id].sp_cost] == SKILLTHINGYMAX
return
else
@skills.push(skill_id)
@skills.sort!
@spellslevels[$data_skills[skill_id].sp_cost] += 1
end
else
@skills.push(skill_id)
@skills.sort!
end
end
end
def forget_skill(skill_id)
if skill_id > 0 and skill_learn?(skill_id) and
$data_skills[skill_id].element_set.include?(SKILLTHINGYELEMENT)
@spellslevels[$data_skills[skill_id].sp_cost] -= 1
end
@skills.delete(skill_id)
end
end
class Game_Party
def resetspellsleft
for actor in $game_party.actors
for i in 0...actor.spellsleft.size
actor.spellsleft[i] = actor.spellsmax[i]
end
end
end
end
class Game_Battler
def skill_can_use?(skill_id)
if $data_skills[skill_id].element_set.include?(SKILLTHINGYELEMENT) and
self.is_a?(Game_Actor)
if self.spellsleft[$data_skills[skill_id].sp_cost] == 0
return false
end
else
# If there's not enough SP, the skill cannot be used.
if $data_skills[skill_id].sp_cost > self.sp
return false
end
end
# Unusable if incapacitated
if dead?
return false
end
# If silent, only physical skills can be used
if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
return false
end
# Get usable time
occasion = $data_skills[skill_id].occasion
# If in battle
if $game_temp.in_battle
# Usable with [Normal] and [Only Battle]
return (occasion == 0 or occasion == 1)
# If not in battle
else
# Usable with [Normal] and [Only Menu]
return (occasion == 0 or occasion == 2)
end
end
def elements_correct(element_set)
# If not an element
if element_set == []
# Return 100
return 100
end
if element_set == [SKILLTHINGYELEMENT]
return 100
end
# Return the weakest object among the elements given
# * "element_rate" method is defined by Game_Actor and Game_Enemy classes,
# which inherit from this class.
weakest = -100
for i in element_set
unless i == SKILLTHINGYELEMENT
weakest = [weakest, self.element_rate(i)].max
end
end
return weakest
end
end
class Window_Skill < Window_Selectable
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 skill.element_set.include?(SKILLTHINGYELEMENT)
self.contents.draw_text(x + 210, y, 70, 32, "Lv" + skill.sp_cost.to_s + " - " + @actor.spellsleft[skill.sp_cost].to_s, 2)
else
self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
end
end
end
class Scene_Skill
def update_skill
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(1)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the skill window
@skill = @skill_window.skill
# If unable to use
if @skill == nil or not @actor.skill_can_use?(@skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# If effect scope is ally
if @skill.scope >= 3
# Activate target window
@skill_window.active = false
@target_window.x = (@skill_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Set cursor position to effect scope (single / all)
if @skill.scope == 4 || @skill.scope == 6
@target_window.index = -1
elsif @skill.scope == 7
@target_window.index = @actor_index - 10
else
@target_window.index = 0
end
# If effect scope is other than ally
else
# If common event ID is valid
if @skill.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @skill.common_event_id
# Play use skill SE
$game_system.se_play(@skill.menu_se)
if @skill.element_set.include?(SKILLTHINGYELEMENT)
@actor.spellsleft[@skill.sp_cost] -= 1
else
# Use up SP
@actor.sp -= @skill.sp_cost
end
# Remake each window content
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
# If R button was pressed
if Input.trigger?(Input::R)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To next actor
@actor_index += 1
@actor_index %= $game_party.actors.size
# Switch to different skill screen
$scene = Scene_Skill.new(@actor_index)
return
end
# If L button was pressed
if Input.trigger?(Input::L)
# Play cursor SE
$game_system.se_play($data_system.cursor_se)
# To previous actor
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# Switch to different skill screen
$scene = Scene_Skill.new(@actor_index)
return
end
end
def update_target
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Erase target window
@skill_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If unable to use because SP ran out
unless @actor.skill_can_use?(@skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @target_window.index == -1
# Apply skill use effects to entire party
used = false
for i in $game_party.actors
used |= i.skill_effect(@actor, @skill)
end
end
# If target is user
if @target_window.index <= -2
# Apply skill use effects to target actor
target = $game_party.actors[@target_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# If single target
if @target_window.index >= 0
# Apply skill use effects to target actor
target = $game_party.actors[@target_window.index]
used = target.skill_effect(@actor, @skill)
end
# If skill was used
if used
# Play skill use SE
$game_system.se_play(@skill.menu_se)
$game_system.se_play(@skill.menu_se)
if @skill.element_set.include?(SKILLTHINGYELEMENT)
@actor.spellsleft[@skill.sp_cost] -= 1
else
# Use up SP
@actor.sp -= @skill.sp_cost
end
# Remake each window content
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# If entire party is dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If command event ID is valid
if @skill.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @skill.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If skill wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
class Scene_Battle
def make_skill_action_result(battler)
# Acquiring skill
@skill = $data_skills[battler.current_action.skill_id]
# Verification whether or not it is cooperation skill,
speller = synthe?(battler)
# If it is not forced action
unless battler.current_action.forcing
# When with SP and so on is cut off and it becomes not be able to use
if speller == nil
unless battler.skill_can_use?(@skill.id)
# It moves to step 6
battler.phase = 6
return
end
end
end
# SP consumption
temp = false
if speller != nil
for spell in speller
if spell.current_action.spell_id == 0
if @skill.element_set.include?(SKILLTHINGYELEMENT) and
spell.is_a?(Game_Actor)
spell.spellsleft[@skill.sp_cost] -= 1
else
spell.sp -= @skill.sp_cost
end
else
if $data_skills[spell.current_action.spell_id].element_set.include?(SKILLTHINGYELEMENT) and
spell.is_a?(Game_Actor)
spell.spellsleft[$data_skills[spell.current_action.spell_id].sp_cost] -= 1
else
spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
end
end
# Refreshing the status window
status_refresh(spell)
end
else
if @skill.element_set.include?(SKILLTHINGYELEMENT) and
battler.is_a?(Game_Actor)
battler.spellsleft[@skill.sp_cost] -= 1
else
battler.sp -= @skill.sp_cost
end
# Refreshing the status window
status_refresh(battler)
end
# Setting animation ID
battler.anime1 = @skill.animation1_id
battler.anime2 = @skill.animation2_id
# Setting common event ID
battler.event = @skill.common_event_id
# Setting the object side battler
set_target_battlers(@skill.scope, battler)
# Applying the effect of skill
for target in battler.target
if speller != nil
damage = 0
d_result = false
effective = false
state_p = []
state_m = []
for spell in speller
if spell.current_action.spell_id != 0
@skill = $data_skills[spell.current_action.spell_id]
end
effective |= target.skill_effect(spell, @skill)
if target.damage[spell].class != String
d_result = true
damage += target.damage[spell]
elsif effective
effect = target.damage[spell]
end
state_p += target.state_p[spell]
state_m += target.state_m[spell]
target.damage.delete(spell)
target.state_p.delete(spell)
target.state_m.delete(spell)
end
if d_result
target.damage[battler] = damage
elsif effective
target.damage[battler] = effect
else
target.damage[battler] = 0
end
target.state_p[battler] = state_p
target.state_m[battler] = state_m
else
target.skill_effect(battler, @skill)
end
end
end
end