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

Project1

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

[已经过期] 显血的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
106
在线时间
11 小时
注册时间
2022-9-10
帖子
4
跳转到指定楼层
1
发表于 2023-2-25 00:49:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x

请问 这个血条 百位数变成十位数就会往左移动一格 这个怎么让他原地不动 下面是脚本

#--# 简单敌人HP条 v 2.9
#
# 在战斗中显示敌人HP条. 在下面有设定。
# 同时还可以使用图片作为HP条.
#
#使用方法:    即插即用,根据需要改变下面的设定
#
#------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email protected]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#--- Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)

#Customization starts here:
module DTP_HP
  #hp条显示在敌人上面还是下面
  ABOVE_MONSTER = true
  #是否使用自定义图:
  #推安放在 Graphics/System 里: Custom_HP.png
  CUSTOM_BAR = false
  #是否显示HP条
  USE_HP_BAR = true
  #是否显示MP条
  USE_MP_BAR = true

  #hp条的宽度
  BAR_WIDTH = 66
  #hp条的高度
  BAR_HEIGHT = 5
  #hp条边框的宽度
  BORDER_WIDTH = 1
  #hp条边框的高度
  BORDER_HEIGHT = 1
  #hp条在x方向上调整值槽位置(左,右)
  BAR_OFFSET_X = 0
  #hp条在y方向上调整值槽位置(上,下)
  BAR_OFFSET_Y = 0

  #hp条的背景颜色
  COLOR_BAR_BACK = Color.new(0,0,0,200)
  #hp条颜色渐变的第一种颜色
  COLOR_BAR_1 = Color.new(255,0,0)
  #hp条颜色渐变的第二种颜色
  COLOR_BAR_2 = Color.new(200,100,100)
  #外边框颜色
  COLOR_BORDER_1 = Color.new(0,0,0,185)
  #内边框颜色
  COLOR_BORDER_2 = Color.new(255,255,255,185)
  #mp条颜色渐变的第一种颜色
  MP_COLOR_BAR_1 = Color.new(0,175,255)
  #mp条颜色渐变的第二种颜色
  MP_COLOR_BAR_2 = Color.new(0,0,255)

  #是否显示文本
  USE_TEXT = true
  #显示的文本, chp = 当前 hp, mhp = 最大 hp, php = 百分比 hp
  #例子: "php%" 或 "chp/mhp" 或 "chp - php%"
  TEXT_DISPLAY = "chp"
  #文本在x方向上调整值槽位置(左,右)
  TEXT_OFFSET_X = 5
  #文本在y方向上调整值槽位置(上,下)
  TEXT_OFFSET_Y = -24
  #文本字体大小
  TEXT_SIZE = Font.default_size
  #文本字体
  TEXT_FONT = Font.default_name

  #只有在指定角色在队伍中时才显示hp条. 将角色id放在数组里.例子: [8,7]
  #如果不需要此功能,请空着数组,如: []
  SPECIFIC_ACTOR = []
  #只有在附加某状态时才显示hp条 (例如一个查看状态),填入状态的id
  #如果不需要此功能,设定为0
  SCAN_STATE = 0
  #敌人是否在被附加查看状态一次之后,即可在未被附加查看状态时显示hp条
  SCAN_ONCE = false
  #Hp条是否仅在玩家选择目标时显示
  ONLY_ON_TARGET = false

  #boss显示的文本
  BOSS_TEXT = "???"
  #boss hp 条的宽度
  BOSS_BAR_WIDTH = 66
  #boss hp 条的高度
  BOSS_BAR_HEIGHT = 5
  #boss hp 条边框的宽度
  BOSS_BORDER_WIDTH = 1
  #boss hp 条边框的高度
  BOSS_BORDER_HEIGHT = 1
  #将视为boss的敌人的id填写在下面这个括号里,用英文逗号隔开.
  BOSS_MONSTERS = []
end
#设定结束

class Sprite_Battler
  alias hpbar_update update
  alias hpbar_dispose dispose
  def update
    hpbar_update
    return unless @battler.is_a?(Game_Enemy)
    if @battler
      update_hp_bar
    end
  end
  def update_hp_bar
    boss = DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id)
    setup_bar if @hp_bar.nil?
    if @text_display.nil?
      @text_display = Sprite_Base.new(self.viewport)
      @text_display.bitmap = Bitmap.new(100,DTP_HP::TEXT_SIZE)
      @text_display.bitmap.font.size = DTP_HP::TEXT_SIZE
      @text_display.bitmap.font.name = DTP_HP::TEXT_FONT
      @text_display.x = @hp_bar.x + DTP_HP::TEXT_OFFSET_X
      @text_display.y = @hp_bar.y + DTP_HP::TEXT_OFFSET_Y
      @text_display.z = 105
    end
    determine_visible
    return unless @hp_bar.visible
    if @hp_bar.opacity != self.opacity
      @hp_bar.opacity = self.opacity
      @mp_bar.opacity = @hp_bar.opacity if DTP_HP::USE_MP_BAR
    end
    @hp_bar.bitmap.clear
    if !boss
      width = DTP_HP::BAR_WIDTH
      height = DTP_HP::BAR_HEIGHT
      bwidth = DTP_HP::BORDER_WIDTH
      bheight = DTP_HP::BORDER_HEIGHT
    else
      width = DTP_HP::BOSS_BAR_WIDTH
      height = DTP_HP::BOSS_BAR_HEIGHT
      bwidth = DTP_HP::BOSS_BORDER_WIDTH
      bheight = DTP_HP::BOSS_BORDER_HEIGHT
    end
    btotal = (bwidth + bheight) * 2
    rwidth = @hp_bar.bitmap.width
    rheight = @hp_bar.bitmap.height
    if !DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR
      @hp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK)
      @hp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2)
      @hp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1)
    end
    hp_width = @battler.hp_rate * width
    if DTP_HP::USE_HP_BAR
      @hp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,hp_width,height,DTP_HP::COLOR_BAR_1,DTP_HP::COLOR_BAR_2)
    end
    if DTP_HP::CUSTOM_BAR && DTP_HP::USE_HP_BAR
      border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png")
      rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height)
      @hp_bar.bitmap.blt(0,0,border_bitmap,rect)
    end
    if DTP_HP::USE_MP_BAR
      @mp_bar.bitmap.clear
      if !DTP_HP::CUSTOM_BAR
        @mp_bar.bitmap.fill_rect(0,0,rwidth,rheight,DTP_HP::COLOR_BAR_BACK)
        @mp_bar.bitmap.fill_rect(bwidth,bheight,rwidth-bwidth*2,rheight-bheight*2,DTP_HP::COLOR_BORDER_2)
        @mp_bar.bitmap.fill_rect(bwidth*2,bheight*2,width,height,DTP_HP::COLOR_BORDER_1)
      end
      mp_width = @battler.mp_rate * width
      @mp_bar.bitmap.gradient_fill_rect(bwidth*2,bheight*2,mp_width,height,DTP_HP::MP_COLOR_BAR_1,DTP_HP::MP_COLOR_BAR_2)
      if DTP_HP::CUSTOM_BAR
        border_bitmap = Bitmap.new("Graphics/System/Custom_HP.png")
        rect = Rect.new(0,0,border_bitmap.width,border_bitmap.height)
        @mp_bar.bitmap.blt(0,0,border_bitmap,rect)
      end
    end
    return unless DTP_HP::USE_TEXT
    @text_display.opacity = @hp_bar.opacity if @text_display.opacity != @hp_bar.opacity
    @text_display.bitmap.clear
    text = DTP_HP::TEXT_DISPLAY.clone
    text = DTP_HP::BOSS_TEXT.clone if DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id)
    text.gsub!(/chp/) {@battler.hp}
    text.gsub!(/mhp/) {@battler.mhp}
    text.gsub!(/php/) {(@battler.hp_rate * 100).to_i}
    @text_display.bitmap.draw_text(0,0,100,@text_display.height,text)
  end
  def setup_bar
    boss = DTP_HP::BOSS_MONSTERS.include?(@battler.enemy_id)
    @hp_bar = Sprite_Base.new(self.viewport)
    if !boss
      width = DTP_HP::BAR_WIDTH + DTP_HP::BORDER_WIDTH * 4
      height = DTP_HP::BAR_HEIGHT + DTP_HP::BORDER_HEIGHT * 4
    else
      width = DTP_HP::BOSS_BAR_WIDTH + DTP_HP::BOSS_BORDER_WIDTH * 4
      height = DTP_HP::BOSS_BAR_HEIGHT + DTP_HP::BOSS_BORDER_HEIGHT * 4
    end
    if DTP_HP::CUSTOM_BAR
      tempbmp = Bitmap.new("Graphics/System/Custom_HP.png")
      width = tempbmp.width
      height = tempbmp.height
    end
    @hp_bar.bitmap = Bitmap.new(width,height)
    @hp_bar.x = self.x - @hp_bar.width / 2 + DTP_HP::BAR_OFFSET_X
    @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y - self.bitmap.height - @hp_bar.height
    @hp_bar.y = self.y + DTP_HP::BAR_OFFSET_Y unless DTP_HP::ABOVE_MONSTER
    @hp_bar.x = 0 if @hp_bar.x < 0
    @hp_bar.y = 0 if @hp_bar.y < 0
    @hp_bar.z = 104
    if DTP_HP::USE_MP_BAR
      @mp_bar = Sprite_Base.new(self.viewport)
      @mp_bar.bitmap = Bitmap.new(@hp_bar.width,@hp_bar.height)
      @mp_bar.x = @hp_bar.x + 6
      @mp_bar.y = @hp_bar.y + @mp_bar.height - 3
      @mp_bar.z = 103
    end
  end
  def determine_visible
    if [email protected]?
      @hp_bar.visible = false
      @mp_bar.visible = false if @mp_bar
      @text_display.visible = false
      if DTP_HP::SCAN_ONCE and DTP_HP::SCAN_STATE == 1
        $game_party.monster_scans[@battler.enemy_id] = true
      end
      return if [email protected]?
    end
    @hp_bar.visible = true
    if DTP_HP::SCAN_STATE != 0
      @hp_bar.visible = false
      @hp_bar.visible = true if @battler.state?(DTP_HP::SCAN_STATE)
      if DTP_HP::SCAN_ONCE
        @hp_bar.visible = true if $game_party.monster_scans[@battler.enemy_id] == true
        $game_party.monster_scans[@battler.enemy_id] = true if @hp_bar.visible
      end
    end
    if !DTP_HP::SPECIFIC_ACTOR.empty?
      @hp_bar.visible = false unless DTP_HP::SCAN_STATE != 0
      DTP_HP::SPECIFIC_ACTOR.each do |i|
        next unless $game_party.battle_members.include?($game_actors)
        @hp_bar.visible = true
      end
    end
    if DTP_HP::ONLY_ON_TARGET
      return unless SceneManager.scene.is_a?(Scene_Battle)
      return unless SceneManager.scene.enemy_window
      @hp_bar.visible = SceneManager.scene.target_window_index == @battler.index
      @hp_bar.visible = false if !SceneManager.scene.enemy_window.active
    end
    @text_display.visible = false if !@hp_bar.visible
    @text_display.visible = true if @hp_bar.visible
    @mp_bar.visible = @hp_bar.visible if DTP_HP::USE_MP_BAR
  end
  def dispose
    @hp_bar.dispose if @hp_bar
    @mp_bar.dispose if @mp_bar
    @text_display.dispose if @text_display
    hpbar_dispose
  end
end

class Scene_Battle
  attr_reader  :enemy_window
  def target_window_index
    begin
    @enemy_window.enemy.index
    rescue
      return -1
    end
  end
end

class Game_Party
  alias hp_bar_init initialize
  attr_accessor  :monster_scans
  def initialize
    hp_bar_init
    @monster_scans = []
  end
end

无标题2.png (92.47 KB, 下载次数: 14)

无标题2.png

Lv1.梦旅人

梦石
0
星屑
106
在线时间
11 小时
注册时间
2022-9-10
帖子
4
2
 楼主| 发表于 2023-2-25 00:58:07 | 只看该作者
就是 这个数字会因为百位数变十位数后自动靠左一格 这样就和右边对不齐了 我想让这个数字在右边不动 和右边对齐 但是看不懂脚本
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 19:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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