赞 | 204 |
VIP | 13 |
好人卡 | 7 |
积分 | 122 |
经验 | 52899 |
最后登录 | 2021-6-29 |
在线时间 | 4435 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 12157
- 在线时间
- 4435 小时
- 注册时间
- 2014-4-11
- 帖子
- 5955
|
本帖最后由 yang1zhi 于 2014-11-20 23:37 编辑
@z2214557w
我只能改成这样了。行的话就拿去吧
我知道你已经解决了。我来加强自己刚刚写的脚本- #==============================================================================
- # ■ Game_Character (接近专定义)
- #------------------------------------------------------------------------------
- # 处理角色的类。本类作为 Game_Player 类与 Game_Event
- # 类的超级类使用。
- #==============================================================================
- # 使用方法:
- # 在设置事件移动那里改为自定义,路线为:toward_player_add(x范围,y范围)
- #==============================================================================
- class Game_Character
- def toward_player_add(x = 1,y = 1)
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- # 求得与主角坐标的差
- sx = (@x - $game_player.x).abs
- sy = (@y - $game_player.y).abs
- if sx <= x and sy <= y
- turn_away_from_player
- if $game_map.passable?(new_x, new_y,0)
- move_away_from_player
- else
- turn_left_90
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- if $game_map.passable?(new_x, new_y,0)
- move_forward
- else
- turn_180
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- if $game_map.passable?(new_x, new_y,0)
- move_forward
- else
- turn_left_90
- move_backward
- turn_left_90
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- if $game_map.passable?(new_x, new_y,0)
- move_forward
- else
- turn_180
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- if $game_map.passable?(new_x, new_y,0)
- move_forward
- end
- end
- end
- end
- end
- else
- move_random
- end
- end
- end
复制代码 |
|