tModLoader Official tModLoader Help Thread

I'm getting an error message: error CS0115 "LemonDemon.SetDefauts" no suitable method to override warnings. Here is my code for y'all.


using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;


namespace SwordTest.NPCs
{
public class LemonDemon : ModNPC
{
public override void SetDefauts()
{
npc.name = "LemonDemon";
npc.displayname = "Lemon Demon";
npc.width = 42;
npc.width = 31;
npc.damage = 42;
npc.defense = 8;
npc.lifemax = 120;
npc.soundhit = 21;
npc.soundkilled = 24;
npc.value = 60f;
npc.knockBackResist = 0.8;
npc.aiStyle = 14;
main.npcFrameCount[npc.type] = 3;
aiType = NPCID.Demon;
animationType = NPCID.Demon;
}

public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return spawnInfo.spawnTileY < Main.maxTilesY - 200 && !Main.dayTime ? 0.5f : 0.5f;
}

public override void FindFrame(int frameHeight)
{
npc.frameCounter -= 0.8f;
npc.frameCounter %= Main.npcFrameCount[npc.type];
int frame = (int)NPCs.frameCounter;
npc.frame.Y = frame * frameHeight;

npc.spriteDirection = npc.direction;
}
public override void NPCLoot()
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Lemon"), 3);
}
}

}
 
I'm getting an error message: error CS0115 "LemonDemon.SetDefauts" no suitable method to override warnings. Here is my code for y'all.


using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;


namespace SwordTest.NPCs
{
public class LemonDemon : ModNPC
{
public override void SetDefauts()
{
npc.name = "LemonDemon";
npc.displayname = "Lemon Demon";
npc.width = 42;
npc.width = 31;
npc.damage = 42;
npc.defense = 8;
npc.lifemax = 120;
npc.soundhit = 21;
npc.soundkilled = 24;
npc.value = 60f;
npc.knockBackResist = 0.8;
npc.aiStyle = 14;
main.npcFrameCount[npc.type] = 3;
aiType = NPCID.Demon;
animationType = NPCID.Demon;
}

public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return spawnInfo.spawnTileY < Main.maxTilesY - 200 && !Main.dayTime ? 0.5f : 0.5f;
}

public override void FindFrame(int frameHeight)
{
npc.frameCounter -= 0.8f;
npc.frameCounter %= Main.npcFrameCount[npc.type];
int frame = (int)NPCs.frameCounter;
npc.frame.Y = frame * frameHeight;

npc.spriteDirection = npc.direction;
}
public override void NPCLoot()
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Lemon"), 3);
}
}

}
"l" is missing. Change "SetDefauts" to "SetDefaults"
 
I have a problem with my code. I'm getting the error message that "P" doesn't exist. I followed Al0n37 on how to create a boss that shoots projectiles. You can watch it here.

I think I have copied everything and followed everything that he told me to do.

Code:
C++:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName.Bosses
{
    public class BossName : ModNPC
    {

      


        public override void SetDefaults()
        {
            npc.aiStyle = 5;  //5 is the flying AI
            npc.lifeMax = 500000;   //boss life
            npc.damage = 200;  //boss damage
            npc.defense = 55;    //boss defense
            npc.knockBackResist = 0f;
            npc.width = 100;
            npc.height = 100;
            animationType = NPCID.DemonEye;   //this boss will behavior like the DemonEye
            Main.npcFrameCount[npc.type] = 2;    //boss frame/animation
            npc.npcSlots = 1f;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = true;
            npc.noTileCollide = true;
            npc.HitSound = SoundID.NPCHit5;
            npc.DeathSound = SoundID.NPCDeath7;
            npc.buffImmune[24] = true;
            music = MusicID.Boss2;
            npc.netAlways = true;

          
      

          

        }
    
        public override void BossLoot(ref string name, ref int potionType)
        {
            potionType = ItemID.GreaterHealingPotion;   //boss drops
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Name"));
        }
        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()
        {
                npc.ai[1]++;
                if (npc.ai[1] >= 230)
                {
                    float Speed = 20f;
                    Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                    int damage = 80;
                    int type = mod.ProjectileType("Projectile");
                    Main.PlaySound(23, (int)npc.position.X, (int)npc.position.Y, 17);
                    float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                    int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation)*Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                    npc.ai[1]=0;
                }
        }

      

    }
}

(Line like 67 or something)
I'm new to coding (I can't code) so it might just be something stupid that I don't recognize. Sorry, if that is the case.
 
Last edited:
I have a problem with my code. I'm getting the error message that "P" doesn't exist. I followed Al0n37 on how to create a boss that shoots projectiles. You can watch it here.

I think I have copied everything and followed everything that he told me to do.

Code:
C++:
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ModName.Bosses
{
    public class BossName : ModNPC
    {

     


        public override void SetDefaults()
        {
            npc.aiStyle = 5;  //5 is the flying AI
            npc.lifeMax = 500000;   //boss life
            npc.damage = 200;  //boss damage
            npc.defense = 55;    //boss defense
            npc.knockBackResist = 0f;
            npc.width = 100;
            npc.height = 100;
            animationType = NPCID.DemonEye;   //this boss will behavior like the DemonEye
            Main.npcFrameCount[npc.type] = 2;    //boss frame/animation
            npc.npcSlots = 1f;
            npc.boss = true;
            npc.lavaImmune = true;
            npc.noGravity = true;
            npc.noTileCollide = true;
            npc.HitSound = SoundID.NPCHit5;
            npc.DeathSound = SoundID.NPCDeath7;
            npc.buffImmune[24] = true;
            music = MusicID.Boss2;
            npc.netAlways = true;

         
     

         

        }
   
        public override void BossLoot(ref string name, ref int potionType)
        {
            potionType = ItemID.GreaterHealingPotion;   //boss drops
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("Name"));
        }
        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()
        {
                npc.ai[1]++;
                if (npc.ai[1] >= 230)
                {
                    float Speed = 20f;
                    Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                    int damage = 80;
                    int type = mod.ProjectileType("Projectile");
                    Main.PlaySound(23, (int)npc.position.X, (int)npc.position.Y, 17);
                    float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                    int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation)*Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                    npc.ai[1]=0;
                }
        }

     

    }
}

(Line like 67 or something)
I'm new to coding (I can't code) so it might just be something stupid that I don't recognize. Sorry, if that is the case.
Al0n37 is ludicrously outdated and should be avoided. Check for better tutorials first off. Secondly, to fix your problem, you need to declare P before you use it. It's being used during the declaration of your rotation float. You need to add Player P = Main.player[npc.target]; in public override void AI(). Then you'll have a vector to call for the rotation float.
 
Thanks! It runs my game now!


It doesn't shoot projectiles though...
Maybe I have to copy the code for the projectiles too.
I thought it was only for the dust animation.
 
Last edited:
I keep getting this error and it seems to happen whenever the game tries to load new mods and it's really annoying
 

Attachments

  • problem.PNG
    problem.PNG
    25.7 KB · Views: 97
Hello all, I have had a problem for a while that I cant seem to fix myself, even though I've done a lot of research on it. My goal is to generate 4 of my custom ores for my mod when creating/generating a new world, but only the ore Magmalite (it can be seen in my code below) seems to generate when I log into a new world. I've searched a lot of most worlds that I've used to test, and I'm positive that the other ores simply aren't generating. I'm also a relatively new coder, although I understand most of my code. I credit example mod and the makers of it for helping me learn how to make a lot of this stuff, and thank you for any help i get for this problem

What I've tried so far:

  • messing with the code and laying it out in different ways to see if it works, in which those other ways did not work
  • watching and reading various videos and parts of the tmodloader forum that have to do with this, along with reading example mods world gen code section, but I still couldn't figure out the problem with my code that makes it so that only one of the ores generate



C#:
using System.IO;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Terraria.GameContent.Generation;

namespace GalandricaMod.Worlds
{
    public class GalandricaWorld : ModWorld
    {
        private const int saveVersion = 0;
        public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
        {
            // Because world generation is like layering several images ontop of each other, we need to do some steps between the original world generation steps.

            // The first step is an Ore. Most vanilla ores are generated in a step called "Shinies", so for maximum compatibility, we will also do this.
            // First, we find out which step "Shinies" is.
            int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
            if (ShiniesIndex != -1)
            {
                // Next, we insert our step directly after the original "Shinies" step. 
                // "...OreGen" are methods seen below.
                tasks.Insert(ShiniesIndex + 1, new PassLegacy("Magmalite Ore", MagmaliteOreGen));
                tasks.Insert(ShiniesIndex + 2, new PassLegacy("Liquilate Ore", LiquilateOreGen));
                tasks.Insert(ShiniesIndex + 3, new PassLegacy("Gairswind Ore", GairswindOreGen));
                tasks.Insert(ShiniesIndex + 4, new PassLegacy("Erodate Ore", ErodateOreGen));
            }
        }
        private void MagmaliteOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
            //Put your custom tile block name
            for (int k = 0; k < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); k++)                                                                                                                                      //      |
            {                                                                                                                                                                                                                      //       |
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(2, 6), mod.TileType("MagmaliteOreTile"), false, 0f, 0f, false, true);
            }    
        }
        private void LiquilateOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
            for (int l = 0; l < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); l++)                                                                                                                                      //      |
            {                                                                                                                                                                                                                      //       |
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(2, 6), mod.TileType("LiquilateOreTile"), false, 0f, 0f, false, true);
            }
        }
        private void GairswindOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
            for (int o = 0; o < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); o++)                                                                                                                                      //      |
            {                                                                                                                                                                                                                      //       |
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(2, 6), mod.TileType("GairswindOreTile"), false, 0f, 0f, false, true);
            }
        }
        private void ErodateOreGen(GenerationProgress progress)
        {
            progress.Message = "Creating the first elemental ores";
            for (int p = 0; p < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 6E-05); p++)                                                                                                                                      //      |
            {                                                                                                                                                                                                                      //       |
                WorldGen.TileRunner(WorldGen.genRand.Next(0, Main.maxTilesX), WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, (int)WorldGen.worldSurfaceHigh + 150), (double)WorldGen.genRand.Next(4, 8), WorldGen.genRand.Next(2, 6), mod.TileType("ErodateOreTile"), false, 0f, 0f, false, true);
            }
        }
    }
}
 
Well cmon now, i posted a post asking for help, then almost instantly took it down cause i thought i was blind and dumb, but now... the enable developer mode button doesnt do anything it is just there, and doesnt work
1575787783040.png
 
Well cmon now, i posted a post asking for help, then almost instantly took it down cause i thought i was blind and dumb, but now... the enable developer mode button doesnt do anything it is just there, and doesnt work
I figured it out, i had to go in and download a couple things for Visual studio
 
Im getting this error and i cant seem to fix it:

[20/ERROR] [tML]: An error occurred while loading ThoriumMod
The mod(s) have been automatically been disabled.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Terraria.ModLoader.Core.AssemblyManager.Instantiate(LoadedMod mod)
at Terraria.ModLoader.Core.AssemblyManager.<>c__DisplayClass10_0.<InstantiateMods>b__1(LoadedMod mod)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Terraria.ModLoader.Core.AssemblyManager.InstantiateMods(List`1 modsToLoad, CancellationToken token)
at Terraria.ModLoader.Core.ModOrganizer.LoadMods(CancellationToken token)
at Terraria.ModLoader.ModLoader.Load(CancellationToken token)

Does anyone else know how to?
I am having the exact same problem, also can't find a solution to this. Were you able to solve this problem by now or are you still waiting for someone to help you? If, by any chance, you've "cracked the code", then I beg of you, please share your solution!
 
I'm currently trying to make a Test mod for Terraria and keep running into issues. I'm trying to make a sword, that has Dust effects, a projectile, and possibly a animated texture for the sword while its in the inventory. PLEASE HELP

Sorry about the format, I didn't know how else to upload
 

Attachments

  • Cracked Projectile.txt
    797 bytes · Views: 115
  • CrackedBlade.txt
    2 KB · Views: 106
  • TestDust.txt
    972 bytes · Views: 100
I'm currently trying to make a Test mod for Terraria and keep running into issues. I'm trying to make a sword, that has Dust effects, a projectile, and possibly a animated texture for the sword while its in the inventory. PLEASE HELP

Sorry about the format, I didn't know how else to upload
my man all those files are in basic text format, they wont do anything related to code that way.

oh you know what im blind, didnt see the format apology, sorry about that.
 
Hello,

Recently updated to v0.11.5 and some debug menus (i presume they are debug menus) appear on the main menu, and when i try to load a world, once it finishes loading, it just crashes to desktop.
I have Terraria Overhaul and Chad's Furniture installed. It used to work before the update. I'm also on a laptop if that makes any difference (cause dual GPU's). Screenshots below.


1576335263079.png
1576335339117.png
 
Hello,

Recently updated to v0.11.5 and some debug menus (i presume they are debug menus) appear on the main menu, and when i try to load a world, once it finishes loading, it just crashes to desktop.
I have Terraria Overhaul and Chad's Furniture installed. It used to work before the update. I'm also on a laptop if that makes any difference (cause dual GPU's). Screenshots below.


View attachment 231363View attachment 231364
I don't exactly know the problem, but I've seen that lots of other people have had this problem with Terraria Overhaul after the new update. Try going back a few pages and see if you can find a solution.
 
Hello,

I have intalled the v0.11.5 and I have been unable to open my maps. The game loads normally, but it crashes when I try to open my maps, any idea how to fix this?
Screenshot_11.png
Screenshot_12.png
 
Back
Top Bottom