> error on adding new types of states via Game_Enemy

I have another problem about this script section:

class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # * states #-------------------------------------------------------------------------- def states st = super for newbornstate in enemy.new_added_state st.push(newbornstate) unless newbornstate.nil? end return st.uniq endendNormally, it works, but whenever I finish my turn during battle, this error occurs:

kJcYObA.jpg


which pinpoints me to this script section:

#-------------------------------------------------------------------------- # * Update State Turn Count #-------------------------------------------------------------------------- def update_state_turns states.each do |state| @state_turns[state.id] -= 1 if @state_turns[state.id] > 0 end endWhat is wrong with my script?
Normally, states are added using add_state(state_id)

Which is when you successfully add the state, it call reset_state_counts(state_id)

Which is in reset_state_counts, there is 

@state_turns[state_id] = state.min_turns + rand(variance)In your script, you add state not by add_state

Which is that's why @state_turns[state.id] > 0 return error

Because it's nil
So what would be the correct script call for my def states? 

I added:

def states super @states.add_state($game_temp.field_effect) unless $game_temp.field_effect.nil? end and somehow another error arises about an undefined + on this script section:

Code:
  #--------------------------------------------------------------------------  # * Get Array of All Objects Retaining Features  #--------------------------------------------------------------------------  def feature_objects    super + [actor] + [self.class] + equips.compact  end
Dealing with the states is somewhat a bit painful if you aimed to have high compatibility.

But if you want to keep the script for yourself, it would be more easier.

Like, you can just change how update_state_turn works. But it's overwriting the method

Code:
def update_state_turns  states.each do |state|    next unless @state_turns[state.id]    @state_turns[state.id] -= 1 if @state_turns[state.id] > 0  endend

Original thread: https://forums.rpgmakerweb.com/threads/error-on-adding-new-types-of-states-via-game_enemy.37163/