RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RESOLVED] Script Modification: DerWulfman's Actor Battler Script

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 66
~RTP Princess~
Okay, so I found this script for adding an actor battler to the battle scene but there's something that I need help with. How do I make it refresh/check if the actor has changed?
I'm using KGC's LargeParty script so that you can swap characters in battle (this happens before your turn, during the Fight/Auto/Escape phase). As it stands, when I change character the same portrait show up every time.

I'd like it to refresh before your turn, or ideally after you switch party members. Any ideas?

Code: [Select]
#==============================================================================
# ** Actor_Battler Module
#------------------------------------------------------------------------------
# A module containing configurable data for the Actor Battler Graphic system.
#==============================================================================

module Actor_Battler
# Actor battler array
ACTOR = Array.new # Do not touch -_^

#========================================================================
# ** C O N F I G U R A T I O N S Y S T E M ** #
#========================================================================

# --Positioning--
# Actor Battler positioning system
#
CENTER_X = true # If true, centers actors rather than default lineup.
DEFAULT_X = 8 # Default party Max
SCREEN_Y = 400 # Vertical height of battlers
SCREEN_X = 0 # Vertical height of battlers
TRANSPARENT = false # If true, makes lightly transparent until attacking.


# --Actor List--
# Add your actor battlers here
#
# Actor# Filename, Hue (optional)
ACTOR[1] = ["Battle - Sorionne"]
ACTOR[2] = ["Battle - Denn"]
ACTOR[3] = ["Battle - Vila", 0]
ACTOR[4] = ["Battle - Lourne", 0]
ACTOR[5] = ["Battle - Orcas", 0]
ACTOR[6] = ["Battle - Mielle", 0]
ACTOR[7] = ["Battle - Hellem", 0]
ACTOR[8] = ["Battle - Ruon", 0]


#========================================================================
# ** E N D O F C O N F I G U R A T I O N ** #
#========================================================================
end



#==============================================================================
# ** RPG Module
#------------------------------------------------------------------------------
# A module containing RPGVX Data Structures.
#==============================================================================
module RPG
#============================================================================
# ** Actor
#----------------------------------------------------------------------------
# Data class for actors
#============================================================================
class Actor
#------------------------------------------------------------------------
# * Alias Listings
#------------------------------------------------------------------------
alias actorbattler_init initialize
#------------------------------------------------------------------------
# * Object Initialization
#------------------------------------------------------------------------
def initialize
# Perform the original call
actorbattler_init
@battler_name = ""
@battler_hue = 0
end
end
end



#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#==============================================================================

class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battle_main_phase # battle flag: main phase
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias actorbattler_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Perform the original call
actorbattler_initialize
# Set the main phase flag to false
@battle_main_phase = false
end
end



#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================

class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :actorbattler_max # Max. size for centered battlers
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias actorbattler_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Perform the original call
actorbattler_initialize
# Set 'Centered' battler max to 4 (default)
@actorbattler_max = Actor_Battler::DEFAULT_X
end
end



#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :screen_x # battle screen X coordinate
attr_accessor :screen_y # battle screen Y coordinate
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias actorbattler_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
# actor_id : actor ID
#--------------------------------------------------------------------------
def initialize(actor_id)
# Perform the original call
actorbattler_init(actor_id)
# Apply battler graphic
@battler_name = Actor_Battler::ACTOR[actor_id][0]
# Apply battler hue if exists, else default of '0'
if Actor_Battler::ACTOR[actor_id][1] != nil
@battler_hue = Actor_Battler::ACTOR[actor_id][1]
else
@battler_hue = 0
end
end
#--------------------------------------------------------------------------
# * Change Battler
# battler_name : new battler graphic filename
# battler_hue : new battler hue setting (default = 0)
#--------------------------------------------------------------------------
def set_battler(battler_name = "", battler_hue = 0)
@battler_name = battler_name
@battler_hue = battler_hue
end
#--------------------------------------------------------------------------
# * Use Sprites?
#--------------------------------------------------------------------------
def use_sprite?
return true
end
#--------------------------------------------------------------------------
# * Get Battle Screen X-Coordinate
#--------------------------------------------------------------------------
def screen_x
return Actor_Battler::SCREEN_X
end
#--------------------------------------------------------------------------
# * Get Battle Screen Y-Coordinate
#--------------------------------------------------------------------------
def screen_y
return Actor_Battler::SCREEN_Y
end
#--------------------------------------------------------------------------
# * Get Battle Screen Z-Coordinate
#--------------------------------------------------------------------------
def screen_z
# Return after calculating z-coordinate by order of members in party
if self.index != nil
return $game_party.members.size - self.index
else
return 0
end
end
end



#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
# This sprite is used to display battlers. It observes a instance of the
# Game_Battler class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias actorbattler_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Perform the original call
actorbattler_update
# If the actor battlers are lightly transparent until they act
if Actor_Battler::TRANSPARENT == true
# If the battler is a visible actor battler
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
end
end
end



#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================

class Spriteset_Battle
#--------------------------------------------------------------------------
# * Create Actor Sprite
# Removes the 'empty' battler image used by the default system and
# replaces it. It also observes the actual size of the party and
# not a predetermined 4-party limit.
#--------------------------------------------------------------------------
def create_actors
@actor_sprites = []
for actor in $game_party.members.reverse
@actor_sprites.push(Sprite_Battler.new(@viewport2, actor))
end
end
#--------------------------------------------------------------------------
# * Update Actor Sprite
#--------------------------------------------------------------------------
def update_actors
# Reset actor battler sprites if party size increases
if $game_party.members.size > @actor_sprites.size
dispose_actors
create_actors
end
for sprite in @actor_sprites
sprite.update
end
end
end



#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias actorbattler_s start
alias actorbattler_spcs start_party_command_selection
alias actorbattler_pv process_victory
alias actorbattler_ea execute_action
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
actorbattler_s
$game_temp.battle_main_phase = false
end
#--------------------------------------------------------------------------
# * Start party command selection
#--------------------------------------------------------------------------
def start_party_command_selection
actorbattler_spcs
if $game_temp.in_battle
$game_temp.battle_main_phase = false
end
end
#--------------------------------------------------------------------------
# * Victory Processing
#--------------------------------------------------------------------------
def process_victory
$game_temp.battle_main_phase = false
actorbattler_pv
end
#--------------------------------------------------------------------------
# * Start Execution of Battle Processing
#--------------------------------------------------------------------------
def execute_action
actorbattler_ea
$game_temp.battle_main_phase = true
end
end

I already tried adding the code below under the "class Spriteset_Battle part of the script but it didn't work.
Code: [Select]
alias actorbattler_spriteset_update update
def update
  # Perform the original call
  actorbattler_spriteset_update
  update_actors
end

Any help would be greatly appreciated!

« Last Edit: October 01, 2011, 03:19:31 AM by littlesatyr »



*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
The @actor_sprites variable is an array holding instances of the Sprite_Battler class. This means both @actor_sprites and $game_party.members hold instances of actors somewhere within them. That means we can compare the two arrays using them. I would create a new array holding only the actors of the battler sprites, then compare that to $game_party.members.
Code: [Select]
a = []
for sprite in @actor_sprites
  a.push(sprite.battler)
end
if a != $game_party.members
dispose_actors
create_actors
And you could work that into the update_actors method like so.
Code: [Select]
def update_actors
  a = []
  for sprite in @actor_sprites
    a.push(sprite.battler)
  end
  if a != $game_party.members or $game_party.members.size > @actor_sprites.size
    dispose_actors
    create_actors
  end
  for sprite in @actor_sprites
    sprite.update
  end
end
That should do the trick. I didn't test it, and I'm scripting blind.
it's like a metaphor or something i don't know

**
Rep:
Level 66
~RTP Princess~
OMG!

Pacman, you are so amazing and awesome! I don't even have the words! Thank you so, so much! I've been looking for a solution to this for a while now and it's been driving me bonkers! It works perfectly, by the way. ;P

Thank you! Thank you! Thank you!
(I am so happy right now! ^.^)



*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Oh, I'm glad it worked. You're very welcome, I'm always willing to help out with a little code, given I have the time.
it's like a metaphor or something i don't know