幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1481|回复: 1

[已解决] 自定义移动躲避问题

[复制链接]

10

主题

15

帖子

1905

积分

⑥精研

积分
1905
QQ
发表于 2010-1-19 11:14:35 | 显示全部楼层 |阅读模式
我找了一个自定义移动的脚本,可惜太不智能,遇到建筑物或东西时不能躲开,直到走死也不出来
导致不能到达终点
谁能帮忙看看这问题怎么解决


---------------------------------------------------------------------------------------
  1. #使用方法:在自定义移动中·脚本·输入
  2. #move_toward(指定地点x坐标,指定地点y坐标,事件ID)
  3. #其中事件ID可写,可不写~
  4. class Game_Character
  5.   def move_toward(x,y,event=nil)
  6.     (x = $game_map.events[event].x ; y = $game_map.events[event].y) if event != nil
  7.     sx = @x - x
  8.     sy = @y - y
  9.     if sx == 0 and sy == 0
  10.       return
  11.     end
  12.     abs_sx = sx.abs
  13.     abs_sy = sy.abs
  14.     if abs_sx == abs_sy
  15.       rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  16.     end
  17.     if abs_sx > abs_sy
  18.       sx > 0 ? move_left : move_right
  19.       if not moving? and sy != 0
  20.         sy > 0 ? move_up : move_down
  21.       end
  22.     else
  23.       sy > 0 ? move_up : move_down
  24.       if not moving? and sx != 0
  25.         sx > 0 ? move_left : move_right
  26.       end
  27.     end
  28.   end
  29. end
复制代码
回复

使用道具 举报

15

主题

271

帖子

2198

积分

⑥精研

我要疯狂积累活跃度!

积分
2198
QQ
发表于 2010-1-19 13:19:47 | 显示全部楼层


http://www.rpgchina.net/read-htm-tid-36905-fpage-4.html
范例里面有移动脚本,自己照着弄就行了。很好用
紫月光流奈河畔, 孤影独行笑苍天。 酆都倒比人间好, 从此慕鬼不羡仙!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-5-14 17:25 , Processed in 0.019184 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表