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.

Battle Text Without Interrupting The Flow

Sooth

Sponsor


Battle Text Without Interrupting The Flow


Hello folks,

I am currently using the default battle system of Rpg Maker XP; there're modifications to the calculations and fight options, but none of them should impact this script.

What I'd like to be able to do, is have messages that appear in combat with two distinct properties:
a. They automatically close after a few seconds.
b. They do not interrupt the player's actions. That is, they can show *while* the player is taking their turn, cycling through skills, etc and, since they automatically go away, not demand any attention except to be occasionally glanced at.

I am not currently using any custom scripts.

If successful, I will use this script to have party members shout out messages in combat corresponding to circumstances in the fight. For example, "The enemy seeks to harry me with mere flesh wounds!" or "I need healing!" when at low health. Other games that have done this include Planescape: Torment, Baldurs' Gate I and II for the PC, and later games of the Might & Magic series - although all of these games use voices instead of text. Square games do things like this, too, actually, with the text running across the screen as the combat continues uninterrupted. Not being able to make messages go on without forcing the player to respond to them first concerns me, but I won't need help managing the other mechanics of it.

The script doesn't have to only work in combat, but combat functionality is all I need.

Many thanks for your time and consideration,

- Kriss
 
Well, I did it, I hope you enjoy it.

You only have to replace the 3 next scripts:

Window_Message
Scene_Battle(1)
Scene_Battle(4)

Code:
#==============================================================================

# ** Window_Message

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

#  This message window is used to display text.

#==============================================================================

 

class Window_Message < Window_Selectable

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

  # * Object Initialization

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

  def initialize

    super(80, 304, 480, 160)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.visible = false

    self.z = 9998

    @fade_in = false

    @fade_out = false

    @contents_showing = false

    @cursor_width = 0

    self.active = false

    self.index = -1

  end

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

  # * Dispose

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

  def dispose

    terminate_message

    $game_temp.message_window_showing = false

    if @input_number_window != nil

      @input_number_window.dispose

    end

    super

  end

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

  # * Terminate Message

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

  def terminate_message

    self.active = false

    self.pause = false

    self.index = -1

    self.contents.clear

    # Clear showing flag

    @contents_showing = false

    # Call message callback

    if $game_temp.message_proc != nil

      $game_temp.message_proc.call

    end

    # Clear variables related to text, choices, and number input

    $game_temp.message_text = nil

    $game_temp.message_proc = nil

    $game_temp.choice_start = 99

    $game_temp.choice_max = 0

    $game_temp.choice_cancel_type = 0

    $game_temp.choice_proc = nil

    $game_temp.num_input_start = 99

    $game_temp.num_input_variable_id = 0

    $game_temp.num_input_digits_max = 0

    # Open gold window

    if @gold_window != nil

      @gold_window.dispose

      @gold_window = nil

    end

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    self.contents.font.color = normal_color

    x = y = 0

    @cursor_width = 0

    # Indent if choice

    if $game_temp.choice_start == 0

      x = 8

    end

    # If waiting for a message to be displayed

    if $game_temp.message_text != nil

      text = $game_temp.message_text

      # Control text processing

      begin

        last_text = text.clone

        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }

      end until text == last_text

      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do

        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""

      end

      # Change "\\\\" to "\000" for convenience

      text.gsub!(/\\\\/) { "\000" }

      # Change "\\C" to "\001" and "\\G" to "\002"

      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }

      text.gsub!(/\\[Gg]/) { "\002" }

      # Get 1 text character in c (loop until unable to get text)

      while ((c = text.slice!(/./m)) != nil)

        # If \\

        if c == "\000"

          # Return to original text

          c = "\\"

        end

        # If \C[n]

        if c == "\001"

          # Change text color

          text.sub!(/\[([0-9]+)\]/, "")

          color = $1.to_i

          if color >= 0 and color <= 7

            self.contents.font.color = text_color(color)

          end

          # go to next text

          next

        end

        # If \G

        if c == "\002"

          # Make gold window

          if @gold_window == nil

            @gold_window = Window_Gold.new

            @gold_window.x = 560 - @gold_window.width

            if $game_temp.in_battle

              @gold_window.y = 192

            else

              @gold_window.y = self.y >= 128 ? 32 : 384

            end

            @gold_window.opacity = self.opacity

            @gold_window.back_opacity = self.back_opacity

          end

          # go to next text

          next

        end

        # If new line text

        if c == "\n"

          # Update cursor width if choice

          if y >= $game_temp.choice_start

            @cursor_width = [@cursor_width, x].max

          end

          # Add 1 to y

          y += 1

          x = 0

          # Indent if choice

          if y >= $game_temp.choice_start

            x = 8

          end

          # go to next text

          next

        end

        # Draw text

        self.contents.draw_text(4 + x, 32 * y, 40, 32, c)

        # Add x to drawn text width

        x += self.contents.text_size(c).width

      end

    end

    # If choice

    if $game_temp.choice_max > 0

      @item_max = $game_temp.choice_max

      self.active = true

      self.index = 0

    end

    # If number input

    if $game_temp.num_input_variable_id > 0

      digits_max = $game_temp.num_input_digits_max

      number = $game_variables[$game_temp.num_input_variable_id]

      @input_number_window = Window_InputNumber.new(digits_max)

      @input_number_window.number = number

      @input_number_window.x = self.x + 8

      @input_number_window.y = self.y + $game_temp.num_input_start * 32

    end

  end

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

  # * Set Window Position and Opacity Level

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

  def reset_window

    if $game_temp.in_battle

      self.y = 16

    else

      case $game_system.message_position

      when 0  # up

        self.y = 16

      when 1  # middle

        self.y = 160

      when 2  # down

        self.y = 304

      end

    end

    if $game_system.message_frame == 0

      self.opacity = 255

    else

      self.opacity = 0

    end

    self.back_opacity = 160

  end

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

  # * Frame Update

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

  def update

    super

    # If fade in

    if @fade_in

      self.contents_opacity += 24

      if @input_number_window != nil

        @input_number_window.contents_opacity += 24

      end

      if self.contents_opacity == 255

        @fade_in = false

      end

      return

    end

    # If inputting number

    if @input_number_window != nil

      @input_number_window.update

      # Confirm

      if Input.trigger?(Input::C) and not $game_temp.in_battle 

        $game_system.se_play($data_system.decision_se)

        $game_variables[$game_temp.num_input_variable_id] =

          @input_number_window.number

        $game_map.need_refresh = true

        # Dispose of number input window

        @input_number_window.dispose

        @input_number_window = nil

        terminate_message

      end

      return

    end

    # If message is being displayed

    if @contents_showing

      # If choice isn't being displayed, show pause sign

      if $game_temp.choice_max == 0 and not $game_temp.in_battle 

        self.pause = true

      end

      # Cancel

      if Input.trigger?(Input::B)

        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0

          $game_system.se_play($data_system.cancel_se)

          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)

          terminate_message

        end

      end

      # Confirm

      if Input.trigger?(Input::C) and not $game_temp.in_battle 

        if $game_temp.choice_max > 0

          $game_system.se_play($data_system.decision_se)

          $game_temp.choice_proc.call(self.index)

        end

        terminate_message

      end

      return

    end

    # If display wait message or choice exists when not fading out

    if @fade_out == false and $game_temp.message_text != nil

      @contents_showing = true

      $game_temp.message_window_showing = true

      reset_window

      refresh

      Graphics.frame_reset

      self.visible = true

      self.contents_opacity = 0

      if @input_number_window != nil

        @input_number_window.contents_opacity = 0

      end

      @fade_in = true

      return

    end

    # If message which should be displayed is not shown, but window is visible

    if self.visible

      @fade_out = true

      self.opacity -= 48

      if self.opacity == 0

        self.visible = false

        @fade_out = false

        $game_temp.message_window_showing = false

      end

      return

    end

  end

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

  # * Cursor Rectangle Update

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

  def update_cursor_rect

    if @index >= 0

      n = $game_temp.choice_start + @index

      self.cursor_rect.set(8, n * 32, @cursor_width, 32)

    else

      self.cursor_rect.empty

    end

  end

end

 

Code:
#==============================================================================

# ** Scene_Battle (part 1)

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

#  This class performs battle screen processing.

#==============================================================================

 

class Scene_Battle

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

  # * Main Processing

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

  def main

    # Initialize each kind of temporary battle data

    $game_temp.in_battle = true

    $game_temp.battle_turn = 0

    $game_temp.battle_event_flags.clear

    $game_temp.battle_abort = false

    $game_temp.battle_main_phase = false

    $game_temp.battleback_name = $game_map.battleback_name

    $game_temp.forcing_battler = nil

    # Initialize battle event interpreter

    $game_system.battle_interpreter.setup(nil, 0)

    # Prepare troop

    @troop_id = $game_temp.battle_troop_id

    $game_troop.setup(@troop_id)

    # Make actor command window

    s1 = $data_system.words.attack

    s2 = $data_system.words.skill

    s3 = $data_system.words.guard

    s4 = $data_system.words.item

    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])

    @actor_command_window.y = 160

    @actor_command_window.back_opacity = 160

    @actor_command_window.active = false

    @actor_command_window.visible = false

    # Make other windows

    @party_command_window = Window_PartyCommand.new

    @help_window = Window_Help.new

    @help_window.back_opacity = 160

    @help_window.visible = false

    @status_window = Window_BattleStatus.new

    @message_window = Window_Message.new

    @message_count = 0

    @message_wait_count = 1 #seconds

    # Make sprite set

    @spriteset = Spriteset_Battle.new

    # Initialize wait count

    @wait_count = 0

    # Execute transition

    if $data_system.battle_transition == ""

      Graphics.transition(20)

    else

      Graphics.transition(40, "Graphics/Transitions/" +

        $data_system.battle_transition)

    end

    # Start pre-battle phase

    start_phase1

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Refresh map

    $game_map.refresh

    # Prepare for transition

    Graphics.freeze

    # Dispose of windows

    @actor_command_window.dispose

    @party_command_window.dispose

    @help_window.dispose

    @status_window.dispose

    @message_window.dispose

    if @skill_window != nil

      @skill_window.dispose

    end

    if @item_window != nil

      @item_window.dispose

    end

    if @result_window != nil

      @result_window.dispose

    end

    # Dispose of sprite set

    @spriteset.dispose

    # If switching to title screen

    if $scene.is_a?(Scene_Title)

      # Fade out screen

      Graphics.transition

      Graphics.freeze

    end

    # If switching from battle test to any screen other than game over screen

    if $BTEST and not $scene.is_a?(Scene_Gameover)

      $scene = nil

    end

  end

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

  # * Determine Battle Win/Loss Results

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

  def judge

    # If all dead determinant is true, or number of members in party is 0

    if $game_party.all_dead? or $game_party.actors.size == 0

      # If possible to lose

      if $game_temp.battle_can_lose

        # Return to BGM before battle starts

        $game_system.bgm_play($game_temp.map_bgm)

        # Battle ends

        battle_end(2)

        # Return true

        return true

      end

      # Set game over flag

      $game_temp.gameover = true

      # Return true

      return true

    end

    # Return false if even 1 enemy exists

    for enemy in $game_troop.enemies

      if enemy.exist?

        return false

      end

    end

    # Start after battle phase (win)

    start_phase5

    # Return true

    return true

  end

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

  # * Battle Ends

  #     result : results (0:win 1:lose 2:escape)

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

  def battle_end(result)

    # Clear in battle flag

    $game_temp.in_battle = false

    # Clear entire party actions flag

    $game_party.clear_actions

    # Remove battle states

    for actor in $game_party.actors

      actor.remove_states_battle

    end

    # Clear enemies

    $game_troop.enemies.clear

    # Call battle callback

    if $game_temp.battle_proc != nil

      $game_temp.battle_proc.call(result)

      $game_temp.battle_proc = nil

    end

    # Switch to map screen

    $scene = Scene_Map.new

  end

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

  # * Battle Event Setup

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

  def setup_battle_event

    # If battle event is running

    if $game_system.battle_interpreter.running?

      return

    end

    # Search for all battle event pages

    for index in 0...$data_troops[@troop_id].pages.size

      # Get event pages

      page = $data_troops[@troop_id].pages[index]

      # Make event conditions possible for reference with c

      c = page.condition

      # Go to next page if no conditions are appointed

      unless c.turn_valid or c.enemy_valid or

             c.actor_valid or c.switch_valid

        next

      end

      # Go to next page if action has been completed

      if $game_temp.battle_event_flags[index]

        next

      end

      # Confirm turn conditions

      if c.turn_valid

        n = $game_temp.battle_turn

        a = c.turn_a

        b = c.turn_b

        if (b == 0 and n != a) or

           (b > 0 and (n < 1 or n < a or n % b != a % b))

          next

        end

      end

      # Confirm enemy conditions

      if c.enemy_valid

        enemy = $game_troop.enemies[c.enemy_index]

        if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp

          next

        end

      end

      # Confirm actor conditions

      if c.actor_valid

        actor = $game_actors[c.actor_id]

        if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp

          next

        end

      end

      # Confirm switch conditions

      if c.switch_valid

        if $game_switches[c.switch_id] == false

          next

        end

      end

      # Set up event

      $game_system.battle_interpreter.setup(page.list, 0)

      # If this page span is [battle] or [turn]

      if page.span <= 1

        # Set action completed flag

        $game_temp.battle_event_flags[index] = true

      end

      return

    end

  end

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

  # * Frame Update

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

  def update

    # If battle event is running

    if $game_system.battle_interpreter.running?

      # Update interpreter

      $game_system.battle_interpreter.update

      # If a battler which is forcing actions doesn't exist

      if $game_temp.forcing_battler == nil

        # If battle event has finished running

        unless $game_system.battle_interpreter.running?

          # Rerun battle event set up if battle continues

          unless judge

            setup_battle_event

          end

        end

        # If not after battle phase

        if @phase != 5

          # Refresh status window

          @status_window.refresh

        end

      end

    end

    # Update system (timer) and screen

    $game_system.update

    $game_screen.update

    # If timer has reached 0

    if $game_system.timer_working and $game_system.timer == 0

      # Abort battle

      $game_temp.battle_abort = true

    end

    # Update windows

    @help_window.update

    @party_command_window.update

    @actor_command_window.update

    @status_window.update

    @message_window.update

    # Update sprite set

    @spriteset.update

    # If transition is processing

    if $game_temp.transition_processing

      # Clear transition processing flag

      $game_temp.transition_processing = false

      # Execute transition

      if $game_temp.transition_name == ""

        Graphics.transition(20)

      else

        Graphics.transition(40, "Graphics/Transitions/" +

          $game_temp.transition_name)

      end

    end

    # If message window is showing

    if $game_temp.message_window_showing 

      @message_count += 1

    end

    if @message_count > @message_wait_count * Graphics.frame_rate

      $game_temp.message_window_showing = false

      @message_window.terminate_message

      @message_count = 0

    end

    

    # If effect is showing

    if @spriteset.effect?

      return

    end

    # If game over

    if $game_temp.gameover

      # Switch to game over screen

      $scene = Scene_Gameover.new

      return

    end

    # If returning to title screen

    if $game_temp.to_title

      # Switch to title screen

      $scene = Scene_Title.new

      return

    end

    # If battle is aborted

    if $game_temp.battle_abort

      # Return to BGM used before battle started

      $game_system.bgm_play($game_temp.map_bgm)

      # Battle ends

      battle_end(1)

      return

    end

    # If waiting

    if @wait_count > 0

      # Decrease wait count

      @wait_count -= 1

      return

    end

    # If battler forcing an action doesn't exist,

    # and battle event is running

    if $game_temp.forcing_battler == nil and

       $game_system.battle_interpreter.running?

      unless $game_temp.message_window_showing 

        return

      end

    end

 

    # Branch according to phase

    case @phase

    when 1  # pre-battle phase

      update_phase1

    when 2  # party command phase

      update_phase2

    when 3  # actor command phase

      update_phase3

    when 4  # main phase

      update_phase4

    when 5  # after battle phase

      update_phase5

    end

  end

end

 

Code:
#==============================================================================

# ** Scene_Battle (part 4)

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

#  This class performs battle screen processing.

#==============================================================================

 

class Scene_Battle

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

  # * Start Main Phase

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

  def start_phase4

    # Shift to phase 4

    @phase = 4

    # Turn count

    $game_temp.battle_turn += 1

    # Search all battle event pages

    for index in 0...$data_troops[@troop_id].pages.size

      # Get event page

      page = $data_troops[@troop_id].pages[index]

      # If this page span is [turn]

      if page.span == 1

        # Clear action completed flags

        $game_temp.battle_event_flags[index] = false

      end

    end

    # Set actor as unselectable

    @actor_index = -1

    @active_battler = nil

    # Enable party command window

    @party_command_window.active = false

    @party_command_window.visible = false

    # Disable actor command window

    @actor_command_window.active = false

    @actor_command_window.visible = false

    # Set main phase flag

    $game_temp.battle_main_phase = true

    # Make enemy action

    for enemy in $game_troop.enemies

      enemy.make_action

    end

    # Make action orders

    make_action_orders

    # Shift to step 1

    @phase4_step = 1

  end

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

  # * Make Action Orders

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

  def make_action_orders

    # Initialize @action_battlers array

    @action_battlers = []

    # Add enemy to @action_battlers array

    for enemy in $game_troop.enemies

      @action_battlers.push(enemy)

    end

    # Add actor to @action_battlers array

    for actor in $game_party.actors

      @action_battlers.push(actor)

    end

    # Decide action speed for all

    for battler in @action_battlers

      battler.make_action_speed

    end

    # Line up action speed in order from greatest to least

    @action_battlers.sort! {|a,b|

      b.current_action.speed - a.current_action.speed }

  end

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

  # * Frame Update (main phase)

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

  def update_phase4

    case @phase4_step

    when 1

      update_phase4_step1

    when 2

      update_phase4_step2

    when 3

      update_phase4_step3

    when 4

      update_phase4_step4

    when 5

      update_phase4_step5

    when 6

      update_phase4_step6

    end

  end

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

  # * Frame Update (main phase step 1 : action preparation)

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

  def update_phase4_step1

    # Hide help window

    @help_window.visible = false

    # Determine win/loss

    if judge

      # If won, or if lost : end method

      return

    end

    # If an action forcing battler doesn't exist

    if $game_temp.forcing_battler == nil

      # Set up battle event

      setup_battle_event

      # If battle event is running

      if $game_system.battle_interpreter.running?

        unless $game_temp.message_window_showing 

          return

        end

      end

    end

    # If an action forcing battler exists

    if $game_temp.forcing_battler != nil

      # Add to head, or move

      @action_battlers.delete($game_temp.forcing_battler)

      @action_battlers.unshift($game_temp.forcing_battler)

    end

    # If no actionless battlers exist (all have performed an action)

    if @action_battlers.size == 0

      # Start party command phase

      start_phase2

      return

    end

    # Initialize animation ID and common event ID

    @animation1_id = 0

    @animation2_id = 0

    @common_event_id = 0

    # Shift from head of actionless battlers

    @active_battler = @action_battlers.shift

    # If already removed from battle

    if @active_battler.index == nil

      return

    end

    # Slip damage

    if @active_battler.hp > 0 and @active_battler.slip_damage?

      @active_battler.slip_damage_effect

      @active_battler.damage_pop = true

    end

    # Natural removal of states

    @active_battler.remove_states_auto

    # Refresh status window

    @status_window.refresh

    # Shift to step 2

    @phase4_step = 2

  end

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

  # * Frame Update (main phase step 2 : start action)

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

  def update_phase4_step2

    # If not a forcing action

    unless @active_battler.current_action.forcing

      # If restriction is [normal attack enemy] or [normal attack ally]

      if @active_battler.restriction == 2 or @active_battler.restriction == 3

        # Set attack as an action

        @active_battler.current_action.kind = 0

        @active_battler.current_action.basic = 0

      end

      # If restriction is [cannot perform action]

      if @active_battler.restriction == 4

        # Clear battler being forced into action

        $game_temp.forcing_battler = nil

        # Shift to step 1

        @phase4_step = 1

        return

      end

    end

    # Clear target battlers

    @target_battlers = []

    # Branch according to each action

    case @active_battler.current_action.kind

    when 0  # basic

      make_basic_action_result

    when 1  # skill

      make_skill_action_result

    when 2  # item

      make_item_action_result

    end

    # Shift to step 3

    if @phase4_step == 2

      @phase4_step = 3

    end

  end

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

  # * Make Basic Action Results

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

  def make_basic_action_result

    # If attack

    if @active_battler.current_action.basic == 0

      # Set anaimation ID

      @animation1_id = @active_battler.animation1_id

      @animation2_id = @active_battler.animation2_id

      # If action battler is enemy

      if @active_battler.is_a?(Game_Enemy)

        if @active_battler.restriction == 3

          target = $game_troop.random_target_enemy

        elsif @active_battler.restriction == 2

          target = $game_party.random_target_actor

        else

          index = @active_battler.current_action.target_index

          target = $game_party.smooth_target_actor(index)

        end

      end

      # If action battler is actor

      if @active_battler.is_a?(Game_Actor)

        if @active_battler.restriction == 3

          target = $game_party.random_target_actor

        elsif @active_battler.restriction == 2

          target = $game_troop.random_target_enemy

        else

          index = @active_battler.current_action.target_index

          target = $game_troop.smooth_target_enemy(index)

        end

      end

      # Set array of targeted battlers

      @target_battlers = [target]

      # Apply normal attack results

      for target in @target_battlers

        target.attack_effect(@active_battler)

      end

      return

    end

    # If guard

    if @active_battler.current_action.basic == 1

      # Display "Guard" in help window

      @help_window.set_text($data_system.words.guard, 1)

      return

    end

    # If escape

    if @active_battler.is_a?(Game_Enemy) and

       @active_battler.current_action.basic == 2

      # Display "Escape" in help window

      @help_window.set_text("Escape", 1)

      # Escape

      @active_battler.escape

      return

    end

    # If doing nothing

    if @active_battler.current_action.basic == 3

      # Clear battler being forced into action

      $game_temp.forcing_battler = nil

      # Shift to step 1

      @phase4_step = 1

      return

    end

  end

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

  # * Set Targeted Battler for Skill or Item

  #     scope : effect scope for skill or item

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

  def set_target_battlers(scope)

    # If battler performing action is enemy

    if @active_battler.is_a?(Game_Enemy)

      # Branch by effect scope

      case scope

      when 1  # single enemy

        index = @active_battler.current_action.target_index

        @target_battlers.push($game_party.smooth_target_actor(index))

      when 2  # all enemies

        for actor in $game_party.actors

          if actor.exist?

            @target_battlers.push(actor)

          end

        end

      when 3  # single ally

        index = @active_battler.current_action.target_index

        @target_battlers.push($game_troop.smooth_target_enemy(index))

      when 4  # all allies

        for enemy in $game_troop.enemies

          if enemy.exist?

            @target_battlers.push(enemy)

          end

        end

      when 5  # single ally (HP 0) 

        index = @active_battler.current_action.target_index

        enemy = $game_troop.enemies[index]

        if enemy != nil and enemy.hp0?

          @target_battlers.push(enemy)

        end

      when 6  # all allies (HP 0) 

        for enemy in $game_troop.enemies

          if enemy != nil and enemy.hp0?

            @target_battlers.push(enemy)

          end

        end

      when 7  # user

        @target_battlers.push(@active_battler)

      end

    end

    # If battler performing action is actor

    if @active_battler.is_a?(Game_Actor)

      # Branch by effect scope

      case scope

      when 1  # single enemy

        index = @active_battler.current_action.target_index

        @target_battlers.push($game_troop.smooth_target_enemy(index))

      when 2  # all enemies

        for enemy in $game_troop.enemies

          if enemy.exist?

            @target_battlers.push(enemy)

          end

        end

      when 3  # single ally

        index = @active_battler.current_action.target_index

        @target_battlers.push($game_party.smooth_target_actor(index))

      when 4  # all allies

        for actor in $game_party.actors

          if actor.exist?

            @target_battlers.push(actor)

          end

        end

      when 5  # single ally (HP 0) 

        index = @active_battler.current_action.target_index

        actor = $game_party.actors[index]

        if actor != nil and actor.hp0?

          @target_battlers.push(actor)

        end

      when 6  # all allies (HP 0) 

        for actor in $game_party.actors

          if actor != nil and actor.hp0?

            @target_battlers.push(actor)

          end

        end

      when 7  # user

        @target_battlers.push(@active_battler)

      end

    end

  end

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

  # * Make Skill Action Results

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

  def make_skill_action_result

    # Get skill

    @skill = $data_skills[@active_battler.current_action.skill_id]

    # If not a forcing action

    unless @active_battler.current_action.forcing

      # If unable to use due to SP running out

      unless @active_battler.skill_can_use?(@skill.id)

        # Clear battler being forced into action

        $game_temp.forcing_battler = nil

        # Shift to step 1

        @phase4_step = 1

        return

      end

    end

    # Use up SP

    @active_battler.sp -= @skill.sp_cost

    # Refresh status window

    @status_window.refresh

    # Show skill name on help window

    @help_window.set_text(@skill.name, 1)

    # Set animation ID

    @animation1_id = @skill.animation1_id

    @animation2_id = @skill.animation2_id

    # Set command event ID

    @common_event_id = @skill.common_event_id

    # Set target battlers

    set_target_battlers(@skill.scope)

    # Apply skill effect

    for target in @target_battlers

      target.skill_effect(@active_battler, @skill)

    end

  end

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

  # * Make Item Action Results

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

  def make_item_action_result

    # Get item

    @item = $data_items[@active_battler.current_action.item_id]

    # If unable to use due to items running out

    unless $game_party.item_can_use?(@item.id)

      # Shift to step 1

      @phase4_step = 1

      return

    end

    # If consumable

    if @item.consumable

      # Decrease used item by 1

      $game_party.lose_item(@item.id, 1)

    end

    # Display item name on help window

    @help_window.set_text(@item.name, 1)

    # Set animation ID

    @animation1_id = @item.animation1_id

    @animation2_id = @item.animation2_id

    # Set common event ID

    @common_event_id = @item.common_event_id

    # Decide on target

    index = @active_battler.current_action.target_index

    target = $game_party.smooth_target_actor(index)

    # Set targeted battlers

    set_target_battlers(@item.scope)

    # Apply item effect

    for target in @target_battlers

      target.item_effect(@item)

    end

  end

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

  # * Frame Update (main phase step 3 : animation for action performer)

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

  def update_phase4_step3

    # Animation for action performer (if ID is 0, then white flash)

    if @animation1_id == 0

      @active_battler.white_flash = true

    else

      @active_battler.animation_id = @animation1_id

      @active_battler.animation_hit = true

    end

    # Shift to step 4

    @phase4_step = 4

  end

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

  # * Frame Update (main phase step 4 : animation for target)

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

  def update_phase4_step4

    # Animation for target

    for target in @target_battlers

      target.animation_id = @animation2_id

      target.animation_hit = (target.damage != "Miss")

    end

    # Animation has at least 8 frames, regardless of its length

    @wait_count = 8

    # Shift to step 5

    @phase4_step = 5

  end

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

  # * Frame Update (main phase step 5 : damage display)

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

  def update_phase4_step5

    # Hide help window

    @help_window.visible = false

    # Refresh status window

    @status_window.refresh

    # Display damage

    for target in @target_battlers

      if target.damage != nil

        target.damage_pop = true

      end

    end

    # Shift to step 6

    @phase4_step = 6

  end

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

  # * Frame Update (main phase step 6 : refresh)

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

  def update_phase4_step6

    # Clear battler being forced into action

    $game_temp.forcing_battler = nil

    # If common event ID is valid

    if @common_event_id > 0

      # Set up event

      common_event = $data_common_events[@common_event_id]

      $game_system.battle_interpreter.setup(common_event.list, 0)

    end

    # Shift to step 1

    @phase4_step = 1

  end

end

 

To set the time to wait until the window message disapear, go to Scene_Battle(1), line 43

Code:
 @message_wait_count = 1 #segundos

and change it to the cuantiy of seconds you want (you can use floats, EJ: 1.5)

Any question ask me
 

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