01-16-2007, 01:00 PM
Old FF Style Spells
by Jaberwocky
May 29 2007
This is a script that lets you have a number of spell levels, with a certain number of times that you can cast spells from that level, as well as a limit on how many spells of that level you can learn. It also lets you have skills that consume SP like normal, too.
The two constants at the top:
SKILLTHINGYELEMENT = 20
SKILLTHINGYMAX = 3
SKILLTHINGYELEMENT is the element ID that you have to mark skills that will be using this system with. On these skills, you need to set the SP cost of the skill to the level of the skill.
SKILLTHINGYMAX is the maximum number of spells you can learn from each level.
A little further down, you'll find:
@spellsmax = [4, 3, 3, 2, 2, 1, 1, 0, 0, 0]
This is the number of spell levels, and the starting number of spells per level.
You can add as many levels as you want, just add numbers to the array.
You can increase the maximum for any actor by using:
$game_actors[actor id].spellsmax[spell level] = amount
Lastly, to reset the number of times you can cast spells to their maximum levels, use $game_party.resetspellsleft
It should work with most other battle systems, as long as the make_skill_effect thing isnt changed, even then, it's not hard to make it work correctly s:
Edit - To add the increase when level up thing, just follow these steps:
Step 1:
Add 'SPELLINCLEVELS = []' up at the top, right beneath 'SKILLTHINGYMAX ='
Step 2:
(Have fun with this one XD)
To set the spellmax for levels, the method is
SPELLINCLEVELS[actor id] = {
level => [lvl0 spells, lvl1 spells, lvl2 spells, lvl3 spells, lvl4 spells, lvl5 spells, lvl6 spells, lvl7 spells, lvl8 spells, lvl9 spells],
level => [lvl0 spells, lvl1 spells, lvl2 spells, lvl3 spells, lvl4 spells, lvl5 spells, lvl6 spells, lvl7 spells, lvl8 spells, lvl9 spells],
etc...
}
This way if the spells max remains the same for a few levels, you don't have to copy the same thing in for all those levels.
If you have a different number of spell levels than 0-9, keep going until you've done them all. If you don't fill out the array with the same number of values as the @spellsmax/@spellsleft/@spellslevels arrays, then it won't work right and will crash s:
Step 3:
Insert this method:
right below the forget_skill method.
And that should do it o_ob (at least, it's working for me >.>;;)
Another Edit -
Still uses the old system in battle, I have no idea how to fit anything more in there unless I make it hide the battlers at the bottom and show this window over it x| It should also be able to fit up to maybe around 15-16 spell levels if you change the spacing s:
Also, if your 'resetspellsleft' method doesnt look like this:
You need to replace it with that to fix a silly error that links the spellsleft and spellsmax arrays x|
by Jaberwocky
May 29 2007
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given.
No support is given.
This is a script that lets you have a number of spell levels, with a certain number of times that you can cast spells from that level, as well as a limit on how many spells of that level you can learn. It also lets you have skills that consume SP like normal, too.
DBS Version
Code:
#-------------------------------------------------------------------------------
# Old FF Style Spells
# by Jaberwocky
#-------------------------------------------------------------------------------
SKILLTHINGYELEMENT = 20
SKILLTHINGYMAX = 3
class Game_Actor < Game_Battler
attr_accessor :spellsleft
attr_accessor :spellsmax
attr_accessor :spellslevels
alias moosemuffins setup
def setup(actor_id)
@spellsmax = [4, 3, 3, 2, 2, 1, 1, 0, 0, 0]
@spellsleft = [4, 3, 3, 2, 2, 1, 1, 0, 0, 0]
@spellslevels = [0, 0, 0, 0, 0, 0, 0, 0, 0]
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
# Get skill
@skill = $data_skills[@active_battler.current_action.skill_id]
# If not a forcing action
unless @active_battler.current_action.forcing
# If unable to use due to SP running out
unless @active_battler.skill_can_use?(@skill.id)
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
if @active_battler.is_a?(Game_Actor) and
@skill.element_set.include?(SKILLTHINGYELEMENT)
@active_battler.spellsleft[@skill.sp_cost] -= 1
else
# Use up SP
@active_battler.sp -= @skill.sp_cost
end
# Refresh status window
@status_window.refresh
# Show skill name on help window
@help_window.set_text(@skill.name, 1)
# Set animation ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# Set command event ID
@common_event_id = @skill.common_event_id
# Set target battlers
set_target_battlers(@skill.scope)
# Apply skill effect
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
end
RTAB Version
Code:
#-------------------------------------------------------------------------------
# Old FF Style Spells
# by Jaberwocky
#-------------------------------------------------------------------------------
SKILLTHINGYELEMENT = 20
SKILLTHINGYMAX = 3
class Game_Actor < Game_Battler
attr_accessor :spellsleft
attr_accessor :spellsmax
attr_accessor :spellslevels
alias moosemuffins setup
def setup(actor_id)
@spellsmax = [4, 3, 3, 2, 2, 1, 1, 0, 0, 0]
@spellsleft = [4, 3, 3, 2, 2, 1, 1, 0, 0, 0]
@spellslevels = [0, 0, 0, 0, 0, 0, 0, 0, 0]
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
The two constants at the top:
SKILLTHINGYELEMENT = 20
SKILLTHINGYMAX = 3
SKILLTHINGYELEMENT is the element ID that you have to mark skills that will be using this system with. On these skills, you need to set the SP cost of the skill to the level of the skill.
SKILLTHINGYMAX is the maximum number of spells you can learn from each level.
A little further down, you'll find:
@spellsmax = [4, 3, 3, 2, 2, 1, 1, 0, 0, 0]
This is the number of spell levels, and the starting number of spells per level.
You can add as many levels as you want, just add numbers to the array.
You can increase the maximum for any actor by using:
$game_actors[actor id].spellsmax[spell level] = amount
Lastly, to reset the number of times you can cast spells to their maximum levels, use $game_party.resetspellsleft
It should work with most other battle systems, as long as the make_skill_effect thing isnt changed, even then, it's not hard to make it work correctly s:
Edit - To add the increase when level up thing, just follow these steps:
Step 1:
Add 'SPELLINCLEVELS = []' up at the top, right beneath 'SKILLTHINGYMAX ='
Step 2:
(Have fun with this one XD)
To set the spellmax for levels, the method is
SPELLINCLEVELS[actor id] = {
level => [lvl0 spells, lvl1 spells, lvl2 spells, lvl3 spells, lvl4 spells, lvl5 spells, lvl6 spells, lvl7 spells, lvl8 spells, lvl9 spells],
level => [lvl0 spells, lvl1 spells, lvl2 spells, lvl3 spells, lvl4 spells, lvl5 spells, lvl6 spells, lvl7 spells, lvl8 spells, lvl9 spells],
etc...
}
This way if the spells max remains the same for a few levels, you don't have to copy the same thing in for all those levels.
If you have a different number of spell levels than 0-9, keep going until you've done them all. If you don't fill out the array with the same number of values as the @spellsmax/@spellsleft/@spellslevels arrays, then it won't work right and will crash s:
Step 3:
Insert this method:
Code:
alias thingamajigger level=
def level=(level)
thingamajigger(level)
for i in 1..level
unless SPELLINCLEVELS[self.id] == nil
@spellsmax = SPELLINCLEVELS[self.id][level] unless SPELLINCLEVELS[self.id][level] == nil
end
end
for j in 0...@spellsleft.size
if @spellsleft[j] > @spellsmax[j]
@spellsleft[j] = @spellsmax[j]
end
end
end
right below the forget_skill method.
And that should do it o_ob (at least, it's working for me >.>;;)
Another Edit -
Made this window for the menu to show the spells left
(Dead Image Link)
Still uses the old system in battle, I have no idea how to fit anything more in there unless I make it hide the battlers at the bottom and show this window over it x| It should also be able to fit up to maybe around 15-16 spell levels if you change the spacing s:
Spell Window
Code:
class Window_Skill < Window_Selectable
def initialize(actor)
super(0, 64, 640, 256)
@actor = actor
@column_max = 2
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
self.height = 256
if $game_temp.in_battle
self.back_opacity = 160
end
end
end
class Window_Spellsleft < Window_Base
def initialize(actor)
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
draw_actor_name(@actor, 4, 0)
draw_actor_state(@actor, 140, 0)
draw_actor_hp(@actor, 284, 0)
draw_actor_sp(@actor, 460, 0)
y = -16
for i in 0...@actor.spellsleft.size
x = 24 + (120 * (i % 5))
if i % 5 == 0
y += 48
end
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 64, 32, "Level " + i.to_s, 1)
self.contents.font.color = system_color
if @actor.spellsleft[i] == 0 and @actor.spellsmax[i] >= 1
self.contents.font.color = knockout_color
elsif @actor.spellsmax[i] > 0
if @actor.spellsmax[i] >= 3
self.contents.font.color = crisis_color if (@actor.spellsleft[i] * 3) <= @actor.spellsmax[i]
else
self.contents.font.color = crisis_color if (@actor.spellsleft[i] * 2) <= @actor.spellsmax[i]
end
end
self.contents.draw_text(x, y + 24, 64, 32, @actor.spellsleft[i].to_s, 1)
end
end
end
class Scene_Skill
def main
# Get actor
@actor = $game_party.actors[@actor_index]
# Make help window, status window, and skill window
@help_window = Window_Help.new
@skill_window = Window_Skill.new(@actor)
# Associate help window
@skill_window.help_window = @help_window
@spellsleftwindow = Window_Spellsleft.new(@actor)
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@spellsleftwindow.dispose
@help_window.dispose
@skill_window.dispose
@target_window.dispose
end
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
@skill_window.refresh
@target_window.refresh
@spellsleftwindow.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
@skill_window.refresh
@target_window.refresh
@spellsleftwindow.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
Also, if your 'resetspellsleft' method doesnt look like this:
Code:
def resetspellsleft
for actor in $game_party.actors
for i in 0...actor.spellsleft.size
actor.spellsleft[i] = actor.spellsmax[i]
end
end
end
You need to replace it with that to fix a silly error that links the spellsleft and spellsmax arrays x|