Is there any way to change music and/or battleback during a battle?
Thanks.
Music and background battle changing during battle
● ARCHIVED · READ-ONLY
-
-
Of course there is it, you can do that via Event Page on the Troop Database.
For BGM you just need to fadeout it and give wait time(so it changed seamlessly, hopefully), then give Play BGM.
For Battleback isn't it obvious? You can just change battleback too. However I think there's a bit problem, I found out that it can't change the battleback, after looking for a while, I found out some culprit
#-------------------------------------------------------------------------- # * Change Battle Background #-------------------------------------------------------------------------- def command_283 $game_map.change_battleback(@params[0], @params[1]) endThat indeed changing the battleback, but it's not do it right now, it kinda like set a new different battleback(if you know what I mean).
Now I try to tweak it a bit, hopefully it does not crash with anything.
Paste this code below in a new slot script
class Game_Interpreter alias john_leagsburg_command283 :command_283 def command_283 if SceneManager.scene.is_a?(Scene_Battle) SceneManager.scene.spriteset.dispose_battleback1 SceneManager.scene.spriteset.dispose_battleback2 $game_map.change_battleback(@params[0], @params[1]) SceneManager.scene.spriteset.create_battleback1 SceneManager.scene.spriteset.create_battleback2 else john_leagsburg_command283 end end end # End of Game_InterpreterHope it helps you. -
Yeah, I wondered why it didn't, but your script isn't fixing it? it still doesn't change :/ for OP, I can do a video, but after that battleback thing is fixed because I think he wants to change battleback also.Of course there is it, you can do that via Event Page on the Troop Database.
For BGM you just need to fadeout it and give wait time(so it changed seamlessly, hopefully), then give Play BGM.
For Battleback isn't it obvious? You can just change battleback too. However I think there's a bit problem, I found out that it can't change the battleback, after looking for a while, I found out some culprit
#-------------------------------------------------------------------------- # * Change Battle Background #-------------------------------------------------------------------------- def command_283 $game_map.change_battleback(@params[0], @params[1]) endThat indeed changing the battleback, but it's not do it right now, it kinda like set a new different battleback(if you know what I mean).
Now I try to tweak it a bit, hopefully it does not crash with anything.
Paste this code below in a new slot script
class Game_Interpreter alias john_leagsburg_command283 :command_283 def command_283 if SceneManager.scene.is_a?(Scene_Battle) SceneManager.scene.spriteset.dispose_battleback1 SceneManager.scene.spriteset.dispose_battleback2 $game_map.change_battleback(@params[0], @params[1]) SceneManager.scene.spriteset.create_battleback1 SceneManager.scene.spriteset.create_battleback2 else john_leagsburg_command283 end end end # End of Game_InterpreterHope it helps you. -
I almost really sure you test it in Battle Test, am I right? Try it in real game instead, if it's still not work then I would bang my head onto wall hahah XD.
-
I did in real, but when I did in a new project, it worked, weird because I positioned both below and above the scripts, so a script could be conflicting with it, which isn't good at all :/ I'll check what script it is and inform it here.I almost really sure you test it in Battle Test, am I right? Try it in real game instead, if it's still not work then I would bang my head onto wall hahah XD.
EDIT: It's Area Maps from Tsukihime, can you check why? it would be good if it's fixed because if I want to use it, and Area Maps is an important script for the project I am doing.
Here is the script:
Spoiler=begin#===============================================================================
Title: Area Maps
Author: Hime
Date: Mar 31, 2013
--------------------------------------------------------------------------------
** Change log
Mar 31
- All events are now local to each area. They will only update if the
player is in the area
Mar 17, 2013
- Initial release
--------------------------------------------------------------------------------
** Terms of Use
* Free to use in non-commercial projects
* Contact me for commercial use
* No real support. The script is provided as-is
* Will do bug fixes, but no compatibility patches
* Features may be requested but no guarantees, especially if it is non-trivial
* Credits to Hime Works in your project
* Preserve this header
--------------------------------------------------------------------------------
** Required
Connected Maps
http://himeworks.wordpress.com/2013/03/17/connected-maps/
--------------------------------------------------------------------------------
** Description
This is an add-on for Connected Maps. It allows you to treat each additional
map as a separate area, rather than simply an extension to the current map.
Each area has its own display name as well as list of encounters.
Areas can be useful if you want to divide a large map into multiple
different parts, while managing each part separately.
--------------------------------------------------------------------------------
** Usage
Place this script below Materials, below Connected Maps, and above main.
This script automatically converts any connected maps into an area map.
Area maps have the following properties
- display name
- encounter list
- encounter steps
- battlebacks
- bgm and bgs
Unfortunately, area maps use the same tileset as the current map
You can access the current area using a script call
$game_map.area
This will return a Game_Area object. You can get the area ID using
$game_map.area.id
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_AreaMaps"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
module Area_Maps
# All events are local to their own areas. They will only be updated
# if the player is in the area. You can turn this off.
Use_Area_Events = false
end
end
#===============================================================================
# ** Rest of script
#===============================================================================
#-------------------------------------------------------------------------------
# An area is a section of the map. It is really just another map, but you can
# have different encounters and a unique area name
#-------------------------------------------------------------------------------
class Game_Area
attr_reader :battleback1_name # battle background (floor) filename
attr_reader :battleback2_name # battle background (wall) filename
attr_reader :id # the idea of the area
attr_reader :x # position of the start of the area
attr_reader :y
def initialize(map_id, area_id, x, y)
@map_id = map_id
@id = area_id
@x = x
@y = y
setup
end
def setup
@map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
setup_battleback
end
def width
@map.width
end
def height
@map.height
end
def display_name
@map.display_name
end
def encounter_list
@map.encounter_list
end
def encounter_step
@map.encounter_step
end
def setup_battleback
if @map.specify_battleback
@battleback1_name = @map.battleback1_name
@battleback2_name = @map.battleback2_name
else
@battleback1_name = nil
@battleback2_name = nil
end
end
def autoplay
@map.bgm.play if @map.autoplay_bgm
@map.bgs.play if @map.autoplay_bgs
end
end
class Game_Map
attr_reader :areas
alias :th_area_maps_setup :setup
def setup(map_id)
@areas = [Game_Area.new(map_id, 1, 0, 0)]
@area = @areas[0]
@area_events = {}
th_area_maps_setup(map_id)
end
alias :th_area_maps_setup_events :setup_events
def setup_events
th_area_maps_setup_events
@area_events[1] = []
@events.each_value {|event| @area_events[1].push(event)}
end
#-----------------------------------------------------------------------------
# Treat the new map as an area
#-----------------------------------------------------------------------------
alias :th_area_maps_setup_connected_map :setup_connected_map
def setup_connected_map(map_id, ox, oy, offset_x, offset_y)
th_area_maps_setup_connected_map(map_id, ox, oy, offset_x, offset_y)
area_id = @areas.size + 1
area = Game_Area.new(map_id, area_id, ox + offset_x, oy + offset_y)
@areas.push(area)
end
#-----------------------------------------------------------------------------
# Store events in a hash indexed by area ID
#-----------------------------------------------------------------------------
alias :th_area_maps_setup_new_events :setup_new_events
def setup_new_events(events)
if TH::Area_Maps::Use_Area_Events
area_id = @areas.size
@area_events[area_id] = []
events.each do |i, event|
@events = Game_Event.new(@map_id, event)
@area_events[area_id].push(@events)
end
else
th_area_maps_setup_new_events(events)
end
end
#-----------------------------------------------------------------------------
# Update only events in the area.
#-----------------------------------------------------------------------------
alias :th_area_maps_update_events :update_events
def update_events
if TH::Area_Maps::Use_Area_Events
@area_events[@area.id].each {|event| event.update}
@common_events.each {|event| event.update }
else
th_area_maps_update_events
end
end
#-----------------------------------------------------------------------------
# Return the current area's display name
#-----------------------------------------------------------------------------
alias :th_area_maps_display_name :display_name
def display_name
@area ? @area.display_name : th_area_maps_display_name
end
#-----------------------------------------------------------------------------
# Encounters are retrieved from current area
#-----------------------------------------------------------------------------
alias :th_area_maps_encounter_list :encounter_list
def encounter_list
@area ? @area.encounter_list : th_area_maps_encounter_list
end
alias :th_area_maps_encounter_step :encounter_step
def encounter_step
@area ? @area.encounter_step : th_area_maps_encounter_step
end
alias :th_area_maps_battleback1_name :battleback1_name
def battleback1_name
@area ? @area.battleback1_name : th_area_maps_battleback1_name
end
alias :th_area_maps_battleback2_name :battleback2_name
def battleback2_name
@area ? @area.battleback2_name : th_area_maps_battleback2_name
end
alias :th_area_maps_setup_battleback :setup_battleback
def setup_battleback
@area ? @area.setup_battleback : th_area_maps_setup_battleback
end
alias :th_area_maps_autoplay :autoplay
def autoplay
@area ? @area.autoplay : th_area_maps_autoplay
end
#-----------------------------------------------------------------------------
# New. Return the player's current area.
#-----------------------------------------------------------------------------
def area(x=$game_player.x, y=$game_player.y)
new_area = @areas.reverse.detect {|area| x >= area.x && y >= area.y }
@area = new_area if @area != new_area
@area
end
end
class Scene_Map < Scene_Base
alias :th_area_maps_start :start
def start
th_area_maps_start
@area_id = $game_map.area.id
end
alias :th_area_maps_update :update
def update
if @area_id != $game_map.area.id
@map_name_window.open
$game_map.autoplay
end
@area_id = $game_map.area.id
th_area_maps_update
end
end
For the OP, I'll upload a video soon on how to do it. -
Oh blast it, does it mean I need to bang my head?
1. Did you using MogHunter script by any chance? or any script that messing with battleback thingy?
2. Try to CTRL+F+SHIFT and type def command_283. Is there any other script that messing with this method? -
Lol.Oh blast it, does it mean I need to bang my head?
1. Did you using MogHunter script by any chance? or any script that messing with battleback thingy?
2. Try to CTRL+F+SHIFT and type def command_283. Is there any other script that messing with this method?
1. The script that messes with the battleback is Area Maps from Tsukihime, as said above. Can you check it?
2. The script Area Maps doesn't have any def command_283.
OP: Here is the video showing how to do it, but you need the script from BoluBolu first: (Paste the code below in a new slot script)
Video:Spoilerclass Game_Interpreter
alias john_leagsburg_command283 :command_283
def command_283
if SceneManager.scene.is_a?(Scene_Battle)
SceneManager.scene.spriteset.dispose_battleback1
SceneManager.scene.spriteset.dispose_battleback2
$game_map.change_battleback(@params[0], @params[1])
SceneManager.scene.spriteset.create_battleback1
SceneManager.scene.spriteset.create_battleback2
else
john_leagsburg_command283
end
end
end # End of Game_Interpreter
-
I just tried BoluBolu's scriptlet, and it worked, however, for the next battle it keeps the changed backbattle, but don't worry, i shall change it after battle. Thanks by the way guys! :)
-
No need a long time to figure why it's not compatible with Tsukihime.
alias :th_area_maps_battleback1_name :battleback1_name def battleback1_name @area ? @area.battleback1_name : th_area_maps_battleback1_name end alias :th_area_maps_battleback2_name :battleback2_name def battleback2_name @area ? @area.battleback2_name : th_area_maps_battleback2_name endI don't blame Hime, I just want to show you why this not work with Hime, basically if you use this script feature, which divide per section of map by areas, the script will not look into the default battleback place(or what is the word?), it will create set a new variable called area which act like well mini map(or cloning map), and by that way they store their each battleback in a different places. Okay my english is getting bad right now.
Now here's a quick raw fix for if you want to preserve Hime but change the battleback is worked, but keep in mind this not the best because you know, to create a real best fix I need to learn Tsuki's script more and I don't think I will do it.
WARNING: This script is created very quickly not looking at efficiency nor impact, I just messing with it, should not distributed, and probably used(don't blame me if anything happen for using this script).
class Scene_Battle; attr_reader :spriteset;endclass Game_Map; attr_reader :area; end class Game_Areaattr_accessor :battleback1_name,:battleback2_name endclass Game_Interpreteralias john_leagsburg_command283 :command_283def command_283if SceneManager.scene.is_a?(Scene_Battle) battle_change_battlebackelse john_leagsburg_command283endenddef battle_change_battleback SceneManager.scene.spriteset.dispose_battleback1 SceneManager.scene.spriteset.dispose_battleback2 $game_map.area.battleback1_name = @params[0] $game_map.area.battleback2_name = @params[1] $game_map.th_area_maps_setup_battleback SceneManager.scene.spriteset.create_battleback1 SceneManager.scene.spriteset.create_battleback2 endend # End of Game_Interpreter
That will do what you want even you used Hime script, I don't really try it but I'm almost sure that it has a bad part, I could guess that all the area connected will changed it's battleback.to the battleback you specify.
Like John quote
But for this, this will change all the area battleback.I just tried BoluBolu's scriptlet, and it worked, however, for the next battle it keeps the changed backbattle, but don't worry, i shall change it after battle. Thanks by the way guys! :)
@John
Of course it keeps the changed backbattle, because that's been expected :) . If you try the normal without my script, you will find that it also keep the changed battleback, because like the name said Change Battleback, means change it! Not change it temporary ;D -
Hey guys actually I found something really interesting, the script I wrote first(the one that not work with Hime's) it should throw you an error, really. I missed something when try to copy it from the editor, now for save you from future headaches, I suggest use this script use this script instead.
Spoilerclass Scene_Battle; attr_reader :spriteset;end
class Game_Interpreter
alias john_leagsburg_command283 :command_283
def command_283
if SceneManager.scene.is_a?(Scene_Battle)
SceneManager.scene.spriteset.dispose_battleback1
SceneManager.scene.spriteset.dispose_battleback2
$game_map.change_battleback(@params[0], @params[1])
SceneManager.scene.spriteset.create_battleback1
SceneManager.scene.spriteset.create_battleback2
else
john_leagsburg_command283
end
end
end # End of Game_Interpreter
I'm really sorry for this inconvenience -___-"
Sorry for double post, I do this so both guys get a new notification. -
Hey guys actually I found something really interesting, the script I wrote first(the one that not work with Hime's) it should throw you an error, really. I missed something when try to copy it from the editor, now for save you from future headaches, I suggest use this script use this script instead.
Spoilerclass Scene_Battle; attr_reader :spriteset;end
class Game_Interpreter
alias john_leagsburg_command283 :command_283
def command_283
if SceneManager.scene.is_a?(Scene_Battle)
SceneManager.scene.spriteset.dispose_battleback1
SceneManager.scene.spriteset.dispose_battleback2
$game_map.change_battleback(@params[0], @params[1])
SceneManager.scene.spriteset.create_battleback1
SceneManager.scene.spriteset.create_battleback2
else
john_leagsburg_command283
end
end
end # End of Game_InterpreterInteresting it didn't throw us a error lol btw the youtube video's description will have your script, is that fine? I mention your name, you can check it out. (it is in post above)SpoilerI'm really sorry for this inconvenience -___-"
Sorry for double post, I do this so both guys get a new notification.
I guess this is solved then. -
Well wait, i tested this on a other game i use for testing pursoses, and i tried battle testing with a game with yanfly's battle system and ATB system, but the battleback changing didn't work.
-
That's what happened to me, that a script was actually disabling the default battleback, so if you provide the scripts and ask him, he might fix it for you.Well wait, i tested this on a other game i use for testing pursoses, and i tried battle testing with a game with yanfly's battle system and ATB system, but the battleback changing didn't work.
-
The Change Battleback command is used to change the background for the NEXT battle. You can't use it in the current battle to change the background immediately. That requires a script call or probably a script mod.
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
Although - it's been requested several times before. Did you do a search before posting? -
It's working fine with me, I'm using Yanfly's Battle Engine and Fomar's ATB and no problem, the bb still change in mid battle.Well wait, i tested this on a other game i use for testing pursoses, and i tried battle testing with a game with yanfly's battle system and ATB system, but the battleback changing didn't work.
-
Then i'm probably using Battleback Stretch script...i'm looking forward to fix by deleting this.
EDIT: Nope, that wasn't actually that. Oh wait, BoluBolu told me in PM that it doesn't work on battle test.
So thanks guys, now i can go back to work without problems. -
Maybe it's just that you need to save your game first. Playing your game asks you if you want to save or not first, and you should. If you don't save (which is what happens when you do battle test), none of your script mods or additions are active.