• 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 [Tutorial] Custom Invasion

Sin Costan

Eye of Cthulhu
Introduction:
Hello TCF community, and by a certain amount of curiosity, I decided to figure out how to make a custom invasion, though I am currently working on some of the kinks in a custom invasion event.

So I decided to do the tutorial as part of the thread instead, so you don’t need to go to a shady google doc to read basic Object Oriented Programming.

For this tutorial, I will be making the most bare bone skeleton of a custom invasion, the file provided is an example using the Dungeon mobs as an example.

So how do we begin our invasion… well, we start off of course with making the mod file itself. So we have our autoload except we add one more hook to the Mod C# file, and that is “UpdateMusic(ref int music)”. Now if you don’t know what “ref” is, it allows the modification of the parameter variable, meaning that the “int” variable that was passed into the parameter will change if the value of the parameter has changed within that method/hook. So to sum it up, just do “music = 1” and it will change it to the first song in the song bank.

So here is what it should look like:

Code:
using System;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ModLoader;

namespace ModName
{
    public class MMod : Mod
    {
        public MMod()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
                AutoloadGores = true,
                AutoloadSounds = true
            };
        }

        //Setting music to 1 which is “Night”
        public override void UpdateMusic(ref int music)
        {
            //Checks if the invasion is in the correct spot, if it is, then change the music
            (Main.invasionX == Main.spawnTileX)
            {
                music = 1;
   
        }
    }
}

So now to work on making the custom invasion. Instead of inheriting a class like we usually do to make our mods work, we willmake our own class, we’ll call CustomInvasion. We will however, still be using the “using” declerations for System and Terraria for this to work.

So we start off creating our file, it will look very similar to all the files except that it does not inherit a class.

Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CustomInvasion
{
    public class CustomInvasion
    {

    }
}

Now to start off our invasion, we want to make a list of what you want to add to your invasion. For vanilla NPCs, we can just call them through ID,. If you want to call

Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName
{
    public class CustomInvasion
    {
        //Initializing an Array that can be used in any file
        public static int[] invaders = {
            NPCID.Zombie,
            NPCID.BlueSlime,
            mod.NPCType("ModNPCName")
        };
    }
}

Now we got a pretty low list, but you can expand it later on by juts putting a comma after each NPC you wish to add. We want to have a way to start an invasion, so we will make a function of our own to start it up, you can add a parameter to it if you want it to be able to be called for multiple types of invasions, but for now, it will be parameter-less since we only have one.

Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName
{
    public class CustomInvasion
    {
        //Initializing an Array that can be used in any file
        public static int[] invaders = {
            NPCID.Zombie,
            NPCID.BlueSlime,
            mod.NPCType("ModNPCName")
        };

        //Setup for an Invasion
        public static void StartCustomInvasion()
        {
            //Set to no invasion if one is present
            if (Main.invasionType != 0 && Main.invasionSize == 0)
            {
                Main.invasionType = 0;
            }
   
            //Once it is set to no invasion setup the invasion
            if (Main.invasionType == 0)
            {
                //Checks amount of players for scaling
                int numPlayers = 0;
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active && Main.player[i].statLifeMax >= 200)
                    {
                        numPlayers++;
                    }
                }
                if (numPlayers > 0)
                {
                    //Invasion setup
                    Main.invasionType = -1; //Not going to be using an invasion that is positive since those are vanilla invasions
                    MWorld.customInvasionUp = true;
                    Main.invasionSize = 100 * numPlayers;
                    Main.invasionSizeStart = Main.invasionSize;
                    Main.invasionProgress = 0;
                    Main.invasionProgressIcon = 0 + 3;
                    Main.invasionProgressWave = 0;
                    Main.invasionProgressMax = Main.invasionSizeStart;
                    Main.invasionWarn = 3600; //This doesn't really matter, as this does not work, I like to keep it here anyways
                    if (Main.rand.Next(2) == 0)
                    {
                        Main.invasionX = 0.0; //Starts invasion immediately rather than wait for it to spawn
                        return;
                    }
                    Main.invasionX = (double)Main.maxTilesX; //Set the initial starting location of the invasion to max tiles
                }
            }
        }
    }
}

So now we need to add a way to update the invasion while it heads towards the player, we also want it to send messages to the player. So we will make two more functions (parameter-less in this case since we are only dealing with one), one called “CustomInvasionWarning()” and another called “CustomInvasionUpdate()”. Here is what they will look like…

Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName
{
    public class CustomInvasion
    {
        //Initializing an Array that can be used in any file
        public static int[] invaders = {
            NPCID.Zombie,
            NPCID.BlueSlime,
            mod.NPCType("ModNPCName")
        };

        //Setup for an Invasion After setting up
        public static void StartCustomInvasion()
        {
            //Set to no invasion if one is present
            if (Main.invasionType != 0 && Main.invasionSize == 0)
            {
                Main.invasionType = 0;
            }
   
            //Once it is set to no invasion setup the invasion
            if (Main.invasionType == 0)
            {
                //Checks amount of players for scaling
                int numPlayers = 0;
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active && Main.player[i].statLifeMax >= 200)
                    {
                        numPlayers++;
                    }
                }
                if (numPlayers > 0)
                {
                    //Invasion setup
                    Main.invasionType = -1; //Not going to be using an invasion that is positive since those are vanilla invasions
                    MWorld.customInvasionUp = true;
                    Main.invasionSize = 100 * numPlayers;
                    Main.invasionSizeStart = Main.invasionSize;
                    Main.invasionProgress = 0;
                    Main.invasionProgressIcon = 0 + 3;
                    Main.invasionProgressWave = 0;
                    Main.invasionProgressMax = Main.invasionSizeStart;
                    Main.invasionWarn = 3600; //This doesn't really matter, as this does not work, I like to keep it here anyways
                    if (Main.rand.Next(2) == 0)
                    {
                        Main.invasionX = 0.0; //Starts invasion immediately rather than wait for it to spawn
                        return;
                    }
                    Main.invasionX = (double)Main.maxTilesX; //Set the initial starting location of the invasion to max tiles
                }
            }
        }

        //Text for messages and syncing
        public static void CustomInvasionWarning()
        {
            String text = "";
            if (Main.invasionX == (double)Main.spawnTileX)
            {
                text = "Custom invasion has reached the spawn position!";
            }
            if(Main.invasionSize <= 0)
            {
                text = "Custom invasion has been defeated.";
            }
            if (Main.netMode == 0)
            {
                Main.NewText(text, 175, 75, 255, false);
                return;
            }
            if (Main.netMode == 2)
            {
                //Sync with net
                NetMessage.SendData(25, -1, -1, NetworkText.FromLiteral(text), 255, 175f, 75f, 255f, 0, 0, 0);
            }
        }

        //Updating the invasion
        public static void UpdateCustomInvasion()
        {
            //If the custom invasion is up
            if(MWorld.customInvasionUp)
            {
                //End invasion if size less or equal to 0
                if(Main.invasionSize <= 0)
                {
                    MWorld.customInvasionUp = false;
                    CustomInvasionWarning();
                    Main.invasionType = 0;
                    Main.invasionDelay = 0;
                }
       
                //Do not do the rest if invasion already at spawn
                if (Main.invasionX == (double)Main.spawnTileX)
                {
                    return;
                }
       
                //Update when the invasion gets to Spawn
                float moveRate = (float)Main.dayRate;
       
                //If the invasion is greater than the spawn position
                if (Main.invasionX > (double)Main.spawnTileX)
                {
                    //Decrement invasion x as to "move them"
                    Main.invasionX -= (double)moveRate;
           
                    //If less than the spawn pos, set invasion pos to spawn pos and warn players that invaders are at spawn
                    if (Main.invasionX <= (double)Main.spawnTileX)
                    {
                        Main.invasionX = (double)Main.spawnTileX;
                        CustomInvasionWarning();
                    }
                    else
                    {
                        Main.invasionWarn--;
                    }
                }
                else
                {
                    //Same thing as the if statement above, just it is from the other side
                    if (Main.invasionX < (double)Main.spawnTileX)
                    {
                        Main.invasionX += (double)moveRate;
                        if (Main.invasionX >= (double)Main.spawnTileX)
                        {
                            Main.invasionX = (double)Main.spawnTileX;
                            CustomInvasionWarning();
                        }
                        else
                        {
                            Main.invasionWarn--;
                        }
                    }
                }
            }
        }
    }
}

You probably saw the “MWorld.customInvasionUp” at some point, but we will be checking that out later. So let’s finish this file by adding in a way for it to report the progress of the invasion, checking the percentage of defeated npcs. So we will call this method “CheckCustomInvasionProgess()”. Most of this stuff I do not really understand myself, so some of the things will have comments telling you that I do not know what it does. Anyways, here is what your function should look like.

Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName
{
    public class CustomInvasion
    {
        //Initializing an Array that can be used in any file
        public static int[] invaders = {
            NPCID.Zombie,
            NPCID.BlueSlime,
            mod.NPCType("ModNPCName")
        };

        //Setup for an Invasion After setting up
        public static void StartCustomInvasion()
        {
            //Set to no invasion if one is present
            if (Main.invasionType != 0 && Main.invasionSize == 0)
            {
                Main.invasionType = 0;
            }
   
            //Once it is set to no invasion setup the invasion
            if (Main.invasionType == 0)
            {
                //Checks amount of players for scaling
                int numPlayers = 0;
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active && Main.player[i].statLifeMax >= 200)
                    {
                        numPlayers++;
                    }
                }
                if (numPlayers > 0)
                {
                    //Invasion setup
                    Main.invasionType = -1; //Not going to be using an invasion that is positive since those are vanilla invasions
                    MWorld.customInvasionUp = true;
                    Main.invasionSize = 100 * numPlayers;
                    Main.invasionSizeStart = Main.invasionSize;
                    Main.invasionProgress = 0;
                    Main.invasionProgressIcon = 0 + 3;
                    Main.invasionProgressWave = 0;
                    Main.invasionProgressMax = Main.invasionSizeStart;
                    Main.invasionWarn = 3600; //This doesn't really matter, as this does not work, I like to keep it here anyways
                    if (Main.rand.Next(2) == 0)
                    {
                        Main.invasionX = 0.0; //Starts invasion immediately rather than wait for it to spawn
                        return;
                    }
                    Main.invasionX = (double)Main.maxTilesX; //Set the initial starting location of the invasion to max tiles
                }
            }
        }

        //Text for messages and syncing
        public static void CustomInvasionWarning()
        {
            String text = "";
            if (Main.invasionX == (double)Main.spawnTileX)
            {
                text = "The Custom Invasion has started!";
            }
            if(Main.invasionSize <= 0)
            {
                text = "Custom Invasion is finished";
            }
            if (Main.netMode == 0)
            {
                Main.NewText(text, 175, 75, 255, false);
                return;
            }
            if (Main.netMode == 2)
            {
                //Sync with net
                NetMessage.SendData(25, -1, -1, NetworkText.FromLiteral(text), 255, 175f, 75f, 255f, 0, 0, 0);
            }
        }

        //Updating the invasion
        public static void UpdateCustomInvasion()
        {
            //If the custom invasion is up
            if(MWorld.customInvasionUp)
            {
                //End invasion if size less or equal to 0
                if(Main.invasionSize <= 0)
                {
                    MWorld.customInvasionUp = false;
                    CustomInvasionWarning();
                    Main.invasionType = 0;
                    Main.invasionDelay = 0;
                }
       
                //Do not do the rest if invasion already at spawn
                if (Main.invasionX == (double)Main.spawnTileX)
                {
                    return;
                }
       
                //Update when the invasion gets to Spawn
                float moveRate = (float)Main.dayRate;
       
                //If the invasion is greater than the spawn position
                if (Main.invasionX > (double)Main.spawnTileX)
                {
                    //Decrement invasion x as to "move them"
                    Main.invasionX -= (double)moveRate;
           
                    //If less than the spawn pos, set invasion pos to spawn pos and warn players that invaders are at spawn
                    if (Main.invasionX <= (double)Main.spawnTileX)
                    {
                        Main.invasionX = (double)Main.spawnTileX;
                        CustomInvasionWarning();
                    }
                    else
                    {
                        Main.invasionWarn--;
                    }
                }
                else
                {
                    //Same thing as the if statement above, just it is from the other side
                    if (Main.invasionX < (double)Main.spawnTileX)
                    {
                        Main.invasionX += (double)moveRate;
                        if (Main.invasionX >= (double)Main.spawnTileX)
                        {
                            Main.invasionX = (double)Main.spawnTileX;
                            CustomInvasionWarning();
                        }
                        else
                        {
                            Main.invasionWarn--;
                        }
                    }
                }
            }
        }

        //Checks the players' progress in invasion
        public static void CheckCustomInvasionProgress()
        {
            //Not really sure what this is
            if (Main.invasionProgressMode != 2)
            {
                Main.invasionProgressNearInvasion = false;
                return;
            }
   
            //Checks if NPCs are in the spawn area to set the flag, which I do not know what it does
            bool flag = false;
            Player player = Main.player[Main.myPlayer];
            Rectangle rectangle = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight);
            int num = 5000;
            int icon = 0;
            for (int i = 0; i < 200; i++)
            {
                if (Main.npc[i].active)
                {
                    icon = 0;
                    int type = Main.npc[i].type;
                    for(int n = 0; n < invaders.Length; n++)
                    {
                        if(type == invaders[n])
                        {
                            Rectangle value = new Rectangle((int)(Main.npc[i].position.X + (float)(Main.npc[i].width / 2)) - num, (int)(Main.npc[i].position.Y + (float)(Main.npc[i].height / 2)) - num, num * 2, num * 2);
                            if (rectangle.Intersects(value))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                }
            }
            Main.invasionProgressNearInvasion = flag;
            int progressMax3 = 1;
   
            //If the custom invasion is up, set the max progress as the initial invasion size
            if (MWorld.customInvasionUp)
            {
                progressMax3 = Main.invasionSizeStart;
            }
   
            //If the custom invasion is up and the enemies are at the spawn pos
            if(MWorld.customInvasionUp && (Main.invasionX == (double)Main.spawnTileX))
            {
                //Shows the UI for the invasion
                Main.ReportInvasionProgress(Main.invasionSizeStart - Main.invasionSize, progressMax3, icon, 0);
            }
   
            //Syncing start of invasion
            foreach(Player p in Main.player)
            {
                NetMessage.SendData(78, p.whoAmI, -1, null, Main.invasionSizeStart - Main.invasionSize, (float)Main.invasionSizeStart, (float)(Main.invasionType + 3), 0f, 0, 0, 0);
            }
        }
    }
}

Now that we have that set up, we can use these later because this file alone, cannot do anything so we will be using different files to act on the stuff we have in the CustomInvasion file. So to start off, let’s get started on spawning NPCs. So we need to change the spawn pool so that we only have the invaders and the spawn rate so we can have a bunch of enemies at once.

Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace ModName
{
    public class MNPC : GlobalNPC
    {
        //Change the spawn pool
        public override void EditSpawnPool(IDictionary< int, float > pool, NPCSpawnInfo spawnInfo)
        {
            //If the custom invasion is up and the invasion has reached the spawn pos
            if(MWorld. customInvasionUp&& (Main.invasionX == (double)Main.spawnTileX))
            {
                //Clear pool so that only the stuff you want spawns
                pool.Clear();
           
//key = NPC ID | value = spawn weight
                //pool.add(key, value)
           
                //For every ID inside the invader array in our CustomInvasion file
                foreach(int i in CustomInvasion.invaders)
                {
                    pool.Add(i, 1f); //Add it to the pool with the same weight of 1
                }
            }
        }

        //Changing the spawn rate
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            //Change spawn stuff if invasion up and invasion at spawn
            if(MWorld. customInvasionUp&& (Main.invasionX == (double)Main.spawnTileX))
            {
                spawnRate = 100; //The higher the number, the less chance it will spawn (thanks jopojelly for how spawnRate works)
                maxSpawns = 10000; //Max spawns of NPCs depending on NPC value
            }
        }
    }
}

We also want to make sure that NPCs don’t de-spawn on the player, so we need to maintain the timeLeft. We also want to progress the invasion, so we add it to the NPC’s loot. It should look like this.

Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace ModName
{
    public class MNPC : GlobalNPC
    {
        //Change the spawn pool
        public override void EditSpawnPool(IDictionary< int, float > pool, NPCSpawnInfo spawnInfo)
        {
            //If the custom invasion is up and the invasion has reached the spawn pos
            if(MWorld.customInvasionUp && (Main.invasionX == (double)Main.spawnTileX))
            {
                //Clear pool so that only the stuff you want spawns
                pool.Clear();
   
                //key = NPC ID | value = spawn weight
                //pool.add(key, value)
       
                //For every ID inside the invader array in our CustomInvasion file
                foreach(int i in CustomInvasion.invaders)
                {
                    pool.Add(i, 1f); //Add it to the pool with the same weight of 1
                }
            }
        }

        //Changing the spawn rate
        public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
        {
            //Change spawn stuff if invasion up and invasion at spawn
            if(MWorld.customInvasionUp && (Main.invasionX == (double)Main.spawnTileX))
            {
                spawnRate = 100; //Higher the number, the more spawns
                maxSpawns = 10000; //Max spawns of NPCs depending on NPC value
            }
        }

        //Adding to the AI of an NPC
        public override void PostAI(NPC npc)
        {
            //Changes NPCs so they do not despawn when invasion up and invasion at spawn
            if(MWorld.customInvasionUp && (Main.invasionX == (double)Main.spawnTileX))
            {
                npc.timeLeft = 1000;
            }
        }

        public override void NPCLoot(NPC npc)
        {
            //When an NPC (from the invasion list) dies, add progress by decreasing size
            if(MWorld.customInvasionUp)
            {
                //Gets IDs of invaders from CustomInvasion file
                foreach(int invader in CustomInvasion.invader)
                {
                    //If npc type equal to invader's ID decrement size to progress invasion
                    if(npc.type == invader)
                    {
                        Main.invasionSize -= 1;
                    }
                }
            }
        }
    }
}

Now we have a way for the NPCs to spawn and progress the invasion, let’s work on the world. For the world stuff we can set it up similarily to how a boss is set up for the world. One added variable we will be adding a Boolean to check if the invasion is up. We will also need to make sure that the invasion can update itself. Here is what your MWorld will like.

Code:
using System;
using System.Collections.Generic;

using Terraria;
using Terraria.ID;
using Terraria.DataStructures;
using Terraria.ModLoader;

namespace ModName
{
    public class MWorld : ModWorld
    {
        //Setting up variables for invasion
        public static bool customInvasionUp = false;
        public static bool downedCustomInvasion = false;

        //Initialize all variables to their default values
        public override void Initialize()
        {
            Main.invasionSize = 0;
            customInvasionUp = false;
            downedCustomInvasion = false;
        }

        //Save downed data
        public override TagCompound Save()
        {
            var downed = new List<string>();
            if (downedCustomInvasion) downed.Add("customInvasion");

            return new TagCompound {
                {"downed", downed}
            };
        }

        //Load downed data
        public override void Load(TagCompound tag)
        {
            var downed = tag.GetList<string>("downed");
            downedCustomInvasion = downed.Contains("customInvasion");
        }

        //Sync downed data
        public override void NetSend(BinaryWriter writer)
        {
            BitsByte flags = new BitsByte();
            flags[0] = downedCustomInvasion;
            writer.Write(flags);
        }

        //Sync downed data
        public override void NetReceive(BinaryReader reader)
        {
            BitsByte flags = reader.ReadByte();
            downedCustomInvasion = flags[0];
        }

        //Allow to update invasion while game is running
        public override void PostUpdate()
        {
            if(customInvasionUp)
            {
                if(Main.invasionX == (double)Main.spawnTileX)
                {
                    //Checks progress and reports progress only if invasion at spawn
                    CustomInvasion.CheckCustomInvasionProgress();
                }
                //Updates the custom invasion while it heads to spawn point and ends it
                CustomInvasion.UpdateCustomInvasion();
            }
        }
    }
}

Nice we have all the important components to an Invasion set up, now all we need is an item to start it up. Simply put, we make an item like a boss spawn except we have it start our invasion instead. Here is what that item will look like…

Code:
using System;
using Microsoft.Xna.Framework;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName.Items
{
    public class CustomInvasionSpawner : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "CustomInvasionSpawner";
            item.width = 32;
            item.height = 32;
            item.scale = 1;
            item.maxStack = 99;
            item.toolTip = "Starts Custom Invasion";
            item.useTime = 30;
            item.useAnimation = 30;
            item.UseSound = SoundID.Item1;
            item.useStyle = 1;
            item.consumable = true;
            item.value = Item.buyPrice(0, 1, 0, 0);
            item.rare = 3;
        }

        public override bool UseItem(Player player)
        {
            if(!MWorld.customInvasionUp)
            {
                Main.NewText("The custom invasion is starting.......", 175, 75, 255, false);
                CustomInvasion.StartCustomInvasion();
                return true;
            }
            else
            {
                return false;
            }
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

With that, this is how you make a custom invasion, so have fun making your own invasion event!
 

Attachments

Last edited:

Jofairden

Duke Fishron
tModLoader
I also have a custom code laying around for drawing an invasion type progress with waves, it's a bit too much of a pain to edit to be placed here however. Nice tutorial.
 

2grufs

Skeletron Prime
ummm, sorry to bother you but where j the folder would I put these files?
[doublepost=1495683853,1495683836][/doublepost]in, not j
 

2grufs

Skeletron Prime
um, I figured out where to put the files, but now it says
error CS0103: The name 'toWho' does not exist in the current context
[doublepost=1495684960,1495684890][/doublepost]I've only changed the directory and the name 'DungueonInvasion' to DungeonInvasion'
[doublepost=1495685383][/doublepost]could you maybe research a 'custom hardmode?'
 

2grufs

Skeletron Prime
I've located the source of the problem:

NetMessage.SendData(78, toWho, -1, "", Main.invasionSizeStart - Main.invasionSize, (float)Main.invasionSizeStart, (float)(Main.invasionType + 3), 0f, 0, 0, 0);
}
 

Sin Costan

Eye of Cthulhu
I've located the source of the problem:

NetMessage.SendData(78, toWho, -1, "", Main.invasionSizeStart - Main.invasionSize, (float)Main.invasionSizeStart, (float)(Main.invasionType + 3), 0f, 0, 0, 0);
}
Right I need to fix that on the example, did it in the Tutorial code, but not in the example invasion.

UPDATE: Updated File
 
Last edited:

2grufs

Skeletron Prime
can you update this to the newest mod version please?
[doublepost=1500796328,1500796241][/doublepost]My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(131,5) : error CS1502: The best overloaded method match for 'Terraria.NetMessage.SendData(int, int, int, Terraria.Localization.NetworkText, int, float, float, float, int, int, int)' has some invalid arguments

My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(131,37) : error CS1503: Argument 4: cannot convert from 'string' to 'Terraria.Localization.NetworkText'

My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(239,5) : error CS1502: The best overloaded method match for 'Terraria.NetMessage.SendData(int, int, int, Terraria.Localization.NetworkText, int, float, float, float, int, int, int)' has some invalid arguments

My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(239,43) : error CS1503: Argument 4: cannot convert from 'string' to 'Terraria.Localization.NetworkText'
[doublepost=1500796348][/doublepost]these are my current errors
 

Sin Costan

Eye of Cthulhu
can you update this to the newest mod version please?
[doublepost=1500796328,1500796241][/doublepost]My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(131,5) : error CS1502: The best overloaded method match for 'Terraria.NetMessage.SendData(int, int, int, Terraria.Localization.NetworkText, int, float, float, float, int, int, int)' has some invalid arguments

My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(131,37) : error CS1503: Argument 4: cannot convert from 'string' to 'Terraria.Localization.NetworkText'

My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(239,5) : error CS1502: The best overloaded method match for 'Terraria.NetMessage.SendData(int, int, int, Terraria.Localization.NetworkText, int, float, float, float, int, int, int)' has some invalid arguments

My Games\Terraria\ModLoader\Mod Sources\InvasionTest\DungueonInvasion.cs(239,43) : error CS1503: Argument 4: cannot convert from 'string' to 'Terraria.Localization.NetworkText'
[doublepost=1500796348][/doublepost]these are my current errors
I fixed it a while ago but I was too lazy to upload it for a while, but its up now.
 

2grufs

Skeletron Prime
hey sin costan, the skeleton banner is an item and it says "The dungeon beckons you..." but nothing happens. I've tried to cause an error log, but there aren't even warnings. the code is a bit advanced for me so I have no idea how to fix. can you help plz?
 

GabeHasWon

Steampunker
Code:
    public class CustomInvasion
    {
        //Initializing an Array that can be used in any file
        public static int[] invaders = {
            NPCID.Zombie,
            NPCID.BlueSlime,
            mod.NPCType("ModNPCName")
        };
    }
You should add a "mod" field. :p
Nice tutorial though
 

jb89

Official Terrarian
if your having trouble with the files change all the dungeoninvasion's to dungueoninvasion
 

Master Ludvig

Official Terrarian
Code:
    public class CustomInvasion
    {
        //Initializing an Array that can be used in any file
        public static int[] invaders = {
            NPCID.Zombie,
            NPCID.BlueSlime,
            mod.NPCType("ModNPCName")
        };
    }
You should add a "mod" field. :p
Nice tutorial though
This is the only thing that doesn't work for me: spawn custom npcs. What do you mean with add a "mod" field, and is that the solution?
 

2grufs

Skeletron Prime
ModLoader.GetMod("AbraxosMOD").NPCType("Alien"),
just change the modnpc name and the mod name
[doublepost=1509782565,1509782550][/doublepost]don't add a comma on the last one
 
Top Bottom