Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Two requests for scripting support

Hi guys, there are two things that I need.
(Working on RMXP RGSS)
One is rather simple, I just need to know how you change the "HP" to something else IN THE MIDDLE of the game by calling a script.
Second thing is much more complicated.
You see, I am making a tactical part in my game, and I need something like GubiD's TBS, but only for movement, I mean that when you attack, it will go to Battle Scene.
Credit is promised!

Thank you all!
 
Code:
# word changue in mid-game, by wep!

 

class Game_System

  attr_reader   :map_interpreter          # Intérprete de eventos en mapa

  attr_reader   :battle_interpreter       # Intérprete de eventos en batalla

  attr_accessor :timer                    # Temporizador

  attr_accessor :timer_working            # Temporizador funcionando

  attr_accessor :save_disabled            # Llamada a Guardar deshabilitado

  attr_accessor :menu_disabled            # Llamada a Menú deshabilitado

  attr_accessor :encounter_disabled       # Encuentro de enemigos deshabilitado

  attr_accessor :message_position         # Opción de Mensaje:Posición de la Ventana

  attr_accessor :message_frame            # Opción de Mensaje: Marco

  attr_accessor :save_count               # Contador de Partidas Guardadas

  attr_accessor :magic_number             # Número de Magia

  attr_reader   :new_hp_word      

  

  alias newsystem initialize

  

  def initialize

    @map_interpreter = Interpreter.new(0, true)

    @battle_interpreter = Interpreter.new(0, false)

    @timer = 0

    @timer_working = false

    @save_disabled = false

    @menu_disabled = false

    @encounter_disabled = false

    @message_position = 2

    @message_frame = 0

    @save_count = 0

    @magic_number = 0

    @new_hp_word = " "

  end

 

  def change_hp_word(word)

   @new_hp_word = word

   $data_system.words.hp = word

  end

end

 

class Scene_Load < Scene_File

  

  #--------------------------------------------------------------------------

  # * Read Save Data

  #     file : file object for reading (opened)

  #--------------------------------------------------------------------------

  alias newread read_save_data

  def read_save_data(file)

    # Read character data for drawing save file

    characters = Marshal.load(file)

    # Read frame count for measuring play time

    Graphics.frame_count = Marshal.load(file)

    # Read each type of game object

    $game_system        = Marshal.load(file)

    $game_switches      = Marshal.load(file)

    $game_variables     = Marshal.load(file)

    $game_self_switches = Marshal.load(file)

    $game_screen        = Marshal.load(file)

    $game_actors        = Marshal.load(file)

    $game_party         = Marshal.load(file)

    $game_troop         = Marshal.load(file)

    $game_map           = Marshal.load(file)

    $game_player        = Marshal.load(file)

    # If magic number is different from when saving

    # (if editing was added with editor)

    if $game_system.magic_number != $data_system.magic_number

      # Load map

      $game_map.setup($game_map.map_id)

      $game_player.center($game_player.x, $game_player.y)

    end

    # Refresh party members

    $game_party.refresh

    # Changes $data word based on $game loaded

    $game_system.change_hp_word($game_system.new_hp_word)

  end

end
About the first thing, quick & dirty but works. Paste it before main script
call this script:
$game_system.change_hp_word("new word")
if you have any problem, reprit here. I have tested for save and load, anyway.
 
Actually that script could be shorter...
For XP...
[rgss]class Game_System
  attr_reader :new_hp_term
  alias gm_sys_init initialize
  def initialize
    gm_sys_init
    @new_hp_term = nil
  end
 
  def new_hp_term=(term)
    $data_system.words.hp = @new_hp_term = term
  end
end
 
class Scene_Load
  alias scn_load_read_save_data read_save_data
  def read_save_data(file)
    scn_load_read_save_data(file)
    if !$game_system.new_hp_term.nil?
      $data_system.words.hp = $game_system.new_hp_term
    end
  end
end
[/rgss]

Script call:

$game_system.new_hp_term = 'SomeP'
 
kyonides":3hrltx0q said:
Actually that script could be shorter...
For XP...
[rgss]class Game_System
  attr_reader :new_hp_term
  alias gm_sys_init initialize
  def initialize
    gm_sys_init
    @new_hp_term = nil
  end
 
  def new_hp_term=(term)
    $data_system.words.hp = @new_hp_term = term
  end
end
 
class Scene_Load
  alias scn_load_read_save_data read_save_data
  def read_save_data(file)
    scn_load_read_save_data(file)
    if !$game_system.new_hp_term.nil?
      $data_system.words.hp = $game_system.new_hp_term
    end
  end
end
[/rgss]

Script call:

$game_system.new_hp_term = 'SomeP'

I have been two days using alias. Then a method aliased is added after the original or what?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top