赞 | 50 |
VIP | 429 |
好人卡 | 14 |
积分 | 8 |
经验 | 146370 |
最后登录 | 2022-6-27 |
在线时间 | 3431 小时 |
Lv2.观梦者 会吐槽的画师
- 梦石
- 0
- 星屑
- 782
- 在线时间
- 3431 小时
- 注册时间
- 2011-6-10
- 帖子
- 6535
|
2楼
楼主 |
发表于 2013-5-17 16:31:01
|
只看该作者
问题2:
我是用的是B站的不离不弃横版战斗系统,原来的横版战斗使得敌人会统一排列在左方,现在我不使用横版系统了,如何恢复敌人的站位,下面这个脚本要删掉哪些?
#==============================================================================
# vx新遇敌系统 by 沉影不器
# protosssonny修改版
# -----------------------------------------------------------------------------
# 功能描述:
# 根据角色队伍人数决定敌人数
# 在[数据库-敌人队伍]中增加多个不同的敌人;遇敌中,敌人将随机抽取,并自动排列
# 明雷指定敌人ID: 明雷遇敌时,允许指定某个敌人必出现
# -----------------------------------------------------------------------------
# 目前大概是这样,不同敌人有不同出现率(这点还没写 - -!).
# 周末之前没时间,先放出这个粗糙工程,欢迎找bug,礼拜天早上查收意见
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :enemy_id # 指定敌人 ID
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
alias ini initialize
def initialize
ini
# 初始化指定敌人 ID
@enemy_id = 0
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 战斗处理
#--------------------------------------------------------------------------
def command_301
return true if $game_temp.in_battle
if @params[0] == 0 # 直接指定
troop_id = @params[1]
else # 使用变量指定
troop_id = $game_variables[@params[1]]
end
if $data_troops[troop_id] != nil
# 代入指定敌人 ID
$game_troop.setup(troop_id, $game_temp.enemy_id)
$game_troop.can_escape = @params[2]
$game_troop.can_lose = @params[3]
$game_temp.battle_proc = Proc.new { |n| @branch[@indent] = n }
$game_temp.next_scene = "battle"
end
@index += 1
return false
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
# 还原指定敌人 ID
$game_temp.enemy_id = 0
dispose_info_viewport
@message_window.dispose
@spriteset.dispose
unless $scene.is_a?(Scene_Gameover)
$scene = nil if $BTEST
end
end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● 敌人角色名称后的文字表
#--------------------------------------------------------------------------
LETTER_TABLE = [ 'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z']
SPACE = 32
#--------------------------------------------------------------------------
# ● 清除
#--------------------------------------------------------------------------
def clear
@screen.clear
@interpreter.clear
@event_flags.clear
@enemies = []
@turn_count = 0
@names_count = {}
@can_escape = false
@can_lose = false
@preemptive = false
@surprise = false
@turn_ending = false
@forcing_battler = nil
# 新坐标数组
@coordinate_x = []
# 敌方新队伍对象
@troop = nil
end
#--------------------------------------------------------------------------
# ○ 获取成员
#--------------------------------------------------------------------------
def members
return @enemies
end
#--------------------------------------------------------------------------
# ○ 获取敌方组对象
#--------------------------------------------------------------------------
def troop
return @troop
end
#--------------------------------------------------------------------------
# ○ 获取敌方组对象
# enemy_id : 敌人 ID
#--------------------------------------------------------------------------
def setup_troop(enemy_id)
# 角色数
party_size = $game_party.members.size
# 指定敌人数
if $game_variables[PA::V_E_N] > 0
enemies_size = $game_variables[PA::V_E_N]
else
case party_size
when 1
enemies_size = 1+rand(2)
when 2
enemies_size = 1+rand(4)
when 3
enemies_size = 1+rand(6)
when 4
enemies_size = 1+rand(8)
end
end
troop_members = []
# 没注意这是实例,晕! @_@
troop_all = $data_troops[@troop_id].clone
# 使敌人组按指定顺序排列,比如在战斗前调用脚本 $special_array =[0,1,1,2,2]
if $special_array != nil
for i in 0...$special_array.size
troop_members.push troop_all.members[$special_array[i]]
end
# 普通遇敌
else
if $game_switches[PA::S_E_O] == false
# 1号ID敌人必须出现在1号位
if $game_switches[PA::S_E_M] == true
enemy_index = 0
for i in 0...enemies_size
troop_members.push troop_all.members[enemy_index]
enemy_index = 1 + rand(troop_all.members.size - 1)
end
else
for i in 0...enemies_size
enemy_index = rand(troop_all.members.size)
troop_members.push troop_all.members[enemy_index]
end
end
end
end
troop_all.members = troop_members
return troop_all
end
#--------------------------------------------------------------------------
# ○ 设定敌人坐标
#--------------------------------------------------------------------------
def setup_coordinate_x
# 获取宽度数组
width = []
# 获取宽度和
width_all = 0
for i in 0...troop.members.size
width.push battle_graphic_width(i)
width_all += width[i]
end
# 计算间距
space = [(Graphics.width-width_all)/(troop.members.size), SPACE].min
space = [(Graphics.width-width_all)/(troop.members.size-1), SPACE].min if troop.members.size > 1
# 预算外
width_all += space * (troop.members.size-1)
# 计算首敌横坐标
x = (Graphics.width - width_all) / 2
x += width[0]/2
x = width[0]/2 if x < width[0]/2
# 循环返回值数组
@coordinate_x.push(x)
for i in 1...troop.members.size
x += width[i-1]/2 + width[i]/2 + space
@coordinate_x.push x
end
end
#--------------------------------------------------------------------------
# ○ 获取敌人战斗图宽度
# index : 敌人队内序号
#--------------------------------------------------------------------------
def battle_graphic_width(index)
id = troop.members[index].enemy_id
battler_name = $data_enemies[id].battler_name
battler_hue = $data_enemies[id].battler_hue
bitmap = Cache.battler(battler_name, battler_hue)
return bitmap.width
end
#--------------------------------------------------------------------------
# ● 设置
# troop_id : 敌方队伍 ID
# enemy_id : 敌人 ID
#--------------------------------------------------------------------------
def setup(troop_id, enemy_id = 0)
clear
@troop_id = troop_id
# 生成敌方队伍
@troop = setup_troop(enemy_id)
# 新坐标重排
setup_coordinate_x
@enemies = []
a = 1
for member in troop.members
next if $data_enemies[member.enemy_id] == nil
enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
enemy.hidden = member.hidden
enemy.immortal = member.immortal
case a
when 1
enemy.screen_x = 100
enemy.screen_y = 350
when 2
enemy.screen_x = 200
enemy.screen_y = 350
when 3
enemy.screen_x = 300
enemy.screen_y = 350
when 4
enemy.screen_x = 400
enemy.screen_y = 350
when 5
enemy.screen_x = 100
enemy.screen_y = 200
when 6
enemy.screen_x = 200
enemy.screen_y = 200
when 7
enemy.screen_x = 300
enemy.screen_y = 200
when 8
enemy.screen_x = 400
enemy.screen_y = 200
end
a += 1
@enemies.push(enemy)
end
make_unique_names
end
end |
|