#==============================================================================
# ■ XP敌人视野脚本 BY 万兽熊最高
# [url]http://bearrpg.weebly.com[/url]
#==============================================================================
module SEEK
#定义敌人事件的标记,把敌人事件的名字改成下面设定的字符串就成。
ENE_TAG = "enemy"
#定义敌人的视野距离,默认为5格
SEEK_DIS = 5
#定义逃出视野距离,默认为7格
ESP_DIS = 7
#定义发现目标时播放的动画ID,默认98
ANI_ID = 98
end
class Game_Character
alias bearrpg update
def update
seek_player
bearrpg
end
#--------------------------------------------------------------------------
# ● 敌人追击范围判定
#--------------------------------------------------------------------------
def viewrange
if ($game_player.x-@x)**2 + ($game_player.y-@y)**2 < SEEK::SEEK_DIS**2
case @direction
when 2
return false if $game_player.y < @y
when 4
return false if $game_player.x > @x
when 6
return false if $game_player.x < @x
when 8
return false if $game_player.y > @y
end
return true
else
return false
end
end
#--------------------------------------------------------------------------
# ● 逃出视野范围
#--------------------------------------------------------------------------
def viewout
return false if ($game_player.x-@x)**2 + ($game_player.y-@y)**2 < SEEK::ESP_DIS**2
return true
end
#--------------------------------------------------------------------------
# ● 发现玩家
#--------------------------------------------------------------------------
def seek_player
return if @event == nil
return if @move_type == 0
for event in $game_map.events.values
if events = $game_map.events
if @event.name == SEEK::ENE_TAG
if !@seeking && viewrange
@animation_id = SEEK::ANI_ID
@remain = [@move_type, @move_speed]
@seeking = true
@move_type = 2
@move_speed = @remain[1] += 1
elsif @seeking && viewout
@seeking = false
if @remain != nil
@move_type = @remain[0]
@move_speed -= 1
end
end
end
end
end
end
end