Untitled

                Never    
C#
       
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace TheBook.NPCs
{
    public class DroneX1 : ModNPC
    {
        public override void SetStaticDefaults()
        {
            DisplayName.SetDefault("Drone");
        }

        public override void SetDefaults()
        {
            npc.width = 38;
            npc.height = 22;
            npc.damage = 18;
            npc.defense = 10;
            npc.lifeMax = 150;
            npc.HitSound = SoundID.NPCHit2;
            npc.DeathSound = SoundID.NPCDeath2;
            npc.value = 150f;
			//Lighting.AddLight(npc.position, 0.1f, 0.2f, 0.7f);
			//npc.light = 0.4f; //Lights up the whole room
            npc.knockBackResist = 0.35f;
            npc.aiStyle = 2;
			Main.npcFrameCount[npc.type] = 4;
			npc.lavaImmune = true;
			npc.netAlways = true;
            //Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.DemonEye]; //Main.npcFrameCount[2];
            aiType = NPCID.Probe; // aiType = 2;
            animationType = NPCID.DemonEye; // animationType = 2;aa
        }

		public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
		if(Main.dayTime)
		{
		return SpawnCondition.OverworldDay.Chance  * 0.3f;
		}
		return SpawnCondition.OverworldNightMonster.Chance *0.8f;
        }
		
		public override void ScaleExpertStats(int numPlayers, float bossLifeScale)
        {
            npc.lifeMax = (int)(npc.lifeMax * 0.579f * bossLifeScale);  //boss life scale in expertmode
            npc.damage = (int)(npc.damage * 0.6f);  //boss damage increase in expermode
			npc.defense = (int)(npc.defense + numPlayers);
        }
		
		public override void AI()
		{
			npc.ai[0]++;
            Player P = Main.player[npc.target];
            if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active)
            {
                npc.TargetClosest(true);
            }
            npc.netUpdate = true;
		
			{
				Lighting.AddLight(npc.position, 0f, 1.9f, 2.0f);
			}
		
		    npc.ai[2]++;
            if (npc.ai[2] >= 330)  // 230 is projectile fire rate
            {
                float Speed = 20f;  //projectile speed
                Vector2 vector8 = new Vector2(npc.position.X + (npc.width / 1), npc.position.Y + (npc.height / 1));
                int damage = 25;  //projectile damage
                int type = mod.ProjectileType("DirtBossFireBall");  //put your projectile
                Main.PlaySound(23, (int)npc.position.X, (int)npc.position.Y, -50);
                float rotation = (float)Math.Atan2(vector8.Y - (P.position.Y + (P.height * 0.5f)), vector8.X - (P.position.X + (P.width * 0.5f)));
                int num54 = Projectile.NewProjectile(vector8.X, vector8.Y, (float)((Math.Cos(rotation) * Speed) * -1), (float)((Math.Sin(rotation) * Speed) * -1), type, damage, 0f, 0);
                npc.ai[2] = 0;
            }
            if (npc.ai[0] % 750 == 1.7)  //Npc spawn rate

            {
                NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("DroneX1"));  //NPC name
            }
            npc.ai[2] += 0;
		}
		
        public override void NPCLoot()
        {
            Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("SliverFoc"), Main.rand.Next(5, 10));
        }
    }
}

Raw Text