class Gun_battle
def start
$mun_id = 0
$ok2 = 0
$orientation = $game_player.direction
find_id_and_voluation
l
end
def find_id_and_voluation
idArray = $game_map.events.keys.find_all{|id| $game_map.events[id].name == '丧尸'}
for @event_id in idArray
x = $game_player.x
y = $game_player.y
ax = $game_map.events[@event_id].x
ay = $game_map.events[@event_id].y
#------------------------------------朝向右时
if y == ay then
if $orientation == 6 # 【 and Input.press? (:C) 】这段代码等下加下去,先去掉....
for bx in x..ax
#------------------------------------判断敌人与角色间是否有障碍物,$ok2= 0时为没有。
a = $game_map.check_passage(bx,y,0x0f)
if a == false
$ok2 = $ok2 + 1
end
end
#-----------------------------------当角色朝右,敌人的X坐标应大于角色,但是敌人的X的坐标不能大于子弹射程,这时判定为击中。
if x < ax and ax < x + 17 then
$ok1 = 0
if $mun_id == 0
$axy = @event_id
$mun_id = 1
end
end
end
end
end
end
#--------------------满足没有障碍物,在射程内,改变变量7的数值
def l
if $ok1 == 0 and $ok2 == 0 then
$game_variables[7]= $axy
end
end
end