Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: nathmatt on September 13, 2010, 01:46:35 pm

Title: [XP] Blizz-ABS Battle Music
Post by: nathmatt on September 13, 2010, 01:46:35 pm
Blizz-ABS Battle Music
Authors: Nathmatt
Version: 1.09
Type: Music changer
Key Term: Blizz-ABS Plugin



Introduction

Changes the music when you are targeted by an enemy



Features




Screenshots

no screen shot needed



Demo

no demo


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# BlizzABS Battle Music by Nathmatt
# Version: 1.09
# Type: Music changer
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
module Music_Change
 
  def self.fade_out
    return 1                            # secounds of music fade
  end
 
  def self.Music
    #RPG::AudioFile.new(name = "", volume = 100, pitch = 100)
    return [RPG::AudioFile.new('001-Battle01')]             # Array of musics
  end
 
end


class Game_Map
 
  def active?
    return (battlers.find_all {|battler|battler.update? &&
    battler.ai.target != nil})
  end

end

class Scene_Map
 
  alias music_change_update update
  def update
    if @map_id != $game_map.map_id
      @battle_music = @normal_music = nil
      @map_id = $game_map.map_id
    end
    @wait = 0 if @wait == nil
    @wait -=1 if @wait > 0
    if $game_map.active?.size > 0 && $game_map.battlers.size > 0
      @wait = 40
      if !@battle_music
        @battle_music = true
        @normal_music = false
        @bgm = $game_system.playing_bgm
        #"Audio/BGM/"
        $game_system.bgm_play(Music_Change.Music[$game_player.music_type])
      end
    elsif @wait == 0 && @normal_music == false
      @battle_music = false
      @normal_music = true
      if @bgm != nil
        $game_system.bgm_play(@bgm)
      else
        $game_system.bgm_fade(1)
      end
    end
    music_change_update
  end
 
end

class Map_Actor
 
  attr_accessor :music_type
 
  alias battle_music_initialize initialize
  def initialize(i)
    battle_music_initialize(i)
    @music_type = 0
  end
 
end

class Game_System
  attr_reader   :playing_bgm
end



Instructions
add the musics you want to the array of musics in the config
to change the music use $game_player.music_type = index
index goes 0 for the first 1 1 for the secound ect...
place this script Below Blizz-ABS


Compatibility

requires Blizz-ABS


Credits and Thanks




Author's Notes

if you have any issues or suggestions post here
Title: Re: [XP] BlizzABS Battle Music
Post by: Calintz on September 13, 2010, 01:54:22 pm
LMAO great response to that question Nathmatt!!
Deserves *level up* for response time.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Blizzard on September 13, 2010, 02:16:50 pm
*fixes header* *levels up* *moves*
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Magus on September 13, 2010, 03:07:30 pm
I love you XD
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Jragyn on September 13, 2010, 08:45:18 pm
Amazing how such simple things can impact the feel of a game. :]
Even worthy of a levelup by me!


--J
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Holyrapid on September 18, 2010, 03:44:37 am
I've been wanting this sort of a thing for as long as iƤve used BABS (or at leasst oafter i played FF12 and used BABS after it) Level up! I'm so gonna use this in my game.
Would it be possible to change that music via a script call, so that you could change it for boss battles etc.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on September 18, 2010, 08:25:08 am
update 1.01 added ability to change the battle music in game
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Kett Shee on September 18, 2010, 09:04:10 am
Spoiler: ShowHide
(http://images.memegenerator.net/Patrick-Star-i-love-you/ImageMacro/2197656/MediumThumbnail.jpg?instanceText=i-love-you)


This deserves a lvl up. :3
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Dweller on September 19, 2010, 02:07:31 am
I updated to the new version and now have an error:

"...uninitilizated constant Music_Change::Music..."

Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on September 19, 2010, 09:35:27 am
update fixed to fix yourself just change
Music_Change::Music

to
Music_Change.Music
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Dweller on September 19, 2010, 09:44:10 am
Done, ty nathmatt. A very usefull script, lvl up
Title: Re: [XP] Blizz-ABS Battle Music
Post by: lonely_cubone on September 19, 2010, 10:15:55 am
Great script, lvl up! I've actually wanted something like this for a while.

Btw, you're now level 69. Congratulations. :naughty:
Title: Re: [XP] Blizz-ABS Battle Music
Post by: The Niche on September 19, 2010, 12:13:19 pm
Quote from: lonely_cubone on September 19, 2010, 10:15:55 am
:naughty:


Soul acquired. Your doom grows ever nearer.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: lonely_cubone on September 20, 2010, 09:18:01 am
I think you have a few of my souls by now. I never knew I had so many of them in the first place :wacko:
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on October 24, 2010, 06:05:43 am
The script is showing error in line

        Audio.bgm_play("Audio/BGM/" + Music_Change.Music[$game_player.music_type])


it says "no implicit conversion from nil to integer"

I place the script right below blizz abs and above main
what did I do wrong?
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 24, 2010, 08:38:00 am
maybe there is a compatibility issue with 1 of the other scripts you are using give me a demo with all the scripts you are using it it and i will test it 
Title: Re: [XP] Blizz-ABS Battle Music
Post by: sirsniffy on October 24, 2010, 04:40:57 pm
Any way to adjust the volume in the battle music?
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 24, 2010, 06:43:58 pm
i believe you should be able to  by changing this line

Audio.bgm_play("Audio/BGM/" + Music_Change.Music[$game_player.music_type])


to this

Audio.bgm_play("Audio/BGM/" + Music_Change.Music[$game_player.music_type],add music percentage here)

so if you want 100% just put 100
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Taiine on October 26, 2010, 08:21:26 am
I think I found a bug. For me, each time I get hit by an enemy, the battle music restarts over from the start. 
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on October 26, 2010, 08:52:32 am
Quote from: nathmatt on October 24, 2010, 08:38:00 am
maybe there is a compatibility issue with 1 of the other scripts you are using give me a demo with all the scripts you are using it it and i will test it 


I think that is not necessary
when I add "auto change bgm" in "map properties" that error didn't appear again
but...

Quote from: Taiine on October 26, 2010, 08:21:26 am
I think I found a bug. For me, each time I get hit by an enemy, the battle music restarts over from the start. 


same problem,
when I change the bgm by using event then battle, after the enemies died the music changed back to beginning (the one I set as auto change bgm)
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Dweller on October 26, 2010, 01:13:12 pm
Quote from: Taiine on October 26, 2010, 08:21:26 am
I think I found a bug. For me, each time I get hit by an enemy, the battle music restarts over from the start. 


I noticed the same bug, but in my case the music restarts sometimes when you get hit by an enemy and others works fine.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 26, 2010, 01:27:53 pm
yea i noticed that too im trying to find what i need to check from the battlers to see if there in battle rather than just walking around
Title: Re: [XP] Blizz-ABS Battle Music
Post by: legacyblade on October 26, 2010, 04:40:10 pm
You can check if there are enemies within the processing range of the ABSEAL (or whatever it is called). I made an addon that did this on an old version of blizzABS, so not sure how to do that anymore, but the manual probably mentions it somewhere
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 26, 2010, 04:45:29 pm
the problem with that is the music changes even when your not being attacked
Title: Re: [XP] Blizz-ABS Battle Music
Post by: legacyblade on October 26, 2010, 07:36:50 pm
oh, I didn't notice that it only changed after being attacked. In your current method, check to see if the currently playing BGM is the/one of the battle musics. If you can't do that with RMXP, set a variable to true whenever you're attacked. I'm guessing the music changes back after a fixed amount of time, so just set the switch to false after that and re-play the map's previous BGM (if there isn't a way to resume that, set a variable with the old BGM). Hope that helps x.x
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Taiine on October 27, 2010, 02:27:22 am
I didn't notice any real issue with the music popping on only when attacked. it started as soon as I got agro from any aggressive mobs. But as soon as they hit you with anything, the battle music restarts over.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 27, 2010, 12:40:36 pm
update 1.03 fixed battle music resetting
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on October 27, 2010, 09:47:15 pm
Quote from: nathmatt on October 27, 2010, 12:40:36 pm
update 1.03 fixed battle music resetting


still restarting....

maybe you should change the method for changing the music

ex : when the battle starts memorized bgm at the map and play battle bgm
then after battle is over restore that bgm
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 27, 2010, 10:09:15 pm
restarting during battle or not restoring the bgm ?
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Dweller on October 28, 2010, 01:10:51 am
Quoterestarting during battle or not restoring the bgm

Sometimes not restoring the bgm but the restarting bug disappeared.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on October 28, 2010, 06:45:54 am
Quote from: nathmatt on October 27, 2010, 10:09:15 pm
restarting during battle or not restoring the bgm ?


I mean the bgm changed back to beginning


Something like this :

I set the autochange bgm in map properties to a
then in the game I change the bgm using event to b
when I battle bgm change to battle music
after battle is over the bgm back to a
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 28, 2010, 08:20:34 am
update 1.04 there that should fix it
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on October 29, 2010, 08:59:23 am
Bug report :

If enemy exist in the map the bgm changed to battle bgm (sometimes disappeared) even though I didn't attacked them (the bgm changed immidiately after I teleported to that map)
If the map doesn't have enemy it would be normal, but when I changed the bgm with event then open my CMS the bgm changed back to beginning


did my english horrible?
Title: Re: [XP] Blizz-ABS Battle Music
Post by: The Niche on October 29, 2010, 09:08:02 am
Yes, you done your english horrible :P. I laughed when I saw that last line.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 29, 2010, 10:44:42 am
Quote from: LiTTleDRAgo on October 29, 2010, 08:59:23 am
Bug report :

If enemy exist in the map the bgm changed to battle bgm (sometimes disappeared) even though I didn't attacked them (the bgm changed immidiately after I teleported to that map)
If the map doesn't have enemy it would be normal, but when I changed the bgm with event then open my CMS the bgm changed back to beginning


did my english horrible?


the music only changes when an enemy targets you so as soon as you enter the map an enemy must target you
my script can't be causing enemies to disappear because it doesn't edit anything to cause that
the menu shouldn't be caused by this either try removing this script to see if the bugs are still there if therer not give me a demo so i can look into it
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on October 30, 2010, 10:09:40 am
Quote from: nathmatt on October 29, 2010, 10:44:42 am
the music only changes when an enemy targets you so as soon as you enter the map an enemy must target you
my script can't be causing enemies to disappear because it doesn't edit anything to cause that
the menu shouldn't be caused by this either try removing this script to see if the bugs are still there if therer not give me a demo so i can look into it


It's not what I mean

probably it's easier to make a demo for explaining since my english is bad

http://www.megaupload.com/?d=H9M9FLN1
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 30, 2010, 10:30:57 am
update: 1.05 fixed bug where music would stop playing when menu was called

@LiTTleDRAgo the music continuing to play after killing all the enemies is more of a Blizz-ABS bug at has to do with having enemies increase a variable it messes up the enemy counter in Blizz-ABS
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on October 31, 2010, 09:52:59 am
@^ That's alright, I figure a way out from that

btw, when I trying to add another alignment in battle this error sometimes appeared

(http://img835.imageshack.us/img835/7127/90798544.jpg)

I don't know what's wrong with the script since it didn't appear often

http://www.megaupload.com/?d=S2C7P56T
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on October 31, 2010, 10:55:39 am
update: 1.06 fixed music bug where if the battle music was on and you left the map the battle music would not play again and i think i fixed undefined music type for Map_Actor
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Taiine on October 31, 2010, 01:02:34 pm
One more little bug.

If you're fighting an enemy and you have to flee from them, or you just run past one and it agro's onto you and you keep going. The enemy can be reset back, no longer going after you, but the battle music will keep  playing and not turn off until you move and get the enemy back on the screen, even if just at the edge and not in range of you, but just on screen will the battle music stop.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Magus on October 31, 2010, 01:29:20 pm
Yeah. That error is a must-fix. I encountered it as well :/
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on November 03, 2010, 11:53:08 am
update: 1.07  see if its fixed now
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Kagutsuchi on January 30, 2011, 05:42:34 pm
The battle music keeps resetting when fighting enemies using ranged skills :(
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on January 30, 2011, 09:23:51 pm
send me the project so i can look at it
Title: Re: [XP] Blizz-ABS Battle Music
Post by: LiTTleDRAgo on February 12, 2011, 01:17:47 am
could you make the music is fading everytime it's switched?
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on February 12, 2011, 08:23:24 am
update: added music fade out

@Kagutsuchi
now that i think about it you should probably increase the enemies sight to match the his attacks range

Title: Re: [XP] Blizz-ABS Battle Music
Post by: JellalFerd on June 16, 2011, 01:33:12 pm
Instead of using arrays, why not just use
$game_system.bgm_play($game_system.battle_bgm)

It works for me if I use that.
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Moshan on September 25, 2011, 10:06:42 am
Is there a way not to stop map BGM and play the battle music louder?
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on September 25, 2011, 11:22:34 am
no because RPG maker XP does not support duel BGM's i believe ARC will allow it tho in its full release
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Sin86 on September 25, 2011, 11:27:57 am
I got a problem. Ok so I set the script to be like this(there wasn't much in the instructions so I had to figure it out myself).

  def self.Music
    case id
    when 1 then return ['002-Battle02']
    end
    return ['001-Battle01']             # Array of musics


Now I set up a map and I use "$game_player.music_type = 1" which should be Battle02. When I do, I get this error.

"Script 'Blizz ABS Music' line 83: TypeError occurred

cannot convert nil into string"
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on September 25, 2011, 11:52:36 am
def self.Music
  return ['001-Battle01','002-Battle02']             # Array of musics
end


like this then 1 would play 002-Battle02
Title: Re: [XP] Blizz-ABS Battle Music
Post by: Sin86 on September 25, 2011, 12:03:40 pm
The array thing works though, thanks man!

However, I look at this code

Audio.bgm_play("Audio/BGM/" + Music_Change.Music[$game_player.music_type],add music percentage here)


By doing that, it applys to all the battle BGMs but is there a way to do it to have each specific battle BGM to have a different volume?
Title: Re: [XP] Blizz-ABS Battle Music
Post by: nathmatt on September 25, 2011, 04:13:49 pm
ok just made it use RPG::AudioFile.new so now you make an array of those for you it would be

def self.Music
  return [RPG::AudioFile.new('001-Battle01'),RPG::AudioFile.new('002-Battle02')]             # Array of musics
end


Title: Re: [XP] Blizz-ABS Battle Music
Post by: Zare on December 29, 2011, 06:07:01 pm
Really Nice Script, but after a battle the battle music keeps playing for me. Is there any Solution to change that?