RGSS3 Unofficial Bugfix Snippets

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Lone Wolf, Apr 3, 2012.

    Tags:
  1. Lone Wolf

    Lone Wolf Tsundere Veteran

    Messages:
    305
    Likes Received:
    60
    First Language:
    English
    I'll be using this thread to compile script snippets I've posted in the VX Ace help section. These work automatically once pasted into the Materials section, and are only tested with the default scripts. For maximum compatibility, put these before any custom scripts you may be using.

    Enemy Turn Count Fix

    By default, enemy actions are determined at the start of the round but before the turn counter is increased. This means that any monster's turn-specific actions actually execute one turn late, so actions set to happen on round 1 won't happen until round 2.

    Code:
    module BattleManager
      def self.input_start
    	if @phase != :input
    	  @phase = :input
    	  $game_troop.increase_turn
    	  $game_party.make_actions
    	  $game_troop.make_actions
    	  clear_actor
    	end
    	return !@surprise && $game_party.inputable?
      end
      def self.turn_start
    	@phase = :turn
    	clear_actor
    	make_action_orders
      end
    end
    
    A side effect of this script is that actions set to happen on turn 0 + 0 will not happen at all (though 0 + X actions will happen normally). According to the tooltip, this is the intended behavior in VX Ace.

    Randomized Enemy Self-Targeting

    By default, enemy actions set to target a member of their own group will always, without exception, target the last enemy in the list, making buffs and healing commands essentially worthless when given to groups of enemies. This patch implements an extra step to keep enemies from skipping target selection for ally actions.

    Code:
    class Game_Action
      def targets_for_friends
    	if item.for_user?
    	  [subject]
    	elsif item.for_dead_friend?
    	  if item.for_one?
    		[friends_unit.smooth_dead_target(@target_index)]
    	  else
    		friends_unit.dead_members
    	  end
    	elsif item.for_friend?
    	  if item.for_one?
    		if @target_index < 0
    		  [friends_unit.random_target]
    		else
    		  [friends_unit.smooth_target(@target_index)]
    		end
    	  else
    		friends_unit.alive_members
    	  end
    	end
      end
    end
    
    Note that this does not implement any enemy AI, it only restores the random behavior found in earlier versions of RPG Maker.

    Custom Font Junk Symbol Fix

    By default, the draw_text_ex method handles specific non-printable characters, like line breaks, but does so in such a way as to leave non-printable junk characters behind. While the normal font draws those as blank spaces, any custom fonts used will render these junk characters as character-not-found glyphs. This adds an extra step to character processing to ensure that only printable characters are drawn to the screen.

    Code:
    class Window_Base
      alias :process_normal_character_vxa :process_normal_character
      def process_normal_character(c, pos)
    	return unless c >= ' '
    	process_normal_character_vxa(c, pos)
      end
    end
    I didn't really do anything that impressive with any of the above, so you don't need to credit me in your game. But thanks are nice.

    Update: If you're using Yanfly's Core Engine Fixes with the Turn Count Fix above, put all snippets after the Core Engine and include this snippet, or the turn count will increment twice, breaking all your Battle Events.



    Code:
    module BattleManager
        class <<self
    	    alias :this_is_how_you_alias_modules :turn_start
        end
        def self.turn_start
    	    @performed_battlers = []
    	    this_is_how_you_alias_modules
        end
    end
     
    Last edited by a moderator: Apr 10, 2012
    #1
  2. TrogButtz

    TrogButtz Hamster Hamster! ~~Dance! Veteran

    Messages:
    75
    Likes Received:
    6
    Location:
    USA
    First Language:
    English
    Nice. These are a great help, thank you! Especially the enemy targeting fix, a lot of my status ailment type functions deal with random targeting, so this is a huge help. Thanks again!
     
    Last edited by a moderator: Apr 3, 2012
    #2
    sokita likes this.
  3. Kotaro

    Kotaro Übernerd Veteran

    Messages:
    164
    Likes Received:
    11
    Location:
    New England
    First Language:
    English
    Primarily Uses:
    RMMV
    Nicely done. I'll put these to use immediately; they'll certainly make things a lot easier.
     
    #3
  4. Archeia

    Archeia Level 99 Demi-fiend Staff Member Developer

    Messages:
    14,478
    Likes Received:
    14,078
    Location:
    Game Dev Salt Mines
    First Language:
    Filipino
    Primarily Uses:
    VNM
    EDIT: owo
     
    Last edited by a moderator: Aug 1, 2012
    #4
  5. Lone Wolf

    Lone Wolf Tsundere Veteran

    Messages:
    305
    Likes Received:
    60
    First Language:
    English
    I mentioned at the top that these are only tested with the default script package. I also mentioned that you should place these before any other script packages, but after the defaults. If you've done both of those things and aren't directly modifying either Game_Actor or the BattleManager, or calls to either, I don't see how any of my code could be causing the problem you describe.

    Randomized Enemy Self-Targeting doesn't affect the GUI in any way. All I've done is add an extra conditional statement to the existing code to make sure enemies don't always target the same thing, and the original code will still run if the specific conditions don't apply. The turn count fix, on the other hand, is an extremely invasive change to the very nature of the VX Ace battle system, but those two commands are also completely unrelated to the GUI. If something you wrote happened to redefine either of those methods without aliasing, however, it is theoretically possible to break something.

    Might I ask what the "bunch of GUI" changes you've done are? The first clue might be "those three commands," as by default the Party Command window has only two.
     
    #5
  6. Archeia

    Archeia Level 99 Demi-fiend Staff Member Developer

    Messages:
    14,478
    Likes Received:
    14,078
    Location:
    Game Dev Salt Mines
    First Language:
    Filipino
    Primarily Uses:
    VNM
    Ah you know, Engage, Escape and Combatlog? that was it. The other fix I added was Core Engine, so it's probably affected. I'll have to give it an indepth test soon. I think I posted this by accident while doing something and the mistake was probably below the core engine fixes oops <:3c
     
    Last edited by a moderator: Apr 4, 2012
    #6
  7. Lone Wolf

    Lone Wolf Tsundere Veteran

    Messages:
    305
    Likes Received:
    60
    First Language:
    English
    As it turns out, there was a potential compatibility issue with Yanfly's Core Engine, because he chose to duplicate Module code rather than aliasing. (I didn't alias only because I had to change the order of command execution.) But it was in the turn order fix, not enemy targeting.

    But I encountered nothing remotely like the problem you described. Even if you are a mod, please be careful with your accusations in the future.
     
    #7
  8. Chaos17

    Chaos17 Dreamer Veteran

    Messages:
    1,252
    Likes Received:
    419
    Location:
    France
    First Language:
    French
    My game crashed a lot of time today when I was testing my battle system (Jet+Yanfly+Yami ATB) with multiple different troops.

    There was no bug reported by Rpg maker just a general error from windows saying that : RGSS3 player stopped to work.

    I searched through almost my scripts which one was the culprid and which was related to battle system, though I am not 100% sure if it was the right one.

    So when I deleted your scripts, my game doesn't crashed anymore.

    My though, is that your fixes aren't compatible with a ATB system.

    Each time I removed a script, I tested my game by doing over 30 battles to check if it was the problem.

    Though, like I said I am not 100% sure that it's your bug fixes which are the cause since I've a lot of scripts and I am not a scripter.
     
    #8
  9. Lone Wolf

    Lone Wolf Tsundere Veteran

    Messages:
    305
    Likes Received:
    60
    First Language:
    English
    :blink: I come back after a long hiatus and suddenly I have a stickied thread on the official RM forums. I can die happy and fulfilled now.

    (ROLL CREDITS)

    ...

    Ahem, anyway: I mention at the top that these are fixes for the base script package only. The turn fix probably isn't compatible with an ATB system. It relies on two turn-based specific methods that any halfway decent programmer would rewrite for a more active battle system, probably fixing the bug in the process. The enemy targeting snippet and the font fix snippet have nothing to do with any of that and can be used independently. As a rule of thumb, you should only use fixes for bugs affecting your game.

    But seriously, even with all that taken into account, my scripts have nothing to do with the RGSS player crashing. If no alert window appears, it's a lower-level error than anything a script could have broken, meaning an issue with the Ruby compiler or the executable itself. It can sometimes even be the result of an elevated background process, like Fraps or an antivirus program, corrupting an instruction in memory. RGSS has always been finicky, and will crash randomly for me even on a fresh project. Just saving and reloading is usually enough for it to sort itself out.
     
    #9
    Seriel likes this.
  10. Yin

    Yin Veteran Veteran

    Messages:
    133
    Likes Received:
    50
    Location:
    NY
    First Language:
    English
    Primarily Uses:
    N/A
    The junk fix symbol fix did not work for me when it came to using my own font in battle, but if anyone is having a problem with the junk after an enemy's name, I fixed it by finding these lines in Game_Enemy:



    Code:
      #--------------------------------------------------------------------------
      # * Get Display Name
      #--------------------------------------------------------------------------
      def name
        @original_name  + (@plural ? letter : "")
      end
    and changing it to this



    Code:
    
    
     #--------------------------------------------------------------------------
      # * Get Display Name
      #--------------------------------------------------------------------------
      def name
        @original_name # + (@plural ? letter : "") <------------- I just commented the extra crap out
      end
    
    
    
    It only happens when there is more than one of the same enemy and it's supposed to add a letter to them so you can identify them from each other. With custom fonts, it just screws it up. Hope this helps someone other than myself.
     
    #10
    Kain likes this.
  11. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,048
    Location:
    Toronto
    First Language:
    English
    You need to make sure your project is not using full-width characters. A lot of people that are using (illegal) versions for some reason have a lot of issues with their project "changing" to japanese.
     
    Last edited by a moderator: Oct 24, 2012
    #11
  12. ??????

    ?????? Diabolical Codemaster Veteran

    Messages:
    6,259
    Likes Received:
    2,298
    Location:
    Your OS
    First Language:
    Binary
    Primarily Uses:
    RMMV
    there whole project just changes to Japanese ? wth lol
     
    #12
  13. Yin

    Yin Veteran Veteran

    Messages:
    133
    Likes Received:
    50
    Location:
    NY
    First Language:
    English
    Primarily Uses:
    N/A
    I had no idea lol. But that is what worked for me. I'm not sure if I'm using a full width font or not.
     
    #13
  14. Lone Wolf

    Lone Wolf Tsundere Veteran

    Messages:
    305
    Likes Received:
    60
    First Language:
    English
    I say this a lot: Hotfix BAD. Sure, changing the code at the exact point where the error occurs can keep the immediate problem from occurring, but it usually comes with a sacrifice and may make pinpointing the actual root of the problem much more difficult.

    My junk-symbol snippet only affects text drawn using draw_text_ex, which is most, but not all, text in the Ace engine. It simply culls any trash characters generated by the RGSS text-parser. There are only two places hard-coded to draw non-typable characters, and both of those rely on a flag set at project creation which identifies the system as Japanese or not.

    I present a new snippet: disable locale auto-detection. The only actual purpose of the region-detect code is to allow the default script pack to be the same for both regions ("Japan" and "Other"), and it only affects Game_Troop and Window_NameEdit, as the rest of the game's text is read from the string table, and there can only be one.



    Code:
    class Game_System
      def japanese?
        #$data_system.japanese
        false
      end
    end
    While this may prove helpful, this is an error that only shows up when System.rvdata2 is created in Japanese and edited on a non-Japanese system, which, unless this is a project you're collaborating on with someone in Japan, shouldn't be possible under normal circumstances. I have yet to trick the editor into thinking my OS is Japanese, even when most every other program out there does (Japanese system locale on an EN-US version of Windows). But hey, benefit of the doubt and all that. I've dealt with some weird impossible stuff, too.
     
    #14
    Kain likes this.
  15. DeleteMe

    DeleteMe Veteran Veteran

    Messages:
    55
    Likes Received:
    0
    First Language:
    English
    Thank you mr. bubbles Lone wolf! When I first saw the custom font fix I had no idea what it was for. But when I encountered the bug I knew immediately that this was the bug fix I needed. Thanks!

    Edit: I have no idea why i wrote Mr. Bubbles. Sorry! Once again thanks Lone wolf
     
    Last edited by a moderator: Jan 16, 2013
    #15
  16. Dark_Metamorphosis

    Dark_Metamorphosis What a horrible night to have a curse. Veteran

    Messages:
    2,194
    Likes Received:
    382
    Location:
    Sweden
    First Language:
    Swedish
    Thanks alot for this, I have a boss battle in my game that is using alot of heals and buffs.. but they always seem to target themselves or just 1 of the 3 characters in the group. With this, the battle will work as I intend it to do, and will make the fight a bit more strategical! thanks! :)
     
    #16
  17. Animebryan

    Animebryan Feels like I'm slowly dying! Veteran

    Messages:
    322
    Likes Received:
    126
    Location:
    Marysville, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    Can all of these snippets be put on 1 script page or do they need to be used separately?
     
    #17
  18. Lone Wolf

    Lone Wolf Tsundere Veteran

    Messages:
    305
    Likes Received:
    60
    First Language:
    English
    All on one page is fine, so long as you don't get your end tags mixed up. So don't accidentally paste a snippet for Game_Actor inside a snippet for BattleManager. RGSS will still run, but the snippet won't do anything.
     
    #18
  19. tiagoms

    tiagoms Veteran Veteran

    Messages:
    181
    Likes Received:
    4
    my version is a 1.0.1.2

    is necessary add this script?
     
    #19
  20. MysteryMan23

    MysteryMan23 Veteran Veteran

    Messages:
    98
    Likes Received:
    25
    First Language:
    English
    For those of you using these fixes with Yanfly's Ace Battle Engine, put these snippets below that script rather than Ace Core Engine
     
    #20

Share This Page