Thread Summary:
I asked for a script to fade out battler images when actors were not the visual focus.
Fantasist made a script, and then improved on it.
Later a critical error was noticed, and Fantasist corrected the issue.
For convenience sake I have updated my main post with the most recent/final script,
and added PreCode Text Information to the script.
I would like to thank Fantasist for taking the time to make this requested script.
Considering hes "retired", and didnt/dosent even have RPGXP installed.
The script works very well, and I really like the visual feel of how this moves your focus to the action.
So, thanks again Fantasist and *powerup*!
MeVII
Battle Actor Image Fade - by Fantasist v1.2: ShowHide #############################################################################
# ------v1.2----- Battle Actor Image Fade - by Fantasist ----v1.2-----------#
# ------------------ PreCode Text Information - by MeVII -------------------#
#############################################################################
# -------------------------- Script Description ----------------------------#
# This script keeps actor images invisible, #
# unless actor takes an action, or is acted upon. #
# --------------------------------------------------------------------------#
#############################################################################
# ----------------------------- Instructions -------------------------------#
# Place this Script Below Scene_Battle 4 #
# --------------------------------------------------------------------------#
#############################################################################
# ---------------------------- Usage Options -------------------------------#
# Enable and disable this option at anytime with the event command "script".#
# This is found on the 3rd tab in an event config window. #
# Copy and paste the below code found between Start Code> <End Code. #
# Start Code>$game_system.invibats = true # enable<End Code. #
# Start Code>$game_system.invibats = false # disable<End Code. #
# --------------------------------------------------------------------------#
#############################################################################
# -------------------------- Version Info ----------------------------------#
# v1.2 Critical Error Fix Mar 4 - 2010 #
# 239 Lines of Code #
# The critical error in 1.1 was corrected. #
# Game no longer crashes if all four actors are not present in battle. #
# #
# v1.1 Total Overhaul Feb 18 - 2010 #
# 195 Lines of Code #
# Added Ability to Enable and Disable Script In-Game with Events #
# Script Issues #
# If all four actors were not present, a critical error occurs. #
# Script'---Battle Actor Image Fade'line 67:NoMethodError occured. #
# undefined method `hideme' for nil:NilClass #
# #
# v1.0 First Release Feb 16 - 2010 #
# 34 Lines of Code #
# Script Issues #
# 1. During time for fade in, some of the animation is missed. #
# (Very Slight) #
# 2. When an actor takes damage, there are two animations: #
# The actor getting hit, and the damage popup. #
# So the script tries to fade out the actor image between the two. #
# (Very Slight) #
# --------------------------------------------------------------------------#
#############################################################################
class Sprite_Battler
FADE_SPEED = 3
attr_accessor :target_opacity
alias invibats_sprite_battler_init initialize
def initialize(*args)
invibats_sprite_battler_init(*args)
@target_opacity = self.opacity
end
alias invibats_sprite_battler_upd update
def update
invibats_sprite_battler_upd
if $game_system.invibats
if self.battler && self.battler.is_a?(Game_Actor)
if fading?
d = (self.target_opacity - self.opacity).to_f / FADE_SPEED
self.opacity += (d < 0 ? d.floor : d.ceil)
end
if @battler.hideme
self.target_opacity = 0
end
if !@battler.hideme
self.target_opacity = 255 unless @battler.hidden || @battler.dead?
end
end
end
end
def fading?
return self.opacity != self.target_opacity
end
end
class Game_System
attr_accessor :invibats
alias invibats_game_temp_init initialize
def initialize
invibats_game_temp_init
@invibats = true
end
end
class Game_Battler
attr_accessor :hideme
alias invibats_game_battler_init initialize
def initialize
invibats_game_battler_init
@hideme = false
end
alias invibats_game_battler_slip_damage_effect slip_damage_effect
def slip_damage_effect
invibats_game_battler_slip_damage_effect
self.hideme = false if $game_system.invibats
end
end
class Scene_Battle
alias invibats_scene_battle_start_phase3 start_phase3
def start_phase3
$game_party.actors.each {|actor| actor.hideme = true}
invibats_scene_battle_start_phase3
end
alias invibats_scene_battle_start_phase1 start_phase1
def start_phase1
$game_party.actors.each {|actor| actor.hideme = false}
invibats_scene_battle_start_phase1
end
alias invibats_scene_battle_start_phase2 start_phase2
def start_phase2
$game_party.actors.each {|actor| actor.hideme = false}
invibats_scene_battle_start_phase2
end
alias invibats_scene_battle_start_phase5 start_phase5
def start_phase5
$game_party.actors.each {|actor| actor.hideme = false}
invibats_scene_battle_start_phase5
end
alias invibats_upd_phase3_actor_select update_phase3_actor_select
def update_phase3_actor_select
invibats_upd_phase3_actor_select
$game_party.actors.each_with_index {|actor, index|
if actor == @active_battler
actor.hideme = false
elsif @actor_arrow && index == @actor_arrow.index
actor.hideme = false
else
actor.hideme = true
end
}
end
def phase3_next_actor
# Loop
begin
# Actor blink effect OFF
if @active_battler != nil
@active_battler.blink = false
@active_battler.hideme = true
end
# If last actor
if @actor_index == $game_party.actors.size-1
# Start main phase
start_phase4
return
end
# Advance actor index
@actor_index += 1
@active_battler = $game_party.actors[@actor_index]
@active_battler.blink = true
@active_battler.hideme = false
# Once more if actor refuses command input
end until @active_battler.inputable?
# Set up actor command window
phase3_setup_command_window
end
#--------------------------------------------------------------------------
# * Go to Command Input of Previous Actor
#--------------------------------------------------------------------------
def phase3_prior_actor
# Loop
begin
# Actor blink effect OFF
if @active_battler != nil
@active_battler.blink = false
@active_battler.hideme = true
end
# If first actor
if @actor_index == 0
# Start party command phase
start_phase2
return
end
# Return to actor index
@actor_index -= 1
@active_battler = $game_party.actors[@actor_index]
@active_battler.blink = true
@active_battler.hideme = false
# Once more if actor refuses command input
end until @active_battler.inputable?
# Set up actor command window
phase3_setup_command_window
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
$game_party.actors.each {|actor| actor.hideme = true}
if @active_battler.is_a?(Game_Actor)
@active_battler.hideme = false
end
# Animation for action performer (if ID is 0, then white flash)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# Shift to step 4
@phase4_step = 4
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 4 : animation for target)
#--------------------------------------------------------------------------
def update_phase4_step4
# Animation for target
for target in @target_battlers
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
if target.is_a?(Game_Actor)
target.hideme = false
end
end
# Animation has at least 8 frames, regardless of its length
@wait_count = 8
# Shift to step 5
@phase4_step = 5
end
end
Hello All:
I would like the actor battler images to be hidden when they are not active, for the basic/standard (non BlizABS etc...) system.
So... (Basic)
Start: Battle Starts, all actor battlers are visible.
Sequence: Select "Fight" Only the actor whos action is being selected is visible.
End: Finish selecting actions for all actors, all battlers remain invisible until next round go to Start.
(Advanced)
Start: Battle Starts, all actor battlers are visible.
Sequence: Select "Fight" Only the actor whos action is being selected is visible.
End: Finish selecting actions for all actors, all battlers remain invisible unless they are attacked by an enemy or take an action. Whereas they appear, then fade out. (For visual appeal) next round go to Start.
Im more interested in the "Basic" application than being all tricky with it.
If someone could post the needed script or script edits youd rock like a dump truck full of boulders.
If not, please give me directions and info and Ill be thankful to see if I can hack it out myself.
I thought the basic of hiding battlers during combat was a script tutorial in here, but I didnt have any luck locating it.
Thanks to all.
MeVII
EDIT
I changed
# 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 -= 255 if self.opacity > 0
else
self.opacity += 255 if self.opacity < 255
end
in Sprite_Battler to get the desired invis effect. But now actor attack animations are also transparent.
Any guidence?
The only thing I could think of are additional empty dummy sprites for the animations. :/
Try setting visible to false and resetting opacity. Maybe it works.
Nope ... darn.
Oh well, it wasn't important, just one of my on the fly ideas.
You always pop in to give me some tips! *powerup*
MeVII
I'm really rusty with RGSS, but here's a thought. Try making use of the @active_battler variable (or similar). Make the sprite visible if it's the active battler. I can't check this myself (RMXP not installed), but it's just a thought.
Hey, thanks for your input!
If your rusty, Im a pile of rust. It would take me a week to do what others do in an hr with scripting.
I understand your idea, to check for active, if active then visible, and visa versa. I just don't have a clue how to go about scripting it.
Im pretty good with events (http://forum.chaos-project.com/index.php/topic,2328.msg46660.html#msg46660), and brute force / grunt work (http://forum.chaos-project.com/index.php/topic,2386.msg48008.html#msg48008) but scripting language is more than I can process.
If anyone else wants to post the script as a favor its up to their generosity.
Thanks to all!
Me VII
class Scene_Battle
alias invibats_battle_update update
def update
invibats_battle_update
@spriteset.actor_sprites.each {|s| b = s.battler
next unless b.is_a?(Game_Actor)
if (@phase == 3 || @phase == 4)
s.target_opacity = (s.effect? || s.blink?) ? 256 : 0
else
s.target_opacity = 256
end
d = (s.target_opacity - s.opacity) / 4
s.opacity += d unless s.opacity == s.target_opacity
}
end
end
class Sprite_Battler
attr_accessor :target_opacity
alias invibats_sprite_battler_init initialize
def initialize(*args)
invibats_sprite_battler_init(*args)
@target_opacity = self.opacity
end
end
class Spriteset_Battle
attr_reader :actor_sprites
end
Okay, this is not perfect, but it works. I made an assumption to make this really simple: Whatever's being animated is doing something. Basing on this, I made the sprites visible or otherwise. Of course, all this applies only to actors and not enemies. Problems I observed are as follows:
1. During the time it takes to fade in, some of the animation is missed.
2. When an actor takes damage, there are two animations: the actor getting hit, and the damage popup. There's a gap between these two effects and the actor sprite tries to become invisible in-between.
Based on the way this works, there might be other undesirable "phenomenon". Why did I go for the shortcut? Well, I don't know enough about the battle system to make a properly implemented system. I tried, but I couldn't get it done. You could say that I'm too lazy to study the system in detail, but this is as far as I'm willing to go as of this time period, I apologize for that.
If you want any more edits for this, let me know.
Quote from: Fantasist on February 16, 2010, 07:23:07 am
You could say that I'm too lazy to study the system in detail, but this is as far as I'm willing to go as of this time period, I apologize for that.
You take your time to make me a custom script on request ... and then apoligize? ;) No need my friend, no need. Thanks alot!
Im up to my ears in data entry, when I swim outta that, Ill get to script configurations. Ill definitely see how this works.
Quote
If you want any more edits for this, let me know.
For right now, based off of your description, I have some questions/input. Pay it no personal attention, I
always have questions.

QuoteI made an assumption to make this really simple: Whatever's being animated is doing something...Of course, all this applies only to actors and not enemies.
Perfect.

Quote1. During the time it takes to fade in, some of the animation is missed.
Can you ditch the fade IN, but keep the fade out? If not, trash the whole fade idea then, its not worth the hassel or missing animations.
Quote2. When an actor takes damage, there are two animations: the actor getting hit, and the damage popup. There's a gap between these two effects and the actor sprite tries to become invisible in-between.
Can you fix this by telling it to "Fade in, after animation stops, wait 1 second, is the same object still being animated? Then do not fade out. Is the same object no longer being animated? Then fade out." ???
QuoteBased on the way this works, there might be other undesirable "phenomenon".
Do all the actors become visible for "screen" animations? Things that affect all players?
Again, I'm quite always off from script configuring in my RPG, so you can put this on your back, back burner.
Quote from: MeVII on February 01, 2010, 11:03:46 am
If anyone else wants to post the script as a favor its up to their generosity.
Thanks for your generosity! *powerup*
MeVII
QuoteCan you ditch the fade IN, but keep the fade out? If not, trash the whole fade idea then, its not worth the hassel or missing animations.
Could be done, I guess. But I've made the fade speed fast, so you should only miss a tiny part and still have some finesse.
QuoteCan you fix this by telling it to "Fade in, after animation stops, wait 1 second, is the same object still being animated? Then do not fade out. Is the same object no longer being animated? Then fade out." ???
It can be done but it's not by far ideal. It's a hassle to implement and it's just not the right way of doing it. The right way is to implement it into the battle system.
QuoteDo all the actors become visible for "screen" animations? Things that affect all players?
...good question ^_^'
Have you tried this btw? It's not that bad. The only way to do this properly is to do it right. I might get around it too (possible, but not likely).
Quote from: Fantasist on February 17, 2010, 07:10:03 am
QuoteDo all the actors become visible for "screen" animations? Things that affect all players?
...good question ^_^'
Have you tried this btw? It's not that bad. The only way to do this properly is to do it right. I might get around it too (possible, but not likely).
I took the time to look at this today. The worst thing about it (and by that, I mean insignificant) is that the image to animation is slightly "clippy". As in, the image is gone before you really "feel" done looking at it.
I like it, and will use it as is, baring really bad anomalys were not predicting.
Only one request, just in case the player loathes it, can it be disabled with a script call function in an event?
Thanks again, and every time!
Me VII
Sure, it can be disabled. Let me come up with the next iteration in the next post.
Excellent! Lookin forward to the edit!
Hey, I took that same personality test myself last year sometime. :) Here it is.
(http://badges.mypersonality.info/badge/0/12/121293.png) (http://mevii.mypersonality.info)
MeVII
How about that, you're more eligible to take up scripting than I am :D (being a thinker and all that)
Anyway, I made the proper version which should work much better:
class Sprite_Battler
attr_accessor :target_opacity
alias invibats_sprite_battler_init initialize
def initialize(*args)
invibats_sprite_battler_init(*args)
@target_opacity = self.opacity
end
alias invibats_sprite_battler_upd update
def update
invibats_sprite_battler_upd
if $game_system.invibats
if self.battler && self.battler.is_a?(Game_Actor) && fading?
d = (self.target_opacity - self.opacity) / 2
if (self.target_opacity - self.opacity).abs <= 16
self.opacity = self.target_opacity
else
self.opacity += d
end
end
if @battler.hideme
self.target_opacity = 0
end
if !@battler.hideme
self.target_opacity = 255 unless @battler.hidden || @battler.dead?
end
end
end
def fading?
return self.opacity != self.target_opacity
end
end
class Game_System
attr_accessor :invibats
alias invibats_game_temp_init initialize
def initialize
invibats_game_temp_init
@invibats = true
end
end
class Game_Battler
attr_accessor :hideme
alias invibats_game_battler_init initialize
def initialize
invibats_game_battler_init
@hideme = false
end
alias invibats_game_battler_slip_damage_effect slip_damage_effect
def slip_damage_effect
invibats_game_battler_slip_damage_effect
self.hideme = false if $game_system.invibats
end
end
class Scene_Battle
alias invibats_scene_battle_start_phase3 start_phase3
def start_phase3
$game_party.actors.each {|actor| actor.hideme = true}
invibats_scene_battle_start_phase3
end
alias invibats_scene_battle_start_phase1 start_phase1
def start_phase1
$game_party.actors.each {|actor| actor.hideme = false}
invibats_scene_battle_start_phase1
end
alias invibats_scene_battle_start_phase2 start_phase2
def start_phase2
$game_party.actors.each {|actor| actor.hideme = false}
invibats_scene_battle_start_phase2
end
alias invibats_scene_battle_start_phase5 start_phase5
def start_phase5
$game_party.actors.each {|actor| actor.hideme = false}
invibats_scene_battle_start_phase5
end
alias invibats_upd_phase3_actor_select update_phase3_actor_select
def update_phase3_actor_select
invibats_upd_phase3_actor_select
$game_party.actors.each_with_index {|actor, index|
if actor == @active_battler
actor.hideme = false
elsif @actor_arrow && index == @actor_arrow.index
actor.hideme = false
else
actor.hideme = true
end
}
end
def phase3_next_actor
# Loop
begin
# Actor blink effect OFF
if @active_battler != nil
@active_battler.blink = false
@active_battler.hideme = true
end
# If last actor
if @actor_index == $game_party.actors.size-1
# Start main phase
start_phase4
return
end
# Advance actor index
@actor_index += 1
@active_battler = $game_party.actors[@actor_index]
@active_battler.blink = true
@active_battler.hideme = false
# Once more if actor refuses command input
end until @active_battler.inputable?
# Set up actor command window
phase3_setup_command_window
end
#--------------------------------------------------------------------------
# * Go to Command Input of Previous Actor
#--------------------------------------------------------------------------
def phase3_prior_actor
# Loop
begin
# Actor blink effect OFF
if @active_battler != nil
@active_battler.blink = false
@active_battler.hideme = true
end
# If first actor
if @actor_index == 0
# Start party command phase
start_phase2
return
end
# Return to actor index
@actor_index -= 1
@active_battler = $game_party.actors[@actor_index]
@active_battler.blink = true
@active_battler.hideme = false
# Once more if actor refuses command input
end until @active_battler.inputable?
# Set up actor command window
phase3_setup_command_window
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
$game_party.actors.each {|actor| actor.hideme = true}
if @active_battler.is_a?(Game_Actor)
@active_battler.hideme = false
end
# Animation for action performer (if ID is 0, then white flash)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# Shift to step 4
@phase4_step = 4
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 4 : animation for target)
#--------------------------------------------------------------------------
def update_phase4_step4
# Animation for target
for target in @target_battlers
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
if target.is_a?(Game_Actor)
target.hideme = false
end
end
# Animation has at least 8 frames, regardless of its length
@wait_count = 8
# Shift to step 5
@phase4_step = 5
end
end
...is the name too bad? I think so >.< btw, this might corrupt old savegames (I wonder if this applies to you anyway).
Quote from: Fantasist on February 18, 2010, 01:03:03 pm
How about that, you're more eligible to take up scripting than I am :D (being a thinker and all that).
Im a systematic creative analyst, yes. However, I am also spacial, visual, dyslexic and in large part a overly "big picture" planer (instead of linear) thinker. So, things like code, algebra, geometry proofs, calculus ... anything formulaic in nature, is very hard for me to learn on my own. Id need a personal teacher to go over things with me point by point, answering my 100 questions for each step before I learned at any significant rate at all.
Which brings me to a question, if you wouldn't mind, could you please tell me exactly what the event script call string is to disable and enable the script? I know its $game...something. :shy:
QuoteAnyway, I made the proper version which should work much better:
Holy cow! You totally overhauled the thing, it quadrupled in size! Thanks 10x fold! *powerup*
Quote...is the name too bad? I think so >.< btw, this might corrupt old savegames (I wonder if this applies to you anyway).
Name? I call it "Battle Actor Image Fade". As for saved games, dosent effect me, aint that far in my game yet.
MeVII
QuoteWhich brings me to a question, if you wouldn't mind, could you please tell me exactly what the event script call string is to disable and enable the script? I know its $game...something.
I can swear I typed it down o_O Anyway, it's:
$game_system.invibats = true # enable
$game_system.invibats = false # disable
QuoteHoly cow! You totally overhauled the thing, it quadrupled in size! Thanks 10x fold! *powerup*
Thanks :) But I'm sure it can be done in a better way, I still don't think it's ideal. But it's close.
QuoteName? I call it "Battle Actor Image Fade".
Heh, much better!
o.o This has got to be the best and the most formal thread summary EVER! lol! *powers up*
QuoteConsidering hes "retired", and didnt/dosent even have RPGXP installed.
lol, I installed RMXP! I couldn't have done it off the top of my head!
Quote from: Fantasist on February 20, 2010, 01:56:05 am
I installed RMXP! I couldn't have done it off the top of my head!
Edited main post.
Changed -
QuoteConsidering hes "retired", and didnt/dosent even have RPGXP installed.
To -
QuoteConsidering he was "retired", and reinstalled RPGXP ... just to make my requested script.
Im tempted to toss out another powerup for that (Reinstalling just to work on a script request.), and I would, but I dont want to get scolded for getting "carried away".
MeVII
!Critical Update!
(Below is only updated version info. See main post for full script.)
#############################################################################
# -------------------------- Version Info ----------------------------------#
# v1.2 Critical Error Fix Mar 4 - 2010 #
# 239 Lines of Code #
# The critical error in 1.1 was corrected. #
# Game no longer crashes if all four actors are not present in battle. #
# #
# v1.1 Total Overhaul Feb 18 - 2010 #
# 195 Lines of Code #
# Added Ability to Enable and Disable Script In-Game with Events #
# Script Issues #
# If all four actors were not present, a critical error occurs. #
# Script'---Battle Actor Image Fade'line 67:NoMethodError occured. #
# undefined method `hideme' for nil:NilClass #
# #
#############################################################################
Thread Summary:
I asked for a script to fade out battler images when actors were not the visual focus.
Fantasist made a script, and then improved on it.
Later a critical error was noticed, and Fantasist corrected the issue.
For convenience sake I have updated my main post with the most recent/final script,
and added PreCode Text Information to the script.
I would like to thank Fantasist for taking the time to make this requested script.
Considering hes "retired", and didnt/dosent even have RPGXP installed.
The script works very well, and I really like the visual feel of how this moves your focus to the action.
So, thanks again Fantasist and *powerup*!
MeVII