• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

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,
 

jopojelly

Retinazer
tModLoader
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:

Codec

Terrarian
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.
 

Kazzymodus

Moderator
Staff member
Moderator
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.
 

Codec

Terrarian
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:

Shakou

Terrarian
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?
 

jopojelly

Retinazer
tModLoader
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.
 

Shakou

Terrarian
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?
 

jopojelly

Retinazer
tModLoader
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;
 

Potency

Terrarian
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.gamepedia.com/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?
 

jopojelly

Retinazer
tModLoader
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.gamepedia.com/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.
 

Potency

Terrarian
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: 1,582
Top Bottom