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

Project1

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

[已经过期] 真八方显示人物行走出来两个咋决绝?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
120 小时
注册时间
2010-12-29
帖子
9
跳转到指定楼层
1
发表于 2011-1-6 20:48:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 fux2 于 2011-1-7 07:22 编辑

如题   我用的是这个脚本   人物行走图(8*8)
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4. ###########################################################################################################################
  5. ###########################################################################################################################
  6. # 脚本功能:八方向走与多帧移动之图片修正__ver1.1。

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

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

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

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

  11. $c3_每一步的帧数= 8
  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.   TIME_LIMIT = 20
  38.   def update
  39.     last_moving = moving?
  40.     unless moving? or $game_system.map_interpreter.running? or
  41.            @move_route_forcing or $game_temp.message_window_showing
  42.       # 用井号后面的东西替代前面的,就可以实现斜4方向走
  43.       case Input.dir8
  44.       when 2
  45.         if $game_switches[2]
  46.           move_down
  47.         else
  48.           move_lower_left
  49.         end            
  50.       when 4
  51.         if $game_switches[2]
  52.           move_left
  53.         else
  54.           move_upper_left
  55.         end
  56.       when 6
  57.         if $game_switches[2]
  58.           move_right
  59.         else
  60.           move_lower_right
  61.         end
  62.       when 8
  63.         if $game_switches[2]
  64.           move_up
  65.         else
  66.           move_upper_right        
  67.         end
  68.       when 1
  69.         move_lower_left
  70.       when 3
  71.         move_lower_right
  72.       when 7
  73.         move_upper_left
  74.       when 9
  75.         move_upper_right
  76.       end
  77.     end
  78.     # 本地变量记忆坐标
  79.     last_real_x = @real_x
  80.     last_real_y = @real_y
  81.     super
  82.     # 角色向下移动、画面上的位置在中央下方的情况下
  83.     if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
  84.       # 画面向下卷动
  85.       $game_map.scroll_down(@real_y - last_real_y)
  86.     end
  87.     # 角色向左移动、画面上的位置在中央左方的情况下
  88.     if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
  89.       # 画面向左卷动
  90.       $game_map.scroll_left(last_real_x - @real_x)
  91.     end
  92.     # 角色向右移动、画面上的位置在中央右方的情况下
  93.     if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
  94.       # 画面向右卷动
  95.       $game_map.scroll_right(@real_x - last_real_x)
  96.     end
  97.     # 角色向上移动、画面上的位置在中央上方的情况下
  98.     if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
  99.       # 画面向上卷动
  100.       $game_map.scroll_up(last_real_y - @real_y)
  101.     end
  102.     # 不在移动中的情况下
  103.     unless moving?
  104.       # 上次主角移动中的情况
  105.       if last_moving
  106.         # 与同位置的事件接触就判定为事件启动
  107.         result = check_event_trigger_here([1,2])
  108.         # 没有可以启动的事件的情况下
  109.         if result == false
  110.           # 调试模式为 ON 并且按下 CTRL 键的情况下除外
  111.           unless $DEBUG and Input.press?(Input::CTRL)
  112.             # 遇敌计数下降
  113.             if @encounter_count > 0
  114.               @encounter_count -= 1
  115.             end
  116.           end
  117.         end
  118.       end
  119.       # 按下 C 键的情况下
  120.       if Input.trigger?(Input::C)
  121.         # 判定为同位置以及正面的事件启动
  122.         check_event_trigger_here([0])
  123.         check_event_trigger_there([0,1,2])
  124.       end
  125.     end
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● 正面事件的启动判定
  129.   #--------------------------------------------------------------------------
  130.   def check_event_trigger_there(triggers)
  131.     result = false
  132.     # 事件执行中的情况下
  133.     if $game_system.map_interpreter.running?
  134.       return result
  135.     end
  136.     # 计算正面坐标
  137.     new_x = @x
  138.     new_y = @y
  139.     case @direction
  140.     when 1
  141.       new_x -= 1
  142.       new_y += 1
  143.     when 2
  144.       new_y += 1
  145.     when 3
  146.       new_x += 1
  147.       new_y += 1
  148.     when 4
  149.       new_x -= 1
  150.     when 6
  151.       new_x += 1
  152.     when 7
  153.       new_x -= 1
  154.       new_y -= 1
  155.     when 8
  156.       new_y -= 1
  157.     when 9
  158.       new_x += 1
  159.       new_y -= 1
  160.     end
  161.     # 全部事件的循环
  162.     for event in $game_map.events.values
  163.       # 事件坐标与目标一致的情况下
  164.       if event.x == new_x and event.y == new_y and
  165.          triggers.include?(event.trigger)
  166.         # 跳跃中以外的情况下、启动判定是正面的事件
  167.         if not event.jumping? and not event.over_trigger?
  168.           event.start
  169.           result = true
  170.         end
  171.       end
  172.     end
  173.     # 找不到符合条件的事件的情况下
  174.     if result == false
  175.       # 正面的元件是计数器的情况下
  176.       if $game_map.counter?(new_x, new_y)
  177.         # 计算 1 元件里侧的坐标
  178.         new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  179.         new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
  180.         # 全事件的循环
  181.         for event in $game_map.events.values
  182.           # 事件坐标与目标一致的情况下
  183.           if event.x == new_x and event.y == new_y and
  184.              triggers.include?(event.trigger)
  185.             # 跳跃中以外的情况下、启动判定是正面的事件
  186.             if not event.jumping? and not event.over_trigger?
  187.               event.start
  188.               result = true
  189.             end
  190.           end
  191.         end
  192.       end
  193.     end
  194.     return result
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 向左下移动
  198.   #--------------------------------------------------------------------------
  199.   def move_lower_left
  200.     # 没有固定面向的场合
  201.     unless @direction_fix
  202.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  203.       @direction = 1#(@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  204.     end
  205.     # 下→左、左→下 的通道可以通行的情况下
  206.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
  207.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
  208.       # 更新坐标
  209.       @x -= 1
  210.       @y += 1
  211.       # 增加步数
  212.       increase_steps
  213.     else
  214.       check_event_trigger_touch(@x-1, @y+1)
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 向右下移动
  219.   #--------------------------------------------------------------------------
  220.   def move_lower_right
  221.     # 没有固定面向的场合
  222.     unless @direction_fix
  223.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  224.       @direction = 3#(@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  225.     end
  226.     # 下→右、右→下 的通道可以通行的情况下
  227.     if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
  228.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
  229.       # 更新坐标
  230.       @x += 1
  231.       @y += 1
  232.       # 增加步数
  233.       increase_steps
  234.     else
  235.       check_event_trigger_touch(@x+1, @y+1)
  236.     end
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 向左上移动
  240.   #--------------------------------------------------------------------------
  241.   def move_upper_left
  242.     # 没有固定面向的场合
  243.     unless @direction_fix
  244.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  245.       @direction = 7#(@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  246.     end
  247.     # 上→左、左→上 的通道可以通行的情况下
  248.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
  249.        (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
  250.       # 更新坐标
  251.       @x -= 1
  252.       @y -= 1
  253.       # 增加步数
  254.       increase_steps
  255.     else
  256.       check_event_trigger_touch(@x-1, @y-1)
  257.     end
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● 向右上移动
  261.   #--------------------------------------------------------------------------
  262.   def move_upper_right
  263.     # 没有固定面向的场合
  264.     unless @direction_fix
  265.       # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
  266.       @direction = 9#(@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  267.     end
  268.     # 上→右、右→上 的通道可以通行的情况下
  269.     if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
  270.        (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
  271.       # 更新坐标
  272.       @x += 1
  273.       @y -= 1
  274.       # 增加步数
  275.       increase_steps
  276.     else
  277.       check_event_trigger_touch(@x+1, @y-1)
  278.     end
  279.   end
  280. end


  281. class Sprite_Character < RPG::Sprite
  282.   def update
  283.     super
  284.     # 元件 ID、文件名、色相与现在的情况存在差异的情况下
  285.     if @tile_id != @character.tile_id or
  286.        @character_name != @character.character_name or
  287.        @character_hue != @character.character_hue
  288.       # 记忆元件 ID 与文件名、色相
  289.       @tile_id = @character.tile_id
  290.       @character_name = @character.character_name
  291.       @character_hue = @character.character_hue
  292.       # 元件 ID 为有效值的情况下
  293.       if @tile_id >= 384
  294.         self.bitmap = RPG::Cache.tile($game_map.tileset_name,
  295.           @tile_id, @character.character_hue)
  296.         self.src_rect.set(0, 0, 32, 32)
  297.         self.ox = 16
  298.         self.oy = 32
  299.       # 元件 ID 为无效值的情况下
  300.       else
  301.         self.bitmap = RPG::Cache.character(@character.character_name,
  302.           @character.character_hue)
  303.         @cw = bitmap.width / $c3_每一步的帧数
  304.           @ch = bitmap.height / 4
  305.         self.ox = @cw / 2
  306.         self.oy = @ch
  307.       end
  308.     end
  309.     # 设置可视状态
  310.     self.visible = (not @character.transparent)
  311.     # 图形是角色的情况下
  312.     if @tile_id == 0
  313.       # 设置传送目标的矩形
  314.       sx = @character.pattern * @cw
  315.         case @character.direction
  316.         when 2
  317.           sy = 0 * @ch
  318.         when 4
  319.           sy = 1 * @ch
  320.         when 6
  321.           sy = 2 * @ch
  322.         when 8
  323.           sy = 3 * @ch
  324.         when 1
  325.           sy = 2 * @ch
  326.         when 3
  327.           sy = 1 * @ch
  328.         when 7
  329.           sy = 3 * @ch
  330.         when 9
  331.           sy = 0 * @ch
  332.         end
  333.       self.src_rect.set(sx, sy, @cw, @ch)
  334.     end
  335.     # 设置脚本的坐标
  336.     self.x = @character.screen_x
  337.     self.y = @character.screen_y
  338.     self.z = @character.screen_z(@ch)
  339.     # 设置不透明度、合成方式、茂密
  340.     self.opacity = @character.opacity
  341.     self.blend_type = @character.blend_type
  342.     self.bush_depth = @character.bush_depth
  343.     # 动画
  344.     if @character.animation_id != 0
  345.       animation = $data_animations[@character.animation_id]
  346.       animation(animation, true)
  347.       @character.animation_id = 0
  348.     end
  349.   end
  350. end

  351. class Game_Character
  352.   attr_accessor :time
  353.   #--------------------------------------------------------------------------
  354.   # ● 初始化对像
  355.   #--------------------------------------------------------------------------
  356.   alias old_ini initialize
  357.   def initialize
  358.     old_ini
  359.     @time = 0
  360.   end
  361.   def c8
  362.     # 随机 0~5 的分支
  363.     case rand(10)
  364.     when 0..3  # 随机
  365.       move_random
  366.     when 4  # 前进一步
  367.       move_forward
  368.     when 5  # 暂时停止
  369.       @stop_count = 0
  370.     when 6..9  #另外4方向随机
  371.       c4
  372.     end
  373.   end
  374.   def c4
  375.     case rand(5)
  376.     when 0
  377.       move_upper_left
  378.     when 1
  379.       move_upper_right
  380.     when 2
  381.       move_lower_left
  382.     when 3
  383.       move_lower_right
  384.     when 4
  385.       @stop_count = 0
  386.     end
  387.   end
  388.       
  389.   def update
  390.     # 跳跃中、移动中、停止中的分支
  391.     if jumping?
  392.       update_jump
  393.     elsif moving?
  394.       update_move
  395.     else
  396.       update_stop
  397.     end
  398.     # 动画计数超过最大值的情况下
  399.     # ※最大值等于基本值减去移动速度 * 1 的值
  400.     if @anime_count > 16*4/$c3_每一步的帧数 - @move_speed * 2
  401.       # 停止动画为 OFF 并且在停止中的情况下
  402.       if not @step_anime and @stop_count > 0
  403.         # 还原为原来的图形
  404.         @pattern = @original_pattern
  405.       # 停止动画为 ON 并且在移动中的情况下
  406.       else
  407.         # 更新图形
  408.         @pattern = (@pattern + 1) % $c3_每一步的帧数
  409.       end
  410.       # 清除动画计数
  411.       @anime_count = 0
  412.     end
  413.     # 等待中的情况下
  414.     if @wait_count > 0
  415.       # 减少等待计数
  416.       @wait_count -= 1
  417.       return
  418.     end
  419.     # 强制移动路线的场合
  420.     if @move_route_forcing
  421.       # 自定义移动
  422.       move_type_custom
  423.       return
  424.     end
  425.     # 事件执行待机中并且为锁定状态的情况下
  426.     if @starting or lock?
  427.       # 不做规则移动
  428.       return
  429.     end
  430.     # 如果停止计数超过了一定的值(由移动频度算出)
  431.     if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  432.       # 移动类型分支
  433.       case @move_type
  434.       when 1  # 随机
  435.         move_type_random
  436.       when 2  # 接近
  437.         move_type_toward_player
  438.       when 3  # 自定义
  439.         move_type_custom
  440.       end
  441.     end
  442.   end
  443. end

  444. class Window_Base < Window
  445.   def draw_actor_graphic(actor, x, y)
  446.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  447.     cw = bitmap.width / $c3_每一步的帧数
  448.     ch = bitmap.height / $c3_总共可用的方向数
  449.     src_rect = Rect.new(0, 0, cw, ch)
  450.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  451.   end
  452. end

  453. class Game_Character
  454.   #--------------------------------------------------------------------------
  455.   # ● 面向主角的方向
  456.   #--------------------------------------------------------------------------
  457.   def turn_toward_player
  458.     # 求得与主角的坐标差
  459.     sx = @x - $game_player.x
  460.     sy = @y - $game_player.y
  461.     # 坐标相等的场合下
  462.     if sx == 0 and sy == 0
  463.       return
  464.     end
  465.     # 横侧距离长的情况下
  466.     if sx.abs > sy.abs
  467.       # 将左右方向变更为朝向主角的方向
  468.       sx > 0 ? turn_left : turn_right
  469.     # 竖侧距离长的情况下
  470.     else
  471.       # 将上下方向变更为朝向主角的方向
  472.       sy > 0 ? turn_up : turn_down
  473.     end
  474.     if sx == -1 and sy == -1
  475.       @direction = 3
  476.       @stop_count = 0
  477.     elsif sx == -1 and sy == 1
  478.       @direction = 9
  479.       @stop_count = 0
  480.     elsif sx == 1 and sy == -1
  481.       @direction = 1
  482.       @stop_count = 0
  483.     elsif sx == 1 and sy == 1
  484.       @direction = 7
  485.       @stop_count = 0
  486.     end
  487.   end
  488. end

  489. #==============================================================================
  490. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  491. #==============================================================================
复制代码
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
71 小时
注册时间
2010-12-25
帖子
104
2
发表于 2011-1-7 04:19:53 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-30 10:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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