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

Project1

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

[已经解决] 足迹脚本如何通过按键来控制显示

[复制链接]

Lv1.梦旅人

梦石
0
星屑
120
在线时间
188 小时
注册时间
2014-1-18
帖子
254
跳转到指定楼层
1
发表于 2016-10-17 12:45:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
脚本:
RUBY 代码复制
  1. class RPG::Tileset
  2.   #--------------------------------------------------------------------------
  3.   # ● 獲取腳印類型
  4.   #--------------------------------------------------------------------------
  5.   def get_footprint_type(tag_id)
  6.     return false unless tag_id.is_a?(Integer)
  7.     self.note.split(/[\r\n]+/).each { |line|
  8.       if line =~ /\[fp_type #{tag_id} (\S+)\]/
  9.         return $1.to_sym
  10.       end
  11.     }
  12.     return :none
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # ● 獲取腳印音效
  16.   #--------------------------------------------------------------------------
  17.   def get_footprint_sound(tag_id)
  18.     return false unless tag_id.is_a?(Integer)
  19.     self.note.split(/[\r\n]+/).each { |line|
  20.       if line =~ /\[fp_sound #{tag_id} (\S+)\]/
  21.         return $1
  22.       end
  23.     }
  24.     return ""
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 獲取腳印淡出速度
  28.   #--------------------------------------------------------------------------
  29.   def get_footprint_fade
  30.     self.note.split(/[\r\n]+/).each { |line|
  31.       if line =~ /\[fp_fade (\d+)\]/
  32.         return $1.to_i
  33.       end
  34.     }
  35.     return 5
  36.   end
  37. end
  38. class Game_Footprint < Game_CharacterBase
  39.   attr_reader :type
  40.   attr_accessor :pattern
  41.   attr_accessor :character_name
  42.   attr_accessor :direction
  43.   attr_accessor :direction_fix
  44.   #--------------------------------------------------------------------------
  45.   # ● 初始化
  46.   #--------------------------------------------------------------------------
  47.   def initialize(t)
  48.     super()
  49.     return unless $game_player
  50.     @direction = $game_player.direction
  51.     self.type = t
  52.     @move_speed = 4
  53.     @move_frequency = 6
  54.     @priority_type = 0
  55.     @through = true
  56.     @transparent = true
  57.     moveto($game_player.x, $game_player.y)
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 設置類型
  61.   #--------------------------------------------------------------------------
  62.   def type=(t)
  63.     @type = t
  64.     @character_name = "$footprint"
  65.     if @type != :normal
  66.       @character_name += "_" + @type.to_s
  67.     end
  68.     case @type
  69.     when :ripple
  70.       @step_anime = true
  71.       @stop_count = 8
  72.     end
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 腳印更新
  76.   #--------------------------------------------------------------------------
  77.   def update
  78.     super
  79.     return if pos?($game_player.x, $game_player.y)
  80.     fadespeed = $game_map.tileset.get_footprint_fade
  81.     return if fadespeed == 0
  82.     if Graphics.frame_count % fadespeed == 0
  83.       @opacity -= 10
  84.     end
  85.   end
  86. end
  87. class Game_Footprints
  88.   #--------------------------------------------------------------------------
  89.   # ● 初始化
  90.   #--------------------------------------------------------------------------
  91.   def initialize
  92.     [url=home.php?mod=space&uid=2653549]@data[/url] = []
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● 加入腳印
  96.   #--------------------------------------------------------------------------
  97.   def push_fp(t=:normal)
  98.     footp = Game_Footprint.new(t)
  99.     footp.moveto($game_player.x, $game_player.y)
  100.     footp.set_direction($game_player.direction)
  101.     @data.push(footp)
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 設置類型
  105.   #--------------------------------------------------------------------------
  106.   def type=(t)
  107.     @data.each{ |ft|
  108.       ft.type = t
  109.     }
  110.   end
  111.   attr_reader :data
  112. end
  113. class Game_Player < Game_Character
  114.   #--------------------------------------------------------------------------
  115.   # ● 清除移動資訊
  116.   #--------------------------------------------------------------------------
  117.   alias footprint_clear_transfer_info clear_transfer_info
  118.   def clear_transfer_info
  119.     footprint_clear_transfer_info
  120.     @footprint = Game_Footprints.new
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 返回腳印列表
  124.   #--------------------------------------------------------------------------
  125.   def footprints
  126.     return @footprint.data
  127.   end
  128.   #alias footprint_moveto moveto
  129.   #def moveto(x, y)
  130.   #  footprint_moveto(x, y)
  131.     #push_footprint
  132.   #end
  133.   #--------------------------------------------------------------------------
  134.   # ● 直線移動
  135.   #--------------------------------------------------------------------------
  136.   alias footprint_move_straight move_straight
  137.   def move_straight(d, turn_ok = true)
  138.     previous_direction = @direction
  139.     footprint_move_straight(d, turn_ok)
  140.     if @move_succeed
  141.       push_footprint(previous_direction)
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 新增腳印
  146.   #--------------------------------------------------------------------------
  147.   def push_footprint(prev_dir=2)
  148.     return unless SceneManager.scene_is?(Scene_Map)
  149.     if @footprint.data.size > 0
  150.       adjust_diagonal_footprint(prev_dir, $game_player.direction)
  151.       @footprint.data[-1].transparent = false
  152.     end
  153.     type = check_terrain?
  154.     return unless type
  155.     @footprint.push_fp(type)
  156.     SceneManager.scene.add_footprint_sprite(@footprint.data[-1])
  157.   end
  158.   def adjust_diagonal_footprint(last_dir, curr_dir)
  159.     return if last_dir == curr_dir
  160.     footprint = @footprint.data[-1]
  161.     name = footprint.character_name + "_dia"
  162.     return unless FileTest.exist?("Graphics/Characters/#{name}.png")
  163.     footprint.character_name = name
  164.     case last_dir+curr_dir
  165.     when 6
  166.       footprint.direction = 8
  167.     when 8
  168.       footprint.direction = 4
  169.     when 12
  170.       footprint.direction = 6
  171.     when 14
  172.       footprint.direction = 2
  173.     end
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 檢查地形
  177.   #--------------------------------------------------------------------------
  178.   def check_terrain?
  179.     terrain = $game_map.terrain_tag($game_player.x, $game_player.y)
  180.     type  = $game_map.tileset.get_footprint_type(terrain)
  181.     sound = $game_map.tileset.get_footprint_sound(terrain)
  182.     RPG::SE.new(sound).play if sound != ""
  183.     if type == :none
  184.       return false
  185.     else
  186.       return type
  187.     end
  188.   end
  189. end
  190. class Spriteset_Map
  191.   #--------------------------------------------------------------------------
  192.   # ● 增加腳印精靈
  193.   #--------------------------------------------------------------------------
  194.   def add_footprint(footprint)
  195.     @character_sprites.push(Sprite_Character.new(@viewport1, footprint))
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ● 更新角色精靈
  199.   #--------------------------------------------------------------------------
  200.   alias footprint_update_characters update_characters
  201.   def update_characters
  202.     footprint_update_characters # 調用原有方法
  203.     update_footsteps # 更新腳印
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● 更新腳印精靈
  207.   #--------------------------------------------------------------------------
  208.   def update_footsteps
  209.     @character_sprites.each {|sprite|
  210.       if sprite.character.is_a?(Game_Footprint)
  211.         sprite.character.update
  212.         if sprite.opacity <= 0 # 不透明度為0時
  213.           @character_sprites.delete(sprite) # 移除精靈
  214.           sprite.dispose # 釋放腳印精靈
  215.         end
  216.       end
  217.     }
  218.   end
  219. end
  220. class Scene_Map < Scene_Base
  221.   #--------------------------------------------------------------------------
  222.   # ● 加入腳印精靈
  223.   #--------------------------------------------------------------------------
  224.   def add_footprint_sprite(footprint)
  225.     @spriteset.add_footprint(footprint)
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ● 創建地圖精靈組
  229.   #--------------------------------------------------------------------------
  230.   alias footprint_create_spriteset create_spriteset
  231.   def create_spriteset
  232.     footprint_create_spriteset
  233.     $game_player.push_footprint
  234.   end
  235. end


就是我想通过这个配合shift冲刺,做出残影的效果,
但是试了很多方法都不清楚怎么让这个脚本只有在shift按下的情况才显示足迹
没事的过来瞄一眼,有事的也过来瞄一眼...群组,XAS PS VA
http://rpg.blue/forum.php?mod=group&fid=537
XAS探索目录:http://rpg.blue/home.php?mo ... o=blog&id=12595
如果有人对你说,你如此帅气(美丽),你要分三个角度去想:
1.就像妈妈对你说:“你如此帅气(美丽)。”(安慰)
2.就像女(男)朋友对你说:“你如此帅气(美丽)”(欺瞒)
3.就像乞丐对你说:“你如此帅气(美丽)”(讨好)

Lv4.逐梦者 (版主)

梦石
0
星屑
6886
在线时间
7027 小时
注册时间
2013-11-2
帖子
1344

开拓者剧作品鉴家

2
发表于 2016-10-17 15:12:29 | 只看该作者
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 新增腳印
  3.   #--------------------------------------------------------------------------
  4.   def push_footprint(prev_dir=2)
  5.     return unless SceneManager.scene_is?(Scene_Map)
  6.     return if !dash?
  7.     if @footprint.data.size > 0
  8.       adjust_diagonal_footprint(prev_dir, $game_player.direction)
  9.       @footprint.data[-1].transparent = false
  10.     end
  11.     type = check_terrain?
  12.     return unless type
  13.     @footprint.push_fp(type)
  14.     SceneManager.scene.add_footprint_sprite(@footprint.data[-1])
  15.   end


第144行的方法改成这样。重点是 return if !dash? 非冲刺状态则不新增脚印。

评分

参与人数 1星屑 +15 收起 理由
xingmot + 15 虽然我XAS的系统还是不行,但是谢谢你了,.

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
120
在线时间
188 小时
注册时间
2014-1-18
帖子
254
3
 楼主| 发表于 2016-10-17 19:45:25 | 只看该作者
稍微改一点点脚本就崩溃,还说未定义方法= =
XAS改系统的东西太多了
没事的过来瞄一眼,有事的也过来瞄一眼...群组,XAS PS VA
http://rpg.blue/forum.php?mod=group&fid=537
XAS探索目录:http://rpg.blue/home.php?mo ... o=blog&id=12595
如果有人对你说,你如此帅气(美丽),你要分三个角度去想:
1.就像妈妈对你说:“你如此帅气(美丽)。”(安慰)
2.就像女(男)朋友对你说:“你如此帅气(美丽)”(欺瞒)
3.就像乞丐对你说:“你如此帅气(美丽)”(讨好)
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
120
在线时间
188 小时
注册时间
2014-1-18
帖子
254
4
 楼主| 发表于 2016-10-18 10:45:00 | 只看该作者
原本的足迹范例完全没问题,但是XAS里好像改过很多行走图方面的东西,好像判断冲刺的那里被改过了,似乎有一句
alias x_dash dash?
那是不是把dash?换成x_dash就行了?

点评

然后就NameError了= =  发表于 2016-10-18 10:50
没事的过来瞄一眼,有事的也过来瞄一眼...群组,XAS PS VA
http://rpg.blue/forum.php?mod=group&fid=537
XAS探索目录:http://rpg.blue/home.php?mo ... o=blog&id=12595
如果有人对你说,你如此帅气(美丽),你要分三个角度去想:
1.就像妈妈对你说:“你如此帅气(美丽)。”(安慰)
2.就像女(男)朋友对你说:“你如此帅气(美丽)”(欺瞒)
3.就像乞丐对你说:“你如此帅气(美丽)”(讨好)
回复 支持 反对

使用道具 举报

Lv4.逐梦者 (版主)

梦石
0
星屑
6886
在线时间
7027 小时
注册时间
2013-11-2
帖子
1344

开拓者剧作品鉴家

5
发表于 2016-10-18 11:04:00 | 只看该作者
RUBY 代码复制
  1. def dash_x?
  2.     return false if @move_route_forcing
  3.     return false if $game_map.disable_dash?
  4.     return false if vehicle
  5.     return Input.press?(:A)
  6.   end


在足迹脚本里面添加这一段(在push_footprint的上方)
然后把push_footprint里面的return if !dash? 换成 return if !dash_x?

我不确定这个会不会造成更多问题,但是还是报错的话(尤其是dash_x?里面的上面三行return_false),尝试注释它们,最后剩下的会是
RUBY 代码复制
  1. def dash_x?
  2.     return Input.press?(:A)
  3.   end


虽然还是不理想(就算是自动事件正常行动或者在不可冲刺的地图,按了冲刺键还是会产生脚步)

评分

参与人数 1星屑 +250 梦石 +1 收起 理由
怪蜀黍 + 250 + 1 楼主认可的解答

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
120
在线时间
188 小时
注册时间
2014-1-18
帖子
254
6
 楼主| 发表于 2016-10-18 11:43:23 | 只看该作者
我感觉应该也没问题,但是XAS系统莫名奇妙其他地方会出问题= =
一按shift就崩溃
没事的过来瞄一眼,有事的也过来瞄一眼...群组,XAS PS VA
http://rpg.blue/forum.php?mod=group&fid=537
XAS探索目录:http://rpg.blue/home.php?mo ... o=blog&id=12595
如果有人对你说,你如此帅气(美丽),你要分三个角度去想:
1.就像妈妈对你说:“你如此帅气(美丽)。”(安慰)
2.就像女(男)朋友对你说:“你如此帅气(美丽)”(欺瞒)
3.就像乞丐对你说:“你如此帅气(美丽)”(讨好)
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-20 12:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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