Save-Point
Unalterable States - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: Unalterable States (/thread-7411.html)



Unalterable States - DerVVulfman - 01-22-2019

Unalterable States
Version: 1.0



Introduction
This is a very simple script in principle and intent. It merely prevents specific status effects from being added or removed unless performed by way of a script call. This way, custom and unique states that are meant to be permanent cannot be accidentally healed by way of items of the use or the Recover All map event.



Script
Code:
#==============================================================================
# ** Unalterable States
#------------------------------------------------------------------------------
#    by DerVVulfman
#    version 1.0
#    01-21-2019 (MM-DD-YYYY)
#    RGSS / RPGMaker XP
#==============================================================================
#
#  This is a very simple script in principle and intent.  It merely prevents
#  specific status effects  from being added or removed  unless performed by
#  way of a script call.  This way,  custom and unique states that are meant
#  to be permanent  cannot be accidentally healed by way of items of the use
#  of the Recover All map event.
#
#  States that are meant  to be permanent,  and cannot be summarily added or
#  remove by normal means,  have their IDs listed in  the Unalterable_States
#  module below.  There is but only one array to edit.  So... list away!
#
#  As stated earlier, you will now need to use script calls to actively
#  add these states.  They are as follows.
#
#  (target).dvv_add_unalterable_state(state_id [, force] )
#    and
#  (target).dvv_remove_unalterable_state(state_id [, force] )
#
#  EXAMPLE:   $game_party.actors[2].dvv_add_unalterable_state(5)
#
#  These are mirrors of the normal 'add_state' and 'remove_state' methods,
#  the methods which are being bypassed  if an Unalterable state is found.
#  
#
#==============================================================================
#
#  TERMS AND CONDITIONS:
#  Free for use, even in commercial games.  However, due credit is required.
#
#==============================================================================


module Unalterable_States
  
  STATES = [21]  # Yes, I had a 21st state in MY game. "Upset Tummy"  ^_^
  
end



#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias dvv_add_unalterable_state add_state
  alias dvv_remove_unalterable_state remove_state
  #--------------------------------------------------------------------------
  # * Add State
  #     state_id : state ID
  #     force    : forcefully added flag (used to deal with auto state)
  #--------------------------------------------------------------------------
  def add_state(state_id, force = false)
    # Block if non-changing
    return if Unalterable_States::STATES.include?(state_id)
    # Perform the original call
    dvv_add_unalterable_state(state_id, force)
  end
  #--------------------------------------------------------------------------
  # * Remove State
  #     state_id : state ID
  #     force    : forcefully removed flag (used to deal with auto state)
  #--------------------------------------------------------------------------
  def remove_state(state_id, force = false)
    # Block if non-changing
    return if Unalterable_States::STATES.include?(state_id)
    # Perform the original call
    dvv_remove_unalterable_state(state_id, force)
  end
end



Instructions
It's a simple system with instructions in the script.



Compatibility
While it should be compatible with any RPGMaker XP script, it might cause issues if you accidentally make a status effect super-permanent when not intended. Carful careful!!!



Terms and Conditions
Free for use, even in commercial games. However, due credit is required.