TroyZ State Hit Removal - Undefined Method ">"

upload_2018-4-24_6-11-53.png

upload_2018-4-24_6-15-16.png

Error happens when I use an item that applies state and also prolongs said state by several turns (with Yanfly state manager)
I specifically note that none of the states have Removed By Hit or any notetags from script that breaks. It's not even used here.

Someone atleast tell me what this means, so I can fix it
Because I don't understand when game just says "what is > idk"

Spoiler: code
# ==============================================================================
# ▼▼▼▼▼▼ TroyZ - States Hit Count Removal ▼▼▼▼▼▼
# ==============================================================================
# Script by : Agung Prasetyo(TroyZ)
# Contact me by : - Email [email hidden]
# - Forum RPGMakerID, username TroyZ
# - Handphone 085756289121
# Engine : VXAce
# Level : Easy
# Version : 1.1
# ------------------------------------------------------------------------------
# Change Logs :
# 18 June 2013 : Version 1.0 released
# 24 October 2013 : Bugfix version 1.1 released
# ------------------------------------------------------------------------------
# How this work :
# This script will give you an ability to create states that removed at a
# certain hit count and certain probability.
# ------------------------------------------------------------------------------
# How to use :
# Place it between material and main. Use this notetags inside states :
#
# <remove by hit: x>
# <remove by hit chance: y>
#
# The states that have this notetags will be removed when the affected battler
# suffers the x total hits at y% probability. You don't have to write the percent
# sign at y, just put the number actually. For example, a state have this notetags :
#
# <remove by hit: 3>
# <remove by hit chance: 50>
#
# The state will be removed when the affected battler suffers 3 hits from enemies.
# When the battler get 3 hits from enemies, the state will be removed at 50% chance.
#
# Bugfix :
# I've made a slight change to the script so that it'll be compatible with YEA - Passive States.
# In previous version, when a passive states are active on battler and the battler
# get even a single hit from enemy, an error occured. This error occured because
# the passive states didn't have any hit counter applied, and this script reduce
# the counter itself. And also, passive states are not allowed to be removed
# unless the battler dies. Version 1.1 has bugfix for this. In order for the
# passive states to not be removed when the battler get hits, put this notetag
# inside the passive states:
#
# <passive>
#
# The <passive> notetag will prevent it from getting removed by hit. Remember,
# put the <passive> notetag ONLY inside the passive states.
# ------------------------------------------------------------------------------
# Compatibility issues :
# - YEA - Passive States, the passive states getting removed even only by single hit.
# Version 1.1 has bugfix for this. Put this script below YEA - Passive States.
# ------------------------------------------------------------------------------
# Who to credit :
# - Allah swt. : For the chance of living that he has given to me.
# - Nabi Muhammad saw. : As a leader and messenger and prophet of Muslim.
# I'm proud to be your follower. 🙂
# - Agung Prasetyo(TroyZ) : Thats me, of course, the ones that made this script. 😛
# ------------------------------------------------------------------------------
# License :
# - Free Game : Just credit those names above.
# - Commercial Game : Same as free game's license.
# ------------------------------------------------------------------------------
$imported = {} if $imported.nil?
$imported[:TroyZ_StatesHitCountRemoval] = true
# ------------------------------------------------------------------------------
# There is nothing to config beyond this line
# ------------------------------------------------------------------------------
module AGUNG
module HIT_COUNT
HIT_COUNT_DEFAULT = 0
HIT_COUNT_REMOVE_CHANCE_DEFAULT = 0
end

module NOTETAGS_HIT_COUNT
HIT_COUNT = /<(?:REMOVE BY HIT|remove by hit):[ ]*(\d+)>/i
HIT_COUNT_REMOVE_CHANCE = /<(?:REMOVE BY HIT CHANCE|remove by hit chance):[ ]*(\d+)>/i
end
end

module DataManager
class << self
alias agung_load_states_hit_count_removal_dbase_x load_database
end

def self.load_database
agung_load_states_hit_count_removal_dbase_x
agung_load_notetags_hit_count_removal_x
end

def self.agung_load_notetags_hit_count_removal_x
[$data_states].each do |states|
states.each do |obj|
next unless obj
obj.agung_load_notetags_hit_count_removal_x
end
end
end
end

class RPG::State < RPG::BaseItem

include AGUNG::HIT_COUNT
include AGUNG::NOTETAGS_HIT_COUNT

attr_accessor :hit_count
attr_accessor :chance_by_hit_count

def agung_load_notetags_hit_count_removal_x
@hit_count = HIT_COUNT_DEFAULT
@chance_by_hit_count = HIT_COUNT_REMOVE_CHANCE_DEFAULT
self.note.split(/[\r\n]+/).each { |baris|
case baris
when HIT_COUNT
@hit_count = $1.to_i
when HIT_COUNT_REMOVE_CHANCE
@chance_by_hit_count = $1.to_i
end
}
end

def passive_states?
self.note.include?("<passive>")
end
end

class Game_BattlerBase
alias agung_clear_states_x clear_states
def clear_states
agung_clear_states_x
@state_hit_count = {}
end

alias agung_erase_state_x erase_state
def erase_state(state_id)
agung_erase_state_x(state_id)
@state_hit_count.delete(state_id)
end
end

class Game_Battler < Game_BattlerBase
alias agung_reset_state_counts_x reset_state_counts
def reset_state_counts(state_id)
agung_reset_state_counts_x(state_id)
@state_hit_count[state_id] = $data_states[state_id].hit_count
end

def update_states_hit_count
states.each do |state|
if !state.passive_states?
if @state_hit_count[state.id] > 0
@state_hit_count[state.id] -= 1
end
end
end
end

def remove_states_by_hit_count
states.each do |state|
if @state_hit_count[state.id] == 0 && rand(100) < state.chance_by_hit_count
remove_state(state.id)
end
end
end

alias agung_on_damage_x on_damage
def on_damage(value)
agung_on_damage_x(value)
update_states_hit_count
remove_states_by_hit_count
end
end
# ------------------------------------------------------------------------------
# END OF SCRIPT
# ------------------------------------------------------------------------------
It says that it can't compare a nil class with a number using that comparison type (higher than).

Replace the error line with this one:
Code:
if (@state_hit_count[state.id] || 0) > 0
That should fix it.
Thank you

Original thread: https://forums.rpgmakerweb.com/threads/troyz-state-hit-removal-undefined-method.94464/