HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Battle Music if unit is attacked/attacking..possible?

01-15-2007, 09:23 AM#1
Elhyse
I want to make my Hero Arena a bit more cooler by making this effect :

If my unit gets attacked or starts attacking another unit, the music changes into a battle themed music(the one I pick obviously).

Is this feature possible without the annoying music stacking? You know the mellow music is playing at the same time with the battle music causing an annoying effect.

If this is possible please tell me how to do it. Thanks!
01-15-2007, 11:30 AM#2
Fireeye
When i understand you right, you want only to play 1 music at the same time, right?
just use the needed sounds as music type and use:
Sound - Play Music
this will stop the old music and play the new one.
01-15-2007, 12:14 PM#3
Elhyse
I want to play a specific music during battle but if the battle is over it reverts to the original music that I set.
01-15-2007, 05:11 PM#4
Alevice
I don't know you can check when an unit stops attacking/being attacked, except by checking that no enemies are around the character. Whenever this happens, you change the music again to th previous bgm.

pseudo triggers (don' have wc3 here):

playBattleMusic
events:
-myHero is being attacked/starts attacking
actions
-play battleMusic
-turn off playBattleMusic
-turn on playNormalMusic

playNormalMusic
events/conditions
-no enemies are around myHero
actions
-play normalMusic
-turn on playBattleMusic
-turn off playNormalMusic
01-15-2007, 06:41 PM#5
shadow1500
To disable in-game music use ClearMusicList followed by StopMusic. When you enter battle use PlayMusic to set it to play a list of battle songs.
01-15-2007, 07:03 PM#6
Pyrogasm
You can also use GetLocalPlayer() ==p //p is an argument, standing for a player to play sound for a specific player. For example:
Collapse JASS:
if GetLocalPlayer()==GetOwningPlayer(GetTriggerUnit()) then
    call StartSound(gg_snd_Error.wav)
endif
The above lines (which you can implement with Custom Script) will play the "Error.wav" sound for only the owning player of "Triggering unit".

There are lots of fun things to do with GLP, but many of them can cause a desync, which is bad. Playing sounds happens to not cause a desync .

Hopefully I've helped with some of your question.
01-15-2007, 08:06 PM#7
BertTheJasser
Don't you hink that is quite sensless as in an Hero Arena Map are always fights which is the main point of the game? Do not treat me wrong, but isn't it easier to simply play all the time battlemsic (which would fit at about 99% of time)?

In that case rthen you could do:
Collapse JASS:
native SetMapMusic                  takes string musicName, boolean random, integer index returns nothing
01-15-2007, 08:08 PM#8
shadow1500
You can detect if a unit is in battle if it took damage in the last 5 seconds.
Each time a unit takes damage, restart some timer (which you created earlier) and set a boolean variable to true. When the timer expires set the boolean value to false. If the boolean value is true then the unit is in battle.

Quote:
Collapse JASS:
if GetLocalPlayer()==GetOwningPlayer(GetTriggerUnit()) then
    call StartSound(Error.wav <gen>)
endif
That won't work because of a syntax error.
01-15-2007, 08:14 PM#9
Pyrogasm
Quote:
Originally Posted by shadow1500
That won't work because of a syntax error.
Eh? What did I do wrong?
01-15-2007, 08:30 PM#10
shadow1500
Error.wav <gen>
This is something you might see in GUI but not in jass.
WE sound variables start with gg_snd_ followed by the sound name as defined by the user. Otherwise you have to create them with CreateSound and then use them.
01-15-2007, 08:34 PM#11
Pyrogasm
Oh, d'oh. That's what I get for writing off the top of my head .

I've fixed it.
01-15-2007, 08:43 PM#12
shadow1500
You can't have dots (.) in the variable name. The variable names are defined by the user and not by the file name.
01-16-2007, 03:31 AM#13
Elhyse
So in short...this is implementable even without JASS right?
01-16-2007, 01:45 PM#14
Alevice
look at my pseudo trigger