赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 5190 |
最后登录 | 2021-2-21 |
在线时间 | 5 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 65
- 在线时间
- 5 小时
- 注册时间
- 2006-8-21
- 帖子
- 417
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
看了“七夕小雨”的教程http://rpg.blue/web/htm/news756.htm
有了一个血条绿黄红渐变的思路,自己写了一个脚本,希望高手指教一下。
![]()
原理就是做一个条件分歧
满血时红色最低,绿色最高
当超过半血的情况,红色随血的减少而增加,直到和绿色相等为止
当低于半血的情况,绿色随血的减少而减少,直到最低
附上色表一张:
![]()
使用方法:把Window_BattleStatus替换为以下脚本
- #==============================================================================
- # ■ 小翼(alwing)特制 HP MP 显示槽↓↓↓↓
- #==============================================================================
- # HP定义
- def HP(actor,x,y,w=94)
- #底色定义
- self.contents.fill_rect(x+26, y+14, w+4,12, Color.new(0,0,0,255))
- self.contents.fill_rect(x+27, y+15, w+2,10, Color.new(255,255,255,255))
- self.contents.fill_rect(x+28, y+16, w,8, Color.new(0,0,0,255))
- #HP宽度定义
- @HPw = w * actor.hp/actor.maxhp
- #中
- if actor.hp > actor.maxhp/2
- @HPcg = 255
- @HPcr = 150 + 105 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
- else
- @HPcr = 255
- @HPcg = 150 + 105 * actor.hp/(actor.maxhp/2)
- end
- #中偏边
- if actor.hp > actor.maxhp/2
- @HPcg1 = 255
- @HPcr1 = 100 + 155 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
- else
- @HPcr1 = 255
- @HPcg1 = 100 + 155 * actor.hp/(actor.maxhp/2)
- end
- #边偏中
- if actor.hp > actor.maxhp/2
- @HPcg2 = 200
- @HPcr2 = 50 + 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
- else
- @HPcr2 = 200
- @HPcg2 = 50 + 150 * actor.hp/(actor.maxhp/2)
- end
- #边
- if actor.hp > actor.maxhp/2
- @HPcg3 = 150
- @HPcr3 = 150 * (actor.maxhp - actor.hp)/(actor.maxhp/2)
- else
- @HPcr3 = 150
- @HPcg3 = 150 * actor.hp/(actor.maxhp/2)
- end
-
- #HP条定义
- self.contents.fill_rect(x+28, y+16, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
- self.contents.fill_rect(x+28, y+17, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
- self.contents.fill_rect(x+28, y+18, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
- #中
- self.contents.fill_rect(x+28, y+19, @HPw,2, Color.new(@HPcr,@HPcg,150,255))
- #中偏边
- self.contents.fill_rect(x+28, y+21, @HPw,1, Color.new(@HPcr1,@HPcg1,100,255))
- #边偏中
- self.contents.fill_rect(x+28, y+22, @HPw,1, Color.new(@HPcr2,@HPcg2,50,255))
- #边
- self.contents.fill_rect(x+28, y+23, @HPw,1, Color.new(@HPcr3,@HPcg3,0,255))
- end
- # MP定义
- def MP(actor,x,y,w=94)
- self.contents.fill_rect(x+26, y+46, w+4,12, Color.new(0,0,0,255))
- self.contents.fill_rect(x+27, y+47, w+2,10, Color.new(255,255,255,255))
- self.contents.fill_rect(x+28, y+48, w,8, Color.new(0,0,0,255))
- @MPw = w * actor.sp/actor.maxsp
- self.contents.fill_rect(x+28, y+48, @MPw,1, Color.new(0,0,150,255))
- self.contents.fill_rect(x+28, y+49, @MPw,1, Color.new(50,50,200,255))
- self.contents.fill_rect(x+28, y+50, @MPw,1, Color.new(100,100,255,255))
- self.contents.fill_rect(x+28, y+51, @MPw,2, Color.new(150,150,255,255))#中
- self.contents.fill_rect(x+28, y+53, @MPw,1, Color.new(100,100,255,255))
- self.contents.fill_rect(x+28, y+54, @MPw,1, Color.new(50,50,200,255))
- self.contents.fill_rect(x+28, y+55, @MPw,1, Color.new(0,0,150,255))
- end
- #==============================================================================
- # ■ 小翼(alwing)特制 HP MP 显示槽↑↑↑
- #==============================================================================
- #==============================================================================
- # ■ Window_BattleStatus
- #------------------------------------------------------------------------------
- # 显示战斗画面同伴状态的窗口。
- #==============================================================================
- class Window_BattleStatus < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 320, 640, 160)
- self.contents = Bitmap.new(width - 32, height - 32)
- @level_up_flags = [false, false, false, false]
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- super
- end
- #--------------------------------------------------------------------------
- # ● 设置升级标志
- # actor_index : 角色索引
- #--------------------------------------------------------------------------
- def level_up(actor_index)
- @level_up_flags[actor_index] = true
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- @item_max = $game_party.actors.size
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- actor_x = i * 160 + 4
- draw_actor_name(actor, actor_x, 0)
- HP(actor,actor_x,32)
- MP(actor,actor_x,32)
- draw_actor_hp(actor, actor_x, 32, 120)
- draw_actor_sp(actor, actor_x, 64, 120)
- if @level_up_flags[i]
- self.contents.font.color = normal_color
- self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
- else
- draw_actor_state(actor, actor_x, 96)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- # 主界面的不透明度下降
- if $game_temp.battle_main_phase
- self.contents_opacity -= 4 if self.contents_opacity > 191
- else
- self.contents_opacity += 4 if self.contents_opacity < 255
- end
- end
- end
复制代码 |
|