RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

[Request] Chaos Drive Bar

Started by busbuzz, December 26, 2006, 03:30:58 AM

0 Members and 2 Guests are viewing this topic.

busbuzz

I want to change this script bein able to use the chaos drive only until the Chaos Drive fills.

#==============================================================================
# Chaos Drive System + Soul Limit System by Blizzard
# Version: 1.0
# Date: 10.10.2006
#
#
# Compatibility:
#
# 99% chance of full compatibility with SDK, not tested altough. WILL corrupt
# your old savegames. Can cause incompatibilty issues with following scripts
# and/or systems:
# - exotic CBS-es
# - Limit Break systems
# WILL cause incompatibility issues with:
# - Soul Rage System + Soul Limit System of any version
#
# Complexity:
# - average
#
# Special knowledge REQUIRED:
# - reading long and boring instructions
# - using the "Call Script" event command
#
#
# Features:
#
# - configure your database easily
# - contains universal font fix, never ever "I can´t see the letters"
# - replaces entire party with one Chaos Drive
# - revert Chaos Drive anytime
#
#
# Instructions:
#
# - Explanation:
# This script will allow the player to use Chaos Drive when in the critical
# HP zone. Chaos Drive will transform the character into another and remove the
# entire party from battle. If a Chaos Drive dies, his original form will also
# die and the party will be brought back. Chaos Drives are always full with HP
# and SP when they enter the battle.
#
# - Configuration:
# Press CRTL+SHIFT+F and type into the window: START Chaos Drive Database
# You can jump now to the database directly. There are more instructions.
# Also please configure the following macros found below:
#
# CHAOS_COLOR   - set the values in the () to numbers between 0-255, also note
#                 that they determine the color ammount in the color like this
#                 example: (RED, GREEN, BLUE, ALPHA) - note: alpha = opacity
# CD_PRECENTAGE - the max percentage of HP the character must have to unlock CD
# EXP_NORMALIZE - set to true if the EXP/LVL of your Chaos Drives should be set
#                 to the same as their caller
#
# To add a new Chaos Drive to a characer use the "Call Script" event command
# and use following syntax:
#
# $game_actors[X].learn_cd(CD_ID)
#
# To remove a Chaos Drive from a character use this syntax:
#
# $game_actors[X].forget_cd(CD_ID)
#
# X is the ID of the character in the database and CD_ID is the ID of the Chaos
# Drive skill in the database. Also create a status effect and name it "Chaos".
# Add whatever animation you want.
#
#
# - Additional info:
# You can use animations and common event calls (i.e. for enhanced animations)
# for any CD skill. It is recommened that CD skills target the user. If you
# want Chaos Drives to have the same ammount of experience as their callers
#
#
# Important note:
#
# Chaos Drives are not normal skills and should be NOT used as such. Chaos
# Drive skills as normal skills will not make a transformation happen.
#
#
# If you find any bugs, please report them here:
# http://www.chaosproject.co.nr/
# or send me an e-mail:
# boris_blizzard@yahoo.de
#
#==============================================================================

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Chaos Drive Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

CHAOS_COLOR = Color.new(240, 0, 0, 255) # Color of the CD command (R, G, B, A)
CD_PERCENTAGE = 10 # how many maximum HP must a character have to unlock CD
EXP_NORMALIZE = false # EXP normalization

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Chaos Drive Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#==============================================================================
# Game_System
#==============================================================================

class Game_System

attr_accessor :chaos_party
attr_accessor :chaos_caller

alias init_cds_later initialize
def initialize
   init_cds_later
   @chaos_party = nil
   @chaos_caller = nil
end

end

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor < Game_Battler

attr_reader :cd_skills

alias setup_cds_later setup   
def setup(actor_id)
   setup_cds_later(actor_id)
   @cd_skills = []
end

def can_use_cd?
   return (not self.dead? and self.hp <= self.maxhp * CD_PERCENTAGE / 100)
end

def learn_cd(id)
   if id > 0 and not @cd_skills.include?(id)
     @cd_skills.push(id)
     @cd_skills.sort!
     return true
   end
   return false
end

def forget_cd(id)
   @cd_skills.delete(id)
   return
end

def use_chaos(id)
   chaos_id = database(id)
   return if chaos_id == 0
   $game_actors[chaos_id].exp = self.exp if EXP_NORMALIZE
   $game_actors[chaos_id].recover_all
   $game_system.chaos_party = $game_party.actors
   $game_party.actors = []
   $game_party.add_actor(chaos_id)
   $game_party.actors[0].add_state($cd_id)
end

def database(id)
   case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Chaos Drive Database
#
# Use following template to connect Chaos Drive skills and their Chaos Drives:
#
#    when X then return Y
#
# X is the skill ID and Y is the ID of the Chaos Drive character in your
# character database.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

   when 4 then return 3
   when 5 then return 6
     
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Chaos Drive Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   else
     return 0
   end
end

end

#==============================================================================
# Game_Party
#==============================================================================

class Game_Party

attr_accessor :actors

end

#==============================================================================
# Spriteset_Battle
#==============================================================================

class Spriteset_Battle

def update_actors(flag = false)
   Graphics.freeze
   for sprite in @actor_sprites
     sprite.dispose
   end
   @actor_sprites = []
   @actor_sprites.push(Sprite_Battler.new(@viewport2))
   @actor_sprites.push(Sprite_Battler.new(@viewport2))
   @actor_sprites.push(Sprite_Battler.new(@viewport2))
   @actor_sprites.push(Sprite_Battler.new(@viewport2))
   if flag
     Graphics.transition(0)
   else
     Graphics.transition(20)
   end
   update
end

end

#==============================================================================
# Window_ChaosDrive
#==============================================================================

class Window_ChaosDrive < Window_Selectable

def initialize(actor)
   super(0, 128, 640, 352)
   @actor = actor
   @column_max = 2
   refresh
   self.index = 0
   self.y = 64
   self.height = 256
   self.back_opacity = 160
end

def skill
   return @data[self.index]
end

def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   for i in 0...@actor.cd_skills.size
     skill = $data_skills[@actor.cd_skills[i]]
     @data.push(skill) if skill != nil
   end
   @item_max = @data.size
   if @item_max > 0
     self.contents = Bitmap.new(width - 32, row_max * 32)
     self.contents.font.name = $fontface
     self.contents.font.size = $fontsize
     for i in 0...@item_max
       draw_item(i)
     end
   end
end

def draw_item(index)
   skill = @data[index]
   self.contents.font.color = normal_color
   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)
end

def update_help
   @help_window.set_text(self.skill == nil ? "" : self.skill.description)
end

end

#==============================================================================
# Window_Command
#==============================================================================

class Window_Command < Window_Selectable

attr_accessor :commands
attr_accessor :actor

alias initialize_cds_later initialize
def initialize(width, commands)
   initialize_cds_later(width, commands)
   @CDcommand = "Chaos Drive"
end

def swap_commands
   temp = @commands[1]
   @commands[1] = @CDcommand
   @CDcommand = temp
   refresh
end

alias refresh_cds_later refresh
def refresh
   if $fontface != nil
     self.contents.font.name = $fontface
   elsif $defaultfonttype != nil
     self.contents.font.name = $defaultfonttype
   end
   self.contents.font.size = 24
   if @commands[1] == "Chaos Drive"
     for j in 0...6
       self.contents.clear
       if @actor.can_use_cd?
         self.contents.font.color = CHAOS_COLOR
       else
         self.contents.font.color = disabled_color
       end
       rect = Rect.new(164 - j * 32, 32, self.contents.width - 8, 32)
       if actor.state?($cd_id)
         self.contents.draw_text(rect, "Revert")
       else
         self.contents.draw_text(rect, @commands[1])
       end
       self.contents.font.color = normal_color
       for i in 0...@item_max
         draw_item(i, normal_color) unless @commands[i] == "Chaos Drive"
       end
       Graphics.update
     end
   else
     refresh_cds_later
     if $scene.is_a?(Scene_Battle)
       self.contents.font.size += 4
       self.contents.font.color = normal_color
       self.contents.draw_text(0, 31, width - 32, 32, "›› ", 2)
       self.contents.font.size -= 4
     end
   end
end

end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle

alias main_cds_later main
def main
   main_cds_later
   @chaos_window.dispose if @chaos_window != nil
end
   
alias phase3_setup_command_window_cds_later phase3_setup_command_window
def phase3_setup_command_window
   phase3_setup_command_window_cds_later
   @actor_command_window.actor = @active_battler
end

alias update_phase3_cds_later update_phase3
def update_phase3
   if @chaos_window != nil and @chaos_window.visible
     @chaos_window.update
     update_phase3_chaos_select
     return
   end
   update_phase3_cds_later
end

alias update_phase3_enemy_select_cds_later update_phase3_enemy_select
def update_phase3_enemy_select
   if Input.trigger?(Input::B)
     end_chaos_select_plus
   end
   update_phase3_enemy_select_cds_later
end

alias update_phase3_actor_select_cds_later update_phase3_actor_select
def update_phase3_actor_select
   if Input.trigger?(Input::B)
     end_chaos_select_plus
   end
   update_phase3_actor_select_cds_later
end

alias phase3_next_actor_cds_later phase3_next_actor
def phase3_next_actor
   end_chaos_select if @chaos_window != nil
   phase3_next_actor_cds_later
end

def update_phase3_chaos_select
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     end_chaos_select if @chaos_window.visible
     return
   end
   if Input.trigger?(Input::C)
     @skill = @chaos_window.skill
     if @skill == nil or not @active_battler.can_use_cd?
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     $game_system.se_play($data_system.decision_se)
     @active_battler.current_action.skill_id = @skill.id
     @chaos_window.visible = false
     if @skill.scope == 1
       start_enemy_select
     elsif @skill.scope == 3 or @skill.scope == 5
       start_actor_select
     else
       phase3_next_actor
     end
     return
   end
end

def start_chaos_select
   @chaos_window = Window_ChaosDrive.new(@active_battler)
   @chaos_window.help_window = @help_window
   @actor_command_window.active = false
   @actor_command_window.visible = false
end

def end_chaos_select
   end_chaos_select_plus
   @actor_command_window.swap_commands
   @chaos_window.dispose
   @chaos_window = nil
   @help_window.visible = false
end

def end_chaos_select_plus
   if @chaos_window != nil
     if @chaos_window.visible
       @actor_command_window.active = true
       @actor_command_window.visible = true
       @help_window.visible = false
     else
       @chaos_window.active = true
       @chaos_window.visible = true
     end
   end
end

alias update_phase4_step2_cds_later update_phase4_step2
def update_phase4_step2
   update_phase4_step2_cds_later
   make_chaos_action_result if @active_battler.current_action.kind == 8
end

def make_chaos_action_result
   @skill = $data_skills[@active_battler.current_action.skill_id]
   @help_window.set_text(@skill.name, 1)
   @animation1_id = @skill.animation1_id
   @animation2_id = @skill.animation2_id
   @common_event_id = @skill.common_event_id
   set_target_battlers(@skill.scope)
   for target in @target_battlers
     target.skill_effect(@active_battler, @skill)
   end
   $game_system.chaos_caller = @active_battler
   @status_window.refresh
end

alias update_phase3_basic_command_cds_later update_phase3_basic_command
def update_phase3_basic_command
   if @actor_command_window.index == 1 and Input.press?(Input::RIGHT)
     if @actor_command_window.commands[1] != "Chaos Drive"
       $game_system.se_play($data_system.decision_se)
       @actor_command_window.swap_commands
     end
     if not Input.trigger?(Input::UP) and not Input.trigger?(Input::DOWN)
       @actor_command_window.update
     end
   else
     if @actor_command_window.commands[1] == "Chaos Drive"
       @actor_command_window.swap_commands
     end
   end
   if @actor_command_window.commands[1] == "Chaos Drive" and
       Input.trigger?(Input::C)
     unless @actor_command_window.actor.state?($cd_id)
       if @actor_command_window.actor.can_use_cd?
         $game_system.se_play($data_system.decision_se)
         @active_battler.current_action.kind = 8
         start_chaos_select
       else
         $game_system.se_play($data_system.buzzer_se)
       end
     else
       $game_system.se_play($data_system.decision_se)
       phase3_next_actor
       judge(true)
     end
     return
   end
   update_phase3_basic_command_cds_later
end

alias judge_cds_later judge
def judge(flag = false)
   if $game_party.actors[0].state?($cd_id)
     if $game_party.actors[0].dead? or flag
       @spriteset.update_actors(true)
       $game_system.chaos_caller.hp = 0 unless flag
       $game_party.actors[0].recover_all
       $game_party.actors = $game_system.chaos_party
       $game_system.chaos_caller = nil
       $game_system.chaos_party = nil
       @status_window.refresh
       return false
     end
   end
   return judge_cds_later
end

alias update_phase4_step4_cds_later update_phase4_step4
def update_phase4_step4
   if $game_system.chaos_caller != nil and $game_system.chaos_party == nil
     for target in @target_battlers
       target.damage = "Chaos Drive!"
     end
   end
   update_phase4_step4_cds_later
end

alias update_phase4_step6_cds_later update_phase4_step6
def update_phase4_step6
   update_phase4_step6_cds_later
   if $game_system.chaos_caller != nil and $game_system.chaos_party == nil
     $game_system.chaos_caller.use_chaos($game_system.chaos_caller.current_action.skill_id)
     @spriteset.update_actors
     @status_window.refresh
   end
end

alias start_phase5_cds_later start_phase5
def start_phase5
   if $game_party.actors[0].state?($cd_id)
     @spriteset.update_actors(true)
     $game_party.actors[0].recover_all
     $game_party.actors = $game_system.chaos_party
     $game_system.chaos_caller = nil
     $game_system.chaos_party = nil
     @status_window.refresh
     $game_player.refresh
   end
   start_phase5_cds_later
end

alias battle_end_cds_later battle_end
def battle_end(result)
   if $game_party.actors[0].state?($cd_id)
     @spriteset.update_actors(true)
     $game_party.actors[0].recover_all
     $game_party.actors = $game_system.chaos_party
     $game_system.chaos_caller = nil
     $game_system.chaos_party = nil
     @status_window.refresh
     $game_player.refresh
   end
   $game_player.refresh
   battle_end_cds_later(result)
end

end

#==============================================================================
# Scene_Title
#==============================================================================

class Scene_Title

alias main_cds_later main
def main
   main_cds_later
   return if $scene == nil
   for state in $data_states
     if state != nil and state.name == "Chaos"
       $cd_id = state.id
       break
     end
   end
end

end