tModLoader Boss Music Mod Help

Zellogi

Steampunker
Ok so I'm new to the coding behind Terraria. I can read/write basic C#, but I don't know where to start with this. What I want to do is create a mod that allows me to set a unique soundtrack for each vanilla boss in the game. This way I can find music that fits the theme of the boss, without it affecting other bosses' themes. I know Tremor Mod did this with King Slime, but since they don't allow you to use tModReader on it, I don't know how they went about doing it. Any help would be appreciated!

On a side note, is it possible to play a song during the waiting period before Moon Lord spawns, as like a buildup to the actual boss theme? Or is it possible to play different songs during each wave of the Old One's Army?
 
I know it's been exactly one year since your second bump, but I think I might have an answer for the main question. For the others, you may be able to find the variables that Terraria uses to keep track of those things and adapt this idea accordingly.

What you'll need to do is put this in the mod class of your mod file:
Code:
public override void UpdateMusic(ref int music,ref MusicPriority priority)
{
}

In the curly brackets, you'll probably want to use one of those "switch case" things that you can do in C# to cycle through the NPC IDs looking for specific numbers relating to the ID of the boss. I don't know how to use those though, so I'll only be using if statements. You'll want to check for if a certain boss is present. Using Plantera as an example, something like this should work:
Code:
if(NPC.AnyNPCs(NPCID.Plantera))
{
}

Note that "Plantera" is this instance is the name of Plantera in the code, but Eye of Cthulhu is "EyeofCthulhu" in the code. You can also substitute "NPCID.Plantera" with Plantera's actual ID. You can find a list of NPC IDs here:
https://terraria.wiki.gg/NPC_IDs

As well as a list of those IDs next to their names in Terraria's code:
https://github.com/blushiemagic/tModLoader/wiki/Vanilla-NPC-IDs

You might wanna use your browser's Find function to search the pages to save time.

Anyways, once you've got your cases set up, you're gonna want to look at this page while doing this next bit:
https://github.com/blushiemagic/tMo...ModLoader/Terraria.ModLoader/MusicPriority.cs

This is an example of changing Plantera's music to the WoF theme:
Code:
music = MusicID.Boss2;
priority = MusicPriority.BossMedium;

The music variable is changed to the music ID of the song you want to play (can also be a number). I know you want to change the songs to custom music, but for reference, here's a list of the names of each track in the code along with which IDs they have been assigned:
https://github.com/blushiemagic/tModLoader/blob/master/patches/tModLoader/Terraria.ID/MusicID.cs

The names should be pretty self explanatory but you can search them on Youtube if you want to know exactly which ones they are.

Here's where we get into something that I don't have a lot of knowledge about, but I think I can help in some way here too. I believe that to play custom music, you would do this:
Code:
music = GetSoundSlot(SoundType.Music, "Your/Music/Folder/Path");

"Your/Music/Folder/Path" should be replaced with the path from your mod folder to your music folder, including everything inbetween (but not including) the mod folder itself and the track you want to play. Again, this may not work and you may wanna look around a little, but it shouldn't take more than a google search.

Anyways, the second line regarding the priority of the music is a bit more interesting. You see, each in-game track is assigned a priority by tModLoader, which is roughly specified in the link containing the definition for MusicPriority. Essentially, you want the priority to be equal to or higher than the one assigned to the track so that your track will play instead. It's best not to set the priority to MusicPriority.BossHigh all the time, as this will interfere with and play over the themes of bosses whose themes should be playing instead (think about having King Slime's theme interrupting the Moon Lord's theme because it spawned when the player was on the outer third of the map).

Here's the entirety of the code I did so you can get a feel for how it's layed out:
Code:
public override void UpdateMusic(ref int music,ref MusicPriority priority)
{
    if(NPC.AnyNPCs(NPCID.Plantera))
    {
        music = MusicID.Boss2;
        priority = MusicPriority.BossMedium;
    }
}

That's about all I have to say on the matter. If want, you can do some digging around tModLoader's various .cs files which can be accessed through going to one of the links to a specific one (like MusicPriority.cs) and going up one step. You may find some values or methods in the other files that will help you with the other things you were trying to implement. You can also search through the variables stated in the actual game's various classes here:
http://tconfig.wikia.com/wiki/Category:Classes (only focus on the ones under Terraria Classes)

I know this was long, but thanks for reading! I'm new to modding so I'm open to corrections. Hope this helped.
 
I know it's been exactly one year since your second bump, but I think I might have an answer for the main question. For the others, you may be able to find the variables that Terraria uses to keep track of those things and adapt this idea accordingly.

What you'll need to do is put this in the mod class of your mod file:
Code:
public override void UpdateMusic(ref int music,ref MusicPriority priority)
{
}

In the curly brackets, you'll probably want to use one of those "switch case" things that you can do in C# to cycle through the NPC IDs looking for specific numbers relating to the ID of the boss. I don't know how to use those though, so I'll only be using if statements. You'll want to check for if a certain boss is present. Using Plantera as an example, something like this should work:
Code:
if(NPC.AnyNPCs(NPCID.Plantera))
{
}

Note that "Plantera" is this instance is the name of Plantera in the code, but Eye of Cthulhu is "EyeofCthulhu" in the code. You can also substitute "NPCID.Plantera" with Plantera's actual ID. You can find a list of NPC IDs here:
NPC IDs

As well as a list of those IDs next to their names in Terraria's code:
tModLoader/tModLoader

You might wanna use your browser's Find function to search the pages to save time.

Anyways, once you've got your cases set up, you're gonna want to look at this page while doing this next bit:
tModLoader/tModLoader

This is an example of changing Plantera's music to the WoF theme:
Code:
music = MusicID.Boss2;
priority = MusicPriority.BossMedium;

The music variable is changed to the music ID of the song you want to play (can also be a number). I know you want to change the songs to custom music, but for reference, here's a list of the names of each track in the code along with which IDs they have been assigned:
tModLoader/tModLoader

The names should be pretty self explanatory but you can search them on Youtube if you want to know exactly which ones they are.

Here's where we get into something that I don't have a lot of knowledge about, but I think I can help in some way here too. I believe that to play custom music, you would do this:
Code:
music = GetSoundSlot(SoundType.Music, "Your/Music/Folder/Path");

"Your/Music/Folder/Path" should be replaced with the path from your mod folder to your music folder, including everything inbetween (but not including) the mod folder itself and the track you want to play. Again, this may not work and you may wanna look around a little, but it shouldn't take more than a google search.

Anyways, the second line regarding the priority of the music is a bit more interesting. You see, each in-game track is assigned a priority by tModLoader, which is roughly specified in the link containing the definition for MusicPriority. Essentially, you want the priority to be equal to or higher than the one assigned to the track so that your track will play instead. It's best not to set the priority to MusicPriority.BossHigh all the time, as this will interfere with and play over the themes of bosses whose themes should be playing instead (think about having King Slime's theme interrupting the Moon Lord's theme because it spawned when the player was on the outer third of the map).

Here's the entirety of the code I did so you can get a feel for how it's layed out:
Code:
public override void UpdateMusic(ref int music,ref MusicPriority priority)
{
    if(NPC.AnyNPCs(NPCID.Plantera))
    {
        music = MusicID.Boss2;
        priority = MusicPriority.BossMedium;
    }
}

That's about all I have to say on the matter. If want, you can do some digging around tModLoader's various .cs files which can be accessed through going to one of the links to a specific one (like MusicPriority.cs) and going up one step. You may find some values or methods in the other files that will help you with the other things you were trying to implement. You can also search through the variables stated in the actual game's various classes here:
Classes (only focus on the ones under Terraria Classes)

I know this was long, but thanks for reading! I'm new to modding so I'm open to corrections. Hope this helped.
Hey, so, could you please explain how to do this but just replacing Terraria music in general? It's been a little over a year since this was posted, and I found it kinda helpful, but I just needed some help with replacing music in general, since I'm trying to replace "Title" with my mod's title music. Thanks!
 
Hey, so, could you please explain how to do this but just replacing Terraria music in general? It's been a little over a year since this was posted, and I found it kinda helpful, but I just needed some help with replacing music in general, since I'm trying to replace "Title" with my mod's title music. Thanks!
It's another year; I know. But I tried it and it played nothing.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;

namespace InsaneCrazyThing.Items
{
    class TryAgain : ModNPC
    {
            

        private int ai;
        private int attackTimer = 0;
        private bool fastspeed = false;
        private Player player;
        private float speed;
        private bool Eye = false;
        private bool Corrupt = false;
        private bool Bones = false;
        private bool Mech = false;
        private bool Golem = false;
        private bool EpicAttack = false;








        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Charc");

        }

        public override void SetDefaults()
        {
            npc.width = 96;
            npc.height = 96;
            Main.npcFrameCount[npc.type] = 4;
            npc.lifeMax = 400000;
            npc.damage = 100;
            npc.defense = 50;
            npc.knockBackResist = 0f;
            npc.aiStyle = -1;
            Main.npcFrameCount[npc.type] = 4;
            aiType = 5;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath2;
            npc.noGravity = true;
            npc.boss = true;
            npc.netAlways = true;
            npc.lavaImmune = true;
            npc.npcSlots = 1f;
            npc.noTileCollide = true;
            npc.buffImmune[24] = true;
            npc.lavaImmune = true;
            npc.value = Item.buyPrice(999, 99, 99, 99);
            music = mod.GetSoundSlot(SoundType.Music, "Items/TryAgain");
            
            bossBag = mod.ItemType("TryAgainBag");
        }








        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);  //boss life scale in expertmode
            npc.damage = (int)(npc.damage * 0.6f);  //boss damage increase in expermode
        }

        public override void AI()
        {
            Target();
            DespawnHandler();
            Move(new Vector2(0, 400));
            Move(new Vector2(0, -400));
            Move(new Vector2(400, -400));
            Move(new Vector2(-400, 400));
            if(npc.life < 390000)
            {
                if (Eye == false)
                {
                    Main.NewText("My Brothers And Sisters, It is time for revenge!");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.EyeofCthulhu);
                    Eye = true;
                }

            }
            if (npc.life < 370000)
            {
                if (Corrupt == false)
                {
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.EaterofWorldsHead);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.BrainofCthulhu);
                    Corrupt = true;
                }
            }


            if (npc.life < 300000)
            {
                if (Mech == false)
                {
                    Main.NewText("My Mechanical Buddies, Arise!");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.TheDestroyer);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronPrime);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.Spazmatism);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.Retinazer);
                    Mech = true;
                }
            }

            if (npc.life < 270000)
            {
                if (Golem == false)
                {
                    Main.NewText("Golem, Youare freed from the altar");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.Golem);
                    Golem = true;
                }
            }

            if (npc.life < 200000)
            {
                if (Bones == false)
                {
                    Main.NewText("Foolish Child, Here comes three more!");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.QueenBee);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronHead);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronHand);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronHand);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.CultistBoss);
                    Bones = true;
                }
            }

            if (npc.life < 100000)
            {
                if (EpicAttack == false)
                {
                    Main.NewText("I shall never Die");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Boss2npc"));
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Boss1npc"));
                    Vector2 perturbedSpeed = new Vector2(player.position.X + player.width / 2, player.position.Y + player.height / 2) -
                    new Vector2(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2); // 30 degree spread.
                                                                                                                       // If you want to randomize the speed to stagger the projectiles
                                                                                                                       // float scale = 1f - (Main.rand.NextFloat() * .3f);
                                                                                                                       // perturbedSpeed = perturbedSpeed * scale;
                    Projectile.NewProjectile(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2, perturbedSpeed.X, perturbedSpeed.Y, ProjectileID.DeathSickle, 2000, 2000, player.whoAmI, player.whoAmI, 0f);
                    EpicAttack = true;

                }
            }



        }





        public override void NPCLoot()
        {
            if (Main.expertMode)
            {
                npc.DropBossBags();
            }
            else
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Doom"), 1);
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Steel_Bar"), Main.rand.Next(1, 50));
            }
        }

        public override void BossLoot(ref string name, ref int potionType)
        {
            Main.NewText("Remach...");
            Main.PlaySound(SoundID.Roar, npc.position);
            
            potionType = ItemID.SuperHealingPotion;
        }

        private void Target()
        {
            player = Main.player[npc.target]; // This will get the player target.
        }

        private void DespawnHandler()
        {
            if (!player.active || player.dead)
            {
                npc.TargetClosest(false);
                player = Main.player[npc.target];
                if (!player.active || player.dead)
                {
                    npc.velocity = new Vector2(0f, -10f);
                    if (npc.timeLeft > 10)
                    {
                        npc.timeLeft = 10;
                    }
                    return;
                }
            }
        }

        private void Move(Vector2 offset)
        {
            speed = 30f; // Sets the max speed of the npc.
            Vector2 moveTo = player.Center - offset; // Gets the point that the npc will be moving to.
            Vector2 move = moveTo - npc.Center;
            float magnitude = Magnitude(move);
            if (magnitude > speed)
            {
                move *= speed / magnitude;
            }
            float turnResistance = 10f; // The larget the number the slower the npc will turn.
            move = (npc.velocity * turnResistance + move) / (turnResistance + 1f);
            magnitude = Magnitude(move);
            if (magnitude > speed)
            {
                move *= speed / magnitude;
            }
            npc.velocity = move;
            Shoot();



        }

        private float Magnitude(Vector2 mag)
        {
            return (float)Math.Sqrt(mag.X * mag.X + mag.Y * mag.Y);
        }

        public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
        {
            scale = 1.5f;
            return null;
        }

        private void Shoot()
        {

            if (Main.rand.Next(1, 200) == 199)
            {

                Vector2 perturbedSpeed = new Vector2(player.position.X + player.width / 2, player.position.Y + player.height / 2) -
                new Vector2(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2).RotatedByRandom(MathHelper.ToRadians(1)); // 30 degree spread.
                                                                                                                       // If you want to randomize the speed to stagger the projectiles
                                                                                                                       // float scale = 1f - (Main.rand.NextFloat() * .3f);
                                                                                                                       // perturbedSpeed = perturbedSpeed * scale;
                Projectile.NewProjectile(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2, perturbedSpeed.X, perturbedSpeed.Y, ProjectileID.PinkLaser, 200, 5, player.whoAmI, player.whoAmI, 0f);

            }
        }

        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            if (NPC.downedMoonlord && player.statDefense >= 70 || NPC.downedMoonlord && player.endurance >= 15)
            {
                return 0.1f;
            }else
            {
                return 0f;
            }
        }



    }
}

Try Again Mod

To Many Monsters!
 
It's another year; I know. But I tried it and it played nothing.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;

namespace InsaneCrazyThing.Items
{
    class TryAgain : ModNPC
    {
           

        private int ai;
        private int attackTimer = 0;
        private bool fastspeed = false;
        private Player player;
        private float speed;
        private bool Eye = false;
        private bool Corrupt = false;
        private bool Bones = false;
        private bool Mech = false;
        private bool Golem = false;
        private bool EpicAttack = false;








        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Charc");

        }

        public override void SetDefaults()
        {
            npc.width = 96;
            npc.height = 96;
            Main.npcFrameCount[npc.type] = 4;
            npc.lifeMax = 400000;
            npc.damage = 100;
            npc.defense = 50;
            npc.knockBackResist = 0f;
            npc.aiStyle = -1;
            Main.npcFrameCount[npc.type] = 4;
            aiType = 5;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath2;
            npc.noGravity = true;
            npc.boss = true;
            npc.netAlways = true;
            npc.lavaImmune = true;
            npc.npcSlots = 1f;
            npc.noTileCollide = true;
            npc.buffImmune[24] = true;
            npc.lavaImmune = true;
            npc.value = Item.buyPrice(999, 99, 99, 99);
            music = mod.GetSoundSlot(SoundType.Music, "Items/TryAgain");
           
            bossBag = mod.ItemType("TryAgainBag");
        }








        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);  //boss life scale in expertmode
            npc.damage = (int)(npc.damage * 0.6f);  //boss damage increase in expermode
        }

        public override void AI()
        {
            Target();
            DespawnHandler();
            Move(new Vector2(0, 400));
            Move(new Vector2(0, -400));
            Move(new Vector2(400, -400));
            Move(new Vector2(-400, 400));
            if(npc.life < 390000)
            {
                if (Eye == false)
                {
                    Main.NewText("My Brothers And Sisters, It is time for revenge!");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.EyeofCthulhu);
                    Eye = true;
                }

            }
            if (npc.life < 370000)
            {
                if (Corrupt == false)
                {
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.EaterofWorldsHead);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.BrainofCthulhu);
                    Corrupt = true;
                }
            }


            if (npc.life < 300000)
            {
                if (Mech == false)
                {
                    Main.NewText("My Mechanical Buddies, Arise!");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.TheDestroyer);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronPrime);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.Spazmatism);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.Retinazer);
                    Mech = true;
                }
            }

            if (npc.life < 270000)
            {
                if (Golem == false)
                {
                    Main.NewText("Golem, Youare freed from the altar");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.Golem);
                    Golem = true;
                }
            }

            if (npc.life < 200000)
            {
                if (Bones == false)
                {
                    Main.NewText("Foolish Child, Here comes three more!");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.QueenBee);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronHead);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronHand);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.SkeletronHand);
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, NPCID.CultistBoss);
                    Bones = true;
                }
            }

            if (npc.life < 100000)
            {
                if (EpicAttack == false)
                {
                    Main.NewText("I shall never Die");
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Boss2npc"));
                    NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("Boss1npc"));
                    Vector2 perturbedSpeed = new Vector2(player.position.X + player.width / 2, player.position.Y + player.height / 2) -
                    new Vector2(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2); // 30 degree spread.
                                                                                                                       // If you want to randomize the speed to stagger the projectiles
                                                                                                                       // float scale = 1f - (Main.rand.NextFloat() * .3f);
                                                                                                                       // perturbedSpeed = perturbedSpeed * scale;
                    Projectile.NewProjectile(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2, perturbedSpeed.X, perturbedSpeed.Y, ProjectileID.DeathSickle, 2000, 2000, player.whoAmI, player.whoAmI, 0f);
                    EpicAttack = true;

                }
            }



        }





        public override void NPCLoot()
        {
            if (Main.expertMode)
            {
                npc.DropBossBags();
            }
            else
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Doom"), 1);
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Steel_Bar"), Main.rand.Next(1, 50));
            }
        }

        public override void BossLoot(ref string name, ref int potionType)
        {
            Main.NewText("Remach...");
            Main.PlaySound(SoundID.Roar, npc.position);
           
            potionType = ItemID.SuperHealingPotion;
        }

        private void Target()
        {
            player = Main.player[npc.target]; // This will get the player target.
        }

        private void DespawnHandler()
        {
            if (!player.active || player.dead)
            {
                npc.TargetClosest(false);
                player = Main.player[npc.target];
                if (!player.active || player.dead)
                {
                    npc.velocity = new Vector2(0f, -10f);
                    if (npc.timeLeft > 10)
                    {
                        npc.timeLeft = 10;
                    }
                    return;
                }
            }
        }

        private void Move(Vector2 offset)
        {
            speed = 30f; // Sets the max speed of the npc.
            Vector2 moveTo = player.Center - offset; // Gets the point that the npc will be moving to.
            Vector2 move = moveTo - npc.Center;
            float magnitude = Magnitude(move);
            if (magnitude > speed)
            {
                move *= speed / magnitude;
            }
            float turnResistance = 10f; // The larget the number the slower the npc will turn.
            move = (npc.velocity * turnResistance + move) / (turnResistance + 1f);
            magnitude = Magnitude(move);
            if (magnitude > speed)
            {
                move *= speed / magnitude;
            }
            npc.velocity = move;
            Shoot();



        }

        private float Magnitude(Vector2 mag)
        {
            return (float)Math.Sqrt(mag.X * mag.X + mag.Y * mag.Y);
        }

        public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
        {
            scale = 1.5f;
            return null;
        }

        private void Shoot()
        {

            if (Main.rand.Next(1, 200) == 199)
            {

                Vector2 perturbedSpeed = new Vector2(player.position.X + player.width / 2, player.position.Y + player.height / 2) -
                new Vector2(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2).RotatedByRandom(MathHelper.ToRadians(1)); // 30 degree spread.
                                                                                                                       // If you want to randomize the speed to stagger the projectiles
                                                                                                                       // float scale = 1f - (Main.rand.NextFloat() * .3f);
                                                                                                                       // perturbedSpeed = perturbedSpeed * scale;
                Projectile.NewProjectile(npc.position.X + npc.width / 2, npc.position.Y + npc.height / 2, perturbedSpeed.X, perturbedSpeed.Y, ProjectileID.PinkLaser, 200, 5, player.whoAmI, player.whoAmI, 0f);

            }
        }

        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            if (NPC.downedMoonlord && player.statDefense >= 70 || NPC.downedMoonlord && player.endurance >= 15)
            {
                return 0.1f;
            }else
            {
                return 0f;
            }
        }



    }
}

Try Again Mod

To Many Monsters!
yeah I had the same issue when trying to add custom music to a boss. it didn't play anything. i said " music = mod.GetSoundSlot(SoundType.Music, "ZephyrMod/Sounds/Music/Boss1Remix.mp3");" and it didn't work
 
yeah I had the same issue when trying to add custom music to a boss. it didn't play anything. i said " music = mod.GetSoundSlot(SoundType.Music, "ZephyrMod/Sounds/Music/Boss1Remix.mp3");" and it didn't work
Try this (with the mod name changed):

using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using Terraria;
using Terraria.ModLoader;

namespace RedCloudMusic
{
public class RedCloudMusic : Mod
{
public static RedCloudMusic instance;

public static RedCloudMusic inst;

public override void UpdateMusic(ref int music, ref MusicPriority priority)
{
if (NPC.AnyNPCs(4)) // Eye of Cthulhu
{
music = ((Mod)this).GetSoundSlot((SoundType)51, "Sounds/Music/Boss1");
priority = (MusicPriority)6;
}
}
}
}
 
I've run into a similar problem where the music is silent when attempting to play it, but I think it might have to do with the song itself.

I made a song using Garage Band on the iPad, but try as I might the song was silent when summoning EoC. I tried for literal days but had no luck. Then I opened ExampleMod and tinkered around with the mod's "Car Keys" item, which summons a Car Mount that plays a different song when used.

When I used the item as normal, the song played without issue. HOWEVER when I switched out the DriveMusic.mp3 and replaced it with my music and renaming it DriveMusic.mp3, it was silent once again.

Apple has always been real stingy about how they do things, and the way that their MP3s and Wavs are converted might be somehow conflicting with the game. I couldn't find anything else about it because I had to head to work right afterwards, bit I'll tinker with it more and post updates later.

*Edit*

Okay, so I just threw ExampleMod's DriveMusic.mp3 into my code and it worked like a charm. I can confirm that certain music creation software doesn't play nice with tModloader, and the only way I got it to work was by converting the song to .wav using Garage Band, then running it through a separate .mp3 converter. As soon as I slapped it into the Music folder and renamed it, it worked like a charm.

I hope this helps anyone having the same issue.
 
Last edited:
Back
Top Bottom