First, allow me say, I am relatively new when it comes to scripting (my knowledge is mostly confined to script modifying, not creating), so any help would be greatly appreciated.
Anyway, I've been using Atoa's version of Tankentai's Side view battle system and most of the add-on's with it. I have already adjusted the interface (windows and so forth) to make them compatible with the ATB system in Tankentai's sideview battle system. I recently tried an advanced skills option script that allows the actor to use a certain amount of MP to increase/decrease the power of a skill. Everything works, except when I go to actually use the skill. The actors simply don't move, they don't use the skill. There is no error, and the script works fine with the regular battle system that comes with the maker, but for whatever reason everything in the script works fine except the actual skill use. Like I said, nothing happens, but I cannot seem to locate why or where the problem is occurring.
So my question is, does anyone have any ideas of what might be causing this? I pasted the code below. Any ideas what might be conflicting and what could be done to make them compatible?
Thank you again for any help in advance.
#==============================================================================
# Advanced Skill Options
# Version 1.0
# Author: modern algebra
# Date: June 5, 2007
#------------------------------------------------------------------------------
# Description: This script is loosely based off the Betrayal at Krondor Spell
# System, with a few differences. Basically, it allows the player to determine
# the power of his skills by choosing how much SP he will use to use the skill.
# Basically, it multiplies each stat which determines effect (POWER, ATK-F,
# etc...) by the percentage of the max SP the player uses. So, if the player
# devotes 20 SP to a skill with 100 max SP, then each of the stats of the skill
# will be only 20% their original value. Also, skills with a power of 0 are
# ignored by this script, so for skills which cause status effects, just set the
# power to 0
#------------------------------------------------------------------------------
# Instructions:
# Place this script above main in the script editor
#==============================================================================
class Window_SkillData < Window_Base
def initialize (skill)
super(340, 80, 300, 240)
self.contents = Bitmap.new(width - 32, height - 32)
self.z=190
self.opacity = 100
@skill = skill
$choice_sp_cost = 0
refresh
end
def refresh
self.contents.clear
line = []
tw = @skill.name.length*10
if tw > 280
tw = 280
end
self.contents.font.color = system_color
self.contents.draw_text (130 - (0.5*tw),0,tw,32, @skill.name)
self.contents.font.color = normal_color
self.contents.font.size = 18
tw = @skill.description.length
line_index = 0
limit = 0
loop do
line[line_index] = @skill.description[limit, 36]
for i in 1...36
if line[line_index][-i,1] == " " || limit + (36-i) >= @skill.description.size
limit += (37-i)
tw -= 36-i
line_index +=1
break
else
line[line_index][-i,1] = " "
end
end
if tw <= 0
break
end
end
line.compact!
for i in 0...line.size
self.contents.draw_text (0, 26*i + 32, 280,32, line[i])
end
self.contents.font.color = system_color
self.contents.font.size = 22
self.contents.draw_text (0,2*26 + 64,160,32, "Skill Power:")
self.contents.draw_text (0,2*26 + 96,160,32, "Max " +$data_system.words.sp+ " Cost:")
self.contents.draw_text (0,2*26 + 128,160,32, "Current Power:")
self.contents.font.color = normal_color
max_power = @skill.power.to_f / @skill.sp_cost.to_f
max_power = (max_power*100).round.to_f / 100.0
tw = (max_power.to_s + " * " +$data_system.words.sp).length
tw = tw*6
self.contents.draw_text (248 - tw,2*26 + 64,140,32, max_power.to_s + " * " +$data_system.words.sp)
self.contents.draw_text (248 - tw,2*26 + 96,160,32, @skill.sp_cost.to_s)
self.contents.draw_text (248 - tw,2*26 + 128,160,32, (max_power*$choice_sp_cost).to_s)
end
end
class Window_ChoosePower < Window_Selectable
def initialize (skill, actor)
super(0, 246, 160, 80)
self.contents = Bitmap.new(width - 32, height - 32)
self.z=200
self.opacity = 235
@actor = actor
@skill = skill
sp_cost_digits_temp = @skill.sp_cost
$sp_cost_digits = 0
while sp_cost_digits_temp != 0
sp_cost_digits_temp = sp_cost_digits_temp / 10
$sp_cost_digits +=1
end
$digits = []
for i in 0...$sp_cost_digits
$digits[i] = 0
end
self.active = false
self.index = 0
refresh
end
def refresh
self.contents.clear
for i in 0...$sp_cost_digits
self.contents.draw_text(75+ i*20 - $sp_cost_digits*10,5,20,32,$digits[i].to_s)
end
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
@index = self.index
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(70 + @index*20 - $sp_cost_digits*10,5,20,32)
end
end
def determine_sp_cost
current_sp = ""
for i in 0...$sp_cost_digits
current_sp += $digits[i].to_s
end
current_sp = current_sp.to_i
return current_sp
end
def update
$choice_sp_cost = determine_sp_cost
if Input.repeat? (Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
self.index = (self.index + 1) % ($sp_cost_digits)
update_cursor_rect
elsif Input.repeat? (Input::LEFT)
$game_system.se_play($data_system.cursor_se)
self.index = (self.index - 1)% ($sp_cost_digits)
update_cursor_rect
elsif Input.repeat? (Input::DOWN)
$digits[self.index] = ($digits[self.index] - 1)%10
current_sp = determine_sp_cost
if @skill.sp_cost < @actor.sp
max_sp_cost = @skill.sp_cost
else
max_sp_cost = @actor.sp
end
while current_sp > max_sp_cost
$digits[self.index] = ($digits[self.index] - 1)
current_sp = determine_sp_cost
end
$choice_sp_cost = current_sp
elsif Input.repeat? (Input::UP)
$game_system.se_play($data_system.cursor_se)
$digits[self.index] = ($digits[self.index] + 1) % 10
current_sp = determine_sp_cost
if @skill.sp_cost < @actor.sp
max_sp_cost = @skill.sp_cost
else
max_sp_cost = @actor.sp
end
if current_sp > max_sp_cost
$digits[self.index] = 0
end
$choice_sp_cost = determine_sp_cost
end
refresh
end
end
class Game_Battler
#--------------------------------------------------------------------------
# * Determine Usable Skills
# skill_id : skill ID
#--------------------------------------------------------------------------
def skill_can_use?(skill_id)
# If there's not enough SP, the skill cannot be used.
if self.sp == 0 || ($data_skills[skill_id].power == 0 && $data_skills[skill_id].sp_cost > self.sp)
return false
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
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# This class performs skill screen processing.
#==============================================================================
class Scene_Skill
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@wait = 0
$skill_stats = []
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Get actor
@actor = $game_party.actors[@actor_index]
# Make help window, status window, and skill window
@help_window = Window_Help.new
@status_window = Window_SkillStatus.new(@actor)
@skill_window = Window_Skill.new(@actor)
# Associate help window
@skill_window.help_window = @help_window
# 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
@help_window.dispose
@status_window.dispose
@skill_window.dispose
@target_window.dispose
if @data_window != nil
@data_window.dispose
@power_window.dispose
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@status_window.update
@skill_window.update
@target_window.update
if @wait == 1
@target_window.visible = false
@skill_window.active = true
@wait -=1
return
elsif @wait > 0
@wait -=1
return
end
# If skill window is active: call update_skill
if @skill_window.active
update_skill
return
end
# If skill target is active: call update_target
if @target_window.active
update_target
return
end
# If power window is active: call update_power
if @power_window.active
update_power
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (if skill window is active)
#--------------------------------------------------------------------------
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 power window
@skill_window.active = false
@target_window.x = (@skill_window.index + 1) % 2 * 304
if @skill.power != 0
@power_window = Window_ChoosePower.new (@skill, @actor)
@data_window = Window_SkillData.new (@skill)
@power_window.active = true
@power = true
else
@target_window.active = true
@target_window.visible = true
@power = false
end
# 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)
# Use up SP
@actor.sp -= @skill.sp_cost
# 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
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
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
@target_window.visible = false
@target_window.active = false
@power_window.active = true
@power_window.visible = true
@data_window.visible = true
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)
@target_window.active = false
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)
# Use up SP
@actor.sp -= @skill.sp_cost
# If SP Cost Chosen
if @power == true
# Return stats to original values
$data_skills[@skill.id].sp_cost = $skill_stats[@skill.id][7]
$data_skills[@skill.id].power = $skill_stats[@skill.id][0]
$data_skills[@skill.id].atk_f = $skill_stats[@skill.id][1]
$data_skills[@skill.id].eva_f = $skill_stats[@skill.id][2]
$data_skills[@skill.id].str_f = $skill_stats[@skill.id][3]
$data_skills[@skill.id].dex_f = $skill_stats[@skill.id][4]
$data_skills[@skill.id].agi_f = $skill_stats[@skill.id][5]
$data_skills[@skill.id].int_f = $skill_stats[@skill.id][6]
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
@target_window.active = false
@wait = 15
end
# If skill wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
# If SP Cost was chosen
if @power == true
# Return stats to original values
$data_skills[@skill.id].sp_cost = $skill_stats[@skill.id][7]
$data_skills[@skill.id].power = $skill_stats[@skill.id][0]
$data_skills[@skill.id].atk_f = $skill_stats[@skill.id][1]
$data_skills[@skill.id].eva_f = $skill_stats[@skill.id][2]
$data_skills[@skill.id].str_f = $skill_stats[@skill.id][3]
$data_skills[@skill.id].dex_f = $skill_stats[@skill.id][4]
$data_skills[@skill.id].agi_f = $skill_stats[@skill.id][5]
$data_skills[@skill.id].int_f = $skill_stats[@skill.id][6]
end
end
return
end
end
def update_power
@power_window.update
@data_window.refresh
# If Enter is pressed, assign updated stats to the skill
if Input.trigger? (Input::C)
$game_system.se_play($data_system.decision_se)
# Retain original stats in an array
$skill_stats[@skill.id] = [@skill.power, @skill.atk_f, @skill.eva_f, @skill.str_f, @skill.dex_f, @skill.agi_f, @skill.int_f, @skill.sp_cost]
# Set the stats of the skill to their new power
multiplier = ($choice_sp_cost.to_f / $data_skills[@skill.id].sp_cost.to_f)
$data_skills[@skill.id].power = ($data_skills[@skill.id].power * multiplier).to_i
$data_skills[@skill.id].atk_f = ($data_skills[@skill.id].atk_f * multiplier).to_i
$data_skills[@skill.id].eva_f = ($data_skills[@skill.id].eva_f * multiplier).to_i
$data_skills[@skill.id].str_f = ($data_skills[@skill.id].str_f * multiplier).to_i
$data_skills[@skill.id].dex_f = ($data_skills[@skill.id].dex_f * multiplier).to_i
$data_skills[@skill.id].agi_f = ($data_skills[@skill.id].agi_f * multiplier).to_i
$data_skills[@skill.id].int_f = ($data_skills[@skill.id].int_f * multiplier).to_i
$data_skills[@skill.id].sp_cost = $choice_sp_cost
# turn off choose_power and choose target
@power_window.active = false
@power_window.visible = false
@data_window.visible = false
@target_window.visible = true
@target_window.active = true
end
# If ESC is pressed, return to the skill choosing window
if Input.trigger? (Input::B)
$game_system.se_play ($data_system.cancel_se)
@power_window.active = false
@power_window.visible = false
@data_window.visible = false
@skill_window.active = true
end
end
end
class Scene_Battle
alias dispose_new_windows end_skill_select
def end_skill_select
dispose_new_windows
if @power_window != nil
@power_window.dispose
@power_window = nil
end
if @data_window != nil
@data_window.dispose
@data_window = nil
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase)
#--------------------------------------------------------------------------
def update_phase3
# If enemy arrow is enabled
if @enemy_arrow != nil
update_phase3_enemy_select
# If actor arrow is enabled
elsif @actor_arrow != nil
update_phase3_actor_select
# If skill window is enabled
elsif @power_window != nil
update_power
elsif @skill_window != nil
update_phase3_skill_select
# If item window is enabled
elsif @item_window != nil
update_phase3_item_select
# If actor command window is enabled
elsif @actor_command_window.active
update_phase3_basic_command
end
end
def update_phase3_skill_select
# Make skill window visible
@skill_window.visible = true
# Update skill window
@skill_window.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# End skill selection
end_skill_select
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 it can't be used
if @skill == nil or not @active_battler.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)
@data_window = Window_SkillData.new (@skill)
@power_window = Window_ChoosePower.new (@skill, $game_party.actors[@actor_index])
if @power == nil
@power = []
end
if @skill.power != 0
@power_window.visible = true
@power_window.active = true
@power[@skill.id] = true
else
@power[@skill.id] = false
@power_window.active = false
@power_window.visible = false
@data_window.visible = false
# Set action
@active_battler.current_action.skill_id = @skill.id
# Make skill window invisible
@skill_window.visible = false
# If effect scope is single enemy
if @skill.scope == 1
# Start enemy selection
start_enemy_select
# If effect scope is single ally
elsif @skill.scope == 3 or @skill.scope == 5
# Start actor selection
start_actor_select
# If effect scope is not single
else
# End skill selection
end_skill_select
# Go to command input for next actor
phase3_next_actor
end
end
return
end
end
def update_power
@power_window.update
@data_window.refresh
if Input.trigger? (Input::C)
if $choice_sp_cost == 0
$choice_sp_cost = 1
end
if $skill_stats == nil
$skill_stats = []
end
$game_system.se_play($data_system.decision_se)
# Retain original stats in an array
$skill_stats[@skill.id] = [@skill.power, @skill.atk_f, @skill.eva_f, @skill.str_f, @skill.dex_f, @skill.agi_f, @skill.int_f, @skill.sp_cost]
# Set the stats of the skill to their new power
multiplier = ($choice_sp_cost.to_f / $data_skills[@skill.id].sp_cost.to_f)
$data_skills[@skill.id].power = ($data_skills[@skill.id].power * multiplier).to_i
$data_skills[@skill.id].atk_f = ($data_skills[@skill.id].atk_f * multiplier).to_i
$data_skills[@skill.id].eva_f = ($data_skills[@skill.id].eva_f * multiplier).to_i
$data_skills[@skill.id].str_f = ($data_skills[@skill.id].str_f * multiplier).to_i
$data_skills[@skill.id].dex_f = ($data_skills[@skill.id].dex_f * multiplier).to_i
$data_skills[@skill.id].agi_f = ($data_skills[@skill.id].agi_f * multiplier).to_i
$data_skills[@skill.id].int_f = ($data_skills[@skill.id].int_f * multiplier).to_i
$data_skills[@skill.id].sp_cost = $choice_sp_cost
# Get rid of power and data window
@power_window.active = false
@power_window.visible = false
@data_window.visible = false
# Set action
@active_battler.current_action.skill_id = @skill.id
# Make skill window invisible
@skill_window.visible = false
# If effect scope is single enemy
if @skill.scope == 1
# Start enemy selection
start_enemy_select
# If effect scope is single ally
elsif @skill.scope == 3 or @skill.scope == 5
# Start actor selection
start_actor_select
# If effect scope is not single
else
# End skill selection
end_skill_select
# Go to command input for next actor
phase3_next_actor
end
end
if Input.trigger? (Input::B)
$game_system.se_play($data_system.buzzer_se)
@data_window.visible = false
@power_window.dispose
@power_window = nil
end
end
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
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
# Use up SP
@active_battler.sp -= @skill.sp_cost
# 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)
if @power[@skill.id] == true
# Return stats to original values
$data_skills[@skill.id].sp_cost = $skill_stats[@skill.id][7]
$data_skills[@skill.id].power = $skill_stats[@skill.id][0]
$data_skills[@skill.id].atk_f = $skill_stats[@skill.id][1]
$data_skills[@skill.id].eva_f = $skill_stats[@skill.id][2]
$data_skills[@skill.id].str_f = $skill_stats[@skill.id][3]
$data_skills[@skill.id].dex_f = $skill_stats[@skill.id][4]
$data_skills[@skill.id].agi_f = $skill_stats[@skill.id][5]
$data_skills[@skill.id].int_f = $skill_stats[@skill.id][6]
end
end
end
end