Project1
标题:
如何设置事件的视线?
[打印本页]
作者:
zxc123a4s5d6
时间:
2015-6-23 16:22
标题:
如何设置事件的视线?
是这样的,我想设计一个潜入任务,然后每一个事件都装了烛光系统的光晕,如果主角进去光晕则判定为暴露,事件会追主角,那么如何设置事件的视野?
作者:
百里_飞柳
时间:
2015-6-23 17:27
本帖最后由 百里_飞柳 于 2015-6-23 17:29 编辑
似乎要判定圆形区域的话……rm做的成吗?
我这里有一个收录的事件sensor range脚本,可以判定玩家距离事件的位置(即△x+△y的和,一个格子为1)为x时,事件页中的独立开关D打开。
使用方法:事件名称中添加 <SensorX> X替换为距离
#==============================================================================
# +++ MOG - Event Sensor Range (v1.0) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com
#==============================================================================
# Permite que o evento tenha dois comportamentos, de curta distância e de
# longa distância.
#===============================================================================
# - Utilização
# Crie uma página com a condição de ativação Self Switch D, está página será
# usada quando o player estiver perto do evento.
# Defina a area do sensor do evento colocando este nome no evento.
#
# <SensorX>
#
# X = 视野范围半径
#
#===============================================================================
module MOG_EVENT_SENSOR
#打开的独立开关
SENSOR_SELF_SWITCH = "D"
end
#===============================================================================
# ■ GAME EVENT
#===============================================================================
class Game_Event < Game_Character
attr_reader :sensor_range
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_event_sensor_initialize initialize
def initialize(map_id, event)
mog_event_sensor_initialize(map_id, event)
setup_event_sensor
end
#--------------------------------------------------------------------------
# ● Setup Event Sensor
#--------------------------------------------------------------------------
def setup_event_sensor
@sensor_range = @event.name =~ /<Sensor(\d+)>/ ? $1.to_i : 0
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_event_sensor_update update
def update
mog_event_sensor_update
update_event_sensor
end
#--------------------------------------------------------------------------
# ● Update Sensor
#--------------------------------------------------------------------------
def update_event_sensor
return if @sensor_range == 0
distance = ($game_player.x - self.x).abs + ($game_player.y - self.y).abs
enable = (distance <= @sensor_range)
key = [$game_map.map_id, self.id, MOG_EVENT_SENSOR::SENSOR_SELF_SWITCH]
last_enable = $game_self_switches[key]
execute_sensor_effect(enable,key) if enable != last_enable
end
#--------------------------------------------------------------------------
# ● Execute_Sensor Effect
#--------------------------------------------------------------------------
def execute_sensor_effect(enable,key)
@pattern = 0
@pattern_count = 0
$game_self_switches[key] = enable
self.refresh
end
end
$mog_rgss3_event_sensor = true
复制代码
作者:
墨凌羽
时间:
2015-6-23 19:52
我只知道一般这种高级的AI最好做成状态机。。。
如果有程序底子的话 去看看饥荒的源码(data/scripts/stategraphs文件夹里就是他的AI状态机的部分)
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1