Project1

标题: NCP角色显示名称 [打印本页]

作者: yangff    时间: 2008-1-20 18:22
标题: NCP角色显示名称
在MAIN上面复制本脚本:
  1. class Game_Event < Game_Character
  2. #——————————————————————————————————————
  3. # 用来返回名称
  4. #——————————————————————————————————————
  5. def name
  6.    return @event.name
  7. end  
  8. def name=(newname)
  9.    @event.name = newname
  10. end
  11. end
  12. #==============================================================================
  13. # ■ Sprite_Character
  14. #------------------------------------------------------------------------------
  15. #  角色显示用脚本。监视 Game_Character 类的实例、
  16. # 自动变化脚本状态。
  17. #==============================================================================
  18. $flyname = "Vehicle"
  19. class Sprite_Character < Sprite_Base
  20.   #--------------------------------------------------------------------------
  21.   # ● 定量
  22.   #--------------------------------------------------------------------------
  23.   BALLOON_WAIT = 12                  # 表情最后帧的等待时间
  24. #--------------------------------------------------------------------------
  25. # ● 定义实例变量
  26. #--------------------------------------------------------------------------
  27. attr_accessor :character                # 角色
  28. #--------------------------------------------------------------------------
  29. # ● 初始化对像
  30. #     viewport  : 查看端口
  31. #     character : 角色 (Game_Character)
  32. #--------------------------------------------------------------------------
  33. def initialize(viewport, character = nil)
  34.    if character.character_name != $flyname
  35.    name = character.name
  36.    end
  37.    super(viewport)
  38.    @character = character
  39.    @namesprite = Sprite.new
  40.    @namesprite.bitmap = Bitmap.new(160, 48)
  41.    @namesprite.bitmap.font.name = "黑体"
  42.    @namesprite.bitmap.font.size = 16
  43.    @namesprite.bitmap.font.color.set(255, 255, 255)
  44.    @evname = name
  45.    if character.character_name != $flyname
  46.    @evname_split = name.split(/,/)[0]
  47. else
  48.    @evname_split = nil
  49. end
  50. if character.character_name != $flyname
  51.    if name[0, 2]=="EV" or character.character_name == $flyname
  52.      @evname_split = " "
  53.    end
  54. end
  55. if character.character_name != $flyname
  56.    if name.split(/,/)[1] != nil
  57.      case name.split(/,/)[1]
  58.      when "0"
  59.        @namesprite.bitmap.font.color.set(255, 255, 255)
  60.      when "1"
  61.        @namesprite.bitmap.font.color.set(128, 128, 255)
  62.      when "2"
  63.        @namesprite.bitmap.font.color.set(255, 128, 128)
  64.      when "3"
  65.        @namesprite.bitmap.font.color.set(128, 255, 128)
  66.      when "4"
  67.        @namesprite.bitmap.font.color.set(128, 255, 255)
  68.      when "5"
  69.        @namesprite.bitmap.font.color.set(255, 128, 255)
  70.      when "6"
  71.        @namesprite.bitmap.font.color.set(255, 255, 128)
  72.      when "7"
  73.        @namesprite.bitmap.font.color.set(192, 192, 192)
  74.      else
  75.        @namesprite.bitmap.font.color.set(255, 255, 255)
  76.      end
  77.    end
  78. end
  79.    if @evname_split != "" and @evname_split != nil
  80.      @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1)
  81.    end
  82.     @character = character
  83.     @balloon_duration = 0
  84.    update
  85. end
  86.   #--------------------------------------------------------------------------
  87.   # ● 释放
  88.   #--------------------------------------------------------------------------
  89.   def dispose
  90.    if character.character_name != $flyname
  91.    @namesprite.bitmap.dispose
  92.    @namesprite.dispose
  93. end

  94.     dispose_balloon
  95.     super
  96.   end
  97. #--------------------------------------------------------------------------
  98. # ● 更新画面
  99. #--------------------------------------------------------------------------
  100. def update
  101.     super
  102.     update_bitmap
  103.     self.visible = (not @character.transparent)
  104.     update_src_rect
  105.     self.x = @character.screen_x
  106.     self.y = @character.screen_y
  107.     self.z = @character.screen_z
  108.     self.opacity = @character.opacity
  109.     self.blend_type = @character.blend_type
  110.     self.bush_depth = @character.bush_depth
  111.     update_balloon
  112.     if @character.animation_id != 0
  113.       animation = $data_animations[@character.animation_id]
  114.       start_animation(animation)
  115.       @character.animation_id = 0
  116.     end
  117.     if @character.balloon_id != 0
  118.       @balloon_id = @character.balloon_id
  119.       start_balloon
  120.       @character.balloon_id = 0
  121.     end

  122.     if character.character_name != $flyname
  123.    if @evname != @character.name
  124.      @namesprite.bitmap.clear
  125.      @evname = @character.name
  126.      @evname_split = @character.name.split(/,/)[0]
  127.      if @character.name.split(/,/)[1] != nil
  128.        case @character.name.split(/,/)[1]
  129.        when "0"
  130.          @namesprite.bitmap.font.color.set(255, 255, 255)
  131.        when "1"
  132.          @namesprite.bitmap.font.color.set(128, 128, 255)
  133.        when "2"
  134.          @namesprite.bitmap.font.color.set(255, 128, 128)
  135.        when "3"
  136.          @namesprite.bitmap.font.color.set(128, 255, 128)
  137.        when "4"
  138.          @namesprite.bitmap.font.color.set(128, 255, 255)
  139.        when "5"
  140.          @namesprite.bitmap.font.color.set(255, 128, 255)
  141.        when "6"
  142.          @namesprite.bitmap.font.color.set(255, 255, 128)
  143.        when "7"
  144.          @namesprite.bitmap.font.color.set(192, 192, 192)
  145.        else
  146.          @namesprite.bitmap.font.color.set(255, 255, 255)
  147.        end
  148.      end
  149.      if @evname_split != "" and @evname_split != nil
  150.        @namesprite.bitmap.draw_text(0, 0, 160, 36, @evname_split, 1)
  151.      end
  152.    end
  153.    @namesprite.x = self.x-80
  154.    @namesprite.y = self.y-self.oy-24
  155.    #@namesprite.visible = $game_switches[39]
  156.    end
  157. end
  158.   #--------------------------------------------------------------------------
  159.   # ● 获取图块图像的指定图块
  160.   #     tile_id : 图块 ID
  161.   #--------------------------------------------------------------------------
  162.   def tileset_bitmap(tile_id)
  163.     set_number = tile_id / 256
  164.     return Cache.system("TileB") if set_number == 0
  165.     return Cache.system("TileC") if set_number == 1
  166.     return Cache.system("TileD") if set_number == 2
  167.     return Cache.system("TileE") if set_number == 3
  168.     return nil
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 刷新传送的位图数据
  172.   #--------------------------------------------------------------------------
  173.   def update_bitmap
  174.     if @tile_id != @character.tile_id or
  175.        @character_name != @character.character_name or
  176.        @character_index != @character.character_index
  177.       @tile_id = @character.tile_id
  178.       @character_name = @character.character_name
  179.       @character_index = @character.character_index
  180.       if @tile_id > 0
  181.         sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
  182.         sy = @tile_id % 256 / 8 % 16 * 32;
  183.         self.bitmap = tileset_bitmap(@tile_id)
  184.         self.src_rect.set(sx, sy, 32, 32)
  185.         self.ox = 16
  186.         self.oy = 32
  187.       else
  188.         self.bitmap = Cache.character(@character_name)
  189.         sign = @character_name[/^[\!\$]./]
  190.         if sign != nil and sign.include?('$')
  191.           @cw = bitmap.width / 3
  192.           @ch = bitmap.height / 4
  193.         else
  194.           @cw = bitmap.width / 12
  195.           @ch = bitmap.height / 8
  196.         end
  197.         self.ox = @cw / 2
  198.         self.oy = @ch
  199.       end
  200.     end
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 刷新传送的矩形数据
  204.   #--------------------------------------------------------------------------
  205.   def update_src_rect
  206.     if @tile_id == 0
  207.       index = @character.character_index
  208.       pattern = @character.pattern < 3 ? @character.pattern : 1
  209.       sx = (index % 4 * 3 + pattern) * @cw
  210.       sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  211.       self.src_rect.set(sx, sy, @cw, @ch)
  212.     end
  213.   end
  214.   #--------------------------------------------------------------------------
  215.   # ● 开始显示表情图标
  216.   #--------------------------------------------------------------------------
  217.   def start_balloon
  218.     dispose_balloon
  219.     @balloon_duration = 8 * 8 + BALLOON_WAIT
  220.     @balloon_sprite = ::Sprite.new(viewport)
  221.     @balloon_sprite.bitmap = Cache.system("Balloon")
  222.     @balloon_sprite.ox = 16
  223.     @balloon_sprite.oy = 32
  224.     update_balloon
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● 刷新表情图标
  228.   #--------------------------------------------------------------------------
  229.   def update_balloon
  230.     if @balloon_duration > 0
  231.       @balloon_duration -= 1
  232.       if @balloon_duration == 0
  233.         dispose_balloon
  234.       else
  235.         @balloon_sprite.x = x
  236.         @balloon_sprite.y = y - height
  237.         @balloon_sprite.z = z + 200
  238.         if @balloon_duration < BALLOON_WAIT
  239.           sx = 7 * 32
  240.         else
  241.           sx = (7 - (@balloon_duration - BALLOON_WAIT) / 8) * 32
  242.         end
  243.         sy = (@balloon_id - 1) * 32
  244.         @balloon_sprite.src_rect.set(sx, sy, 32, 32)
  245.       end
  246.     end
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● 释放表情图标
  250.   #--------------------------------------------------------------------------
  251.   def dispose_balloon
  252.     if @balloon_sprite != nil
  253.       @balloon_sprite.dispose
  254.       @balloon_sprite = nil
  255.     end
  256.   end
  257. end
  258. class Game_Player < Game_Character
  259. def name
  260.    return ""
  261. end
  262. end

复制代码

作者: 紫剑阁~幻血    时间: 2008-1-20 18:35
提示: 作者被禁止或删除 内容自动屏蔽
作者: fmz    时间: 2008-1-20 18:36
测试了下 又个小BUG 显示人名换地图后跟随主角移动

作者: yangff    时间: 2008-1-20 18:50
以下引用fmz于2008-1-20 10:36:52的发言:

测试了下 又个小BUG 显示人名换地图后跟随主角移动

不会啊。
事件名里有EV的不会显示人名。根据66RPG上的修改
作者: fmz    时间: 2008-1-20 18:58
哦 不会吧  我吧我的工程传上
你帮我检查下
http://rpg.blue/upload_program/files/Project1_81255471.rar
作者: yangff    时间: 2008-1-20 19:34
以下引用fmz于2008-1-20 10:58:39的发言:

哦 不会吧  我吧我的工程传上
你帮我检查下
http://rpg.blue/upload_program/files/Project1_81255471.rar

很正常啊
作者: 越前リョーマ    时间: 2008-1-20 19:52
太好了,

刚好需要……!{/hx}{/qiang}
作者: fmz    时间: 2008-1-20 21:09
...................
以下引用yangff于2008-1-20 11:34:05的发言:
<br><script language="javascript">
<!--
strCont="[quote]以下引用fmz于2008-1-20 10:58:39的发言:\r\n\r\n哦 不会吧  我吧我的工程传上\r\n你帮我检查下 \r\nhttp://rpg.blue/upload_program/files/Project1_81255471.rar \r\n
\r\n很正常啊";
document.write(ubb.spbShowTopic(strCont,1));
//-->
</script><blockquote class="CodeBorder">以下引用fmz于2008-1-20 10:58:39的发言:<br>
<br>
哦 不会吧 &nbsp;我吧我的工程传上<br>
你帮我检查下 <br>
<a href="http://rpg.blue/upload_program/files/Project1_81255471.rar" target="_blank">http://rpg.blue/upload_program/files/Project1_81255471.rar</a> <br>
</blockquote><br>
很正常啊

[/quote]
郁闷了 自己找下哪里错了吧
作者: LSF蛋壳    时间: 2008-1-20 22:51
提示: 作者被禁止或删除 内容自动屏蔽
作者: yangff    时间: 2008-1-20 22:52
以下引用LSF蛋壳于2008-1-20 14:51:27的发言:


以下引用yangff于2008-1-20 11:34:05的发言:


以下引用fmz于2008-1-20 10:58:39的发言:

哦 不会吧  我吧我的工程传上
你帮我检查下
http://rpg.blue/upload_program/files/Project1_81255471.rar


很正常啊



有点问题……

{/gg}我不会啊
作者: 诡异の猫    时间: 2008-1-20 23:00
第86行
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    dispose_balloon
    @namesprite.bitmap.dispose
    @namesprite.dispose

    super
  end

加入这2行就OK
作者: yangff    时间: 2008-1-20 23:11
以下引用诡异の猫于2008-1-20 15:00:48的发言:

第86行
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
   dispose_balloon
   @namesprite.bitmap.dispose
   @namesprite.dispose
   super
end

加入这2行就OK

哦。这个BUG我修复了。可能他的脚本比较早
作者: fmz    时间: 2008-1-21 16:09
以下引用诡异の猫于2008-1-20 15:00:48的发言:
<br><script language="javascript">
<!--
strCont="第86行\r\n  #--------------------------------------------------------------------------\r\n  # ● 释放\r\n  #--------------------------------------------------------------------------\r\n  def dispose\r\n    dispose_balloon\r\n    @namesprite.bitmap.dispose\r\n    @namesprite.dispose\r\n    super\r\n  end\r\n\r\n加入这2行就OK";
document.write(ubb.spbShowTopic(strCont,1));
//-->
</script>第86行<br>
&nbsp;#--------------------------------------------------------------------------<br>
&nbsp;# ● 释放<br>
&nbsp;#--------------------------------------------------------------------------<br>
&nbsp;def dispose<br>
&nbsp; &nbsp;dispose_balloon<br>
&nbsp; &nbsp;<font color="#ff33ff">@namesprite.bitmap.dispose<br>
&nbsp; &nbsp;@namesprite.dispose</font><br>
&nbsp; &nbsp;super<br>
&nbsp;<font color="#000099">end</font><br>
<br>
加入这2行就OK

谢谢了 吧你的放进去后就不出现这个问题了!
作者: clamp1234    时间: 2008-1-21 19:00
提示: 作者被禁止或删除 内容自动屏蔽
作者: yangff    时间: 2008-1-21 19:02
以下引用fmz于2008-1-21 8:05:00的发言:

你发布的86行是这样的 汗!!!!!
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
  if character.character_name != $flyname
  @namesprite.bitmap.dispose
  @namesprite.dispose
end

   dispose_balloon
   super
end

如果character.character_name != $flyname就说明是飞行船。不须释放
作者: 越前リョーマ    时间: 2008-1-29 01:48
漏洞漏洞……

NPC选择独立开关后消失,
事件的名字依然存在……

可能跟VX的命名系统有关……
但XP版的就没这个问题……
作者: yangff    时间: 2008-1-29 02:06
以下引用越前リョーマ于2008-1-28 17:48:47的发言:

漏洞漏洞……

NPC选择独立开关后消失,
事件的名字依然存在……

可能跟VX的命名系统有关……
但XP版的就没这个问题……

你看看XP里 MS要 XXX.XXX[X] = "   "啊
作者: 越前リョーマ    时间: 2008-1-29 02:07
以下引用yangff于2008-1-28 18:06:05的发言:


以下引用越前リョーマ于2008-1-28 17:48:47的发言:

漏洞漏洞……

NPC选择独立开关后消失,
事件的名字依然存在……

可能跟VX的命名系统有关……
但XP版的就没这个问题……


你看看XP里 MS要 XXX.XXX[X] = "   "啊

至少没这个BUG……
作者: yangff    时间: 2008-1-29 02:18
并行一个
$game_map.events[事件ID].name = "  "
作者: clamp135    时间: 2008-1-29 02:28
提示: 作者被禁止或删除 内容自动屏蔽
作者: 越前リョーマ    时间: 2008-1-29 02:29
以下引用clamp135于2008-1-28 18:28:30的发言:

看小柯做的东东!发现NPC变透明后名字还在头顶上-.=!

就是因为这个原因……
作者: clamp135    时间: 2008-1-29 02:58
提示: 作者被禁止或删除 内容自动屏蔽
作者: 2288809    时间: 2008-11-12 04:51
???
-------------66RPG-------------------
◆ 2008-11-11 20:51:05
错误类型 :
        Errno::ENOENT
错误信息 :
        No such file or directory - Graphics/Battlebacks/5#<RPG::MapInfo:0x1b6e1f0>16#<RPG::MapInfo:0x1b6f270>27#<RPG::MapInfo:0x1b6f360>11#<RPG::MapInfo:0x1b6d8a8>22#<RPG::MapInfo:0x1b6e190>17#<RPG::MapInfo:0x1b6d788>6#<RPG::MapInfo:0x1b6d7e8>28#<RPG::MapInfo:0x1b6d848>23#<RPG::MapInfo:0x1b6d668>1#<RPG::MapInfo:0x1b6d6c8>12#<RPG::MapInfo:0x1b6d728>29#<RPG::MapInfo:0x1b6d548>18#<RPG::MapInfo:0x1b6d5a8>7#<RPG::MapInfo:0x1b6d608>24#<RPG::MapInfo:0x1b6d428>2#<RPG::MapInfo:0x1b6d488>13#<RPG::MapInfo:0x1b6d4e8>30#<RPG::MapInfo:0x1b6d308>19#<RPG::MapInfo:0x1b6d368>8#<RPG::MapInfo:0x1b6d3c8>14#<RPG::MapInfo:0x1b6d1e8>3#<RPG::MapInfo:0x1b6d248>25#<RPG::MapInfo:0x1b6d2a8>9#<RPG::MapInfo:0x1b6d128>20#<RPG::MapInfo:0x1b6d188>4#<RPG::MapInfo:0x1b6d008>15#<RPG::MapInfo:0x1b6d068>26#<RPG::MapInfo:0x1b6d0c8>10#<RPG::MapInfo:0x1b6ccc0>21#<RPG::MapInfo:0x1b6cfa8>
错误可能发生的相关位置 :
        Cache : 第 79 行 : initialize
        Cache : 第 79 行 : new
        Cache : 第 79 行 : load_bitmap
        cp半即时战斗(普通版1.02a) : 第 1919 行 : battleback
        cp半即时战斗(普通版1.02a) : 第 346 行 : start
        Scene_Base : 第 12 行 : main
        错误详细提示 : 第 37 行 : run
        错误详细提示 : 第 151 行
-------------66RPG-------------------



我的本来就有cp半即时战斗的脚本和一些其他脚本,
出现了很多冲突!
作者: 死亡之龙    时间: 2008-11-15 19:24
提示: 作者被禁止或删除 内容自动屏蔽
作者: fmz    时间: 2009-6-12 08:00
你发布的86行是这样的 汗!!!!!
#--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
   if character.character_name != $flyname
   @namesprite.bitmap.dispose
   @namesprite.dispose
end

    dispose_balloon
    super
  end
作者: 电车之兔    时间: 2009-8-15 23:59
这是怎么回事?

npc.jpg (19.54 KB, 下载次数: 27)

npc.jpg

作者: number567    时间: 2009-9-25 01:20
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1