Change battleback during battle

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I've tried the usual Change Battleback command, and that didn't work.
Can this be done using event commands or will I need a snippet?

Thanks.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
yes and no

the event command changes the setting for the map, that is why it doesn't work during battle.
However I once read a post here that there is a script command to force the battlescreen to update the battleback at any time from the then-current map setting.

So that way you'll need both - the event command to set the new battleback and the script command to force the update.

Unfortunately I don't remember the script command myself, but someone around here should be able to find the old post for it...
 
  • Like
Reactions: Kes

Faye Valentine

The Mapgician
Veteran
Joined
May 2, 2014
Messages
471
Reaction score
427
First Language
Spanish
Primarily Uses
RMVXA
Searched. Found an Archeia post. I'll quote it:
Feb 12, 2014
There is a way. In troops tab:

Change Battleback to your desired graphic.

Script Call: SceneManager.scene.refresh_battleback

This will only work if you play in-game from Map -> Battle and not in test play.
Might as well try this?
 
  • Like
Reactions: Kes

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Refresh battleback doesn't exist. Try this instead (which again, I'm too lazy to test)
Code:
spriteset = SceneManager.scene.instance_variable_get("@spriteset")
spriteset.dispose_battleback1
spriteset.dispose_battleback2
spriteset.create_battleback1
spriteset.create_battleback2
 
  • Like
Reactions: Kes

Faye Valentine

The Mapgician
Veteran
Joined
May 2, 2014
Messages
471
Reaction score
427
First Language
Spanish
Primarily Uses
RMVXA
@TheoAllen: tested, it's not working. Tested under standard parameters (blank project)

Archeia script is working. Tested. Only in-game, though. Game crash on troops testing.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@TheoAllen and @Faye Valentine
I tried both ways.
With Archeia's method I got a crash with the error message
undefine method 'refresh battleback'

With TheoAllen's code in the script call, however, it worked like a charm.

Thank you both very much for your help with this.
I shall keep the thread open for a little while in case some oddity creeps out of the woodwork, but I'm hopeful that all will now be well.
 

Faye Valentine

The Mapgician
Veteran
Joined
May 2, 2014
Messages
471
Reaction score
427
First Language
Spanish
Primarily Uses
RMVXA
@Kes: wow funny thing. I tested it in a blank project, but straight on the game and it showed no crash message whereas theo's crashed, both in-game and on troops tab. Well, glad you found a working solution, mate.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
@Faye Valentine I was going to reply u that I don't believe, but it's Kes that has the problem so I shrugged in the end.
What was the crash though? Those are really default script function, while "refresh_battleback" was never in default script.
It's funny it's working in your side actually.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Using @TheoAllen 's code I got a script to work.
Ruby:
# Change Battle background with a spell
# Created by Roninator2
# Version 1.0
# free for commercial use

# How to use
# Name the graphic files whatever name you specify in the Filename below
# and numbered, with the second battleback with an a at the end.
# e.g.
# SpellBG1.png <- battleback 1
# SpellBG1a.png <- battleback 2
# SpellBG2.png <- battleback 1
# SpellBG2a.png <- battleback 2
# SpellBG3.png <- battleback 1
# SpellBG3a.png <- battleback 2

# files must be present even if they are empty
# then have the spell with the notetag <change_bbg: 1>

# it does not restore the original battleback if no battleback is
# setup before the battle starts. *You get the swirl image of the map.

module R2_change_bbg_by_skill
  Regex = /<change_bbg:[ ](\d+)>/i
  Filename = "SpellBG"
end

class Scene_Battle < Scene_Base
  alias r2_use_item_skill_bg    use_item
  def use_item
    r2_use_item_skill_bg
    item = @subject.current_action.item
    @setbg = false
    if item.is_a?(RPG::Skill) && item.note.split(/[\r\n]+/).each { |line|
      case line
      when R2_change_bbg_by_skill::Regex
        @bgnum = $1.to_i
        @setbg = true
      end
      }
    end
    if @original_bg1 == nil
      @original_bg1 = $game_map.battleback1_name
      @original_bg2 = $game_map.battleback2_name
    end
    if @setbg == true
      bbgimage = R2_change_bbg_by_skill::Filename.to_s
      spellbg1 = bbgimage.to_s + @bgnum.to_s
      spellbg2 = bbgimage.to_s + @bgnum.to_s + "a"
      Graphics.freeze
      $game_map.change_battleback(spellbg1, spellbg2)
      spriteset = SceneManager.scene.instance_variable_get("@spriteset")
      spriteset.dispose_battleback1
      spriteset.dispose_battleback2
      spriteset.create_battleback1
      spriteset.create_battleback2
      Graphics.transition(60)
    end
  end
  alias r2_terminate_bg   terminate
  def terminate
    r2_terminate_bg
    $game_map.change_battleback(@original_bg1, @original_bg2)
    @original_bg1 = nil
  end
end
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top