# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: 4 Corners Battle Hud ║ Version: 1.01 ║
# ║ Author: Roninator2 ║ ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function: ║ Date Created ║
# ║ ╠════════════════════╣
# ║ Script Function ║ 23 Oct 2024 ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description: ║
# ║ Display actor status in the 4 corners of the battle screen ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions: ║
# ║ Plug and play ║
# ║ Adjust the background colour as desired ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates: ║
# ║ 1.00 - 23 Oct 2024 - Script finished ║
# ║ 1.01 - 25 Oct 2024 - Fixed Frame and refresh and windows colour ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks: ║
# ║ Roninator2 ║
# ║ Yanfly - some code copied ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use: ║
# ║ Follow the original Authors terms of use where applicable ║
# ║ - When not made by me (Roninator2) ║
# ║ Free for all uses in RPG Maker except nudity ║
# ║ Anyone using this script in their project before these terms ║
# ║ were changed are allowed to use this script even if it conflicts ║
# ║ with these new terms. New terms effective 03 Apr 2024 ║
# ║ No part of this code can be used with AI programs or tools ║
# ║ Credit must be given ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ End of editable region ║
# ╚════════════════════════════════════════════════════════════════════╝
module BattleManager
def self.actor_index
return @actor_index
end
end
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(140, 0, window_width, window_height)
self.z = 200
self.opacity = 0
@lines = []
@num_wait = 0
create_back_bitmap
create_back_sprite
refresh
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
Graphics.width - 280
end
#--------------------------------------------------------------------------
# * Create Background Sprite
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = @back_bitmap
@back_sprite.x = x
@back_sprite.y = y
@back_sprite.z = z - 1
end
end
class Window_PartyCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(Graphics.width / 2 - window_width / 2, Graphics.height / 2 - fitting_height(visible_line_number) / 2)
self.openness = 0
deactivate
end
end
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def setup(actor)
@actor = actor
index = BattleManager.actor_index
clear_command_list
case index
when 0
self.x = 142
self.y = 15
when 1
self.x = Graphics.width - 143 - self.width
self.y = 15
when 2
self.x = 142
self.y = Graphics.height - 140
when 3
self.x = Graphics.width - 143 - self.width
self.y = Graphics.height - 140
end
make_command_list
refresh
select(0)
activate
open
end
end
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# overwrite method: initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, window_height)
@op = self.opacity
self.openness = 0
self.opacity = 0
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
Graphics.width
end
#--------------------------------------------------------------------------
# * Get Window Height
#--------------------------------------------------------------------------
def window_height
Graphics.height
end
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
$game_party.battle_members.size
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_all_items
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# * Get Row Count
#--------------------------------------------------------------------------
def row_max
return 2
end
#--------------------------------------------------------------------------
# new method: actor
#--------------------------------------------------------------------------
def actor; return $game_party.battle_members[@index]; end
#--------------------------------------------------------------------------
# overwrite method: draw_item
#--------------------------------------------------------------------------
def draw_item(index)
return if index.nil?
clear_item(index)
actor = $game_party.battle_members[index]
rect = item_rect(index)
return if actor.nil?
draw_window_frame(rect.x-5, rect.y-5, rect.width+10, rect.height+5)
draw_actor_face(actor, rect.x+2, rect.y+2, actor.alive?)
draw_actor_name(actor, rect.x, rect.y, rect.width-8)
draw_actor_action(actor, rect.x, rect.y)
draw_actor_icons(actor, rect.x, rect.y+25, rect.width)
contents.font.size = 16
draw_actor_hp(actor, rect.x+2, rect.y+60, rect.width-4)
draw_actor_mp(actor, rect.x+2, rect.y+75, rect.width-4)
draw_actor_tp(actor, rect.x+2, rect.y+90, rect.width-4)
end
def get_window_colour
adj = 0
r = $game_system.window_tone.red.to_i
g = $game_system.window_tone.green.to_i
b = $game_system.window_tone.blue.to_i
adj = r * -1 if r < 0 && (r < (g || b))
adj = g * -1 if g < 0 && (g < (r || b))
adj = b * -1 if b < 0 && (b < (r || g))
if adj > 0
adj = 50 if adj > 50
r = r + adj
g = g + adj
b = b + adj
end
a = @op
t = Color.new(r, g, b, a)
return t
end
#--------------------------------------------------------------------------
# new method: draw_window_frame
#--------------------------------------------------------------------------
def draw_window_frame(x, y, w, h)
contents.blt(x, y, windowskin, Rect.new(64,0,16,16))
contents.blt(x+w-16, y, windowskin, Rect.new(112,0,16,16))
contents.blt(x, y+h-16, windowskin, Rect.new(64,48,16,16))
contents.blt(x+w-16, y+h-16, windowskin, Rect.new(112,48,16,16))
contents.fill_rect(x + 4, y + 4, 120, 115, get_window_colour)
i=0
while i < w-32 do
contents.blt(x+i+4, y, windowskin, Rect.new(80,0,[w-10-i,32].min,16))
contents.blt(x+i+4, y+h-16, windowskin, Rect.new(80,48,[w-10-i,32].min,16))
i+=32
end
i=0
while i < h-32 do
contents.blt(x, y+4+i, windowskin, Rect.new(64,16,16,[h-32-i,32].min))
contents.blt(x+w-16, y+4+i, windowskin, Rect.new(112,16,16,[h-32-i,32].min))
contents.blt(x, y+26+i, windowskin, Rect.new(64,16,16,[h-32-i,32].min))
contents.blt(x+w-16, y+26+i, windowskin, Rect.new(112,16,16,[h-32-i,32].min))
i+=32
end
end
#--------------------------------------------------------------------------
# overwrite method: item_rect
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = 120
rect.height = 120
case index
when 0
rect.x = 5
rect.y = 5
when 1
rect.x = Graphics.width - 150
rect.y = 5
when 2
rect.x = 5
rect.y = Graphics.height - 150
when 3
rect.x = Graphics.width - 150
rect.y = Graphics.height - 150
end
return rect
end
#--------------------------------------------------------------------------
# overwrite method: draw_face
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, dx, dy, enabled = true)
bitmap = Cache.face(face_name)
fx = [(96 - item_rect(0).width + 1) / 2, 0].max
fy = face_index / 4 * 96 + 2
fw = [item_rect(0).width - 4, 92].min
rect = Rect.new(fx, fy, fw, 92)
rect = Rect.new(face_index % 4 * 96 + fx, fy, fw, 92)
contents.blt(dx, dy, bitmap, rect, enabled ? 255 : translucent_alpha)
bitmap.dispose
end
#--------------------------------------------------------------------------
# overwrite method: draw_actor_name
#--------------------------------------------------------------------------
def draw_actor_name(actor, dx, dy, dw = 112)
reset_font_settings
contents.font.size = 16
change_color(hp_color(actor))
draw_text(dx+24, dy, dw-24, line_height, actor.name)
end
#--------------------------------------------------------------------------
# overwrite method: draw_current_and_max_values
#--------------------------------------------------------------------------
def draw_current_and_max_values(dx, dy, dw, current, max, color1, color2)
change_color(color1)
draw_text(dx, dy, dw, line_height, current, 2)
end
#--------------------------------------------------------------------------
# new method: draw_actor_action
#--------------------------------------------------------------------------
def draw_actor_action(actor, dx, dy)
draw_icon(action_icon(actor), dx, dy)
end
#--------------------------------------------------------------------------
# new method: action_icon
#--------------------------------------------------------------------------
def action_icon(actor)
return 0 if actor.current_action.nil?
return 0 if actor.current_action.item.nil?
return actor.current_action.item.icon_index
end
#--------------------------------------------------------------------------
# overwrite method: draw_actor_hp
#--------------------------------------------------------------------------
def draw_actor_hp(actor, dx, dy, width = 124)
draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
change_color(system_color)
cy = (Font.default_size - contents.font.size) / 2 + 1
draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)
draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp,
hp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# overwrite method: draw_actor_mp
#--------------------------------------------------------------------------
def draw_actor_mp(actor, dx, dy, width = 124)
draw_gauge(dx, dy, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
change_color(system_color)
cy = (Font.default_size - contents.font.size) / 2 + 1
draw_text(dx+2, dy+cy, 30, line_height, Vocab::mp_a)
draw_current_and_max_values(dx, dy+cy, width, actor.mp, actor.mmp,
mp_color(actor), normal_color)
end
#--------------------------------------------------------------------------
# overwrite method: draw_actor_tp
#--------------------------------------------------------------------------
def draw_actor_tp(actor, dx, dy, width = 124)
draw_gauge(dx, dy, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
change_color(system_color)
cy = (Font.default_size - contents.font.size) / 2 + 1
draw_text(dx+2, dy+cy, 30, line_height, Vocab::tp_a)
change_color(tp_color(actor))
draw_text(dx + width - 42, dy+cy, 42, line_height, actor.tp.to_i, 2)
end
end
class Window_BattleSkill < Window_SkillList
#--------------------------------------------------------------------------
# * Object Initialization
# info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
def initialize(help_window, info_viewport)
y = help_window.height
super(0, y, Graphics.width, Graphics.height - y)
self.visible = false
@help_window = help_window
end
end
class Window_BattleItem < Window_ItemList
#--------------------------------------------------------------------------
# * Object Initialization
# info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
def initialize(help_window, info_viewport)
y = help_window.height
super(0, y, Graphics.width, Graphics.height - y)
self.visible = false
@help_window = help_window
end
end
class Window_BattleActor < Window_BattleStatus
#--------------------------------------------------------------------------
# ● window display
#--------------------------------------------------------------------------
def show
@old_index = nil
select(0) if @index < 0
super
end
#--------------------------------------------------------------------------
# ● Window update
#--------------------------------------------------------------------------
def update
super
update_target_anim
end
#--------------------------------------------------------------------------
# ● Target anime update
#--------------------------------------------------------------------------
def update_target_anim
if @index != @old_index
refresh
@old_index = @index
rect = item_rect(@index)
draw_highlight_frame(rect.x-5, rect.y-5, rect.width+10, rect.height+5)
end
end
#--------------------------------------------------------------------------
# new method: draw_window_frame
#--------------------------------------------------------------------------
def draw_window_frame(x, y, w, h)
contents.blt(x, y, windowskin, Rect.new(64,0,16,16), 120)
contents.blt(x+w-16, y, windowskin, Rect.new(112,0,16,16), 120)
contents.blt(x, y+h-16, windowskin, Rect.new(64,48,16,16), 120)
contents.blt(x+w-16, y+h-16, windowskin, Rect.new(112,48,16,16), 120)
contents.fill_rect(x + 4, y + 4, 120, 115, get_window_colour)
i=0
while i < w-32 do
contents.blt(x+16+i, y, windowskin, Rect.new(80,0,[w-32-i,32].min,16), 120)
contents.blt(x+16+i, y+h-16, windowskin, Rect.new(80,48,[w-32-i,32].min,16), 120)
i+=32
end
i=0
while i < h-32 do
contents.blt(x, y+16+i, windowskin, Rect.new(64,16,16,[h-32-i,32].min), 120)
contents.blt(x+w-16, y+16+i, windowskin, Rect.new(112,16,16,[h-32-i,32].min), 120)
i+=32
end
end
#--------------------------------------------------------------------------
# new method: draw_window_frame
#--------------------------------------------------------------------------
def draw_highlight_frame(x, y, w, h)
contents.blt(x, y, windowskin, Rect.new(64,0,16,16), 255)
contents.blt(x+w-16, y, windowskin, Rect.new(112,0,16,16), 255)
contents.blt(x, y+h-16, windowskin, Rect.new(64,48,16,16), 255)
contents.blt(x+w-16, y+h-16, windowskin, Rect.new(112,48,16,16), 255)
i=0
while i < w-32 do
contents.blt(x+16+i, y, windowskin, Rect.new(80,0,[w-32-i,32].min,16), 255)
contents.blt(x+16+i, y+h-16, windowskin, Rect.new(80,48,[w-32-i,32].min,16), 255)
i+=32
end
i=0
while i < h-32 do
contents.blt(x, y+16+i, windowskin, Rect.new(64,16,16,[h-32-i,32].min), 255)
contents.blt(x+w-16, y+16+i, windowskin, Rect.new(112,16,16,[h-32-i,32].min), 255)
i+=32
end
end
end
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
def initialize(info_viewport)
super(140, 0, window_width, fitting_height(4))
refresh
self.visible = false
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
Graphics.width - 282
end
#--------------------------------------------------------------------------
# ● window display
#--------------------------------------------------------------------------
def show
@target_anim_on = true
@old_index = nil
aindex = BattleManager.actor_index
case aindex
when 0, 1
self.y = Graphics.height - self.height - 20
when 2, 3
self.y = 15
end
select(0) if @index < 0
super
end
#--------------------------------------------------------------------------
# ● Hiding a window
#--------------------------------------------------------------------------
alias hide2 hide
def hide
old_enemy.sprite_effect_type = :whiten_loop_stop if @old_index != nil
enemy.sprite_effect_type = :whiten_loop_stop
@target_anim_on = false
@old_index = nil
hide2
end
#--------------------------------------------------------------------------
# ● Window update
#--------------------------------------------------------------------------
def update
super
update_target_anim
end
#--------------------------------------------------------------------------
# ● Target anime update
#--------------------------------------------------------------------------
def update_target_anim
return if @target_anim_on == nil
if @target_anim_on && @index != @old_index
old_enemy.sprite_effect_type = :whiten_loop_stop if @old_index != nil
enemy.sprite_effect_type = :whiten_loop if enemy
end
@old_index = @index
end
#--------------------------------------------------------------------------
# ● Get previous enemy character object
#--------------------------------------------------------------------------
def old_enemy
$game_troop.alive_members[@old_index]
end
end
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● Start of effect
#--------------------------------------------------------------------------
def start_effect(effect_type)
@effect_type = effect_type
case @effect_type
when :appear
@effect_duration = 16
@battler_visible = true
when :disappear
@effect_duration = 32
@battler_visible = false
when :whiten
@effect_duration = 16
@battler_visible = true
when :blink
@effect_duration = 20
@battler_visible = true
when :collapse
@effect_duration = 48
@battler_visible = false
when :boss_collapse
@effect_duration = bitmap.height
@battler_visible = false
when :instant_collapse
@effect_duration = 16
@battler_visible = false
when :whiten_loop
@whiten_cnt = 0.0
@effect_duration = -1
@battler_visible = true
when :whiten_loop_stop
@effect_duration = -1
end
revert_to_normal
end
#--------------------------------------------------------------------------
# ● Effect update
#--------------------------------------------------------------------------
alias update_effect2 update_effect
def update_effect
update_effect2
if @effect_duration < 0
case @effect_type
when :whiten_loop
update_whiten_loop
when :whiten_loop_stop
update_whiten_loop_stop
end
end
end
#--------------------------------------------------------------------------
# ● Effect on selection
#--------------------------------------------------------------------------
def update_whiten_loop
d=(-90+@whiten_cnt/180)*Math::PI
col = 255 * Math.sin(d)
@whiten_cnt += 6
@whiten_cnt %= 180
self.color.set(col, col, col, col)
end
#--------------------------------------------------------------------------
# ● Effect ends when selected
#--------------------------------------------------------------------------
def update_whiten_loop_stop
@whiten_cnt = 0.0
self.color.set(0, 0, 0, 0)
@effect_duration = 0
@effect_type = nil
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Update Information Display Viewport
#--------------------------------------------------------------------------
def update_info_viewport
end
#--------------------------------------------------------------------------
# * Create Status Window
#--------------------------------------------------------------------------
def create_status_window
@status_window = Window_BattleStatus.new
end
#--------------------------------------------------------------------------
# * Create Information Display Viewport
#--------------------------------------------------------------------------
def create_info_viewport
@info_viewport = Viewport.new
@info_viewport.z = 100
@status_window.viewport = @info_viewport
end
#--------------------------------------------------------------------------
# * Create Party Commands Window
#--------------------------------------------------------------------------
def create_party_command_window
@party_command_window = Window_PartyCommand.new
@party_command_window.viewport = @info_viewport
@party_command_window.set_handler(:fight, method(:command_fight))
@party_command_window.set_handler(:escape, method(:command_escape))
@party_command_window.unselect
end
#--------------------------------------------------------------------------
# * Create Actor Commands Window
#--------------------------------------------------------------------------
def create_actor_command_window
@actor_command_window = Window_ActorCommand.new
@actor_command_window.viewport = @info_viewport
@actor_command_window.set_handler(:attack, method(:command_attack))
@actor_command_window.set_handler(:skill, method(:command_skill))
@actor_command_window.set_handler(:guard, method(:command_guard))
@actor_command_window.set_handler(:item, method(:command_item))
@actor_command_window.set_handler(:cancel, method(:prior_command))
@actor_command_window.hide
end
#--------------------------------------------------------------------------
# * To Previous Command Input
#--------------------------------------------------------------------------
def prior_command
if BattleManager.prior_command
start_actor_command_selection
else
@actor_command_window.hide
start_party_command_selection
end
end
#--------------------------------------------------------------------------
# * Start Actor Command Selection
#--------------------------------------------------------------------------
def start_actor_command_selection
@status_window.select(BattleManager.actor.index)
@party_command_window.close
@actor_command_window.setup(BattleManager.actor)
@actor_command_window.show
end
#--------------------------------------------------------------------------
# * Start Turn
#--------------------------------------------------------------------------
def turn_start
@actor_command_window.hide
@party_command_window.close
@actor_command_window.close
@status_window.unselect
@subject = nil
BattleManager.turn_start
@log_window.wait
@log_window.clear
end
end