=begin
#==============================================================================#
# AMN MOG - Battle Hud EX - States Addon
# Version 1.01
# Author: AMoonlessNight
# Date: 22 Sep 2020
# Latest: 22 Sep 2020
#==============================================================================#
# UPDATE LOG
#------------------------------------------------------------------------------#
# 22 Sep 2020 - created the script
#==============================================================================#
# TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use; contact for commercial use
# - Follow the original terms and conditions of Moghunter's script
# - If you would like to edit/adjust this script, please make edits as a new
# script (do not edit this script directly) and provide proper credit
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#
# Original script by Moghunter
# https://atelierrgss.wordpress.com/
#==============================================================================#
This script is an addon for Moghunter's Battle Hud EX script. It makes it so
that you can have states spaced out, instead of just showing one at a time. You
can also set it so that states scroll through if there are more than the max
number.
=end
module MOG_BATTLE_HUD_EX
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
# Change the values in the area below to suit your needs.
#==============================================================================
# Maximum number of states to show at once
STATES_MAX = 2
# Spacing between states
STATES_SPACING = 4
# Whether to scroll through if there are more states than STATES_MAX
STATES_SCROLL_IF_OVER_MAX = true
# NOTE: If you have STATES_SCROLLING_ANIMATION set to TRUE, then the states
# will scroll through smoothly. Otherwise, they will tick through each whole
# state icon.
# Time to wait before switching states
STATES_WAIT_TIME = 30
#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
# Please do not edit below this point unless you know what you are doing.
#==============================================================================
end
class Battle_Hud_EX
STATE_ICON_SIZE = 24 + STATES_SPACING
alias amn_mogbhs_bathudex_createstates create_states
def create_states(viewport)
@max_states_size = [[STATES_MAX, 1].max, (Graphics.width / STATE_ICON_SIZE).floor].min
amn_mogbhs_bathudex_createstates(viewport)
if STATES_VISIBLE
@state_scroll_viewport = Viewport.new(@status.x, @status.y, STATE_ICON_SIZE * @max_states_size, 24)
@state_scroll_viewport.z = @status.z
@state_scroll_plane = Plane.new(@state_scroll_viewport)
@state_scroll_plane.z = @state_scroll_viewport.z
end
end
alias amn_mogbhs_bathudex_refreshstates refresh_states
def refresh_states
amn_mogbhs_bathudex_refreshstates
@states_size = [STATE_ICON_SIZE * @status_size_real, 24].max
@state_scroll_viewport.rect.width = [@states_size, STATE_ICON_SIZE * @max_states_size].min
@actor_status.dispose
@actor_status = Bitmap.new(@states_size, 24)
@actor.states.reject{|s| HIDE_STATES_ID.include?(s.id)}.each_with_index do |s, i|
rect = Rect.new(s.icon_index % 16 * 24, s.icon_index / 16 * 24, 24, 24)
@actor_status.blt(STATE_ICON_SIZE * i, 0, @icon_image, rect)
end
@state_scroll_plane.bitmap = @actor_status
@state_scroll_plane.ox = 0
end
def flow_states
return if @actor_status == nil
return unless @actor.states.size > 0
return unless @status_size_real > @max_states_size && STATES_SCROLL_IF_OVER_MAX
if STATES_SCROLLING_ANIMATION
@state_scroll_plane.ox += 1
else
@status_flow[1] += 1
if @status_flow[1] > STATES_WAIT_TIME
@status_flow[1] = 0
@state_scroll_plane.ox += STATE_ICON_SIZE
end
end
end
alias amn_mogbhs_bathudex_disposestates dispose_states
def dispose_states
if @state_scroll_plane
@state_scroll_plane.bitmap.dispose if @state_scroll_plane.bitmap
@state_scroll_plane.dispose
end
@state_scroll_viewport.dispose if @state_scroll_viewport
amn_mogbhs_bathudex_disposestates
end
alias amn_mogbhs_bathudex_updatestates update_states
def update_states
amn_mogbhs_bathudex_updatestates
if @status && @state_scroll_plane.opacity != @status.opacity
@state_scroll_plane.opacity = @status.opacity
end
end
end