设为首页收藏本站

仙剑之十里坡

 找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 4334|回复: 8
打印 上一主题 下一主题

真·八方向走ver1.1

[复制链接]

67

主题

2

听众

2064

积分

仗剑行侠

会员等级: 5

  • TA的每日心情
    无聊
    2013-8-16 09:01
  • 签到天数: 161 天

    [LV.7]常住仙友III

    精华
    0
    积分
    2064
    历练
    0
    声望
    43
    人气
    3
    单身中……
    帮我摆脱单身吧
    跳转到指定楼层
    1
    发表于 2010-11-7 20:37:45 |只看该作者 |倒序浏览
    本帖最后由 御剑奇侠 于 2010-11-9 19:42 编辑

    1. #==============================================================================
    2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
    3. #==============================================================================
    4. class Game_Player < Game_Character
    5. if $c3_总共可用的方向数 == 8
    6. def update
    7. last_moving = moving?
    8. unless moving? or $game_system.map_interpreter.running? or
    9. @move_route_forcing or $game_temp.message_window_showing
    10. # 用井号后面的东西替代前面的,就可以实现斜4方向走
    11. case Input.dir8
    12. when 2
    13. move_down #move_lower_left
    14. when 4
    15. move_left #move_upper_left
    16. when 6
    17. move_right #move_lower_right
    18. when 8
    19. move_up #move_upper_right
    20. when 1
    21. move_lower_left
    22. when 3
    23. move_lower_right
    24. when 7
    25. move_upper_left
    26. when 9
    27. move_upper_right
    28. end
    29. end
    30. # 本地变量记忆坐标
    31. last_real_x = @real_x
    32. last_real_y = @real_y
    33. super
    34. # 角色向下移动、画面上的位置在中央下方的情况下
    35. if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
    36. # 画面向下卷动
    37. $game_map.scroll_down(@real_y - last_real_y)
    38. end
    39. # 角色向左移动、画面上的位置在中央左方的情况下
    40. if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
    41. # 画面向左卷动
    42. $game_map.scroll_left(last_real_x - @real_x)
    43. end
    44. # 角色向右移动、画面上的位置在中央右方的情况下
    45. if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
    46. # 画面向右卷动
    47. $game_map.scroll_right(@real_x - last_real_x)
    48. end
    49. # 角色向上移动、画面上的位置在中央上方的情况下
    50. if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
    51. # 画面向上卷动
    52. $game_map.scroll_up(last_real_y - @real_y)
    53. end
    54. # 不在移动中的情况下
    55. unless moving?
    56. # 上次主角移动中的情况
    57. if last_moving
    58. # 与同位置的事件接触就判定为事件启动
    59. result = check_event_trigger_here([1,2])
    60. # 没有可以启动的事件的情况下
    61. if result == false
    62. # 调试模式为 ON 并且按下 CTRL 键的情况下除外
    63. unless $DEBUG and Input.press?(Input::CTRL)
    64. # 遇敌计数下降
    65. if @encounter_count > 0
    66. @encounter_count -= 1
    67. end
    68. end
    69. end
    70. end
    71. # 按下 C 键的情况下
    72. if Input.trigger?(Input::C)
    73. # 判定为同位置以及正面的事件启动
    74. check_event_trigger_here([0])
    75. check_event_trigger_there([0,1,2])
    76. end
    77. end
    78. end
    79. #--------------------------------------------------------------------------
    80. # ● 正面事件的启动判定
    81. #--------------------------------------------------------------------------
    82. def check_event_trigger_there(triggers)
    83. result = false
    84. # 事件执行中的情况下
    85. if $game_system.map_interpreter.running?
    86. return result
    87. end
    88. # 计算正面坐标
    89. new_x = @x
    90. new_y = @y
    91. case @direction
    92. when 1
    93. new_x -= 1
    94. new_y += 1
    95. when 2
    96. new_y += 1
    97. when 3
    98. new_x += 1
    99. new_y += 1
    100. when 4
    101. new_x -= 1
    102. when 6
    103. new_x += 1
    104. when 7
    105. new_x -= 1
    106. new_y -= 1
    107. when 8
    108. new_y -= 1
    109. when 9
    110. new_x += 1
    111. new_y -= 1
    112. end
    113. # 全部事件的循环
    114. for event in $game_map.events.values
    115. # 事件坐标与目标一致的情况下
    116. if event.x == new_x and event.y == new_y and
    117. triggers.include?(event.trigger)
    118. # 跳跃中以外的情况下、启动判定是正面的事件
    119. if not event.jumping? and not event.over_trigger?
    120. event.start
    121. result = true
    122. end
    123. end
    124. end
    125. # 找不到符合条件的事件的情况下
    126. if result == false
    127. # 正面的元件是计数器的情况下
    128. if $game_map.counter?(new_x, new_y)
    129. # 计算 1 元件里侧的坐标
    130. new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    131. new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    132. # 全事件的循环
    133. for event in $game_map.events.values
    134. # 事件坐标与目标一致的情况下
    135. if event.x == new_x and event.y == new_y and
    136. triggers.include?(event.trigger)
    137. # 跳跃中以外的情况下、启动判定是正面的事件
    138. if not event.jumping? and not event.over_trigger?
    139. event.start
    140. result = true
    141. end
    142. end
    143. end
    144. end
    145. end
    146. return result
    147. end
    148. #--------------------------------------------------------------------------
    149. # ● 向左下移动
    150. #--------------------------------------------------------------------------
    151. def move_lower_left
    152. # 没有固定面向的场合
    153. unless @direction_fix
    154. # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
    155. @direction = 1#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
    156. end
    157. # 下→左、左→下
    158. 的通道可以通行的情况下
    159. if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
    160. (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
    161. # 更新坐标
    162. @x -= 1
    163. @y += 1
    164. # 增加步数
    165. increase_steps
    166. else
    167. check_event_trigger_touch(@x-1, @y+1)
    168. end
    169. end
    170. #--------------------------------------------------------------------------
    171. # ● 向右下移动
    172. #--------------------------------------------------------------------------
    173. def move_lower_right
    174. # 没有固定面向的场合
    175. unless @direction_fix
    176. # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
    177. @direction = 3#(@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
    178. end
    179. # 下→右、右→下
    180. 的通道可以通行的情况下
    181. if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
    182. (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
    183. # 更新坐标
    184. @x += 1
    185. @y += 1
    186. # 增加步数
    187. increase_steps
    188. else
    189. check_event_trigger_touch(@x+1, @y+1)
    190. end
    191. end
    192. #--------------------------------------------------------------------------
    193. # ● 向左上移动
    194. #--------------------------------------------------------------------------
    195. def move_upper_left
    196. # 没有固定面向的场合
    197. unless @direction_fix
    198. # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
    199. @direction = 7#(@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
    200. end
    201. # 上→左、左→上
    202. 的通道可以通行的情况下
    203. if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
    204. (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
    205. # 更新坐标
    206. @x -= 1
    207. @y -= 1
    208. # 增加步数
    209. increase_steps
    210. else
    211. check_event_trigger_touch(@x-1, @y-1)
    212. end
    213. end
    214. #--------------------------------------------------------------------------
    215. # ● 向右上移动
    216. #--------------------------------------------------------------------------
    217. def move_upper_right
    218. # 没有固定面向的场合
    219. unless @direction_fix
    220. # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
    221. @direction = 9#(@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
    222. end
    223. # 上→右、右→上 的通道可以通行的情况下
    224. if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
    225. (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
    226. # 更新坐标
    227. @x += 1
    228. @y -= 1
    229. # 增加步数
    230. increase_steps
    231. else
    232. check_event_trigger_touch(@x+1, @y-1)
    233. end
    234. end
    235. #--------------------------------------------------------------------------
    236. # ● 雅土左下移動
    237. #--------------------------------------------------------------------------
    238. def move_lower_left_p
    239. unless @direction_fix
    240. @direction = 1
    241. end
    242. distance = (2 ** @move_speed) / Math.sqrt(2)
    243. turn_left unless down1(@x, @y, distance)
    244. turn_down if @event
    245. turn_down unless left1(@x, @y, distance) unless @event
    246. turn_left if @event
    247. end
    248. #--------------------------------------------------------------------------
    249. # ● 雅土右下移動
    250. #--------------------------------------------------------------------------
    251. def move_lower_right_p
    252. unless @direction_fix
    253. @direction = 3
    254. end
    255. distance = (2 ** @move_speed) / Math.sqrt(2)
    256. turn_right unless down1(@x, @y, distance)
    257. turn_down if @event
    258. turn_down unless right1(@x, @y, distance) unless @event
    259. turn_right if @event
    260. end
    复制代码
    分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    转播转播0 分享淘帖0 分享分享0 收藏收藏0
    蜉蝣之羽,衣裳楚楚。心之忧矣,於我归处?
    蜉蝣之翼,采采衣服。心之忧矣,於我归息?
    蜉蝣掘阅,麻衣如雪。心之忧矣,於我归说?

    67

    主题

    2

    听众

    2064

    积分

    仗剑行侠

    会员等级: 5

  • TA的每日心情
    无聊
    2013-8-16 09:01
  • 签到天数: 161 天

    [LV.7]常住仙友III

    精华
    0
    积分
    2064
    历练
    0
    声望
    43
    人气
    3
    单身中……
    帮我摆脱单身吧
    2
    发表于 2010-11-7 20:38:31 |只看该作者
    1. #--------------------------------------------------------------------------
    2. # ● 雅土左上移動
    3. #--------------------------------------------------------------------------
    4. def move_upper_left_p
    5. unless @direction_fix
    6. @direction = 7
    7. end
    8. distance = (2 ** @move_speed) / Math.sqrt(2)
    9. turn_left unless up1(@x, @y, distance)
    10. turn_up if @event
    11. turn_up unless left1(@x, @y, distance) unless @event
    12. turn_left if @event
    13. end
    14. #--------------------------------------------------------------------------
    15. # ● 雅土右上移動
    16. #--------------------------------------------------------------------------
    17. def move_upper_right_p
    18. unless @direction_fix
    19. @direction = 9
    20. end
    21. distance = (2 ** @move_speed) / Math.sqrt(2)
    22. turn_right unless up1(@x, @y, distance)
    23. turn_up if @event
    24. turn_up unless right1(@x, @y, distance) unless @event
    25. turn_right if @event
    26. end
    27. end
    28. end


    29. class Sprite_Character < RPG::Sprite
    30. def update
    31. super
    32. # 元件 ID、文件名、色相与现在的情况存在差异的情况下
    33. if @tile_id != @character.tile_id or
    34. @character_name != @character.character_name or
    35. @character_hue != @character.character_hue
    36. # 记忆元件 ID 与文件名、色相
    37. @tile_id = @character.tile_id
    38. @character_name = @character.character_name
    39. @character_hue = @character.character_hue
    40. # 元件 ID 为有效值的情况下
    41. if @tile_id >= 384
    42. self.bitmap = RPG::Cache.tile($game_map.tileset_name,
    43. @tile_id, @character.character_hue)
    44. self.src_rect.set(0, 0, 32, 32)
    45. self.ox = 16
    46. self.oy = 32
    47. # 元件 ID 为无效值的情况下
    48. else
    49. self.bitmap = RPG::Cache.character(@character.character_name,
    50. @character.character_hue)
    51. @cw = bitmap.width / $c3_每一步的帧数
    52. if $c3_总共可用的方向数==4
    53. @ch = bitmap.height / 4
    54. else
    55. @ch = bitmap.height / 8
    56. end
    57. self.ox = @cw / 2
    58. self.oy = @ch
    59. end
    60. end
    61. # 设置可视状态
    62. self.visible = (not @character.transparent)
    63. # 图形是角色的情况下
    64. if @tile_id == 0
    65. # 设置传送目标的矩形
    66. sx = @character.pattern * @cw
    67. if $c3_总共可用的方向数==8
    68. case @character.direction
    69. when 2
    70. sy = 0 * @ch
    71. when 4
    72. sy = 1 * @ch
    73. when 6
    74. sy = 2 * @ch
    75. when 8
    76. sy = 3 * @ch
    77. when 1
    78. sy = 4 * @ch
    79. when 3
    80. sy = 5 * @ch
    81. when 7
    82. sy = 6 * @ch
    83. when 9
    84. sy = 7 * @ch
    85. end
    86. else
    87. sy = (@character.direction - 2) / 2 * @ch
    88. end
    89. self.src_rect.set(sx, sy, @cw, @ch)
    90. end
    91. # 设置脚本的坐标
    92. self.x = @character.screen_x
    93. self.y = @character.screen_y
    94. self.z = @character.screen_z(@ch)
    95. # 设置不透明度、合成方式、茂密
    96. self.opacity = @character.opacity
    97. self.blend_type = @character.blend_type
    98. self.bush_depth = @character.bush_depth
    99. # 动画
    100. if @character.animation_id != 0
    101. animation = $data_animations[@character.animation_id]
    102. animation(animation, true)
    103. @character.animation_id = 0
    104. end
    105. end
    106. end

    107. class Game_Character
    108. def c8
    109. # 随机 0~5 的分支
    110. case rand(10)
    111. when 0..3 # 随机
    112. move_random
    113. when 4 # 前进一步
    114. move_forward
    115. when 5 # 暂时停止
    116. @stop_count = 0
    117. when 6..9 #另外4方向随机
    118. c4
    119. end
    120. end
    121. def c4
    122. case rand(5)
    123. when 0
    124. move_upper_left
    125. when 1
    126. move_upper_right
    127. when 2
    128. move_lower_left
    129. when 3
    130. move_lower_right
    131. when 4
    132. @stop_count = 0
    133. end
    134. end

    135. def update
    136. # 跳跃中、移动中、停止中的分支
    137. if jumping?
    138. update_jump
    139. elsif moving?
    140. update_move
    141. else
    142. update_stop
    143. end
    144. # 动画计数超过最大值的情况下
    145. # ※最大值等于基本值减去移动速度 * 1 的值
    146. if @anime_count > 16*4/$c3_每一步的帧数 - @move_speed * 2
    147. # 停止动画为 OFF 并且在停止中的情况下
    148. if not @step_anime and @stop_count > 0
    149. # 还原为原来的图形
    150. @pattern = @original_pattern
    151. # 停止动画为 ON 并且在移动中的情况下
    152. else
    153. # 更新图形
    154. @pattern = (@pattern + 1) % $c3_每一步的帧数
    155. end
    156. # 清除动画计数
    157. @anime_count = 0
    158. end
    159. # 等待中的情况下
    160. if @wait_count > 0
    161. # 减少等待计数
    162. @wait_count -= 1
    163. return
    164. end
    165. # 强制移动路线的场合
    166. if @move_route_forcing
    167. # 自定义移动
    168. move_type_custom
    169. return
    170. end
    171. # 事件执行待机中并且为锁定状态的情况下
    172. if @starting or lock?
    173. # 不做规则移动
    174. return
    175. end
    176. # 如果停止计数超过了一定的值(由移动频度算出)
    177. if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
    178. # 移动类型分支
    179. case @move_type
    180. when 1 # 随机
    181. move_type_random
    182. when 2 # 接近
    183. move_type_toward_player
    184. when 3 # 自定义
    185. move_type_custom
    186. end
    187. end
    188. end
    189. end

    190. class Window_Base < Window
    191. def draw_actor_graphic(actor, x, y)
    192. bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    193. cw = bitmap.width / $c3_每一步的帧数
    194. ch = bitmap.height / $c3_总共可用的方向数
    195. src_rect = Rect.new(0, 0, cw, ch)
    196. self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
    197. end
    198. end

    199. class Game_Character
    200. #--------------------------------------------------------------------------
    201. # ● 面向主角的方向
    202. #--------------------------------------------------------------------------
    203. def turn_toward_player
    204. # 求得与主角的坐标差
    205. sx = @x - $game_player.x
    206. sy = @y - $game_player.y
    207. # 坐标相等的场合下
    208. if sx == 0 and sy == 0
    209. return
    210. end
    211. # 横侧距离长的情况下
    212. if sx.abs > sy.abs
    213. # 将左右方向变更为朝向主角的方向
    214. sx > 0 ? turn_left : turn_right
    215. # 竖侧距离长的情况下
    216. else
    217. # 将上下方向变更为朝向主角的方向
    218. sy > 0 ? turn_up : turn_down
    219. end
    220. if sx == -1 and sy == -1
    221. @direction = 3
    222. @stop_count = 0
    223. elsif sx == -1 and sy == 1
    224. @direction = 9
    225. @stop_count = 0
    226. elsif sx == 1 and sy == -1
    227. @direction = 1
    228. @stop_count = 0
    229. elsif sx == 1 and sy == 1
    230. @direction = 7
    231. @stop_count = 0
    232. end
    233. end
    234. end

    235. #==============================================================================
    236. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
    237. #==============================================================================
    复制代码


    全选后将两个脚本插入到main前面的一个脚本中,请参考脚本开头部分的注释。
    脚本冲突可能:极少数地图类,但是和伪·八方向走丝毫不冲突。
    蜉蝣之羽,衣裳楚楚。心之忧矣,於我归处?
    蜉蝣之翼,采采衣服。心之忧矣,於我归息?
    蜉蝣掘阅,麻衣如雪。心之忧矣,於我归说?
    回复

    使用道具 举报

    160

    主题

    6

    听众

    1万

    积分

    超级版主

    蜀山剑侠银行行长

    超级版主

  • TA的每日心情
    开心
    3 天前
  • 签到天数: 859 天

    [LV.10]以坛为家III

    精华
    3
    积分
    13202
    历练
    7
    声望
    24
    人气
    2364

    金融巨子 润泽万物 坚若磐石

    单身中……
    帮我摆脱单身吧
    3
    发表于 2010-11-7 22:00:08 |只看该作者
    我没记错的话,这个脚本我也在这个版看过,御剑你下次发之前看看会不会重复好不?
    于是饮酒乐甚,扣舷而歌之。歌曰:“桂棹兮兰桨,击空明兮溯流光。残阳阳兮是羊羊,吾乃最爱南宫煌。”
    回复

    使用道具 举报

    67

    主题

    2

    听众

    2064

    积分

    仗剑行侠

    会员等级: 5

  • TA的每日心情
    无聊
    2013-8-16 09:01
  • 签到天数: 161 天

    [LV.7]常住仙友III

    精华
    0
    积分
    2064
    历练
    0
    声望
    43
    人气
    3
    单身中……
    帮我摆脱单身吧
    4
    发表于 2010-11-7 22:36:19 |只看该作者
    咦?为什么我没看见捏??
    蜉蝣之羽,衣裳楚楚。心之忧矣,於我归处?
    蜉蝣之翼,采采衣服。心之忧矣,於我归息?
    蜉蝣掘阅,麻衣如雪。心之忧矣,於我归说?
    回复

    使用道具 举报

    107

    主题

    6

    听众

    4719

    积分

    版主

    [- 血夜系列作者 -]

    版主

  • TA的每日心情
    无聊
    2015-7-18 22:25
  • 签到天数: 123 天

    [LV.7]常住仙友III

    精华
    1
    积分
    4719
    历练
    3
    声望
    20
    人气
    548

    黑色羽翼 神仙眷侣 出神入化 妙笔生花 灵动清风 匠心独运 鬼斧神工

    吳述兒
    幸福:72℃
    5
    发表于 2010-11-8 04:43:51 |只看该作者
    御剑你…连帖X2
    哎...我不是管理这板块编辑不了...
    你发脚本的话可以学南瓜插入代码的吖....你这样直接复制黏贴过来....
    很长哎...

           
    回复

    使用道具 举报

    160

    主题

    6

    听众

    1万

    积分

    超级版主

    蜀山剑侠银行行长

    超级版主

  • TA的每日心情
    开心
    3 天前
  • 签到天数: 859 天

    [LV.10]以坛为家III

    精华
    3
    积分
    13202
    历练
    7
    声望
    24
    人气
    2364

    金融巨子 润泽万物 坚若磐石

    单身中……
    帮我摆脱单身吧
    6
    发表于 2010-11-8 06:08:27 |只看该作者
    八方行走啊,我真的觉得见过呢,我记错了吗?
    于是饮酒乐甚,扣舷而歌之。歌曰:“桂棹兮兰桨,击空明兮溯流光。残阳阳兮是羊羊,吾乃最爱南宫煌。”
    回复

    使用道具 举报

    1082

    主题

    15

    听众

    1万

    积分

    管理员

    魔尊

    管理员

  • TA的每日心情
    无聊
    2024-4-22 00:16
  • 签到天数: 2281 天

    [LV.Master]伴坛终老

    精华
    3
    积分
    18263
    历练
    9
    声望
    342
    人气
    6122

    出神入化 润泽万物 金融巨子 神仙眷侣

    佛珠
    幸福:605℃
    7
    发表于 2010-11-8 11:15:57 |只看该作者
    回复 7# 最爱南宫煌


        我也没搜到 可能你在别的地方看得吧
    回复

    使用道具 举报

    22

    主题

    1

    听众

    2118

    积分

    仗剑行侠

    会员等级: 5

  • TA的每日心情
    无聊
    2012-2-12 03:34
  • 签到天数: 57 天

    [LV.5]常住仙友I

    精华
    0
    积分
    2118
    历练
    1
    声望
    12
    人气
    189
    单身中……
    帮我摆脱单身吧
    8
    发表于 2010-11-8 13:47:40 |只看该作者
    话说真的跟伪的有什么区别呢?
    仙劍online台服   全區—pvp夢璃(原過云坊)
    玄小北—劍俠—35級
    十裡坡的童鞋如果要玩仙劍ol台服
    記得來這個區m我哦
    有福利的說~
    回复

    使用道具 举报

    827

    主题

    7

    听众

    1万

    积分

    御剑江湖

    秘密

    会员等级: 8

  • TA的每日心情
    无聊
    昨天 07:58
  • 签到天数: 2890 天

    [LV.Master]伴坛终老

    精华
    0
    积分
    13017
    历练
    0
    声望
    411
    人气
    373

    转帖之王 匠心独运

    单身中……
    帮我摆脱单身吧
    9
    发表于 2010-11-9 18:11:59 |只看该作者
    在雨的模板貌似找到过~
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 加入我们

    手机版|Archiver|仙剑之十里坡 ( 苏ICP备11022766号 )  

    GMT+8, 2024-5-4 16:33 , Processed in 0.563395 second(s), 63 queries .

    Powered by Discuz! X2.5

    © 2001-2012 Comsenz Inc.

    回顶部