Dacern
Terrarian
I'm pretty new to modding, I have done it for only a couple of days, and I need help. For some reason, some of my enemies despawn instantly when coming into contact with about 75% of my modded weapons. Can you figure out why, and help me? I'll attach code of one of the enemies. (I know that this enemy will not spawn by the way.)
public class Legs : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Legs");
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Harpy];
}
public override void SetDefaults()
{
npc.width = 32;
npc.height = 32;
npc.lifeMax = 1000;
npc.damage = 25;
npc.defense = 0;
npc.HitSound = SoundID.NPCHit17;
npc.DeathSound = SoundID.NPCDeath15;
npc.value = 7500f;
npc.knockBackResist = 1f;
npc.aiStyle = 26;
aiType = NPCID.Unicorn;
animationType = NPCID.Zombie;
}
public override void HitEffect(int hitDirection, double damage)
{
for (int i = 0; i < 10; i++)
{
int dustType = 5;
int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
Dust dust = Main.dust[dustIndex];
dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
}
}
}
public class Legs : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Legs");
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Harpy];
}
public override void SetDefaults()
{
npc.width = 32;
npc.height = 32;
npc.lifeMax = 1000;
npc.damage = 25;
npc.defense = 0;
npc.HitSound = SoundID.NPCHit17;
npc.DeathSound = SoundID.NPCDeath15;
npc.value = 7500f;
npc.knockBackResist = 1f;
npc.aiStyle = 26;
aiType = NPCID.Unicorn;
animationType = NPCID.Zombie;
}
public override void HitEffect(int hitDirection, double damage)
{
for (int i = 0; i < 10; i++)
{
int dustType = 5;
int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
Dust dust = Main.dust[dustIndex];
dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
}
}
}
Simple🌳
Official Terrarian
I don't see something wrong with this NPC other than it have no defense at all.I'm pretty new to modding, I have done it for only a couple of days, and I need help. For some reason, some of my enemies despawn instantly when coming into contact with about 75% of my modded weapons. Can you figure out why, and help me? I'll attach code of one of the enemies. (I know that this enemy will not spawn by the way.)
public class Legs : ModNPC
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Legs");
Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.Harpy];
}
public override void SetDefaults()
{
npc.width = 32;
npc.height = 32;
npc.lifeMax = 1000;
npc.damage = 25;
npc.defense = 0;
npc.HitSound = SoundID.NPCHit17;
npc.DeathSound = SoundID.NPCDeath15;
npc.value = 7500f;
npc.knockBackResist = 1f;
npc.aiStyle = 26;
aiType = NPCID.Unicorn;
animationType = NPCID.Zombie;
}
public override void HitEffect(int hitDirection, double damage)
{
for (int i = 0; i < 10; i++)
{
int dustType = 5;
int dustIndex = Dust.NewDust(npc.position, npc.width, npc.height, dustType);
Dust dust = Main.dust[dustIndex];
dust.velocity.X = dust.velocity.X + Main.rand.Next(-50, 51) * 0.01f;
dust.velocity.Y = dust.velocity.Y + Main.rand.Next(-50, 51) * 0.01f;
dust.scale *= 1f + Main.rand.Next(-30, 31) * 0.01f;
}
}
}
There may be a chance the error is caused by the 75% of your weapons, so you may want to attach your weapon code too.
Kakuvadas
Golem
Hello, I am creating a modded adventure map for quite a while. Does anyone have any knowledge of how to make statues, which spawn modded enemies?
I've seen statues like that in Thorium or Split mods, but the devs aren't really answering

p.s. statues for vanilla enemies works
I've seen statues like that in Thorium or Split mods, but the devs aren't really answering
p.s. statues for vanilla enemies works
alessandrozingali
Skeletron Prime
soooooooooooooooooo how is going the update for 1.4?
Dacern
Terrarian
I don't see something wrong with this NPC other than it have no defense at all.
There may be a chance the error is caused by the 75% of your weapons, so you may want to attach your weapon code too.
Here's one of the weapons that always instantly kills enemies.
public class FirebloomSpellbook : ModItem
{
public override void SetDefaults()
{
item.damage = 500;
item.magic = true;
item.mana = 10;
item.width = 28;
item.height = 32;
item.useTime = 75;
item.useAnimation = 75;
item.useStyle = 5;
item.knockBack = 10;
item.value = 30000;
item.rare = 8;
item.UseSound = SoundID.Item88;
item.autoReuse = true;
item.shootSpeed = 15f;
item.shoot = 85;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
float numberProjectiles = 20;
float rotation = MathHelper.ToRadians(180);
position += Vector2.Normalize(new Vector2(speedX, speedY)) * 180f;
for (int i = 0; i < numberProjectiles; i++)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; // Watch out for dividing by 0 if there is only 1 projectile.
Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<Upgrade>(), 1);
recipe.AddIngredient(ItemID.FlowerofFire, 1);
recipe.AddIngredient(ItemID.Sunflower, 5);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
Simple🌳
Official Terrarian
Nothing wrong with that either... The extremely high damage of the weapon and the absolute zero defense of the NPC might've caused it to die immediately. Another thing that could've happened was that your sound was off and the NPC did not have gore.Here's one of the weapons that always instantly kills enemies.
public class FirebloomSpellbook : ModItem
{
public override void SetDefaults()
{
item.damage = 500;
item.magic = true;
item.mana = 10;
item.width = 28;
item.height = 32;
item.useTime = 75;
item.useAnimation = 75;
item.useStyle = 5;
item.knockBack = 10;
item.value = 30000;
item.rare = 8;
item.UseSound = SoundID.Item88;
item.autoReuse = true;
item.shootSpeed = 15f;
item.shoot = 85;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
float numberProjectiles = 20;
float rotation = MathHelper.ToRadians(180);
position += Vector2.Normalize(new Vector2(speedX, speedY)) * 180f;
for (int i = 0; i < numberProjectiles; i++)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; // Watch out for dividing by 0 if there is only 1 projectile.
Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<Upgrade>(), 1);
recipe.AddIngredient(ItemID.FlowerofFire, 1);
recipe.AddIngredient(ItemID.Sunflower, 5);
recipe.AddTile(TileID.Anvils);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
silent_ptr
Plantera
How do I get my tile to only be placed on walls? I've tried this:
And it doesn't let me place it at all. Is there also a way to make it face a certain direction based on what wall it was placed on? Thanks.
EDIT: I tried the following, and it worked a bit better but it needs 2 blocks on either side (and the sprite direction doesn't change):
C#:
public override void SetDefaults()
{
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileLavaDeath[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
TileObjectData.newTile.AnchorWall = true;
TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 };
TileObjectData.addTile(Type);
disableSmartCursor = true;
}
EDIT: I tried the following, and it worked a bit better but it needs 2 blocks on either side (and the sprite direction doesn't change):
C#:
public override void SetDefaults()
{
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileLavaDeath[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2);
//TileObjectData.newTile.AnchorWall = true;
TileObjectData.newTile.AnchorLeft = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
TileObjectData.newTile.AnchorRight = new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
TileObjectData.newTile.CoordinateHeights = new[] { 16, 16 };
TileObjectData.addTile(Type);
disableSmartCursor = true;
}
Last edited:
Aspet
Terrarian
I'm using the 32-bit version why?Are you using the 64-bit version?
Buddha
Terrarian
This needs to get updated ... not for the sake of "Terraria v1.4" but more like converting my buildings and such to 1.3.5.3.
TEdit is not able to process tiled buildings (with even items which are STRICTLY v1.3 based!), the array range is kinda bugging out (as if the application saves v1.4 meta data for no reason on its application footprint) and I am not able to get my fancy buildings over to tModLoader based Maps.
TEdit is not able to process tiled buildings (with even items which are STRICTLY v1.3 based!), the array range is kinda bugging out (as if the application saves v1.4 meta data for no reason on its application footprint) and I am not able to get my fancy buildings over to tModLoader based Maps.
Simple🌳
Official Terrarian
The 64-bit version is a more experimental than public mode. It is slower on updates, if you wait long enough, the 64-bit Tmodloader may catch up.I'm using the 32-bit version why?
shoelid
Terrarian
Hey! New to modding, and I'm posting here with the hope that somebody can help me with my code. I want my weapon to give the player a buff when they right click with it. The issue is that once the player right clicks with the sword, item.buffType is assigned to the entire item. From that point forward, both the left and right clicks assign the buff. How do I unassign item.buffType for the left click functionality? or maybe there's a better way to go about this?
Here's the relevant code:
Here's the relevant code:
C#:
public override bool CanUseItem(Player player){ //right click functionality
if (player.altFunctionUse == 2){
item.UseSound = SoundID.Item100;//placeholder
item.useStyle = ItemUseStyleID.HoldingUp;
item.useTime = 10;//placeholder
item.useAnimation = 10;//placeholder
item.noMelee = true;
item.buffType = ModContent.BuffType<GhostbladeBuff>();
item.buffTime = 360;
}
else {
item.UseSound = SoundID.Item1;
item.useStyle = ItemUseStyleID.SwingThrow;
item.useTime = 10;
item.useAnimation = 25;
item.noMelee = false;
}
return base.CanUseItem(player);
}
Yeahfrick
Official Terrarian
Aint working appears 1 error idk why (changed "name" and "texture" putted back these things but keep appearing the error)To Al0n37 does have an outdated code. Add "Player player," to and public override void HorizontalWingSpeeds(ref float speed, ref float acceleration) and public override void VerticalWingSpeeds(ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
There are some extra errors I have noticed:
TileID.anvil is not the ID for an anvil, it should be this instead: TileID.Anvils
In SetDefaults, item.toolTip = ""; and item.name = "LatormWings"; is outdated. Instead, make a new class thingy called SetStaticDefaults
public override void SetStaticDefaults() {
DisplayName.SetDefault("LatormWings");
Tooltip.SetDefault("");
}
C#:using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace noname.Items { public class LatormWings : ModItem { public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips) { equips.Add(EquipType.Wings); return true; } public override void SetStaticDefaults() { DisplayName.SetDefault("LatormWings"); Tooltip.SetDefault(""); } public override void SetDefaults() { item.width = 22; item.height = 20; item.value = 10000; item.rare = 4; item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { player.wingTimeMax = 10; //wings Height } public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { ascentWhenFalling = 0.85f; ascentWhenRising = 0.15f; maxCanAscendMultiplier = 1f; maxAscentMultiplier = 3f; constantAscend = 0.135f; } public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration) { speed = 9f; acceleration *= 2.5f; } public override void AddRecipes() //How to craft this item { ModRecipe recipe = new ModRecipe (mod); recipe.AddIngredient(null, "latorm", 10); recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); } } }
I hope that works!
P.S: There is another modding tutorial video called Modding Master class made by Lynx on youtube, although cancelled for 1.4, it is up to date.
C#:
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace noname.Items
{
public class LatormWings : ModItem
{
public override bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips)
{
equips.Add(EquipType.Wings);
return true;
}
public override void SetStaticDefaults() {
DisplayName.SetDefault("LatormWings");
Tooltip.SetDefault("a");
}
public override void SetDefaults()
{
item.width = 22;
item.height = 20;
item.value = 10000;
item.rare = 4;
item.accessory = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.wingTimeMax = 10; //wings Height
}
public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}
public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)
{
speed = 9f;
acceleration *= 2.5f;
}
public override void AddRecipes() //How to craft this item
{
ModRecipe recipe = new ModRecipe (mod);
recipe.AddIngredient(null, "latorm", 10);
recipe.AddTile(TileID.Anvils);
}
}
}
error:[19:31:52] [8/ERROR] [tML]: C:\Users\AARONCITO\Documents\My Games\Terraria\ModLoader\Mod Sources\noname\Items\LatormWings.cs(19,29) : error CS0115: 'LatormWings.Autoload(ref string, ref string, IList<EquipType>)': no suitable method found to override
Simple🌳
Official Terrarian
Whenever you have this type of error: no suitable method found to override. You simply replace 'override' with 'static' or 'virtual'Aint working appears 1 error idk why (changed "name" and "texture" putted back these things but keep appearing the error)
C#:using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace noname.Items { public class LatormWings : ModItem { public override bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips) { equips.Add(EquipType.Wings); return true; } public override void SetStaticDefaults() { DisplayName.SetDefault("LatormWings"); Tooltip.SetDefault("a"); } public override void SetDefaults() { item.width = 22; item.height = 20; item.value = 10000; item.rare = 4; item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { player.wingTimeMax = 10; //wings Height } public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { ascentWhenFalling = 0.85f; ascentWhenRising = 0.15f; maxCanAscendMultiplier = 1f; maxAscentMultiplier = 3f; constantAscend = 0.135f; } public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration) { speed = 9f; acceleration *= 2.5f; } public override void AddRecipes() //How to craft this item { ModRecipe recipe = new ModRecipe (mod); recipe.AddIngredient(null, "latorm", 10); recipe.AddTile(TileID.Anvils); } } }
error:[19:31:52] [8/ERROR] [tML]: C:\Users\AARONCITO\Documents\My Games\Terraria\ModLoader\Mod Sources\noname\Items\LatormWings.cs(19,29) : error CS0115: 'LatormWings.Autoload(ref string, ref string, IList<EquipType>)': no suitable method found to override
So it should look like this now:
C#:
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace noname.Items
{
public class LatormWings : ModItem
{
public virtual bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips) // you can also do static.
{
equips.Add(EquipType.Wings);
return true;
}
public override void SetStaticDefaults() {
DisplayName.SetDefault("LatormWings");
Tooltip.SetDefault("a");
}
public override void SetDefaults()
{
item.width = 22;
item.height = 20;
item.value = 10000;
item.rare = 4;
item.accessory = true;
}
public override void UpdateAccessory(Player player, bool hideVisual)
{
player.wingTimeMax = 10; //wings Height
}
public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend)
{
ascentWhenFalling = 0.85f;
ascentWhenRising = 0.15f;
maxCanAscendMultiplier = 1f;
maxAscentMultiplier = 3f;
constantAscend = 0.135f;
}
public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration)
{
speed = 9f;
acceleration *= 2.5f;
}
public override void AddRecipes() //How to craft this item
{
ModRecipe recipe = new ModRecipe (mod);
recipe.AddIngredient(null, "latorm", 10);
recipe.AddTile(TileID.Anvils);
}
}
}
Yeahfrick
Official Terrarian
wtf not even a day and you replyWhenever you have this type of error: no suitable method found to override. You simply replace 'override' with 'static' or 'virtual'
So it should look like this now:
C#:using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace noname.Items { public class LatormWings : ModItem { public virtual bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips) // you can also do static. { equips.Add(EquipType.Wings); return true; } public override void SetStaticDefaults() { DisplayName.SetDefault("LatormWings"); Tooltip.SetDefault("a"); } public override void SetDefaults() { item.width = 22; item.height = 20; item.value = 10000; item.rare = 4; item.accessory = true; } public override void UpdateAccessory(Player player, bool hideVisual) { player.wingTimeMax = 10; //wings Height } public override void VerticalWingSpeeds(Player player, ref float ascentWhenFalling, ref float ascentWhenRising, ref float maxCanAscendMultiplier, ref float maxAscentMultiplier, ref float constantAscend) { ascentWhenFalling = 0.85f; ascentWhenRising = 0.15f; maxCanAscendMultiplier = 1f; maxAscentMultiplier = 3f; constantAscend = 0.135f; } public override void HorizontalWingSpeeds(Player player, ref float speed, ref float acceleration) { speed = 9f; acceleration *= 2.5f; } public override void AddRecipes() //How to craft this item { ModRecipe recipe = new ModRecipe (mod); recipe.AddIngredient(null, "latorm", 10); recipe.AddTile(TileID.Anvils); } } }
Simple🌳
Official Terrarian
I am pretty quick, huh?wtf not even a day and you reply
Yeahfrick
Official Terrarian
Yes, too the wings dont show and dont workI am pretty quick, huh?
Simple🌳
Official Terrarian
Another thing you can do instead of:Yes, too the wings dont show and dont work
C#:
public virtual bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips) // you can also do static.
{
equips.Add(EquipType.Wings);
return true;
}
C#:
[AutoloadEquip(EquipType.Wings)]
public class LatormWings : ModItem
Yeahfrick
Official Terrarian
Thx now it works uwu, you saved me a lot of hours thanks lmaoAnother thing you can do instead of:
is add this instead:C#:public virtual bool Autoload(ref string LatormWings, ref string LatormWings_Wings, IList<EquipType> equips) // you can also do static. { equips.Add(EquipType.Wings); return true; }
So that there is an autoload on top of your LatormWingsC#:[AutoloadEquip(EquipType.Wings)] public class LatormWings : ModItem
>>Terrarian<<
Solar Pillar
Hey guys, Is tModLoader now compatible with Terraria version 1.4.0.5?
Similar threads
- Replies
- 40
- Views
- 23K
- Replies
- 5
- Views
- 1K
- Replies
- 893
- Views
- 891K
- Sticky
- Replies
- 270
- Views
- 264K
- Locked
- Replies
- 234
- Views
- 48K
-
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.