Need Help With Yanfly's Buff & State Manager Script

I wanted to use Yanfly's script here to give better control for the buffs and debuffs so I can have skills like Haste, to increase agility, and Slow, to decrease it, as well as defense and other stats. However with no demo for this script I have to rely on the screenshots listed in the above link, and despite following said screenshots (as in I copied everything written from them from the note tags to enemy tags) the game does not show these stats changing whatsoever.

I am using Venka's Bestiary here that does show every stat upon scanning the enemies. No matter what I do or what I change, these stats do not change and the buffs/debuffs don't seem to be affected. Could someone look at these two scripts and see if you can spot the problem? If the problem isn't between the scripts, and work for you separate from my project, I'll know the problem isn't these two scripts, but something else and if that's the case I'll share an edited demo for you to look through with the tilesets I've purchased removed.

Spoiler: Screenshots
1681864941887.png
1681864985340.png
1681865161542.png
1681865185702.png
A couple of things here.
Your screenshot is showing the enemy scan in battle.
So you have to ask if the stats being shown are because the bestiary is showing database stats or if the debuff script is not working for your project, and yes I understand that the states are only for the enemies in battle, but depending on how things work together it could push the updated stats to the bestiary.
This is from not looking at any code.

Inspecting Venka script...

The Scan window is a child of the bestiary stats window.
in bestiary stats it is using $data_enemies[enemy_id]
Not the battle enemy, the database enemy.

You could try adding into the bestiary script line 1224 for the def enemy_id=(enemy_id)
@enemy = SceneManager.scene.enemy_window.enemy if (SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.enemy_window.active)
Not tested, just taking a look at yanfly's enemy target info script.


Doesn't work enemy window is not active at that moment.
Moved to: RGSSx Script Support
A couple of things here.
Your screenshot is showing the enemy scan in battle.
So you have to ask if the stats being shown are because the bestiary is showing database stats or if the debuff script is not working for your project, and yes I understand that the states are only for the enemies in battle, but depending on how things work together it could push the updated stats to the bestiary.
This is from not looking at any code.

Inspecting Venka script...

The Scan window is a child of the bestiary stats window.
in bestiary stats it is using $data_enemies[enemy_id]
Not the battle enemy, the database enemy.

You could try adding into the bestiary script line 1224 for the def enemy_id=(enemy_id)
@enemy = SceneManager.scene.enemy_window.enemy if (SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.enemy_window.active)
Not tested, just taking a look at yanfly's enemy target info script.
That does show the stats being affected, however if I select an enemy to see the stats before scanning, I get this.

Spoiler
1681943053186.png
1681943076469.png

Did I write this right?

Spoiler
#----------------------------------------------------------------------------
# ○ new method: enemy_id
#----------------------------------------------------------------------------
def enemy_id=(enemy_id)
return @enemy = nil if enemy_id == 0
if @enemy != $data_enemies[enemy_id]
@enemy = $data_enemies[enemy_id]
refresh
@enemy = SceneManager.scene.enemy_window.enemy if
( SceneManager.scene_is?(Scene_Battle) &&
SceneManager.scene.enemy_window.active)
end
end

And sorry I posted this in the wrong forum. ^^;

BEGIN OF EDIT:
While the window for the stats during battle does indeed show the stats for the enemy being changed, the skill it uses does not raise it at all. Can you tell me exactly how the

<max buff stat: +x>
<max buff stat: -x>

<max debuff stat: +x>
<max debuff stat: -x>

actually works? I'm a bit confused on how they work, as you gotta add them on the enemy and skill note tags, and Yanfly utterly fails in explaining how this script exactly works. Maybe I'm just terrible at math.
:END OF EDIT
<max buff stat: +x>
Reading this by itself can be confusing but when you also read the MAXIMUM_BUFF_LIMIT
down on line 266, it become a little bit clearer.
The note tag will restrict how many times that particular stat can be buffed.
So it you had <max buff atk: +1>
then you can only add a buff to the atk stat once. The next time the stat is attempted to be buffed will not apply.

If you want to send me in a PM your updated scripts file then I can play with a battle and see if I can find if this is working or not, but also describe what you are doing or send the troops file, or enemy file or the map file. Not sure where you do the battle from what troop event you are using or what enemy or what skill.
Either bestiary_include? doesn't exist or there's something wrong with @enemy.shown_id...
I have no idea why it's causing an issue as when I put p(@enemy.shown_id) it works fine, but gives me the same error for the same line.
In the script on line 551 if I add in attr_reader :shown_id then the problem goes away.

I also figure out the enemy_window option I was suggesting, however it won't work as the script is looking for specific data and the enemy_window gives Game_Enemy while the original code gets the RPG::Enemy
So in short I don't think you will ever get it to show lowered stats when they are buffed or debuffed.
But at the same time it actually doesn't look like they are getting debuffed.
I'll look more later.
This is weird because the demo points to a line of code totally different to the one you mentioned above.

Ruby:
class Window_BattleScan < Window_BestiaryStats
  #----------------------------------------------------------------------------
  # ♦ Public Instance Variables
  #----------------------------------------------------------------------------
  attr_accessor    :show_stats
  #----------------------------------------------------------------------------
  # ● upgraded method: initialize
  #----------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
  end
  #----------------------------------------------------------------------------
  # ● upgraded method: refresh
  #----------------------------------------------------------------------------
  def refresh
    contents.clear
    return if @enemy.nil?
    if $game_party.bestiary_include?(@enemy.shown_id)
      @y = 0
      case @index
      when 0; draw_basic_stats
      when 1; draw_enemy_resists # <=== THIS ONE IS LINE 1600 !!
      when 2; draw_enemy_states
      when 3; draw_debuff_rates
      end
    else
      set_bestiary_font(:stat_name)
      text = Venka::Bestiary::No_Info
      draw_text(0, 0, contents.width, contents.height, text, 1)
    end
  end
  #----------------------------------------------------------------------------
  # ○ new method: draw_basic_stats
  #----------------------------------------------------------------------------
  def draw_basic_stats
    determine_window_height(4)
    8.times {|stat| draw_stat(stat, :stat)}
  end
  #----------------------------------------------------------------------------
  # ○ new method: draw_enemy_resists
  #----------------------------------------------------------------------------
  def draw_enemy_resists
    elements = Venka::Bestiary::Elements
    height = (elements.size / 2) + (elements.size % 2)
    determine_window_height(height)
    get_revealed_resists
    (elements.size).times {|i| draw_ele_info(i, elements[i], info_rect(i))}
  end
  #----------------------------------------------------------------------------
  # ○ new method: draw_enemy_states
  #----------------------------------------------------------------------------
  def draw_enemy_states
    states = Venka::Bestiary::States
    height = (states.size / 2) + (states.size % 2)
    determine_window_height(height)
    (states.size).times {|i| draw_state_info(i, states[i], info_rect(i))}
  end
  #----------------------------------------------------------------------------
  # ○ new method: draw_debuff_rates
  #----------------------------------------------------------------------------
  def draw_debuff_rates
    determine_window_height(4)
    8.times {|stat| draw_stat(stat, :debuff)}
  end
end
This is weird because the demo points to a line of code totally different to the one you mentioned above.
you mean venka bestiary?
1682416696000.png
So I spent a few hours on this yesterday and figured out (admittedly to my own lack of intelligence or maybe just understanding as to what the venka bestiary does),
there is a misconception with the venka bestiary script.
The bestiary will show the enemy stats and features that are configured in the database. It will not look at the current enemy that is in battle.
It simply gets the enemy id and loads the database information.
So the debuffs window on the enemy scan is showing any features that have debuff's applied to them.
If you apply a debuff to an enemy in battle this will not be considered for the scan window.

The bestiary script needs to be rewritten to have that as a possibility.
My tests of the buff and state manager seems to work fine (test project).

Once a new script or modification of venka bestiary is made then this should be solved.
So I spent a few hours on this yesterday and figured out (admittedly to my own lack of intelligence or maybe just understanding as to what the venka bestiary does),
there is a misconception with the venka bestiary script.
The bestiary will show the enemy stats and features that are configured in the database. It will not look at the current enemy that is in battle.
It simply gets the enemy id and loads the database information.
So the debuffs window on the enemy scan is showing any features that have debuff's applied to them.
If you apply a debuff to an enemy in battle this will not be considered for the scan window.

The bestiary script needs to be rewritten to have that as a possibility.
My tests of the buff and state manager seems to work fine (test project).

Once a new script or modification of venka bestiary is made then this should be solved.

If anyone has the time and skill for scripting, could you help in making this work?

Sorry I've been away from this post. Life just got pretty busy.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-yanflys-buff-state-manager-script.156794/