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

Project1

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

[RMVA发布] 凡走过必留下痕迹 ── 脚印系统脚本

[复制链接]

Lv2.观梦者

天仙

梦石
0
星屑
610
在线时间
184 小时
注册时间
2008-4-15
帖子
5023

贵宾

跳转到指定楼层
发表于 2012-3-18 12:46:07 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

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

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

x
本帖最后由 Sion 于 2013-12-16 16:24 编辑

使用说明

数据库->图块中的备注理填写 [fp_type 地形标记ID 脚印类型]
普通脚印使用 normal
例如: [fp_type 1 normal] 表示 1 号地形标记使用普通脚印
使用时必须在 Graphics/Characters 中放置一个脚印的行走图(文件名 $footprint)
图片格式如一般行走图,不过没有动画时只需要正中间一栏即可(参考范例)

使用其他类型时,需要再 Graphics/Characters 中放置一个脚印的行走图
文件名为 $footprint + 下划线 + 类型名称
如 $footprint_blood 那么在备注中就能使用 [fp_type 1 blood] 调用

如果需要使用斜方向的脚印,那就再放一个斜方向的行走图
格式由上至下为 右上、右下、左上、左下
文件名为  普通文件名 + _dia
如 $footprint_dia 就是对应 $footprint 的斜方向行走图
$footprint_blood_dia 就是对应 $footprint_blood 的斜方向行走图
斜方向脚印会在转弯时自动使用
没有对应文件时会自动忽略


数据库->图块中的备注理填写 [fp_sound 地形标记ID 音效文件名]
就可以调用 Audio/SE 中的音效文件

数据库->图块中的备注理填写 [fp_fade 秒数]
可以设定某图块中脚印消失的速度
没有填写时默认为 5
设定为 0 时则不会消失(不过会渐渐拖慢速度)

范例:
http://115.com/file/c2hel4yh
http://hop.tl/3TVxPnNxsyqL38nZo7
footprint.zip (2.17 MB, 下载次数: 1576)


  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.       [url=home.php?mod=space&uid=316553]@opacity[/url] -= 10
  84.     end
  85.   end
  86. end
  87. class Game_Footprints
  88.   #--------------------------------------------------------------------------
  89.   # ● 初始化
  90.   #--------------------------------------------------------------------------
  91.   def initialize
  92.     @data = []
  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
复制代码

点评

VA行走图里有脚印的……!Onther的第六张……  发表于 2012-3-18 21:17

评分

参与人数 1星屑 +1332 收起 理由
fux2 + 1332 塞糖

查看全部评分

VA脚本开工中...
偷窃脚本1.0 - 已完成

Lv1.梦旅人

梦石
0
星屑
104
在线时间
15 小时
注册时间
2023-5-29
帖子
11
16
发表于 2023-9-2 20:47:54 | 只看该作者
不错的细节脚本!
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
349
在线时间
76 小时
注册时间
2018-1-26
帖子
28
15
发表于 2018-2-11 14:19:16 | 只看该作者
楼主,我用了这个叫脚本,和NPC头上显示字的脚本有冲突啊,请问怎么解决呢。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
241
在线时间
23 小时
注册时间
2017-11-22
帖子
42
14
发表于 2017-11-23 13:42:52 | 只看该作者
本帖最后由 xkwzx 于 2017-11-23 13:45 编辑

C:\Users\Administrator\Desktop
显示错误
class RPG::Tileset
  #--------------------------------------------------------------------------
  # ● 获取脚印类型
  #--------------------------------------------------------------------------
  def get_footprint_type(tag_id)
    return false unless tag_id.is_a?(Integer)
    self.note.split(/[\r\n]+/).each { |line|
      if line =~ /\[fp_type #{tag_id} (\S+)\]/
        return $1.to_sym
      end
    }
    return :none
  end
  #--------------------------------------------------------------------------
  # ● 获取脚印音效
  #--------------------------------------------------------------------------
  def get_footprint_sound(tag_id)
    return false unless tag_id.is_a?(Integer)
    self.note.split(/[\r\n]+/).each { |line|
      if line =~ /\[fp_sound #{tag_id} (\S+)\]/
        return $1
      end
    }
    return ""
  end
  #--------------------------------------------------------------------------
  # ● 获取脚印淡出速度
  #--------------------------------------------------------------------------
  def get_footprint_fade
    self.note.split(/[\r\n]+/).each { |line|
      if line =~ /\[fp_fade (\d+)\]/
        return $1.to_i
      end
    }
    return 5
  end
end
class Game_Footprint < Game_CharacterBase
  attr_reader :type
  attr_accessor :pattern
  attr_accessor :character_name
  attr_accessor :direction
  attr_accessor :direction_fix
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(t)
    super()
    return unless $game_player
    @direction = $game_player.direction
    self.type = t
    @move_speed = 4
    @move_frequency = 6
    @priority_type = 0
    @through = true
    @transparent = true
    moveto($game_player.x, $game_player.y)
  end
  #--------------------------------------------------------------------------
  # ● 设置类型
  #--------------------------------------------------------------------------
  def type=(t)
    @type = t
    @character_name = "$footprint"
    if @type != :normal
      @character_name += "_" + @type.to_s
    end
    case @type
    when :ripple
      @step_anime = true
      @stop_count = 8
    end
  end
  #--------------------------------------------------------------------------
  # ● 脚印更新
  #--------------------------------------------------------------------------
  def update
    super
    return if pos?($game_player.x, $game_player.y)
    fadespeed = $game_map.tileset.get_footprint_fade
    return if fadespeed == 0
    if Graphics.frame_count % fadespeed == 0
      @opacity -= 10
    end
  end
end
class Game_Footprints
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize
    @data = []
  end
  #--------------------------------------------------------------------------
  # ● 加入脚印
  #--------------------------------------------------------------------------
  def push_fp(t=:normal)
    footp = Game_Footprint.new(t)
    footp.moveto($game_player.x, $game_player.y)
    footp.set_direction($game_player.direction)
    @data.push(footp)
  end
  #--------------------------------------------------------------------------
  # ● 设置类型
  #--------------------------------------------------------------------------
  def type=(t)
    @data.each{ |ft|
      ft.type = t
    }
  end
  attr_reader :data
end
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 清除移动资讯
  #--------------------------------------------------------------------------
  alias footprint_clear_transfer_info clear_transfer_info
  def clear_transfer_info
    footprint_clear_transfer_info
    @footprint = Game_Footprints.new
  end
  #--------------------------------------------------------------------------
  # ● 返回脚印列表
  #--------------------------------------------------------------------------
  def footprints
    return @footprint.data
  end
  #alias footprint_moveto moveto
  #def moveto(x, y)
  #  footprint_moveto(x, y)
    #push_footprint
  #end
  #--------------------------------------------------------------------------
  # ● 直线移动
  #--------------------------------------------------------------------------
  alias footprint_move_straight move_straight
  def move_straight(d, turn_ok = true)
    previous_direction = @direction
    footprint_move_straight(d, turn_ok)
    if @move_succeed
      push_footprint(previous_direction)
    end
  end
  #--------------------------------------------------------------------------
  # ● 新增脚印
  #--------------------------------------------------------------------------
  def push_footprint(prev_dir=2)
    return unless SceneManager.scene_is?(Scene_Map)
    if @footprint.data.size > 0
      adjust_diagonal_footprint(prev_dir, $game_player.direction)
      @footprint.data[-1].transparent = false
    end
    type = check_terrain?
    return unless type
    @footprint.push_fp(type)
    SceneManager.scene.add_footprint_sprite(@footprint.data[-1])
  end
  def adjust_diagonal_footprint(last_dir, curr_dir)
    return if last_dir == curr_dir
    footprint = @footprint.data[-1]
    name = footprint.character_name + "_dia"
    return unless FileTest.exist?("Graphics/Characters/#{name}.png")
    footprint.character_name = name
    case last_dir+curr_dir
    when 6
      footprint.direction = 8
    when 8
      footprint.direction = 4
    when 12
      footprint.direction = 6
    when 14
      footprint.direction = 2
    end
  end
  #--------------------------------------------------------------------------
  # ● 检查地形
  #--------------------------------------------------------------------------
  def check_terrain?
    terrain = $game_map.terrain_tag($game_player.x, $game_player.y)
    type  = $game_map.tileset.get_footprint_type(terrain)
    sound = $game_map.tileset.get_footprint_sound(terrain)
    RPG::SE.new(sound).play if sound != ""
    if type == :none
      return false
    else
      return type
    end
  end
end
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ● 增加脚印精灵
  #--------------------------------------------------------------------------
  def add_footprint(footprint)
    @character_sprites.push(Sprite_Character.new(@viewport1, footprint))
  end
  #--------------------------------------------------------------------------
  # ● 更新角色精灵
  #--------------------------------------------------------------------------
  alias footprint_update_characters update_characters
  def update_characters
    footprint_update_characters # 调用原有方法
    update_footsteps # 更新脚印
  end
  #--------------------------------------------------------------------------
  # ● 更新脚印精灵
  #--------------------------------------------------------------------------
  def update_footsteps
    @character_sprites.each {|sprite|
      if sprite.character.is_a?(Game_Footprint)
        sprite.character.update
        if sprite.opacity <= 0 # 不透明度为0时
          @character_sprites.delete(sprite) # 移除精灵
          sprite.dispose # 释放脚印精灵
        end
      end
    }
  end
end
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 加入脚印精灵
  #--------------------------------------------------------------------------
  def add_footprint_sprite(footprint)
    @spriteset.add_footprint(footprint)
  end
  #--------------------------------------------------------------------------
  # ● 创建地图精灵组
  #--------------------------------------------------------------------------
  alias footprint_create_spriteset create_spriteset
  def create_spriteset
    footprint_create_spriteset
    $game_player.push_footprint
  end
end

QQ图片20171123134200.png (17.08 KB, 下载次数: 11)

QQ图片20171123134200.png
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
12 小时
注册时间
2017-4-2
帖子
12
13
发表于 2017-7-17 15:16:10 | 只看该作者
本帖最后由 顾殇. 于 2017-7-17 17:33 编辑

为什么显示第84行有误?

评分

参与人数 1星屑 +1 收起 理由
鑫晴 + 1 你倒是把错误截图出来啊

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
815
在线时间
636 小时
注册时间
2011-1-21
帖子
176
12
发表于 2013-5-19 11:30:24 | 只看该作者
可用于XP么?
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3657
在线时间
4466 小时
注册时间
2008-6-12
帖子
802
11
发表于 2013-5-19 09:06:18 | 只看该作者
请问如何让NPC行走也能留下脚印呢
本人三无老人,请大神轻拍
回复 支持 反对

使用道具 举报

Lv1.梦旅人

幻想天神

梦石
0
星屑
55
在线时间
166 小时
注册时间
2012-3-24
帖子
404
10
发表于 2013-5-3 19:41:14 | 只看该作者
嗯。。。不错的脚本
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
30 小时
注册时间
2013-3-10
帖子
11
9
发表于 2013-5-3 10:15:42 | 只看该作者
115网盘挂掉了……脚印的行走图应该怎么做呢?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
202 小时
注册时间
2010-12-16
帖子
156
8
发表于 2013-2-16 18:14:55 | 只看该作者
速度的话,多少最高多少最低?
想成为触的渣一枚Or觉得自己是渣的渣一枚。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
14 小时
注册时间
2012-8-18
帖子
9
7
发表于 2012-8-20 19:21:15 | 只看该作者
比例不太对啊。。。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-10 19:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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