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.
Screenshots
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi254.photobucket.com%2Falbums%2Fhh99%2FZylos_2007%2Fda.png&hash=6064a15b520b914a11bbd5a1e6e5af2168c4d1a7)
Possibly the most useless screenshot to show off what a Desperation Attack does.
But hey, at least this giant picture caught your attention, right? :V
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi254.photobucket.com%2Falbums%2Fhh99%2FZylos_2007%2Fda2.png&hash=43485ccca3d0c4ec787d95213ffeb9e9cc58312f)
Example 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
endCredit
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.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi254.photobucket.com%2Falbums%2Fhh99%2FZylos_2007%2FSmilies%2Fzylos_read2.gif&hash=23472e000ef95fa4ee98b439d7cf6509402d0157)
Looks very nice Zylos. Good work.
That has to be one of the biggest if end branches I've ever seen though :P
Haha, yes. But it would be just one long sentence if I used a lot of and's. Still, it does exactly as it's supposed to either way.
Hello^^
Sorry,but i don't understand the script(I think it because of my low level of English)
In two words what does the script please?
Essentiellement, lorsque votre personnage a une faible HP pendant un combat, ce script va remplacer une attaque normale au hasard avec une prédéfinie habileté. Critical_HP est le pourcentage maximum de HP nécessaire pour le habileté pour être activé. Random_Chance est la pour cent de probabilité pour la habileté de remplacer une attaque normale. Pardonnez mon pauvre français et en l'aide plus de deux mots. ^^;
Essentially, when your character has low HP during battle, this script will randomly replace a normal attack with a preset skill. Critical_HP is the maximum percentage of HP needed for the skill to be able to go off. Random_Chance is the percent chance of the ability to replace a normal attack.
Haaa^^ Merci pour la traduction,tu as un bon français.C'est un bon script!
Haaa^^ Thank for traduction,your english is good.Nice script =)
Marvelous, Zylos. This would be a fine addition to any game that uses the built in battle system.
That raises a question: would it work with custom battle systems? Not ABSs, just things like Tankentai or TDS's battle system.
Regardless, excellent.
Just as is, no, I don't think so. But again, it's simple enough in it's nature that it can be edited to fit them, so that'll be something for me to add to in the near future.
Version 1.2, now with Tankentai's SBS. Just change Battle_System to 1 and you're good to go.
Zylos, would it be possible to modify this (as it stands now) or have you modify it so you can change the "desperation attack" to vary with weapons/gear equipped? I'm asking because this is the closest thing I could find to the Golden Sun "weapon unleash" effect, except it looks like I could only ever give someone either 1 unleash, or a number of them, except they wouldn't be affected by the equipped weapon, so say the frost weapon unleash could go off while you have a fire weapon on, and let's be honest, that just wouldn't make much sense. I don't know or really understand scripting too well (aside from reading how to use and modify them) but could you make it something like "if x is equipped (x being the weapon) then the attack becomes y (y being the skill ID from the database)"?
Also, is it possible to make this script function using the cooldown system? I want my desperation attack to ALWAYS occur when you reach HP critical, but have a cooldown so it's not like "BAM OP ATTACK" "BAM OP ATTACK" "BAM OP ATTACK" back to back.
I'll see what I can do. (https://rmrk.net/proxy.php?request=http%3A%2F%2Fi254.photobucket.com%2Falbums%2Fhh99%2FZylos_2007%2FSmilies%2Fzylos_closedgrin.gif&hash=93dc5cce5363bfb4a9dbad97cc18e2d5b12318fb)
I was wondering if it would work with YEM battle melody?
Also, I found your basic desperation attack script doesn't seem to play nicely with modern algebra's Cooldown script. If I use your's and his cooldown one together, your's works, but his does not (the cooldowns don't seem to trigger)
Do you know why? and if so, is there anything I can do to make them play nicely together?
As far as the weapons, you can actually change that manually with a common event. Set up a parallel process event with conditional branches checking if a certain actor has a certain weapon equipped. If so, use the script command and enter in "Desperation_Attack::DesperateAttack[x] = y", where x is the actor ID and y is the new skill ID.
As far as the cooldown process, MA's script will likely work if you place it after the Desperation Attack script. That'll be something for me to work on.
I'm not sure if it'll work with the YEM system, send me a link to it and I'll see what I can do. In the meantime, I found a bug I need to fix with the Tankentai's SBS set up. x.x
unforetunately that didn't do it, it still didn't trigger the cooldown. I'm gonna try the other thing you mentioned now.
You only need one common event, and one conditional branch for each weapon type / actor. Ex:
Conditional Branch: [Ralph] is [Longsword] equipped
Script: Desperation_Attack::DesperateAttack[1] = 61
Else
Conditional Branch: [Ralph] is [Bastard Sword] equipped
Script: Desperation_Attack::DesperateAttack[1] = 82
Else
Script: Desperation_Attack::DesperateAttack[1] = 28
Branch End
Branch End
Edit: Judging from your deleted post, I guess you already figured that out.
rofl, yeah, I did. but yeah, the cooldown thing wasn't working even after I moved the cooldown thing to be after your's.
Okay, this has been updated to version 1.5, fixing a major glitch with Tankentai's SBS thanks to Modern Algebra and adding a cooldown option between Desperation Attacks. I tested as best I could and found no more bugs, but if someone should find something I didn't see, let me know.
@zerothedarklord - I also tested to see if MA's script would work. It will work, but the catch is that Desperation Attacks are a little different. MA's Recharge Script sets it so that you can't select a skill for the length of the cooldown period, but a Desperation Attack is an automatic skill the player doesn't actually choose. So, MA's script will work for normal skills, but you'll need to use the new cooldown option of my script for Desperation Attacks.
I discovered a problem with your script. A compatibility issue. I'm not sure why, but for whatever reason, it won't work correctly with the 'ability mp cost mod' script I have. while your script is active, it makes it so mp is not consumed while in combat. Any ideas?
Show me this script?
I sent it as a message, having any luck finding anything?
Took a look at it, and you'll want to replace what you've got with the current version (then add in the custom stuff you wrote in). I think it should work just fine now, since I rewrote it to no longer use execute_action_skill. Give it a try.
testing the mp cost compatibility bug right now.
Excellent, it seems to be working, and I see you added the cooldown compatibility as well, very nice.
Upgraded one more time to allow changed Desperation Attacks to be saved via Game_System. Pretty much I just switched from adding variables to a new module to adding the variables to the already existing Game_System class, which will let the player save their Desperation Attack if they should change it.
The only real difference for users is that you need to use "$Game_System.DesperateAttack[x] = y" instead of "Desperation_Attack::DesperateAttack[x] = y" if you change it in an event.
Let's see...
Take a look at the script down at def desperation. Where it says $game_system.DesperateAttack[@active_battler.id], change it to $game_system.DesperateAttack[@active_battler.class_id]. Should be two instances that need changing.
I don't think it has to do with my script. What class related scripts do you have?
Feel free to PM me with your problem to avoid crowding up the thread.
I think im having an issue with the script, in battle test and new game works fine (i guess because i didnt started the game again, just tested a new battles), the issue says
"line 130: NoMethodError ocurred"
"undefined method ´[]´for nil:NilClass"
this is the line 130: "$game_system.DesperateAttack[@active_battler.id] != nil &&"
I believe that has something to do with the skills i added after i started the game (and those skills were not updated in the started game) but im not sure... is there a way to fix it or i should start a new game to use the script? (or it has nothing to do with your script???)
PD: Thanks for the script, its awesome!
If you're continuing from a prior save file from a period that you didn't have the script inserted, then yeah, there's going to be an issue. If you're playing a new game or playing a save file that had the script to begin with, then it should run just fine.
Ok! Thanks for answer dude!
Bump...
I have another issue with the script, when i tried to change the desperate attack in a common event/ script command, i get an error that says:
NoMethodErrorOcurred occurred while running script.
undefined method ´DesperateAttack´ for nil:NilClass
I tested it in a new project with the default scripts, and gets me the same error.
I wrote in the common event this:
$Game_System.DesperateAttack[001] = 15
That should mean that Ralph will change his desperate attack to skill 15, or i wrote something wrong?
I wanted to do this because i wanted to change the desperate attack depend on the weapon.
Thanks for reading!
It's just a capitalization error, methinks. The call should be like this:
$game_system.DesperateAttack[1] = 15
Also, note that instead of 001 I put 1. That should work.
Oh my god you are rigth pacman, its just that in the script info says "$Game_System" so i copy paste it lol...
Thank you!
It works with BEM ! I wanted to try this out myself, and once you have low HP, and you use attack afterwards, it works!
Almost sure my question will not be answered, but anyway... there is a way to set the desperation attack like FF8, that replaced the normal attack label optionaly? I´m using tankentai.
Regards!