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.

Damage Display disappeared

McP

Member

Hello, i am using KGCs Cooperation Skills and i have a problem: The damage for the coop attacks is not shown. It does not say "Miss" or "0", it just shows nothing...the enemy takes damage nevertheless, since he dies after the coop-attack.
I'll post the script so you can look over it:

Code:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ 連繋スキル - KGC_CooperationSkill ◆
#_/    â—‡ Last update : 2007/05/28 â—‡
#_/----------------------------------------------------------------------------
#_/  複数のスキルを組み合わせ、別のスキルを発動させる機能です。
#_/  It is a function to combine some skills, and to execute another skill.
#_/============================================================================
#_/  ≪個別戦闘コマンド[SeparationCommand]≫より下
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

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

module KGC
  # ◆連繋スキル配列
  #  ≪[発動スキルID, [必要スキルID1, 必要スキルID2, ...]]≫
  #  配列なので、忘れずに , で区切ってください。
  CS_SKILLS = [
    # スパイラルフレア
    [83, [88, 7]],
    [84, [88, 10]],
    [85, [88, 13]],
  ]  # -- Don't delete this line! --

  # ◆敵連繋スキル許可
  #  true にすると、敵も連繋スキル判定を行う。
  CS_PERMIT_ENEMY = true

  # ◆連繋元スキル発動許可
  #  true にすると、連繋元となるスキルもすべて発動する。
  #  false にすると、連繋スキルのみ発動する。
  #  (≪Active Count Battle≫では、最後の連繋元スキルにのみ影響)
  CS_EXECUTE_ORIGIN_SKILL = false
end

#### CS_SKILLS
### Array of "Cooperation Skill".
#  << ["Cooperation Skill" ID, [Necessary skill ID 1, ID 2, ...]] >>

#### CS_PERMIT_ENEMY
### Enables enemy to execute "Cooperation Skill".

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

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

#==============================================================================
# ■ Game_Battler (分割定義 3)
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ● 連繋スキルの効果適用
  #     users    : スキルの使用者リスト (バトラー)
  #                users[i] : Game_CooperationSkillUser
  #     skill    : スキル
  #     is_actor : 使用者がアクター
  #--------------------------------------------------------------------------
  def cooperation_skill_effect(users, skill, is_actor)
    # クリティカルフラグをクリア
    self.critical = false
    # スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、
    # またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # メソッド終了
      return false
    end
    user_list = (is_actor ? $game_party.actors : $game_troop.enemies).compact
    # 有効フラグをクリア
    effective = false
    # コモンイベント ID が有効の場合は有効フラグをセット
    effective |= skill.common_event_id > 0
    # 第一命中判定
    hit2 = 100 * users.size
    if skill.atk_f > 0
      users.each { |u|
        user = user_list[u.index]
        hit2 += user.hit * skill.atk_f / 100
      }
    end
    hit = users.size * 0.75
    hit = Integer(skill.hit * hit2 / 100)
    hit_result = (rand(100) < hit)
    # 不確実なスキルの場合は有効フラグをセット
    effective |= hit < 100
    # 命中の場合
    if hit_result
      # 威力を計算
      power = 0
      users.each { |u|
        user = user_list[u.index]
        power += user.atk * skill.atk_f / 100
      }
      power /= users.size * 0.75
      power = Integer(power + skill.power)
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # 倍率を計算
      rate = 0
      users.each { |u|
        user = user_list[u.index]
        rate += (user.str * skill.str_f / 100)
        rate += (user.dex * skill.dex_f / 100)
        rate += (user.agi * skill.agi_f / 100)
        rate += (user.int * skill.int_f / 100)
      }
      rate /= users.size * 0.75
      rate = Integer(rate + 20)
      # 基本ダメージを計算
      self.damage = power * rate / 20
      # 属性修正
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # ダメージの符号が正の場合
      if self.damage > 0
        # 防御修正
        if self.guarding?
          self.damage /= 2
        end
      end
      # 分散
      if skill.variance > 0 and self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # 第二命中判定
      eva = 0
      user_dex = 0
      users.each { |u|
        user = user_list[u.index]
        user_dex += user.dex
      }
      user_dex /= users.size
      eva += 8 * self.agi / user_dex
      eva += self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # 不確実なスキルの場合は有効フラグをセット
      effective |= hit < 100
    end
    # 命中の場合
    if hit_result
      # 威力 0 以外の物理攻撃の場合
      if skill.power != 0 and skill.atk_f > 0
        # ステート衝撃解除
        remove_states_shock
        # 有効フラグをセット
        effective = true
      end
      # HP からダメージを減算
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # ステート変化
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # 威力が 0 の場合
      if skill.power == 0
        # ダメージに空文字列を設定
        self.damage = ""
        # ステートに変化がない場合
        unless @state_changed
          # ダメージに "Miss" を設定
          self.damage = "Daneben"
        end
      end
    # ミスの場合
    else
      # ダメージに "Miss" を設定
      self.damage = "Daneben"
    end
    # 戦闘中でない場合
    unless $game_temp.in_battle
      # ダメージに nil を設定
      self.damage = nil
    end
    # メソッド終了
    return effective
  end
end

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

#==============================================================================
# â–  Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● スキルの使用可能判定
  #     skill_id : スキル ID
  #--------------------------------------------------------------------------
  def skill_can_use?(skill_id)
    return super(skill_id)
  end
end

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

#==============================================================================
# â–  Game_CooperationSkillUser
#==============================================================================

class Game_CooperationSkillUser
  attr_reader :index, :skill_id
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(index, skill_id)
    @index = index
    @skill_id = skill_id
  end
end

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

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

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  alias main_KGC_CooperationSkill main
  def main
    # 連繋スキル発動フラグを解除
    @cooperation_skill_exec = false
    @cooperation_skill_id = 0
    # 連繋判定用配列を初期化
    @cooperate_actors = []
    @cooperate_enemies = []

    main_KGC_CooperationSkill
  end
end

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

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

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● パーティコマンドフェーズ開始
  #--------------------------------------------------------------------------
  alias start_phase2_KGC_CooperationSkill start_phase2
  def start_phase2
    # 連繋スキル発動フラグを解除
    @cooperation_skill_exec = false
    @cooperation_skill_id = 0
    # 連繋判定用配列を初期化
    @cooperate_actors.clear
    @cooperate_enemies.clear

    start_phase2_KGC_CooperationSkill
  end
end

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

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

class Scene_Battle
  unless KGC::CS_EXECUTE_ORIGIN_SKILL || $imported["ActiveCountBattle"]
  #--------------------------------------------------------------------------
  # ● メインフェーズ開始
  #--------------------------------------------------------------------------
  alias start_phase4_KGC_CooperationSkill start_phase4
  def start_phase4
    start_phase4_KGC_CooperationSkill

    # 判定用データ作成
    @cooperate_actors.clear
    @cooperate_enemies.clear
    $game_party.actors.each { |actor|
      if actor.current_action.kind == 1
        user = Game_CooperationSkillUser.new(actor.index,
          actor.current_action.skill_id)
        @cooperate_actors << user
      end
    }
  end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  #--------------------------------------------------------------------------
  alias update_phase4_step2_KGC_CooperationSkill update_phase4_step2
  def update_phase4_step2
    @judged = false
    unless KGC::CS_EXECUTE_ORIGIN_SKILL
      # 発動判定
      judge_cooperation_skill(@active_battler)
      if @cooperation_skill_exec
        @phase4_step = 6
        return
      end
    end

    update_phase4_step2_KGC_CooperationSkill
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  #--------------------------------------------------------------------------
  alias update_phase4_step6_KGC_CooperationSkill update_phase4_step6
  def update_phase4_step6
    if @cooperation_skill_exec && !@judged
      # 連繋スキル終了
      @cooperation_skill_exec = false
      @cooperation_skill_id = 0
      @exec_battlers.clear
    # 発動判定
    elsif KGC::CS_EXECUTE_ORIGIN_SKILL
      judge_cooperation_skill(@active_battler)
    end
    if @cooperation_skill_exec
      execute_cooperation_skill
      @judged = false
      return
    end

    update_phase4_step6_KGC_CooperationSkill
  end
  #--------------------------------------------------------------------------
  # ● 連繋スキル第一発動判定
  #     battler : 判定対象
  #--------------------------------------------------------------------------
  def judge_cooperation_skill(battler)
    return false if @judged
    @judged = true

    # 行動がスキルの場合
    if battler.current_action.kind == 1
      # 敵全滅判定
      target_all_dead = true
      enemy_list = battler.is_a?(Game_Actor) ?
        $game_troop.enemies : $game_party.actors
      enemy_list.each { |e|
        if e.exist?
          target_all_dead = false
          break
        end
      }
      # 対象が残っていれば第二発動判定
      unless target_all_dead
        return judge_cooperation_skill_second(battler)
      end
    else
      # 判定用配列から削除
      if battler.is_a?(Game_Actor)
        remove_cooperate_battler(0, battler)
      elsif battler.is_a?(Game_Enemy)
        remove_cooperate_battler(1, battler)
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ● 連繋スキル第二発動判定
  #--------------------------------------------------------------------------
  def judge_cooperation_skill_second(battler)
    # 判定用データ作成
    user = Game_CooperationSkillUser.new(battler.index,
      battler.current_action.skill_id)
    if battler.is_a?(Game_Actor)
      remove_cooperate_battler(0, battler)
      @cooperate_actors << user
    elsif battler.is_a?(Game_Enemy) && KGC::CS_PERMIT_ENEMY
      remove_cooperate_battler(1, battler)
      @cooperate_enemies << user
    end
    # 連繋スキル発動判定
    KGC::CS_SKILLS.each { |cs|
      # アクター判定
      if battler.is_a?(Game_Actor)
        check_cooperation_exec_battlers(0, cs)
        if @cooperation_skill_exec
          break
        end
      # エネミー判定
      elsif battler.is_a?(Game_Enemy) && KGC::CS_PERMIT_ENEMY
        check_cooperation_exec_battlers(1, cs)
        if @cooperation_skill_exec
          break
        end
      end
    }
    return @cooperation_skill_exec
  end
  #--------------------------------------------------------------------------
  # ● 連繋スキル発動バトラー判定
  #     type    : 0..Actor  1..Enemy
  #     cs_data : Cooperation skill data
  #--------------------------------------------------------------------------
  def check_cooperation_exec_battlers(type, cs_data)
    case type
    when 0  # Actor
      cooperate_battlers = @cooperate_actors
      battler_list = $game_party.actors
    when 1  # Enemy
      cooperate_battlers = @cooperate_enemies
      battler_list = $game_troop.enemies
    end
    exec = true
    # 発動者リストを作成
    @exec_battlers = []
    cs_data[1].each { |sid|
      user = cooperate_battlers.find { |cb|
        sid == cb.skill_id && !@exec_battlers.include?(cb)
      }
      exec &= user != nil
      if exec
        @exec_battlers << user
      else
        break
      end
    }
    if exec
      # 発動者全員が発動条件を満たすか判定
      @exec_battlers.each { |eb|
        unless battler_list[eb.index].exist? &&
            battler_list[eb.index].skill_can_use?(cs_data[0])
          exec = false
          break
        end
      }
    end
    # 連繋スキル発動
    if exec
      # 発動フラグを立てる
      @cooperation_skill_exec = true
      @cooperation_skill_id = cs_data[0]
      @cooperation_skill_user = type
      # 発動者を削除
      cooperate_battlers.each_with_index { |cb, i|
        if @exec_battlers.include?(cb)
          @action_battlers.delete(battler_list[cb.index])
          cooperate_battlers[i] = nil
        end
      }
      cooperate_battlers.compact!
    end
  end
  #--------------------------------------------------------------------------
  # ● 連繋加担者削除
  #     type    : 0..アクター  1..エネミー
  #     battler : 削除対象
  #--------------------------------------------------------------------------
  def remove_cooperate_battler(type, battler)
    case type
    when 0  # アクター
      if @cooperate_actors.size > 1
        @cooperate_actors.each_index { |i|
          if @cooperate_actors[i].index == battler.index
            @cooperate_actors[i] = nil
          end
        }
        @cooperate_actors.compact!
      end
    when 1  # エネミー
      if KGC::CS_PERMIT_ENEMY && @cooperate_enemies.size > 1
        @cooperate_enemies.each_index { |i|
          if @cooperate_enemies[i].index == battler.index
            @cooperate_enemies[i] = nil
          end
        }
        @cooperate_enemies.compact!
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 連繋スキル発動
  #--------------------------------------------------------------------------
  def execute_cooperation_skill
    # スキル取得
    skill = $data_skills[@cooperation_skill_id]
    # ヘルプウィンドウにスキル名を表示
    @help_window.set_text(skill.name, 1)
    if $imported["SkillMessage"]
      # スキル使用メッセージ表示
      show_skill_message(@active_battler, skill)
    end
    # アニメーション ID を設定
    @animation1_id = skill.animation1_id
    @animation2_id = skill.animation2_id
    # コモンイベント ID を設定
    @common_event_id = skill.common_event_id
    # 攻撃対象取得
    @target_battlers = []
    set_target_battlers(skill.scope)

    case @cooperation_skill_user
    when 0  # アクター
      user_list = $game_party.actors
      if $imported["ActiveCountBattle"] && @input_battler != nil
        @exec_battlers.each_index { |j|
          if $game_party.actors[@exec_battlers[j].index] == @input_battler
            # コマンド入力を解除
            command_input_cancel
          end
        }
      end
      @status_window.refresh
    when 1  # エネミー
      user_list = $game_troop.enemies
    end
    # SP消費
    @exec_battlers.each_index { |i|
      user_list[@exec_battlers[i].index].sp -= skill.sp_cost
    }
    # 発動者全員に発動アニメを表示
    @exec_battlers.each_index { |i|
      user_list[@exec_battlers[i].index].animation_id = @animation1_id
      user_list[@exec_battlers[i].index].animation_hit = true
    }
    # スキル適用
    @target_battlers.each { |target|
      target.cooperation_skill_effect(@exec_battlers, skill,
        @cooperation_skill_user == 0)
    }
    # ステップ 4 に移行
    @phase4_step = 4
  end
  #--------------------------------------------------------------------------
  # ● 連繋スキル加担判定
  #     battler : 判定するバトラー
  #--------------------------------------------------------------------------
  def cooperation_exec?(battler)
    if @cooperation_skill_exec
      if !battler.is_a?(Game_Enemy) || KGC::CS_PERMIT_ENEMY
        # 発動者に含まれているか判定
        @exec_battlers.each_index { |i|
          return true if @exec_battlers[i].index == battler.index
        }
      end
    end
    return false
  end
end

Oh, and I am using the DBS.
 

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