Undefeated Hidden Enemies Visual Fix

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by DerTraveler, Aug 28, 2013.

  1. DerTraveler

    DerTraveler Veteran Veteran

    Messages:
    48
    Likes Received:
    38
    Location:
    Osaka, Japan
    First Language:
    German
    Hello everybody,

    I don't know if anyone else notices this - but it was bugging me right from the beginning, when I was playing around with battles, that have halfway appearing enemies.


    Introduction

    When you flee from a battle (Thanks to Mihel for pointing that out) before all halfway appearing enemies are summoned, there is a short moment just before the battle ends, when you will see the whole enemy party on the battle screen. This is now fixed.

    How to use
    Just paste the Script anywhere in the Materials section.

    Screenshots & Demo

    Unneccessary...

    Compatibility issues?
    There shouldn't be any. If you use any battle system apart from the default one or Yanfly's Battle Engine Ace, you should check the overwritten method just in case.

    The Script

    Code:
    #==============================================================================
    #
    # "Undefeated Hidden Enemies Visual Fix"
    # Version 1.1
    # Last Update: September 2nd, 2013
    # Author: DerTraveler (dertraveler [at] gmail.com)
    #
    #==============================================================================
    #
    # Description:
    #
    # Fixes a small visual bug concerning hidden enemies that haven't appeared.
    # Without the fix these enemies would appear for a very short moment before the
    # battle ends, when the party flees from combat.
    #
    #==============================================================================
    #
    # How to use:
    #
    # Just paste it anywhere in the Materials section.
    #
    #==============================================================================
    #
    # Changelog:
    #   1.1:
    #     - Change the implementation of Game_Enemy only instead of Game_Battler
    #       and SceneManager, which were unneccessarily central changes.
    #       Thanks to Mihel & Tsukihime for pointing out that the bug only occurs
    #       when fleeing from battle and for hints regarding the cause of the
    #       problem.
    #
    # Compatibility:
    #
    # Overwrites  - Game_Enemy: on_battle_end
    #
    #==============================================================================
    #
    # Terms of use:
    #
    # - Free to use in any commercial or non-commercial project.
    # - Please mail me if you find bugs so I can fix them.
    # - If you have feature requests, please also mail me, but I can't guarantee
    #   that I will add every requested feature.
    # - You don't need to credit me, if you don't want to for some reason, since
    #   it's only a bugfix of a standard RPG Maker behaviour.
    #
    #==============================================================================
    class Game_Enemy < Game_Battler   
      # Identically to the implementation in Game_BattlerBase except of the removed
      # call to 'appear' in the end, which is unneccessary since the data of
      # defeated enemies aren't reused anywhere else.
      def on_battle_end
       @result.clear
       remove_battle_states   
       remove_all_buffs   
       clear_actions   
       clear_tp unless preserve_tp?
      end
    end
     
     
    Last edited by a moderator: Dec 23, 2018
    #1
    Mihel and Shaz like this.
  2. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,060
    Location:
    Toronto
    First Language:
    English
    I am unable to reproduce the bug.


    I am not using any custom scripts.
     
    Last edited by a moderator: Aug 29, 2013
    #2
  3. Archeia

    Archeia Level 99 Demi-fiend Staff Member Developer

    Messages:
    14,553
    Likes Received:
    14,238
    Location:
    Game Dev Salt Mines
    First Language:
    Filipino
    Primarily Uses:
    VNM
    I think this occurred to me in VX and sometimes at VXAce but I can't reproduce it. Nice to know there's a fix :3
     
    #3
  4. DerTraveler

    DerTraveler Veteran Veteran

    Messages:
    48
    Likes Received:
    38
    Location:
    Osaka, Japan
    First Language:
    German
    Very very strange...
    I also tried to reproduce it just now (with all the other scripts included) with the fix commented out and it doesn't happen to me either....
    In a brand new game the same....

    But I can clearly remember that many of not most of the times when I finished the battle before the remaining enemies had appeared, that this bug would happen...
     
    #4
  5. Mihel

    Mihel Veteran Veteran

    Messages:
    384
    Likes Received:
    45
    It happens to me ALL the times when I flee a battle.

    This fixed it, thanks a lot.
     
    #5
  6. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,060
    Location:
    Toronto
    First Language:
    English
    I would suggest something like this instead since the issue is strictly related to escaping.

    Rather than overwriting SceneManager and Game_Battler methods and removing stuff that might be used by other things.

    Code:
    module BattleManager  class << self    alias :th_hidden_enemy_visual_bug_process_abort :process_abort  end  def self.process_abort    wait_for_message    th_hidden_enemy_visual_bug_process_abort  endend
     
    Last edited by a moderator: Aug 30, 2013
    #6
    Mihel likes this.
  7. DerTraveler

    DerTraveler Veteran Veteran

    Messages:
    48
    Likes Received:
    38
    Location:
    Osaka, Japan
    First Language:
    German
    Updated the fix and made it much much easier and without any big changes to central classes...

    Thanks to Mihel and Tsukihime for pointing out the problem and for giving me ideas to improve the implementation... (The first one was actually really embarassing in terms of object orientation principles and global changes, considering that I should know much better as a CS major ;) )....

    For any scripter/programmer who is interested:

    Actually the whole on_battle_end method for Troops is quite unneccessary since the objects aren't reused anytime later, so probably it could just be overwritten with an empty method without any negative effects, although I haven't examined all dependencies yet.

    The call of appear at the end of the method normally should produce this bug everytime a battle is ended, but in most cases the Scene is changed fast enough to not see any strange hidden enemies appear.

    The only exception is fleeing...

    module BattleManager... #-------------------------------------------------------------------------- # * Escape Processing #-------------------------------------------------------------------------- def self.process_escape $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name)) success = @preemptive ? true : (rand < @escape_ratio) Sound.play_escape if success process_abort else @escape_ratio += 0.1 $game_message.add('\.' + Vocab::EscapeFailure) $game_party.clear_actions end wait_for_message # <- the culprit return success end...endIn this case the on_battle_end-call (called in process_abort) actually happens before the message is shown completely (in case of winning or losing this is not the case - the call to on_battle_end is always after the message). Thus the appearance of hidden enemies is completed even before you have the chance to press enter to close the escape message.
     
     
    #7
    Tsukihime likes this.
  8. DJ-0zymandias

    DJ-0zymandias Absolute God of Hyperdeath Member

    Messages:
    8
    Likes Received:
    0
    First Language:
    English
    Actually, I found a better fix for this that also removes the flee spoiler. I simply moved the "wait_for_message" call to before the conditional.
     
    #8
  9. Shaz

    Shaz Veteran Veteran

    Messages:
    37,552
    Likes Received:
    11,260
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm reposting the code from the OP as it was messed up with the forum upgrade.

    Code:
    #==============================================================================
    # 
    # "Undefeated Hidden Enemies Visual Fix"
    # Version 1.1
    # Last Update: September 2nd, 2013
    # Author: DerTraveler (dertraveler [at] gmail.com)
    #
    #==============================================================================
    #
    # Description:
    #
    # Fixes a small visual bug concerning hidden enemies that haven't appeared.
    # Without the fix these enemies would appear for a very short moment before the
    # battle ends, when the party flees from combat.
    #
    #==============================================================================
    #
    # How to use:
    # 
    # Just paste it anywhere in the Materials section.
    #
    #==============================================================================
    #
    # Changelog:
    #   1.1:
    #     - Change the implementation of Game_Enemy only instead of Game_Battler
    #       and SceneManager, which were unneccessarily central changes.
    #       Thanks to Mihel & Tsukihime for pointing out that the bug only occurs
    #       when fleeing from battle and for hints regarding the cause of the
    #       problem.
    #
    # Compatibility:
    #
    # Overwrites  - Game_Enemy: on_battle_end
    #
    #==============================================================================
    #
    # Terms of use:
    #
    # - Free to use in any commercial or non-commercial project.
    # - Please mail me if you find bugs so I can fix them.
    # - If you have feature requests, please also mail me, but I can't guarantee
    #   that I will add every requested feature.
    # - You don't need to credit me, if you don't want to for some reason, since
    #   it's only a bugfix of a standard RPG Maker behaviour.
    #
    #==============================================================================
    class Game_Enemy < Game_Battler   
      # Identically to the implementation in Game_BattlerBase except of the removed 
      # call to 'appear' in the end, which is unneccessary since the data of 
      # defeated enemies aren't reused anywhere else. 
      def on_battle_end
        @result.clear 
        remove_battle_states   
        remove_all_buffs   
        clear_actions   
        clear_tp unless preserve_tp? 
      end
    end 
     
    #9
    Nightblade50 likes this.

Share This Page