赞 | 4 |
VIP | 28 |
好人卡 | 22 |
积分 | 12 |
经验 | 73335 |
最后登录 | 2024-8-7 |
在线时间 | 1795 小时 |
Lv3.寻梦者 死亡颂唱者
- 梦石
- 0
- 星屑
- 1159
- 在线时间
- 1795 小时
- 注册时间
- 2011-10-21
- 帖子
- 2245
|
本帖最后由 acn00269 于 2012-6-7 19:21 编辑
为帮到LZ 我不惜把游戏都破解了
下面就发上显 示敌人HP,MP的脚本- #先声明一下,这属于一时胡写的,可能没有沉影的好,大家勿喷
- class Spriteset_Battle
- #Sideview 2 的1331行有定义
- =begin
- #--------------------------------------------------------------------------
- # ● 生成敌人活动块
- #--------------------------------------------------------------------------
- def create_enemies
- @enemy_sprites = []
- @enemy_hpbar_sprites = []
- for enemy in $game_troop.members.reverse
- @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
- @enemy_hpbar_sprites.push(Sprite_Hpbar.new(@viewport1, enemy))
- end
- end
- =end
- #--------------------------------------------------------------------------
- # ● 刷新敌人活动块
- #--------------------------------------------------------------------------
- def update_enemies
- for sprite in @enemy_sprites + @enemy_hpbar_sprites
- sprite.update
- end
- end
- #--------------------------------------------------------------------------
- # ● 释放敌人活动块
- #--------------------------------------------------------------------------
- def dispose_enemies
- for sprite in @enemy_sprites + @enemy_hpbar_sprites
- sprite.dispose
- end
- end
- end
- #==============================================================================
- # ■ Sprite_Sprite_Hpbar
- #------------------------------------------------------------------------------
- # 血条显示
- #==============================================================================
- class Sprite_Hpbar < Sprite_Base
- #--------------------------------------------------------------------------
- # ● 定量
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :battler
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # viewport : 视口
- # battler : 战斗者 (Game_Battler)
- #--------------------------------------------------------------------------
- def initialize(viewport, battler = nil)
- super(viewport)
- @battler = battler
- @name = @battler.name
- @hp = @battler.hp
- @mp = @battler.mp
- self.bitmap = Bitmap.new(100,50)
- self.bitmap.font.size = 12
- self.bitmap.font.color = @battler.hp <= @battler.maxhp / 4 ? text_color(17) : text_color(24)
- self.bitmap.draw_text(0,22,100,20,@battler.hp ,2)
- self.bitmap.font.color = text_color(23)
- self.bitmap.draw_text(0,31,100,20,@battler.mp ,2)
- draw_enemy_hp_gauge(@battler, 0, 15, 50)
- draw_enemy_mp_gauge(@battler, 0, 23, 50)
- self.x = @battler.screen_x - 45
- self.y = @battler.screen_y - self.bitmap.height / 2 - 5
- self.z = @battler.screen_z + 5000
- end
- #--------------------------------------------------------------------------
- # 获取文字色
- # n : 文字色编号 (0~31)
- #--------------------------------------------------------------------------
- def text_color(n)
- windowskin = Cache.system("Window")
- x = 64 + (n % 8) * 8
- y = 96 + (n / 8) * 8
- return windowskin.get_pixel(x, y)
- end
- #--------------------------------------------------------------------------
- # HP矩形的描画
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # width : 宽
- #--------------------------------------------------------------------------
- def draw_enemy_hp_gauge(enemy, x, y, width = 432)
- gw = width * @hp / enemy.maxhp
- gc1 = text_color(28)
- gc2 = text_color(24)
- self.bitmap.fill_rect(x+15, y + 24 - 8, width, 6, text_color(19))
- self.bitmap.gradient_fill_rect(x+15, y + 24 - 8, gw, 6, gc1, gc2)
- end
- #--------------------------------------------------------------------------
- # MP矩形的描画
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # width : 宽
- #--------------------------------------------------------------------------
- def draw_enemy_mp_gauge(enemy, x, y, width = 432)
- if enemy.maxmp > 0
- gw = width * @mp / enemy.maxmp
- else
- gw = 0
- end
- gc1 = text_color(1)
- gc2 = text_color(23)
- self.bitmap.fill_rect(x+15, y + 24 - 8, width, 6, text_color(19))
- self.bitmap.gradient_fill_rect(x+15, y + 24 - 8, gw, 6, gc1, gc2)
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @battler == nil
- self.bitmap = nil
- else
- update_battler_bitmap
- end
- end
- #--------------------------------------------------------------------------
- # 刷新位图数据
- #--------------------------------------------------------------------------
- def update_battler_bitmap
- if @battler.dead? or @battler.hidden
- self.opacity = 0
- end
- if [email protected]? and [email protected] and self.opacity == 0
- self.opacity = 255
- end
- if @hp != @battler.hp or @mp != @battler.mp or @name != @battler.name
- @name = @battler.name
- @hp = @battler.hp
- @mp = @battler.mp
- self.bitmap.clear
- self.bitmap.font.color = @battler.hp <= @battler.maxhp / 4 ? text_color(17) : text_color(24)
- self.bitmap.draw_text(0,24,100,20,@battler.hp ,2)
- self.bitmap.font.color = text_color(23)
- self.bitmap.draw_text(0,34,100,20,@battler.mp ,2)
- draw_enemy_hp_gauge(@battler, 0, 15, 50)
- draw_enemy_mp_gauge(@battler, 0, 25, 50)
- end
- end
- end
复制代码 为尊重作者 我就只发这一个脚本 |
评分
-
查看全部评分
|