changing 'fail to flee' text

skyerobyn

Warper
Member
Joined
May 31, 2015
Messages
2
Reaction score
0
First Language
english
Primarily Uses
i'm new to these boards, and to rpg making in general, so sorry if this seems really easy. i've been basically playing round, and trying various things, and have got stuck on something that seemed it should be easy. after a battle, if you fail to escape you get this message "However, it was unable to escape!". i'd like to change 'it' to instead be the character name, but can't figure out how (outside of typing it in manually, which doesn't allow for different names) and my searches have proved useless.

if someone could tell me if/how i could accomplish this, as well as why/how that works (so i can apply the idea to other things if necessary), that would be great.

thanks in advance,

skye
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
The message itself is part of the vocab script and you can make simple changes in the script editor.


However, adding an actor name into a vocab that is not intended for one is not a simple change, that requires programming knowledge and changes in the battlemanager script in addition to changes in vocab.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
The problem is in the method 'process_escape' within the 'BattleManager' module. I have added some comments to the code below to sort of help explain what is going on (hopefully).

Code:
  #--------------------------------------------------------------------------  # * Escape Processing  #--------------------------------------------------------------------------  def self.process_escape    # '$game_message.add' outputs a modified version of the EscapeStart text to the message buffer.    # The 'sprintf' command basically takes the 'EscapeStart' text and replaces the '%s' -- an indicator    # for 'string' -- with the text output of the 'name' method within 'Game_Party' ('Eric', or 'Eric's Party').     $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      # Here is the primary issue. Unlike line 222, 'sprintf' is not used on 'EscapeFailure', and no      # string indicator ('%s') is even in the failure text by default. So, what we need to do is change      # 'EscapeFailure' to include '%s' where the name should be inserted.      $game_message.add('\.' + Vocab::EscapeFailure)      $game_party.clear_actions    end    wait_for_message    return success  end
The following scriptlet should allow for what you are wanting. For the purposes of compatibility, I have chosen to use a round-about way to alter the 'process_escape' method.

Code:
#==============================================================================# ** Vocab#------------------------------------------------------------------------------#  This module defines terms and messages. It defines some data as constant# variables. Terms in the database are obtained from $data_system.#==============================================================================module Vocab  # Since the script is going to over-write the actual 'EscapeFailure' constant,  # I created a copy with the only difference being the added string indicator ('%s')  # and an underscore in the name.  EscapeFailure_   = "However, %s was unable to escape!"  end # Vocab#==============================================================================# ** BattleManager#------------------------------------------------------------------------------#  This module manages battle progress.#==============================================================================module BattleManager  #--------------------------------------------------------------------------  # * ALIAS - Escape Processing  #--------------------------------------------------------------------------  class << self    unless method_defined?(:battle_Y1oisDRH_battle_manager_process_escape)      alias_method(:battle_Y1oisDRH_battle_manager_process_escape, :process_escape)    end  end    def self.process_escape(*args, &block)    # Here I perform the 'sprintf' text replacement using the copied 'EscapeFailure_'     # constant, then use 'const_set' to over-write the actual 'EscapeFailure' constant    # which the following aliased command will use.     Vocab.const_set("EscapeFailure", sprintf(Vocab::EscapeFailure_, $game_party.name))        battle_Y1oisDRH_battle_manager_process_escape(*args, &block)  end  end # BattleManager
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

skyerobyn

Warper
Member
Joined
May 31, 2015
Messages
2
Reaction score
0
First Language
english
Primarily Uses
The problem is in the method 'process_escape' within the 'BattleManager' module. I have added some comments to the code below to sort of help explain what is going on (hopefully).

#-------------------------------------------------------------------------- # * Escape Processing #-------------------------------------------------------------------------- def self.process_escape # '$game_message.add' outputs a modified version of the EscapeStart text to the message buffer. # The 'sprintf' command basically takes the 'EscapeStart' text and replaces the '%s' -- an indicator # for 'string' -- with the text output of the 'name' method within 'Game_Party' ('Eric', or 'Eric's Party'). $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 # Here is the primary issue. Unlike line 222, 'sprintf' is not used on 'EscapeFailure', and no # string indicator ('%s') is even in the failure text by default. So, what we need to do is change # 'EscapeFailure' to include '%s' where the name should be inserted. $game_message.add('\.' + Vocab::EscapeFailure) $game_party.clear_actions end wait_for_message return success endThe following scriptlet should allow for what you are wanting. For the purposes of compatibility, I have chosen to use a round-about way to alter the 'process_escape' method.

Code:
#==============================================================================# ** Vocab#------------------------------------------------------------------------------#  This module defines terms and messages. It defines some data as constant# variables. Terms in the database are obtained from $data_system.#==============================================================================module Vocab  # Since the script is going to over-write the actual 'EscapeFailure' constant,  # I created a copy with the only difference being the added string indicator ('%s')  # and an underscore in the name.  EscapeFailure_   = "However, %s was unable to escape!"  end # Vocab#==============================================================================# ** BattleManager#------------------------------------------------------------------------------#  This module manages battle progress.#==============================================================================module BattleManager  #--------------------------------------------------------------------------  # * ALIAS - Escape Processing  #--------------------------------------------------------------------------  class << self    unless method_defined?(:battle_Y1oisDRH_battle_manager_process_escape)      alias_method(:battle_Y1oisDRH_battle_manager_process_escape, :process_escape)    end  end    def self.process_escape(*args, &block)    # Here I perform the 'sprintf' text replacement using the copied 'EscapeFailure_'     # constant, then use 'const_set' to over-write the actual 'EscapeFailure' constant    # which the following aliased command will use.     Vocab.const_set("EscapeFailure", sprintf(Vocab::EscapeFailure_, $game_party.name))        battle_Y1oisDRH_battle_manager_process_escape(*args, &block)  end  end # BattleManager
thanks very much for all the help! i had an idea that it was something in BattleManager that was determining what to use for %s, but couldn't figure it out, didn't guess it was the sprintf command.

i've pasted in your script and it's working great! would you be able to do a similar thing with something other than 'game_party', and how would you figure out what it would need to be called? say if you were to use a specific actor name instead?

would it be too much to ask what the bits above and below the explained script in the BattleManager escape processing alias mean? if it's a good idea to do aliases for the sake of compatibility when making these kinds of edits, i'd love to know how they work too, if it's not too much trouble.

would i be right in thinking that to do it without an alias you would just change "$game_message.add('\.' + Vocab::EscapeFailure)" to "$game_message.add('\.' + sprintf(Vocab::EscapeFailure, $game_party.name)), and replace "it" in the vocab with "%s"?

sorry for putting this in the wrong forum, i'll be more careful in the future.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top