Classes:MusicChanger
Note: Wait! Stop! You do not need to copy this actor's code into your project! Here's why:
|
Music changer | |||
---|---|---|---|
Actor type | Map spot | Game | ![]() |
DoomEd Number | 14165 | Class Name | MusicChanger |
Classes: Actor → SectorAction → MusicChanger
The MusicChanger thing changes the music when triggered by the player entering the sector in which the thing is placed. The MUSINFO lump is used to associate music lumps to numbers in a given map. The music is changed to that associated to the number indicated by the changer's first parameter. A value of 0 for that parameter always correspond to the level's default music. The music changes only for the player who triggers the MusicChanger actor.
If the music lump is in a mod music format, the second parameter can be used to set the order.
This thing is mostly for compatibility with existing PrBoom+/Risen3D maps, as ACS offers more flexible ways to change music during play.
Use in a Doom-format map
In a map format where things cannot have parameters, DoomEd numbers 14101 to 14164 can be used instead: ZDoom will translate each such item in the map to a MusicChanger actor whose first parameter is equal to its number minus 14100. (So, 14101 will be interpreted as if it were 14165 with first parameter 1.)
ZScript definition
Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub. |
class MusicChanger : SectorAction
{
override bool TriggerAction (Actor triggerer, int activationType)
{
if (activationType & SECSPAC_Enter && triggerer.player != null)
{
if (triggerer.player.MUSINFOactor != self)
{
triggerer.player.MUSINFOactor = self;
triggerer.player.MUSINFOtics = 30;
}
}
return false;
}
override void PostBeginPlay()
{
// The music changer should consider itself activated if the player
// spawns in its sector as well as if it enters the sector during a P_TryMove.
Super.PostBeginPlay();
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i] && players[i].mo && players[i].mo.CurSector == self.CurSector)
{
TriggerAction(players[i].mo, SECSPAC_Enter);
}
}
}
}
DECORATE definition
![]() |
Warning: This is legacy code, kept for archival purposes only. DECORATE is deprecated in GZDoom and is completely superseded by ZScript. GZDoom internally uses the ZScript definition above. |
ACTOR MusicChanger : SectorAction native {}