Desperation Attacks (VX)
Version: 1.6
Author: Zylos
Date: April 1, 2011
Version History
- <Version 1.6> 04.01.2011 - Allowed changed attacks to be saved.
- <Version 1.5> 03.24.2011 - Added Cooldown_Wait and fixed SBS glitch.
- <Version 1.2> 03.06.2011 - Made compatible with Tankentai's SBS
- <Version 1.0> 03.04.2011 - Original Release
Description
This script mimics the Desperation Attack system used in Final Fantasy VI, allowing the actors to randomly perform more powerful last resort attacks instead of their regular attacks when they are in critical health. You need only to set in the HP percentage actors reach critical health upon, the random chance rate for the Desperation Attack to replace a regular attack, and the skill ID each actor uses as their attack.
Features
- Allows actors to perform familiar Deathblows in critical status.
- Lets the actors use even unlearned skills without costing MP.
- Very straight forward and easily customizable.
- Skills can be changed with ease in events.
- Allows an optional cooldown period between Desperation Attacks.
- Disables Desperation Attacks when either beserked or confused.
- Compatible with Tankentai's Sideview Battle System.
- Based directly off of the system used in Final Fantasy VI.
ScreenshotsPossibly the most useless screenshot to show off what a Desperation Attack does.
But hey, at least this giant picture caught your attention, right? :VExample of Desperation Attacks in use with Tankentai's SBS. Instructions
- Place this script in the materials section, above Main.
- In the editable region of this script, enter in the needed data as follows:
- Critical_HP: The percentage of health at which the actor reaches critical status and is eligible for a Desperation Attack. Default is 25, which is the same as the RMVX default for critical status anyway.
- Random_Chance: The chance percentage the Desperation Attack being used instead of a regular attack, provided the actor is in critical status and not either confused or beserked. Default is 1/16 chance, or 6.25%, which is what it was in Final Fantasy VI.
- Battle_System: NEW! In versions 1.2 of this script or newer, you can also use this script with Tankentai's Sideview Battle System. Simply set 'Battle_System' to 0 if you are using the default RMVX system or 1 if you are using Tankentai's SBS.
- Cooldown_Wait: NEW! In versions 1.5 or newer, you can add a cooldown period in which the player must wait a certain number of turns before being able to use a Desperation Attack again. Set this to 0 if you do not wish to have a cooldown period.
- DesperateAttack[x]: The ID number of the skill being used for the Desperation Attack, where x is the ID number of the specific actor using the attack. For example, if actor 1, Ralph, was to use skill 82, Newclear, as his attack, you would use DesperateAttack[1] = 82.
- Note! If you wish to change the actor's Desperation Attack during the course of the game, you can do so easily in an event by using the script command and using: "$Game_System.DesperateAttack[x] = y" without the quotation marks, where x is the ID number of the actor and y is the ID of the skill you wish to change it to.
Script
#==============================================================================
# Desperation Attacks (VX)
# Version: 1.6
# Author: Zylos (rmrk.net)
# Date: April 1, 2011
#------------------------------------------------------------------------------
# Description:
#
# This script mimics the Desperation Attack system used in Final Fantasy VI,
# allowing the actors to randomly perform more powerful last resort attacks
# instead of their regular attacks when they are in critical health. You
# need only to set in the HP percentage actors reach critical health upon,
# the random chance rate for the Desperation Attack to replace a regular
# attack, and the skill ID each actor uses as their attack.
#
#------------------------------------------------------------------------------
# Instructions:
#
# - Place this script in the materials section, above Main.
# - In the editable region of this script, just below these instructions,
# enter in the needed data as follows:
#
#
# Critical_HP: The percentage of health at which the actor reaches
# critical status and is eligible for a Desperation
# Attack. Default is 25, which is the same as the RMVX
# default for critical status anyway.
#
# Random_Chance: The chance percentage the Desperation Attack being
# used instead of a regular attack, provided the actor is
# in critical status and not either confused or beserked.
# Default is 1/16 chance, or 6.25%, which is what it was
# in Final Fantasy VI.
#
# DesperateAttack[x]: The ID number of the skill being used for the
# Desperation Attack, where x is the ID number of the
# specific actor using the attack. For example, if
# actor 1, Ralph, was to use skill 82, Newclear, as
# his attack, you would use DesperateAttack[1] = 82.
#
# Battle_System: In versions 1.2 or newer, you can also use this script
# with Tankentai's Sideview Battle System. Simply set
# 'Battle_System' to 0 if you are using the default RMVX
# system or 1 if you are using Tankentai's SBS.
#
# Cooldown_Wait: In versions 1.5 or newer, you can add a cooldown period
# in which the player must wait a certain number of turns
# before being able to use a Desperation Attack again. Set
# this to 0 if you do not wish to have a cooldown period.
#
#
# - Note! If you wish to change the actor's Desperation Attack during the
# course of the game, you can do so easily in an event by using the
# script command and using: "$Game_System.DesperateAttack[x] = y"
# without the quotation marks, where x is the ID number of the actor and
# y is the ID of the skill you wish to change it to.
#
#==============================================================================
class Game_System
attr_accessor :Critical_HP
attr_accessor :Random_Chance
attr_accessor :Battle_System
attr_accessor :Cooldown_Wait
attr_accessor :DesperateAttack
alias_method :desperation_attack, :initialize
def initialize
#============================================================================
# EDITABLE REGION:
#============================================================================
@Critical_HP = 25
@Random_Chance = 6.25
@Battle_System = 0
@Cooldown_Wait = 0
@DesperateAttack = []
@DesperateAttack[1] = 82
@DesperateAttack[2] = 81
@DesperateAttack[3] = 68
@DesperateAttack[4] = 60
#============================================================================
# END EDITABLE REGION
#============================================================================
desperation_attack
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# Adding on the variable determining whether a Desperation Attack is in
# effect or not already.
#==============================================================================
class Game_Actor
attr_accessor :desperation
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# First checks if an actor in the battle has a Desperation Attack set, and if
# they are capable of activating it. If the actor is in critical status, has an
# attack set, and is not inflicted with either beserk or confusion, it will draw
# a random chance of swapping the regular attack selected with the Desperation
# attack.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
alias_method :desperate_cool_start, :start
def start
desperate_cool_start
@desperate_cooldown = []
for actor in $game_party.members
@desperate_cooldown[actor.id] = 0
end
end
#--------------------------------------------------------------------------
# * Desperation
#--------------------------------------------------------------------------
def desperation
if @active_battler.is_a?(Game_Actor) &&
$game_system.DesperateAttack[@active_battler.id] != nil &&
@active_battler.action.basic == 0 &&
!@active_battler.berserker? &&
!@active_battler.confusion? &&
!@active_battler.desperation &&
!judge_win_loss &&
@desperate_cooldown[@active_battler.id] == 0 &&
((@active_battler.hp * 100) / @active_battler.maxhp) <= $game_system.Critical_HP &&
(rand(100)) <= $game_system.Random_Chance
@active_battler.action.skill_id = $game_system.DesperateAttack[@active_battler.id]
@active_battler.action.forcing = true
@active_battler.desperation = true
@active_battler.action.kind = 1
@desperate_cooldown[@active_battler.id] = $game_system.Cooldown_Wait + 1
return true
end
return false
end
#--------------------------------------------------------------------------
# * Start party command selection
#--------------------------------------------------------------------------
alias_method :desperate_clear, :start_party_command_selection
def start_party_command_selection
desperate_clear
if $game_temp.in_battle
for actor in $game_party.members
actor.desperation = false
end
end
end
#--------------------------------------------------------------------------
# * Execute Battle Actions
#--------------------------------------------------------------------------
alias_method :desperate_cool, :execute_action
def execute_action
desperate_cool
if @active_battler.is_a?(Game_Actor) &&
@desperate_cooldown[@active_battler.id] > 0
@desperate_cooldown[@active_battler.id] -= 1
end
end
#--------------------------------------------------------------------------
# * Execute Action Desperation Attack
#--------------------------------------------------------------------------
def execute_action_desperate_attack
if $game_system.Battle_System == nil or $game_system.Battle_System == 0
if @active_battler.is_a?(Game_Actor)
if @active_battler.desperation == true
text = @active_battler.name + " unleashes a desperate attack!"
Sound.play_use_skill
$game_troop.screen.start_flash(Color.new(255,255,255,255), 10)
@message_window.add_instant_text(text)
wait(50)
@message_window.clear
end
end
skill = @active_battler.action.skill
text = @active_battler.name + skill.message1
@message_window.add_instant_text(text)
unless skill.message2.empty?
wait(10)
@message_window.add_instant_text(skill.message2)
end
targets = @active_battler.action.make_targets
display_animation(targets, skill.animation_id)
if @active_battler.is_a?(Game_Actor)
if @active_battler.desperation == false
@active_battler.mp -= @active_battler.calc_mp_cost(skill)
end
end
$game_temp.common_event_id = skill.common_event_id
for target in targets
target.skill_effect(@active_battler, skill)
display_action_effects(target, skill)
end
elsif $game_system.Battle_System == 1
if @active_battler.is_a?(Game_Actor)
if @active_battler.desperation == true
text = @active_battler.name + " unleashes a desperate attack!"
Sound.play_use_skill
$game_troop.screen.start_flash(Color.new(255,255,255,255), 10)
@help_window.set_text(text, 1)
@help_window.visible = true
wait_2(50)
end
end
skill = @active_battler.action.skill
if skill.plus_state_set.include?(1)
for member in $game_party.members + $game_troop.members
next if member.immortal
next if member.dead?
member.dying = true
end
else
immortaling
end
if @active_battler.is_a?(Game_Actor)
if @active_battler.desperation == false
return if @active_battler.consum_skill_cost(skill) == false
end
end
target_decision(skill)
@spriteset.set_action(@active_battler.actor?, @active_battler.index, skill.base_action)
pop_help(skill)
playing_action
$game_temp.common_event_id = skill.common_event_id
end
end
#--------------------------------------------------------------------------
# * Execute Action Attack
#--------------------------------------------------------------------------
alias_method :desperate_replace, :execute_action_attack
def execute_action_attack
if desperation
execute_action_desperate_attack
return
end
desperate_replace
end
#--------------------------------------------------------------------------
# * Update Basic 2 (for Tankentai's SBS only)
#--------------------------------------------------------------------------
def update_basic_2(main = false)
Graphics.update unless main # Update game screen
Input.update unless main # Update input information
$game_system.update # Update timer
$game_troop.update # Update enemy group
@message_window.update # Update message window
@spriteset.update_viewports
end
#--------------------------------------------------------------------------
# * Wait 2 (for Tankentai's SBS only)
#--------------------------------------------------------------------------
def wait_2(duration, no_fast = false)
for i in 0...duration
update_basic_2
break if not no_fast and i >= duration / 2 and show_fast?
end
end
end
Credit
Thanks
- Sandgolem, who wrote a Desperation Attacks script for RMXP. I based this one heavily off of studying his script. If you need this stuff for XP, look him up.
- Square, for making FFVI. Why exactly do I thank them, Iunno.
- Modern Algebra, for fixing a problem that had stumped me completely. x.x
Known Compatibility Issues
This has been made to work both with the default RMVX battle system, and Tankentai's Sideview Battle System. I don't know if it'll work with any other system at the moment, though the script is simple enough in nature that it can easily be edited to be compatible.