tModLoader Official tModLoader Help Thread

Why can't I publish?
Error :
Tip: Adding a homepage to build.txt will make your mod more appealing.
Mod Browser NOT updated. Change version number if you wish to update your mod!

This is my build.txt.

author = --Elias--
version = 1.0
displayName = Nightmare Mod
homepage = http://forums.terraria.org/index.php?threads/released-wip-the-nightmare-mod.46857/
hideCode = true
hideResources = true
includeSource = false
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*
includePDB = true

Read the error message more carefully. "Change version number if you wish to update your mod!"
You need to give your Mod a new version number, Modloader seems just fine.
 
I should reword the question. How do I make a weapon have a similar animation scheme to wing items? For example, wings use two different textures (one for animation and one for item image).

How would I make a weapon have the animated texture for the item image AND use a regular single frame texture for the weapon being swung?
 
Is it possible to control the player, such as making it move about randomly? I found some methods that suggest this is possible, such as Player.JumpMovement or Player.KeyHoldDown, but no luck so far.
I've also tried faking input sending either PostMessage or SendMessage WM_KEYDOWN/KEYUP, but no luck there, either.
 
I'm currently trying to recreate the WaterBolt Projectile, I've copied the AI and changed the "this" sections and it works fine, but I'm unable to change the "dust" how would I do that? And how can I increase the number of bounces?
 
Last edited:
I'm currently trying to recreate the WaterBolt Projectile, I've copied the AI and changed the "this" sections and it works fine, but I'm unable to change the "dust" how would I do that?
Dusts, sounds and textures used by items are hard-coded into Terrarias code. When you tell Terrearia to use the Water Bolt ai for your modded projectile, it will automatically spawn the respective Dust. There is no way to change which type of dust the ai is spawning.
The reason why your projectile doesn't also use the Water Bolt texture is because the texture used for any entity in Terraria depends on it's ID. Your projectile is not the same as the Water Bolt, and therefore has a different ID and, as a consequence, texture. (unless you specifically told the game to use the same one)
It does however have the same ai as the Water Bolt and will therefore exert the exact same behaviour. Inluding the creation of blue dust.

The only real way to fix your problem is to create your own AI code and make it spawn other Dust. You can have a look at the code of the Example Bullet to aid you. It behaves very similar to the Water Bolt (bouncing off walls) so you wouldn't have to change all that much.
 
I tried adding recipes to my armors and this error came up
Code:
c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\IchorHelmet.cs(39,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\IchorLeggings.cs(33,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(46,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(47,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(48,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(49,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(36,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(37,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(38,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(39,25) : error CS0103: The name 'ItemID' does not exist in the current context
and here is the code of one of the things
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace BMod.Items.Armor
{
    public class NightChestplate : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Body);
            return true;
        }

        public override void SetDefaults()
        {
            item.name = "Night's Chestplate";
            item.width = 26;
            item.height = 20;
            AddTooltip("You are a creature of the night now.");
            AddTooltip2("5% increased movement speed");
            item.value = Item.buyPrice(0,1,8,0);
            item.rare = 3;
            item.defense = 13;
        }

        public override void UpdateEquip(Player player)
        {
            player.moveSpeed += 1.05f;
        }
       
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.JungleShirt, 1);
            recipe.AddIngredient(ItemID.NecroBreastplate, 1);
            recipe.AddIngredient(ItemID.ShadowScalemail, 1);
            recipe.AddIngredient(ItemID.MoltenBreastplate, 1);
            recipe.AddTile(26);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
 
I tried adding recipes to my armors and this error came up
Code:
c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\IchorHelmet.cs(39,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\IchorLeggings.cs(33,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(46,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(47,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(48,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(49,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(36,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(37,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(38,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(39,25) : error CS0103: The name 'ItemID' does not exist in the current context
and here is the code of one of the things
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace BMod.Items.Armor
{
    public class NightChestplate : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Body);
            return true;
        }

        public override void SetDefaults()
        {
            item.name = "Night's Chestplate";
            item.width = 26;
            item.height = 20;
            AddTooltip("You are a creature of the night now.");
            AddTooltip2("5% increased movement speed");
            item.value = Item.buyPrice(0,1,8,0);
            item.rare = 3;
            item.defense = 13;
        }

        public override void UpdateEquip(Player player)
        {
            player.moveSpeed += 1.05f;
        }
      
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.JungleShirt, 1);
            recipe.AddIngredient(ItemID.NecroBreastplate, 1);
            recipe.AddIngredient(ItemID.ShadowScalemail, 1);
            recipe.AddIngredient(ItemID.MoltenBreastplate, 1);
            recipe.AddTile(26);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
You need "using Terraria.ID;" in all the other files. This file wasn't one of the ones with the error
 
I tried adding recipes to my armors and this error came up
Code:
c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\IchorHelmet.cs(39,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\IchorLeggings.cs(33,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(46,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(47,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(48,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightHelmet.cs(49,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(36,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(37,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(38,25) : error CS0103: The name 'ItemID' does not exist in the current context

c:\Users\BenGTheGreat\Documents\My Games\Terraria\ModLoader\Mod Sources\BMod\Items\Armor\NightLeggings.cs(39,25) : error CS0103: The name 'ItemID' does not exist in the current context
and here is the code of one of the things
Code:
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace BMod.Items.Armor
{
    public class NightChestplate : ModItem
    {
        public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
        {
            equips.Add(EquipType.Body);
            return true;
        }

        public override void SetDefaults()
        {
            item.name = "Night's Chestplate";
            item.width = 26;
            item.height = 20;
            AddTooltip("You are a creature of the night now.");
            AddTooltip2("5% increased movement speed");
            item.value = Item.buyPrice(0,1,8,0);
            item.rare = 3;
            item.defense = 13;
        }

        public override void UpdateEquip(Player player)
        {
            player.moveSpeed += 1.05f;
        }
      
        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.JungleShirt, 1);
            recipe.AddIngredient(ItemID.NecroBreastplate, 1);
            recipe.AddIngredient(ItemID.ShadowScalemail, 1);
            recipe.AddIngredient(ItemID.MoltenBreastplate, 1);
            recipe.AddTile(26);
            recipe.SetResult(this, 1);
            recipe.AddRecipe();
        }
    }
}
The code you posted is actually NOT one of the affected files. If you take a close look at the Error messages you'll see that only the files
IchorHelmet.cs , IchorLeggings.cs , NightHelmet.cs and NightLeggings.cs are affected.

You need to add
Code:
using Terraria.ID;
to the affected files.
 
The code you posted is actually NOT one of the affected files. If you take a close look at the Error messages you'll see that only the files
IchorHelmet.cs , IchorLeggings.cs , NightHelmet.cs and NightLeggings.cs are affected.

You need to add
Code:
using Terraria.ID;
to the affected files.
the problem was already solved by @jopojelly but thx for trying to help anyways :)
 
Dusts, sounds and textures used by items are hard-coded into Terrarias code. When you tell Terrearia to use the Water Bolt ai for your modded projectile, it will automatically spawn the respective Dust. There is no way to change which type of dust the ai is spawning.
The reason why your projectile doesn't also use the Water Bolt texture is because the texture used for any entity in Terraria depends on it's ID. Your projectile is not the same as the Water Bolt, and therefore has a different ID and, as a consequence, texture. (unless you specifically told the game to use the same one)
It does however have the same ai as the Water Bolt and will therefore exert the exact same behaviour. Inluding the creation of blue dust.

The only real way to fix your problem is to create your own AI code and make it spawn other Dust. You can have a look at the code of the Example Bullet to aid you. It behaves very similar to the Water Bolt (bouncing off walls) so you wouldn't have to change all that much.

It's a New Item and Projectile it want a "Fire Version" of the waterbolt and I have new Textures.

Item:
Code:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TerrariaEnhanced.Items.Weapons
{
    public class MagmaBolt : ModItem
    {
        public override void SetDefaults()
        {
            item.autoReuse = true;
            item.rare = 4;
            item.mana = 10;
            item.useSound = 21;
            item.name = "Magma Bolt";
            item.useStyle = 5;
            item.damage = 29;
            item.useAnimation = 17;
            item.useTime = 17;
            item.width = 24;
            item.height = 28;
            item.scale = 0.9f;
            item.shoot = mod.ProjectileType("MagmaBoltP");
            item.shootSpeed = 4.5f;
            item.knockBack = 5f;
            item.toolTip = "Casts a slow moving bolt of magma";
            item.magic = true;
            item.value = 80000;
            return;
        }


        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.WaterBolt);
            recipe.AddIngredient(ItemID.HellstoneBar, 10);
            recipe.AddTile(TileID.Bookcases);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}

Projetile:
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TerrariaEnhanced.Projectiles
{
    public class MagmaBoltP : ModProjectile
    {
        public override void SetDefaults()
        {
            projectile.CloneDefaults(ProjectileID.WaterBolt);
            projectile.name = "MagmaBoltP";
            aiType = ProjectileID.WaterBolt;
        }
       
        public override void AI()
        {
            for (int num92 = 0; num92 < 5; num92++)
            {
                float num93 = projectile.velocity.X / 3f * (float)num92;
                float num94 = projectile.velocity.Y / 3f * (float)num92;
                int num95 = 4;
                int num127 = Dust.NewDust(new Vector2(projectile.position.X + (float)num95, projectile.position.Y + (float)num95), projectile.width - num95 * 2, projectile.height - num95 * 2, 172, 0f, 0f, 100, default(Color), 1.2f);
                Main.dust[num127].noGravity = true;
                Main.dust[num127].velocity *= 0.1f;
                Main.dust[num127].velocity += projectile.velocity * 0.1f;
                Dust expr_4896_cp_0 = Main.dust[num127];
                expr_4896_cp_0.position.X = expr_4896_cp_0.position.X - num93;
                Dust expr_48B1_cp_0 = Main.dust[num127];
                expr_48B1_cp_0.position.Y = expr_48B1_cp_0.position.Y - num94;
            }
            if (Main.rand.Next(5) == 0)
            {
                int num97 = 4;
                int num127 = Dust.NewDust(new Vector2(projectile.position.X + (float)num97, projectile.position.Y + (float)num97), projectile.width - num97 * 2, projectile.height - num97 * 2, 172, 0f, 0f, 100, default(Color), 0.6f);
                Main.dust[num127].velocity *= 0.25f;
                Main.dust[num127].velocity += projectile.velocity * 0.5f;
            }
        }
        }
        }

And is there a way to increase the amount of bounces?
 
And is there a way to increase the amount of bounces?
I think you can add
Code:
projectile.penetrate = <bounces>
to your code to determine how many times it can bounce or penetrate an enemy.
It seems like you had another question, but I am not sure what you want :(
 
I think you can add
Code:
projectile.penetrate = <bounces>
to your code to determine how many times it can bounce or penetrate an enemy.
It seems like you had another question, but I am not sure what you want :(
I want the dust Color in orange, but I don't know how I can either add Dust or change dust to the "code", you said it isn't possible to change dust but when you can't change it how can you add Dust?
 
I want the dust Color in orange, but I don't know how I can either add Dust or change dust to the "code", you said it isn't possible to change dust but when you can't change it how can you add Dust?
You have to write your own ai code, that mimics the Waterbolt. In the code you posted you seem to also spawn you own dust, so I think your problem is that both your dust and the waterbolt dust are appearing, correct?
 
I think you can add
Code:
projectile.penetrate = <bounces>
to your code to determine how many times it can bounce or penetrate an enemy.
It seems like you had another question, but I am not sure what you want :(

Sorry to trouble you but would you have any idea how to make a summon similar to the Stardust Dragon staff work properly?

I have it working right now but if you summon more segments the tail detaches and the segments don't attach properly.

I could send you the code as well, if you'd like to help :)
 
Sorry to trouble you but would you have any idea how to make a summon similar to the Stardust Dragon staff work properly?

I have it working right now but if you summon more segments the tail detaches and the segments don't attach properly.

I could send you the code as well, if you'd like to help :)
I can have a look at it, if you want. Just PM me the respective code and I'll se what I can do.
 
Hello :)

Currently I´m trying to implement a level system but I can´t increase any stats only life and mana.
Every time I call my function in my class, that interihance ModPlayer, I want to increase the maximum life and melee damage multiplier.
The function is called every time I enter a chat command like:
/skill str
Code:
player.statLife += 20;
player.statLifeMax += 20;
player.statLifeMax2 += 20;
player.meleeDamage *= 1.2f;

The problem is that he increases the maximum hp but the melee damage remains unaffected.

I also tried with many other [player.*] properties but only the following properties are working:
Code:
player.statLife += 20;
player.statLifeMax += 20;
player.statLifeMax2 += 20;
player.statMana += 10;
player.statManaMax += 10;
player.statManaMax2 += 10;

Other properties do nothing like:
Code:
player.rangedDamage += 0.1f;
player.magicDamage += 0.1f;
player.meleeSpeed += 0.1f;
player.meleeDamage += 0.1f;
 
Back
Top Bottom