Chaos Rage Limit System

21 de junho de 2012

O Chaos Rage Limit System é um Actor Transformation System e Enhanced Limit Break System que combina o Chaos Drive System (CDS), Soul Rage System (SRS) e Soul Limit System (SLS), permitindo usar todos estes sistemas (ou add-ons) simultâneamente, em um projeto do RPG Maker XP.

Este script permite que o equipamento do jogador tenha habilidades embutidas. Se os inimigos atacam, um personagem, um valor (Soul Rage ou SR) vai aumentar. Com uma quantidade de SR determinada, é possível executar habilidades especiais que estão implementadas no equipamento. O Soul Rage é semelhante as “habilidades Ikari” de “Lufia 2 – Rise of the Sinistrals” para o SNES. Entretanto, este script fornece a possibilidade de usar mais habilidades com uma parte do equipamento e permite usar o valor de SR para mais do que apenas Soul Rage (como no Soul Limit ou Chaos Drive).

Nós temos aqui o código do CRLS 5.5b em texto. A versão que está na demo (para download) é a 5.4b. O Chaos Rage Limit System (CRLS) foi feito por Blizzard (não é a Blizzard do StarCraft).

Código Do Chaos Rage Limit System 5.5b

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Chaos Rage Limit System (Chaos Drive, Soul Rage, Soul Limit) by Blizzard
# Version: 5.5b
# Type: Actor Transformation System, Enhanced Limit Break System
# CRLS Date 5.0: 7.7.2007
# CRLS Date 5.0b: 12.7.2007
# CRLS Date 5.3b: 24.9.2007
# CRLS Date 5.31b: 25.10.2007
# CRLS Date 5.32b: 10.12.2007
# CRLS Date 5.4b: 6.1.2008
# CRLS Date 5.5b: 22.1.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# SRS Date v1.0: 13.04.2006
# SRS Date v2.2b: 08.09.2006
# CDS Date v1.0: 10.10.2006
# CDS Date v1.3b: 3.11.2006
# SRS/SLS Date v4.2: 3.11.2006
# CDS Date v1.31b: 23.2.2007
# SRS/SLS Date v4.4b: 23.2.2007
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 
#   THIS SCRIPT MAY NOT BE USED BY PEOPLE WHO ARE MAINLY ACTIVE ON RMXP.ORG!!!
# 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 
# IMPORTANT NOTE:
# 
#   This script allows the use of the "Soul Rage System" (SRS), the "Soul Limit
#   System" (SLS) and the "Chaos Drive System" (CDS) at the same time. Special
#   Thanks to GuardianAngelX72 for the idea for Chaos Drive.
# 
# 
# Compatibility:
# 
#   98% compatible with SDK 1.x. 40% compatible with SDK 2.x. WILL corrupt your
#   old savegames. Can cause incompatibilty issues with following scripts
#   and/or systems:
#   - exotic CBS-es
#   - Limit Break systems
#   - Custom Equipment systems (i.e. 2 accessories) (can be EASILY merged)
#   - needs the 5.x version of the Scene_SoulRage add-on if you use one
# 
# 
# Features:
# 
#   - Chaos Drive, Soul Rage and Soul Limit Systems in one script
#   - configure your databases easily
#   - using Blizzard gradient styler 4.x with 7 different styles
#   - contains universal font fix, never ever "I can't see the letters"
#   - completely overworked all three systems
#   - compatible with Tons of Add-ons
#   - maximum compatibility with other scripts
#   - moving Chaos Drive/Soul Rage/Soul Limit command in defineable color and a
#     faster animated cursor
# 
# SRS specific features:
#   - use multiple skills per equipment part
#   - SR % increase when you get attacked, use it to unleash SR skills
#   - cycle through available skills with LEFT/RIGHT
# SLS specific features:
#   - configure Soul Limit for each character separately
#   - using a limit can kill a character if you set it up that way
#   - use a different command than the actual SL skill name
#     (example: command name is "Bahamut", skill name is "Giga Flare")
# CDS specific features:
#   - replaces entire party with one Chaos Drive OR transforms only the actor
#     who is using the CD skill
#   - revert Chaos Drive anytime
#   - configurable conditions like in Soul Limit
# 
# new in v5.3b:
#   - compatible with Multi-Hit from Tons of Add-ons v5.x and higher
#   - rewritten conditions using classic syntax to avoid RGSS conditioning bug
#   - added possiblities that status effect, armors and weapons can increase
#     the SRS_rate for a character
#   - fixed a couple of bugs and glitches
#   - removed the barstyle plugin, please get the newest version of Tons of
#     Add-ons if you want to keep using the bars
#   - Chaos Drive Status Effect can now be named however you like, but you need
#     to configure
#   - improved coding
# 
# new in v5.31b:
#   - fixed a slight bug that would never occur anyway
#   - now the global variable for compatibility contains the version of CRLS
# 
# new in v5.32b:
#   - improved performance
# 
# new in v5.4b:
#   - now it is possible to define actors who can use SRS/SLS/CDS and who can't
#   - other bugs were not fixed, I was too drunk to fix them at the time being
# 
# new in v5.5b:
#   - fixed the bugs that were not fixed in the last version
# 
# 
# General configuration:
# 
#   DRAW_SR     - set this value to false if you don't want SR% display at all
#   SR_NAME     - this is the name of the SR % if you have SRS turned off
#   DRAW_BAR    - set this value to false if you don't want an SR bar at all
#                 (does not work if you don't have a script for HP/SP/EXP bars)
#   BAR_STYLE   - set it from 0 to 6 to use one out of seven bar styles
#   BAR_OPACITY - set it from 0 to 255 to define the bar's opacity
#   SR_ENABLED  - add any actor ID of actors who actually have the SR attribute
#                 drawn in battle
# 
# 
# Instructions:
# 
#                           ...::: Soul Rage :::...
# 
# Explanation:
# 
#   This script allows the player equipment to have built-in skills. If enemies
#   attack a character a value (the Soul Rage or SR) will increase. With a
#   certain ammount of SR it is possible to perform special skills that are
#   implemented into equipment. Soul Rage is similar to "Ikari skills" from
#   "Lufia 2 - Rise of the Sinistrals" for the SNES. Although, this script
#   provides the possiblity of using more skills with one equipment part and
#   allows using the SR value for more than just Soul Rage (like for Soul Limit
#   or Chaos Drive).
# 
# 
# Configuration:
# 
#   Press CRTL+SHIFT+F and type into the window:
#   Soul Rage Database
#   You can jump now to the database directly. There are more instructions.
#   Also please configure the following global variable found below:
# 
#   SRS_ACTIVE - set this value to false to disable Rage (if you do so you
#                don't need to configure ANYTHING connected to Soul Rage)
#                (Side-Note: It's pointless to disable both)
#   SRS_rate   - set the filling rate of the SR, 1000 is standard, 500 is 2
#                times slower and 2000 would be 2 times faster
#   RAGE_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
#   SR_USERS   - add any actor ID of actors who can use SRS
# 
# 
# Additional info:
# 
#   If you want to change the value of the SR bar ingame use the "Call script"
#   event command and use this syntax:
# 
#   $game_actors[X].sr = Y
# 
#   X - ID of the hero in the database
#   Y - new value of the SR
# 
#   You can also use another syntax:
# 
#   $game_party.actors[X].sr = Y
# 
#   X - position of the hero in the party
#   Y - new value of the SR
# 
#   Note that X starts from 0 and NOT 1. The ammount is shown as 100,0%, this
#   is 1000 SR. i.e. 59,1% would be 591 SR.
# 
#   Also if you want to use my gradient script, please refer to the Code in
#   Tons of Add-ons version 4.91b or higher.
# 
# 
# Note:
# 
#   Using Soul Rage skills as normal skills is not recommended, because of the
#   SP/SR cost. It is better you create a different skill if you want to use it
#   as Soul Rage. But then again, you don't have to... In the other hand Soul
#   Limit skills can be used as normal skills without any problems.
# 
# 
#                           ...::: Soul Limit :::...
# 
# Explanation:
# 
#   Soul Limit is a special attack an actor can use if he has either low HP,
#   high SR, etc. It is an enhanced version of Limit Break / Overdrive, but
#   connected to the Soul Rage. 
# 
# 
# Configuration:
# 
#   SLS_ACTIVE -  set this value to false to disable Limit (if you do so you
#                 don't need to configure ANYTHING connected to Soul Limit)
#   LIMIT_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
#   SL_USERS    - add any actor ID of actors who can use SLS
# 
#   Press CRTL+SHIFT+F and type into the window:
#   Soul Limit / Chaos Drive Database
# 
# 
# Additional info:
# 
#   Soul Limit is more superior than Limit Break as you can involve HP, SR and
#   even SP conditions as well as consuming. You can create a game where a
#   character can use his Limit skill as long as his HP are under 20% without
#   consuming any stats. (i.e. Final Fantasy VIII) or create a game where the
#   using of a Limit skill requires suicide just by setting the character's
#   @hp_consume value to 100.
#   If you want to change the Soul Limit skill ID and/or command ingame use the
#   "Call script" event command and use this syntax:
# 
#   $game_actors[X].set_new_limit("STRING", ID)
# 
#   X      - ID of the hero in the database and Y the ammount
#   STRING - the new name for the SL command
#   ID     - ID of the new SL skill in the database
# 
#   You can also use another syntax:
# 
#   $game_party.actors[Y].set_new_limit("STRING", ID)
# 
#   Y - postion of the hero in the party, starts from 0 (NOT 1!)
#   STRING - the new name for the SL command
#   ID     - ID of the new SL skill in the database
# 
# 
#                          ...::: Chaos Drive :::...
# 
# Explanation:
# 
#   This script will allow the player to use Chaos Drive when in critical
#   HP/SP/SR 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:
# 
#   CDS_ACTIVE    - set this value to false to disable CD (if you do so you
#                   don't need to configure ANYTHING connected to Chaos Drive)
#   CD_ID         - set this value to the state ID of Chaos Drive
#   EXP_NORMALIZE - set to true if the EXP/LVL of your Chaos Drives should be
#                   set to the same as their caller (a stronger caller would
#                   call a stronger version of the same Chaos Drive then)
#   REMOVE_PARTY  - set to true if you want the party to disappear when a CD is
#                   called, set to false if you only want replace the caller
#   MAX_PARTY     - set to the value of the maximum size of your party
#   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
#   CONNECTED     - if you set this value to false, when a Chaos Drive dies,
#                   the caster will still be alive
#   STAY_DAMAGE   - if you set this value to true, Chaos Drives will not be
#                   healed when they are reverted, they will stay dead when
#                   they get killed and calling them will be impossible until
#                   they are revived (can be used for summoning systems)
#   CD_USERS      - add any actor ID of actors who can use CDS
# 
#   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 set
#   CD_ID to its ID in the database. Make the skill target the user or you will
#   get a bug. 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 recommended that CD skills target the
#   user.
# 
# 
# 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. Do not
#   assign two different characters the same Chaos Drive character. If you want
#   them to access the same character, make a duplicate CD character in your
#   database.
# 
# 
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

DRAW_SR = true
SR_NAME = 'SR'
DRAW_BAR = true
BAR_STYLE = 3
BAR_OPACITY = 224
SR_ENABLED = [1, 2, 3, 4, 5, 6, 7, 8]

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Soul Rage Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

SRS_ACTIVE = true
SRS_rate = 1000
RAGE_COLOR = Color.new(255, 0, 0)
SR_USERS = [1, 2, 3, 4, 5, 6, 7, 8]

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Soul Rage Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Soul Limit Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

SLS_ACTIVE = true
LIMIT_COLOR = Color.new(0, 255, 0)
SL_USERS = [1, 2, 3, 4, 5, 6, 7, 8]

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Soul Limit Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

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

CDS_ACTIVE = true
CD_ID = 17
EXP_NORMALIZE = false
REMOVE_PARTY = true
MAX_PARTY = 4
CHAOS_COLOR = Color.new(128, 64, 255)
CONNECTED = true
STAY_DAMAGE = true
CD_USERS = [1, 2, 3, 4, 5, 6, 7, 8]

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

$crls = 5.5

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

class Game_System
  
  attr_accessor :chaos_party
  attr_accessor :bar_style
  attr_reader   :bar_opacity
  
  alias init_crls_later initialize
  def initialize
    init_crls_later
    @chaos_party = []
    MAX_PARTY.times {@chaos_party.push(0)} unless REMOVE_PARTY
  end
  
  def sr_database(equip_id, weapon = false)
    skill_ids = []
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Soul Rage Database
#
# This is your equipment Soul Rage database. To add a new Soul Rage skill to a
# weapon is very simple. Add another "when"-branch in the script snipplet below
# (they have comments next to it). Configure it like this template:
# 
# when WEAPON_ID
#   skill_ids.push(SOULRAGE_SKILL_ID)
#   skill_ids.push(SOULRAGE_SKILL_ID)
# 
# The same works for armors:
# 
# when ARMOR_ID
#   skill_ids.push(SOULRAGE_SKILL_ID)
#   skill_ids.push(SOULRAGE_SKILL_ID)
# 
# The lines are commented below so you should have no problems with the script.
# 
# To determine the percentage of Soul Rage consumed to use a skill, set the SP
# to the percentage. e.g. 33SP would mean 33% of the Soul Rage bar.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    if weapon
      case equip_id # weapon IDs
      when 6
        skill_ids.push(10)
        skill_ids.push(11)
        skill_ids.push(12)
      when 10
        skill_ids.push(8)
      end
    else
      case equip_id # armor IDs
      when 5
        skill_ids.push(1)
      when 17
        skill_ids.push(25)
      end
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Soul Rage Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return (skill_ids.size > 0 ? skill_ids : [0])
  end
  
  def sre_database(equip_id, weapon = false)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Soul Rage Equipment Database
#
# This is your Soul Rage Equipment database. Adding equipment IDs here will
# cause them to increase or decrease the SRS_rate if they are equipped. All
# values are in %, that means a value of i.e. 20 will cause 20 more SR, two
# values of 20 will cause 40, etc. Negative values will decrease the rate.
# Configure it like this template:
# 
# when WEAPON_ID then return RATE
# 
# The same works for armors:
# 
# when ARMOR_ID then return RATE
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    if weapon
      case equip_id # weapon IDs
      when 2 then return 5
      when 15 then return 5
      end
    else
      case equip_id # armor IDs
      when 3 then return 20
      when 13 then return 10
      end
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Soul Rage Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return 0
  end
  
  def srs_database(state_id)
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Soul Rage State Database
#
# This is your Soul Rage State database. Adding status effect IDs here will
# cause them to increase or decrease the SRS_rate when they are inflicted. All
# values are in %, that means a value of i.e. 20 will cause 20 more SR, two
# values of 20 will cause 40, etc. Negative values will decrease the rate.
# Configure it like this template:
# 
# when STATE_ID then return RATE
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    case state_id
    when 17 then return 10
    end
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Soul Rage Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    return 0
  end
  
  def cd_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 4
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Chaos Drive Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    end
    return 0
  end
  
  def sl_database(id)
    case id
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Soul Limit / Chaos Drive Database
# 
# This is your Soul Limit/Chaos Drive Database. Below you can configure the
# Special attack and the command name of the Soul Limit. You can also configure
# the conditions that need to be met to allow the usage of Soul Limit and Chaos
# Drive. Use following syntax to setup the Soul Limit for each character:
# 
#  when ACTOR_ID
#    limit_name = "STRING"
#    limit_id = SKILL_ID
#    slsr_rate = VAL1
#    slhp_rate = VAL2
#    slsp_rate = VAL3
#    slsr_consume = VAL4
#    slhp_consume = VAL5
#    slsp_consume = VAL6
#    cdsr_rate = VAL7
#    cdhp_rate = VAL8
#    cdsp_rate = VAL9
#    cdsr_consume = VALa
#    cdhp_consume = VALb
#    cdsp_consume = VALc
#    allow_suicide = EXPR
#
# ACTOR_ID - the ID of the character in the normal database
# STRING   - the name the limit command should have
# SKILL_ID - the ID of the Soul Limit skill in the normal database
# VAL1     - minimum SR (in %) needed to make the Soul Limit skill available
# VAL2     - maximum HP (in %) needed to make the Soul Limit skill available
# VAL3     - maximum SP (in %) needed to make the Soul Limit skill available
# VAL4     - SR (in %) cunsumed if Soul Limit is used
# VAL5     - HP (in %) cunsumed if Soul Limit is used
# VAL6     - SP (in %) cunsumed if Soul Limit is used
# VAL7     - minimum SR (in %) needed to make the Chaos Drive skills available
# VAL8     - maximum HP (in %) needed to make the Chaos Drive skills available
# VAL9     - maximum SP (in %) needed to make the Chaos Drive skills available
# VALa     - SR (in %) cunsumed if Chaos Drive is used
# VALb     - HP (in %) cunsumed if Chaos Drive is used
# VALc     - SP (in %) cunsumed if Chaos Drive is used
# EXPR     - true or false
# 
# Example:
# 
#  when 2
#    limit_name = "Saturn Cannon"
#    limit_id = 101
#    slsr_rate = 80
#    slhp_rate = 50
#    slsp_rate = 100
#    slsr_consume = -10
#    slhp_consume = 10
#    slsp_consume = 50
#    cdsr_rate = 0
#    cdhp_rate = 10
#    cdsp_rate = 10
#    cdsr_consume = 0
#    cdhp_consume = 0
#    cdsp_consume = 10
#    allow_suicide = false
# 
# (let's say skill number 101 is called "Last Judgement")
# 
# Character number 2 needs minimum 80% SR, his HP must be less than or equal to
# 50% and his SP must be less than or equal to 100% (in other words, SP don't
# affect the availability of the SL skill of character number 2). If he uses
# the Soul Limit command displayed as "Saturn Cannon", he will use the skill
# "Last Judgement" (ID number 101). He will gain 10% of his maximum SR, lose
# 10% of his maximum HP and lose 50% of his maximum SP. If his HP are less than
# or equal to 10% he will not die, but his HP will only decrease to 1.
# Chaos drive can be used if the HP and SP are 10% or lower. If used, 10% SP of
# the using actor will be consumed. If you are not using either SL or CD, you
# can just skip configuring those numbers.
# 
# Side-notes:
# The VAL values can be from 0 to 100 (since it is in %). Every value over 100
# is automatically limited to 100. Negative values will cause stat gaining
# instead of losing. (You can create skills, that heal the user AND attack the
# enemies without a common event call). If you set the values VAL1, VAL2 and/or
# VAL3 to a negative number, this character will have no Soul Limit.
# 
# Notes:
# - you have the possibility to i.e. set a command to "Bahamut", but the actual
#   skill name that will be displayed during its animation will be "Giga Flare"
# - to change a Soul Limit skill during the game read the instructions at the
#   beginning of the script
# - do not set it up that way that the user dies from using a Chaos Drive. It
#   might bug your game. Best is to let using a CD skill not consume any HP.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    when 1
      limit_name = "Devastator"
      limit_id = 81
      slsr_rate = 20
      slhp_rate = 50
      slsp_rate = 100
      slsr_consume = 20
      slhp_consume = 0
      slsp_consume = 0
      cdsr_rate = 0
      cdhp_rate = 100
      cdsp_rate = 100
      cdsr_consume = 0
      cdhp_consume = 0
      cdsp_consume = 0
      allow_suicide = false
    when 2
      limit_name = "Summon Proximus"
      limit_id = 82
      slsr_rate = 100
      slhp_rate = 100
      slsp_rate = 100
      slsr_consume = 20
      slhp_consume = 0
      slsp_consume = 0
      cdsr_rate = 20
      cdhp_rate = 100
      cdsp_rate = 100
      cdsr_consume = 100
      cdhp_consume = 0
      cdsp_consume = 0
      allow_suicide = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Soul Limit / Chaos Drive Database
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    else
      limit_name, allow_suicide = '', true
      slsr_rate = slhp_rate = slsp_rate = cdsr_rate = cdhp_rate = cdsp_rate = -1
      limit_id = slsr_consume = slhp_consume = slsp_consume = cdsr_consume =
      cdhp_consume = cdsp_consume = 0
    end
    return [limit_name, limit_id, slsr_rate, slhp_rate, slsp_rate,
            slsr_consume, slhp_consume, slsp_consume, cdsr_rate, cdhp_rate,
            cdsp_rate, cdsr_consume, cdhp_consume, cdsp_consume, allow_suicide]
  end

  def find_chaos(id)
    (1...$data_actors.size).each {|i|
        if $game_actors[i] != nil
          return $game_actors[i] if $game_actors[i].chaos_id == id
        end}
  end
  
  def bar_opacity=(alpha)
    @bar_opacity = [[255, alpha].min, 0].max
  end
  
end

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

class Game_Actor < Game_Battler

  attr_accessor :chaos_id
  attr_accessor :chaos_action
  attr_reader   :cd_skills
  attr_reader   :sr
  attr_reader   :limit_name
  attr_reader   :limit_id
  
  alias setup_crls_later setup
  def setup(actor_id)
    setup_crls_later(actor_id)
    @cd_skills, @sr, @chaos_id, @chaos_action = [], 0, 0, 0
    @limit_name, @limit_id, @slsr_rate, @slhp_rate, @slsp_rate, @slsr_consume,
    @slhp_consume, @slsp_consume, @cdsr_rate, @cdhp_rate, @cdsp_rate,
    @cdsr_consume, @cdhp_consume, @cdsp_consume, @allow_suicide = 
    $game_system.sl_database(actor_id)
  end
  
  def sr=(sr)
    @sr = [[sr, 0].max, 1000].min
  end
  
  def set_new_limit(name, id)
    @limit_name, @limit_id = name, id
  end
  
  def learn_cd(id)
    if id > 0 && !@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 = $game_system.cd_database(id)
    return if @chaos_id == 0
    $game_actors[@chaos_id].exp = self.exp if EXP_NORMALIZE
    $game_actors[@chaos_id].recover_all unless STAY_DAMAGE
    if REMOVE_PARTY
      $game_party.actors.each {|actor| actor.chaos_action = -1}
      $game_system.chaos_party = $game_party.actors
      $game_party.actors = []
      $game_party.add_actor(@chaos_id)
      $game_party.actors[0].add_state(CD_ID)
    else
      @chaos_action = -1
      $game_system.chaos_party[self.index] = @id
      $game_party.actors[self.index] = $game_actors[@chaos_id]
      $game_actors[@chaos_id].add_state(CD_ID)
    end
    self.sr -= @cdsr_consume * 10
    self.hp -= @cdhp_consume * self.maxhp / 100
    self.sp -= @cdsp_consume * self.maxsp / 100
  end
  
  def revert_chaos
    if REMOVE_PARTY
      $game_party.actors = $game_system.chaos_party
      $game_party.actors.each {|actor| actor.chaos_action = -1}
      $game_system.chaos_party = []
      $game_system.find_chaos(id).hp = 0 if CONNECTED && self.dead?
    else
      @chaos_action = -1
      $game_system.chaos_party[self.index] = 0
      origin_actor = $game_system.find_chaos(id)
      $game_party.actors[self.index] = origin_actor
      origin_actor.hp = 0 if CONNECTED && self.dead?
    end
  end

  def can_use_sr?(id)
    return ($data_skills[id].sp_cost <= self.sr / 10)
  end

  def can_use_sl?
    return (SLS_ACTIVE && self.sr / 10 >= @slsr_rate &&
        100 * self.hp / self.maxhp <= @slhp_rate &&
        100 * self.sp / self.maxsp <= @slsp_rate)
  end
  
  def can_use_cd?
    return (CDS_ACTIVE && !self.dead? && self.sr / 10 >= @cdsr_rate &&
        100 * self.hp / self.maxhp <= @cdhp_rate &&
        100 * self.sp / self.maxsp <= @cdsp_rate)
  end
  
  alias skill_can_use_crls_later? skill_can_use?
  def skill_can_use?(id)
    if @cd_skills.include?(id)
      return true unless STAY_DAMAGE
      id = $game_system.cd_database(id)
      return (id != 0 && !$game_actors[id].dead?)
    end
    return skill_can_use_crls_later?(id)
  end
  
  def use_limit
    self.sr -= @slsr_consume * 10
    self.hp -= @slhp_consume * self.maxhp / 100
    self.sp -= @slsp_consume * self.maxsp / 100
    self.hp = 1 if self.hp == 0 && !@allow_suicide
  end
  
end
 
#==============================================================================
# Game_Battler
#==============================================================================

class Game_Battler
    
  alias hp_is_equal_to_crls_later hp=
  def hp=(val)
    last_hp = self.hp
    hp_is_equal_to_crls_later(val)
    if self.is_a?(Game_Actor)
      if self.dead?
        self.sr = 0
      elsif self.hp < last_hp
        exrate = 100
        exrate += $game_system.sre_database(@weapon_id, true)
        [@armor1_id, @armor2_id, @armor3_id, @armor4_id].each {|i|
            exrate += $game_system.sre_database(i, false)}
        @states.each {|i| exrate += $game_system.srs_database(i)}
        self.sr += (last_hp - self.hp) * SRS_rate * exrate / last_hp / 100
      end
    end
  end

end

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

class Game_Party

  attr_accessor :actors
  
end

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

class Spriteset_Battle

  def update_actors(flag = false)
    Graphics.freeze
    @actor_sprites.each_index {|i|
        @actor_sprites[i].battler = $game_party.actors[i]
        if @actor_sprites[i].battler != nil &&
            @actor_sprites[i].battler.chaos_action == -1
          actor = @actor_sprites[i].battler
          @actor_sprites[i].dispose
          @actor_sprites[i] = Sprite_Battler.new(@viewport2)
          @actor_sprites[i].update
          @actor_sprites[i].battler, actor.chaos_action = actor, 0
        end}
    Graphics.transition((flag ? 0 : 20))
    Graphics.freeze
    update
    Graphics.transition((flag ? 0 : 20))
  end
  
end

#==============================================================================
# Window_Base
#==============================================================================

class Window_Base < Window
  
  def draw_actor_sr(actor, x, y, w = 144)
    w = 120 unless $scene.is_a?(Scene_Menu)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y-16, width, 64, (SRS_ACTIVE ? 'SR' : SR_NAME))
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, w, 32, "#{actor.sr/10},#{actor.sr%10}%", 2)
  end
 
  def draw_actor_sr_with_bar(actor, x, y, w = 148)
    w -= 12
    rate = actor.sr.to_f / 1000
    color1 = Color.new(80, 0, 0, 192) 
    color2 = Color.new(240, 0, 0, 192) 
    color3 = Color.new(80, 0, 0, 192) 
    self.contents.gradient_bar(x, y, w, color1, color2, color3, rate)
    if $scene.is_a?(Scene_Battle)
      draw_actor_sr(actor, x, y, w)
    else
      draw_actor_sr(actor, x, y)
    end
  end

  def draw_item_name2(item, x, y, color)
    return if item == nil
    opacity = self.contents.font.color == normal_color ? 255 : 128
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.color = color
    self.contents.draw_text(x + 28, y, 288, 32, item.name)
  end
  
end

#==============================================================================
# Window_BattleStatus
#==============================================================================

class Window_BattleStatus < Window_Base
  
  alias refresh_crls_later refresh
  def refresh
    return refresh_crls_later unless DRAW_SR
    self.contents.clear
    if $fontface != nil
      self.contents.font.name = $fontface
    elsif $defaultfonttype != nil
      self.contents.font.name = $defaultfonttype
    end
    self.contents.font.size = 24
    $game_party.actors.each_index {|i|
        if $tons_version != nil && $tons_version >= 4.82 &&
            $game_system.CENTER_BATTLER
          actor_x = case $game_party.actors.size
          when 1 then 4 + 240
          when 2 then 4 + 80 + i * 320
          when 3 then 4 + 80 + i * 160
          when 4 then 4 + i * 160
          end
        else
          actor_x = i * 160 + 4
        end
        draw_actor_name($game_party.actors[i], actor_x, -8)
        draw_actor_hp($game_party.actors[i], actor_x, 14, 120)
        draw_actor_sp($game_party.actors[i], actor_x, 44, 120)
        if SR_ENABLED.include?($game_party.actors[i].id)
          if DRAW_BAR && $tons_version != nil && $tons_version >= 4.82
            draw_actor_sr_with_bar($game_party.actors[i], actor_x, 74, 120)
          else
            draw_actor_sr($game_party.actors[i], actor_x, 74, 120)
          end
        end
        if @level_up_flags[i]
          self.contents.font.color = normal_color
          self.contents.draw_text(actor_x, 100, 120, 32, 'LEVEL UP!')
        else
          draw_actor_state($game_party.actors[i], actor_x, 100)
        end}
  end
  
end

#==============================================================================
# Window_SoulRage
#==============================================================================

class Window_SoulRage < Window_Selectable

  attr_accessor :index
  
  def initialize(actor)
    super(0, 128, 640, 384)
    self.contents = Bitmap.new(width - 42, 5 * 42)
    if $fontface != nil
      self.contents.font.name = $fontface
    elsif $defaultfonttype != nil
      self.contents.font.name = $defaultfonttype
    end
    self.contents.font.size = 24
    @skill_ids, @alt_index = [[0], [0], [0], [0], [0]], [0, 0, 0, 0, 0]
    @column_max, @item_max, @actor, @index = 1, 5, actor, 0
    refresh
    self.y, self.height, self.back_opacity = 64, 256, 160 if $game_temp.in_battle
  end
  
  def update_actor(actor)
    @actor = actor
    refresh  
  end
  
  def refresh
    self.contents.clear
    (0...5).each {|i| draw_item(i)} if @actor != nil
  end
  
  def draw_item(i)
    equip = case i
    when 0 then $data_weapons[@actor.weapon_id]
    when 1 then $data_armors[@actor.armor1_id]
    when 2 then $data_armors[@actor.armor2_id]
    when 3 then $data_armors[@actor.armor3_id]
    when 4 then $data_armors[@actor.armor4_id]
    end
    @skill_ids[i] = $game_system.sr_database(equip == nil ? 0 : equip.id, (i == 0))
    id = @skill_ids[i][@alt_index[i]]
    if id != 0
      skill = $data_skills[id]
      if @actor.can_use_sr?(skill.id)
        self.contents.font.color = normal_color
      else
        self.contents.font.color = disabled_color
      end
      rect = Rect.new(0, i*42, self.width / @column_max - 42, 42)
      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(300, 8+i*42, bitmap, Rect.new(0, 0, 24, 24), opacity)
      self.contents.draw_text(328, i*42, 204, 42, skill.name, 0)
      unless skill.sp_cost == 0
        self.contents.draw_text(516, i*42, 64, 42, "#{skill.sp_cost}%", 2)
      end
      if @skill_ids[i].size > 1
        self.contents.draw_text(284, i*42, 32, 42, '«')
        self.contents.draw_text(564, i*42, 32, 42, '»', 2)
      end
    else
      self.contents.font.color = disabled_color
      self.contents.draw_text(328, i*42, 204, 42, 'not available', 0)
    end
    if id == 0
      color = disabled_color
    elsif @actor.can_use_sr?(id)
      color = normal_color
    else
      color = disabled_color
    end
    if @actor.equippable?(equip)
      draw_item_name2(equip, 4, 4+i*42, color)
    else
      self.contents.font.color = disabled_color
      self.contents.draw_text(4, i*42, 288, 42, 'Nothing equipped')
    end
  end
  
  alias upd_crls_later update
  def update
    upd_crls_later
    size = @skill_ids[@index].size
    if Input.trigger?(Input::RIGHT)
      old_index = @alt_index[@index]
      @alt_index[@index] = (@alt_index[@index] + 1) % size
      if old_index != @alt_index[@index]
        $game_system.se_play($data_system.cursor_se)
        refresh
      end
    elsif Input.trigger?(Input::LEFT)
      old_index = @alt_index[@index]
      @alt_index[@index] = (@alt_index[@index] + size - 1) % size
      if old_index != @alt_index[@index]
        $game_system.se_play($data_system.cursor_se)
        refresh
      end
    end
  end
  
  def top_row
    return self.oy / 42
  end
  
  def top_row=(row)
    self.oy = [[row, 0].max, row_max - 1].min * 42
  end
  
  def page_row_max
    return (self.height - 42) / 42
  end
  
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    self.top_row = row if row < top_row
    self.top_row = row - (page_row_max - 1) if row > top_row + (page_row_max - 1)
    cursor_width = self.width / @column_max - 32
    x = @index % @column_max * (cursor_width + 42)
    y = @index / @column_max * 42 - self.oy
    self.cursor_rect.set(x, y, cursor_width, 42)
  end
  
  def update_help
    @help_window.set_text(self.skill == nil ? '' : self.skill.description)
  end
  
  def skill
    id = @skill_ids[@index][@alt_index[@index]]
    return $data_skills[id] if id != 0
  end
  
end

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

class Window_ChaosDrive < Window_Skill
  
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    @actor.cd_skills.each {|i| @data.push($data_skills[i]) if $data_skills[i] != nil}
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      if $fontface != nil
        self.contents.font.name = $fontface
      elsif $defaultfonttype != nil
        self.contents.font.name = $defaultfonttype
      end
      self.contents.font.size = 24
      (0...@item_max).each {|i| draw_item(i)}
    end
  end
  
  alias draw_item_crls_later draw_item
  def draw_item(i)
    draw_item_crls_later(i)
    self.contents.fill_rect(236+i%2*320, i/2*32, 48, 32, Color.new(0, 0, 0, 0))
  end
  
end

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

class Window_Command < Window_Selectable
  
  attr_accessor :commands
  attr_reader   :actor
  
  alias initialize_crls_later initialize
  def initialize(width, commands)
    initialize_crls_later(width, commands)
    @commands2 = [@commands[0], 'Soul Rage', 'Chaos Drive']
  end
  
  def set_player_command(new_actor)
    if @actor != nil && @commands[0] == @actor.limit_name
      @commands[0] = @commands2[0]
    end
    @commands2[0] = new_actor.limit_name
    @actor = new_actor
    refresh
  end
  
  def swap_commands(index)
    if index == 0
      if @commands[0] == @actor.limit_name
        @commands[0] = @commands2[0]
      else
        @commands2[0], @commands[0] = @commands[0], @actor.limit_name
      end
    else
      @commands[index], @commands2[index] = @commands2[index], @commands[index]
    end
    refresh
  end
  
  alias refresh_crls_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 @actor != nil && SLS_ACTIVE && SL_USERS.include?(@actor.id) &&
        @commands[0] == @actor.limit_name
      (0...6).each {|j|
          self.contents.clear
          self.contents.font.color = LIMIT_COLOR
          rect = Rect.new(164 - j * 32, 0, self.contents.width - 8, 32)
          self.contents.draw_text(rect, @commands[0])
          (0...@item_max).each {|i|
              draw_item(i, normal_color) unless @commands[i] == @actor.limit_name}
          if $scene.is_a?(Scene_Battle)
            self.contents.font.color = normal_color
            self.contents.font.size += 4
            if SRS_ACTIVE && SR_USERS.include?(@actor.id)
              self.contents.draw_text(0, 31, width - 32, 32, '›› ', 2)
            end
            if CDS_ACTIVE && CD_USERS.include?(@actor.id)
              self.contents.draw_text(0, 63, width - 32, 32, '›› ', 2)
            end
            self.contents.font.size -= 4
          end
          Graphics.update}
    elsif SRS_ACTIVE && @commands[1] == 'Soul Rage' &&
        SR_USERS.include?(@actor.id)
      (0...6).each {|j|
          self.contents.clear
          self.contents.font.color = RAGE_COLOR
          rect = Rect.new(164 - j * 32, 32, self.contents.width - 8, 32)
          self.contents.draw_text(rect, @commands[1])
          self.contents.font.color = normal_color
          (0...@item_max).each {|i|
              draw_item(i, normal_color) unless @commands[i] == 'Soul Rage'}
          if $scene.is_a?(Scene_Battle)
            self.contents.font.color = normal_color
            self.contents.font.size += 4
            if SLS_ACTIVE && @actor != nil && SL_USERS.include?(@actor.id) &&
                @actor.can_use_sl?
              self.contents.draw_text(0, -1, width - 32, 32, '›› ', 2)
            end
            if CDS_ACTIVE && CD_USERS.include?(@actor.id)
              self.contents.draw_text(0, 63, width - 32, 32, '›› ', 2)
            end
            self.contents.font.size -= 4
          end
          Graphics.update}
    elsif CDS_ACTIVE && CD_USERS.include?(@actor.id) &&
        @commands[2] == 'Chaos Drive'
      (0...6).each {|j|
          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, 64, self.contents.width - 8, 32)
          if @actor.states.include?(CD_ID)
            self.contents.draw_text(rect, 'Revert')
          else
            self.contents.draw_text(rect, @commands[2])
          end
          self.contents.font.color = normal_color
          (0...@item_max).each {|i|
              draw_item(i, normal_color) unless @commands[i] == 'Chaos Drive'}
          if $scene.is_a?(Scene_Battle)
            self.contents.font.color = normal_color
            self.contents.font.size += 4
            if SLS_ACTIVE && @actor != nil && SL_USERS.include?(@actor.id) &&
                @actor.can_use_sl?
              self.contents.draw_text(0, -1, width - 32, 32, '›› ', 2)
            end
            if SRS_ACTIVE && SR_USERS.include?(@actor.id)
              self.contents.draw_text(0, 31, width - 32, 32, '›› ', 2)
            end
            self.contents.font.size -= 4
          end
          Graphics.update}
    else
      refresh_crls_later
      if $scene.is_a?(Scene_Battle)
        self.contents.font.color = normal_color
        self.contents.font.size += 4
        if SRS_ACTIVE && SR_USERS.include?(@actor.id)
          self.contents.draw_text(0, 31, width - 32, 32, '›› ', 2)
        end
        if SLS_ACTIVE && @actor != nil && SL_USERS.include?(@actor.id) &&
            @actor.can_use_sl?
          self.contents.draw_text(0, -1, width - 32, 32, '›› ', 2)
        end
        if CDS_ACTIVE && CD_USERS.include?(@actor.id)
          self.contents.draw_text(0, 63, width - 32, 32, '›› ', 2)
        end
        self.contents.font.size -= 4
      end
    end
  end
  
  def test_limit
    return (@actor != nil && @actor.can_use_sl? && @index == 0)
  end
  
  def limit
    return (@actor != nil ? @actor.limit_name : '')
  end
  
end

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

class Scene_Battle
  
  alias main_crls_later main
  def main
    main_crls_later
    [@rage_window, @chaos_window].each {|win| win.dispose if win != nil}
  end
    
  alias phase3_setup_command_window_crls_later phase3_setup_command_window
  def phase3_setup_command_window
    phase3_setup_command_window_crls_later
    @actor_command_window.set_player_command(@active_battler)
  end
  
  alias update_phase3_crls_later update_phase3
  def update_phase3
    if @rage_window != nil && @rage_window.visible
      @rage_window.update
      update_phase3_rage_select
    elsif @chaos_window != nil && @chaos_window.visible
      @chaos_window.update
      update_phase3_chaos_select
    else
      update_phase3_crls_later
    end
  end
  
  alias update_phase3_enemy_select_crls_later update_phase3_enemy_select
  def update_phase3_enemy_select
    end_rage_select_plus if Input.trigger?(Input::B)
    update_phase3_enemy_select_crls_later
  end

  alias update_phase3_actor_select_crls_later update_phase3_actor_select
  def update_phase3_actor_select
    end_rage_select_plus if Input.trigger?(Input::B)
    update_phase3_actor_select_crls_later
  end

  alias phase3_next_actor_crls_later phase3_next_actor
  def phase3_next_actor
    end_rage_select if @rage_window != nil
    end_chaos_select if @chaos_window != nil
    phase3_next_actor_crls_later
  end

  def update_phase3_rage_select
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      end_rage_select if @rage_window.visible
    elsif Input.trigger?(Input::C) 
      @skill = @rage_window.skill
      if @skill == nil || !@active_battler.can_use_sr?(@skill.id)
        $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
      @rage_window.visible = false
      if @skill.scope == 1
        start_enemy_select
      elsif [3, 5].include?(@skill.scope)
        start_actor_select
      else
        phase3_next_actor
      end
    end
  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
    elsif Input.trigger?(Input::C) 
      @skill = @chaos_window.skill
      if @skill == nil || !@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
      phase3_next_actor
    end
  end
  
  def start_rage_select
    @rage_window = Window_SoulRage.new(@active_battler)
    @rage_window.help_window = @help_window
    @actor_command_window.active = @actor_command_window.visible = false
  end
  
  def end_rage_select
    end_rage_select_plus
    @actor_command_window.swap_commands(1)
    @rage_window.dispose
    @rage_window, @help_window.visible = nil, false
  end
  
  def end_rage_select_plus
    if @rage_window != nil
      if @rage_window.visible
        @actor_command_window.active = @actor_command_window.visible = true
        @help_window.visible = false
      else
        @rage_window.active = @rage_window.visible = true
      end
    end
  end
  
  def start_chaos_select
    @chaos_window = Window_ChaosDrive.new(@active_battler)
    @chaos_window.help_window = @help_window
    @actor_command_window.active = @actor_command_window.visible = false
  end
  
  def end_chaos_select
    end_chaos_select_plus
    @actor_command_window.swap_commands(2)
    @chaos_window.dispose
    @chaos_window, @help_window.visible = nil, false
  end
  
  def end_chaos_select_plus
    if @chaos_window != nil
      if @chaos_window.visible
        @actor_command_window.active = @actor_command_window.visible = true
        @help_window.visible = false
      else
        @chaos_window.active = @chaos_window.visible = true
      end
    end
  end
  
  def make_sl_action_result
    @skill = $data_skills[@active_battler.current_action.skill_id]
    if $tons_version != nil && $tons_version >= 5.0
      @active_battler.use_limit if @repeat[0] <= 1
    else
      @active_battler.use_limit
    end
    make_crls_postaction_result
  end
  
  def make_rage_action_result
    @skill = $data_skills[@active_battler.current_action.skill_id]
    unless @active_battler.current_action.forcing ||
        @active_battler.can_use_sr?(@skill.id)
      $game_temp.forcing_battler = nil
      @phase4_step = 1
      return
    end
    if $tons_version != nil && $tons_version >= 5.0
      @active_battler.sr -= @skill.sp_cost * 10 if @repeat[0] <= 1
    else
      @active_battler.sr -= @skill.sp_cost * 10
    end
    make_crls_postaction_result
  end
  
  def make_chaos_action_result
    @skill = $data_skills[@active_battler.current_action.skill_id]
    unless @skill == nil
      @active_battler.chaos_action = 1
      make_crls_postaction_result
    end
  end
  
  def make_crls_postaction_result
    @status_window.refresh
    @help_window.set_text(@skill.name, 1)
    @animation1_id, @animation2_id = @skill.animation1_id, @skill.animation2_id
    @common_event_id = @skill.common_event_id
    set_target_battlers(@skill.scope)
    @target_battlers.each {|target| target.skill_effect(@active_battler, @skill)}
  end
  
  alias update_phase4_step2_crls_later update_phase4_step2
  def update_phase4_step2
    update_phase4_step2_crls_later
    case @active_battler.current_action.kind
    when 3 then make_rage_action_result
    when 8 then make_chaos_action_result
    when 9 then make_sl_action_result
    end
  end
  
  alias update_phase3_basic_command_crls_later update_phase3_basic_command
  def update_phase3_basic_command
    if SLS_ACTIVE && SL_USERS.include?(@active_battler.id) &&
        @actor_command_window.index != 0 &&
        @actor_command_window.commands[0] == @actor_command_window.limit
      @actor_command_window.swap_commands(0)
      @help_window.set_text('', 1)
      @help_window.visible = false
    end
    if SRS_ACTIVE && SR_USERS.include?(@active_battler.id) &&
        @actor_command_window.index != 1 &&
        @actor_command_window.commands[1] == 'Soul Rage'
      @actor_command_window.swap_commands(1)
    end
    if CDS_ACTIVE && CD_USERS.include?(@active_battler.id) &&
        @actor_command_window.index != 2 &&
        @actor_command_window.commands[2] == 'Chaos Drive'
      @actor_command_window.swap_commands(2)
    end
    if SLS_ACTIVE && SL_USERS.include?(@active_battler.id)
      if @actor_command_window.commands[0] == @actor_command_window.limit &&
          @actor_command_window.index != 0
        @actor_command_window.swap_commands(0, true)
      end
      if @actor_command_window.test_limit && Input.press?(Input::RIGHT)
        if @actor_command_window.commands[0] != @actor_command_window.limit
          $game_system.se_play($data_system.decision_se)
          skill = $data_skills[@actor_command_window.actor.limit_id]
          @help_window.set_text(skill.description, 1)
          @actor_command_window.swap_commands(0)
        end
        if !Input.press?(Input::UP) && !Input.press?(Input::DOWN)
          @actor_command_window.update
        end
      elsif @actor_command_window.commands[0] == @actor_command_window.limit
        $game_system.se_play($data_system.cancel_se)
        @actor_command_window.swap_commands(0)
        @help_window.set_text('', 1)
        @help_window.visible = false
      end
      if @actor_command_window.commands[0] == @actor_command_window.limit &&
          Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 9
        @active_battler.current_action.skill_id = @actor_command_window.actor.limit_id
        @skill = $data_skills[@active_battler.current_action.skill_id]
        @help_window.visible = false
        if @skill.scope == 1
          start_enemy_select
          @actor_command_window.swap_commands(0)
        elsif [3, 5].include?(@skill.scope)
          start_actor_select
          @actor_command_window.swap_commands(0)
        else
          @actor_command_window.swap_commands(0)
          phase3_next_actor
        end
        return
      end
    end
    if SRS_ACTIVE && SR_USERS.include?(@active_battler.id)
      if @actor_command_window.commands[1] == 'Soul Rage' &&
          @actor_command_window.index != 1
        @actor_command_window.swap_commands(1, true)
      end
      if @actor_command_window.index == 1 && Input.press?(Input::RIGHT)
        if @actor_command_window.commands[1] != 'Soul Rage'
          $game_system.se_play($data_system.decision_se)
          @actor_command_window.swap_commands(1)
        end
        if !Input.press?(Input::UP) && !Input.press?(Input::DOWN)
          @actor_command_window.update
        end
      elsif @actor_command_window.commands[1] == 'Soul Rage'
        $game_system.se_play($data_system.cancel_se)
        @actor_command_window.swap_commands(1)
      end
      if @actor_command_window.commands[1] == 'Soul Rage' &&
          Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 3
        start_rage_select
        return
      end
    end
    if CDS_ACTIVE && CD_USERS.include?(@active_battler.id)
      if @actor_command_window.index == 2 && Input.press?(Input::RIGHT)
        if @actor_command_window.commands[2] != 'Chaos Drive'
          $game_system.se_play($data_system.decision_se)
          @actor_command_window.swap_commands(2)
        end
        if !Input.press?(Input::UP) && !Input.press?(Input::DOWN)
          @actor_command_window.update
        end
      elsif @actor_command_window.commands[2] == 'Chaos Drive'
        $game_system.se_play($data_system.cancel_se)
        @actor_command_window.swap_commands(2)
      end
      if @actor_command_window.commands[2] == 'Chaos Drive' &&
          Input.trigger?(Input::C)
        unless @actor_command_window.actor.states.include?(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)
          @active_battler.current_action.kind = 8
          @active_battler.chaos_action = 2
          @actor_command_window.swap_commands(2)
          phase3_next_actor
        end
        return
      end
    end
    update_phase3_basic_command_crls_later
  end

  alias update_phase4_step4_crls_later update_phase4_step4
  def update_phase4_step4
    @target_battlers.each {|target|
        if target.is_a?(Game_Actor) && target.chaos_action == 1
          target.damage = 'Chaos Drive!'
        end}
    update_phase4_step4_crls_later
  end
  
  alias update_phase4_step6_crls_later update_phase4_step6
  def update_phase4_step6
    update_phase4_step6_crls_later
    flag = false
    $game_party.actors.each {|actor|
        if [1, 2].include?(actor.chaos_action)
          case actor.chaos_action
          when 1 then actor.use_chaos(actor.current_action.skill_id)
          when 2 then actor.revert_chaos
          end
          flag = true
        end}
    if flag
      @status_window.refresh
      @spriteset.update_actors
    end
  end

  def exit_chaos(dead = true)
    flag = true
    $game_party.actors.each {|actor|
        if actor.states.include?(CD_ID) && (dead || actor.dead?)
          actor.revert_chaos
          actor.recover_all unless STAY_DAMAGE
          flag = false
        end}
    @status_window.refresh unless flag
    return flag
  end
  
  alias judge_crls_later judge
  def judge
    result = exit_chaos(false)
    @status_window.refresh
    @spriteset.update_actors(true)
    return (result && judge_crls_later)
  end
  
  alias start_phase5_crls_later start_phase5
  def start_phase5
    exit_chaos
    @spriteset.update_actors
    start_phase5_crls_later
  end
  
  alias battle_end_crls_later battle_end
  def battle_end(result)
    exit_chaos
    @spriteset.update_actors(true)
    $game_player.refresh
    battle_end_crls_later(result)
  end
  
end
site ou autor do arquivo Blizzard (RM) tamanho do arquivo 514 KB licencaGrátis sistemas operacionais compativeisWindows 98/98SE/Me/2000/XP/Vista/7 Download

Deixe um comentário

  • Seja social e nos siga!

           
  • Páginas

  • Tags Especiais

  • Categorias

  • Parceiros

  • eXTReMe Tracker
    Copyright © 2001 - 2017 Gaming Room. Todos os Direitos Reservados - É expressamente proibida a reprodução total ou parcial deste site sem o consentimento dos autores.