RGSS3 Unofficial Bugfix Snippets

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
307
Reaction score
62
First Language
English
Primarily Uses
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:

TrogButtz

Hamster Hamster! ~~Dance!
Veteran
Joined
Mar 19, 2012
Messages
75
Reaction score
6
First Language
English
Primarily Uses
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:

Kotaro

Übernerd
Veteran
Joined
Mar 29, 2012
Messages
164
Reaction score
11
First Language
English
Primarily Uses
RMMV
Nicely done. I'll put these to use immediately; they'll certainly make things a lot easier.
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
307
Reaction score
62
First Language
English
Primarily Uses
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.
 

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
14,730
Reaction score
14,577
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:

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
307
Reaction score
62
First Language
English
Primarily Uses
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.
 

Chaos17

Dreamer
Veteran
Joined
Mar 13, 2012
Messages
1,253
Reaction score
421
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.
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
307
Reaction score
62
First Language
English
Primarily Uses
: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.
 

Yin

Veteran
Veteran
Joined
Jul 18, 2012
Messages
133
Reaction score
50
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.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,075
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:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,271
Reaction score
2,333
First Language
Binary
Primarily Uses
RMMV
there whole project just changes to Japanese ? wth lol
 

Yin

Veteran
Veteran
Joined
Jul 18, 2012
Messages
133
Reaction score
50
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.
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
307
Reaction score
62
First Language
English
Primarily Uses
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.
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.
 

DeleteMe

Veteran
Veteran
Joined
Dec 30, 2012
Messages
55
Reaction score
0
First Language
English
Primarily Uses
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:

Dark_Metamorphosis

What a horrible night to have a curse.
Veteran
Joined
Nov 23, 2012
Messages
2,194
Reaction score
382
First Language
Swedish
Primarily Uses
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! :)
 

Animebryan

Need more resources!
Veteran
Joined
Jul 31, 2012
Messages
351
Reaction score
165
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?
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
307
Reaction score
62
First Language
English
Primarily Uses
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.
 

tiagoms

Veteran
Veteran
Joined
May 19, 2014
Messages
181
Reaction score
4
Primarily Uses
my version is a 1.0.1.2

is necessary add this script?
 

MysteryMan23

Veteran
Veteran
Joined
Apr 2, 2012
Messages
104
Reaction score
27
First Language
English
Primarily Uses
RMMV
For those of you using these fixes with Yanfly's Ace Battle Engine, put these snippets below that script rather than Ace Core Engine
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

6.5 million beers are in need for rescue. I don't drink beer too much, but my Czech heart is sinking. It's just a pity that they priced it so high. At this price nobody is interested.
I couldn't have Taco Bell, so I grabbed a giant piece of strawberry cheesecake instead.
Guys one of our Animal Crossing Villagers (Sherb) just told us that he hoped that the villager who was having her birthday had as memorable of a birthday as his sixth birthday. Which was "the one where the clown went into our house and never came back" and that "his mother says she still sometimes hears the honking in the walls".
My tutor has been furloughed for 8 weeks. If we are too... sucks, but it's a lot of game making time...
Social distancing extended for another week. Personally I'm cool, but this is depressing.

Forum statistics

Threads
95,575
Messages
930,195
Members
125,860
Latest member
Raven019
Top