Project1

标题: 如何显示任务完成 [打印本页]

作者: DZ2333    时间: 2019-9-30 20:53
标题: 如何显示任务完成
就像魔兽世界一样,我和NPC对话,给我任务,完成后给任务的NPC头上会有感叹号
作者: 魔法丶小肉包    时间: 2019-9-30 23:32
RUBY 代码复制
  1. #encoding:utf-8
  2. #==============================================================================
  3. # ■ NPC头顶上显示图片(动态版) by 魔法丶小肉包
  4. #------------------------------------------------------------------------------
  5. # 说明:在指定NPC头上显示图片(自定义图片)
  6. #
  7. # 使用方法:
  8. # 事件-脚本 show_npc_icon 在本事件头上显示一次
  9. # 事件-脚本 show_npc_icon(2) 在2号事件头上显示一次
  10. # 如需一直显示,事件设定并行处理
  11. #
  12. # 素材名:SHOW 素材规格:256*32 分为8列,每一小格32*32(详细请参考心情图标的素材)
  13. #------------------------------------------------------------------------------
  14. # 更新日志:
  15. # 2019.9.30 公开发布
  16. #==============================================================================
  17. class Sprite_Character < Sprite_Base
  18.   attr_accessor :character
  19.   def initialize(viewport, character = nil)
  20.     super(viewport)
  21.     @character = character
  22.     @balloon_duration = 0
  23.     @show_duration = 0
  24.     update
  25.   end
  26.   def dispose
  27.     end_animation
  28.     end_balloon
  29.     end_show
  30.     super
  31.   end
  32.   def update
  33.     super
  34.     update_bitmap
  35.     update_src_rect
  36.     update_position
  37.     update_other
  38.     update_balloon
  39.     update_show
  40.     setup_new_effect
  41.   end
  42.   def setup_new_effect
  43.     if !animation? && @character.animation_id > 0
  44.       animation = $data_animations[@character.animation_id]
  45.       start_animation(animation)
  46.     end
  47.     if !@balloon_sprite && @character.balloon_id > 0
  48.       @balloon_id = @character.balloon_id
  49.       start_balloon
  50.     end
  51.     if !@show_sprite && @character.show_id > 0
  52.       @show_id = @character.show_id
  53.       start_show
  54.     end
  55.   end
  56.   def start_show
  57.     dispose_show
  58.     @show_duration = 8 * show_speed + show_wait
  59.     @show_sprite = ::Sprite.new(viewport)
  60.     @show_sprite.bitmap = Cache.system("SHOW")
  61.     @show_sprite.ox = 16
  62.     @show_sprite.oy = 32
  63.     update_show
  64.   end
  65.   def dispose_show
  66.     if @show_sprite
  67.       @show_sprite.dispose
  68.       @show_sprite = nil
  69.     end
  70.   end
  71.   def update_show
  72.     if @show_duration > 0
  73.       @show_duration -= 1
  74.       if @show_duration > 0
  75.         @show_sprite.x = x
  76.         @show_sprite.y = y - height
  77.         @show_sprite.z = z + 200
  78.         sx = show_frame_index * 32
  79.         sy = (@show_id - 1) * 32
  80.         @show_sprite.src_rect.set(sx, sy, 32, 32)
  81.       else
  82.         end_show
  83.       end
  84.     end
  85.   end
  86.   def end_show
  87.     dispose_show
  88.     @character.show_id = 0
  89.   end
  90.   def show_speed
  91.     return 8
  92.   end
  93.   def show_wait
  94.     return 12
  95.   end
  96.   def show_frame_index
  97.     return 7 - [(@show_duration - show_wait) / show_speed, 0].max
  98.   end
  99. end
  100. class Game_CharacterBase
  101.    attr_accessor :show_id
  102.    alias minit_public_members init_public_members
  103.    def init_public_members
  104.      minit_public_members
  105.      @show_id = 0
  106.    end
  107. end
  108. class Game_Interpreter
  109.   def show_npc_icon(id = 0)
  110.     return unless get_character(id)
  111.     get_character(id).show_id = 1
  112.   end
  113. end

作者: 魔法丶小肉包    时间: 2019-10-1 12:36





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