[RESOLVED] Cut Short Victory ME?

Started by WhiteRose, April 03, 2010, 04:57:32 pm

Previous topic - Next topic

WhiteRose

April 03, 2010, 04:57:32 pm Last Edit: April 03, 2010, 06:14:08 pm by Flower Lady WhiteRose
I don't think anyone has asked this before, but I'm sure that it's a fairly common problem.

What I want to happen is this: upon completion of a battle, the victory fanfare would play as normal. However, when the player presses the button and returns to the map, the victory ME should stop, and the map music should play. I've tried editing the standard scripts, and I've gotten the first part to work successfully (the victory music stopping when returning to the map,) but then the map music doesn't play as it should. Can anyone help me out? Thanks!
(Yes, this is for Doodle Quest. The demo's almost ready! Just have to tie up a few loose ends like this.)

Tyril132

I *think* you might be able to do this through the FMOD Ex Audio script, by Hiretsukan.
Lv. 7 Writer | Lv. 7 Composer | Lv. 7 Mapper | Lv. 4 Eventer | Lv. 0 Scripter | Lv. 1 Spriter
DSC Project Soundtrack
Personality Index:: ShowHide

(Hexamin)

what script are you using for battle results, just the standard?  i might be able to tweak it if i knew a bit more about your situation.  Audio.se_stop will stop the ME, and if you do it before the battle processing finishes, the bgm should pick back up on the map.  otherwise you should be able to have an autorun event that turns on the bgm again?
Max 1111101000; characters remaining: 1110111000

WhiteRose

Quote from: (Hexamin) on April 03, 2010, 05:24:16 pm
what script are you using for battle results, just the standard?  i might be able to tweak it if i knew a bit more about your situation.  Audio.se_stop will stop the ME, and if you do it before the battle processing finishes, the bgm should pick back up on the map.  otherwise you should be able to have an autorun event that turns on the bgm again?

Yeah, I'm just using the standard script. That's about the same as what I tried to do, but it's having these issues anyway. This really should be possible with just a minor tweak to the scripts, so I'd prefer to not have to use extra events or scripts, but I will if it turns out to be the only way. If you want to take a look at it, Hex, that'd be great. Tyril, thanks for the suggestion. If I can't get it working, I'll be sure to give that a try.

Tyril132

That's perfectly understandable. The only reason I suggested it is that I happen to be using it to set dynamic looping points for .ogg files for my project, and I noticed the ME skip > BGM restore functionality as a side-effect. Sorry I couldn't be of more assistance.
Lv. 7 Writer | Lv. 7 Composer | Lv. 7 Mapper | Lv. 4 Eventer | Lv. 0 Scripter | Lv. 1 Spriter
DSC Project Soundtrack
Personality Index:: ShowHide

(Hexamin)

April 03, 2010, 05:50:44 pm #5 Last Edit: April 03, 2010, 05:57:24 pm by (Hexamin)
Just replace Scene_Battle2 with this
Spoiler: ShowHide

#==============================================================================
# ** Scene_Battle (part 2)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
 #--------------------------------------------------------------------------
 # * Start Pre-Battle Phase
 #--------------------------------------------------------------------------
 def start_phase1
   # Shift to phase 1
   @phase = 1
   # Clear all party member actions
   $game_party.clear_actions
   # Set up battle event
   setup_battle_event
 end
 #--------------------------------------------------------------------------
 # * Frame Update (pre-battle phase)
 #--------------------------------------------------------------------------
 def update_phase1
   # Determine win/loss situation
   if judge
     # If won or lost: end method
     return
   end
   # Start party command phase
   start_phase2
 end
 #--------------------------------------------------------------------------
 # * Start Party Command Phase
 #--------------------------------------------------------------------------
 def start_phase2
   # Shift to phase 2
   @phase = 2
   # Set actor to non-selecting
   @actor_index = -1
   @active_battler = nil
   # Enable party command window
   @party_command_window.active = true
   @party_command_window.visible = true
   # Disable actor command window
   @actor_command_window.active = false
   @actor_command_window.visible = false
   # Clear main phase flag
   $game_temp.battle_main_phase = false
   # Clear all party member actions
   $game_party.clear_actions
   # If impossible to input command
   unless $game_party.inputable?
     # Start main phase
     start_phase4
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (party command phase)
 #--------------------------------------------------------------------------
 def update_phase2
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by party command window cursor position
     case @party_command_window.index
     when 0  # fight
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Start actor command phase
       start_phase3
     when 1  # escape
       # If it's not possible to escape
       if $game_temp.battle_can_escape == false
         # Play buzzer SE
         $game_system.se_play($data_system.buzzer_se)
         return
       end
       # Play decision SE
       $game_system.se_play($data_system.decision_se)
       # Escape processing
       update_phase2_escape
     end
     return
   end
 end
 #--------------------------------------------------------------------------
 # * 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
     $game_system.se_play($data_system.escape_se)
     # Return to BGM before battle started
     $game_system.bgm_play($game_temp.map_bgm)
     # 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
 #--------------------------------------------------------------------------
 # * Start After Battle Phase
 #--------------------------------------------------------------------------
 def start_phase5
   # Shift to phase 5
   @phase = 5
   # Play battle end ME
   $game_system.me_play($game_system.battle_end_me)
   # Return to BGM before battle started
   $game_system.bgm_play($game_temp.map_bgm)
   # Initialize EXP, amount of gold, and treasure
   exp = 0
   gold = 0
   treasures = []
   # Loop
   for enemy in $game_troop.enemies
     # If enemy is not hidden
     unless enemy.hidden
       # Add EXP and amount of gold obtained
       exp += enemy.exp
       gold += enemy.gold
       # Determine if treasure appears
       if rand(100) < enemy.treasure_prob
         if enemy.item_id > 0
           treasures.push($data_items[enemy.item_id])
         end
         if enemy.weapon_id > 0
           treasures.push($data_weapons[enemy.weapon_id])
         end
         if enemy.armor_id > 0
           treasures.push($data_armors[enemy.armor_id])
         end
       end
     end
   end
   # Treasure is limited to a maximum of 6 items
   treasures = treasures[0..5]
   # Obtaining EXP
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     if actor.cant_get_exp? == false
       last_level = actor.level
       actor.exp += exp
       if actor.level > last_level
         @status_window.level_up(i)
       end
     end
   end
   # Obtaining gold
   $game_party.gain_gold(gold)
   # Obtaining treasure
   for item in treasures
     case item
     when RPG::Item
       $game_party.gain_item(item.id, 1)
     when RPG::Weapon
       $game_party.gain_weapon(item.id, 1)
     when RPG::Armor
       $game_party.gain_armor(item.id, 1)
     end
   end
   # Make battle result window
   @result_window = Window_BattleResult.new(exp, gold, treasures)
   # Set wait count
   @phase5_wait_count = 1
 end
 #--------------------------------------------------------------------------
 # * Frame Update (after battle phase)
 #--------------------------------------------------------------------------
 def update_phase5
   # If wait count is larger than 0
   if @phase5_wait_count > 0
     # Decrease wait count
     @phase5_wait_count -= 1
     # If wait count reaches 0
     if @phase5_wait_count == 0
       # Show result window
       @result_window.visible = true
       # Clear main phase flag
       $game_temp.battle_main_phase = false
       # Refresh status window
       @status_window.refresh
     end
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Battle ends
     Audio.me_stop
     battle_end(0)
   end
 end
end



That worked for me.  You do have auto-bgm on your map, right?
Max 1111101000; characters remaining: 1110111000

WhiteRose

Quote from: (Hexamin) on April 03, 2010, 05:50:44 pm
Just replace Scene_Battle2 with this
Spoiler: ShowHide

[code]#==============================================================================
# ** Scene_Battle (part 2)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Start Pre-Battle Phase
  #--------------------------------------------------------------------------
  def start_phase1
    # Shift to phase 1
    @phase = 1
    # Clear all party member actions
    $game_party.clear_actions
    # Set up battle event
    setup_battle_event
  end
  #--------------------------------------------------------------------------
  # * Frame Update (pre-battle phase)
  #--------------------------------------------------------------------------
  def update_phase1
    # Determine win/loss situation
    if judge
      # If won or lost: end method
      return
    end
    # Start party command phase
    start_phase2
  end
  #--------------------------------------------------------------------------
  # * Start Party Command Phase
  #--------------------------------------------------------------------------
  def start_phase2
    # Shift to phase 2
    @phase = 2
    # Set actor to non-selecting
    @actor_index = -1
    @active_battler = nil
    # Enable party command window
    @party_command_window.active = true
    @party_command_window.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # Clear main phase flag
    $game_temp.battle_main_phase = false
    # Clear all party member actions
    $game_party.clear_actions
    # If impossible to input command
    unless $game_party.inputable?
      # Start main phase
      start_phase4
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (party command phase)
  #--------------------------------------------------------------------------
  def update_phase2
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by party command window cursor position
      case @party_command_window.index
      when 0  # fight
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Start actor command phase
        start_phase3
      when 1  # escape
        # If it's not possible to escape
        if $game_temp.battle_can_escape == false
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Escape processing
        update_phase2_escape
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * 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
      $game_system.se_play($data_system.escape_se)
      # Return to BGM before battle started
      $game_system.bgm_play($game_temp.map_bgm)
      # 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
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    # Shift to phase 5
    @phase = 5
    # Play battle end ME
    $game_system.me_play($game_system.battle_end_me)
    # Return to BGM before battle started
    $game_system.bgm_play($game_temp.map_bgm)
    # Initialize EXP, amount of gold, and treasure
    exp = 0
    gold = 0
    treasures = []
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP and amount of gold obtained
        exp += enemy.exp
        gold += enemy.gold
        # Determine if treasure appears
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    # Treasure is limited to a maximum of 6 items
    treasures = treasures[0..5]
    # Obtaining EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    # Obtaining gold
    $game_party.gain_gold(gold)
    # Obtaining treasure
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Make battle result window
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Set wait count
    @phase5_wait_count = 1
  end
  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase)
  #--------------------------------------------------------------------------
  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
      end
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Battle ends
      Audio.me_stop
      battle_end(0)
    end
  end
end
[/code


That worked for me.  You do have auto-bgm on your map, right?[/code]


Yup, I do. Thanks Hex! I'll give it a shot right now. *Levels up!*

(Hexamin)

Lemme know if it works for you, I'll try somethin' else.  ^_^
Max 1111101000; characters remaining: 1110111000

WhiteRose


(Hexamin)

Hmm... what other scripts/mods are you using?
Max 1111101000; characters remaining: 1110111000

Jackolas

that's not making sense.
there is no way that a default script with only "Audio.me_stop" added could create that error.
can you plzz let us look at the script you had before that error (the 1 that did not stop the sound, the Scene_Battle2 you had)

WhiteRose

April 03, 2010, 06:11:25 pm #11 Last Edit: April 03, 2010, 06:13:46 pm by Flower Lady WhiteRose
Quote from: Jackolas on April 03, 2010, 06:07:48 pm
that's not making sense.
there is no way that a default script with only "Audio.me_stop" added could create that error.
can you plzz let us look at the script you had before that error (the 1 that did not stop the sound, the Scene_Battle2 you had)

._.
Sorry. I erased it when I put Hex's script there instead.

Anyway, I just tried replacing the script with the default and now the problem's gone. Curious, curious....

EDIT: Hmm, I just replaced it with Hex's script yet again, and now it's working properly. It must have had something to do with the way you messed up the code tags in your post. Well, it's working now, and that's what's important.

Works perfect! Thanks Hex! (Topic resolved.)