[rgss]# Title: Some kind of battle script
# By StarGGundam2 & Silver Wind
# Writing this makes me feel weird
# In order to change the opacity of the character's status in battle change the
# self.opacity of the Window_BattleStatus class.
##################################
#####Window BattleStatus################
##################################
class Window_BattleStatus < Window_Base
def initialize
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = [false, false, false, false]
self.opacity = 200
refresh
end
end
##################################
#####Window PartyCommand################
##################################
class Window_PartyCommand < Window_Selectable
def initialize
super(600, 600, 32, 32)
self.opacity = 0
end
end
##################################
#####Window BattleResult################
##################################
class Window_BattleResult < Window_Base
def initialize(exp, gold, treasures)
@exp = exp
@gold = gold
@treasures = treasures
super(160, 0, 320, @treasures.size * 32 + 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.y = 160 - height / 2
self.back_opacity = 160
self.visible = false
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
x = 4
self.contents.font.color = normal_color
cx = contents.text_size(@gold.to_s).width
self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
x += cx + 4
self.contents.font.color = system_color
self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
y = 32
for item in @treasures
draw_item_name(item, 4, y)
y += 32
end
end
end
##################################
#####Scene_Battle################
##################################
class Scene_Battle
def update_phase2
start_phase3
return
end
end
##################################
#####Window MenuStatus################
##################################
class Window_MenuStatus < Window_Selectable
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 116
actor = $game_party.actors
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
end
##################################
#####Window Status################
##################################
class Window_Status < Window_Base
def refresh
self.contents.clear
draw_actor_graphic(@actor, 40, 112)
draw_actor_name(@actor, 4, 0)
draw_actor_class(@actor, 4 + 144, 0)
draw_actor_level(@actor, 96, 32)
draw_actor_state(@actor, 96, 64)
draw_actor_hp(@actor, 96, 112, 172)
draw_actor_sp(@actor, 96, 144, 172)
draw_actor_parameter(@actor, 96, 192, 0)
draw_actor_parameter(@actor, 96, 224, 1)
draw_actor_parameter(@actor, 96, 256, 2)
draw_actor_parameter(@actor, 96, 304, 3)
draw_actor_parameter(@actor, 96, 336, 4)
draw_actor_parameter(@actor, 96, 368, 5)
draw_actor_parameter(@actor, 96, 400, 6)
self.contents.font.color = system_color
self.contents.draw_text(320, 160, 96, 32, "equipment")
draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
end
end
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :viewport1 # enemy viewport
attr_reader :viewport2 # actor viewport
attr_reader :enemy_sprites
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Make viewports
@viewport1 = Viewport.new(0, 0, 640, 480)
# ----- silver wind's edit: 800 >> 960 ----- #
@viewport5 = Viewport.new(0, 0, 640, 480) #960
# ------------------------------------------ #
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 101
@viewport3.z = 200
@viewport4.z = 5000
#@viewport5.z = 200
# Make battleback sprite
@battleback_sprite = Sprite.new(@viewport1)
# Make enemy sprites
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport5, enemy, 0)) # new
@enemy_sprites.push(Sprite_Battler.new(@viewport5, enemy, 160))
end
# Make actor sprites
@actor_sprites = []
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
# Make weather
@weather = RPG::Weather.new(@viewport1)
# Make picture sprites
@picture_sprites = []
for i in 51..100
@picture_sprites.push(Sprite_Picture.new(@viewport3,
$game_screen.pictures))
end
# Make timer sprite
@timer_sprite = Sprite_Timer.new
# Frame update
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# If battleback bit map exists, dispose of it
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
# Dispose of battleback sprite
@battleback_sprite.dispose
# Dispose of enemy sprites and actor sprites
for sprite in @enemy_sprites + @actor_sprites
sprite.dispose
end
# Dispose of weather
@weather.dispose
# Dispose of picture sprites
for sprite in @picture_sprites
sprite.dispose
end
# Dispose of timer sprite
@timer_sprite.dispose
# Dispose of viewports
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
@viewport4.dispose
@viewport5.dispose
end
end
# --------------------------------------------- #
# Fix by Silver Wind #
# --------------------------------------------- #
# expanded battle-back area (viewport 1)
class Spriteset_Battle
def update
# Update actor sprite contents (corresponds with actor switching)
@actor_sprites[0].battler = $game_party.actors[0]
@actor_sprites[1].battler = $game_party.actors[1]
@actor_sprites[2].battler = $game_party.actors[2]
@actor_sprites[3].battler = $game_party.actors[3]
# If battleback file name is different from current one
if @battleback_name != $game_temp.battleback_name
@battleback_name = $game_temp.battleback_name
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@battleback_sprite.src_rect.set(0, 0, 640, 480)
end
# Update battler sprites
for sprite in @enemy_sprites + @actor_sprites
sprite.update
end
# Update weather graphic
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.update
# Update picture sprites
for sprite in @picture_sprites
sprite.update
end
# Update timer sprite
@timer_sprite.update
# Set screen color tone and shake position
@viewport1.tone = $game_screen.tone
@viewport5.tone = $game_screen.tone # new
@viewport1.ox = $game_screen.shake
# Set screen flash color
@viewport4.color = $game_screen.flash_color
@viewport5.color = $game_screen.flash_color # new
# Update viewports
@viewport1.update
@viewport2.update
@viewport4.update
@viewport5.update
end
end
class Sprite_Battler < RPG::Sprite
def initialize(viewport, battler = nil, offset=nil)
super(viewport)
@battler = battler
@battler_visible = false
@offset = offset# new
end
def update
super
# If battler is nil
if @battler == nil
self.bitmap = nil
loop_animation(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
# ----------- edit ------------
if @offset.nil?
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
else
bitmap2 = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap2.width
@height = (bitmap2.height) - @offset
self.ox = @width / 2
off = (@offset==0 ? -160 : 160)
self.oy = @height - @offset
src_rect = Rect.new(0, off, @width, @height+@offset) # @offset
self.bitmap = Bitmap.new(@width, @height+@offset)
self.bitmap.blt(0, 0, bitmap2, src_rect)
end
<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;"> self.oy = @height + @offset # was +@offset
<span style="color:#000080; font-style:italic;"> src_rect = Rect.new(0, off, @width, @height+@offset) # off was -160
<span style="color:#000080; font-style:italic;"> self.bitmap = Bitmap.new(@width, @height+@offset)
<span style="color:#000080; font-style:italic;"> self.bitmap.blt(0, 0, bitmap2, src_rect)
<span style="color:#000080; font-style:italic;">=end
# -----------------------------
# Change opacity level to 0 when dead or hidden
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
# If animation ID is different than current one
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
# If actor which should be displayed
if @battler.is_a?(Game_Actor) and @battler_visible
# Bring opacity level down a bit when not in main phase
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# Blink
if @battler.blink
blink_on
else
blink_off
end
# If invisible
unless @battler_visible
# Appear
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@battler_visible = true
end
end
# If visible
if @battler_visible
# Escape
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# White flash
if @battler.white_flash
# ------------ edit ------------- #
# the large enemy is made from 2 sprites.
# this edit makes them flash together
if $game_temp.in_battle
for sprite in $scene.spriteset.enemy_sprites
if @battler == sprite.battler
#p 'found another sprite of this battler'
sprite.whiten
end
end
end
# ------------------------------------ #
whiten
@battler.white_flash = false
end
# Animation
if @battler.animation_id != 0
# ------------ edit ------------- #
animation = $data_animations[@battler.animation_id]
#animation(animation, @battler.animation_hit)
@count = animation.frame_max
@battler.animation_id = 0
if $game_temp.in_battle
for sprite in $scene.spriteset.enemy_sprites
if @battler == sprite.battler
#p 'found another sprite of this battler'
#sprite.battler.animation_id = @battler.animation_id
#sprite.animation() #(animation, @battler.animation_hit)
#sprite.loop_animation($data_animations[@battler.animation_id])
#animation = $data_animations[@battler.animation_id]
#sprite.animation(animation, @battler.animation_hit)
#sprite.update
#sprite.battler.animation_id = 0
#animation = $data_animations[anim_id]
sprite.loop_animation(animation)
@second_sprite = sprite
end
end
end
# ----------------------------------------- #
#loop_animation(animation)
animation(animation, @battler.animation_hit)
end
# ------------------ edit ------------------ #
if @count and @count >0 : @count -= 1 end
if @count==0
unless @second_sprite.nil?
@second_sprite.loop_animation(nil)
end
loop_animation(nil)
end
# ------------------------------------------- #
# Damage
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# Collapse
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@battler_visible = false
end
end
# Set sprite coordinates
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
end
# --------------------------------------------------------------------------- #
class Scene_Battle
attr_reader :spriteset
def start_enemy_select
# Make enemy arrow
@enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2) #was viewport1
# Associate help window
@enemy_arrow.help_window = @help_window
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
end
end
[/rgss]