using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using System;
namespace EpicnessModRemastered.Buffs
{
public class Freeze : ModBuff
{
public override void SetDefaults()
{
Main.buffNoTimeDisplay[Type] = false;
Main.buffName[this.Type] = "Freeze";
Main.buffTip[this.Type] = "Nothing Shall MOVE!!!";
}
public override void Update(NPC npc, ref int buffIndex)//, int buffIndex, int buffType, int buffTime)
{
npc.velocity.X = 0;
npc.velocity.Y = 0;
npc.color = new Color(0, 80, 255, 100);
}
}
}
You'll have to post your code and the error. But you might want to check out this guide: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/Items/ExampleItem.cs#L31I need some help with my mod. I am trying to make my custom mod item a material for some armor, but when i add the ingredient to the armor, it says that my modded item is only a variable. Can someone please tell me how to make the custom item a material. Thanks
Or use a helper methodThe reason for that is that Terraria uses the BlendState of AlphaBlend, which doesn't like semi-transparent pixels very well. There's two ways around this, though.
1) Create your own SpriteBatch and use BlendState.AlphaBlend in 'Begin'.
2) Give your sprite a black background and then set it's Alpha to 0.
1 is a bit complex. 2 is more straight forward, but can make parts of your sprite dark that you don't want it to.
public static void MultiplyColorsByAlpha(this Texture2D texture)
{
Color[] data = new Color[texture.Width * texture.Height];
texture.GetData(data);
for (int i = 0; i < data.Length; i++)
{
Vector4 we = data[i].ToVector4();
data[i] = new Color(we.X * we.W, we.Y * we.W, we.Z * we.W, we.W);
}
texture.SetData(data);
}
public override void SetDefaults()
{
projectile.name = "Improve Bone Dagger";
projectile.width = 22;
projectile.height = 22;
projectile.friendly = true;
projectile.penetrate = 6;
projectile.thrown = true;
}
public override void AI()
{
this.ai[0] += 1f;
if (this.ai[0] >= 20f)
{
this.velocity.Y = this.velocity.Y + 0.4f;
this.velocity.X = this.velocity.X * 0.97f;
}
else //if (this.type == 48 || this.type == 54 || this.type == 93 || this.type == 520 || this.type == 599)
{
this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
}
}
I'm confused. The code you have posted shouldn't even build correctly, are you sure that is the code that is being used in that example image? For example, this.ai[0] should be projectile.ai[0] and so on for all the other "this"sHow to make sprite rotate correctly?
This is my custom Bone Dagger's Projectile :
AI function is cpoied from gamesource (using ILSpy) , but the projectile does not rotate like bone throwing knife. So I think it isn't enough to make an projectile rotate. What should I add to my code?Code:public override void SetDefaults() { projectile.name = "Improve Bone Dagger"; projectile.width = 22; projectile.height = 22; projectile.friendly = true; projectile.penetrate = 6; projectile.thrown = true; } public override void AI() { this.ai[0] += 1f; if (this.ai[0] >= 20f) { this.velocity.Y = this.velocity.Y + 0.4f; this.velocity.X = this.velocity.X * 0.97f; } else //if (this.type == 48 || this.type == 54 || this.type == 93 || this.type == 520 || this.type == 599) { this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f; } }
What happened :
What I want
My bad, i copy it from my old .cs file so "this" still not be replaced by "projectile", but the structure is not changed.I'm confused. The code you have posted shouldn't even build correctly, are you sure that is the code that is being used in that example image? For example, this.ai[0] should be projectile.ai[0] and so on for all the other "this"s
if (this.counter >= 5)
{
projectile.rotation += (float)(Math.PI / 5f);
}
else
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
}
private int counter;
public override void SetDefaults()
{
projectile.CloneDefaults(ProjectileID.BoneDagger);
projectile.name = "Improve Bone Dagger";
projectile.aiStyle = 0;
projectile.penetrate = 4;
this.counter = 0;
}
public override void AI()
{
int num = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 75, projectile.velocity.X, projectile.velocity.Y, 100, default(Color), 1.2f);
Main.dust[num].position = (Main.dust[num].position + projectile.Center) / 2f;
Main.dust[num].noGravity = true;
if (Main.rand.Next(3) == 0)
{
Main.dust[num].scale *= 2f;
}
projectile.ai[0] += 1f;
if (projectile.ai[0] >= 50f)
{
projectile.velocity.Y = projectile.velocity.Y + 0.4f;
projectile.velocity.X = projectile.velocity.X * 0.97f;
this.counter++;
}
if (this.counter >= 5)
{
projectile.rotation += (float)(Math.PI / 5f);
}
else
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
}
}
version = v0.1Got this error while trying to build my mod for the first time, I don't know what is wrong with build.txt
Failed to load C:\Users\Aidan\Documents\My Games\Terraria\ModLoader\Mod Sources\Mechanite\build.txt
System.FormatException: Input string was not in a correct format.
at System.Version.VersionResult.SetFailure(ParseFailureKind failure, String argument)
at System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent)
at System.Version.TryParseVersion(String version, VersionResult& result)
at System.Version.Parse(String input)
at System.Version..ctor(String version)
at Terraria.ModLoader.BuildProperties.ReadBuildFile(String modDir)
at Terraria.ModLoader.ModCompile.ReadProperties(String modFolder, IBuildStatus status)
author = Sinchu9
version = v0.1
displayName = Mechanite
Mod
hideCode = true
hideResources = true
includeSource = false
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*
includePDB = true
languageVersion = 4
version = v0.1
is wrong
version = 0.1
is right.
Oh, was this not a copy and paste error?now I get this
Failed to load C:\Users\Me\Documents\My Games\Terraria\ModLoader\Mod Sources\Mechanite\build.txt
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at Terraria.ModLoader.BuildProperties.ReadBuildFile(String modDir)
at Terraria.ModLoader.ModCompile.ReadProperties(String modFolder, IBuildStatus status)
displayName = Mechanite
Mod
Very strange, in my build.txt it looked like it was on one line. Although retyping it fixed it.Should be 1 line.Code:displayName = Mechanite Mod
Probably the namespace, double check things and look at the Texture Load error guide in my signature.Very strange, in my build.txt it looked like it was on one line. Although retyping it fixed it.
now I get this when loading in Terraria
Items/Armor/Tier1/MechaniteBreastplateR_Body
at Terraria.ModLoader.Mod.GetTexture(String name)
at Terraria.ModLoader.ModLoader.GetTexture(String name)
at Terraria.ModLoader.Mod.AddEquipTexture(EquipTexture equipTexture, ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AddEquipTexture(ModItem item, EquipType type, String name, String texture, String armTexture, String femaleTexture)
at Terraria.ModLoader.Mod.AutoloadItem(Type type)
at Terraria.ModLoader.Mod.Autoload()
at Terraria.ModLoader.ModLoader.do_Load(Object threadContext)
I also have other armor sets have the same naming convention and work fine, so I'm confused