Revive State
Version: 1.1
Author: modern algebra
Date: May 16, 2010
Version History
- <Version 1.1> 05.16.2010 - Can now play a message when the revive goes off
- <Version 1.0> 05.16.2010 - Original Release
Description
This script allows you to make states that will revive the actor who has it immediately upon KO. You can set to what health it revives them to, either directly or by percentage, and you can set the SE and message that plays when it works.
Features
- Can create revive states that immediately revive the actor if he/she becomes incapacitated, like fairies in LoZ
- Can set the amount of health to regain either directly or by percentage
- Can set a specific Revive SE to play when that revive operates
- Can set a specific Revive Message to play when that revive operates
Instructions
Please see the header of the script for instructions.
Script
#==============================================================================
# Revive State
# Version: 1.1
# Author: modern algebra (rmrk.net)
# Date: May 16, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to make states that will revive the actor who has
# it immediately upon KO. You can set to what health it revives them to,
# either directly or by percentage, and you can set the SE and message that
# plays when it works.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot in the Script Editor (F11), somewhere
# below Materials but still above Main.
#
# To set a state to revive, all you need to do is put the following code in
# its note field:
# \revive[x]
# x : the health you want the actor to return to. If you wish to set it
# to a percentage, simply put a % sign after the value, so:
# \revive[x%]
#
# If you want the state to dissipate upon reviving the actor, then make sure
# you set it as a State to Cancel in your Incapacitated state. Otherwise, it
# will remain until it is naturally removed.
#
# If you wish, you can also set states up to have special revive SEs with the
# code in the note field:
# \REVIVE_SE[se_name, volume, pitch]
# If you don't set this, then it will default to the DEFAULT_REVIVAL_SE, as
# found and setup at line 48. If you set it, but exclude volume or pitch, then
# they will default to 100.
#
# You can also set states to have special revive messages when it works, by
# using this code in the note field:
# \REVIVE_MSG[ message]
# If you exclude it, it will default to whatever message you have set at line
# 52.
#==============================================================================
# CONSTANT
#==============================================================================
# Here, you can set the default revival SE for all revive skills. Set it as:
# DEFAULT_REVIVAL_SE = "se name", volume, pitch
# If you exclude volume or pitch, they default to 100.
DEFAULT_REVIVAL_SE = "Raise1", 100, 120
# You can set the default revival message for all revive skills. Set it as:
# DEFAULT_REVIVAL_SE = " message"
# Prior to this message, the actor or enemy's name who it affects will be
# printed.
DEFAULT_REVIVAL_MSG = " was knocked out but is revived!"
#==============================================================================
# ** RPG::State
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - revival_health; revival_se; revival_message
#==============================================================================
class RPG::State
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Revival Health
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def revival_health
if !@revival_health
@revival_health = 0
if self.note[/\\REVIVE\[(\d+)(%?)\]/i] != nil
@revival_health = $2.empty? ? $1.to_i : [($1.to_f / 100.0), 1.0].min
end
end
return @revival_health
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Revival SE
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def revival_se
if !@revival_se
@revival_se = DEFAULT_REVIVAL_SE
@revival_se = [@revival_se] if !@revival_se.is_a? (Array)
if self.note[/\\REVIVE_SE\[([^,\]]+),?\s*(\d*),?\s*(\d*)\]/i] != nil
@revival_se = [$1.to_s]
@revival_se.push ($2.to_i) if !$2.empty?
@revival_se.push ($3.to_i) if !$3.empty?
end
end
return RPG::SE.new (*@revival_se)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Revival Message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def revival_message
if !@revival_message
@revival_message = self.note[/\\REVIVE_MSG\[(.*?)\]/i] != nil ? $1.to_s : DEFAULT_REVIVAL_MSG
end
return @revival_message
end
end
#==============================================================================
# ** Game_Battler
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new accessor variable - revival_message
# aliased method - add_state; states_active?
#==============================================================================
class Game_Battler
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variable
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :revival_message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * States Active?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modal_rvvest_avestat_6yh2 states_active?
def states_active? (*args)
return true if @revival_message
return modal_rvvest_avestat_6yh2 (*args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add State
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_revive_adstae_8ik5 add_state
def add_state (state_id, *args)
rs = nil
rh = 0
if state_id == 1 # If Incapacitated State
self.states.each { |state|
rh2 = state.revival_health
rh2 = [(self.maxhp*rh2).to_i, self.maxhp].min if rh2.is_a? (Float)
if rh2 > rh
rs = state
rh = rh2
end
}
end
ma_revive_adstae_8ik5 (state_id, *args) # Run Original Method
if rs != nil # If revive state engaged
begin
rs.revival_se.play
rescue
end
self.hp = rh
@revival_message = "#{self.name}#{rs.revival_message}" if !rs.revival_message.empty?
end
end
end
#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - display_added_states
#==============================================================================
class Scene_Battle
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Display Added States
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias moda_rvval_dspadst_4tg9 display_added_states
def display_added_states (target, *args)
moda_rvval_dspadst_4tg9 (target, *args) # Run Original Method
if target.revival_message != nil
@message_window.replace_instant_text (target.revival_message)
wait(20)
target.revival_message = nil
end
end
end
Credit
Thanks
Support
Please post in this topic at RMRK.net for support.
Known Compatibility Issues
No currently known compatibility issues. Should work with almost any battle system, though it might not show the message.