Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- ╔══════════════════════════════════════════════════════════════════════════════╗
- ║ Map Music in Battles Scriptlet ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ Version : 1.0 ║
- ║ Author : Companion Wulf ║
- ║ Platforms : RMXP ║
- ║ Release Date : 7 March 2015 ║
- ║ Last Update : 7 March 2015 ║
- ║ Demo Version : N/A ║
- ║ Demo Date : Unreleased ║
- ║ Website : http://rpgmakertimes.info ║
- ║ Blog : http://blog.rpgmakertimes.info ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ DESCRIPTION ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ This scriptlet enables the current map BGM to play throughout ║
- ║ battles without pausing, disabling the battle BGM and victory ║
- ║ ME completely. ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ INSTALLATION ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ Place the scriptlet above "Main". ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ INSTRUCTIONS ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ Import all parallax graphics into the Graphics/Parallaxes ║
- ║ Set BATTLE_MUSIC to "false" to enable the map BGM to play in ║
- ║ battles. Setting it to "true" will reenable it. ║
- ║ ║
- ║ To toggle it on or off during the game you can use the follow- ║
- ║ ing either in a script or Script event command: ║
- ║ ║
- ║ $game_battle_bgm.battle_music = true/false ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ DEVELOPMENT NOTES ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ This scriptlet was inspired by a question on Yahoo! Answers. ║
- ║ ║
- ║ https://ca.answers.yahoo.com/question/index?qid=20150225050638AAmsjt3 ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ COMPATIBILITY ISSUES ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ There may be incompatibility issues with scripts that affect ║
- ║ the post-battle phase. Aside from that I don't see any other ║
- ║ problems. ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ METHODS AFFECTED ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ ● New Methods ║
- ║ ● Aliased Methods ║
- ║ ● Game_Map: ║
- ║ ○ main ║
- ║ ● Overwritten Methods ║
- ║ ● Scene_Map: ║
- ║ ○ call_battle ║
- ║ ● Scene_Battle: ║
- ║ ○ start_phase5 ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ FUTURE UPDATES ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ ● No future updates are planned. ║
- ║ ║
- ╠══════════════════════════════════════════════════════════════════════════════╣
- ║ ◄ VERSION HISTORY ► ║
- ╟──────────────────────────────────────────────────────────────────────────────╢
- ║ v1.0 (07-Mar-2015) ║
- ║ ● Began/Finished scriptlet ║
- ║ ║
- ╚══════════════════════════════════════════════════════════════════════════════╝
- =end
- $imported = {} if $imported == nil; $imported["CW-MapMusicBattles"] = true
- #==============================================================================
- # ** Battle_Music
- #==============================================================================
- class Battle_Music
- attr_accessor :battle_music
- def initialize
- @battle_music = false
- end
- end
- #==============================================================================
- # ** Scene_Title
- #==============================================================================
- class Scene_Title
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- alias cw_mmibs_main main
- def main
- cw_mmibs_main
- $game_battle_bgm = Battle_Music.new
- end
- end
- #==============================================================================
- # ** Scene_Map
- #==============================================================================
- class Scene_Map
- #--------------------------------------------------------------------------
- # * Battle Call
- #--------------------------------------------------------------------------
- def call_battle
- # Clear battle calling flag
- $game_temp.battle_calling = false
- # Clear menu calling flag
- $game_temp.menu_calling = false
- $game_temp.menu_beep = false
- # Make encounter count
- $game_player.make_encounter_count
- # Memorize map BGM and stop BGM
- $game_temp.map_bgm = $game_system.playing_bgm
- if $game_battle_bgm.battle_music
- $game_system.bgm_stop
- # Play battle start SE
- $game_system.se_play($data_system.battle_start_se)
- # Play battle BGM
- $game_system.bgm_play($game_system.battle_bgm)
- end
- # Straighten player position
- $game_player.straighten
- # Switch to battle screen
- $scene = Scene_Battle.new
- end
- end
- #==============================================================================
- # ** Scene_Battle (part 2)
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # * 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) if $game_battle_bgm.battle_music#BATTLE_MUSIC
- # 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 = 100
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement