11-10-2019, 04:13 AM (This post was last modified: 11-12-2019, 03:58 AM by DerVVulfman.
Edit Reason: Stupid! Stupid! Stupid! Error Fix!
)
ZLSL's Battle Portraits
Version: 1.2
Introduction
This script allows you to display an 'extra' shot of your hero-in-action within your default battlesystem when it is his or her turn to choose what action to take. That is, you can display a large portrait of the hero or heroine when the [ Actor Command Window ] ( Attack|Skill|Item|Defend ) is visible and active.
Demo
None. This one's pretty simple in implementation.
Script
Here you go!
Code:
#==============================================================================
# ** ZLSL's Battle Portraits
#------------------------------------------------------------------------------
# version 1.1
# by DerVVulfman
# 11-10-2019 (MM-DD-YYYY)
# RGSS / RPGMaker XP
#------------------------------------------------------------------------------
#
# INTRODUCTION:
#
# This script allows you to display an 'extra' shot of your hero-in-action
# within your default battlesystem when it is his or her turn to choose what
# action to take. That is, you can display a large portrait of the hero or
# heroine when the [ Actor Command Window ] ( Attack|Skill|Item|Defend ) is
# visible and active.
#
# It works on most default-styled strategic battle systems such as the one
# that comes with RPGMaker XP. And these hero portraits will appear behind
# the battlestatus window while simultaneously be in front of all battlers
# in the battlefield.
#
#
#------------------------------------------------------------------------------
#
# INSTALLATION:
#
# Place this script below Scene_Debug and above Main. If it is in use with
# with a custom battle system, it must be placed below such a system.
#
# Configure the position where the portaits will be shown. This is done in
# the ZLSL_Portraits module.
#
#------------------------------------------------------------------------------
#
# RESOURCES:
#
# This script requires new portait resources. They can be stock default RTP
# battlers, but it would seem preferable to have larger graphics in order to
# highlight the heroes.
#
# These graphics must be stored in a custom Graphics\BPortrait folder. The
# folder is cachable. This means it will cache and compress if oyu do wish
# to compress and encrypt your game. Nice, eh?
#
#==============================================================================
#
# THANKS:
#
# Thanks to zlsl who requested the system. I figured... I had about ten
# minutes to kill.
#
#------------------------------------------------------------------------------
#
# COMPATIBILITY:
#
# Fairly compatible for RPGMaker XP systems. It doesn't rewrite any methods
# in the system. But it does attach a Keyring item to the Scene_Item class.
#
#------------------------------------------------------------------------------
#
# TERMS OF USE:
#
# Free for use, even in commercial games. Only due credit is required.
# That includes credit for zlsl as well as my own.
#
#
#==============================================================================
module ZLSL_Portraits
X_POS = 240 # X-Position of battler in the viewport
Y_POS = 320 # Y-Position of battler in the viewport
end
#==============================================================================
# ** RPG::Cache
#------------------------------------------------------------------------------
# The module that loads each of RPGXP's graphic formats, creates a Bitmap
# object, and retains it.
#==============================================================================
module RPG::Cache
#------------------------------------------------------------------------
# * Battle Portait
# filename : filename of the cached bitmap
# hue : hue of the cached bitmap
#------------------------------------------------------------------------
def self.bportait(filename, hue=0)
begin
self.load_bitmap("Graphics/BPortrait/", filename, hue)
rescue
self.load_bitmap("Graphics/BPortrait/", "", hue)
end
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battle_in_action # battle callback (Proc)
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias oogabooga initialize
def initialize
oogabooga
@battle_in_action = nil
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :party_size
end
#==============================================================================
# ** Sprite_BattlerProfile
#------------------------------------------------------------------------------
# This sprite is used to display the battler.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_BattlerProfile < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler # battler
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# battler : battler (Game_Battler)
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose unless self.bitmap.nil?
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If battler is nil
if @battler == nil
self.bitmap = nil
return
end
# If file name or hue are different than current ones
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# Get and set bitmap
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
end
# Bring opacity level down a bit when not in main phase
if $game_temp.battle_in_action == nil
self.opacity = 0
elsif $game_temp.battle_in_action == @battler
self.opacity = 255
else
self.opacity = 0
end
# Set sprite coordinates
self.x = ZLSL_Portraits::X_POS
self.y = ZLSL_Portraits::Y_POS
self.z = 0
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within
# the Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :viewporthero # battler portrait viewport
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias zlslbportait_spriteset_initialize initialize
alias zlslbportait_spriteset_dispose dispose
alias zlslbportait_spriteset_update update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Make viewports
@viewporthero = Viewport.new(0, 0, 640, 320)
@viewporthero.z = 50
# Acquire current number of battlers
party_size = zlslbportait_function_update_actor_party_size
# Make actor sprites
@figure_sprites = []
for i in 0...party_size
@figure_sprites.push(Sprite_BattlerProfile.new(@viewporthero))
end
# Perform the original call
zlslbportait_spriteset_initialize
end
#--------------------------------------------------------------------------
# * Frame Update : zlsl Battler Portait Function - Acquire Party Size
#--------------------------------------------------------------------------
def zlslbportait_function_update_actor_party_size
# Set current number of battlers
return_value = 4
return_value = $game_party.party_size if $game_party.party_size != nil
return return_value
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Perform the original call
zlslbportait_spriteset_dispose
# Dispose of enemy sprites and actor sprites
for sprite in @figure_sprites
sprite.dispose
end
@viewporthero.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Acquire current number of battlers
party_size = zlslbportait_function_update_actor_party_size
# Update actor sprite contents (corresponds with actor switching)
for i in 0...party_size
@figure_sprites[i].battler = $game_party.actors[i]
end
# Update battler sprites
for sprite in @figure_sprites
sprite.update
end
# Perform the original call
zlslbportait_spriteset_update
# Update viewport
@viewporthero.update
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias zlslbportait_battle_main main
alias zlslbportait_battle_start_phase2 start_phase2
alias zlslbportait_battle_start_phase3 start_phase3
alias zlslbportait_battle_phase3_set_cmd_window phase3_setup_command_window
alias zlslbportait_battle_start_phase4 start_phase4
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_main
end
#--------------------------------------------------------------------------
# * Start Actor Command Phase
#--------------------------------------------------------------------------
def start_phase2
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_start_phase2
end
#--------------------------------------------------------------------------
# * Start Actor Command Phase
#--------------------------------------------------------------------------
def start_phase3
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_start_phase3
end
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
def phase3_setup_command_window
# Set the flag for the spriteset window (actual battler!)
$game_temp.battle_in_action = @active_battler
# Perform the original call
zlslbportait_battle_phase3_set_cmd_window
end
#--------------------------------------------------------------------------
# * Start Actor Command Phase
#--------------------------------------------------------------------------
def start_phase4
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_start_phase4
end
end
Instructions
Place this script below Scene_Debug and above Main. If it is in use with with a custom battle system, it must be placed below such a system.
Configure the position where the portaits will be shown. This is done in the ZLSL_Portraits module.
Compatibility
Thanks to zlsl who requested the system. I figured... I had about ten minutes to kill.
Credits and Thanks
˂If you're using graphics made or scripts written by others, or have someone to thank, do it here. This section is optional if you have no one to mention.˃
Terms and Conditions
Free for use, even in commercial games. Only due credit is required. That includes credit for zlsl as well as my own.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
I neglected to include recognition of a 'party_size' value within the Game_Party class. This value is typically nil and unused by the script. However, I recognize that other scripts that increase the size of the default system's party beyond 4-members uses this value. If detected, then this new value will be used instead.
So... no. The party_size value does not define the size of the party within this script, it is a hook used by other scripts.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Introduction
This script allows you to display an 'extra' shot of your hero-in-action within your default battlesystem when it is his or her turn to choose what action to take. That is, you can display a large portrait of the hero or heroine when the [ Actor Command Window ] ( Attack|Skill|Item|Defend ) is visible and active.
Demo
None. This one's pretty simple in implementation.
Script
Here you go!
Code:
#==============================================================================
# ** ZLSL's Battle Portraits
#------------------------------------------------------------------------------
# version 1.1
# by DerVVulfman
# 11-10-2019 (MM-DD-YYYY)
# RGSS / RPGMaker XP
#------------------------------------------------------------------------------
#
# INTRODUCTION:
#
# This script allows you to display an 'extra' shot of your hero-in-action
# within your default battlesystem when it is his or her turn to choose what
# action to take. That is, you can display a large portrait of the hero or
# heroine when the [ Actor Command Window ] ( Attack|Skill|Item|Defend ) is
# visible and active.
#
# It works on most default-styled strategic battle systems such as the one
# that comes with RPGMaker XP. And these hero portraits will appear behind
# the battlestatus window while simultaneously be in front of all battlers
# in the battlefield.
#
#
#------------------------------------------------------------------------------
#
# INSTALLATION:
#
# Place this script below Scene_Debug and above Main. If it is in use with
# with a custom battle system, it must be placed below such a system.
#
# Configure the position where the portaits will be shown. This is done in
# the ZLSL_Portraits module.
#
#------------------------------------------------------------------------------
#
# RESOURCES:
#
# This script requires new portait resources. They can be stock default RTP
# battlers, but it would seem preferable to have larger graphics in order to
# highlight the heroes.
#
# These graphics must be stored in a custom Graphics\BPortrait folder. The
# folder is cachable. This means it will cache and compress if oyu do wish
# to compress and encrypt your game. Nice, eh?
#
#==============================================================================
#
# THANKS:
#
# Thanks to zlsl who requested the system. I figured... I had about ten
# minutes to kill.
#
#------------------------------------------------------------------------------
#
# COMPATIBILITY:
#
# Fairly compatible for RPGMaker XP systems. It doesn't rewrite any methods
# in the system. But it does attach a Keyring item to the Scene_Item class.
#
#------------------------------------------------------------------------------
#
# TERMS OF USE:
#
# Free for use, even in commercial games. Only due credit is required.
# That includes credit for zlsl as well as my own.
#
#
#==============================================================================
module ZLSL_Portraits
X_POS = 240 # X-Position of battler in the viewport
Y_POS = 320 # Y-Position of battler in the viewport
end
#==============================================================================
# ** RPG::Cache
#------------------------------------------------------------------------------
# The module that loads each of RPGXP's graphic formats, creates a Bitmap
# object, and retains it.
#==============================================================================
module RPG::Cache
#------------------------------------------------------------------------
# * Battle Portait
# filename : filename of the cached bitmap
# hue : hue of the cached bitmap
#------------------------------------------------------------------------
def self.bportait(filename, hue=0)
begin
self.load_bitmap("Graphics/BPortrait/", filename, hue)
rescue
self.load_bitmap("Graphics/BPortrait/", "", hue)
end
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battle_in_action # battle callback (Proc)
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias oogabooga initialize
def initialize
oogabooga
@battle_in_action = nil
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :party_size
end
#==============================================================================
# ** Sprite_BattlerProfile
#------------------------------------------------------------------------------
# This sprite is used to display the battler.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_BattlerProfile < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler # battler
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# battler : battler (Game_Battler)
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose unless self.bitmap.nil?
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If battler is nil
if @battler == nil
self.bitmap = nil
return
end
# If file name or hue are different than current ones
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# Get and set bitmap
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
end
# Bring opacity level down a bit when not in main phase
if $game_temp.battle_in_action == nil
self.opacity = 0
elsif $game_temp.battle_in_action == @battler
self.opacity = 255
else
self.opacity = 0
end
# Set sprite coordinates
self.x = ZLSL_Portraits::X_POS
self.y = ZLSL_Portraits::Y_POS
self.z = 0
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within
# the Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :viewporthero # battler portrait viewport
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias zlslbportait_spriteset_initialize initialize
alias zlslbportait_spriteset_dispose dispose
alias zlslbportait_spriteset_update update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Make viewports
@viewporthero = Viewport.new(0, 0, 640, 320)
@viewporthero.z = 50
# Acquire current number of battlers
party_size = zlslbportait_function_update_actor_party_size
# Make actor sprites
@figure_sprites = []
for i in 0...party_size
@figure_sprites.push(Sprite_BattlerProfile.new(@viewporthero))
end
# Perform the original call
zlslbportait_spriteset_initialize
end
#--------------------------------------------------------------------------
# * Frame Update : zlsl Battler Portait Function - Acquire Party Size
#--------------------------------------------------------------------------
def zlslbportait_function_update_actor_party_size
# Set current number of battlers
return_value = 4
return_value = $game_party.party_size if $game_party.party_size != nil
return return_value
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Perform the original call
zlslbportait_spriteset_dispose
# Dispose of enemy sprites and actor sprites
for sprite in @figure_sprites
sprite.dispose
end
@viewporthero.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Acquire current number of battlers
party_size = zlslbportait_function_update_actor_party_size
# Update actor sprite contents (corresponds with actor switching)
for i in 0...party_size
@figure_sprites[i].battler = $game_party.actors[i]
end
# Update battler sprites
for sprite in @figure_sprites
sprite.update
end
# Perform the original call
zlslbportait_spriteset_update
# Update viewport
@viewporthero.update
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias zlslbportait_battle_main main
alias zlslbportait_battle_start_phase2 start_phase2
alias zlslbportait_battle_start_phase3 start_phase3
alias zlslbportait_battle_phase3_set_cmd_window phase3_setup_command_window
alias zlslbportait_battle_start_phase4 start_phase4
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_main
end
#--------------------------------------------------------------------------
# * Start Actor Command Phase
#--------------------------------------------------------------------------
def start_phase2
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_start_phase2
end
#--------------------------------------------------------------------------
# * Start Actor Command Phase
#--------------------------------------------------------------------------
def start_phase3
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_start_phase3
end
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
def phase3_setup_command_window
# Set the flag for the spriteset window (actual battler!)
$game_temp.battle_in_action = @active_battler
# Perform the original call
zlslbportait_battle_phase3_set_cmd_window
end
#--------------------------------------------------------------------------
# * Start Actor Command Phase
#--------------------------------------------------------------------------
def start_phase4
# Kill the flag for the spriteset window
$game_temp.battle_in_action = nil
# Perform the original call
zlslbportait_battle_start_phase4
end
end
Instructions
Place this script below Scene_Debug and above Main. If it is in use with with a custom battle system, it must be placed below such a system.
Configure the position where the portaits will be shown. This is done in the ZLSL_Portraits module.
Compatibility
Thanks to zlsl who requested the system. I figured... I had about ten minutes to kill.
Credits and Thanks
˂If you're using graphics made or scripts written by others, or have someone to thank, do it here. This section is optional if you have no one to mention.˃
Terms and Conditions
Free for use, even in commercial games. Only due credit is required. That includes credit for zlsl as well as my own.
Hi guys!
This script is great as an original, but if you want to add a little taste, see my post! Please understand that English is not my native language, so explanation is poor. I used a translator:->
The original script loads the same image as Battler.
I wanted to support battler and command battle portraits differently.
The bitmap folder supported BPortrait, but the script did not recognize the BPortrait folder. (ᵕ̣̣̣̣̣̣﹏ᵕ̣̣̣̣̣̣)
I was troubled all night and modified this. It was actually a very simple way.
Just modify the pink box in the picture.
first if @battler.battler_name != @character_name or
▲ Please search and find. And,
Battle and Command Battle Portraits now support different images! Put your command portrait in the BPortrait folder!
※ Battler and Battle Portrait must have the same name !!
※ Only Atoa ATB is not supported. I will be more concerned about this problem.
Thanks to DerVVulfman and kyonides for their help!
Everyone gave me help and advice until late. This made it possible to build the system I wanted.
I created the Cache system using tried and true methods so the BPortrait folder would properly save. But STUPID ME! I forgot to change the self.bitmap line within Sprite_BattlerProfile over from using the battler folder to the bportait folder!
Oookay. It's now fully fixed.
DerVV waves to yeodongsaeng (Little Sis)
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)