Project1

标题: CharacterNameDisplay ( 人物名称显示 ) [2012.8.13] [打印本页]

作者: 忧雪の伤    时间: 2011-8-22 21:50
标题: CharacterNameDisplay ( 人物名称显示 ) [2012.8.13]
本帖最后由 忧雪の伤 于 2012-8-13 19:30 编辑
  1. #==============================================================================
  2. #  Name [ CharacterNameDisplay ( 人物名称显示 ) ]
  3. #  Apply To [ RPG Maker XP & RPG Maker VX & RPG Maker VX Ace ]
  4. #------------------------------------------------------------------------------
  5. #  Author [ 忧雪の伤 ]
  6. #  Last Update [ 2012.8.13 ]
  7. #------------------------------------------------------------------------------
  8. #  Link [ 66RPG Ideal Script Association ]
  9. #  => http://rpg.blue/group-215-1.html
  10. #  Link [ OWL Authors' Protection Organization ]
  11. #  => http://oapo.qzworld.net/index.html
  12. #==============================================================================

  13. #==============================================================================
  14. # * Test Section
  15. #==============================================================================

  16. unless Module.constants.include? RUBY_VERSION == '1.9.2' ? :ISA : 'ISA'
  17.   message = "You need to add that script over this."
  18.   method(RUBY_VERSION == '1.9.2' ? :msgbox : :p)[message]
  19.   `start http://rpg.blue/thread-181551-1-1.html`
  20. end

  21. #==============================================================================
  22. # * Registered Section
  23. #==============================================================================

  24. $imported['CharacterNameDisplay'] = '2012.8.13'

  25. #==============================================================================
  26. # * Running Section
  27. #==============================================================================

  28. module ISA::CharacterNameDisplay
  29.   #--------------------------------------------------------------------------
  30.   # * Setup Section
  31.   #--------------------------------------------------------------------------
  32.   #    LocationPlus : 置顶的布尔值 ( true or false )
  33.   #    Switch : 返回布尔值的过程对象 ( Method or Proc )
  34.   #--------------------------------------------------------------------------
  35.   LocationPlus = true
  36.   Switch = proc { $game_switches[0] }
  37.   class Sprite < ::Sprite
  38.     #------------------------------------------------------------------------
  39.     # * Setup Section
  40.     #------------------------------------------------------------------------
  41.     #    DefaultSize : 默认字体大小 ( Fixnum )
  42.     #    DefaultName : 默认字体名称 (  Array or String )
  43.     #    DefaultColor : 默认字体颜色 ( Color )
  44.     #    DefaultBold : 默认字体粗体 ( true or false )
  45.     #    DefaultItalic : 默认字体斜体 ( true or false )
  46.     #    DefaultShadow : 默认字体阴影 ( true or false ) [ VX or VA ]
  47.     #    DefaultOutline : 默认字体描边 ( true or false ) [ VA ]
  48.     #    DefaultOutColor : 默认字体描边颜色 ( Color ) [ VA ]
  49.     #------------------------------------------------------------------------
  50.     DefaultSize = Font.default_size
  51.     DefaultName = Font.default_name
  52.     DefaultColor = Font.default_color
  53.     DefaultBold = Font.default_bold
  54.     DefaultItalic = Font.default_italic
  55.     begin
  56.       DefaultShadow = Font.default_shadow
  57.       DefaultOutline = Font.default_outline
  58.       DefaultOutColor = Font.default_out_color
  59.     rescue
  60.       nil
  61.     end
  62.     attr_reader :string
  63.     def initialize viewport, character
  64.       super viewport
  65.       @block = proc { '' }
  66.       begin
  67.         symbol = :isa_name_for_character_name_display
  68.         case character
  69.         when Game_Player
  70.           case ISA::Edition
  71.           when :xp
  72.             @block = $data_actors[$game_party.actors[0].id].method symbol
  73.           when :vx
  74.             @block = $game_party.members[0].actor.method symbol
  75.           when :va
  76.             @block = character.actor.actor.method symbol
  77.           end
  78.         when (Game_Follower rescue nil)
  79.           @block = character.actor.actor.method symbol
  80.         when Game_Event
  81.           @block = character.instance_variable_get(:@event).method symbol
  82.         end
  83.       rescue
  84.         nil
  85.       end
  86.       @string = @block.call
  87.       @character = character
  88.       self.x = character.screen_x
  89.       self.y = character.screen_y
  90.       refresh
  91.       nil
  92.     end
  93.     def update
  94.       self.x = @character.screen_x
  95.       self.y = @character.screen_y
  96.       self.ox = src_rect.width / 2
  97.       return if @string.equal? @block.call
  98.       @string = @block.call
  99.       refresh
  100.       nil
  101.     end
  102.     def dispose
  103.       super
  104.       bitmap.dispose unless bitmap.nil?
  105.       nil
  106.     end
  107.     def refresh
  108.       bitmap.dispose unless bitmap.nil?
  109.       return if match_each_line.empty?
  110.       src_bitmap = []
  111.       match_each_line.each {|item|
  112.         bitmap = Bitmap.new 16, 16
  113.         bitmap.font = item[1]
  114.         text_size = bitmap.text_size item[0]
  115.         width = text_size.width.zero? ? 16 : text_size.width
  116.         height = text_size.height.zero? ? 16 : text_size.height
  117.         src_bitmap << [Bitmap.new(width, height), item[0], 0]
  118.         plus = (src_bitmap[-2][0].height + src_bitmap[-2][2] rescue 0)
  119.         src_bitmap[-1][2] = src_bitmap[-1][2] + plus
  120.         src_bitmap[-1][0].font = item[1]
  121.       }
  122.       width = (src_bitmap.map {|item| item[0].width }).max
  123.       height = src_bitmap.inject(0) {|result, item| result + item[0].height }
  124.       self.bitmap = Bitmap.new width, height
  125.       src_bitmap.each {|item|
  126.         bitmap.font = item[0].font
  127.         bitmap.draw_text 0, item[2], width, item[0].height, item[1], 1
  128.       }
  129.       nil
  130.     end
  131.     def match_each_line
  132.       @string.dup.split(/\\n/).map {|item|
  133.         font = Font.new
  134.         font.size = DefaultSize
  135.         font.name = DefaultName
  136.         font.color = DefaultColor
  137.         item.slice!(/<size\(([0-9]*)\)>/)
  138.         font.size = $1.to_i unless $1.nil?
  139.         item.slice!(/<name\((.*)\)>/)
  140.         font.name = $1 unless $1.nil?
  141.         item.slice!(/<bold\((true|false)\)>/)
  142.         font.bold = $1 ? eval($1) : DefaultBold
  143.         item.slice!(/<italic\((true|false)\)>/)
  144.         font.italic = $1 ? eval($1) : DefaultItalic
  145.         item.slice!(/<color\((.*)\)>/)
  146.         font.color.set *$1.split(/,/).map {|string| string.to_f } unless $1.nil?
  147.         begin
  148.           item.slice!(/<shadow\((true|false)\)>/)
  149.           font.shadow = $1 ? eval($1) : DefaultShadow
  150.           item.slice!(/<outline\((true|false)\)>/)
  151.           font.outline = $1 ? eval($1) : DefaultOutline
  152.           item.slice!(/<out_color\((.*)\)>/)
  153.           raise StandardError if $1.nil?
  154.           font.out_color.set *$1.split(/,/).map {|item| item.to_f }
  155.         rescue
  156.           nil
  157.         end
  158.         [item, font]
  159.       }
  160.     end
  161.   end
  162. end

  163. [RPG::Actor, RPG::Event].each {|item|
  164.   item.class_eval {
  165.     alias isa_name_for_character_name_display name unless $@
  166.     def name *args
  167.       result = isa_name_for_character_name_display(*args).dup
  168.       array = [/<bold\((true|false)\)>/, /<italic\((true|false)\)>/,
  169.       /<shadow\((true|false)\)>/, /<outline\((true|false)\)>/, /<invisible>/,
  170.       /<size\([0-9]*\)>/, /<name\(.*\)>/, /<color\(.*\)>/, /<out_color\(.*\)>/]
  171.       array.each {|item| result.slice! item }
  172.       result.gsub(/\\n/, '')
  173.     end
  174.   }
  175. }

  176. class Game_Character
  177.   alias isa_initialize_fisrt_for_character_name_display initialize
  178.   attr_accessor :isa_boolean_for_character_name_display
  179.   def initialize *args
  180.     @isa_boolean_for_character_name_display = true
  181.     isa_initialize_fisrt_for_character_name_display *args
  182.   end
  183. end

  184. class Game_Event
  185.   alias isa_initialize_second_for_character_name_display initialize
  186.   def initialize *args
  187.     isa_initialize_second_for_character_name_display *args
  188.     @isa_boolean_for_character_name_display =
  189.       [email protected]_name_for_character_name_display[0, 2]['EV']
  190.     nil
  191.   end
  192. end
  193.   
  194. class Sprite_Character
  195.   alias isa_initialize_for_character_name_display initialize
  196.   alias isa_dispose_for_character_name_display dispose
  197.   alias isa_update_for_character_name_display update
  198.   def initialize *args
  199.     sprite = ISA::CharacterNameDisplay::Sprite.new args[0], args[1]
  200.     @isa_name_for_character_name_display = sprite
  201.     isa_initialize_for_character_name_display *args
  202.   end
  203.   def dispose *args
  204.     @isa_name_for_character_name_display.dispose
  205.     isa_dispose_for_character_name_display *args
  206.   end
  207.   def update *args
  208.     sprite = @isa_name_for_character_name_display
  209.     sprite.visible = visible && !sprite.string['<invisible>'] &&
  210.       character.isa_boolean_for_character_name_display &&
  211.         !ISA::CharacterNameDisplay::Switch[]
  212.     sprite.z = self.z + 1
  213.     sprite.update
  214.     return unless ISA::CharacterNameDisplay::LocationPlus
  215.     sprite.oy = src_rect.height + sprite.src_rect.height
  216.     isa_update_for_character_name_display *args
  217.   end
  218. end
复制代码

作者: 越前リョーマ    时间: 2011-10-6 00:19
这不是坑里的那个脚本么,各种美好
作者: 574656549    时间: 2012-1-29 21:29
提示: 作者被禁止或删除 内容自动屏蔽
作者: a2219119    时间: 2012-7-6 02:17
LZ能搞个脚本使用说明吗?我们菜鸟看不懂脚本!

作者: a2219119    时间: 2012-7-6 13:37
好像脚本出问题....

360截图20120706133437921.jpg (6.15 KB, 下载次数: 29)

脚本28行出错

脚本28行出错

360截图20120706133524937.jpg (9.71 KB, 下载次数: 35)

错误的时为什么会弹出网址

错误的时为什么会弹出网址

作者: acn00269    时间: 2012-7-7 19:07
a2219119 发表于 2012-7-6 13:37
好像脚本出问题....

把这个脚本也放到你脚本编辑器上
点击这里
作者: ′芙兰朵露    时间: 2012-9-17 09:36
请问如何更改字体大小和位置...比如说放在脚下
作者: zpmqxine    时间: 2013-2-20 19:45
脚本208行错误
uninitialized constant ISA::CharacterNameDisplay
很实用的脚本啊,很想用但新手不懂,求解决




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