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;
}
}
}