Enemy HP/SP and Name

This is a really useful Script I found on 66RPG.com and edited slightly


What it Does

This script shows the enemies' name, HP and SP in battle.


Advice for Usage

I Advise you use some form of HP/SP bar with this script to make the HP and SP stand out.
Something like the CogWheel Plug 'n' Play Menu Bars.
If you do use bars that alias themselves to the HP and SP you have to put the code below this one.


Screenies

http://i25.photobucket.com/albums/c66/R ... ostbar.jpg[/IMG]


The Script

The Script Spoiler
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# ■ エネミーHP&SP(ver 0.98)

# □ カスタマイズポイント
#==============================================================================
module PLAN_HPSP_DRAW
FONT_NAME         = ["Arial"]    # フォント
FONT_SIZE         =  18                            # フォントサイズ
FONT_BOLD         = true                              # 太字
FONT_ITALIC       = true                              # 斜体

DRAW_NAME         = true                              # 名前の描画
DRAW_HP           = true                              # HP の描画
DRAW_SP           = true                              # SP の描画

DRAW_WIDTH        =  80                               # 描画幅
DRAW_HEIGHT       = 3 * 32                            # 描画高さ
DRAW_SPACE        =   0                               # 行間
DRAW_Y            =  24                               # 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_hp(@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_sp(@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_hp(@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_sp(@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 = 220, align = 0)
   if $scene.is_a?(Scene_Battle)
     flag = actor.name.sub!(/\*f/, '').nil? ? false : true
     self.contents.font.color = Color.new(0, 0, 0, 192)
   self.contents.draw_text(x+1, y, width, 32, actor.name, align)
   self.contents.draw_text(x, y+1, width, 32, actor.name, align)
end
   self.contents.font.color = normal_color
   self.contents.draw_text(x, y, width, 32, actor.name, align)
end

alias draw_actor_hp_original draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    # Draw Shadow Effects for Battles
    if $scene.is_a?(Scene_Battle)
      self.contents.font.color = Color.new(0, 0, 0, 192)
      self.contents.draw_text(x, y+1, 32, 32, $data_system.words.hp)
      self.contents.draw_text(x+1, y, 32, 32, $data_system.words.hp)
      self.contents.draw_text(hp_x, y+1, 48, 32, actor.hp.to_s, 2)
      self.contents.draw_text(hp_x+1, y, 48, 32, actor.hp.to_s, 2)
    if flag
      self.contents.draw_text(hp_x + 49, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 48, y+1, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y+1, 48, 32, actor.maxhp.to_s)
      self.contents.draw_text(hp_x + 61, y, 48, 32, actor.maxhp.to_s)
    end
    end
    # Draw "HP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # Draw 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)
    # Draw 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
 
  alias draw_actor_sp_original draw_actor_sp
  def draw_actor_sp(actor, x, y, width = 144)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # Draw Shadow Effects for Battles
    if $scene.is_a?(Scene_Battle)
      self.contents.font.color = Color.new(0, 0, 0, 192)
      self.contents.draw_text(x, y+1, 32, 32, $data_system.words.sp)
      self.contents.draw_text(x+1, y, 32, 32, $data_system.words.sp)
      self.contents.draw_text(sp_x, y+1, 48, 32, actor.sp.to_s, 2)
      self.contents.draw_text(sp_x+1, y, 48, 32, actor.sp.to_s, 2)
    if flag
      self.contents.draw_text(hp_x + 49, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 48, y+1, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y+1, 48, 32, actor.maxsp.to_s)
      self.contents.draw_text(hp_x + 61, y, 48, 32, actor.maxsp.to_s)
    end
    end
    # Draw "SP" text string
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # Draw 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)
    # Draw 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

#--------------------------------------------------------------------------
# ● ステートの描画
#--------------------------------------------------------------------------
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
Expand to see the code.



Credit

Credit to which ever bit of Japanese is a name in the comments, otherwise just to 66RPG.com
And mini credit to me if you're kind :D




Enjoy :D
Ooh, cool. Better than any enemy HP script out there. (No hard feelings, anyone.) *uses*
syvkal, I recommend you put a black shadow or outline round the enemies hp/sp. Then if someone has a monster like a ghost you can see it clearly. :P
Yeah I have, just like a said it's an oldish screenie.

And sorry if I sounded a bit rude when I posted that on your thread -_- ...



I'll get a new screenie and put it up.
You didn't sound rude, don't worry. No, I meant the actual script, I tried it out and even if you have the bars, if you have an enemy like a ghost, the hp/sp isn't well shown. I like how the enemy's name is shown, maybe you should do the same thing with the hp and sp.
Oh sorry I get you :D
K I'll do that too :D


:EDIT:


*Update*

The HP and SP have now been lined with a shadow.
If you are using a gradient bar script read the updated 'Advice for Usage'

If someone does see the strange aliasing that I've done and knows how to make it shorter without causing the script to hang please tell me :D
Is there any way this script could be toggled on and off so that it could be used as a sort of "scan" type skill? That would rock.
[QUOTE=ryanwh]Is there any way this script could be toggled on and off so that it could be used as a sort of "scan" type skill? That would rock.[/QUOTE]

I was just about to ask that exact question.
I guess so. I'll have a looky, I'm sure I can do it, but I really busy at the moment (hence why I haven't been on for a while)...
what would i put this script in

thankyou...
Hey great script...everything works good, until i try to heal I get this error:

?????' ' ? 327 ??? NameError ???????

undefined local variable or method `hp_x' for #

Anyway to fix this...?
I'm on the wrong PC at the moment so I'll fix it when I get on the other one.
Hey nevermind I found the error, It was in these lines:

if flag
self.contents.draw_text(hp_x + 49, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 48, y+1, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y+1, 48, 32, actor.maxsp.to_s)
self.contents.draw_text(hp_x + 61, y, 48, 32, actor.maxsp.to_s)
^^
The "hp" is supposed to be sp, looks halfway done. So just change all of the "hp"s with "sp" and it fixes it. Might wanna update your script :P

One question: How do you add an outline or a shadow around the enemy's HP text...?
Umm I think I updated that in the script already
And thanks for that for some reason I missed that... but it works fine on mine...
So this just goes in it's own script, right?
It doesn't alter the other scripts?

Sorry, I'm a complete newb to scripting... I don't have a clue.

And afterwards, where does the plug-and-play script go?
Everytime I put this script in, nothing happens. How come this works for everyone else?
Did you go into battle? Thats where the enemy HP, SP shows up.
excuse me, syvkal? i am having problems with your script, it wont let me heal T_T when i use a potion or a cure spell in battle i getz an error and it goes kaboom, but if i do it outside battle im fine.
if flag
self.contents.draw_text(hp_x + 49, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 48, y+1, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y+1, 48, 32, actor.maxsp.to_s)
self.contents.draw_text(hp_x + 61, y, 48, 32, actor.maxsp.to_s)
^^
The "hp" is supposed to be sp, looks halfway done. So just change all of the "hp"s with "sp" and it fixes it.

(line 327 btw)

I had the same problem earlier...
sweet thanks that did it ^_^ w00t for this script i needed this T_T
excuse me...your script works fine except that its not alined correctly

screenshot
http://i10.tinypic.com/2eztqvl.jpg[/img]

how do i fix that?...im using clive's HP/MP/ATB/Overdrive bar Slanted Style
The monsters picture is too big, maybe theres extra space at the bottom of the picture you can remove it shouldnt be that far down.

But yes, this happens with all the largest enemies even in RTP resources of RMXP, you just have to move the enemy up, and try to cut the bottom as much as possible.

Or, find the coordinates it draws the stats in the script, and move it around.
how about toggling it on and off so if its a boss monster you should toggle it off or make it a ????HP so it would be exciting to defeat how much the monster's hp left
[QUOTE=Italianstal1ion;131077]The monsters picture is too big, maybe theres extra space at the bottom of the picture you can remove it shouldnt be that far down.
[/QUOTE]
its the same with small monsters =/

[QUOTE=Ravenix;131253]how about toggling it on and off so if its a boss monster you should toggle it off or make it a ????HP so it would be exciting to defeat how much the monster's hp left[/QUOTE]
uhhh...isnt it usually the opposite?

ahhh...i found wats wrong...its not compatible with this script im using(its made by XRXS, not me)
My script Spoiler
# ▼▲▼ XRXS_BP 8. バトルバック・Full-View+可動カメラ ver.2 ▼▲▼
# by 桜雅 在土

#==============================================================================
# □ カスタマイズポイント
#==============================================================================
module XRXS_BP8
  #
  # カメラ移動スピード基準値 (基本的に小さいほうが速い)
  #
  SPEED = 8
  #
  # グラフィックスアレイ式サイズ設定
  #
  GA = Rect.new(-192, -144, 1024, 768)  # XGA サイズ
  #GA = Rect.new(   0, -  0,  640, 480) # VGA サイズ
end
#------------------------------------------------------------------------------
#
#
#
#    â–½ 可動カメラ システム â–½
#
#
#
#==============================================================================
# â–¡ XCam
#------------------------------------------------------------------------------
#   å¯å‹•カメラを扱うクラスです。
#==============================================================================
class XCam
  #--------------------------------------------------------------------------
  # â—‹ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :x
  attr_reader   :y
  attr_reader   :z
  attr_accessor :x_destination
  attr_accessor :y_destination
  attr_accessor :z_destination
  attr_accessor :watch_battler
  attr_accessor :wait_count
  #--------------------------------------------------------------------------
  # â—‹ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    # カメラ初期位置決定
    @x = 320
    @y = 240
    @z = 295
    # カメラ:センタリング
    self.centering
    # 初期化
    @wait_count = 0
  end
  #--------------------------------------------------------------------------
  # â—‹ フレーム更新
  #--------------------------------------------------------------------------
  def update
    @moved = false
    # カメラ位置の更新
    if @wait_count > 0
      # ウェイトカウントを減らす
      @wait_count -= 1
    else
      # スピードの取得
      speed = XRXS_BP8::SPEED
      #
      # カメラ: Z 座標 (優先)
      #
      z_dest = @z_destination
      if @z != z_dest
        if @z < z_dest
          distance = [(z_dest - @z)/speed, 1].max
        else
          distance = [(z_dest - @z)/speed, -1].min
        end
        @z = [[@z + distance, 74].max, 296].min
        @moved = true
      end
      #
      # カメラ: X 座標
      #
      x_dest = @watch_battler == nil ? @x_destination : @watch_battler.x
      if @x != x_dest
        if (@x - x_dest).abs < speed
          distance = x_dest - @x
        elsif @x < x_dest
          distance = [(x_dest - @x)/speed, 8].max
        else
          distance = [(x_dest - @x)/speed, -8].min
        end
        maximum = 192 * (296 - @z) / 111 + 320
        minimum = 640 - maximum
        @x = [[@x + distance, minimum].max, maximum].min
        @moved = true
      end
      #
      # カメラ: Y 座標
      #
      y_dest = @watch_battler == nil ? @y_destination : 88 + @watch_battler.y/2
      if @y != y_dest
        if (@y - y_dest).abs < speed
          distance = y_dest - @y
        elsif @y < y_dest
          distance = [(y_dest - @y)/speed, 4].max
        else
          distance = [(y_dest - @y)/speed, -4].min
        end
        maximum = 164 * (296 - @z) / 111 + 240
        minimum = 480 - maximum
        @y = [[@y + distance, minimum].max, maximum].min
        @moved = true
      end
    end
  end
  #--------------------------------------------------------------------------
  # â—‹ 動いたかどうか?
  #--------------------------------------------------------------------------
  def moved?
    return @moved
  end
  #--------------------------------------------------------------------------
  # â—‹ センタリング
  #--------------------------------------------------------------------------
  def centering
    @watch_battler = nil
    @x_destination = 320
    @y_destination = 240
    @z_destination = 185
  end
  #--------------------------------------------------------------------------
  # â—‹ 注目
  #--------------------------------------------------------------------------
  def watch(battler)
    @watch_battler = battler
    @z_destination = 176
  end
  #--------------------------------------------------------------------------
  # â—‹ ズームアウト
  #--------------------------------------------------------------------------
  def zoomout
    @z_destination = 222
  end
  #--------------------------------------------------------------------------
  # â—‹ 指定 X 位置を注目
  #--------------------------------------------------------------------------
  def watch_at(x)
    @watch_battler = nil
    @x_destination =   x
    @y_destination = 240
    @z_destination = 185
  end
end
#==============================================================================
# â–  Game_Battler
#==============================================================================
class Game_Battler
  #--------------------------------------------------------------------------
  # â—‹ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :x                        # バトルフィールド 横 位置(+が右 )
  attr_reader   :y                        # バトルフィールド 高さ 位置(+が下 )
  attr_reader   :z                        # バトルフィールド奥行き位置(+が手前)
  attr_accessor :zoom                     # 現在のズーム倍率
  #--------------------------------------------------------------------------
  # â—‹ バトルフィールド上に居るか?
  #--------------------------------------------------------------------------
  def in_battlefield?
    return false
  end
end
#==============================================================================
# â–  Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # â—‹ バトルフィールド上に居るか? [オーバーライド]
  #--------------------------------------------------------------------------
  def in_battlefield?
    return true
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias xrxs_bp8_initialize initialize
  def initialize(troop_id, member_index)
    @x    = $data_troops[troop_id].members[member_index].x
    @y    = $data_troops[troop_id].members[member_index].y
    @z    = 0
    @zoom = 1.00
    # 呼び戻す
    xrxs_bp8_initialize(troop_id, member_index)
  end
  #--------------------------------------------------------------------------
  # ● バトル画面 X 座標の取得
  #--------------------------------------------------------------------------
  alias xrxs_bp8_screen_x screen_x
  def screen_x
    return xrxs_bp8_screen_x if $xcam == nil
    return 320 + (xrxs_bp8_screen_x - $xcam.x) * self.zoom
  end
  #--------------------------------------------------------------------------
  # ● バトル画面 Y 座標の取得
  #--------------------------------------------------------------------------
  alias xrxs_bp8_screen_y screen_y
  def screen_y
    return xrxs_bp8_screen_y if $xcam == nil
    return 240 + (xrxs_bp8_screen_y - $xcam.y) * self.zoom
  end
end
#==============================================================================
# â–  Spriteset_Battle
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # â—‹ フレーム更新 (可動カメラ)
  #--------------------------------------------------------------------------
  def update_xcam
    # カメラ位置が動いた場合
    if $xcam.moved?
      # カメラ位置からズーム率を計算
      zoom = 1.00 * 185 / $xcam.z
      # 背景の設定更新
      @battleback_sprite.zoom_x = zoom
      @battleback_sprite.zoom_y = zoom
      @battleback_sprite.x      = -($xcam.x - 320) * zoom - 512 * (zoom - 1)
      @battleback_sprite.y      = -($xcam.y - 240) * zoom - 384 * (zoom - 1)
    end
  end
end
#==============================================================================
# --- バトラースプライト可動カメラズーム対応 モジュール ---
#==============================================================================
module XRXS_Cam_Deal
  def update
    # 呼び戻す
    super
    # バトラーが nil の場合は終了
    return if @battler == nil
    # バトルフィールドにいない場合も終了
    return unless @battler.in_battlefield?
    # カメラが存在しない場合も終了
    return if $xcam == nil
    # 例外補正
    @battler.z = 0 if @battler.z == nil
    # ズーム率
    zoom = 1.00 * (185 - @battler.z) / ($xcam.z - @battler.z)
    self.zoom_x   = zoom
    self.zoom_y   = zoom
    @battler.zoom = zoom
    # ズーム率の変更に伴いスプライトの座標を再設定
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
  end
end
class Sprite_Battler < RPG::Sprite
  include XRXS_Cam_Deal
end
#==============================================================================
# --- ダメージフォロー モジュール ---
#==============================================================================
module XRXS_DamageFollow
  def update
    # 呼び戻す
    super
    # カメラが存在しない場合
    return if $xcam == nil
    # バトラーが nil またはバトルフィールドにいない場合
    return if @battler == nil or not @battler.in_battlefield?
    # 直前カメラ位置から、移動量を算出
    x_moved = @last_cam_x == nil ? 0 : $xcam.x - @last_cam_x
    y_moved = @last_cam_y == nil ? 0 : $xcam.y - @last_cam_y
    # ダメージスプライト配列の作成
    damage_sprites  = [@_damage_sprite]
    damage_sprites += @damage_sprites if @damage_sprites != nil
    # カメラをフォロー
    for sprite in damage_sprites
      next if sprite == nil
      next if sprite.disposed?
      sprite.x -= x_moved
      sprite.y -= y_moved
    end
    # 直前カメラ位置の保持
    @last_cam_x = $xcam.x
    @last_cam_y = $xcam.y
  end
end
class Sprite_Battler < RPG::Sprite
  include XRXS_DamageFollow
end
#==============================================================================
# â–  Scene_Battle
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  alias xrxs_bp8_main main
  def main
    # 可動カメラの生成
    $xcam = XCam.new
    # 戻す
    xrxs_bp8_main
    # 可動カメラの解放
    $xcam = nil
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias xrxs_bp8_update update
  def update
    # 可動カメラのフレーム更新
    $xcam.update
    # 呼び戻す
    xrxs_bp8_update
  end
end
#------------------------------------------------------------------------------
# ▽ 可動カメラの動き設定
#==============================================================================
# â–  Scene_Battle
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # ● パーティコマンドフェーズ開始
  #--------------------------------------------------------------------------
  alias xrxs_bp8_start_phase2 start_phase2
  def start_phase2
    # カメラ:センタリング
    $xcam.centering
    # 呼び戻す
    xrxs_bp8_start_phase2
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択)
  #--------------------------------------------------------------------------
  alias xrxs_bp8_update_phase3_enemy_select update_phase3_enemy_select
  def update_phase3_enemy_select
    # 現在選択中のエネミーを取得
    enemy = $game_troop.enemies[@enemy_arrow.index]
    # カメラ:注目
    $xcam.watch_at(enemy.x)
    # 戻す
    xrxs_bp8_update_phase3_enemy_select
  end
  #--------------------------------------------------------------------------
  # ● エネミー選択終了
  #--------------------------------------------------------------------------
  alias xrxs_bp8_end_enemy_select end_enemy_select
  def end_enemy_select
    # カメラ:センタリング
    $xcam.centering
    # 呼び戻す
    xrxs_bp8_end_enemy_select
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  #--------------------------------------------------------------------------
  alias xrxs_bp8_update_phase4_step2 update_phase4_step2
  def update_phase4_step2
    # 戻す
    xrxs_bp8_update_phase4_step2
    # ステップ 3 に移行する予定の場合
    if @phase4_step == 3
      # アクティブなバトラーがバトルフィールドに居る場合
      if @active_battler.in_battlefield?
        # カメラ:注目
        $xcam.watch(@active_battler)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション)
  #--------------------------------------------------------------------------
  alias xrxs_bp8_update_phase4_step3 update_phase4_step3
  def update_phase4_step3
    # 戻す
    xrxs_bp8_update_phase4_step3
    # カメラターゲットとなりうるターゲットの X 平均値を計算
    x_average  = 0
    number     = 0
    cam_target = nil
    for target in @target_battlers
      if target.in_battlefield?
        x_average += target.x
        number    += 1
        cam_target = target
      end
    end
    # カメラターゲットが見つかった場合
    if number > 0
      # もし対象アニメが「位置:画面」の場合
      animation = $data_animations[@animation2_id]
      if animation != nil and animation.position == 3
        # カメラ:センタリング
        $xcam.centering
        # カメラ:ズームアウト
        $xcam.zoomout
      elsif number == 1
        # カメラ:注目
        $xcam.watch(cam_target)
      else
        # カメラ:指定 X 位置を注目
        $xcam.watch_at(x_average / number)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● アフターバトルフェーズ開始
  #--------------------------------------------------------------------------
  alias xrxs_bp8_start_phase5 start_phase5
  def start_phase5
    # カメラ:センタリング
    $xcam.centering
    # 呼び戻す
    xrxs_bp8_start_phase5
  end
end






#------------------------------------------------------------------------------
#
#
#
#    â–½ Full-View システム â–½
#
#
#
#==============================================================================
# â–  Spriteset_Battle
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias xrxs_bp8_initialize initialize
  def initialize
    # 呼び戻す
    xrxs_bp8_initialize
    # グラフィックスアレイを取得
    ga = XRXS_BP8::GA
    # ビューポート 0 を作成
    @viewport0 = Viewport.new(ga.x, ga.y, ga.width, ga.height)
    @viewport0.z  = 0
    # ビューポート 1 の設定を変更
    @viewport1.z += 1
    @viewport1.rect.height = 480
    # バトルバックスプライトを再作成 (ビューポート 0 を使用)
    @battleback_sprite.dispose
    @battleback_sprite = Sprite.new(@viewport0)
    @battleback_name = ""
    # バトルバックのフレーム更新
    update_battleback
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias xrxs_bp8_dispose dispose
  def dispose
    # 呼び戻す
    xrxs_bp8_dispose
    # ビューポートを解放
    @viewport0.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias xrxs_bp8_update update
  def update
    # フレーム更新 (バトルバック)
    update_battleback
    # フレーム更新 (可動カメラ)
    update_xcam if defined? update_xcam
    # 呼び戻す
    xrxs_bp8_update
  end
  #--------------------------------------------------------------------------
  # â—‹ フレーム更新 (バトルバック)
  #--------------------------------------------------------------------------
  def update_battleback
    # バトルバックのファイル名が現在のものと違う場合
    if @battleback_name != $game_temp.battleback_name
      @battleback_name = $game_temp.battleback_name
      if @battleback_sprite.bitmap != nil
        @battleback_sprite.bitmap.dispose
      end
      # グラフィックスアレイを取得
      ga = XRXS_BP8::GA
      # バトルバックの取得と拡大
      bg   = RPG::Cache.battleback(@battleback_name)
      xga  = Bitmap.new(ga.width, ga.height)
      xga.stretch_blt(xga.rect, bg, bg.rect)
      # XGAをバトルバックに設定
      @battleback_sprite.bitmap = xga
    end
  end
end
#==============================================================================
# ◇ RPG::Sprite「戦闘中の"画面"アニメの位置修正」 [再定義]
#==============================================================================
module RPG
  class Sprite < ::Sprite
    def animation_set_sprites(sprites, cell_data, position)
      for i in 0..15
        sprite = sprites[i]
        pattern = cell_data[i, 0]
        if sprite == nil or pattern == nil or pattern == -1
          sprite.visible = false if sprite != nil
          next
        end
        sprite.visible = true
        sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
        if position == 3
          if self.viewport != nil
            sprite.x = self.viewport.rect.width / 2
            sprite.y = 160 # この一行だけ変更
          else
            sprite.x = 320
            sprite.y = 240
          end
        else
          sprite.x  = self.x - self.ox + self.src_rect.width / 2
          sprite.y  = self.y - self.oy + self.src_rect.height / 2
          sprite.y -= self.src_rect.height / 4 if position == 0
          sprite.y += self.src_rect.height / 4 if position == 2
        end
        sprite.x += cell_data[i, 1]
        sprite.y += cell_data[i, 2]
        sprite.z = 2000
        sprite.ox = 96
        sprite.oy = 96
        sprite.zoom_x = cell_data[i, 3] / 100.0
        sprite.zoom_y = cell_data[i, 3] / 100.0
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
        sprite.blend_type = cell_data[i, 7]
      end
    end
  end
end
Expand to see the code.


can any of u pro scripters make it so it works? it would make my game so much better...
Is there a way to make this work with Minkoffs animated battlers?
Because the Bars and stuff just don't appear...
I'm using this script, and I get an error when I try to heal. I changed the 'hp's to 'sp's, and now it says 'cannot convert fixnum into string'. The error still occurs on line 327, but I can't figure out what's wrong.

Oops, just realized that I must have accidentally altered the script a little after copying it into the script editor. My bad XD
[QUOTE=Nin;59694]Ooh, cool. Better than any enemy HP script out there. (No hard feelings, anyone.) *uses*[/QUOTE]

were is it btw because I want to use it. :)
is it possible to just have the hp bar shown, because i really dont care about the enemies sp ( or have it so you can turn it on or off through an option)

Also can you make this compatible with Tricksters Bars script? the bars dont show up with this script in my project
Awesome script dude, but as some people already said if you can make it go on, and off for Bosses it would be perfect for my game.
Ill use this script!

but can you change it so the Name, HP, and SP arent shown
and make the bars more near? o_O

thx

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=5617