Hi im having a problem. I want to create a script that makes that the music isnt restarted after combat. For that for now im trying to store the map song position and then play it again and seek it to the saved position.
But that donts works. For some reason i can seek a file that i just created a line above. But i created a event in map that seeks it and works fine. The start argument also donts seems to work.´
As a example i post the test script. I was adapting other scritp to here. For now i was testing a scape routine. Like this it dont sounds when entering again the map.
class Scene_Map
alias fmodex_old_map_call_battle call_battle
def call_battle
p "vasm", Audio['bgm'].position
$game_temp.map_bgm_pos = Audio['bgm'].position
fmodex_old_map_call_battle
end
end
class Game_Temp
attr_accessor :map_bgm_pos
attr_accessor :from_battle
alias :fmodex_old_temp_initialize :initialize unless $@
def initialize
fmodex_old_temp_initialize
@map_bgm_pos = 0
@from_battle = false
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# * Frame Update (party command phase: escape)
#--------------------------------------------------------------------------
def update_phase2_escape
# Calculate enemy agility average
enemies_agi = 0
enemies_number = 0
for enemy in $game_troop.enemies
if enemy.exist?
enemies_agi += enemy.agi
enemies_number += 1
end
end
if enemies_number > 0
enemies_agi /= enemies_number
end
# Calculate actor agility average
actors_agi = 0
actors_number = 0
for actor in $game_party.actors
if actor.exist?
actors_agi += actor.agi
actors_number += 1
end
end
if actors_number > 0
actors_agi /= actors_number
end
# Determine if escape is successful
success = rand(100) < 50 * actors_agi / enemies_agi
# If escape is successful
if success
# Play escape SE
p "escape mode"
$game_system.se_play($data_system.escape_se)
$game_temp.from_battle = false
Audio.bgm_play($game_temp.map_bgm.name, 100, 100, $game_temp.map_bgm_pos)
# Battle ends
battle_end(1)
# If escape is failure
else
# Clear all party member actions
$game_party.clear_actions
# Start main phase
start_phase4
end
end
end