赞 | 0 |
VIP | 31 |
好人卡 | 3 |
积分 | 5 |
经验 | 31161 |
最后登录 | 2024-7-2 |
在线时间 | 339 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 495
- 在线时间
- 339 小时
- 注册时间
- 2008-8-13
- 帖子
- 526
|
追踪敌人的脚本可以在Game_Character 3中这样写
#--------------------------------------------------------------------------
# ● 接近敌人
#--------------------------------------------------------------------------
def move_toward_event
#获取敌人的坐标
for event in $game_map.events.values
next if event.return_erased2
next if event.list == nil
next if event.list[0].code != 108
next if event.list[0].parameters[0] != "敌人"
eventx = event.x
eventy = event.y
end
# 求得与主角的坐标差
sx = @x - eventx
sy = @y - eventy
# 坐标相等情况下
if sx == 0 and sy == 0
return
end
# 求得差的绝对值
abs_sx = sx.abs
abs_sy = sy.abs
# 横距离与纵距离相等的情况下
if abs_sx == abs_sy
# 随机将边数增加 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# 横侧距离长的情况下
if abs_sx > abs_sy
# 左右方向优先。向主角移动
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
# 竖侧距离长的情况下
else
# 上下方向优先。向主角移动
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
然后给事件的自定义移动路线中设置成
◆脚本:move_toward_event
就可以了
个人认为ARPG还应该加入敌人挨打的图,那样更加真实[纯属虐美工- -] |
评分
-
查看全部评分
|