Project1
标题:
显示于敌人脚下的血条Z值
[打印本页]
作者:
白萌奈奈
时间:
2010-11-27 11:31
标题:
显示于敌人脚下的血条Z值
这个脚本血条Z值比战斗图高、、我想弄他比战斗图低比战斗背景高 @enemy_hpsp_window.z = -3这样马上低于战斗图导致看不到。。。 @enemy_hpsp_window.z = -2也是高于战斗图高于战斗背景。。@enemy_hpsp_window.z = self.z -2也是高于战斗图高于战斗背景 。怎么弄让它Z值比战斗图低比战斗背景高
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# ■ エネミーHP&SP(ver 0.98)
# □ カスタマイズポイント
#==============================================================================
module PLAN_HPSP_DRAW
FONT_NAME = ["黑体", "楷体", "宋体"] # フォント
FONT_SIZE = 14 # フォントサイズ
FONT_BOLD = true # 太字
FONT_ITALIC = true # 斜体
DRAW_NAME = false # 名前の描画
DRAW_HP = true # HP の描画
DRAW_SP = true # SP の描画
DRAW_WIDTH = 80 # 描画幅
DRAW_HEIGHT = 3 * 32 # 描画高さ
DRAW_SPACE = 0 # 行間
DRAW_Y = 36 # Y 座標修正値
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_initialize initialize
def initialize(viewport, battler = nil)
# 元のメソッドに戻す
plan_enemy_hpsp_draw_initialize(viewport, battler)
# エネミーの場合
if @battler.is_a?(Game_Enemy)
width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
x = @battler.screen_x - width / 2
y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
@enemy_hpsp_window = Window_Base.new(x, y, width, height)
@enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32)
@enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME
@enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE
@enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD
@enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC
y = 0
@old_enemy_hpsp = []
one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
if PLAN_HPSP_DRAW::DRAW_NAME
@enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
@old_enemy_hpsp.push(@battler.name)
end
if PLAN_HPSP_DRAW::DRAW_HP
@enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
@old_enemy_hpsp.push(@battler.hp)
end
if PLAN_HPSP_DRAW::DRAW_SP
@enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
@old_enemy_hpsp.push(@battler.sp)
end
@enemy_hpsp_window.opacity = 0
@enemy_hpsp_window.contents_opacity = 0
@enemy_hpsp_window.z = -2
end
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_dispose dispose
def dispose
# エネミーの場合
if @battler.is_a?(Game_Enemy)
@enemy_hpsp_window.dispose
end
# 元のメソッドに戻す
plan_enemy_hpsp_draw_dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_update update
def update
# 元のメソッドに戻す
plan_enemy_hpsp_draw_update
# エネミーの場合
if @battler.is_a?(Game_Enemy)
@enemy_hpsp_window.visible = @battler_visible
# スプライトの座標を設定
width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
@enemy_hpsp_window.x = self.x - width / 2
@now_enemy_hpsp = []
if PLAN_HPSP_DRAW::DRAW_NAME
@now_enemy_hpsp.push(@battler.name)
end
if PLAN_HPSP_DRAW::DRAW_HP
@now_enemy_hpsp.push(@battler.hp)
end
if PLAN_HPSP_DRAW::DRAW_SP
@now_enemy_hpsp.push(@battler.sp)
end
if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh
@old_enemy_hpsp = @now_enemy_hpsp
@enemy_hpsp_window.contents.clear
y = 0
width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
if PLAN_HPSP_DRAW::DRAW_NAME
@enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
end
if PLAN_HPSP_DRAW::DRAW_HP
@enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
end
if PLAN_HPSP_DRAW::DRAW_SP
@enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
end
Graphics.frame_reset
end
end
end
#--------------------------------------------------------------------------
# ● visible の設定
#--------------------------------------------------------------------------
if !method_defined?("plan_enemy_hpsp_draw_visible=")
alias plan_enemy_hpsp_draw_visible= visible=
end
def visible=(bool)
# エネミーの場合
if @battler.is_a?(Game_Enemy)
@enemy_hpsp_window.visible = bool
end
# 元のメソッドに戻す
self.plan_enemy_hpsp_draw_visible=(bool)
end
#--------------------------------------------------------------------------
# ● 不透明度の設定
#--------------------------------------------------------------------------
if !method_defined?("plan_enemy_hpsp_draw_opacity=")
alias plan_enemy_hpsp_draw_opacity= opacity=
end
def opacity=(n)
# 元のメソッドに戻す
self.plan_enemy_hpsp_draw_opacity=(n)
# エネミーの場合
if @battler.is_a?(Game_Enemy)
@enemy_hpsp_window.contents_opacity = n
end
end
#--------------------------------------------------------------------------
# ● ダメージ
#--------------------------------------------------------------------------
def damage(value, critical)
super(value, critical)
bitmap = @_damage_sprite.bitmap
@_damage_sprite.dispose
@_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.viewport.z = self.viewport.z + 1
@_damage_sprite.z = 3000
@_damage_duration = 40
end
#--------------------------------------------------------------------------
# ● ダメージ解放
#--------------------------------------------------------------------------
def dispose_damage
if @_damage_sprite != nil
@_damage_sprite.viewport.dispose
end
super
end
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :enemy_hpsp_refresh
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_initialize initialize
def initialize
# 元のメソッドに戻す
plan_enemy_hpsp_draw_initialize
@enemy_hpsp_refresh = false
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● プレバトルフェーズ開始 (エネミー名+アルファベット用)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_start_phase1 start_phase1
def start_phase1
$game_temp.enemy_hpsp_refresh = true
# 元のメソッドに戻す
plan_enemy_hpsp_draw_start_phase1
end
#--------------------------------------------------------------------------
# ● パーティコマンドフェーズ開始 (エネミー名+アルファベット用)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_start_phase2 start_phase2
def start_phase2
$game_temp.enemy_hpsp_refresh = false
# 元のメソッドに戻す
plan_enemy_hpsp_draw_start_phase2
end
#--------------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5
def update_phase4_step5
# 元のメソッドに戻す
plan_enemy_hpsp_draw_update_phase4_step5
$game_temp.enemy_hpsp_refresh = true
end
#--------------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6
def update_phase4_step6
# 元のメソッドに戻す
plan_enemy_hpsp_draw_update_phase4_step6
$game_temp.enemy_hpsp_refresh = false
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 名前の描画
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y, width = 120, align = 0)
self.contents.font.color = normal_color
align = 1 if $scene.is_a?(Scene_Battle)
self.contents.draw_text(x, y, width, 32, actor.name, align)
end
#--------------------------------------------------------------------------
# ● ステートの描画
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 120)
# 元のメソッドに戻す
text = make_battler_state_text(actor, width, true)
self.contents.draw_text(x, y, width, 32, text, 1)
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
class Window_Base < Window
def draw_actor_hp2222(actor, x, y, width = 100, height=8)
y+=3
olx = x
oly = y
w = width * actor.hp / [actor.maxhp,1].max
hp_color_1 = Color.new(255, 0, 0, 192)
hp_color_2 = Color.new(255, 255, 0, 192)
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
x -= 1
y += (height/4).floor
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
x = olx
y = oly-14
# 描绘字符串 "HP"
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
# 计算描绘 MaxHP 所需的空间
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
# 描绘 HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
# 描绘 MaxHP
if flag
self.contents.font.color = normal_color
self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
end
end
def draw_actor_sp2222(actor, x, y, width = 100, height = 8)
y+=3
olx = x
oly = y
w = width * actor.sp / [actor.maxsp,1].max
hp_color_1 = Color.new( 0, 0, 255, 192)
hp_color_2 = Color.new( 0, 255, 255, 192)
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
x -= 1
y += (height/4).floor
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
x -= 1
y += (height/4).ceil
self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
x = olx
y = oly-14
# 描绘字符串 "SP"
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
# 计算描绘 MaxSP 所需的空间
if width - 32 >= 108
sp_x = x + width - 108
flag = true
elsif width - 32 >= 48
sp_x = x + width - 48
flag = false
end
# 描绘 SP
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
# 描绘 MaxSP
if flag
self.contents.font.color = normal_color
self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
end
end
#--------------------------------------------------------------------------
# ● ライン描画 by 桜雅 在土
#--------------------------------------------------------------------------
def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
# 描写距離の計算。大きめに直角時の長さ。
distance = (start_x - end_x).abs + (start_y - end_y).abs
# 描写開始
if end_color == start_color
for i in 1..distance
x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
if width == 1
self.contents.set_pixel(x, y, start_color)
else
self.contents.fill_rect(x, y, width, width, start_color)
end
end
else
for i in 1..distance
x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
r = start_color.red * (distance-i)/distance + end_color.red * i/distance
g = start_color.green * (distance-i)/distance + end_color.green * i/distance
b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
if width == 1
self.contents.set_pixel(x, y, Color.new(r, g, b, a))
else
self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
end
end
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
复制代码
作者:
白萌奈奈
时间:
2010-11-27 12:12
{:nm_3:}好吧我放弃了........
作者:
烁灵
时间:
2010-11-27 13:34
本帖最后由 烁灵 于 2010-11-27 23:36 编辑
回复
白萌奈奈
的帖子
不要急嘛~
话说XP的战斗背景和敌方精灵是同一个viewport的,
具体见Spriteset_Battle
@viewport1 = Viewport.new(0, 0, 640, 320)
……
# 生成战斗背景活动块
@battleback_sprite = Sprite.new(@viewport1)
……
# 生成敌人活动块
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
end
复制代码
作用对象都是viewport1,所以我觉得再建一个viewport5,专门来放背景,而把这个viewport5的z调小一点就好了,当然吾辈这个脚本小白怕出错,把其他有关viewport1的东西都对viewport5执行了一遍。。。
下边是脚本,覆盖了原Spriteset_Battle试试,那个血条的z保持你的-2
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的活动块的类。本类在 Scene_Battle 类
# 的内部使用。
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :viewport1 # 敌人方的显示端口
attr_reader :viewport2 # 角色方的显示端口
#--------------------------------------------------------------------------
# ● 初始化变量
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 320)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480)
##########################################
#背景图显示端口
@viewport5 = Viewport.new(0, 0, 640, 320)
##########################################
@viewport2.z = 101
@viewport3.z = 200
@viewport4.z = 5000
##########################################
@viewport5.z= -10
##########################################
# 生成战斗背景活动块
#@battleback_sprite = Sprite.new(@viewport1)
############################################
@battleback_sprite = Sprite.new(@viewport5)
############################################
# 生成敌人活动块
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
end
# 生成敌人活动块
@actor_sprites = []
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
# 生成天候
@weather = RPG::Weather.new(@viewport1)
# 生成图片活动块
@picture_sprites = []
for i in 51..100
@picture_sprites.push(Sprite_Picture.new(@viewport3,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 如果战斗背景位图存在的情况下就释放
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
# 释放战斗背景活动块
@battleback_sprite.dispose
# 释放敌人活动块、角色活动块
for sprite in @enemy_sprites + @actor_sprites
sprite.dispose
end
# 释放天候
@weather.dispose
# 释放图片活动块
for sprite in @picture_sprites
sprite.dispose
end
# 释放计时器活动块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
@viewport4.dispose
################################################
@viewport5.dispose
################################################
end
#--------------------------------------------------------------------------
# ● 显示效果中判定
#--------------------------------------------------------------------------
def effect?
# 如果是在显示效果中的话就返回 true
for sprite in @enemy_sprites + @actor_sprites
return true if sprite.effect?
end
return false
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新角色的活动块 (对应角色的替换)
@actor_sprites[0].battler = $game_party.actors[0]
@actor_sprites[1].battler = $game_party.actors[1]
@actor_sprites[2].battler = $game_party.actors[2]
@actor_sprites[3].battler = $game_party.actors[3]
# 战斗背景的文件名与现在情况有差异的情况下
if @battleback_name != $game_temp.battleback_name
@battleback_name = $game_temp.battleback_name
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@battleback_sprite.src_rect.set(0, 0, 640, 320)
end
# 刷新战斗者的活动块
for sprite in @enemy_sprites + @actor_sprites
sprite.update
end
# 刷新天气图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.update
# 刷新图片活动块
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器活动块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
#####################################
@viewport5.tone = $game_screen.tone
#####################################
@viewport1.ox = $game_screen.shake
#####################################
@viewport5.ox = $game_screen.shake
#####################################
# 设置画面的闪烁色
@viewport4.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport2.update
@viewport4.update
########################
@viewport5.update
########################
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1