#-------------------------------------------------------------------------- # ● 设置物品或特技对像方的战斗者 # scope : 特技或者是物品的范围 #-------------------------------------------------------------------------- def set_target_battlers(scope) # 行动方的战斗者是敌人的情况下 if @active_battler.is_a?(Game_Enemy) # 效果范围分支 case scope when 1 # 敌单体 index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 2 # 敌全体 for actor in 0...[$game_party.actors.size,4].min if $game_party.actors[actor].exist? @target_battlers.push($game_party.actors[actor]) end end when 3 # 我方单体 index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4 # 我方全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5 # 我方单体 (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 # 我方全体 (HP 0) for enemy in $game_troop.enemies if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end end when 7 # 使用者 @target_battlers.push(@active_battler) end end # 行动方的战斗者是角色的情况下 if @active_battler.is_a?(Game_Actor) # 效果范围分支 case scope when 1 # 敌单体 index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 2 # 敌全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 3 # 我方单体 index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 4 # 我方全体 for actor in 0...[$game_party.actors.size,4].min if $game_party.actors[actor].exist? @target_battlers.push($game_party.actors[actor]) end end when 5 # 我方单体 (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 # 我方全体 (HP 0) for actor in 0...[$game_party.actors.size,4].min if $game_party.actors[actor] != nil and $game_party.actors[actor].hp0? @target_battlers.push($game_party.actors[actor]) end end when 7 # 使用者 @target_battlers.push(@active_battler) end end end #-------------------------------------------------------------------------- # ● 生成行动循序 #-------------------------------------------------------------------------- def make_action_orders # 初始化序列 @action_battlers @action_battlers = [] # 添加敌人到 @action_battlers 序列 for enemy in $game_troop.enemies @action_battlers.push(enemy) end # 添加角色到 @action_battlers 序列 for actor in 0...[$game_party.actors.size,4].min @action_battlers.push($game_party.actors[actor]) end # 确定全体的行动速度 for battler in @action_battlers battler.make_action_speed end # 按照行动速度从大到小排列 @action_battlers.sort! {|a,b| b.current_action.speed - a.current_action.speed } end #-------------------------------------------------------------------------- # ● 开始结束战斗回合 #-------------------------------------------------------------------------- def start_phase5 # 转移到回合 5 @phase = 5 # 演奏战斗结束 ME $game_system.me_play($game_system.battle_end_me) # 还原为战斗开始前的 BGM $game_system.bgm_play($game_temp.map_bgm) # 初始化 EXP、金钱、宝物 exp = 0 gold = 0 treasures = [] # 循环 for enemy in $game_troop.enemies # 敌人不是隐藏状态的情况下 unless enemy.hidden # 获得 EXP、增加金钱 exp += enemy.exp gold += enemy.gold # 出现宝物判定 if rand(100) < enemy.treasure_prob if enemy.item_id > 0 treasures.push($data_items[enemy.item_id]) end if enemy.weapon_id > 0 treasures.push($data_weapons[enemy.weapon_id]) end if enemy.armor_id > 0 treasures.push($data_armors[enemy.armor_id]) end end end end # 限制宝物数为 6 个 treasures = treasures[0..5] # 获得 EXP for i in 0...[$game_party.actors.size,4].min actor = $game_party.actors[i] if actor.cant_get_exp? == false last_level = actor.level actor.exp += exp if actor.level > last_level actor.hp = actor.maxhp; actor.sp = actor.maxsp #角色HP SP 等于最大值 @status_window.level_up(i) end end end # 获得金钱 $game_party.gain_gold(gold) # 获得宝物 for item in treasures case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end end # 生成战斗结果窗口 @result_window = Window_BattleResult.new(exp, gold, treasures) # 设置等待计数 @phase5_wait_count = 100 end
1.PNG (3.07 KB, 下载次数: 12)
所有新增脚本
2.PNG (466.19 KB, 下载次数: 13)
敌人技能(单体)出现问题
3.PNG (3.64 KB, 下载次数: 12)
class Game_Party def random_target_actor(hp0 = false) # 初始化轮流 roulette = [] # 循环 for actor in @actors # 符合条件的场合 #↓增加判断条件 if (actor.index < 4) && (not hp0 and actor.exist?) or (hp0 and actor.hp0?) # 获取角色职业的位置 [位置] position = $data_classes[actor.class_id].position # 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2 n = 4 - position # 添加角色的轮流 n 回 n.times do roulette.push(actor) end end end # 轮流大小为 0 的情况 if roulette.size == 0 return nil end # 转轮盘赌,决定角色 return roulette[rand(roulette.size)] end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |