Trying to get ctb script to work with yanflies battle engine

this might be a pretty specific request so its understandable if no ones able to help me on it, but im trying to get this ctb script by circle cross


to work with yanflies battle engine


the ctb script specifically is just an addon to this ctb script


the addon makes it so you can see enemy action bars too, the main reason i want to use this one specifically is because looking through a lot of the similar ctb/atb scripts and whatnot and this was the only one i found with what i was looking for: the ability to see the player and enemy action bars, and the bars ceasing to move when the players turn was happening or an enemy action was happening

oddly enough the main ctb script seems to play fine with the yanfly battle engine but when i add the script to see action bars it crashes, does anyone know if theres a way to make them work together?

alternatively if anyone knows a similar script out there that does the main stuff i want thatd work too, i looked pretty thoroughly through a lot of other ones but maybe i missed a nice one or didnt notice some config in another that would let me get what im looking for

EDIT: i found the script in this thread https://forums.rpgmakerweb.com/index.php?threads/fomar0153-atb-stamina-bar-on-enemies.157863/ which is an addon for fomar0153s yanfly compatible ATB sytem, its the closest alternative Ive found but comes with its own problems I dont understand: like it seems to disable multiple actions a turn and instant actions from yanflies instant cast, plus it only shows 1 bar for your whole party which is tied to the slowest member, not sure if any of that is fixable
So the crash comes from trying to get the information from the actor battler sprite, which does not exist by default.
You can simply copy over the same line from yanfly's battle engine script, because yanfly changed the battlestatus window not all information is the same.
in the enemy info addon put this below line 47 def update_bitmap
return if @battler.actor? && @battler.battler_name == ""

Also with yanfly engine you don't see the atb bar for the actor. Is that something you wanted?
in yanfly battle engine you can add in the AP display so that it shows up.
on line 1823 in the draw_item(index) method add this
draw_actor_ap(actor, rect.x + 0, rect.y, 100)
above the end line
So the crash comes from trying to get the information from the actor battler sprite, which does not exist by default.
You can simply copy over the same line from yanfly's battle engine script, because yanfly changed the battlestatus window not all information is the same.
in the enemy info addon put this below line 47 def update_bitmap
return if @battler.actor? && @battler.battler_name == ""

Also with yanfly engine you don't see the atb bar for the actor. Is that something you wanted?
in yanfly battle engine you can add in the AP display so that it shows up.
on line 1823 in the draw_item(index) method add this
draw_actor_ap(actor, rect.x + 0, rect.y, 100)
above the end line
hey cheers for the help mate, i was so happy it just worked together yesterday i must notve noticed the bars disappeared with yanfly and the base CTB script, but your code worked to fix that so thanks
though for the enemy bars im still getting a crash, i think i put the code in right but heres what it looks like in case i messed something up
in the enemy info addon put this below line 47 def update_bitmap
I meant this literally. not at the bottom of the method. also it's inside the if statement so it will crash before it runs the code to fix the issue.
So to be clear above the if statement.
I meant this literally. not at the bottom of the method. also it's inside the if statement so it will crash before it runs the code to fix the issue.
So to be clear above the if statement.

ah i got it, appreciate you taking the time help

putting that in the right spot made it stop crashing but now theres a smaller issue: whichever enemy im targetting seems to have the part of the windowskin used to highlight menu selections overlayed on them
tried messing with a few different skins but even the basic default one looks fairly jarring, know a way to revert it back to the yanfly enemy highlight? or if its easier just remove it since i might be able to use a seperate script for enemy flashing/highlighting
whichever enemy im targetting seems to have the part of the windowskin used to highlight menu selections overlayed on them
That's also happening in my test demo with just those three scripts in it.
I'll look later to see if I can remove the highlight. unless @Timtrack beats me to it

so thinking about it more, that is a default function. If the cursor box was removed then how would you know which enemy is selected?
Without the enemy info script then you get the enemy window selecting the enemy name with the cursor on it.
The enemy info simply removes the window and puts the selection on the sprite.

But to remove the cursor box you can add this to the enemy info script.
Line 204
after the def hide method
Ruby:
  #--------------------------------------------------------------------------
  # overwrite method: update_cursor
  #--------------------------------------------------------------------------
  def update_cursor
    cursor_rect.empty
  end
If you then want the enemy to be selected with something I have a script for enemy target flash, you can get it from my repositories. github, pastebin.
putting that in the right spot made it stop crashing but now theres a smaller issue: whichever enemy im targetting seems to have the part of the windowskin used to highlight menu selections overlayed on them
Yes, the script explanation is that Yanfly hides the window that show the enemy list while CTB Enemy Bars use that window to draw the ap bar but hides all the rest. The square around the battlers is the cursor of the ghost window.

I'll look later to see if I can remove the highlight. unless @Timtrack beats me to it
I did not plan on helping originally as I've never touched any ATB script, but here I am ahah

Here is my 'compatibility patch', I added the patching that @Roninator2 suggested, also fixed the mp (and potentially hp display?) that can now be floats with CTB:
Ruby:
# Yanfly Battle Engine + CTB and CTB Enemy Bars addon
#Load order:
# Yanfly Battle Engine
# CTB
# CTB Enemy bars
# This script

class Window_BattleStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # overwrite method: draw_actor_hp -> drawn hp is an int now
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, dx, dy, width = 124)
    draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
    change_color(system_color)
    cy = (Font.default_size - contents.font.size) / 2 + 1
    draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)
    draw_current_and_max_values(dx, dy+cy, width, actor.hp.to_i, actor.mhp,
                                hp_color(actor), normal_color)
  end
 
  #--------------------------------------------------------------------------
  # overwrite method: draw_actor_mp -> drawn mp is an int now
  #--------------------------------------------------------------------------
  def draw_actor_mp(actor, dx, dy, width = 124)
    draw_gauge(dx, dy, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
    change_color(system_color)
    cy = (Font.default_size - contents.font.size) / 2 + 1
    draw_text(dx+2, dy+cy, 30, line_height, Vocab::mp_a)
    draw_current_and_max_values(dx, dy+cy, width, actor.mp.to_i, actor.mmp,
                                mp_color(actor), normal_color)
  end
                           
  #--------------------------------------------------------------------------
  # alias method: draw_item -> show ap bar for actors
  #--------------------------------------------------------------------------
  alias ctb_ybe_draw_item draw_item
  def draw_item(index)
    ctb_ybe_draw_item(index)
    return if index.nil?
    actor = battle_members[index]
    return if actor.nil?
    rect = item_rect(index)
    draw_actor_ap(actor, rect.x + 0, line_height*2, rect.width-4)
  end
end #Window_BattleStatus

#for CTB Enemies Bars:

class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # alias method: update_bitmap -> ignore non-enemies
  #--------------------------------------------------------------------------
  alias ctb_ybe_update_bitmap update_bitmap
  def update_bitmap
    return ctb_ybe_update_bitmap if @battler.enemy?
    cc_enemy_info_update_bitmap #aliased method from enemy bar addon
  end
end #Sprite_Battler

class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # overwrite method: update_cursor -> never show the cursor
  #--------------------------------------------------------------------------
  def update_cursor
    return
  end
end #Window_BattleEnemy

I don't really know if that's enough, I also observed that the guard skill is locked when using CTB, is this an intended behavior?
In any case I'm unsure if Yanfly's scripts will work properly with CTB in the long run so watch out for any other potential bug, good luck!
cheers for the help guys, that script worked to fix the targetting overlay, and it went back to working like the default yanfly enemy highlight so the blink script isnt necessary, though i like it and will probably use it so thanks Roninantor

one problem remains i hadnt noticed earlier which after checking does also start when adding the enemy bar addon, the top window from the battle engine that shows enemy names + states disappeared, after testing a fair bit thats the last problem left i believe if your able to help, sorry for being such a pain

I also observed that the guard skill is locked when using CTB, is this an intended behavior?
thats because it reads skills speed stat as AP cost with 0 being the full bar and anything more setting specific cost values, since guard by default has 2000 speed it cant be used with the default max AP but setting it lower fixes it, its another feature i like from that script
I did not plan on helping originally as I've never touched any ATB script, but here I am ahah
and yet your solution is far better than what I was thinking of doing.

the top window from the battle engine that shows enemy names + states disappeared,
this is because the enemy addon does not have the @help_window.show command.
Even though it is aliased it is not getting processed.
You can add it into the enemy info script.
at the bottom
Ruby:
#==============================================================================
# □ Scene_Battle
#------------------------------------------------------------------------------
#  This class handles battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ○ Start of enemy character selection
  #--------------------------------------------------------------------------
  alias cc_enemy_info_select_enemy_selection select_enemy_selection
  def select_enemy_selection
    cc_enemy_info_select_enemy_selection
    @skill_window.hide
    @item_window.hide
    @help_window.show
  end
  #--------------------------------------------------------------------------
  # ○ Enemy character [Cancel]
  #--------------------------------------------------------------------------
  alias cc_enemy_info_on_enemy_cancel on_enemy_cancel
  def on_enemy_cancel
    cc_enemy_info_on_enemy_cancel
    case @actor_command_window.current_symbol
    when :skill
      @skill_window.show
    when :item
      @item_window.show
    end
    if @skill_window.visible || @item_window.visible
      @help_window.show
    else
      @help_window.hide
    end
  end
end
and yet your solution is far better than what I was thinking of doing.


this is because the enemy addon does not have the @help_window.show command.
Even though it is aliased it is not getting processed.
You can add it into the enemy info script.
at the bottom
Ruby:
#==============================================================================
# □ Scene_Battle
#------------------------------------------------------------------------------
#  This class handles battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ○ Start of enemy character selection
  #--------------------------------------------------------------------------
  alias cc_enemy_info_select_enemy_selection select_enemy_selection
  def select_enemy_selection
    cc_enemy_info_select_enemy_selection
    @skill_window.hide
    @item_window.hide
    @help_window.show
  end
  #--------------------------------------------------------------------------
  # ○ Enemy character [Cancel]
  #--------------------------------------------------------------------------
  alias cc_enemy_info_on_enemy_cancel on_enemy_cancel
  def on_enemy_cancel
    cc_enemy_info_on_enemy_cancel
    case @actor_command_window.current_symbol
    when :skill
      @skill_window.show
    when :item
      @item_window.show
    end
    if @skill_window.visible || @item_window.visible
      @help_window.show
    else
      @help_window.hide
    end
  end
end
played around a couple hours with this and everythings working well, youve both been great help

gonna wait a couple more hours to report the thread solved in case i run into anything, but its looking pretty good

cheers

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-get-ctb-script-to-work-with-yanflies-battle-engine.181014/