じ☆ve冰风 发表于 昨天 15:53

RGSS3 Unofficial Bugfix Snippets

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.

Spoiler                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.

Spoiler                Code:       
class Game_Action
def targets_for_friends
        if item.for_user?
          
        elsif item.for_dead_friend?
          if item.for_one?
               
          else
                friends_unit.dead_members
          end
        elsif item.for_friend?
          if item.for_one?
                if @target_index < 0
                  
                else
                  
                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.

Spoiler                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




本贴来自国际rpgmaker官方论坛作者:Lone Wolf处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/rgss3-unofficial-bugfix-snippets.1131/
页: [1]
查看完整版本: RGSS3 Unofficial Bugfix Snippets