tModLoader Any monster spawn rate and spawn cap mod?

Pacze

Terrarian
Hey there,

Some friends and me are looking for some very challenging server to play, as we do every now and then.
What we are missing now is a mod (hopefully that uses tmodloader) that would let us increase the NPC spawn cap and lower the NPC spawn rate (lower meaning faster spawns) on a server.

I used the search function multiple times with different keywords but couldn't find anything. Except for a piece of code posted by jopojelly some time ago in this thread:
http://forums.terraria.org/index.php?threads/spawn-rate-question.45066/

We'd rather avoid using "Cheat Sheet", cause of its extra features.
So yep, does anyone know about a mod that would actually do this, or any way to do it? We would really appreciate it!

Also, I'm sorry if i posted this on the wrong section, kinda tried to choose the one that seemed less incorrect to me.

Grettings,
 
Well, you can make a folder called "SpawnBoostMod" and make a file called "SpawnBoostMod.cs" in that folder with the following code, then build it using the Mod Sources menu in tmodloader, and it's all ready to go.

Code:
using Terraria;
using Terraria.ModLoader;

namespace SpawnBoostMod
{
    class SpawnBoostMod : Mod { }

    class SpawnRateMultiplierGlobalNPC : GlobalNPC
    {
        static float multiplier = 5f;
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns) {
            spawnRate = (int)(spawnRate / multiplier);
            maxSpawns = (int)(maxSpawns * multiplier);
        }
    }
}
 
Last edited:
Well, you can make a folder called "SpawnBoostMod" and make a file called "SpawnBoostMod.cs" in that folder with the following code, then build it using the Mod Sources menu in tmodloader, and it's all ready to go.

Code:
using Terraria;
using Terraria.ModLoader;

namespace SpawnBoostMod
{
    class SpawnBoostMod : Mod
    {
        public SpawnBoostMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
            };
        }
    }

    class SpawnRateMultiplierGlobalNPC : GlobalNPC
    {
        float multiplier = 5f;
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            spawnRate = (int)(spawnRate / multiplier);
            maxSpawns = (int)(maxSpawns * multiplier);
        }
    }
}

Is there anyway to make this only apply if you are under the battle potion effect? Would love to make them about like how the 15x from cheatsheet works.
 
Is there anyway to make this only apply if you are under the battle potion effect? Would love to make them about like how the 15x from cheatsheet works.
Try this:
Code:
using Terraria;
using Terraria.ModLoader;

namespace SpawnBoostMod
{
    class SpawnBoostMod : Mod
    {
        public SpawnBoostMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
            };
        }
    }

    class SpawnRateMultiplierGlobalNPC : GlobalNPC
    {
        float multiplier = 5f;
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            if(player.enemySpawns)
            {
                spawnRate = (int)(spawnRate / multiplier);
                maxSpawns = (int)(maxSpawns * multiplier);
            }
        }
    }
}
I have a hunch that this will stack weirdly, so you will probably have to experiment with different values before it works.
 
Try this:
Code:
using Terraria;
using Terraria.ModLoader;

namespace SpawnBoostMod
{
    class SpawnBoostMod : Mod
    {
        public SpawnBoostMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
            };
        }
    }

    class SpawnRateMultiplierGlobalNPC : GlobalNPC
    {
        float multiplier = 5f;
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            if(player.enemySpawns)
            {
                spawnRate = (int)(spawnRate / multiplier);
                maxSpawns = (int)(maxSpawns * multiplier);
            }
        }
    }
}
I have a hunch that this will stack weirdly, so you will probably have to experiment with different values before it works.

Thank you, this works great!
 
Last edited:
Well, you can make a folder called "SpawnBoostMod" and make a file called "SpawnBoostMod.cs" in that folder with the following code, then build it using the Mod Sources menu in tmodloader, and it's all ready to go.

Code:
using Terraria;
using Terraria.ModLoader;

namespace SpawnBoostMod
{
    class SpawnBoostMod : Mod
    {
        public SpawnBoostMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
            };
        }
    }

    class SpawnRateMultiplierGlobalNPC : GlobalNPC
    {
        float multiplier = 5f;
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            spawnRate = (int)(spawnRate / multiplier);
            maxSpawns = (int)(maxSpawns * multiplier);
        }
    }
}
Can i somehow choose how fast and how many mobs will spawn?
 
Can i somehow choose how fast and how many mobs will spawn?
spawnRate is the 1:X chance each frame that an NPC will spawn provided maxSpawns isn't reached.
maxSpawns is the total number of enemy NPC that can spawn. Most NPC count as 1 towards this number, some more, like bosses, some less.

Adjust those numbers however you like. I used the same multiplier for each, but you can use different numbers if you want to.
 
spawnRate is the 1:X chance each frame that an NPC will spawn provided maxSpawns isn't reached.
maxSpawns is the total number of enemy NPC that can spawn. Most NPC count as 1 towards this number, some more, like bosses, some less.

Adjust those numbers however you like. I used the same multiplier for each, but you can use different numbers if you want to.
I have no idea how this code works though, what if i want max 250 mobs on the screen while having them spawn 10/sec?
 
I have no idea how this code works though, what if i want max 250 mobs on the screen while having them spawn 10/sec?
Oh, well the point of the code I posted was to take advantage of Peace candles and Water candles, but if you want it constant no matter what, know that there are 60 frames a seconds, so since you want 10 a second, I think 6 works:

spawnRate = 6;
maxSpawns = 250;
 
Hey, I'm also looking to increase spawn rates, but the code shown above seems to be constant across all areas. For example, putting 'spawnRate = 6' also applies to Forest (Surface day) and will just make A LOT of slimes appear.

http://terraria.wiki.gg/NPC_spawning

I would like to be able to just halve these spawn rates, while capping the maximum spawns to about 60. For example, I would love if Forest (Surface day) had a spawn rate of 300, and Meteorite (day) to have 120, instead of 600 and 240 respectively. Is this possible?
 
Hey, I'm also looking to increase spawn rates, but the code shown above seems to be constant across all areas. For example, putting 'spawnRate = 6' also applies to Forest (Surface day) and will just make A LOT of slimes appear.

http://terraria.wiki.gg/NPC_spawning

I would like to be able to just halve these spawn rates, while capping the maximum spawns to about 60. For example, I would love if Forest (Surface day) had a spawn rate of 300, and Meteorite (day) to have 120, instead of 600 and 240 respectively. Is this possible?
Yeah, look at the first example I posted earlier in the thread. (multiplier of 2) If you want more specific than 2x spawns depending on the Biome, you'll have to check the zones the player is in.
 
Yeah, look at the first example I posted earlier in the thread. (multiplier of 2) If you want more specific than 2x spawns depending on the Biome, you'll have to check the zones the player is in.
spawnRate = (int)(spawnRate / 2);
maxSpawns = 60;

Would I change it to this? Sorry, I'm a complete newb with code.
 
I am so sorry for necrothreading but I'm having a lot of trouble with this because its the first thing I've done with mods and i was wondering if you could post an example with everything thats needed changed or a list of what needs to be changed and the description because I've found nothing on the internet or github (https://github.com/blushiemagic/tMo...Q#sequence-contains-no-matching-element-error) because it says "see ??? for more information"
Please help, I will appreciate it

-Clueless terraria modder
 

Ok i keep getting errors upon loadup

code looks like this:

using Terraria;
using Terraria.ModLoader;

namespace SpawnBoostMod
{
class SpawnBoostMod : Mod
{
public SpawnBoostMod()
{
Properties = new ModProperties()
{
Autoload = true,
};
}
}

class SpawnRateMultiplierGlobalNPC : GlobalNPC
{
float multiplier = 5f;
public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
{
if(player.enemySpawns)
{
spawnRate = 6;
maxSpawns = 50;
}
}
}
}

And the error looks like this:
 

Attachments

  • Untitled.png
    Untitled.png
    255.7 KB · Views: 2,190
Back
Top Bottom