设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1665|回复: 5
打印 上一主题 下一主题

寻找传说中的xp斜四方行走脚本(1vip)

 关闭 [复制链接]

Lv2.观梦者

神隐的主犯

梦石
0
星屑
373
在线时间
271 小时
注册时间
2008-2-22
帖子
7691

贵宾

跳转到指定楼层
1
发表于 2008-5-17 23:43:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
RT,要可以用的哦。(废话 PAI飞)
版务信息:本贴由楼主自主结贴~

《天空之城 —— 破碎的命运》

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2007-5-28
帖子
364
2
发表于 2008-5-17 23:55:32 | 只看该作者
XP的为什么要发到VX区呢?

  1. #==============================================================================
  2. # ■ 斜行4方向
  3. class Game_Character
  4.   #--------------------------------------------------------------------------
  5.   # ● 向左下移動
  6.   #--------------------------------------------------------------------------
  7.   def move_lower_left(turn_enabled = true)
  8.     unless @direction_fix
  9.       turn_down
  10.     end
  11.     # 下→左、左→下 的通道可以通行的情況下
  12.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
  13.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
  14.       # 更新座標
  15.       @x -= 1
  16.       @y += 1
  17.       # 增加步數
  18.       increase_steps
  19.     else
  20.       check_event_trigger_touch(@x-1, @y+1)
  21.     end
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 向右下移動
  25.   #--------------------------------------------------------------------------
  26.   def move_lower_right(turn_enabled = true)
  27.     unless @direction_fix
  28.       turn_right
  29.     end
  30.     # 下→右、右→下 的通道可以通行的情況下
  31.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
  32.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
  33.       # 更新座標
  34.       @x += 1
  35.       @y += 1
  36.       # 增加步數
  37.       increase_steps
  38.     else
  39.       check_event_trigger_touch(@x+1, @y+1)
  40.     end
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 向左上移動
  44.   #--------------------------------------------------------------------------
  45.   def move_upper_left(turn_enabled = true)
  46.     unless @direction_fix
  47.       turn_left
  48.     end
  49.     # 上→左、左→上 的通道可以通行的情況下
  50.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
  51.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
  52.       # 更新座標
  53.       @x -= 1
  54.       @y -= 1
  55.       # 增加步數
  56.       increase_steps
  57.     else
  58.       check_event_trigger_touch(@x-1, @y-1)
  59.     end
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 向右上移動
  63.   #--------------------------------------------------------------------------
  64.   def move_upper_right(turn_enabled = true)
  65.     unless @direction_fix
  66.       turn_up
  67.     end
  68.     # 上→右、右→上 的通道可以通行的情況下
  69.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
  70.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
  71.       # 更新座標
  72.       @x += 1
  73.       @y -= 1
  74.       # 增加步數
  75.       increase_steps
  76.     else
  77.       check_event_trigger_touch(@x+1, @y-1)
  78.     end
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 隨機移動
  82.   #--------------------------------------------------------------------------
  83.   def move_random
  84.     case rand(4)
  85.     when 0  # 向左下移動
  86.       move_lower_left(false)
  87.     when 1  # 向左上移動
  88.       move_upper_left(false)
  89.     when 2  # 向右下移動
  90.       move_lower_right(false)
  91.     when 3  # 向右上移動
  92.       move_upper_right(false)
  93.     end
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 前進一步
  97.   #--------------------------------------------------------------------------
  98.   def move_forward
  99.     case @direction
  100.     when 2
  101.       move_lower_left(false)
  102.     when 4
  103.       move_upper_left(false)
  104.     when 6
  105.       move_lower_right(false)
  106.     when 8
  107.       move_upper_right(false)
  108.     end
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 後退一步
  112.   #--------------------------------------------------------------------------
  113.   def move_backward
  114.     # 記憶朝向固定訊息
  115.     last_direction_fix = @direction_fix
  116.     # 強制固定朝向
  117.     @direction_fix = true
  118.     # 朝向分歧
  119.     case @direction
  120.     when 2  # 下
  121.       move_upper_right(false)
  122.     when 4  # 左
  123.       move_lower_right(false)
  124.     when 6  # 右
  125.       move_upper_left(false)
  126.     when 8  # 上
  127.       move_lower_left(false)
  128.     end
  129.     # 還原朝向固定訊息
  130.     @direction_fix = last_direction_fix
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 面向主角的方向
  134.   #--------------------------------------------------------------------------
  135.   def turn_toward_player
  136.     # 求得與主角的座標差值
  137.     sx = @x - $game_player.x
  138.     sy = @y - $game_player.y
  139.     # 座標相等的場合下
  140.     if sx == 0 and sy == 0
  141.       return
  142.     end
  143.     if sx < 0 and sy > 0
  144.       turn_up
  145.     elsif sx > 0 and sy > 0
  146.       turn_left
  147.     elsif sx > 0 and sy < 0
  148.       turn_down
  149.     elsif sx < 0 and sy < 0
  150.       turn_right
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 背向主角的方向
  155.   #--------------------------------------------------------------------------
  156.   def turn_away_from_player
  157.     # 求得與主角的座標差
  158.     sx = @x - $game_player.x
  159.     sy = @y - $game_player.y
  160.     # 座標相等的場合下
  161.     if sx == 0 and sy == 0
  162.       return
  163.     end
  164.     if sx < 0 and sy > 0
  165.       turn_down
  166.     elsif sx > 0 and sy > 0
  167.       turn_right
  168.     elsif sx > 0 and sy < 0
  169.       turn_up
  170.     elsif sx < 0 and sy < 0
  171.       turn_left
  172.     end
  173.   end
  174. end
  175. #==============================================================================
  176. # ■ 正面事件的啟動判定
  177. #------------------------------------------------------------------------------
  178. #  事件啟動的判定。
  179. #  本類別的實例請參考 $game_player。
  180. #==============================================================================
  181. class Game_Player < Game_Character
  182.   def check_event_trigger_there(triggers)
  183.     result = false
  184.     # 事件執行中的情況下
  185.     if $game_system.map_interpreter.running?
  186.       return result
  187.     end
  188.     # 計算正面座標
  189. ##########################################################
  190.     case @direction
  191.      when 2
  192.        new_x = @x-1
  193.        new_y = @y+1
  194.      when 4
  195.        new_x = @x-1
  196.        new_y = @y-1
  197.      when 6
  198.        new_x = @x+1
  199.        new_y = @y+1  
  200.      when 8
  201.        new_x = @x+1
  202.        new_y = @y-1
  203.      end
  204. ##########################################################
  205.     # 全部事件的循環
  206.     for event in $game_map.events.values
  207.       # 事件座標與目標一致的情況下
  208.       if event.x == new_x and event.y == new_y and
  209.          triggers.include?(event.trigger)
  210.         # 跳躍中以外的情況下、啟動判定是正面的事件
  211.         if not event.jumping? and not event.over_trigger?
  212.           event.start
  213.           result = true
  214.         end
  215.       end
  216.     end
  217.     # 找不到符合條件的事件的情況下
  218.     if result == false
  219.       # 正面的元件是計數器的情況下
  220.       if $game_map.counter?(new_x, new_y)
  221.         # 計算 1 元件裡側的座標
  222. ##########################################################
  223.         case @direction
  224.          when 2
  225.            new_x = @x-1
  226.            new_y = @y+1
  227.          when 4
  228.            new_x = @x-1
  229.            new_y = @y-1
  230.          when 6
  231.            new_x = @x+1
  232.            new_y = @y+1  
  233.          when 8
  234.            new_x = @x+1
  235.            new_y = @y-1
  236.          end
  237. ##########################################################
  238.         # 全事件的循環
  239.         for event in $game_map.events.values
  240.           # 事件座標與目標一致的情況下
  241.           if event.x == new_x and event.y == new_y and
  242.              triggers.include?(event.trigger)
  243.             # 跳躍中以外的情況下、啟動判定是正面的事件
  244.             if not event.jumping? and not event.over_trigger?
  245.               event.start
  246.               result = true
  247.             end
  248.           end
  249.         end
  250.       end
  251.     end
  252.     return result
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 畫面更新
  256.   #--------------------------------------------------------------------------
  257.   def update
  258.     # 本地變數記錄移動訊息
  259.     last_moving = moving?
  260.     # 移動中、事件執行中、強制移動路線中、
  261.     # 訊息視窗一個也不顯示的時候
  262.     unless moving? or $game_system.map_interpreter.running? or
  263.            @move_route_forcing or $game_temp.message_window_showing
  264.       # 如果方向鍵被按下、主角就朝那個方向移動
  265. ######################################################################
  266.      case Input.dir4
  267.       when 2
  268.         move_lower_right
  269.       when 4
  270.         move_lower_left
  271.       when 6
  272.         move_upper_right
  273.       when 8
  274.         move_upper_left
  275.       end
  276. ######################################################################
  277.     end
  278.     # 本地變數記憶座標
  279.     last_real_x = @real_x
  280.     last_real_y = @real_y
  281.     super
  282.     # 角色向下移動、畫面上的位置在中央下方的情況下
  283.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  284.       # 畫面向下捲動
  285.       $game_map.scroll_down(@real_y - last_real_y)
  286.     end
  287.     # 角色向左移動、畫面上的位置在中央左方的情況下
  288.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  289.       # 畫面向左捲動
  290.       $game_map.scroll_left(last_real_x - @real_x)
  291.     end
  292.     # 角色向右移動、畫面上的位置在中央右方的情況下
  293.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  294.       # 畫面向右捲動
  295.       $game_map.scroll_right(@real_x - last_real_x)
  296.     end
  297.     # 角色向上移動、畫面上的位置在中央上方的情況下
  298.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  299.       # 畫面向上捲動
  300.       $game_map.scroll_up(last_real_y - @real_y)
  301.     end
  302.     # 不在移動中的情況下
  303.     unless moving?
  304.       # 上次主角移動中的情況
  305.       if last_moving
  306.         # 與同位置的事件接觸就判定為事件啟動
  307.         result = check_event_trigger_here([1,2])
  308.         # 沒有可以啟動的事件的情況下
  309.         if result == false
  310.           # 偵錯模式為 ON 並且按下 CTRL 鍵的情況下除外
  311.           unless $DEBUG and Input.press?(Input::CTRL)
  312.             # 遇敵計數下降
  313.             if @encounter_count > 0
  314.               @encounter_count -= 1
  315.             end
  316.           end
  317.         end
  318.       end
  319.       # 按下 C 鍵的情況下
  320.       if Input.trigger?(Input::C)
  321.         # 判定為同位置以及正面的事件啟動
  322.         check_event_trigger_here([0])
  323.         check_event_trigger_there([0,1,2])
  324.       end
  325.     end
  326.   end
  327. end
复制代码

系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
回复 支持 反对

使用道具 举报

Lv2.观梦者

神隐的主犯

梦石
0
星屑
373
在线时间
271 小时
注册时间
2008-2-22
帖子
7691

贵宾

3
 楼主| 发表于 2008-5-17 23:58:09 | 只看该作者
呀呀,忘记了。在VX区呆久了,呵呵。

《天空之城 —— 破碎的命运》
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2007-5-28
帖子
364
4
发表于 2008-5-17 23:58:45 | 只看该作者
以下引用八云紫于2008-5-17 15:58:09的发言:

呀呀,忘记了。在VX区呆久了,呵呵。

你试试这个脚本吧。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

胃:伪·好人之怨念<

梦石
0
星屑
50
在线时间
4 小时
注册时间
2007-6-24
帖子
5058

开拓者VX城市地图大赛亚军

5
发表于 2008-5-17 23:58:48 | 只看该作者
如果是只有斜四行走没有正四方向的话据说改行走图和一小段脚本就得
哈哈哈哈哈
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
17 小时
注册时间
2007-5-28
帖子
364
6
发表于 2008-5-18 00:01:03 | 只看该作者
以下引用cheyenne于2008-5-17 15:58:48的发言:

如果是只有斜四行走没有正四方向的话据说改行走图和一小段脚本就得

可能质感不好吧……
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-7-24 10:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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