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

Project1

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

[已经解决] 战斗中敌人如何显示状态图标

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1346
在线时间
806 小时
注册时间
2013-8-3
帖子
455
跳转到指定楼层
1
发表于 2015-3-6 02:45:59 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我想让默认的战斗系统敌人显示异常状态图标,状态最好显示在敌人头上,不要显示血槽,可能需要脚本。

【同人游戏】勇者斗恶龙TG
欢迎加入游戏测试群333599798
如有需私聊请加QQ:516425000

Lv5.捕梦者

梦石
0
星屑
21962
在线时间
8568 小时
注册时间
2011-12-31
帖子
3362
2
发表于 2015-3-6 09:28:12 | 只看该作者
本帖最后由 tseyik 于 2015-3-6 10:02 编辑


http://blog.livedoor.jp/kurement ... cat_107209.html?p=2
不顯示生可在這二句前加上#
     new_bitmap.fill_rect(0, 25, width, 10, color(0))
      new_bitmap.gradient_fill_rect(2, 27, fill_w, 6, color(1), color(2))
  1. #==============================================================================
  2. #  ■エネミーの状態を表示 for RGSS3 Ver0.80-α
  3. # □作成者 kure
  4. #==============================================================================
  5. $kure_base_script = {} if $kure_base_script == nil
  6. $kure_base_script[:InfoBar] = 100
  7. p "エネミーの情報表示"
  8. module KURE
  9.   module InfoBar
  10.     #初期設定(変更しない事)-----------------------------------------------------
  11.     COLOR = []
  12.    
  13.     #表示色(IDによって割り当てが決まっています。)
  14.       #バーの背景色(ID0)
  15.       COLOR[0] = Color.new(32 ,32, 64, 255)
  16.       
  17.       #HPバーの色(ID1,ID2)
  18.       COLOR[1] = Color.new(224 ,128, 64, 255)
  19.       COLOR[2] = Color.new(240 ,192, 64, 255)
  20.    
  21.   end
  22. end

  23. #==============================================================================
  24. # ■ RPG::Enemy(追加定義)
  25. #==============================================================================
  26. class RPG::Enemy < RPG::BaseItem
  27.   #--------------------------------------------------------------------------
  28.   # ☆ バーの表示幅の定義(追加定義)
  29.   #--------------------------------------------------------------------------  
  30.   def infobar_width
  31.     @note.match(/<情報表示幅\s?(\d+)\s?>/)
  32.     return 100 unless $1
  33.     return $1.to_i
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ☆ バーの表示幅の定義(追加定義)
  37.   #--------------------------------------------------------------------------  
  38.   def infobar_visible?
  39.     return false if @note.include?("<情報非表示>")
  40.     return true
  41.   end
  42. end

  43. #==============================================================================
  44. # ■ Game_Enemy
  45. #==============================================================================
  46. class Game_Enemy < Game_Battler
  47.   #--------------------------------------------------------------------------
  48.   # ☆ バーの表示幅の定義(追加定義)
  49.   #--------------------------------------------------------------------------  
  50.   def infobar_width
  51.     return enemy.infobar_width
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ☆ バーの表示幅の定義(追加定義)
  55.   #--------------------------------------------------------------------------  
  56.   def infobar_visible?
  57.     return enemy.infobar_visible?
  58.   end
  59. end

  60. #==============================================================================
  61. # ■ Spriteset_Battle
  62. #==============================================================================
  63. class Spriteset_Battle
  64.   #--------------------------------------------------------------------------
  65.   # ● 敵キャラスプライトの作成(エイリアス再定義)
  66.   #--------------------------------------------------------------------------
  67.   alias k_basescript_before_create_enemies create_enemies
  68.   def create_enemies
  69.     k_basescript_before_create_enemies
  70.     @enemy_info_bar = $game_troop.members.reverse.collect do |enemy|
  71.       Sprite_Infobar.new(@viewport1, enemy)
  72.     end
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 敵キャラスプライトの更新(エイリアス再定義)
  76.   #--------------------------------------------------------------------------
  77.   alias k_basescript_before_update_enemies update_enemies
  78.   def update_enemies
  79.     k_basescript_before_update_enemies
  80.     @enemy_info_bar.each {|sprite| sprite.update }
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 敵キャラスプライトの解放(エイリアス再定義)
  84.   #--------------------------------------------------------------------------
  85.   alias k_basescript_before_dispose_enemies dispose_enemies
  86.   def dispose_enemies
  87.     k_basescript_before_dispose_enemies
  88.     @enemy_info_bar.each {|sprite| sprite.dispose }
  89.   end
  90. end

  91. #==============================================================================
  92. # ■ Sprite_Infobar
  93. #==============================================================================
  94. class Sprite_Infobar < Sprite_Base
  95.   #--------------------------------------------------------------------------
  96.   # ● 公開インスタンス変数
  97.   #--------------------------------------------------------------------------
  98.   attr_accessor :battler
  99.   #--------------------------------------------------------------------------
  100.   # ● オブジェクト初期化
  101.   #--------------------------------------------------------------------------
  102.   def initialize(viewport, battler = nil)
  103.     super(viewport)
  104.     @battler = battler
  105.     @fill_w = nil
  106.     @bitmap_data = Cache.battler(battler.battler_name, battler.battler_hue)
  107.     @state = battler.states
  108.     @icon_set = Cache.system("Iconset")
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● フレーム更新
  112.   #--------------------------------------------------------------------------
  113.   def update
  114.     super
  115.     if @battler
  116.       @use_sprite = @battler.use_sprite?
  117.       if @use_sprite
  118.         update_bitmap
  119.         update_origin
  120.         update_position
  121.       end
  122.     else
  123.       self.bitmap = nil
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 解放
  128.   #--------------------------------------------------------------------------
  129.   def dispose
  130.     bitmap.dispose if bitmap
  131.     super
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 転送元ビットマップの更新
  135.   #--------------------------------------------------------------------------
  136.   def update_bitmap
  137.     fill_w = @battler.infobar_width * (@battler.hp.to_f / @battler.mhp)
  138.     state = battler.states
  139.     if @fill_w != fill_w or @state != state
  140.       @fill_w = fill_w
  141.       @state = state
  142.       
  143.       width = @battler.infobar_width + 4
  144.       
  145.       new_bitmap = Bitmap.new(width, 35)
  146.       @state.each_with_index {|state, index|
  147.         next if 24 * (index + 1) > new_bitmap.width
  148.         rect = Rect.new(state.icon_index % 16 * 24, state.icon_index / 16 * 24, 24, 24)
  149.         new_bitmap.blt(24 * index, 0, @icon_set, rect, 255)
  150.       }
  151.       new_bitmap.fill_rect(0, 25, width, 10, color(0))
  152.       new_bitmap.gradient_fill_rect(2, 27, fill_w, 6, color(1), color(2))
  153.    
  154.       self.bitmap = new_bitmap
  155.       init_visibility
  156.       
  157.       self.opacity = 0 unless @battler.infobar_visible?
  158.     end
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 可視状態の初期化
  162.   #--------------------------------------------------------------------------
  163.   def init_visibility
  164.     @battler_visible = @battler.alive?
  165.     self.opacity = 0 unless @battler_visible
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ● 文字色取得
  169.   #--------------------------------------------------------------------------
  170.   def color(num)
  171.     return KURE::InfoBar::COLOR[num]
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 原点の更新
  175.   #--------------------------------------------------------------------------
  176.   def update_origin
  177.     if bitmap
  178.       self.ox = bitmap.width / 2
  179.       self.oy = bitmap.height
  180.     end
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 位置の更新
  184.   #--------------------------------------------------------------------------
  185.   def update_position
  186.     self.x = @battler.screen_x
  187.     self.y = @battler.screen_y - @bitmap_data.height
  188.     self.z = @battler.screen_z + 10
  189.   end
  190. end
复制代码

点评

请问sideview横版的可以使用这个脚本吗?  发表于 2015-7-3 14:16
请问下 生命值跟状态的位置怎么改变呢? 表示看不懂。。。  发表于 2015-3-7 22:33
完美解决!谢谢tseyik  发表于 2015-3-6 18:24

评分

参与人数 1梦石 +1 收起 理由
taroxd + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-4 21:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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