Number of Additional Actions on an enemy with a state?

I'm having some weird issue with a state when added to an enemy. The idea of the state is to simply give it more actions to the enemy to use on its turn.
I put it in 100% so there's obviusly 100% chance of it using a second attack/skill.
Now, for some reason, when I add the 100% additional action due to a state, it's not exactly 100%. Some time it just do 1 action.
But when I add the additional action (100%) to the enemy in it database, it work 100% of the time as long as I tested. It possible that some resistance/stat/or anything similar is making that the STATE is not giving that 100% of additional action to the enemy affected?

Also, let's say I give the enemy an additional attack in its database, if I also add this state, so long it only did 2 attacks no matter how many time I tried. I'm using the additional actions wrong?

EDIT: Okay, after more testing, I realized that when I add the state to the enemy, it doesn't get the additional attack in its first turn. But it does on its NEXT turn. Could this be some error for a script?

EDIT2: So I tested this in a blank project and yeah, for some odd reason, when you give an enemy a state that grant it an additional action, this additional action is not added to it pool moves during it first turn, it's looks like the game recalculate the number of additional action the enemy have after it finish it first turn. When it should recalculate it each time any battler finish an action/turn, at least in my opinion.
EDIT: Okay, after more testing, I realized that when I add the state to the enemy, it doesn't get the additional attack in its first turn. But it does on its NEXT turn. Could this be some error for a script?
Unless it's a ATB type of battle the extra action is not calculated until the start of the next turn, because once the actions start the system already has the actions programmed in and can't be modified, but you can add on actions with follow up skills or something like that where doing a specific action causes another to start.
Also, let's say I give the enemy an additional attack in its database, if I also add this state, so long it only did 2 attacks no matter how many time I tried. I'm using the additional actions wrong?
I could write something so that you have the additional actions set in the features but only used if the enemy has a specific state.
I wrote a similar script recently for the actors , but I could probably rework it for enemies.
I put it in 100% so there's obviusly 100% chance of it using a second attack/skill.
Now, for some reason, when I add the 100% additional action due to a state, it's not exactly 100%. Some time it just do 1 action.
I don't about that one. if the features had it set for the enemy to do two actions then it should do two.
Unless it's a ATB type of battle the extra action is not calculated until the start of the next turn, because once the actions start the system already has the actions programmed in and can't be modified
I knew it! That kind of sucks.

I could write something so that you have the additional actions set in the features but only used if the enemy has a specific state.
I wrote a similar script recently for the actors , but I could probably rework it for enemies.
Not gonna lie, that would be pretty useful!
Won't be as easy as I thought. I'll keep trying.
The other script I wrote modified the equipment features not the actor features.
So I'm trying to figure out how to block a predefined enemy feature until restrictions allow it.
I'm having some trouble with this still.
I got it working but only for the first enemy in the troop.
If you were to fight three slimes then only the first one is affected.
If you fight a slime, a bat, and a rat then all three would be affected.
Spoiler: Roninator2 - Enemy Feature Restriction
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Enemy Feature Modify         ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Adjust features for enemies       ╠════════════════════╣
# ║                                     ║    22 Jul 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║                                                          ║
# ║   Put note tag on enemy note box in order to block       ║
# ║   a feature unless the condition is true                 ║
# ║  <feature restrict: feature_id,method,value,condition>   ║
# ║   example                                                ║
# ║     <feature restrict: 2,st,15>                          ║
# ║     <feature restrict: 4,sw,50>                          ║
# ║     <feature restrict: 5,v,21,gt,5>                      ║
# ║     <feature restrict: 5,v,21,lt,5>                      ║
# ║   Feature lists starts at 0                              ║
# ║                                                          ║
# ║  Available conditions:                                   ║
# ║    st - state (state must be inflicted)                  ║
# ║    sw - switch (switch must be true)                     ║
# ║    v - variable (gt = greater than, lt = less than)      ║
# ║                                                          ║
# ║  Numbers:                                                ║
# ║    st,15 - state 15 is inflicted                         ║
# ║    sw,50 - switch 50 is true                             ║
# ║  v,21,gt,5 - variable 21 is equal to or greater than 5   ║
# ║                                                          ║
# ║  The effect:                                             ║
# ║    All features on the enemy will not work               ║
# ║    Only features not in the notetag will be available    ║
# ║    Features that are referenced in the note tag          ║
# ║    will be used or added to the enemy when the           ║
# ║    condition is true.                                    ║
# ║                                                          ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - Created script with help from Tsukihime code      ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Free for all uses in RPG Maker - Except nudity           ║
# ╚══════════════════════════════════════════════════════════╝

module R2_Class_Feature_Adjust
  Feature_Restrict = /<feature[ -_]restrict:[ ](\w+(?:\s*,\s*\w+)*)>/i
end
 
module DataManager
  class <<self
    alias load_database_original_r2_enemy_feature_adjust_mod load_database
  end
  #--------------------------------------------------------------------------
  # * Alias Load Database
  #--------------------------------------------------------------------------
  def self.load_database
    load_database_original_r2_enemy_feature_adjust_mod
    load_enemy_feature_param_mod
  end
  #--------------------------------------------------------------------------
  # * Load Enemy Feature Restrictions
  #--------------------------------------------------------------------------
  def self.load_enemy_feature_param_mod
    for obj in $data_enemies
      next if obj.nil?
      obj.load_enemy_feature_param_mod
    end
  end
end

class RPG::Enemy
  attr_accessor :feature_restrict
  #--------------------------------------------------------------------------
  # * Load Enemy Feature Restrictions
  #--------------------------------------------------------------------------
  def load_enemy_feature_param_mod
    @feature_restrict = []
    results = self.note.scan(R2_Class_Feature_Adjust::Feature_Restrict)
    results.each do |res|
      data = res[0]
      restrict = []
      for x in data.split(",")
        restrict.push(x)
      end
      @feature_restrict << restrict
    end
  end
end

class Game_Enemy
  #--------------------------------------------------------------------------
  # * Overwrite Enemy
  #--------------------------------------------------------------------------
  def enemy
    @saved_features = []
    @original_features = [] if @original_features.nil?
    orig = $data_enemies[@enemy_id]
    @original_features = orig.features if @original_features.empty?
    orig.features = @original_features
    @deleted_features = []
    @removed_features = []
    @removed_features = check_feature_restrict(orig)
    @removed_features.each do |ft|
      @deleted_features << @original_features[ft]
    end
    @original_features.each do |ef|
      next if ef.nil?
      @same = false
      code_o = ef.code
      data_o = ef.data_id
      value_o = ef.value
      @deleted_features.each do |df|
        next if df.nil?
        code_d = df.code
        data_d = df.data_id
        value_d = df.value
        if (code_d == code_o) && (data_o == data_d) && (value_o == value_d)
          @same = true
        end
      end
      @saved_features << ef if @same == false
    end
    orig.features = @saved_features
    return orig
  end
  #--------------------------------------------------------------------------
  # * New Check feature restrictions
  #--------------------------------------------------------------------------
  def check_feature_restrict(orig)
    ft_remove = []
    restrict_features = orig.feature_restrict
    restrict_features.each do |ftr|
      ft = ftr[0].to_i
      mt = ftr[1].to_s.downcase
      vl = ftr[2].to_i
      eq = ftr[3].to_s.downcase
      cd = ftr[4].to_i
      case mt
      when "st", " st"
        ft_remove.push(ft) if !state?(vl)
      when "sw", " sw"
        if $game_switches[vl] == true
          ft_remove.push(ft)
        end
      when "v", " v"
        if eq == "gt"
          if $game_variables[vl] > cd
            ft_remove.push(ft)
          end
        else
          if $game_variables[vl] < cd
            ft_remove.push(ft)
          end
        end
      end
    end
    return ft_remove
  end
end

If other ruby coders can point out where I'm doing something wrong, that would be great. Thank you
My brother in christ we don't deserve you! You're awesome.

Original thread: https://forums.rpgmakerweb.com/threads/number-of-additional-actions-on-an-enemy-with-a-state.149533/