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

Project1

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

[已经过期] 求个只有左右方向的多帧行走图脚本

[复制链接]

Lv2.观梦者

梦石
0
星屑
337
在线时间
824 小时
注册时间
2008-9-16
帖子
664
跳转到指定楼层
1
发表于 2014-2-24 02:15:34 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
本帖最后由 曹天一 于 2014-2-24 02:21 编辑

最好在14帧左右,自带待机效果的跪求啊解决了送10个QB,总之急求啊!!!!!

Lv3.寻梦者

梦石
0
星屑
1281
在线时间
6552 小时
注册时间
2010-12-30
帖子
8949
5
发表于 2014-2-26 13:21:12 | 只看该作者
曹天一 发表于 2014-2-26 13:17
我试试看

还有这个,虽然不知道支不支持14……
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
337
在线时间
824 小时
注册时间
2008-9-16
帖子
664
4
 楼主| 发表于 2014-2-26 13:17:42 | 只看该作者
835494264 发表于 2014-2-26 12:50
只有左右方向的效果用限制地图来做个伪横版好了~

我试试看
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1281
在线时间
6552 小时
注册时间
2010-12-30
帖子
8949
3
发表于 2014-2-26 12:50:49 | 只看该作者
只有左右方向的效果用限制地图来做个伪横版好了~
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. ###########################################################################################################################
  5. ###########################################################################################################################
  6. # 脚本功能:八方向走与多帧移动之图片修正__ver1.1。

  7. # 更新日期:2005年8月6日

  8. # 更新内容:增加斜方向触发,增加斜方向面向角色(1步之内)

  9. # 使用方法:将本脚本插入到main之前。如果你使用了雅土版的八方向走脚本,请确保这个脚本的顺序位置,在雅土八方向走脚本的后面。

  10. # 预先处理:请输入每一步的帧数和总共可用的方向数

  11. $c3_每一步的帧数 = 14
  12. $c3_总共可用的方向数 = 8 #——建议不要修改这个。如果要伪8方向的,就用伪的好了。

  13. # 图片处理与功能说明:

  14. # 1、每一步的帧数:
  15. #    众所周知,RMXP的移动行走图是一个方向共有4帧,很多人都觉得这个帧数有点少。
  16. # 使用这个脚本之后,只要将 $c3_每一步的帧数 这个变量设置一个需要的帧数即可修改
  17. # 单方向移动帧数为相应输入值。修改后,需要用photoshop将所有用到的素材的横排
  18. # 调整为相应帧数,比如输入了8则要将每一行设置8个图像(即每一个行走图有8列)。

  19. # 2、可用方向调整(可用数量:4、8):
  20. #    当为4方向时没有任何变化,还是一个图4行,上左右下4个方向。
  21. #    如果想使用8方向走,将需要八方向行走的行走图在延伸扩大的画布中按照左下、右下、左上、右上继续排布图像。
  22. # 即,行走图图片从上到下的面向排列顺序为:下,左,右,上,左下,右下,左上,右上。
  23. #    至于不需要8方向走的普通的NPC(character),使用photoshop将画布向下扩大一倍即可使用。
  24. #    需要注意的是,如果需要斜方向飞鸟,请不要忘记自制素材。

  25. # 特别提示:   
  26. #     使用本脚本前请先考虑清楚是否要做这种效果。因为使用本脚本后需要用photoshop处理character行走图素材
  27. # 虽然这种处理用photoshop定义动作只需要5分钟即可全部完成,但在制作阶段会感觉不是很爽(具体的用了才知道)
  28. # 作者的建议是,如果你没有足够的制作经验,使用这个脚本得不偿失。请确保自己的能力属于“高手”级别!

  29. # 附赠功能:
  30. #     可以让NPC角色随机8方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c8即可
  31. #     可以让NPC角色随机4斜角方向走,方法是:NPC角色移动路线为“自定义”,然后自定义里面使用脚本,输入c4即可
  32. #     可以使用真·斜4方向行走,参考脚本53行开始

  33. # 作者:carol3
  34. ###########################################################################################################################
  35. ###########################################################################################################################

  36. class Game_Player < Game_Character
  37.   if $c3_总共可用的方向数 == 8
  38.     def update
  39.       last_moving = moving?
  40.       
  41.       
  42.    if [url=home.php?mod=space&uid=134219]@Time[/url] == @TIME_LIMIT
  43.      @character_name = @character_name + "_W"
  44.      @scratch = true
  45.      @step_anime = true
  46.      @time = @TIME_LIMIT + 1 unless @time == nil
  47.    elsif @time < @TIME_LIMIT
  48.      @scratch = false
  49.      @step_anime = false
  50.    end
  51.    if @scratch == false
  52.      @old_pic = @character_name
  53.    end
  54.    
  55.    
  56.       unless moving? or $game_system.map_interpreter.running? or
  57.              @move_route_forcing or $game_temp.message_window_showing
  58.         # 用井号后面的东西替代前面的,就可以实现斜4方向走
  59.         case Input.dir8
  60.         when 2
  61.           move_down #move_lower_left
  62.          @time = 0
  63.          @scratch = false
  64.          @character_name = @old_pic
  65.         when 4
  66.           move_left #move_upper_left
  67.          @time = 0
  68.          @scratch = false
  69.          @character_name = @old_pic
  70.         when 6
  71.           move_right #move_lower_right
  72.          @time = 0
  73.          @scratch = false
  74.          @character_name = @old_pic
  75.         when 8
  76.           move_up #move_upper_right
  77.          @time = 0
  78.          @scratch = false
  79.          @character_name = @old_pic
  80.         when 1
  81.           move_lower_left
  82.          @time = 0
  83.          @scratch = false
  84.          @character_name = @old_pic
  85.         when 3
  86.           move_lower_right
  87.          @time = 0
  88.          @scratch = false
  89.          @character_name = @old_pic
  90.         when 7
  91.           move_upper_left
  92.          @time = 0
  93.          @scratch = false
  94.          @character_name = @old_pic
  95.         when 9
  96.           move_upper_right
  97.          @time = 0
  98.          @scratch = false
  99.          @character_name = @old_pic
  100.        end
  101.      end
  102.      # 本地变量记忆坐标
  103.       last_real_x = @real_x
  104.       last_real_y = @real_y
  105.       super
  106.       # 角色向下移动、画面上的位置在中央下方的情况下
  107.       if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  108.         # 画面向下卷动
  109.         $game_map.scroll_down(@real_y - last_real_y)
  110.       end
  111.       # 角色向左移动、画面上的位置在中央左方的情况下
  112.       if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  113.         # 画面向左卷动
  114.         $game_map.scroll_left(last_real_x - @real_x)
  115.       end
  116.       # 角色向右移动、画面上的位置在中央右方的情况下
  117.       if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  118.         # 画面向右卷动
  119.         $game_map.scroll_right(@real_x - last_real_x)
  120.       end
  121.       # 角色向上移动、画面上的位置在中央上方的情况下
  122.       if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  123.         # 画面向上卷动
  124.         $game_map.scroll_up(last_real_y - @real_y)
  125.       end
  126.       # 不在移动中的情况下
  127.       unless moving?
  128.         
  129.         
  130.         @time += 1 if @time < @TIME_LIMIT
  131.         
  132.         
  133.         # 上次主角移动中的情况
  134.         if last_moving
  135.           # 与同位置的事件接触就判定为事件启动
  136.           result = check_event_trigger_here([1,2])
  137.           # 没有可以启动的事件的情况下
  138.           if result == false
  139.             # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  140.             unless $DEBUG and Input.press?(Input::CTRL)
  141.               # 遇敌计数下降
  142.               if @encounter_count > 0
  143.                 @encounter_count -= 1
  144.               end
  145.             end
  146.           end
  147.         end
  148.         # 按下 C 键的情况下
  149.         if Input.trigger?(Input::C)
  150.           # 判定为同位置以及正面的事件启动
  151.           check_event_trigger_here([0])
  152.           check_event_trigger_there([0,1,2])
  153.         end
  154.       end
  155.     end
  156.     #--------------------------------------------------------------------------
  157.     # ● 正面事件的启动判定
  158.     #--------------------------------------------------------------------------
  159.     def check_event_trigger_there(triggers)
  160.       result = false
  161.       # 事件执行中的情况下
  162.       if $game_system.map_interpreter.running?
  163.         return result
  164.       end
  165.       # 计算正面坐标
  166.       new_x = @x
  167.       new_y = @y
  168.       case @direction
  169.       when 1
  170.         new_x -= 1
  171.         new_y += 1
  172.       when 2
  173.         new_y += 1
  174.       when 3
  175.         new_x += 1
  176.         new_y += 1
  177.       when 4
  178.         new_x -= 1
  179.       when 6
  180.         new_x += 1
  181.       when 7
  182.         new_x -= 1
  183.         new_y -= 1
  184.       when 8
  185.         new_y -= 1
  186.       when 9
  187.         new_x += 1
  188.         new_y -= 1
  189.       end
  190.       # 全部事件的循环
  191.       for event in $game_map.events.values
  192.         # 事件坐标与目标一致的情况下
  193.         if event.x == new_x and event.y == new_y and
  194.            triggers.include?(event.trigger)
  195.           # 跳跃中以外的情况下、启动判定是正面的事件
  196.           if not event.jumping? and not event.over_trigger?
  197.             event.start
  198.             result = true
  199.           end
  200.         end
  201.       end
  202.       # 找不到符合条件的事件的情况下
  203.       if result == false
  204.         # 正面的元件是计数器的情况下
  205.         if $game_map.counter?(new_x, new_y)
  206.           # 计算 1 元件里侧的坐标
  207.           new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  208.           new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  209.           # 全事件的循环
  210.           for event in $game_map.events.values
  211.             # 事件坐标与目标一致的情况下
  212.             if event.x == new_x and event.y == new_y and
  213.                triggers.include?(event.trigger)
  214.               # 跳跃中以外的情况下、启动判定是正面的事件
  215.               if not event.jumping? and not event.over_trigger?
  216.                 event.start
  217.                 result = true
  218.               end
  219.             end
  220.           end
  221.         end
  222.       end
  223.       return result
  224.     end
  225.     #--------------------------------------------------------------------------
  226.     # ● 向左下移动
  227.     #--------------------------------------------------------------------------
  228.     def move_lower_left
  229.       # 没有固定面向的场合
  230.       unless @direction_fix
  231.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  232.         @direction = 1#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  233.       end
  234.       # 下→左、左→下 的通道可以通行的情况下
  235.       if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
  236.          (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
  237.         # 更新坐标
  238.         @x -= 1
  239.         @y += 1
  240.         # 增加步数
  241.         increase_steps
  242.       else
  243.         check_event_trigger_touch(@x-1, @y+1)
  244.       end
  245.       @time = 0
  246.       @scratch = false
  247.       @character_name = @old_pic
  248.     end
  249.     #--------------------------------------------------------------------------
  250.     # ● 向右下移动
  251.     #--------------------------------------------------------------------------
  252.     def move_lower_right
  253.       # 没有固定面向的场合
  254.       unless @direction_fix
  255.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  256.         @direction = 3#(@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  257.       end
  258.       # 下→右、右→下 的通道可以通行的情况下
  259.       if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
  260.          (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
  261.         # 更新坐标
  262.         @x += 1
  263.         @y += 1
  264.         # 增加步数
  265.         increase_steps
  266.       else
  267.         check_event_trigger_touch(@x+1, @y+1)
  268.       end
  269.       @time = 0
  270.       @scratch = false
  271.       @character_name = @old_pic
  272.     end
  273.     #--------------------------------------------------------------------------
  274.     # ● 向左上移动
  275.     #--------------------------------------------------------------------------
  276.     def move_upper_left
  277.       # 没有固定面向的场合
  278.       unless @direction_fix
  279.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  280.         @direction = 7#(@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  281.       end
  282.       # 上→左、左→上 的通道可以通行的情况下
  283.       if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
  284.          (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
  285.         # 更新坐标
  286.         @x -= 1
  287.         @y -= 1
  288.         # 增加步数
  289.         increase_steps
  290.       else
  291.         check_event_trigger_touch(@x-1, @y-1)
  292.       end
  293.       @time = 0
  294.       @scratch = false
  295.       @character_name = @old_pic
  296.     end
  297.     #--------------------------------------------------------------------------
  298.     # ● 向右上移动
  299.     #--------------------------------------------------------------------------
  300.     def move_upper_right
  301.       # 没有固定面向的场合
  302.       unless @direction_fix
  303.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  304.         @direction = 9#(@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  305.       end
  306.       # 上→右、右→上 的通道可以通行的情况下
  307.       if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
  308.          (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
  309.         # 更新坐标
  310.         @x += 1
  311.         @y -= 1
  312.         # 增加步数
  313.         increase_steps
  314.       else
  315.         check_event_trigger_touch(@x+1, @y-1)
  316.       end
  317.       @time = 0
  318.       @scratch = false
  319.       @character_name = @old_pic
  320.     end
  321.     #--------------------------------------------------------------------------
  322.     # ● 雅土左下移動
  323.     #--------------------------------------------------------------------------
  324.     def move_lower_left_p
  325.       unless @direction_fix
  326.         @direction = 1
  327.       end
  328.       distance = (2 ** @move_speed) / Math.sqrt(2)
  329.       turn_left unless down1(@x, @y, distance)
  330.       turn_down if @event
  331.       turn_down unless left1(@x, @y, distance) unless @event
  332.       turn_left if @event
  333.     end
  334.     #--------------------------------------------------------------------------
  335.     # ● 雅土右下移動
  336.     #--------------------------------------------------------------------------
  337.     def move_lower_right_p
  338.       unless @direction_fix
  339.         @direction = 3
  340.       end
  341.       distance = (2 ** @move_speed) / Math.sqrt(2)
  342.       turn_right unless down1(@x, @y, distance)
  343.       turn_down if @event
  344.       turn_down unless right1(@x, @y, distance) unless @event
  345.       turn_right if @event
  346.     end
  347.     #--------------------------------------------------------------------------
  348.     # ● 雅土左上移動
  349.     #--------------------------------------------------------------------------
  350.     def move_upper_left_p
  351.       unless @direction_fix
  352.         @direction = 7
  353.       end
  354.       distance = (2 ** @move_speed) / Math.sqrt(2)
  355.       turn_left unless up1(@x, @y, distance)
  356.       turn_up if @event
  357.       turn_up unless left1(@x, @y, distance) unless @event
  358.       turn_left if @event
  359.     end
  360.     #--------------------------------------------------------------------------
  361.     # ● 雅土右上移動
  362.     #--------------------------------------------------------------------------
  363.     def move_upper_right_p
  364.       unless @direction_fix
  365.         @direction = 9
  366.       end
  367.       distance = (2 ** @move_speed) / Math.sqrt(2)
  368.       turn_right unless up1(@x, @y, distance)
  369.       turn_up if @event
  370.       turn_up unless right1(@x, @y, distance) unless @event
  371.       turn_right if @event
  372.     end
  373.   else
  374.     def update
  375.       last_moving = moving?
  376.       
  377.       
  378.    if @time == @TIME_LIMIT
  379.      @character_name = @character_name + "_W"
  380.      @scratch = true
  381.      @step_anime = true
  382.      @time = @TIME_LIMIT + 1 unless @time == nil
  383.    elsif @time < @TIME_LIMIT
  384.      @scratch = false
  385.      @step_anime = false
  386.    end
  387.    if @scratch == false
  388.      @old_pic = @character_name
  389.    end
  390.    
  391.    
  392.       unless moving? or $game_system.map_interpreter.running? or
  393.              @move_route_forcing or $game_temp.message_window_showing
  394.         # 用井号后面的东西替代前面的,就可以实现斜4方向走
  395.         case Input.dir4
  396.         when 2
  397.           move_down #move_lower_left
  398.          @time = 0
  399.          @scratch = false
  400.          @character_name = @old_pic
  401.         when 4
  402.           move_left #move_upper_left
  403.          @time = 0
  404.          @scratch = false
  405.          @character_name = @old_pic
  406.         when 6
  407.           move_right #move_lower_right
  408.          @time = 0
  409.          @scratch = false
  410.          @character_name = @old_pic
  411.         when 8
  412.           move_up #move_upper_right
  413.          @time = 0
  414.          @scratch = false
  415.          @character_name = @old_pic
  416.        end
  417.      end
  418.      # 本地变量记忆坐标
  419.       last_real_x = @real_x
  420.       last_real_y = @real_y
  421.       super
  422.       # 角色向下移动、画面上的位置在中央下方的情况下
  423.       if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  424.         # 画面向下卷动
  425.         $game_map.scroll_down(@real_y - last_real_y)
  426.       end
  427.       # 角色向左移动、画面上的位置在中央左方的情况下
  428.       if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  429.         # 画面向左卷动
  430.         $game_map.scroll_left(last_real_x - @real_x)
  431.       end
  432.       # 角色向右移动、画面上的位置在中央右方的情况下
  433.       if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  434.         # 画面向右卷动
  435.         $game_map.scroll_right(@real_x - last_real_x)
  436.       end
  437.       # 角色向上移动、画面上的位置在中央上方的情况下
  438.       if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  439.         # 画面向上卷动
  440.         $game_map.scroll_up(last_real_y - @real_y)
  441.       end
  442.       # 不在移动中的情况下
  443.       unless moving?
  444.         
  445.         
  446.         @time += 1 if @time < @TIME_LIMIT
  447.         
  448.         
  449.         # 上次主角移动中的情况
  450.         if last_moving
  451.           # 与同位置的事件接触就判定为事件启动
  452.           result = check_event_trigger_here([1,2])
  453.           # 没有可以启动的事件的情况下
  454.           if result == false
  455.             # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  456.             unless $DEBUG and Input.press?(Input::CTRL)
  457.               # 遇敌计数下降
  458.               if @encounter_count > 0
  459.                 @encounter_count -= 1
  460.               end
  461.             end
  462.           end
  463.         end
  464.         # 按下 C 键的情况下
  465.         if Input.trigger?(Input::C)
  466.           # 判定为同位置以及正面的事件启动
  467.           check_event_trigger_here([0])
  468.           check_event_trigger_there([0,1,2])
  469.         end
  470.       end
  471.     end
  472.     #--------------------------------------------------------------------------
  473.     # ● 正面事件的启动判定
  474.     #--------------------------------------------------------------------------
  475.     def check_event_trigger_there(triggers)
  476.       result = false
  477.       # 事件执行中的情况下
  478.       if $game_system.map_interpreter.running?
  479.         return result
  480.       end
  481.       # 计算正面坐标
  482.       new_x = @x
  483.       new_y = @y
  484.       case @direction
  485.       when 1
  486.         new_x -= 1
  487.         new_y += 1
  488.       when 2
  489.         new_y += 1
  490.       when 3
  491.         new_x += 1
  492.         new_y += 1
  493.       when 4
  494.         new_x -= 1
  495.       when 6
  496.         new_x += 1
  497.       when 7
  498.         new_x -= 1
  499.         new_y -= 1
  500.       when 8
  501.         new_y -= 1
  502.       when 9
  503.         new_x += 1
  504.         new_y -= 1
  505.       end
  506.       # 全部事件的循环
  507.       for event in $game_map.events.values
  508.         # 事件坐标与目标一致的情况下
  509.         if event.x == new_x and event.y == new_y and
  510.            triggers.include?(event.trigger)
  511.           # 跳跃中以外的情况下、启动判定是正面的事件
  512.           if not event.jumping? and not event.over_trigger?
  513.             event.start
  514.             result = true
  515.           end
  516.         end
  517.       end
  518.       # 找不到符合条件的事件的情况下
  519.       if result == false
  520.         # 正面的元件是计数器的情况下
  521.         if $game_map.counter?(new_x, new_y)
  522.           # 计算 1 元件里侧的坐标
  523.           new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  524.           new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  525.           # 全事件的循环
  526.           for event in $game_map.events.values
  527.             # 事件坐标与目标一致的情况下
  528.             if event.x == new_x and event.y == new_y and
  529.                triggers.include?(event.trigger)
  530.               # 跳跃中以外的情况下、启动判定是正面的事件
  531.               if not event.jumping? and not event.over_trigger?
  532.                 event.start
  533.                 result = true
  534.               end
  535.             end
  536.           end
  537.         end
  538.       end
  539.       return result
  540.     end
  541.     #--------------------------------------------------------------------------
  542.     # ● 向左下移动
  543.     #--------------------------------------------------------------------------
  544.     def move_lower_left
  545.       # 没有固定面向的场合
  546.       unless @direction_fix
  547.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  548.         @direction = 1#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  549.       end
  550.       # 下→左、左→下 的通道可以通行的情况下
  551.       if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
  552.          (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
  553.         # 更新坐标
  554.         @x -= 1
  555.         @y += 1
  556.         # 增加步数
  557.         increase_steps
  558.       else
  559.         check_event_trigger_touch(@x-1, @y+1)
  560.       end
  561.       @time = 0
  562.       @scratch = false
  563.       @character_name = @old_pic
  564.     end
  565.     #--------------------------------------------------------------------------
  566.     # ● 向右下移动
  567.     #--------------------------------------------------------------------------
  568.     def move_lower_right
  569.       # 没有固定面向的场合
  570.       unless @direction_fix
  571.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  572.         @direction = 3#(@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  573.       end
  574.       # 下→右、右→下 的通道可以通行的情况下
  575.       if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
  576.          (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
  577.         # 更新坐标
  578.         @x += 1
  579.         @y += 1
  580.         # 增加步数
  581.         increase_steps
  582.       else
  583.         check_event_trigger_touch(@x+1, @y+1)
  584.       end
  585.       @time = 0
  586.       @scratch = false
  587.       @character_name = @old_pic
  588.     end
  589.     #--------------------------------------------------------------------------
  590.     # ● 向左上移动
  591.     #--------------------------------------------------------------------------
  592.     def move_upper_left
  593.       # 没有固定面向的场合
  594.       unless @direction_fix
  595.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  596.         @direction = 7#(@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  597.       end
  598.       # 上→左、左→上 的通道可以通行的情况下
  599.       if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
  600.          (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
  601.         # 更新坐标
  602.         @x -= 1
  603.         @y -= 1
  604.         # 增加步数
  605.         increase_steps
  606.       else
  607.         check_event_trigger_touch(@x-1, @y-1)
  608.       end
  609.       @time = 0
  610.       @scratch = false
  611.       @character_name = @old_pic
  612.     end
  613.     #--------------------------------------------------------------------------
  614.     # ● 向右上移动
  615.     #--------------------------------------------------------------------------
  616.     def move_upper_right
  617.       # 没有固定面向的场合
  618.       unless @direction_fix
  619.         # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  620.         @direction = 9#(@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  621.       end
  622.       # 上→右、右→上 的通道可以通行的情况下
  623.       if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
  624.          (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
  625.         # 更新坐标
  626.         @x += 1
  627.         @y -= 1
  628.         # 增加步数
  629.         increase_steps
  630.       else
  631.         check_event_trigger_touch(@x+1, @y-1)
  632.       end
  633.       @time = 0
  634.       @scratch = false
  635.       @character_name = @old_pic
  636.     end
  637.     #--------------------------------------------------------------------------
  638.     # ● 雅土左下移動
  639.     #--------------------------------------------------------------------------
  640.     def move_lower_left_p
  641.       unless @direction_fix
  642.         @direction = 1
  643.       end
  644.       distance = (2 ** @move_speed) / Math.sqrt(2)
  645.       turn_left unless down1(@x, @y, distance)
  646.       turn_down if @event
  647.       turn_down unless left1(@x, @y, distance) unless @event
  648.       turn_left if @event
  649.     end
  650.     #--------------------------------------------------------------------------
  651.     # ● 雅土右下移動
  652.     #--------------------------------------------------------------------------
  653.     def move_lower_right_p
  654.       unless @direction_fix
  655.         @direction = 3
  656.       end
  657.       distance = (2 ** @move_speed) / Math.sqrt(2)
  658.       turn_right unless down1(@x, @y, distance)
  659.       turn_down if @event
  660.       turn_down unless right1(@x, @y, distance) unless @event
  661.       turn_right if @event
  662.     end
  663.     #--------------------------------------------------------------------------
  664.     # ● 雅土左上移動
  665.     #--------------------------------------------------------------------------
  666.     def move_upper_left_p
  667.       unless @direction_fix
  668.         @direction = 7
  669.       end
  670.       distance = (2 ** @move_speed) / Math.sqrt(2)
  671.       turn_left unless up1(@x, @y, distance)
  672.       turn_up if @event
  673.       turn_up unless left1(@x, @y, distance) unless @event
  674.       turn_left if @event
  675.     end
  676.     #--------------------------------------------------------------------------
  677.     # ● 雅土右上移動
  678.     #--------------------------------------------------------------------------
  679.     def move_upper_right_p
  680.       unless @direction_fix
  681.         @direction = 9
  682.       end
  683.       distance = (2 ** @move_speed) / Math.sqrt(2)
  684.       turn_right unless up1(@x, @y, distance)
  685.       turn_up if @event
  686.       turn_up unless right1(@x, @y, distance) unless @event
  687.       turn_right if @event
  688.     end
  689.   end
  690. end


  691. class Sprite_Character < RPG::Sprite
  692.   def update
  693.     super
  694.     # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  695.     if @tile_id != @character.tile_id or
  696.        @character_name != @character.character_name or
  697.        @character_hue != @character.character_hue
  698.       # 记忆元件 ID 与文件名、色相
  699.       @tile_id = @character.tile_id
  700.       @character_name = @character.character_name
  701.       @character_hue = @character.character_hue
  702.       # 元件 ID 为有效值的情况下
  703.       if @tile_id >= 384
  704.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  705.           @tile_id, @character.character_hue)
  706.         self.src_rect.set(0, 0, 32, 32)
  707.         self.ox = 16
  708.         self.oy = 32
  709.       # 元件 ID 为无效值的情况下
  710.       else
  711.         self.bitmap = RPG::Cache.character(@character.character_name,
  712.           @character.character_hue)
  713.         @cw = bitmap.width / $c3_每一步的帧数
  714.         if $c3_总共可用的方向数==4
  715.           @ch = bitmap.height / 4
  716.         else
  717.           @ch = bitmap.height / 8
  718.         end
  719.         self.ox = @cw / 2
  720.         self.oy = @ch
  721.       end
  722.     end
  723.     # 设置可视状态
  724.     self.visible = (not @character.transparent)
  725.     # 图形是角色的情况下
  726.     if @tile_id == 0
  727.       # 设置传送目标的矩形
  728.       sx = @character.pattern * @cw
  729.       if $c3_总共可用的方向数==8
  730.         case @character.direction
  731.         when 2
  732.           sy = 0 * @ch
  733.         when 4
  734.           sy = 1 * @ch
  735.         when 6
  736.           sy = 2 * @ch
  737.         when 8
  738.           sy = 3 * @ch
  739.         when 1
  740.           sy = 4 * @ch
  741.         when 3
  742.           sy = 5 * @ch
  743.         when 7
  744.           sy = 6 * @ch
  745.         when 9
  746.           sy = 7 * @ch
  747.         end
  748.       else
  749.         sy = (@character.direction - 2) / 2 * @ch
  750.       end
  751.       self.src_rect.set(sx, sy, @cw, @ch)
  752.     end
  753.     # 设置脚本的坐标
  754.     self.x = @character.screen_x
  755.     self.y = @character.screen_y
  756.     self.z = @character.screen_z(@ch)
  757.     # 设置不透明度、合成方式、茂密
  758.     self.opacity = @character.opacity
  759.     self.blend_type = @character.blend_type
  760.     self.bush_depth = @character.bush_depth
  761.     # 动画
  762.     if @character.animation_id != 0
  763.       animation = $data_animations[@character.animation_id]
  764.       animation(animation, true)
  765.       @character.animation_id = 0
  766.     end
  767.   end
  768. end

  769. class Game_Character
  770. attr_accessor :time
  771. attr_accessor :TIME_LIMIT
  772. attr_accessor :character_name
  773. attr_accessor :old_pic
  774. #--------------------------------------------------------------------------
  775. # ● 初始化对像
  776. #--------------------------------------------------------------------------
  777. alias old_ini initialize
  778.   def initialize
  779.    old_ini
  780.    @time = 0
  781.    @TIME_LIMIT = 1  # 抓耳挠腮前的等待时间 (好象也不是帧…不知道是什么单位了)
  782. end
  783.   def c8
  784.     # 随机 0~5 的分支
  785.     case rand(10)
  786.     when 0..3  # 随机
  787.       move_random
  788.     when 4  # 前进一步
  789.       move_forward
  790.     when 5  # 暂时停止
  791.       @stop_count = 0
  792.     when 6..9  #另外4方向随机
  793.       c4
  794.     end
  795.   end
  796.   def c4
  797.     case rand(5)
  798.     when 0
  799.       move_upper_left
  800.     when 1
  801.       move_upper_right
  802.     when 2
  803.       move_lower_left
  804.     when 3
  805.       move_lower_right
  806.     when 4
  807.       @stop_count = 0
  808.     end
  809.   end
  810.       
  811.   def update
  812.     # 跳跃中、移动中、停止中的分支
  813.     if jumping?
  814.       update_jump
  815.     elsif moving?
  816.       update_move
  817.     else
  818.       update_stop
  819.     end
  820.     # 动画计数超过最大值的情况下
  821.     # ※最大值等于基本值减去移动速度 * 1 的值
  822.     if @anime_count > 17*14/$c3_每一步的帧数 - @move_speed * 2   
  823.       # 停止动画为 OFF 并且在停止中的情况下
  824.       if not @step_anime and @stop_count > 0
  825.         # 还原为原来的图形
  826.         @pattern = @original_pattern
  827.       # 停止动画为 ON 并且在移动中的情况下
  828.       else
  829.         # 更新图形
  830.         @pattern = (@pattern + 1) % $c3_每一步的帧数
  831.       end
  832.       # 清除动画计数
  833.       @anime_count = 0
  834.     end
  835.     # 等待中的情况下
  836.     if @wait_count > 0
  837.       # 减少等待计数
  838.       @wait_count -= 1
  839.       return
  840.     end
  841.     # 强制移动路线的场合
  842.     if @move_route_forcing
  843.       # 自定义移动
  844.       move_type_custom
  845.       return
  846.     end
  847.     # 事件执行待机中并且为锁定状态的情况下
  848.     if @starting or lock?
  849.       # 不做规则移动
  850.       return
  851.     end
  852.     # 如果停止计数超过了一定的值(由移动频度算出)
  853.     if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  854.       # 移动类型分支
  855.       case @move_type
  856.       when 1  # 随机
  857.         move_type_random
  858.       when 2  # 接近
  859.         move_type_toward_player
  860.       when 3  # 自定义
  861.         move_type_custom
  862.       end
  863.     end
  864.   end
  865. end
  866. class Window_Base < Window
  867.   def draw_actor_graphic(actor, x, y)
  868.     if actor.id < 30
  869.       bitmap = RPG::Cache.character(actor.character_name + "_W", actor.character_hue)
  870.     else
  871.       bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  872.     end
  873.     cw = bitmap.width / $c3_每一步的帧数
  874.     ch = bitmap.height / $c3_总共可用的方向数
  875.     src_rect = Rect.new(0, 0, cw, ch)
  876.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  877.   end
  878. end

  879. class Game_Character
  880.   #--------------------------------------------------------------------------
  881.   # ● 面向主角的方向
  882.   #--------------------------------------------------------------------------
  883.   def turn_toward_player
  884.     # 求得与主角的坐标差
  885.     sx = @x - $game_player.x
  886.     sy = @y - $game_player.y
  887.     # 坐标相等的场合下
  888.     if sx == 0 and sy == 0
  889.       return
  890.     end
  891.     # 横侧距离长的情况下
  892.     if sx.abs > sy.abs
  893.       # 将左右方向变更为朝向主角的方向
  894.       sx > 0 ? turn_left : turn_right
  895.     # 竖侧距离长的情况下
  896.     else
  897.       # 将上下方向变更为朝向主角的方向
  898.       sy > 0 ? turn_up : turn_down
  899.     end
  900.     if sx == -1 and sy == -1
  901.       @direction = 3
  902.       @stop_count = 0
  903.     elsif sx == -1 and sy == 1
  904.       @direction = 9
  905.       @stop_count = 0
  906.     elsif sx == 1 and sy == -1
  907.       @direction = 1
  908.       @stop_count = 0
  909.     elsif sx == 1 and sy == 1
  910.       @direction = 7
  911.       @stop_count = 0
  912.     end
  913.   end
  914. end
复制代码

评分

参与人数 1星屑 +120 收起 理由
myownroc + 120 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
337
在线时间
824 小时
注册时间
2008-9-16
帖子
664
2
 楼主| 发表于 2014-2-24 15:02:31 | 只看该作者
.................
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 16:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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