RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Revive State

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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


Code: [Select]
#==============================================================================
#    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


  • modern algebra

Thanks

  • Wizard, for the request

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.
« Last Edit: May 16, 2010, 07:31:53 PM by modern algebra »

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
So it's basically like a Re-raise status in FF? Sounds pretty cool.

Though I'm not sure if I like the fact that it simply plays a sound. It should write something in the text like "%s was Re-Risen".
« Last Edit: May 16, 2010, 06:04:30 PM by cozziekuns »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, I'll quickly write a new version that can, but it likely won't work for a number of custom battle systems :(

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
If you get this to compatible with Tankentai SVBS, that'd be great :)
I haven't actually checked if it wasn't yet. Just assuming this being probably one of those "custom battle systems" it won't work with.
I'm actually making a game this time :O

(and get this, I plan on using all the scripts I've asked for in the past lol, including the tutorial and inventory scripts :D)

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, the function almost certainly will. The only thing I have reservations about is whether the message will show up, but I can check it out.

EDIT::

I looked at it for a little - it does work but it's weird. Anyway, I don't think it's useful since they already have some sort of autolife feature built into Tankentai. I haven't looked into how to use it, but I'm sure it works so I wouldn't bother using this script if you have Tankentai.
« Last Edit: May 16, 2010, 09:10:22 PM by modern algebra »

**
Rep: +0/-0Level 76
RMRK Junior
Ok...I'm not a complete idiot (I don't think)...

I know how the basics of scripting and whatnot, but one big problem is holding me back...

When I copy scripts, the formatting is not carried over, so that when I paste, all the code is on one line. What's the deal?

(I would have posted this on the sticky note about how to copy scripts, but it's locked)

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
It's a problem with Internet Explorer and SMF2. Just use another browser to copy scripts for now and it will hopefully be fixed some time in the future. I attached a text document with this script to this post. If you don't have another browser, you can just get it from there.
« Last Edit: July 09, 2010, 08:34:14 PM by modern algebra »