Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Skyval's Agility Based Battle System

I'm having a little trouble with Skyval's Agility Based Battle System. In fact it is a problem that prevents me from ever actually releasing a demo.

See my problem is that when I attack, the bar returns to zero and begins to refill allowing others to take their turn in battle. However when I use a skill, the bar doesn't return to zero effectively giving the player and infinite amount of turns because it becomes his go the next round straight away barely giving time for the other bars to fill more than 1% extra.

Here is the script including any edits I made to it to change the location of the time bar on the battle screen to be more appropriately suited with the custom battle system I have up. Anyone got any suggestions or ideas?


Code:
#==============================================================================
#  ▼▲▼ Syvkal's Agility Based Battle V1.1 ▼▲▼
#-----------------------------------------------------------------
#  By Syvkal
#  Based on ▼▲▼ XRXS_BP 1. CP制導入 ver..16 ▼▲▼
#==============================================================================
#  Thanks to also to Ccoa for teaching me how to use Alias
#-----------------------------------------------------------------
# This scipt is simple and easy to use. 
# To add more commands for seperate types of skills. Search for: ADD
#==============================================================================
class Scene_Battle
DATA_SYSTEM_COMMAND_UP_SE = "ready"
#        Command Name            CP Cost
CP_COST_BASIC_ACTIONS = 65535
CP_COST_SKILL_ACTION = 65535
CP_COST_ITEM_ACTION = 65535
CP_COST_BASIC_ATTACK = 65535
CP_COST_BASIC_GUARD = 32768
CP_COST_BASIC_NOTHING = 65535
CP_COST_BASIC_ESCAPE = 65535
CP_COST_SKILL_CLASS_SPECIAL = 40200
# ADD more commands here
end
class Scene_Battle_CP
BATTLE_SPEED = 0.4
START_CP_PERCENT = 0
end
#==============================================================================
class Scene_Battle_CP
#--------------------------------------------------------------------------
attr_accessor :stop
#----------------------------------------------------------------------------
def initialize
@battlers = []
@cancel = false
@stop = false
@agi_total = 0
count_battlers = []
for enemy in $game_troop.enemies
count_battlers.push(enemy)
end
for actor in $game_party.actors
count_battlers.push(actor)
end
for battler in count_battlers
@agi_total += battler.agi
end
for battler in count_battlers
battler.cp = [[65535 * START_CP_PERCENT * (rand(15) + 85) * 4 * battler.agi / @agi_total / 10000, 0].max, 65535].min
end
end
#----------------------------------------------------------------------------
def update
return if @stop
for battler in $game_party.actors + $game_troop.enemies
if battler.dead? == true
battler.cp = 0
next
end
battler.cp = [[battler.cp + BATTLE_SPEED * 4096 * battler.agi / @agi_total, 0].max, 65535].min
end
end
#----------------------------------------------------------------------------
def stop
@cancel = true
if @cp_thread != nil then
@cp_thread.join
@cp_thread = nil
end
end
end
#==============================================================================
class Game_Battler
attr_accessor :now_guarding
attr_accessor :cp
attr_accessor :slip_state_update_ban
#--------------------------------------------------------------------------
alias xrxs_bp1_inputable? inputable?
def inputable?
bool = xrxs_bp1_inputable?
return (bool and (@cp >= 65535))
end
#--------------------------------------------------------------------------
alias xrxs_bp1_slip_damage? slip_damage?
def slip_damage?
return false if @slip_state_update_ban
return xrxs_bp1_slip_damage?
end
#--------------------------------------------------------------------------
alias xrxs_bp1_remove_states_auto remove_states_auto
def remove_states_auto
return if @slip_state_update_ban
xrxs_bp1_remove_states_auto
end
end
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
alias xrxs_bp1_setup setup
def setup(actor_id)
xrxs_bp1_setup(actor_id)
@hate = 100
@cp = 0
@now_guarding = false
@slip_state_update_ban = false
end
end
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
alias xrxs_bp1_initialize initialize
def initialize(troop_id, member_index)
xrxs_bp1_initialize(troop_id, member_index)
@hate = 100 # init-value is 100
@cp = 0
@now_guarding = false
@slip_state_update_ban = false
end
end
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
attr_accessor :update_cp_only
#--------------------------------------------------------------------------
alias xrxs_bp1_initialize initialize
def initialize
@update_cp_only = false
xrxs_bp1_initialize
end
#--------------------------------------------------------------------------
alias xrxs_bp1_refresh refresh
def refresh
unless @update_cp_only
xrxs_bp1_refresh
end
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
actors_size = [$game_party.actors.size, 4].max
max_width = [600 / (actors_size + 1), 80].max
x_shift = max_width + (600 - max_width*actors_size)/(actors_size - 1)
actor_x = i * x_shift + 4
draw_actor_cp_meter(actor, 450, i * 25 + 4, max_width, 0)
end
end
#--------------------------------------------------------------------------



           
           
           
           
           
def draw_actor_cp_meter(actor, x, y, width = 156, type = 0)
 if actor.cp != 0
   rate = actor.cp.to_f / 65535
 else
   rate = 1
 end
 plus_x = 0
 rate_x = 0
 plus_y = 32
 plus_width = 0
 rate_width = 80
 height = 7
 align1 = 1
 align2 = 2
 align3 = 0
 grade1 = 1
 grade2 = 0
 color1 = Color.new(0, 0, 0, 192)
 color2 = Color.new(255, 255, 192, 192)
 color3 = Color.new(0, 0, 0, 192)
 color4 = Color.new(64, 0, 0, 192)
 color5 = Color.new(255 * rate, 80 * rate ** 2, 80 - 80 * rate, 192)
 color6 = Color.new(235 * rate, 255 - 10 * rate ** 2, 240 - 205 * rate, 192)
 if actor.cp != 0
   cp = (width + plus_width) * actor.cp * rate_width /
                                                       100 / 65535
 else
   cp = (width + plus_width) * rate_width / 100
 end
     gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
             width, plus_width + width * rate_width / 100,
             height, cp, align1, align2, align3,
             color1, color2, color3, color4, color5, color6, grade1, grade2)
           end
         end
         


#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
alias xrxs_bp1_update update
def update
xrxs_bp1_update
@cp_thread.update
end
#--------------------------------------------------------------------------
alias xrxs_bp1_battle_end battle_end
def battle_end(result)
@cp_thread.stop
xrxs_bp1_battle_end(result)
end
#--------------------------------------------------------------------------
alias xrxs_bp1_start_phase1 start_phase1
def start_phase1
@agi_total = 0
@cp_thread = Scene_Battle_CP.new
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4, "Escape"])
@actor_command_window.y = 128
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
@actor_command_window.draw_item(4, $game_temp.battle_can_escape ? @actor_command_window.normal_color : @actor_command_window.disabled_color)
xrxs_bp1_start_phase1
end
#--------------------------------------------------------------------------
alias xrxs_bp1_start_phase2 start_phase2
def start_phase2
xrxs_bp1_start_phase2
@party_command_window.active = false
@party_command_window.visible = false
start_phase3
end
#--------------------------------------------------------------------------
alias xrxs_bp1_phase3_setup_command_window phase3_setup_command_window
def phase3_setup_command_window
@cp_thread.stop = true
@active_battler.now_guarding = false
Audio.se_play(DATA_SYSTEM_COMMAND_UP_SE) if DATA_SYSTEM_COMMAND_UP_SE != ""
xrxs_bp1_phase3_setup_command_window
end
#--------------------------------------------------------------------------
alias xrxs_bsp1_update_phase3_basic_command update_phase3_basic_command
def update_phase3_basic_command
if Input.trigger?(Input::C)
case @actor_command_window.index
when 4
if $game_temp.battle_can_escape
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 4
phase3_next_actor
else
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
xrxs_bsp1_update_phase3_basic_command
end
#--------------------------------------------------------------------------
alias xrxs_bp1_start_phase4 start_phase4
def start_phase4
xrxs_bp1_start_phase4
@cp_thread.stop = false
end
#--------------------------------------------------------------------------
alias xrxs_bp1_make_action_orders make_action_orders
def make_action_orders
xrxs_bp1_make_action_orders
exclude_battler = []
for battler in @action_battlers
if battler.cp < 65535
exclude_battler.push(battler)
end
end
@action_battlers -= exclude_battler
end
#--------------------------------------------------------------------------
alias xrxs_bp1_update_phase4_step1 update_phase4_step1
def update_phase4_step1
@phase4_act_continuation = 0
if judge
@cp_thread.stop
return
end
@active_battler = @action_battlers[0]
@status_window.update_cp_only = true
@active_battler.slip_state_update_ban = true if @active_battler != nil
xrxs_bp1_update_phase4_step1
if @phase4_step != 2
@status_window.refresh
Graphics.frame_reset
end
@status_window.update_cp_only = false
@active_battler.slip_state_update_ban = false if @active_battler != nil
end
#--------------------------------------------------------------------------
alias xrxs_bp1_update_phase4_step2 update_phase4_step2
def update_phase4_step2
unless @active_battler.current_action.forcing
if @active_battler.restriction == 2 or @active_battler.restriction == 3
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
end
if @active_battler.restriction == 4
$game_temp.forcing_battler = nil
if @phase4_act_continuation == 0 and @active_battler.cp >= 65535
@active_battler.remove_states_auto
@active_battler.cp = [(@active_battler.cp - 65535),0].max
@status_window.refresh
end
@phase4_step = 1
return
end
end
case @active_battler.current_action.kind
when 0
@active_battler.cp -= CP_COST_BASIC_ACTIONS if @phase4_act_continuation == 0
when 2
@active_battler.cp -= CP_COST_ITEM_ACTION if @phase4_act_continuation == 0
end
@cp_thread.stop = true
@active_battler.remove_states_auto
xrxs_bp1_update_phase4_step2
end
#--------------------------------------------------------------------------
alias original_make_skill_action_result make_skill_action_result
def make_skill_action_result
  original_make_skill_action_result
    if @skill.element_set.include?(17)
      @active_battler.cp -= CP_COST_SKILL_CLASS_SPECIAL if @phase4_act_continuation == 0
# ADD more sets of skill types here
# To add more just add elsif @skill.element_set.include?(ID)
# Make ID the ID of your attribute and then change CP_COST_SKILL_CLASS_SPECIAL
# To the name of the command you added at the top
    else
      @active_battler.cp -= CP_COST_SKILL_ACTION if @phase4_act_continuation == 0
    end
  end

#--------------------------------------------------------------------------
alias xrxs_bp1_make_basic_action_result make_basic_action_result
def make_basic_action_result
if @active_battler.current_action.basic == 0 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_ATTACK
end
if @active_battler.current_action.basic == 1 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_GUARD
end
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_ESCAPE
end
if @active_battler.current_action.basic == 3 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_NOTHING
end
if @active_battler.current_action.basic == 4 and @phase4_act_continuation == 0
@active_battler.cp -= CP_COST_BASIC_ESCAPE
if $game_temp.battle_can_escape == false
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
update_phase2_escape
return
end
xrxs_bp1_make_basic_action_result
end
#--------------------------------------------------------------------------
alias xrxs_bp1_update_phase4_step3 update_phase4_step3
def update_phase4_step3
xrxs_bp1_update_phase4_step3
end
#--------------------------------------------------------------------------
alias xrxs_bp1_update_phase4_step5 update_phase4_step5
def update_phase4_step5
if @active_battler.hp > 0 and @active_battler.slip_damage?
@active_battler.slip_damage_effect
@active_battler.damage_pop = true
end
xrxs_bp1_update_phase4_step5
end
#--------------------------------------------------------------------------
def update_phase4_step7
@cp_thread.stop = false
@help_window.visible = false
end
end


EDIT: I have a fear that it may be clashing with another script so here are the names of those I'm using:

The SDK Ver. 1.5
The KGC Module
----------------
Esper + Junction System
FF7 Menu by Acedent_Prone
Cogwheel's HP/MP/EXP
Deke's Crafting System
FF7 Opening Credits by Squall789
Limit Breaks by DerVerVulfman
Passablity Mini-Map by Selwyn
KGC Skill Grouping
KGC Item Grouping
Advanced Save Menu by Selwyn
Reflection Script by Rataime
Destruction Engine by Rataime
File Error Report by SephirothSpawn
Anti-Lag by Near Fantastica
Cursor Script by Selwyn
Shadow Text by Ultimate Jesus
Steal Effect by Trickster
-----------------------
Triple Triad by Sephiroth Spawn
-----------------------
Others not above Main:

FFX-XII Damage Display by Selwyn
Side View Battlers by RPG Advocate
Final Fantasy Style Battle Status by Petros


I have my doubts that any of those actually clash with the script however, except perhaps the SDK.
 
Did you read the comment :
# ADD more sets of skill types here
# To add more just add elsif @skill.element_set.include?(ID)
# Make ID the ID of your attribute and then change CP_COST_SKILL_CLASS_SPECIAL
# To the name of the command you added at the top
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top