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.
[VXA][SOLVED]Full Recovery Immune States conflicting with Passive Skills

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 55
RMRK Junior
I have a script that was made when I requested it in the "Script Request" section that allows you to set certain states to be immune to the "Full Recovery" event command, it works fine, but when I use it with Yanfly's "Yanfly Engine Ace - Passive States v1.02" script, it causes this error:

Quote
Script 'Game_Actor' line 52: TypeError occured.

no implicit conversion from nil to integer

This is the "Full Recovery Immune States" script (made by Pacman):
Spoiler for Full Recovery Immune States:
Code: [Select]
class Game_BattlerBase
  alias no_recover_states_init initialize
  def initialize(*args)
    @states = []
    no_recover_states_init(*args)
  end
  alias no_recover_states_clear clear_states
  def clear_states(*args)
    hold_states = []
    for state in states
      hold_states.push(state.id) if state.note[/\\no[_ ]recover/i] != nil
    end
    no_recover_states_clear(*args)
    @states = hold_states
  end
end

and here is Yanfly's "Yanfly Engine Ace - Passive States v1.02" script:
Spoiler for Yanfly Engine Ace - Passive States v1.02:
Code: [Select]
#==============================================================================
#
# ? Yanfly Engine Ace - Passive States v1.02
# -- Last Updated: 2012.01.23
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-PassiveStates"] = true

#==============================================================================
# ? Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.23 - Compatibility Update: Doppelganger
# 2012.01.08 - Added passive state checks for adding/removing states.
# 2011.12.14 - Started Script and Finished.
#
#==============================================================================
# ? Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows for actors, classes, weapons, armours, and enemies to have
# passives that are based off of states. Passive states will be active at all
# times and are immune to restrictions and will only disappear if the battler
# dies. Once the battler revives, the passives will return.
#
#==============================================================================
# ? Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials/?? but above ? Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Actor Notetags - These notetags go in the actors notebox in the database.
# -----------------------------------------------------------------------------
# <passive state: x>
# <passive state: x, x>
# This will cause state x to be always on (unless the battler is dead). To have
# multiple passives, insert multiples of this notetag.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <passive state: x>
# <passive state: x, x>
# This will cause state x to be always on (unless the battler is dead). To have
# multiple passives, insert multiples of this notetag.
#
# -----------------------------------------------------------------------------
# Weapon Notetags - These notetags go in the weapons notebox in the database.
# -----------------------------------------------------------------------------
# <passive state: x>
# <passive state: x, x>
# This will cause state x to be always on (unless the battler is dead). To have
# multiple passives, insert multiples of this notetag.
#
# -----------------------------------------------------------------------------
# Armour Notetags - These notetags go in the armours notebox in the database.
# -----------------------------------------------------------------------------
# <passive state: x>
# <passive state: x, x>
# This will cause state x to be always on (unless the battler is dead). To have
# multiple passives, insert multiples of this notetag.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemies notebox in the database.
# -----------------------------------------------------------------------------
# <passive state: x>
# <passive state: x, x>
# This will cause state x to be always on (unless the battler is dead). To have
# multiple passives, insert multiples of this notetag.
#
#==============================================================================
# ? Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
# ? Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module BASEITEM
   
    PASSIVE_STATE =
      /<(?:PASSIVE_STATE|passive state):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # BASEITEM
  end # REGEXP
end # YEA

#==============================================================================
# ? DataManager
#==============================================================================

module DataManager
 
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_pst load_database; end
  def self.load_database
    load_database_pst
    load_notetags_pst
  end
 
  #--------------------------------------------------------------------------
  # new method: load_notetags_pst
  #--------------------------------------------------------------------------
  def self.load_notetags_pst
    groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
      $data_enemies]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_pst
      end
    end
  end
 
end # DataManager

#==============================================================================
# ? RPG::BaseItem
#==============================================================================

class RPG::BaseItem
 
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :passive_states
 
  #--------------------------------------------------------------------------
  # common cache: load_notetags_pst
  #--------------------------------------------------------------------------
  def load_notetags_pst
    @passive_states = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::BASEITEM::PASSIVE_STATE
        $1.scan(/\d+/).each { |num|
        @passive_states.push(num.to_i) if num.to_i > 0 }
      #---
      end
    } # self.note.split
    #---
  end
 
end # RPG::BaseItem

#==============================================================================
# ? Game_BattlerBase
#==============================================================================

class Game_BattlerBase
 
  #--------------------------------------------------------------------------
  # alias method: state?
  #--------------------------------------------------------------------------
  alias game_battlerbase_state_check_pst state?
  def state?(state_id)
    return true if passive_state?(state_id)
    return game_battlerbase_state_check_pst(state_id)
  end
 
  #--------------------------------------------------------------------------
  # alias method: states
  #--------------------------------------------------------------------------
  alias game_battlerbase_states_pst states
  def states
    array = game_battlerbase_states_pst
    array |= passive_states
    return array
  end
 
  #--------------------------------------------------------------------------
  # new method: passive_state?
  #--------------------------------------------------------------------------
  def passive_state?(state_id)
    @passive_states = [] if @passive_states.nil?
    return @passive_states.include?(state_id)
  end
 
  #--------------------------------------------------------------------------
  # new method: passive_states
  #--------------------------------------------------------------------------
  def passive_states
    array = []
    if actor?
      for state_id in self.actor.passive_states
        array.push($data_states[state_id]) if passive_state_addable?(state_id)
      end
      for state_id in self.class.passive_states
        array.push($data_states[state_id]) if passive_state_addable?(state_id)
      end
      for equip in equips
        next if equip.nil?
        for state_id in equip.passive_states
          array.push($data_states[state_id]) if passive_state_addable?(state_id)
        end
      end
    else # enemy
      for state_id in self.enemy.passive_states
        array.push($data_states[state_id]) if passive_state_addable?(state_id)
      end
      if $imported["YEA-Doppelganger"] && !self.class.nil?
        for state_id in self.class.passive_states
          array.push($data_states[state_id]) if passive_state_addable?(state_id)
        end
      end
    end
    create_passive_state_array(array)
    sort_passive_states(array)
    set_passive_state_turns(array)
    return array
  end
 
  #--------------------------------------------------------------------------
  # new method: create_passive_state_array
  #--------------------------------------------------------------------------
  def create_passive_state_array(array)
    @passive_states = []
    for state in array
      @passive_states.push(state.id)
    end
  end
 
  #--------------------------------------------------------------------------
  # new method: passive_state_addable?
  #--------------------------------------------------------------------------
  def passive_state_addable?(state_id)
    return false if $data_states[state_id].nil?
    return alive?
  end
 
  #--------------------------------------------------------------------------
  # new method: set_passive_state_turns
  #--------------------------------------------------------------------------
  def sort_passive_states(array)
    array.sort! do |state_a, state_b|
      if state_a.priority != state_b.priority
        state_b.priority <=> state_a.priority
      else
        state_a.id <=> state_b.id
      end
    end
    return array
  end
 
  #--------------------------------------------------------------------------
  # new method: set_passive_state_turns
  #--------------------------------------------------------------------------
  def set_passive_state_turns(array)
    for state in array
      @state_turns[state.id] = 0 unless @states.include?(state.id)
      @state_steps[state.id] = 0 unless @states.include?(state.id)
    end
  end
 
end # Game_BattlerBase

#==============================================================================
# ? Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
 
  #--------------------------------------------------------------------------
  # alias method: state_addable?
  #--------------------------------------------------------------------------
  alias game_battler_state_addable_ps state_addable?
  def state_addable?(state_id)
    return false if passive_state?(state_id)
    return game_battler_state_addable_ps(state_id)
  end
 
  #--------------------------------------------------------------------------
  # alias method: remove_state
  #--------------------------------------------------------------------------
  alias game_battler_remove_state_ps remove_state
  def remove_state(state_id)
    return if passive_state?(state_id)
    game_battler_remove_state_ps(state_id)
  end
 
end # Game_Battler

#==============================================================================
#
# ? End of File
#
#==============================================================================

I think the problem has to do with this line in Yanfly's script:
Spoiler for:
Code: [Select]
module DataManager
 
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_pst load_database; end
  def self.load_database
    load_database_pst
    load_notetags_pst
  end
 
  #--------------------------------------------------------------------------
  # new method: load_notetags_pst
  #--------------------------------------------------------------------------
  def self.load_notetags_pst
    groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
      $data_enemies]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_pst
      end
    end
  end
 
end # DataManager

This was posted at the end of my script request thread, but now it seems like it isn't a script request issue anymore, but a script fix issue, so I thought it should go here.
« Last Edit: August 18, 2012, 05:52:57 PM by dragon3025 »

***
Rep:
Level 77
RMRK Junior
Both scripts do the same thing, I believe. So there would be some conflict.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best 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
No, the scripts don't do the same thing and that isn't the source of the conflict. The source of the conflict is that the method, clear_states, is called before any actor is ever initialized. That is normally fine, but Pacman's script modifies that method to call the method states. Normally, that wouldn't be an immense problem either, but Yanfly's script has modified the states method to call the actor method, and since the actor is not yet initialized at that time, it creates the error.

It could probably be fixed by replacing Pacman's script with something like this:

Code: [Select]
class Game_BattlerBase
  alias no_recover_states_clear clear_states
  def clear_states(*args)
    hold_states = @states ? @states.select {|s| !$data_states[s].note[/\\no[_ ]recover/i].nil? } : []
    no_recover_states_clear(*args)
    @states |= hold_states
  end
end

That's just blind, but I think it ought to work. Also, credit only Pacman for the script if you use it - all I did was play around with his design.
« Last Edit: August 17, 2012, 03:51:36 PM by modern algebra »

**
Rep: +0/-0Level 55
RMRK Junior
No, the scripts don't do the same thing and that isn't the source of the conflict. The source of the conflict is that the method, clear_states, is called before any actor is ever initialized. That is normally fine, but Pacman's script modifies that method to call the method states. Normally, that wouldn't be an immense problem either, but Yanfly's script has modified the states method to call the actor method, and since the actor is not yet initialized at that time, it creates the error.

It could probably be fixed by replacing Pacman's script with something like this:

Code: [Select]
class Game_BattlerBase
  alias no_recover_states_clear clear_states
  def clear_states(*args)
    hold_states = @states ? @states.select {|s| !$data_states[s].note[/\\no[_ ]recover/i].nil? } : []
    no_recover_states_clear(*args)
    @states |= hold_states
  end
end

That's just blind, but I think it ought to work. Also, credit only Pacman for the script if you use it - all I did was play around with his design.
Thanks for the response. I tried it out and it worked at first, but after moving around for a bit I got this error:

Quote
Script 'Game_Battler' line 244: NoMethodError occurred

undefined method `>' for nil:NilClass
« Last Edit: August 18, 2012, 11:26:13 AM by modern algebra »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best 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
OK, well try this:

Code: [Select]
class Game_BattlerBase
  alias no_recover_states_clear clear_states
  def clear_states(*args)
    hold_states = {}
    if @states
      hs = @states.select {|s| !$data_states[s].note[/\\no[_ ]recover/i].nil? }
      for s in hs do hold_states[s] = [@state_turns[s], @state_steps[s]] end
    end
    no_recover_states_clear(*args)
    hold_states.each_pair {|s, ary|
      unless @states.include?(s)
        @states.push(s)
        @state_turns[s], @state_steps[s] = *ary
      end
    }
  end
end

**
Rep: +0/-0Level 55
RMRK Junior
OK, well try this:

Code: [Select]
class Game_BattlerBase
  alias no_recover_states_clear clear_states
  def clear_states(*args)
    hold_states = {}
    if @states
      hs = @states.select {|s| !$data_states[s].note[/\\no[_ ]recover/i].nil? }
      for s in hs do hold_states[s] = [@state_turns[s], @state_steps[s]] end
    end
    no_recover_states_clear(*args)
    hold_states.each_pair {|s, ary|
      unless @states.include?(s)
        @states.push(s)
        @state_turns[s], @state_steps[s] = *ary
      end
    }
  end
end
This worked perfectly, thanks.