minor issue with battle mist script

hey this is a problem slightly related to https://forums.rpgmakerweb.com/inde...t-to-work-with-yanflies-battle-engine.181014/

but since it involves a different script i figured making a new thread might be better than asking for the other one to be re-opened (sorry if thats incorrect)

what im trying to do is use this battle mist script

with the CTB enemy display script from the above thread

the minor issue is that the mist graphic which is supposed to display over enemies is being shown behind them, i confirmed that the mist script works with everything else im using and its just the CTB enemy display script causing the problem

i found 1 'fix' for it by setting the viewport4.z on line 67 of the enemy display script to -1 (which made enemies display behind the battleback but DID make the fog go over them properly when the back was empty) but i figure someone who knows what they're doing could probably tell me a better way to fix it without having to disable all battlebacks
have you tried changing the order of the two scripts involved?
in a lot of ways the z-priority is influenced by the draw order, and depending on where the scripts attach themselves to the engine (I haven't checked that) it can be influenced by the script order.
have you tried changing the order of the two scripts involved?
in a lot of ways the z-priority is influenced by the draw order, and depending on where the scripts attach themselves to the engine (I haven't checked that) it can be influenced by the script order.
yeah i tried moving the mist script above and below the CTB enemy script in an otherwise empty test game and to the top and bottom of my main list of scripts and it was the same every time
Hey,

The sprite is over the mist is because the CTB enemy bar script changes the viewport for battlers sprites (actors and enemies):
Ruby:
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ○ ビューポートの作成
  #--------------------------------------------------------------------------
  alias cc_enemy_info_create_viewports create_viewports
  def create_viewports
    cc_enemy_info_create_viewports
    @viewport4 = Viewport.new
    @viewport4.z = 0
  end
  #--------------------------------------------------------------------------
  # ○ 敵キャラスプライトの作成
  #--------------------------------------------------------------------------
  def create_enemies
    @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
      Sprite_Battler.new(@viewport4, enemy)
    end
  end
  #--------------------------------------------------------------------------
  # ○ アクタースプライトの作成
  #    デフォルトではアクター側の画像は表示しないが、便宜上、敵と味方を同じ
  #  ように扱うためにダミーのスプライトを作成する。
  #--------------------------------------------------------------------------
  def create_actors
    @actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport4) }
  end
  #--------------------------------------------------------------------------
  # ○ ビューポートの更新
  #--------------------------------------------------------------------------
  alias cc_enemy_info_update_viewports update_viewports
  def update_viewports
    cc_enemy_info_update_viewports
    @viewport4.tone.set($game_troop.screen.tone)
    @viewport4.ox = $game_troop.screen.shake
    @viewport4.update
  end
end

I don't understand why the scripter did that, I commented the whole Spriteset_Battle class from the script and it seems to have fixed the issue, I am unsure why they changed the viewport.

So, you can either comment the section I mentioned or add this scriptlet below:
Ruby:
#put this script below CTB Enemy Bars to put back the sprites behind mist or
#other effects

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # overwrite method: create_viewports -> restore original behavior
  #--------------------------------------------------------------------------
  def create_viewports
    cc_enemy_info_create_viewports #aliased method from CTB Enemy
  end
  #--------------------------------------------------------------------------
  # overwrite method: create_enemies -> restore original behavior
  #--------------------------------------------------------------------------
  def create_enemies
    @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
      Sprite_Battler.new(@viewport1, enemy)
    end
  end
  #--------------------------------------------------------------------------
  # overwrite method: create_actors -> restore original behavior
  #--------------------------------------------------------------------------
  def create_actors
    @actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport1) }
  end
  #--------------------------------------------------------------------------
  # overwrite method: update_viewports -> restore original behavior
  #--------------------------------------------------------------------------
  def update_viewports
    cc_enemy_info_update_viewports #aliased method from CTB Enemy
  end
end #Spriteset_Battle
Hey,

The sprite over the mist is because the CTB enemy bar script changes the viewport for battlers sprites (actors and enemies):
Ruby:
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ○ ビューポートの作成
  #--------------------------------------------------------------------------
  alias cc_enemy_info_create_viewports create_viewports
  def create_viewports
    cc_enemy_info_create_viewports
    @viewport4 = Viewport.new
    @viewport4.z = 0
  end
  #--------------------------------------------------------------------------
  # ○ 敵キャラスプライトの作成
  #--------------------------------------------------------------------------
  def create_enemies
    @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
      Sprite_Battler.new(@viewport4, enemy)
    end
  end
  #--------------------------------------------------------------------------
  # ○ アクタースプライトの作成
  #    デフォルトではアクター側の画像は表示しないが、便宜上、敵と味方を同じ
  #  ように扱うためにダミーのスプライトを作成する。
  #--------------------------------------------------------------------------
  def create_actors
    @actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport4) }
  end
  #--------------------------------------------------------------------------
  # ○ ビューポートの更新
  #--------------------------------------------------------------------------
  alias cc_enemy_info_update_viewports update_viewports
  def update_viewports
    cc_enemy_info_update_viewports
    @viewport4.tone.set($game_troop.screen.tone)
    @viewport4.ox = $game_troop.screen.shake
    @viewport4.update
  end
end

I don't understand why the scripter did that, I commented the whole Spriteset_Battle class from the script and it seems to have fixed the issue, I am unsure why they changed the viewport.

So, you can either comment the section I mentioned or add this scriptlet below:
Ruby:
#put this script below CTB Enemy Bars to put back the sprites behind mist or
#other effects

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # overwrite method: create_viewports -> restore original behavior
  #--------------------------------------------------------------------------
  def create_viewports
    cc_enemy_info_create_viewports #aliased method from CTB Enemy
  end
  #--------------------------------------------------------------------------
  # overwrite method: create_enemies -> restore original behavior
  #--------------------------------------------------------------------------
  def create_enemies
    @enemy_sprites = $game_troop.members.reverse.collect do |enemy|
      Sprite_Battler.new(@viewport1, enemy)
    end
  end
  #--------------------------------------------------------------------------
  # overwrite method: create_actors -> restore original behavior
  #--------------------------------------------------------------------------
  def create_actors
    @actor_sprites = Array.new(4) { Sprite_Battler.new(@viewport1) }
  end
  #--------------------------------------------------------------------------
  # overwrite method: update_viewports -> restore original behavior
  #--------------------------------------------------------------------------
  def update_viewports
    cc_enemy_info_update_viewports #aliased method from CTB Enemy
  end
end #Spriteset_Battle
works like a charm, cheers for the help!

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/minor-issue-with-battle-mist-script.181121/