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 messages disappear too fast!

I'm using this script:

KGC Multi Hit

Code:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ 多段攻撃 - KGC_MultiAttack ◆
#_/----------------------------------------------------------------------------
#_/  複数回効果を適用する行動を作成します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================

module KGC
  # ◆攻撃判定用SEファイル名
  #  (大文字・小文字は問わない。拡張子不要)
  MATK_HIT_SE = "_multi_attack"
  # ◆多段攻撃時、1Hitごとにステータスウィンドウを再描画
  #  (無駄に重いので、高速化ACB以外では使用しない方が無難)
  MATK_HIT_REFRESH = false

  # ◆合計ダメージ表示
  #  合計ダメージを逐次表示。
  MATK_SHOW_TOTAL_DMG = true
  # ◆前のダメージ表示を消去
  #  前回のダメージを消去してから次のダメージ表示を出す。
  MATK_DELETE_PREV_DMG = false

  # ◆ダメージ表示をずらす
  #  前回のダメージ表示から少しずれた位置に次のダメージ表示を出す。
  MATK_SHIFT_DMG_POS = true
  # ◆ダメージ表示のずれの大きさ
  #  正にすると下方向、負にすると上方向にずれる。
  MATK_SHIFT_DMG_POS_AMT = -4

  # ◆ヒット数表示
  MATK_SHOW_HIT_COUNT = true
  # ◆ヒット数の書式
  #  【{n}…ヒット数】
  MATK_HIT_COUNT_FORMAT = "{n}Hits"
  # ◆ヒット数の文字色
  MATK_HIT_COUNT_COLOR = Color.new(255, 224, 160)
  # ◆ヒット数のフォント
  MATK_HIT_COUNT_FONT_NAME   = ["MS P明朝", "Times New Roman"]  # フォント名
  MATK_HIT_COUNT_FONT_SIZE   = 22    # サイズ
  MATK_HIT_COUNT_FONT_BOLD   = true  # 太字
  MATK_HIT_COUNT_FONT_ITALIC = true  # 斜体
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["MultiAttack"] = true

#==============================================================================
# â–  Sprite_Battler
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KGC_MultiAttack initialize
  def initialize(viewport, battler = nil)
    initialize_KGC_MultiAttack(viewport, battler)

    @_damage_sprite_array = []
    @_damage_duration_array = []
    @_hit_count_sprite = Sprite.new(viewport)
    @_hit_count_sprite.bitmap =
      Bitmap.new(160, KGC::MATK_HIT_COUNT_FONT_SIZE * 3 / 2)
    reset_hit_count
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias dispose_KGC_MultiAttack dispose
  def dispose
    @_damage_sprite_array.each_index { |i| dispose_damage(i) }
    @_hit_count_sprite.bitmap.dispose
    @_hit_count_sprite.dispose

    dispose_KGC_MultiAttack
  end
  #--------------------------------------------------------------------------
  # ● 多段ヒット判定
  #--------------------------------------------------------------------------
  def multi_attack?
    if @_multi_attack
      @_multi_attack = false
      return true
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ● ヒットカウント加算
  #--------------------------------------------------------------------------
  def add_hit_count
    @_hit_count += 1
  end
  #--------------------------------------------------------------------------
  # ● ヒットカウント初期化
  #--------------------------------------------------------------------------
  def reset_hit_count
    @_hit_count = 0
  end
  #------------------------------------------------------------------------
  # ● ダメージスプライト作成
  #------------------------------------------------------------------------
  def damage(value, critical)
    @_damage_sprite_array.compact!
    @_damage_duration_array.compact!
    super
    sprite = RPG::Sprite.new
    sprite.bitmap = @_damage_sprite.bitmap.dup
    sprite.ox = @_damage_sprite.ox
    sprite.oy = @_damage_sprite.oy
    sprite.x = @_damage_sprite.x
    sprite.y = @_damage_sprite.y
    if KGC::MATK_SHIFT_DMG_POS
      sprite.y += @_damage_sprite_array.size * KGC::MATK_SHIFT_DMG_POS_AMT
    end
    sprite.z = @_damage_sprite.z
    @_damage_sprite_array.unshift(sprite)
    @_damage_duration_array.unshift(40)
    # ヒットカウント作成
    if KGC::MATK_SHOW_HIT_COUNT
      img = @_hit_count_sprite.bitmap
      img.clear
      if @_hit_count > 1
        img.font.name = KGC::MATK_HIT_COUNT_FONT_NAME
        img.font.size = KGC::MATK_HIT_COUNT_FONT_SIZE
        img.font.bold = KGC::MATK_HIT_COUNT_FONT_BOLD
        img.font.italic = KGC::MATK_HIT_COUNT_FONT_ITALIC
        img.font.color = KGC::MATK_HIT_COUNT_COLOR
        format = KGC::MATK_HIT_COUNT_FORMAT.gsub(/{n}/i) {"#{@_hit_count}"}
        img.draw_frame_text(0, 0, sprite.bitmap.width, img.height, format, 1)
      end
    end
    dispose_damage(-1)
  end
  #--------------------------------------------------------------------------
  # ● ダメージスプライト破棄
  #--------------------------------------------------------------------------
  def dispose_damage(index = nil)
    return if index == nil
    if index >= 0 && @_damage_sprite_array[index] != nil
      @_damage_sprite_array[index].bitmap.dispose
      @_damage_sprite_array[index].dispose
      @_damage_sprite_array[index] = nil
      @_damage_duration_array[index] = nil
      @_damage_sprite_array.compact!
      @_damage_duration_array.compact!
    elsif index < 0 && @_damage_sprite != nil
      @_damage_sprite.bitmap.dispose
      @_damage_sprite.dispose
      @_damage_sprite = nil
      @_damage_duration = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● ダメージスプライトクリア
  #--------------------------------------------------------------------------
  def clear_damage
    @_damage_sprite_array.each_index { |i|
      dispose_damage(i)
    }
  end
  #--------------------------------------------------------------------------
  # ● アニメーション実行タイミング
  #--------------------------------------------------------------------------
  def animation_process_timing(timing, hit)
    if (timing.condition == 0) || (timing.condition == 1 && hit) ||
       (timing.condition == 2 && !hit)
      if timing.se.name != ""
        @_multi_attack |= timing.se.name.upcase == KGC::MATK_HIT_SE.upcase
      end
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_KGC_MultiAttack update
  def update
    @_multi_attack = false if Graphics.frame_count % 2 == 0

    update_KGC_MultiAttack

    if @_damage_sprite_array.size > 0
      @_damage_sprite_array.each_with_index { |sp, i|
        if sp == nil
          next
        end
        if @_damage_duration_array[i] == 0
          dispose_damage(i)
          next
        end
        @_damage_duration_array[i] -= 1
        sp.x = self.x
        if $imported["DamageAlter"]
          damage_direct(sp, @_damage_duration_array[i])
        else
          case @_damage_duration_array[i]
          when 38..39
            sp.y -= 4
          when 36..37
            sp.y -= 2
          when 34..35
            sp.y += 2
          when 28..33
            sp.y += 4
          end
          sp.opacity = 256 - (12 - @_damage_duration_array[i]) * 32
        end
      }
      if KGC::MATK_SHOW_HIT_COUNT && @_damage_sprite_array[0] != nil
        sp = @_damage_sprite_array[0]
        sp2 = @_hit_count_sprite
        sp2.ox = sp.ox
        sp2.oy = sp.oy
        sp2.x = sp.x
        sp2.y = sp.y + 48
        sp2.z = sp.z
        sp2.opacity = sp.opacity
      end
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# â–  Spriteset_Battle
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ● スプライト取得
  #--------------------------------------------------------------------------
  def sprites
    return @enemy_sprites + @actor_sprites
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Battle (分割定義 1)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_KGC_MultiAttack update
  def update
    attacker = ($imported["ActiveCountBattle"] ?
      @action_battler : @active_battler)
    if @phase4_step == 5 && @target_battlers != [] && attacker != nil
      # ステータスウィンドウ再描画
      @status_window.refresh if KGC::MATK_HIT_REFRESH
      @spriteset.sprites.each { |sp|
        # 多段ヒット判定
        unless sp.multi_attack? && @target_battlers.include?(sp.battler)
          next
        end
        if KGC::MATK_DELETE_PREV_DMG
          sp.clear_damage
        end
        if KGC::MATK_SHOW_TOTAL_DMG  # 合計を表示
          if @_matk_total_damage[sp.battler] == nil
            @_matk_total_damage[sp.battler] = 0
          end
          if sp.battler.damage.is_a?(Numeric)
            @_matk_total_damage[sp.battler] += sp.battler.damage
            if KGC::MATK_SHOW_HIT_COUNT
              sp.add_hit_count
            end
          end
          sp.damage(@_matk_total_damage[sp.battler], sp.battler.critical)
        else  # 逐次表示
          sp.damage(sp.battler.damage, sp.battler.critical)
        end
        # 効果を追加
        case attacker.current_action.kind
        when 0
          if attacker.current_action.basic == 0
            sp.battler.attack_effect(attacker)
          end
        when 1
          skill = $data_skills[attacker.current_action.skill_id]
          sp.battler.skill_effect(attacker, skill)
        when 2
          item = $data_skills[attacker.current_action.item_id]
          sp.battler.item_effect(item)
        end
      }
    end

    update_KGC_MultiAttack
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Battle (分割定義 4)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
  #--------------------------------------------------------------------------
  alias update_phase4_step4_KGC_MultiAttack update_phase4_step4
  def update_phase4_step4
    # 多段攻撃用の初期化処理
    if @_matk_total_damage == nil
      @_matk_total_damage = {}
    else
      @_matk_total_damage.clear
    end
    if KGC::MATK_SHOW_HIT_COUNT
      @spriteset.sprites.each { |sp| sp.reset_hit_count }
    end

    update_phase4_step4_KGC_MultiAttack
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  #--------------------------------------------------------------------------
  alias update_phase4_step5_KGC_MultiAttack update_phase4_step5
  def update_phase4_step5
    # 多段ダメージ更新処理
    @spriteset.sprites.each { |sp|
      if @target_battlers.include?(sp.battler) &&
          @_matk_total_damage[sp.battler] != nil &&
          sp.battler.damage.is_a?(Numeric)
        if KGC::MATK_SHOW_TOTAL_DMG
          sp.battler.damage = @_matk_total_damage[sp.battler] + sp.battler.damage
        end
        if KGC::MATK_SHOW_HIT_COUNT
          sp.add_hit_count
        end
      end
    }

    update_phase4_step5_KGC_MultiAttack
  end
end

For some reason, when I've got it loaded into my game, the battle messages flow far more quickly than normal. Things like "Defend" stay on screen for about half the time they usually would. I'm guessing it is to do with the way that the script handles the multiple hits, and while it isn't that big a deal, I can see it hurting playability a little if you can't tell what an enemy is doing (or, say, read what item is stolen) before the system whisks it away again.

Any advice on how to fix this? If necessary, I'll just extend the wait command that must already be there on the battle dialogues in the scripts, if someone can point me to the lines of code I'd need to play about with to adjust that. I'd rather fix the script itself, but I'll take whatever I can.
 

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