Project1
标题:
如何让角色碰到路障就自动饶开?
[打印本页]
作者:
宾少
时间:
2007-9-3 05:49
标题:
如何让角色碰到路障就自动饶开?
用纯事件来做的话,好象不大可能。(量太大了!{/gg})
在石焚刃暖中,有这样的效果。我把那个游戏下载了,但还是不知道怎么做,而且不知道为什么,那个游戏老出错。
请教大大们该杂弄? [LINE]1,#dddddd[/LINE]
版务信息:本贴由楼主自主结贴~
作者:
宾少
时间:
2007-9-3 05:49
标题:
如何让角色碰到路障就自动饶开?
用纯事件来做的话,好象不大可能。(量太大了!{/gg})
在石焚刃暖中,有这样的效果。我把那个游戏下载了,但还是不知道怎么做,而且不知道为什么,那个游戏老出错。
请教大大们该杂弄? [LINE]1,#dddddd[/LINE]
版务信息:本贴由楼主自主结贴~
作者:
柳柳
时间:
2007-9-5 06:09
石焚刃暖中没有这个效果,这只是你的错觉。
普通做法就是这样:http://rpg.blue/viewthread.php?tid=39702
或者也有别的方法,比如你用地形标志,这样走路的时候不断判断地形标志决定主角的绕行方法就行了。但是对脚本有一定要求,而且设置起来比较麻烦。
当然也可以制作一个专用工具来设置绕行,不过没什么必要……
作者:
美兽
时间:
2007-9-5 12:55
那个是寻路算法,
附加在鼠标脚本中,
脱离版本有人曾做个使用工程。
http://rpg.blue/web/htm/news566.htm
不过后来作者在某张回帖修改过,主站没有更新。
作者:
新月の道化师
时间:
2007-9-5 16:38
这个脚本也可以实现绕路功能的
http://rpg.blue/viewthread.php?tid=65895
作者:
幻の飞鱼
时间:
2007-9-6 00:40
自动饶开的我记得我写过一个=。=
这里
#==============================================================================
# 使用方法:
# 1.直接插在MAIN前即可使用
# 2.面对事件不进行自动转向
# 3.对于个别需要自动转向的事件,在该事件的第一页第一行写一句注释"not_npc"(不含引号)
#
#------------------------------------------------------------------------------
class Game_Character
#--------------------------------------------------------------------------
# ● 可以通行判定
# x : X 坐标
# y : Y 坐标
# d : 方向 (0,2,4,6,8) ※ 0 = 全方向不能通行的情况判定 (跳跃用)
#--------------------------------------------------------------------------
def passable?(x, y, d)
#---------------------------
$isnpc = true
#---------------------------
# 求得新的坐标
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# 坐标在地图以外的情况
unless $game_map.valid?(new_x, new_y)
# 不能通行
return false
end
# 穿透是 ON 的情况下
if @through
# 可以通行
return true
end
# 移动者的元件无法来到指定方向的情况下
unless $game_map.passable?(x, y, d, self)
# 通行不可
return false
end
# 从指定方向不能进入到移动处的元件的情况下
unless $game_map.passable?(new_x, new_y, 10 - d)
# 不能通行
return false
end
# 循环全部事件
for event in $game_map.events.values
# 事件坐标于移动目标坐标一致的情况下
if event.x == new_x and event.y == new_y
# 穿透为 ON
unless event.through
# 自己就是事件的情况下
if self != $game_player
# 不能通行
#---------------------------
$isnpc = false if event.list[0].parameters[0] != "not_npc"
#---------------------------
return false
end
# 自己是主角、对方的图形是角色的情况下
if event.character_name != ""
# 不能通行
#---------------------------
$isnpc = false if event.list[0].parameters[0] != "not_npc"
#---------------------------
return false
end
end
end
end
# 主角的坐标与移动目标坐标一致的情况下
if $game_player.x == new_x and $game_player.y == new_y
# 穿透为 ON
unless $game_player.through
# 自己的图形是角色的情况下
if @character_name != ""
# 不能通行
return false
end
end
end
# 可以通行
return true
end
#--------------------------------------------------------------------------
# ● 向下移动
# turn_enabled : 本场地位置更改许可标志
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
#---------------------------
direct = @direction
#---------------------------
# 面向下
if turn_enabled
turn_down
end
# 可以通行的场合
if passable?(@x, @y, 2)
# 面向下
turn_down
# 更新坐标
@y += 1
# 增加步数
increase_steps
# 不能通行的情况下
else
#---------------------------
if $isnpc
if passable?(@x, @y, 6) and passable?(@x+1, @y, 2) and passable?(@x, @y, 4) and passable?(@x-1, @y, 2)
move_left if direct == 4
move_right if direct == 6
if direct == 2 or direct == 8
randtra = rand(2)
randtra == 0 ? move_left : move_right
end
else
move_left if passable?(@x, @y, 4) and passable?(@x-1, @y, 2)
move_right if passable?(@x, @y, 6) and passable?(@x+1, @y, 2)
end
end
#---------------------------
# 接触事件的启动判定
check_event_trigger_touch(@x, @y+1)
end
end
#--------------------------------------------------------------------------
# ● 向左移动
# turn_enabled : 本场地位置更改许可标志
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
#---------------------------
direct = @direction
#---------------------------
# 面向左
if turn_enabled
turn_left
end
# 可以通行的情况下
if passable?(@x, @y, 4)
# 面向左
turn_left
# 更新坐标
@x -= 1
# 增加步数
increase_steps
# 不能通行的情况下
else
#---------------------------
if $isnpc
if passable?(@x, @y, 8) and passable?(@x, @y-1, 4) and passable?(@x, @y, 2) and passable?(@x, @y+1, 4)
move_up if direct == 8
move_down if direct == 2
if direct == 4 or direct == 6
randtra = rand(2)
randtra == 0 ? move_up : move_down
end
else
move_up if passable?(@x, @y, 8) and passable?(@x, @y-1, 4)
move_down if passable?(@x, @y, 2) and passable?(@x, @y+1, 4)
end
end
#---------------------------
# 接触事件的启动判定
check_event_trigger_touch(@x-1, @y)
end
end
#--------------------------------------------------------------------------
# ● 向右移动
# turn_enabled : 本场地位置更改许可标志
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
#---------------------------
direct = @direction
#---------------------------
# 面向右
if turn_enabled
turn_right
end
# 可以通行的场合
if passable?(@x, @y, 6)
# 面向右
turn_right
# 更新坐标
@x += 1
# 增加部数
increase_steps
# 不能通行的情况下
else
#---------------------------
if $isnpc
if passable?(@x, @y, 8) and passable?(@x, @y-1, 6) and passable?(@x, @y, 2) and passable?(@x, @y+1, 6)
move_up if direct == 8
move_down if direct == 2
if direct == 4 or direct == 6
randtra = rand(2)
randtra == 0 ? move_up : move_down
end
else
move_up if passable?(@x, @y, 8) and passable?(@x, @y-1, 6)
move_down if passable?(@x, @y, 2) and passable?(@x, @y+1, 6)
end
end
#---------------------------
# 接触事件的启动判定
check_event_trigger_touch(@x+1, @y)
end
end
#--------------------------------------------------------------------------
# ● 向上移动
# turn_enabled : 本场地位置更改许可标志
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
#---------------------------
direct = @direction
#---------------------------
# 面向上
if turn_enabled
turn_up
end
# 可以通行的情况下
if passable?(@x, @y, 8)
# 面向上
turn_up
# 更新坐标
@y -= 1
# 歩数増加
increase_steps
# 不能通行的情况下
else
#---------------------------
if $isnpc
if passable?(@x, @y, 6) and passable?(@x+1, @y, 8) and passable?(@x, @y, 4) and passable?(@x-1, @y, 8)
move_left if direct == 4
move_right if direct == 6
if direct == 2 or direct == 8
randtra = rand(2)
randtra == 0 ? move_left : move_right
end
else
move_left if passable?(@x, @y, 4) and passable?(@x-1, @y, 8)
move_right if passable?(@x, @y, 6) and passable?(@x+1, @y, 8)
end
end
#---------------------------
# 接触事件的启动判定
check_event_trigger_touch(@x, @y-1)
end
end
end
复制代码
[LINE]1,#dddddd[/LINE]
系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1