• For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
  • 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.
  • Begin your search for Journey's End information here and here. Please report bugs and issues for Journey's End here.
  • For issues you find with the Mobile 1.3 update, please follow this link and give as much detail as possible. This is the speediest way to get info to DR Studios to look at your issue. Also, some troubleshooting hints here.

tModLoader Official tModLoader Help Thread

dreverseb

Terrarian
\NicksMod\Items\DesertChitinHelmet.cs(35,37) : error CS1011: Empty character literal
NicksMod\Items\DesertChitinHelmet.cs(35,37) : error CS1010: Newline in constant
plz help me i have no idea whats going on
tModLoader says:
In string number 35 symbol number 37 is wrong.

In string: player.statDefense += 4;'
Delete this: '
 

Wiggs

Terrarian
Hello, I've been trying to make a new biome for my Terraria mod. I have been trying to add more then one block to the world, but it only comes out as all one block or the other. Code:
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;
using System.Linq;


namespace VolcanoMod
{
public class ModNameWorld : ModWorld
{

public override void ModifyWorldGenTasks(List<GenPass> tasks, ref float totalWeight)
{
int genIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
if (genIndex == -1)
{
return;
}
tasks.Insert(genIndex + 1, new PassLegacy("Custom Biome", delegate (GenerationProgress progress)
{
progress.Message = "Custom Biome Progress";
for (int i = 0; i < Main.maxTilesX / 900; i++)
{
int X = WorldGen.genRand.Next(1, Main.maxTilesX - 300);
int Y = WorldGen.genRand.Next((int)WorldGen.rockLayer - 100, Main.maxTilesY - 200);
int TileType = 57;

WorldGen.TileRunner(X, Y, 350, WorldGen.genRand.Next(100, 200), TileType, false, 0f, 0f, true, true);
{
int Xo = X + Main.rand.Next(100, 200);
int Yo = Y + Main.rand.Next(100, 200);
if (Main.tile[Xo, Yo].type == mod.TileType("CustomTileBlock"))
{

{
WorldGen.TileRunner(Xo, Yo, (double)WorldGen.genRand.Next(5, 10), WorldGen.genRand.Next(5, 10), mod.TileType("CustomOreTile"), false, 0f, 0f, false, true);
}
}
}
}

}));
}
}
}
 

Nick_Kick_Butt

Terrarian
NicksMod\Npcs\KillerWhale.cs(32,97) : error CS1061: 'Terraria.Player' does not contain a definition for 'ZoneOcean' and no extension method 'ZoneOcean' accepting a first argument of type 'Terraria.Player' could be found (are you missing a using directive or an assembly reference?)
can someone plz help me
i wanna know how i would make it spawn in ocean only
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

                                                            //By Al0n37
namespace NicksMod.Npcs
{
    public class KillerWhale : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Killer Whale";
            npc.displayName = "Killer Whale";
            npc.width = 120;
            npc.height = 54;
            npc.damage = 110;
            npc.defense = 6;
            npc.lifeMax = 800;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 60f;
            npc.knockBackResist = 0.0f;
            npc.aiStyle = 44;
            Main.npcFrameCount[npc.type] = 1;
            aiType = NPCID.Shark;  //npc behavior
            animationType = NPCID.Shark;
        }

        public override float CanSpawn(NPCSpawnInfo spawnInfo)
        {
            return spawnInfo.spawnTileY < Main.worldSurface && Main.dayTime && spawnInfo.player.ZoneOcean
? 0.09f : 0.00f; //spawn at day
        }
        public override void FindFrame(int frameHeight)
        {
            npc.frameCounter -= 0.5F; // Determines the animation speed. Higher value = faster animation.
            npc.frameCounter %= Main.npcFrameCount[npc.type];
            int frame = (int)npc.frameCounter;
            npc.frame.Y = frame * frameHeight;

            npc.spriteDirection = npc.direction;
           
               

           
       


        }
        public override void NPCLoot()  //Npc drop
        {
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OrcaFin"), 1); //Item spawn
            }
        }
    }
}
 

jopojelly

Retinazer
tModLoader
NicksMod\Npcs\KillerWhale.cs(32,97) : error CS1061: 'Terraria.Player' does not contain a definition for 'ZoneOcean' and no extension method 'ZoneOcean' accepting a first argument of type 'Terraria.Player' could be found (are you missing a using directive or an assembly reference?)
can someone plz help me
i wanna know how i would make it spawn in ocean only
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

                                                            //By Al0n37
namespace NicksMod.Npcs
{
    public class KillerWhale : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Killer Whale";
            npc.displayName = "Killer Whale";
            npc.width = 120;
            npc.height = 54;
            npc.damage = 110;
            npc.defense = 6;
            npc.lifeMax = 800;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 60f;
            npc.knockBackResist = 0.0f;
            npc.aiStyle = 44;
            Main.npcFrameCount[npc.type] = 1;
            aiType = NPCID.Shark;  //npc behavior
            animationType = NPCID.Shark;
        }

        public override float CanSpawn(NPCSpawnInfo spawnInfo)
        {
            return spawnInfo.spawnTileY < Main.worldSurface && Main.dayTime && spawnInfo.player.ZoneOcean
? 0.09f : 0.00f; //spawn at day
        }
        public override void FindFrame(int frameHeight)
        {
            npc.frameCounter -= 0.5F; // Determines the animation speed. Higher value = faster animation.
            npc.frameCounter %= Main.npcFrameCount[npc.type];
            int frame = (int)npc.frameCounter;
            npc.frame.Y = frame * frameHeight;

            npc.spriteDirection = npc.direction;
          
              

          
      


        }
        public override void NPCLoot()  //Npc drop
        {
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("OrcaFin"), 1); //Item spawn
            }
        }
    }
}
ZoneBeach
 

Hallam_9K

Spazmatism
Hey, is there a line of code I could use to change my NPC's Health if its Expert Mode?
Well, there is this:
Code:
        public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);  //boss life scale in expertmode
        }
But I think that may or may not be for bosses.
 

Nick_Kick_Butt

Terrarian
Does anyone know why my fighter type zombie npc blinks after getting hit or turning around?
Also does anyone know how to make a fighter type npc shoot projectile
heres code below
Before you read my npc sprite has 3 animations
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

                                                            //By Al0n37
namespace NicksMod.Npcs
{
    public class NoviceMageZombie : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Novice Mage Zombie";
            npc.displayName = "Novice Mage Zombie";
            npc.width = 50;
            npc.height = 50;
            npc.damage = 30;
            npc.defense = 2;
            npc.lifeMax = 120;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 60f;
            npc.knockBackResist = 0.2f;
            npc.aiStyle = 3;
            Main.npcFrameCount[npc.type] = 3;
            aiType = NPCID.Zombie;  //npc behavior
            animationType = NPCID.Zombie;
        }

        public override float CanSpawn(NPCSpawnInfo spawnInfo)
        {
            return spawnInfo.spawnTileY < Main.worldSurface && !Main.dayTime ? 0.2f : 0.00f; //spawn at night
        }
        public override void FindFrame(int frameHeight)
        {
            npc.frameCounter -= 0.8F; // Determines the animation speed. Higher value = faster animation.
            npc.frameCounter %= Main.npcFrameCount[npc.type];
            int frame = (int)npc.frameCounter;
            npc.frame.Y = frame * frameHeight;

            npc.spriteDirection = npc.direction;
           
               

           
       


        }
        public override void NPCLoot()  //Npc drop
        {
            {
 

Hallam_9K

Spazmatism
Does anyone know why my fighter type zombie npc blinks after getting hit or turning around?
Also does anyone know how to make a fighter type npc shoot projectile
heres code below
Before you read my npc sprite has 3 animations
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

                                                            //By Al0n37
namespace NicksMod.Npcs
{
    public class NoviceMageZombie : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Novice Mage Zombie";
            npc.displayName = "Novice Mage Zombie";
            npc.width = 50;
            npc.height = 50;
            npc.damage = 30;
            npc.defense = 2;
            npc.lifeMax = 120;
            npc.HitSound = SoundID.NPCHit1;
            npc.DeathSound = SoundID.NPCDeath1;
            npc.value = 60f;
            npc.knockBackResist = 0.2f;
            npc.aiStyle = 3;
            Main.npcFrameCount[npc.type] = 3;
            aiType = NPCID.Zombie;  //npc behavior
            animationType = NPCID.Zombie;
        }

        public override float CanSpawn(NPCSpawnInfo spawnInfo)
        {
            return spawnInfo.spawnTileY < Main.worldSurface && !Main.dayTime ? 0.2f : 0.00f; //spawn at night
        }
        public override void FindFrame(int frameHeight)
        {
            npc.frameCounter -= 0.8F; // Determines the animation speed. Higher value = faster animation.
            npc.frameCounter %= Main.npcFrameCount[npc.type];
            int frame = (int)npc.frameCounter;
            npc.frame.Y = frame * frameHeight;

            npc.spriteDirection = npc.direction;
          
              

          
      


        }
        public override void NPCLoot()  //Npc drop
        {
            {
Here's for shooting projectiles:
Code:
        public override void AI()
        {
            npc.ai[0]++;
            Player P = Main.player[npc.target];
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            npc.netUpdate = true;

            npc.ai[1]++;
            if (npc.ai[1] >= 230)  // 230 is projectile fire rate
            {
                float Speed = 14f;  //projectile speed
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 2), npc.position.Y + (npc.height / 2));
                int damage = 20;  //projectile damage
                int type = mod.ProjectileType("NAME_OF_PROJECTILE_HERE");  //put your projectile
                Main.PlaySound(15, (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;
            }
 

a1b2c41

Official Terrarian
Hey im having an error:
c:\Users\user\Documents\My Games\Terraria\ModLoader\Mod Sources\MTGMod\Projectiles\FeastAndFamine.cs(24,29) : error CS1001: Identifier expected

below is the code with the error line commented on.

public override void SetDefaults()
{
projectile.name = "FeastAndFamine";
projectile.width = 20;
projectile.height = 20;
projectile.alpha = 255;
projectile.friendly = true;
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.ranged = true;
ProjectileID.Sets.Bullet.[projectile.type] = true; //this is the error line
projectile.timeLeft = 500;
}

can someone please help?
 

Eldrazi

Eater of Worlds
Hey im having an error:
c:\Users\user\Documents\My Games\Terraria\ModLoader\Mod Sources\MTGMod\Projectiles\FeastAndFamine.cs(24,29) : error CS1001: Identifier expected

below is the code with the error line commented on.

public override void SetDefaults()
{
projectile.name = "FeastAndFamine";
projectile.width = 20;
projectile.height = 20;
projectile.alpha = 255;
projectile.friendly = true;
projectile.tileCollide = false;
projectile.ignoreWater = true;
projectile.ranged = true;
ProjectileID.Sets.Bullet.[projectile.type] = true; //this is the error line
projectile.timeLeft = 500;
}

can someone please help?
You have Bullet.[projectile.type] remove the . there
 

dreverseb

Terrarian
Hm... i have some trouble. I need spawn enemy in: day time, forest biome and dirt layer, but my npc spawn overtime! And how i can make this npc spawn rarely?

Code:
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return (spawnInfo.player.ZoneOverworldHeight || spawnInfo.player.ZoneDirtLayerHeight) && Main.dayTime && !spawnInfo.player.ZoneUndergroundDesert && !spawnInfo.player.ZoneDesert && !spawnInfo.player.ZoneSnow && !spawnInfo.player.ZoneJungle && !spawnInfo.player.ZoneCrimson && !spawnInfo.player.ZoneCorrupt && !spawnInfo.player.ZoneHoly ? 0.5f : 0.5f;
}
 

dtim

Terrarian
Hm... i have some trouble. I need spawn enemy in: day time, forest biome and dirt layer, but my npc spawn overtime! And how i can make this npc spawn rarely?

Code:
public override float CanSpawn(NPCSpawnInfo spawnInfo)
{
return (spawnInfo.player.ZoneOverworldHeight || spawnInfo.player.ZoneDirtLayerHeight) && Main.dayTime && !spawnInfo.player.ZoneUndergroundDesert && !spawnInfo.player.ZoneDesert && !spawnInfo.player.ZoneSnow && !spawnInfo.player.ZoneJungle && !spawnInfo.player.ZoneCrimson && !spawnInfo.player.ZoneCorrupt && !spawnInfo.player.ZoneHoly ? 0.5f : 0.5f;
}
Change the 0.5f numbers. Those are chances for the NPC to spawn. The first one before the colon is the chance to spawn if all the conditions are met. The second one is the chance to spawn if the conditions are not met.
 

G4M3R57

Terrarian
Sup everybody, I have a question.

How to add gravity to the projectile?
And how to calibrate it?

I wonder, because my projectile just flies in the air, a grenade does not do that.
 

Solo-Ion

Dungeon Spirit
Is it possible for a custom projectile to spawn a custom NPC? I really need to know.
As far as I know, it is. Do you know how to use the NewNPC method?

Sup everybody, I have a question.

How to add gravity to the projectile?
And how to calibrate it?

I wonder, because my projectile just flies in the air, a grenade does not do that.
Terraria has gravity of 0.35 pixels per tick on the Y axis. Just add 0.35f to your projectile's Y velocity in it's AI.
 

Voila

Terrarian
How can I make an item DO something? I know this is kinda vague but I mean I want my item to do more than place a tile or swing like a sword but I'm not sure where to put my methods. Like, can I call them anywhere in the item.cs file? Is there an "onUse()" method or something? The documentation for TmodLoader is kinda disorganized so I'm having trouble finding this stuff...
 

jopojelly

Retinazer
tModLoader
How can I make an item DO something? I know this is kinda vague but I mean I want my item to do more than place a tile or swing like a sword but I'm not sure where to put my methods. Like, can I call them anywhere in the item.cs file? Is there an "onUse()" method or something? The documentation for TmodLoader is kinda disorganized so I'm having trouble finding this stuff...
https://github.com/bluemagic123/tModLoader/wiki/ModItem#public-virtual-bool-useitemplayer-player
 

Voila

Terrarian
How can I make an item DO something? I know this is kinda vague but I mean I want my item to do more than place a tile or swing like a sword but I'm not sure where to put my methods. Like, can I call them anywhere in the item.cs file? Is there an "onUse()" method or something? The documentation for TmodLoader is kinda disorganized so I'm having trouble finding this stuff...
Thank you! Just what I needed. :3
 
Top Bottom