[問題] 在66RPG 網站找到一個腳本
看板RPGMaker (RPG製作大師 - RPG Maker)作者Lahaluto (俊偉)時間18年前 (2007/03/25 22:39)推噓0(0推 0噓 0→)留言0則, 0人參與討論串1/1
這個腳本很長 不過我有個問題
他這個腳本可以用於 同伴數大於4人的腳本
可是我發現這腳本有一個問題
就是 只有前面4人可以戰鬥 這個沒問題
但是怪物的攻擊 居然可以攻擊到 第4位以後 休戰的角色
我改了很多地方 就是沒辦法修改 怪物打4位以後的問題
所以我想問一下 該怎麼改 才可以讓怪物只打前面4位
不要攻擊到後面的同伴
#==============================================================================
# 本?本?自www.66RPG.com,使用和???保留此信息
#==============================================================================
class Scene_Save
#--------------------------------------------------------------------------
# ● ?入存??据
# file : ?入用文件?像 (已?打?)
#--------------------------------------------------------------------------
def write_save_data(file)
# 生成描?存?文件用的角色?形
characters = []
for i in 0...[$game_party.actors.size,4].min
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# ?入描?存?文件用的角色?据
Marshal.dump(characters, file)
# ?入?量游???用?面??
Marshal.dump(Graphics.frame_count, file)
# 增加 1 次存?次?
$game_system.save_count += 1
# 保存魔法??
# (???器保存的值以?机值替?)
$game_system.magic_number = $data_system.magic_number
# ?入各种游??像
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● ?置物品或特技?像方的?斗者
# 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
@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
#--------------------------------------------------------------------------
# ● ?到?入下一?角色的命令
#--------------------------------------------------------------------------
def phase3_next_actor
# 循?
begin
# 角色的明?效果 OFF
if @active_battler != nil
@active_battler.blink = false
end
# 最后的角色的情?
if @actor_index == [$game_party.actors.size-1,3].min
# ?始主回合
start_phase4
return
end
# 推?角色索引
@actor_index += 1
@active_battler = $game_party.actors[@actor_index]
@active_battler.blink = true
# 如果角色是在?法接受指令的??就再?
end until @active_battler.inputable?
# ?置角色的命令窗口
phase3_setup_command_window
end
end
class Arrow_Actor < Arrow_Base
#--------------------------------------------------------------------------
# ● 刷新?面
#--------------------------------------------------------------------------
def update
super
# 光?右
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@index += 1
@index %= [$game_party.actors.size,4].min
end
# 光?左
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@index += $game_party.actors.size - 1
@index %= [$game_party.actors.size,4].min
end
# ?置活??坐?
if self.actor != nil
self.x = self.actor.screen_x
self.y = self.actor.screen_y
end
end
end
#==============================================================================
# ■ Window_Target
#------------------------------------------------------------------------------
# 物品?面与特技?面的、使用?像角色??窗口。
#==============================================================================
class Window_Target < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化?像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 336, 480)
self.contents = Bitmap.new(width - 32, $game_party.actors.size*112)
self.z += 10
@item_max = $game_party.actors.size
@top_row = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 4
y = i * 112
actor = $game_party.actors[i]
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x + 8, y + 32)
draw_actor_state(actor, x + 8, y + 64)
draw_actor_hp(actor, x + 152, y + 32)
draw_actor_sp(actor, x + 152, y + 64)
end
end
#--------------------------------------------------------------------------
# ● 刷新光?矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光?位置 -1 ?全?、-2 以下????? (使用者自身)
if @index <= -2
self.cursor_rect.set(0, (@index + 10) * 112, self.width - 32, 96)
elsif @index == -1
self.cursor_rect.set(0, 0, self.width - 32, @item_max * 112 - 20)
else
tpy = @index * 112 - self.oy
self.cursor_rect.set(0, tpy, self.width - 32, 96)
if @index < @top_row
@top_row = @index
self.oy = @top_row *112
end
if @index > @top_row+3
@top_row = @index-3
self.oy = @top_row *112
end
end
end
end
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# ?示菜??面和同伴??的窗口。
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目?
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, $game_party.actors.size*112)
refresh
@top_row = 0
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 112
if i <=3
self.contents.font.color = Color.new(255,255,0,255)
self.contents.draw_text(x,y,340,32,"[出?]",2)
self.contents.font.color = normal_color
else
self.contents.font.color = Color.new(128,128,128,255)
self.contents.draw_text(x,y,340,32,"[待机]",2)
self.contents.font.color = normal_color
end
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
#--------------------------------------------------------------------------
# ● 刷新光?矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
tpy = @index * 112 - self.oy
self.cursor_rect.set(0, tpy, self.width - 32, 96)
if @index < @top_row
@top_row = @index
self.oy = @top_row *112
end
if @index > @top_row+3
@top_row = @index-3
self.oy = @top_row *112
end
end
end
end
class Game_Party
#--------------------------------------------------------------------------
# ● 全?判定
#--------------------------------------------------------------------------
def all_dead?
# 同伴人?? 0 的情?下
if $game_party.actors.size == 0
return false
end
# 同伴中?人 HP 在 0 以上
for i in 0..3
if @actors[i] != nil and@actors[i].hp >0
return false
end
end
# 全?
return true
end
#--------------------------------------------------------------------------
# ● 加入同伴
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def add_actor(actor_id)
# ?取角色
actor = $game_actors[actor_id]
# 同伴人?未? 4 人、本角色不在?伍中的情?下
if not @actors.include?(actor)
# 添加角色
@actors.push(actor)
# ?原主角
$game_player.refresh
end
end
end
#==============================================================================
# 本?本?自www.66RPG.com,使用和???保留此信息
#==============================================================================
class Scene_Menu
# --------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
@changer = 0
@where = 0
@checker = 0
end
# --------------------------------
def main
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "??"
s5 = "?存?度"
s6 = "离?游?"
s7 = "?整?伍"
s8 = "升?加?"
s9 = "人物介?"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7,
s8, s9])
@command_window.index = @menu_index
if $game_party.actors.size == 0
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
if $game_system.save_disabled
@command_window.disable_item(4)
end
if $game_party.actors.size == 1
@command_window.disable_item(6)
end
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 320
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@command_window.dispose
@playtime_window.dispose
@gold_window.dispose
@status_window.dispose
end
# --------------------------------
def update
@command_window.update
@playtime_window.update
@gold_window.update
@status_window.update
if @command_window.active
update_command
return
end
if @status_window.active
update_status
return
end
end
# --------------------------------
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
if $game_party.actors.size == 1 and @command_window.index ==6
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 5
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
when 6
$game_system.se_play($data_system.decision_se)
@checker = 0
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 7
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 8
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
end
return
end
end
# --------------------------------
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 1
if $game_party.actors[@status_window.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@status_window.index)
when 2
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@status_window.index)
when 3
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@status_window.index)
when 6
$game_system.se_play($data_system.decision_se)
if @checker == 0
@changer = $game_party.actors[@status_window.index]
@where = @status_window.index
@checker = 1
else
$game_party.actors[@where] =
$game_party.actors[@status_window.index]
$game_party.actors[@status_window.index] = @changer
@checker = 0
@status_window.refresh
end
when 7
$game_system.se_play($data_system.decision_se)
$scene = Scene_Lvup.new(@status_window.index)
when 8
$game_system.se_play($data_system.decision_se)
$scene = Scene_Charactor.new(@status_window.index)
end
return
end
end
end
#插件(升?加?,??伍?序,人物介?,??行走?)
#==============================================================================
# 本?本?自www.66RPG.com,使用和???保留此信息
#==============================================================================
# 作者: 柳柳
#
# ?明:?是功能我再比?早期的?候?布在幻森,不?那?候比?笨,方法很糟糕
# ?次是拿上就可以用的。
#
# 感?:Claimh的?本使我想起??功能重做了一遍,本想直接用他的,不?他的算法?分
# 冗余了,?好意思用。
#==============================================================================
# 使用方法:默?情?下把?????了走步?。如果想自行修改,提供功能如下:
#
# 角色走步?:draw_walk_actor_graphic
# 角色?向?:draw_turn_actor_graphic
#
# 回复原有??角色?:?除100行以后的?容。修改下面???量可以更改行走速度
#==============================================================================
WALK_REFRESH_FRAME_SPEED = 15 # 刷新的速度,越大越慢,你可以改?3左右??看
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# 初始化方法
#--------------------------------------------------------------------------
alias initialize_walk initialize
def initialize(x, y, width, height)
initialize_walk(x, y, width, height)
@start_walk = false
@turn_index = 0
@turn_phase = 0
end
#--------------------------------------------------------------------------
# ★ 角色行走?
# actor : 角色
# x : 描?的 X 坐?
# y : 描?的 Y 坐?
#--------------------------------------------------------------------------
def draw_walk_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
@start_turn = true
case @turn_phase
when 0
x_x = 0
when 1
x_x = cw
when 2
x_x = cw * 2
when 3
x_x = cw * 3
end
src_rect = Rect.new(x_x, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ★ 角色?向?
# actor : 角色
# x : 描?的 X 坐?
# y : 描?的 Y 坐?
#--------------------------------------------------------------------------
def draw_turn_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
@start_turn = true
case @turn_phase
when 0
x_x = 0
when 1
x_x = ch
when 2
x_x = ch * 3
when 3
x_x = ch * 2
end
src_rect = Rect.new(0, x_x, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# 更新(可?使用刷新,玩命耗??存= =)
#--------------------------------------------------------------------------
alias walk_update update
def update
walk_update
if @start_turn == true
@turn_index += 1
if @turn_index == WALK_REFRESH_FRAME_SPEED
refresh
@turn_index = 0
@turn_phase = (@turn_phase+1)%4
end
end
end
end
#==============================================================================
# Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# 把原有???改???走步?
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
draw_walk_actor_graphic(actor, x, y)
end
end
#==============================================================================
# 本?本?自www.66RPG.com,使用和???保留此信息
#==============================================================================
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.169.116.168
RPGMaker 近期熱門文章
PTT遊戲區 即時熱門文章
4
15