Standalone [1.3] tModLoader - A Modding API

WolfHybrid23

Official Terrarian
Is there anyway I can make a texture for wings where it looks like the texture is moving instead of the wings like twighlight dye does
 

Orion The Boundary Ryu

Skeletron Prime
Ok now the ranged weapon is working but now I have another problem with it. Instead of using rockets, it uses a different projectile. So far it shot out powder (hallow or vile) for rocket 1 and for rocket 5 it shot out flamarangs.
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Items.Weapons

{

    public class BlackBox : ModItem

    {

        public override void SetDefaults()

        {

            item.name = "Black Box";

            item.damage = 25;

            item.ranged = true;

            item.width = 40;

            item.height = 20;

            item.toolTip = "MAGGOT!";

            item.useTime = 20;

            item.useAnimation = 20;

            item.useStyle = 5;

            item.noMelee = true;

            item.knockBack = 4;

            item.value = 10000;

            item.rare = 2;

            item.UseSound = SoundID.Item11;

            item.autoReuse = true;

            item.shoot = 10;

            item.shootSpeed = 16f;

            item.useAmmo = AmmoID.Rocket;

        }



        public override void AddRecipes()

        {

            ModRecipe recipe = new ModRecipe(mod);

            recipe.AddIngredient(ItemID.LeadBar, 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }
}}
 

WolfHybrid23

Official Terrarian
If you have on armor from a mod you made check in the code for the armor you may have set it to hide certain body parts like the head and such the code to do that would be:
Code:
 public override bool Draw[Head/Body/Legs]()
using that in your code will tell the Mod Loader to hide the body part in question.
[doublepost=1483137517,1483137086][/doublepost]
Ok now the ranged weapon is working but now I have another problem with it. Instead of using rockets, it uses a different projectile. So far it shot out powder (hallow or vile) for rocket 1 and for rocket 5 it shot out flamarangs.
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Items.Weapons

{

    public class BlackBox : ModItem

    {

        public override void SetDefaults()

        {

            item.name = "Black Box";

            item.damage = 25;

            item.ranged = true;

            item.width = 40;

            item.height = 20;

            item.toolTip = "MAGGOT!";

            item.useTime = 20;

            item.useAnimation = 20;

            item.useStyle = 5;

            item.noMelee = true;

            item.knockBack = 4;

            item.value = 10000;

            item.rare = 2;

            item.UseSound = SoundID.Item11;

            item.autoReuse = true;

            item.shoot = 10;

            item.shootSpeed = 16f;

            item.useAmmo = AmmoID.Rocket;

        }



        public override void AddRecipes()

        {

            ModRecipe recipe = new ModRecipe(mod);

            recipe.AddIngredient(ItemID.LeadBar, 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }
}}
I don't know what could be causing that maybe there's a mix up with the ItemID for "Rocket 4" and the "Flamearang", or "Rocket 4" could have a different Internal Item ID than the other rockets. It also could help to use the actual ID instead of ItemID.<ItemName> and have 4 different codes for each rocket id like this:
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Items.Weapons

{

    public class BlackBox : ModItem

    {

        public override void SetDefaults()

        {

            item.name = "Black Box";

            item.damage = 25;

            item.ranged = true;

            item.width = 40;

            item.height = 20;

            item.toolTip = "MAGGOT!";

            item.useTime = 20;

            item.useAnimation = 20;

            item.useStyle = 5;

            item.noMelee = true;

            item.knockBack = 4;

            item.value = 10000;

            item.rare = 2;

            item.UseSound = SoundID.Item11;

            item.autoReuse = true;

            item.shoot = 10;

            item.shootSpeed = 16f;

            item.useAmmo = 771;

            item.useAmmo = 772;

            item.useAmmo = 773;

            item.useAmmo = 774;

        }



        public override void AddRecipes()

        {

            ModRecipe recipe = new ModRecipe(mod);

            recipe.AddIngredient(ItemID.LeadBar, 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }
[doublepost=1483137762][/doublepost]
If you have on armor from a mod you made check in the code for the armor you may have set it to hide certain body parts like the head and such the code to do that would be:
Code:
 public override bool Draw[Head/Body/Legs]()
using that in your code will tell the Mod Loader to hide the body part in question.
[doublepost=1483137517,1483137086][/doublepost]
I don't know what could be causing that maybe there's a mix up with the ItemID for "Rocket 4" and the "Flamearang", or "Rocket 4" could have a different Internal Item ID than the other rockets. It also could help to use the actual ID instead of ItemID.<ItemName> and have 4 different codes for each rocket id like this:
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Items.Weapons

{

    public class BlackBox : ModItem

    {

        public override void SetDefaults()

        {

            item.name = "Black Box";

            item.damage = 25;

            item.ranged = true;

            item.width = 40;

            item.height = 20;

            item.toolTip = "MAGGOT!";

            item.useTime = 20;

            item.useAnimation = 20;

            item.useStyle = 5;

            item.noMelee = true;

            item.knockBack = 4;

            item.value = 10000;

            item.rare = 2;

            item.UseSound = SoundID.Item11;

            item.autoReuse = true;

            item.shoot = 10;

            item.shootSpeed = 16f;

            item.useAmmo = 771;

            item.useAmmo = 772;

            item.useAmmo = 773;

            item.useAmmo = 774;

        }



        public override void AddRecipes()

        {

            ModRecipe recipe = new ModRecipe(mod);

            recipe.AddIngredient(ItemID.LeadBar, 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }
}}
I looked up the rocket ids and found no rocket 5 where did you see rocket 5, that could also be why it shot "Flamarangs" for rocket 5.
 

Ivysaur

Official Terrarian
Ok now the ranged weapon is working but now I have another problem with it. Instead of using rockets, it uses a different projectile. So far it shot out powder (hallow or vile) for rocket 1 and for rocket 5 it shot out flamarangs.
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Items.Weapons

{

    public class BlackBox : ModItem

    {

        public override void SetDefaults()

        {

            item.name = "Black Box";

            item.damage = 25;

            item.ranged = true;

            item.width = 40;

            item.height = 20;

            item.toolTip = "MAGGOT!";

            item.useTime = 20;

            item.useAnimation = 20;

            item.useStyle = 5;

            item.noMelee = true;

            item.knockBack = 4;

            item.value = 10000;

            item.rare = 2;

            item.UseSound = SoundID.Item11;

            item.autoReuse = true;

            item.shoot = 10;

            item.shootSpeed = 16f;

            item.useAmmo = AmmoID.Rocket;

        }



        public override void AddRecipes()

        {

            ModRecipe recipe = new ModRecipe(mod);

            recipe.AddIngredient(ItemID.LeadBar, 10);

            recipe.AddTile(TileID.Anvils);

            recipe.SetResult(this);

            recipe.AddRecipe();

        }
}}
By the way:
If you want to heal the player when this weapon attacks an NPC you could try to add this function:

Code:
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit)
{
      player.statLife += 10;
}

If you need to tweak or buff it you can adjust the 10.
 

360Chadscope

Pixel Pirate
Is there a way to make a 2x2 tile piece of furniture that can be placed on a wall?
I tried
Code:
TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2Wall);
But I guess there is no tiles like that in vanilla Terraria.
In addition to this question, I also have this situation which I need help with.
I made a gnome and I want to place it. Placement preview knows what's up:
upload_2016-12-31_0-40-21.png

But sadly that's where it ends;
upload_2016-12-31_0-41-6.png

This is what the tile actually looks like when I place it down. It looks like it just took the lowest row of pixels and stretched it out to fit (almost) the entire area.
Has anyone had this same problem? And if so, how did you fix it?
Here is the code for the gnome tile, if that helps:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.Enums;
using Terraria.ModLoader;
using Terraria.ObjectData;
using Terraria.DataStructures;

namespace chadsfurni.Tiles
{
    public class gnome : ModTile
    {
        public override void SetDefaults()
        {
            TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
            TileObjectData.addTile(Type);
            AddMapEntry(new Color(120, 50, 35), "Gnome");
            dustType = 11;
            disableSmartCursor = true;
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 32, 48, mod.ItemType("gnome"));
        }
    }
}
 

Orion The Boundary Ryu

Skeletron Prime
I am making a projectile for my new weapon in my mod but the projectile bounces of walls and doesent explode like a rocket would.
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Projectiles

{

    public class Rocket : ModProjectile

    {

        public override void SetDefaults()

        {

            projectile.name = "Rocket";

            projectile.width = 8;

            projectile.height = 8;

            projectile.aiStyle = 1;

            projectile.friendly = true;

            projectile.ranged = true;

            projectile.penetrate = 5;

            projectile.timeLeft = 600;

            projectile.alpha = 255;

            projectile.light = 0.5f;

            projectile.extraUpdates = 1;

            ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;

            ProjectileID.Sets.TrailingMode[projectile.type] = 0;

            aiType = ProjectileID.Bullet;

        }



        public override bool OnTileCollide(Vector2 oldVelocity)

        {

            projectile.penetrate--;

            if (projectile.penetrate <= 0)

            {

                projectile.Kill();

            }

            else

            {

                if (projectile.velocity.X != oldVelocity.X)

                {

                    projectile.velocity.X = -oldVelocity.X;

                }

                if (projectile.velocity.Y != oldVelocity.Y)

                {

                    projectile.velocity.Y = -oldVelocity.Y;

                }

                Main.PlaySound(SoundID.Item10, projectile.position);

            }

            return false;

        }



        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)

        {

            Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);

            for (int k = 0; k < projectile.oldPos.Length; k++)

            {

                Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);

                Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);

                spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);

            }

            return true;

        }

    }

}
 

CATZSparks

Spazmatism
Has anyone found out how to fix the problem where some people cant do anything after trying to get an item? im having that proplem too and i dont know what to do
 

jopojelly

Retinazer
tModLoader
In addition to this question, I also have this situation which I need help with.
I made a gnome and I want to place it. Placement preview knows what's up:
View attachment 153405
But sadly that's where it ends;
View attachment 153406
This is what the tile actually looks like when I place it down. It looks like it just took the lowest row of pixels and stretched it out to fit (almost) the entire area.
Has anyone had this same problem? And if so, how did you fix it?
Here is the code for the gnome tile, if that helps:
Code:
using System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.Enums;
using Terraria.ModLoader;
using Terraria.ObjectData;
using Terraria.DataStructures;

namespace chadsfurni.Tiles
{
    public class gnome : ModTile
    {
        public override void SetDefaults()
        {
            TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
            TileObjectData.addTile(Type);
            AddMapEntry(new Color(120, 50, 35), "Gnome");
            dustType = 11;
            disableSmartCursor = true;
        }

        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 32, 48, mod.ItemType("gnome"));
        }
    }
}
Show the item code. It's likely place style not = to 0 or something.
 

360Chadscope

Pixel Pirate
Show the item code. It's likely place style not = to 0 or something.
Code:
using Terraria.ID;
using Terraria.ModLoader;

namespace chadsfurni.Items
{
    public class gnome : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Gnome";
            item.width = 16;
            item.height = 22;
            item.maxStack = 99;
            AddTooltip("Holding a little shovel.");
            item.useTurn = true;
            item.autoReuse = true;
            item.useAnimation = 15;
            item.useTime = 10;
            item.useStyle = 1;
            item.consumable = true;
            item.value = 0;
            item.createTile = mod.TileType("gnome");
        }

        public override void AddRecipes()
        {
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.Wood, 1);
        //    recipe.AddTile(TileID.Sawmill);
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
This is the item code.
 

Ivysaur

Official Terrarian
Has anyone found out how to fix the problem where some people cant do anything after trying to get an item? im having that proplem too and i dont know what to do
What exactly do you mean? If you can't get your item then you can add a recipe to it, or spawn it in with cheat sheet.
 

Cjay

Terrarian
Im Having A Problem, My Mod Wont Build And The Error Lead's To My Armors Buff Code.
If You Find SomeThing Wrong Please Tell Me.

Helmet :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.NightOwl, 2);
        }
    }

Breastplate :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.Shine, 2);
        }
    }

Leggings :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.Speed, 2);
        }
    }
 

jopojelly

Retinazer
tModLoader
Im Having A Problem, My Mod Wont Build And The Error Lead's To My Armors Buff Code.
If You Find SomeThing Wrong Please Tell Me.

Helmet :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.NightOwl, 2);
        }
    }

Breastplate :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.Shine, 2);
        }
    }

Leggings :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.Speed, 2);
        }
    }
I don't think Speed is a buff, (https://github.com/bluemagic123/tModLoader/wiki/Vanilla-Buff-IDs), but you can't have unbalanced curly braces. One { to start the method, one } to end the method. Not 2. Also, post the error in the future.
 

WolfHybrid23

Official Terrarian
I am making a projectile for my new weapon in my mod but the projectile bounces of walls and doesent explode like a rocket would.
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Projectiles

{

    public class Rocket : ModProjectile

    {

        public override void SetDefaults()

        {

            projectile.name = "Rocket";

            projectile.width = 8;

            projectile.height = 8;

            projectile.aiStyle = 1;

            projectile.friendly = true;

            projectile.ranged = true;

            projectile.penetrate = 5;

            projectile.timeLeft = 600;

            projectile.alpha = 255;

            projectile.light = 0.5f;

            projectile.extraUpdates = 1;

            ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;

            ProjectileID.Sets.TrailingMode[projectile.type] = 0;

            aiType = ProjectileID.Bullet;

        }



        public override bool OnTileCollide(Vector2 oldVelocity)

        {

            projectile.penetrate--;

            if (projectile.penetrate <= 0)

            {

                projectile.Kill();

            }

            else

            {

                if (projectile.velocity.X != oldVelocity.X)

                {

                    projectile.velocity.X = -oldVelocity.X;

                }

                if (projectile.velocity.Y != oldVelocity.Y)

                {

                    projectile.velocity.Y = -oldVelocity.Y;

                }

                Main.PlaySound(SoundID.Item10, projectile.position);

            }

            return false;

        }



        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)

        {

            Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);

            for (int k = 0; k < projectile.oldPos.Length; k++)

            {

                Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);

                Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);

                spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);

            }

            return true;

        }

    }

}
Try changing 'projectile.penetrate' to a massive amount, 5 could be a lesser amount of strength than the block it hits in question.
 

Miu86silva

Terrarian
Can some one tell me where the characters are store, I have an old character that I want to "revive" (he is not dead in the game / he is in softcore)
 

CATZSparks

Spazmatism
What exactly do you mean? If you can't get your item then you can add a recipe to it, or spawn it in with cheat sheet.
when ever there is an item on the ground from like mining a block or killing a monster and i try to pick it up i cant do anything it just freezes my character and i can only open my inv. or save & exit
 

Orion The Boundary Ryu

Skeletron Prime
Can anyone tell me how to get my projectile to explode on impact? I got it to stop bouncing and etc..
Code:
using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Graphics;

using Terraria;

using Terraria.ID;

using Terraria.ModLoader;



namespace Tf2.Projectiles

{

    public class Rocket : ModProjectile

    {

        public override void SetDefaults()

        {

            projectile.name = "Rocket";

            projectile.width = 8;

            projectile.height = 8;

            projectile.aiStyle = 1;

            projectile.friendly = true;

            projectile.ranged = true;

            projectile.penetrate = 1;

            projectile.timeLeft = 600;

            projectile.alpha = 255;

            projectile.light = 0.5f;

            projectile.extraUpdates = 1;

            ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;

            ProjectileID.Sets.TrailingMode[projectile.type] = 0;

            aiType = ProjectileID.Bullet;

        }



        public override bool OnTileCollide(Vector2 oldVelocity)

        {

            projectile.penetrate--;

            if (projectile.penetrate <= 200)

            {

                projectile.Kill();

            }

            else

            {

                if (projectile.velocity.X != oldVelocity.X)

                {

                    projectile.velocity.X = -oldVelocity.X;

                }

                if (projectile.velocity.Y != oldVelocity.Y)

                {

                    projectile.velocity.Y = -oldVelocity.Y;

                }

                Main.PlaySound(SoundID.Item10, projectile.position);

            }

            return false;

        }



        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)

        {

            Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f);

            for (int k = 0; k < projectile.oldPos.Length; k++)

            {

                Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY);

                Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length);

                spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f);

            }

            return true;

        }

    }

}
[doublepost=1483215141,1483215054][/doublepost]
Im Having A Problem, My Mod Wont Build And The Error Lead's To My Armors Buff Code.
If You Find SomeThing Wrong Please Tell Me.

Helmet :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.NightOwl, 2);
        }
    }

Breastplate :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.Shine, 2);
        }
    }

Leggings :

Code:
public override void UpdateArmorSet(Player player)
        {
            player.AddBuff(BuffID.Speed, 2);
        }
    }
Change speed to swiftness, just like jopojelly said speed isn't a vanilla buff :p
 
Top Bottom