tModLoader Official tModLoader Help Thread

I have a problem with my code here. Im trying to add an ore called Erothium, but error code CS1519 is getting in the way.

c:\Users\Elija\Documents\My Games\Terraria\ModLoader\Mod Sources\BlastsMod\Items\Placeable\ErothiumOre.cs(14,9) : error CS1519: Invalid token '{' in class, struct, or interface member declaration

my code:

using Terraria.ID;
using Terraria.ModLoader;

namespace BlastsMod.Items.Placeable
{
public class ErothiumOre : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Erothium Ore");
Tooltip.SetDefault("Looks purple");
}
public override voidSetDefaults();
{
item.width =12;
item.height =12;
item.useTime =10;
item.useAnimation =10;
item.useStyle =1;
item.value =1500;
item.rare =2;
item.UseSound =SoundID.Item1;
item.autoReuse =true;
item.consumable =true;
item.createTile =mod.TileType("ErothiumOreTile")
item.maxStack=999
}
}
}
 
I have a problem with my code here. Im trying to add an ore called Erothium, but error code CS1519 is getting in the way.
<snip>
There are at least two things that are causing errors here.
  1. public override voidSetDefaults();
    You need a space between void at SetDefaults(), and the semicolon after SetDefaults() isn't expected (aka remove it).

  2. item.createTile =mod.TileType("ErothiumOreTile")
    item.maxStack=999
    Two missing semicolons.
 
i am trying to make a item that spawns a enemy. but when i use it nothing happens.
this is my code
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MagnarMadness.Items
{
    public class VoodooDemonSpawner : ModItem
    {
        public override void SetStaticDefaults()
        {
            Tooltip.SetDefault("WIP Item.");
        }
     
        public override void SetDefaults()
        {
            item.width = 47;
            item.height = 33;
            item.maxStack = 999;
            item.value = 100;
            item.rare = 1;
            item.useAnimation = 30;
            item.useTime = 30;
            item.useStyle = 4;
            item.consumable = true;
        }
        public override bool UseItem(Player player)
        {
            NPC.SpawnOnPlayer(player.whoAmI, NPCID.VoodooDemon);
            return true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
i really do hope that someone can help me with this. because i struggle badly trying to get this to work.
 
Hey does anyone know the code I can add to an item to call GlobalNPC on behalf of every active NPC in the world? Currently I'm trying to make an item that clears the pillars, preferably without summoning Moonlord, so help with that would be greatly appreciated.
Edit: Solved my problem, made the item, it works, but if anyone knows how to make an item call GlobalNPC on behalf of every active NPC in the world upon use, that would be a great help :)

i am trying to make a item that spawns a enemy. but when i use it nothing happens.
this is my code
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MagnarMadness.Items
{
    public class VoodooDemonSpawner : ModItem
    {
        public override void SetStaticDefaults()
        {
            Tooltip.SetDefault("WIP Item.");
        }

        public override void SetDefaults()
        {
            item.width = 47;
            item.height = 33;
            item.maxStack = 999;
            item.value = 100;
            item.rare = 1;
            item.useAnimation = 30;
            item.useTime = 30;
            item.useStyle = 4;
            item.consumable = true;
        }
        public override bool UseItem(Player player)
        {
            NPC.SpawnOnPlayer(player.whoAmI, NPCID.VoodooDemon);
            return true;
        }
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 1);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
i really do hope that someone can help me with this. because i struggle badly trying to get this to work.
I think you might need to replace NPCID.VoodooDemon with 66 (The id number of the npc). Idk if that will help but give it a try, I've made an item similar to this that works, and that is all I can think of that the problem could be unless you're missing some using thingies (e.g. using System;). Also you could add a sound to it with Main.PlaySound(SoundID.Roar, player.position, 0); (thats the roaring sound like when EoC is summoned with the suspicious eye)
 
Last edited:
Hi. I'm back after a long time away. And new to the modded community. So please excuse me if this question has been asked already. 225 pages on this post and I wasn't able to find an answer. I'm probably not using the right keywords or something. I know I should mention I'm running a Steam installation of the game.

So I've set up a Terraria server over on my dedicated server host. But I can't connect to it because no matter what I do, I can't get my copy of Terraria to run. From what I've gathered online all you need to do is copy the latest "tmod" files into your game folder, let it overwrite what it needs to. And it should be good from there. But when I go to launch the game I get hit with an error.

https://i.imgur.com/UwCcYv0.png

I know it can be done. I just can't seem to figure it out. I love this game. But I've gotten tired of Vanilla and want to move on to something new. Any help would be greatly appreciated.
I figured out what the issue was. My AV (Bitdefender) was blocking things but not alerting me. I found them when it blocked another program.
 
Hey does anyone know the code I can add to an item to call GlobalNPC on behalf of every active NPC in the world? Currently I'm trying to make an item that clears the pillars, preferably without summoning Moonlord, so help with that would be greatly appreciated.
Edit: Solved my problem, made the item, it works, but if anyone knows how to make an item call GlobalNPC on behalf of every active NPC in the world upon use, that would be a great help :)


I think you might need to replace NPCID.VoodooDemon with 66 (The id number of the npc). Idk if that will help but give it a try, I've made an item similar to this that works, and that is all I can think of that the problem could be unless you're missing some using thingies (e.g. using System;). Also you could add a sound to it with Main.PlaySound(SoundID.Roar, player.position, 0); (thats the roaring sound like when EoC is summoned with the suspicious eye)

thanks for the reply. i will try the things you have said
[doublepost=1530860880,1530860441][/doublepost]
Hey does anyone know the code I can add to an item to call GlobalNPC on behalf of every active NPC in the world? Currently I'm trying to make an item that clears the pillars, preferably without summoning Moonlord, so help with that would be greatly appreciated.
Edit: Solved my problem, made the item, it works, but if anyone knows how to make an item call GlobalNPC on behalf of every active NPC in the world upon use, that would be a great help :)


I think you might need to replace NPCID.VoodooDemon with 66 (The id number of the npc). Idk if that will help but give it a try, I've made an item similar to this that works, and that is all I can think of that the problem could be unless you're missing some using thingies (e.g. using System;). Also you could add a sound to it with Main.PlaySound(SoundID.Roar, player.position, 0); (thats the roaring sound like when EoC is summoned with the suspicious eye)

now i am getting a new error.

error c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,52) : error CS1026: ) expected

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,55) : error CS1002: ; expected

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,55) : error CS1525: Invalid expression term ')'

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,56) : error CS1002: ; expected

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,56) : error CS1525: Invalid expression term ')'

this is my code.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria;

namespace MagnarMadness.Items
{
    public class VoodooDemonSpawner : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Voodoo Demon Spawner");
            Tooltip.SetDefault("Summons A Voodoo Demon");
        }

        public override void SetDefaults()
        {
            item.width = 47;
            item.height = 33;
            item.maxStack = 20;
            item.value = 100;
            item.rare = 1;
            item.useAnimation = 40;
            item.useTime = 45;
            item.consumable = true;

            item.useStyle = 4; // Holds up like a summon item.
        }

        public override bool UseItem(Player player)
        {
            NPC.SpawnOnPlayer(player.whoAmI, (NPCID.66)); // Spawn the boss within a range of the player.
            Main.PlaySound(SoundID.Roar, player.position, 0);
            return true;
        }
    }
}
 
thanks for the reply. i will try the things you have said
[doublepost=1530860880,1530860441][/doublepost]

now i am getting a new error.

error c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,52) : error CS1026: ) expected

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,55) : error CS1002: ; expected

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,55) : error CS1525: Invalid expression term ')'

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,56) : error CS1002: ; expected

c:\Users\dylan\Documents\My Games\Terraria\ModLoader\Mod Sources\MagnarMadness\Items\VoodooDemonSpawner.cs(36,56) : error CS1525: Invalid expression term ')'

this is my code.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.ModLoader;
using Terraria.ID;
using Terraria;

namespace MagnarMadness.Items
{
    public class VoodooDemonSpawner : ModItem
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Voodoo Demon Spawner");
            Tooltip.SetDefault("Summons A Voodoo Demon");
        }

        public override void SetDefaults()
        {
            item.width = 47;
            item.height = 33;
            item.maxStack = 20;
            item.value = 100;
            item.rare = 1;
            item.useAnimation = 40;
            item.useTime = 45;
            item.consumable = true;

            item.useStyle = 4; // Holds up like a summon item.
        }

        public override bool UseItem(Player player)
        {
            NPC.SpawnOnPlayer(player.whoAmI, (NPCID.66)); // Spawn the boss within a range of the player.
            Main.PlaySound(SoundID.Roar, player.position, 0);
            return true;
        }
    }
}
Na just have it like
NPC.SpawnOnPlayer(player.whoAmI, 66); // Spawn the boss within a range of the player.
That should hopefully work
 
i actually just fixed that before you sent your reply. sorry but thanks for the help
Ok good you got it fixed :)

I need help does anyone know how to create a shadowflame hex doll type projectile? I've looked at the code for the aiStyle of it and copied it into the AI hook of my projectile but when I try to load it up I get this error:
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(75,5) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(75,9) : error CS1002: ; expected
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(75,21) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(75,25) : error CS1002: ; expected
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(80,5) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(80,9) : error CS1002: ; expected
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(80,21) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(80,25) : error CS1002: ; expected
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(95,4) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(95,8) : error CS1002: ; expected
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(95,20) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(95,24) : error CS1002: ; expected
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(97,4) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(97,8) : error CS1002: ; expected
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(97,20) : error CS1525: Invalid expression term 'ref'
c:\Users\willj\OneDrive\Documents\My Games\Terraria\ModLoader\Mod Sources\WillBanksysMod\Projectiles\FiresnakeTentacle.cs(97,24) : error CS1002: ; expected

This is my code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
namespace WillBanksysMod.Projectiles
{
public class FiresnakeTentacle : ModProjectile
{
public override string Texture { get { return "Terraria/Projectile_" + ProjectileID.RuneBlast; } }

public override void SetStaticDefaults()
{
DisplayName.SetDefault("Firesnake Tentacle");
}
public override void SetDefaults()
{
projectile.alpha = 255;
projectile.width = 40;
projectile.height = 40;
//projectile.aiStyle = 91;
projectile.friendly = true;
projectile.magic = true;
projectile.MaxUpdates = 3;
projectile.penetrate = 3;
}

public override void AI()
{
if (projectile.velocity.X != projectile.velocity.X)
{
if (Math.Abs(projectile.velocity.X) < 1f)
{
projectile.velocity.X = 0f - projectile.velocity.X;
}
else
{
projectile.Kill();
}
}
if (projectile.velocity.Y != projectile.velocity.Y)
{
if (Math.Abs(projectile.velocity.Y) < 1f)
{
projectile.velocity.Y = 0f - projectile.velocity.Y;
}
else
{
projectile.Kill();
}
}

Vector2 center19 = projectile.Center;
scale = 1f - localAI[0];
projectile.width = (int)(20f * scale);
projectile.height = projectile.width;
projectile.position.X = center19.X - (float)(projectile.width / 2);
projectile.position.Y = center19.Y - (float)(projectile.height / 2);
if ((double)localAI[0] < 0.1)
{
ref reference = ref localAI[0];
reference += 0.01f;
}
else
{
ref reference = ref localAI[0];
reference += 0.025f;
}
if (localAI[0] >= 0.95f)
{
Kill();
}

projectile.velocity.X = projectile.velocity.X + this.ai[0] * 1.5f;
projectile.velocity.Y = projectile.velocity.Y + this.ai[1] * 1.5f;
if (projectile.velocity.Length() > 16f)
{
projectile.velocity.Normalize();
projectile.velocity *= 16f;
}
ref reference = ref this.ai[0];
reference *= 1.05f;
ref reference = ref this.ai[1];
reference *= 1.05f;
if (scale < 1f)
{
int num844 = 0;
while ((float)num844 < scale * 10f)
{
Vector2 position173 = new Vector2(projectile.position.X, projectile.position.Y);
int width138 = projectile.width;
int height138 = projectile.height;
float x33 = projectile.velocity.X;
float y33 = projectile.velocity.Y;
newColor = default(Color);
int num845 = Dust.NewDust(position173, width138, height138, 27, x33, y33, 100, newColor, 1.1f);
Main.dust[num845].position = (Main.dust[num845].position + projectile.Center) / 2f;
Main.dust[num845].noGravity = true;
dust3 = Main.dust[num845];
dust3.velocity *= 0.1f;
dust3 = Main.dust[num845];
dust3.velocity -= projectile.velocity * (1.3f - scale);
Main.dust[num845].fadeIn = (float)(100 + owner);
dust3 = Main.dust[num845];
dust3.scale += scale * 0.75f;
num4 = num844;
num844 = num4 + 1;
}
}
}
}
}

Edit: Solved! Copy this if you want, changing the relevant fields :)
Took me a while to find this, been looking a lot longer than when I posted this question, and others may be looking so here you go:
(Note: I have no idea how to make the 'tentacles' curve, currently they just go straight. Anyone any idea?)

Code:
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.IO;
using Microsoft.Xna.Framework.Graphics;
using Terraria.UI;
using System;
using Terraria.DataStructures;

namespace WillBanksysMod.Projectiles
{
    public class FiresnakeTentacle : ModProjectile
    {
        public override string Texture { get { return "Terraria/Projectile_" + ProjectileID.RuneBlast; } }
    
        public int width138;
        public int height138;
        public float x33;
        public float y33;
    
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Firesnake Tentacle");
        }

        public override void SetDefaults()
        {
            projectile.alpha = 255;
            projectile.width = 40;
            projectile.height = 40;
            //projectile.aiStyle = 91;
            projectile.friendly = true;
            projectile.magic = true;
            projectile.MaxUpdates = 3;
            projectile.penetrate = 3;
        }
    
        public override bool PreAI()
        {
            return true;
        }

        public override void AI()
        {
            Vector2 center10 = projectile.Center;
            projectile.scale = 1f - projectile.localAI[0];
            projectile.width = (int)(20f * projectile.scale);
            projectile.height = projectile.width;
            projectile.position.X = center10.X - (float)(projectile.width / 2);
            projectile.position.Y = center10.Y - (float)(projectile.height / 2);
            if ((double)projectile.localAI[0] < 0.1)
            {
                projectile.localAI[0] += 0.01f;
            }
    
            else
            {
                projectile.localAI[0] += 0.025f;
            }
            if (projectile.localAI[0] >= 0.95f)
            {
                projectile.Kill();
            }
    
            projectile.velocity.X = projectile.velocity.X + projectile.ai[0] * 1.5f;
            projectile.velocity.Y = projectile.velocity.Y + projectile.ai[1] * 1.5f;
            if (projectile.velocity.Length() > 16f)
            {
                projectile.velocity.Normalize();
                projectile.velocity *= 16f;
            }
            projectile.ai[0] *= 1.05f;
            projectile.ai[1] *= 1.05f;
            if (projectile.scale < 1f)
            {
                int num892 = 0;
                while ((float)num892 < projectile.scale * 10f)
                {
                    //Dust "6" (OnFire Orange Color) is used.
                    int num893 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 235, projectile.velocity.X, projectile.velocity.Y, 0, default(Color), 1.1f);
                    Main.dust[num893].position = (Main.dust[num893].position + projectile.Center) / 2f;
                    Main.dust[num893].noGravity = true;
                    Dust dust = Main.dust[num893];
                    dust.velocity *= 0.1f;
                    dust = Main.dust[num893];
                    dust.velocity -= projectile.velocity * (1.3f - projectile.scale);
                    Main.dust[num893].fadeIn = (float)(100 + projectile.owner);
                    dust = Main.dust[num893];
                    dust.scale += projectile.scale * 0.75f;
                    int num3 = num892;
                    num892 = num3 + 1;
                }
                return;
            }
        
        }
    }
}
 
Last edited:
Hey sorry if this is not where I'm supposed to ask this. Does anyone know a mod that allows you to transform into other creatures, besides Thorium.
 
Hi there. got few question here.
1. how can I check "is there any boss(from any mod) alive" via code? This is for a farming weapon which does 99999 damage and obviously I don't want to kill bosses in one hit.so i want to disable the weapon when any boss alive. Or "cannot hit any boss" is another solution. tried:

public override bool? CanHitNPC(Player player, NPC target)
{
return (!target.boss);
}
doesn't work. one hit the KingSlime,which should be a boss and therefore should not hit by this weapon in theory.

2. how can i adjust a weapon's damage when game progress through? for example, when i kill kingslime, it does 10 more damage. showing where should i put the code as well would be extremely wonderful.

3. what is the definition of "item.animation"?

4. how should i write the code if I want "when the projectile hit an enemy, enemy's hp reduced 1000 per second"? target.liferegen in OnHitNpc() doesn't work.

Thanks in advance.


p.s. for the weapon in Q1, it would also be wonderful if anyone knows how to kill any type of none-boss hostile mobs in one hit using code(just like the /kill command in minecraft). I just don't like number inflation.
 
You take the earlier code, check in which zone the player is and apply a debuff:
Code:
public class MyModPlayer : ModPlayer // <- Deriving.
{
    public override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit) // <- Overriding.
    {
    // Tadaaaa, we're hitting an NPC.
        if(player.ZoneSnow)
        {
            target.AddBuff(BuffID.Frostburn, 300);
        }
    }
}
when i do that it says no suitable method found to override on the OnHitNPC line, what am i doing wrong?

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

namespace TutorialMod
{
public class myModPlayer : ModPlayer
{
public override void onHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{
if()
{
int lifeSteal = damage / 100 * 5;
Player.statLife += lifeSteal;
Player.HealEffect(lifeSteal);
}
}
public bool vampireFangsEquipped;

public override void ResetEffects()
{
this.vampireFangsEquipped = false;
}
}
}
 
Indeed. Detecting the accessory is actually not all that hard. On your ModPlayer create a boolean:
Code:
public bool myAccessoryEquipped;

public override void ResetEffects()
{
    this.myAccessoryEquipped = false;
}
Then over at your accessory, you can do:
Code:
// Inside the UpdateAccessory method:
player.GetModPlayer<MyModPlayer>(mod).myAccessoryEquipped = true;
And then you can use that boolean in the player.
it says in vampire fangs

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

namespace TutorialMod.Items
{
public class VampireFangs : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Vampire Fangs");
Tooltip.SetDefault("Trick Or Treat!");
}
public override void SetDefaults()
{
item.width = 20;
item.height = 20;
item.maxStack = 1;
item.value = 500000;
item.accessory = true;
item.rare = 3;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.GetModPlayer<MyModPlayer>(mod).vampireFangsEquipped = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(mod.ItemType("VampireFang"), 2);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

that myModPlayer cannot be found, why does this happen?

(myModPlayer)

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

namespace TutorialMod
{
public class myModPlayer : ModPlayer
{
public void onHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{
if(this.vampireFangsEquipped = true)
{
int lifeSteal = damage / 100 * 5;
player.statLife += lifeSteal;
player.HealEffect(lifeSteal);
}
}
public bool vampireFangsEquipped;

public override void ResetEffects()
{
this.vampireFangsEquipped = false;
}
}
}
 
I'm trying to make a baldi's basics mod but I keep getting this error in the .cs
(25,23) : error CS1061: 'int' does not contain a definition for 'Item1' and no extension method 'Item1' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)
script is below


using Terraria.ID;
using Terraria.ModLoader;

namespace BaldisBasicsMod.Items
{
public class WoodenRuler : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Baldi's Ruler");
Tooltip.SetDefault("You Feel Like You Need To Calculate.");
}
public override void SetDefaults()
{
item.damage = 1500;
item.melee = true;
item.width = 40;
item.height = 40;
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 3;
item.knockBack = 75;
item.value = 5000000;
item.rare = 11;
item.UseSound = 11;
item.autoReuse = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.Wood, 5000);
recipe.AddIngredient(ItemID.Star, 25);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
 
You all just need to look closer at ExampleMod or come to the discord chat, hardly anyone answers questions here. discord.me/tModLoader
 
it says in vampire fangs

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

namespace TutorialMod.Items
{
public class VampireFangs : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Vampire Fangs");
Tooltip.SetDefault("Trick Or Treat!");
}
public override void SetDefaults()
{
item.width = 20;
item.height = 20;
item.maxStack = 1;
item.value = 500000;
item.accessory = true;
item.rare = 3;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.GetModPlayer<MyModPlayer>(mod).vampireFangsEquipped = true;
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(mod.ItemType("VampireFang"), 2);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}

that myModPlayer cannot be found, why does this happen?

(myModPlayer)

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

namespace TutorialMod
{
public class myModPlayer : ModPlayer
{
public void onHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{
if(this.vampireFangsEquipped = true)
{
int lifeSteal = damage / 100 * 5;
player.statLife += lifeSteal;
player.HealEffect(lifeSteal);
}
}
public bool vampireFangsEquipped;

public override void ResetEffects()
{
this.vampireFangsEquipped = false;
}
}
}
You capitalized “my” in the accessory. It should be player.GetModPlayer<myModPlayer> [...] to match your class name.
 
You capitalized “my” in the accessory. It should be player.GetModPlayer<myModPlayer> [...] to match your class name.
i fixed that but now in myModPlayer on the onHitNPC line it says no suitable method found to override please help
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace TutorialMod
{
public class myModPlayer : ModPlayer
{
public bool vampireFangsEquipped;

public override void ResetEffects()
{
this.vampireFangsEquipped = false;
}
public override void onHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{

player.AddBuff(BuffID.CursedInferno, 60);

}
}
}
 
i fixed that but now in myModPlayer on the onHitNPC line it says no suitable method found to override please help
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;

namespace TutorialMod
{
public class myModPlayer : ModPlayer
{
public bool vampireFangsEquipped;

public override void ResetEffects()
{
this.vampireFangsEquipped = false;
}
public override void onHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
{

player.AddBuff(BuffID.CursedInferno, 60);

}
}
}
OnHitNPC, not onHitNPC. I’d recommend getting something like Visual Studio or similar so you don’t have to come here for every small, case sensitivity error.
 
How would I make something create a certain tile in a certain place? Such as when I destroy a tile, another tile takes it's place? Or when a projectile is killed, it spawns a tile (Kind of like the ice rod)? Please if anybody could help me, please do :)
I've looked at the source code and can't figure it out
Edit: I've got WorldGen.SolidTile(TileX, TileY); which actually loads but does not work in-game, it gets me the error: Index was outside the bounds of the array. at Terraria.WorldGen.SolidTile(Int32 i, Int32 j). Anyway, I don't think it allows me to choose the type of tile, so it's kind of useless

Another Edit: Argh I've done it again: Every time I ask a question on here, I end up being able to solve it. So I've discovered how to do that :D ANYWAY, there is one thing I haven't been able to figure out; how do I add a firing delay to my custom trap?
 
Last edited:
Back
Top Bottom