示例#1
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            ProtectState s;
            if (state == null) s = ProtectState.DontKnowWhere;
            else s = (ProtectState) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            Entity entity = host.GetNearestEntity(acquireRange, protectee);
            Vector2 vect;
            switch (s)
            {
                case ProtectState.DontKnowWhere:
                    if (entity != null)
                    {
                        s = ProtectState.Protecting;
                        goto case ProtectState.Protecting;
                    }
                    break;
                case ProtectState.Protecting:
                    if (entity == null)
                    {
                        s = ProtectState.DontKnowWhere;
                        break;
                    }
                    vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
                    if (vect.Length() > reprotectRange)
                    {
                        Status = CycleStatus.InProgress;
                        vect.Normalize();
                        float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
                        host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist);
                        host.UpdateCount++;
                    }
                    else
                    {
                        Status = CycleStatus.Completed;
                        s = ProtectState.Protected;
                    }
                    break;
                case ProtectState.Protected:
                    if (entity == null)
                    {
                        s = ProtectState.DontKnowWhere;
                        break;
                    }
                    Status = CycleStatus.Completed;
                    vect = new Vector2(entity.X - host.X, entity.Y - host.Y);
                    if (vect.Length() > protectionRange)
                    {
                        s = ProtectState.Protecting;
                        goto case ProtectState.Protecting;
                    }
                    break;
            }

            state = s;
        }
示例#2
0
 private static bool Blob(Vector2 q)
 {
     var eye1 = new Vector2(q.X - 0.2f, q.Y/2 + 0.2f).Length() < 0.05f;
     var eye2 = new Vector2(q.X + 0.2f, q.Y/2 + 0.2f).Length() < 0.05f;
     var body = q.Length() < 0.8f - 0.18*MathF.Sin(5*(float)Math.Atan2(q.Y, q.X));
     return body && !eye1 && !eye2;
 }
示例#3
0
 public override bool Perform(Point origin, GenAction action)
 {
     Vector2 vector2 = new Vector2((float)this._offset.X, (float)this._offset.Y);
     float single = vector2.Length();
     int num = (int)(single / 6f);
     if (this._endPoints != null)
     {
         this._endPoints.Add(new Point(origin.X + this._offset.X, origin.Y + this._offset.Y));
     }
     if (!this.PerformSegment(origin, action, origin, new Point(origin.X + this._offset.X, origin.Y + this._offset.Y), num))
     {
         return false;
     }
     int num1 = (int)(single / 8f);
     for (int i = 0; i < num1; i++)
     {
         float single1 = ((float)i + 1f) / ((float)num1 + 1f);
         Point point = new Point((int)(single1 * (float)this._offset.X), (int)(single1 * (float)this._offset.Y));
         Vector2 vector21 = new Vector2((float)(this._offset.X - point.X), (float)(this._offset.Y - point.Y));
         Vector2 vector22 = vector21;
         double num2 = (double)(((float)GenBase._random.NextDouble() * 0.5f + 1f) * (float)((GenBase._random.Next(2) == 0 ? -1 : 1)));
         Vector2 vector23 = new Vector2();
         vector21 = vector22.RotatedBy(num2, vector23) * 0.75f;
         Point point1 = new Point((int)vector21.X + point.X, (int)vector21.Y + point.Y);
         if (this._endPoints != null)
         {
             this._endPoints.Add(new Point(point1.X + origin.X, point1.Y + origin.Y));
         }
         if (!this.PerformSegment(origin, action, new Point(point.X + origin.X, point.Y + origin.Y), new Point(point1.X + origin.X, point1.Y + origin.Y), num - 1))
         {
             return false;
         }
     }
     return true;
 }
示例#4
0
 public FixedLinearSpring(Body body, Vector2 bodyAttachPoint, Vector2 worldAttachPoint, float springConstant,
                          float dampingConstant)
 {
     _body = body;
     _bodyAttachPoint = bodyAttachPoint;
     _worldAttachPoint = worldAttachPoint;
     SpringConstant = springConstant;
     DampingConstant = dampingConstant;
     _difference = worldAttachPoint - _body.GetWorldPosition(bodyAttachPoint);
     _restLength = _difference.Length();
 }
        public bool IsInActivationDistance(Body b1, Body b2)
        {
            _difference = b1.position - b2.position;
            float distance = _difference.Length();
            if (distance < 0)
            {
                _difference *= -1;
            }

            return distance <= ActivationDistance;
        }
示例#6
0
        private static bool Radial(Vector2 p)
        {
            var angle = (float)Math.Atan2(p.Y, p.X);
            var length = 0.5f*(Math.Max(Math.Abs(p.X), Math.Abs(p.Y)) + p.Length());
            var r1 = 0.5f + 0.4f*MathF.Sin(_startAngle + _bumps*angle + MathF.Cos((_bumps + 3)*angle));
            var r2 = 0.7f - 0.2f*MathF.Sin(_startAngle + _bumps*angle - MathF.Sin((_bumps + 2)*angle));

            if (Math.Abs(angle - _dipAngle) < _dipWidth || Math.Abs(angle - _dipAngle + 2*MathF.PI) < _dipWidth  || Math.Abs(angle - _dipAngle - 2*MathF.PI) < _dipWidth) {
                r1 = r2 = 0.2f;
            }
            return (length < r1 || (length > r1*IslandFactor && length < r2));
        }
        // alternative way, 3.36 times slower
        protected bool MyHitTest(Ray rayWS, ref List<HitTestResult> hits)
        {
            LineGeometry3D lineGeometry3D;
            Viewport3DX viewport;

            if (this.Visibility == Visibility.Collapsed ||
                this.IsHitTestVisible == false ||
                (viewport = FindVisualAncestor<Viewport3DX>(this.renderHost as DependencyObject)) == null ||
                (lineGeometry3D = this.Geometry as LineGeometry3D) == null)
            {
                return false;
            }

            var result = new HitTestResult { IsValid = false, Distance = double.MaxValue };
            var lastDist = double.MaxValue;
            var index = 0;
            foreach (var line in lineGeometry3D.Lines)
            {
                var t0 = Vector3.TransformCoordinate(line.P0, this.ModelMatrix);
                var t1 = Vector3.TransformCoordinate(line.P1, this.ModelMatrix);
                Vector3 sp, tp;
                float sc, tc;
                var distance = LineBuilder.GetRayToLineDistance(rayWS, t0, t1, out sp, out tp, out sc, out tc);
                var svpm = viewport.GetScreenViewProjectionMatrix();
                Vector4 sp4;
                Vector4 tp4;
                Vector3.Transform(ref sp, ref svpm, out sp4);
                Vector3.Transform(ref tp, ref svpm, out tp4);
                var sp3 = sp4.ToVector3();
                var tp3 = tp4.ToVector3();
                var tv2 = new Vector2(tp3.X - sp3.X, tp3.Y - sp3.Y);
                var dist = tv2.Length();
                if (dist < lastDist && dist <= this.HitTestThickness)
                {
                    lastDist = dist;
                    result.PointHit = sp.ToPoint3D();
                    result.NormalAtHit = (sp - tp).ToVector3D(); // not normalized to get length
                    result.Distance = distance;
                    result.ModelHit = this;
                    result.IsValid = true;
                    result.Tag = index; // ToDo: LineHitTag with additional info
                }

                index++;
            }

            if (result.IsValid)
            {
                hits.Add(result);
            }

            return result.IsValid;
        }
示例#8
0
 public LinearSpring(Body body1, Vector2 attachPoint1, Body body2, Vector2 attachPoint2, float springConstant,
                     float dampingConstant)
 {
     _body1 = body1;
     _body2 = body2;
     _attachPoint1 = attachPoint1;
     _attachPoint2 = attachPoint2;
     SpringConstant = springConstant;
     DampingConstant = dampingConstant;
     _difference = body2.GetWorldPosition(attachPoint2) - body1.GetWorldPosition(attachPoint1);
     _restLength = _difference.Length();
 }
示例#9
0
        public Missile(ContentManager content, Vector3 moveVector, Vector3 position)
        {
            model = XNAUtils.LoadModelWithBoundingSphere(ref transforms, ResourceNames.Missile, content);

            moveVector.Normalize();
            Vector2 ZX = new Vector2(moveVector.Z, moveVector.X);

            rotation = Quaternion.Identity;
            float horizontalAngle = (float)Math.Asin(moveVector.X / ZX.Length());
            if (moveVector.Z < 0)
                horizontalAngle = MathHelper.Pi - horizontalAngle;
            rotation *= Quaternion.CreateFromAxisAngle(Vector3.Up, horizontalAngle + MathHelper.PiOver2);
            float verticalAngle = (float)Math.Asin(moveVector.Y / moveVector.Length());
            rotation *= Quaternion.CreateFromAxisAngle(Vector3.Forward, verticalAngle);
            this.scale = 0.1f;
            this.moveVector = moveVector;
            this.position = position;
        }
示例#10
0
        public override void AI()
        {
            Player      player    = Main.player[projectile.owner];
            FargoPlayer modPlayer = player.GetModPlayer <FargoPlayer>();

            if (player.dead)
            {
                modPlayer.BigBrainMinion = false;
            }
            if (modPlayer.BigBrainMinion)
            {
                projectile.timeLeft = 2;
            }

            projectile.frameCounter++;
            if (projectile.frameCounter >= 8)
            {
                projectile.frameCounter = 0;
                projectile.frame        = (projectile.frame + 1) % 12;
            }

            projectile.ai[0] += 0.4f;
            projectile.alpha  = (int)(Math.Cos(projectile.ai[0] * MathHelper.TwoPi / 180) * 60) + 60;

            if (projectile.minionSlots <= 6) //projectile scale increases with minion slots consumed, caps at 6 slots
            {
                projectile.scale = 0.75f + projectile.minionSlots / 12;
            }
            else
            {
                projectile.scale = 1.25f;
            }

            bool targetting            = false; //targetting code, prioritize targetted npcs, then look for closest if none is found
            NPC  targetnpc             = null;
            NPC  minionAttackTargetNpc = projectile.OwnerMinionAttackTargetNPC;

            if (minionAttackTargetNpc != null && minionAttackTargetNpc.CanBeChasedBy((object)this, false))
            {
                Vector2 distancetotarget = minionAttackTargetNpc.Center - projectile.Center;
                if (distancetotarget.Length() < 1500)
                {
                    targetnpc  = minionAttackTargetNpc;
                    targetting = true;
                }
            }
            else if (!targetting)
            {
                float distancemax = 1500;
                for (int index = 0; index < 200; ++index)
                {
                    if (Main.npc[index].CanBeChasedBy((object)this, false))
                    {
                        Vector2 distancetotarget = Main.npc[index].Center - projectile.Center;
                        if (distancetotarget.Length() < distancemax)
                        {
                            distancemax = distancetotarget.Length();
                            targetnpc   = Main.npc[index];
                            targetting  = true;
                        }
                    }
                }
            }

            if (targetting)
            {
                projectile.localAI[0]++;
                if (projectile.localAI[0] > 7)
                {
                    Vector2 spawnpos = targetnpc.Center + Main.rand.NextVector2CircularEdge(150, 150);
                    Main.PlaySound(SoundID.Item, (int)spawnpos.X, (int)spawnpos.Y, 104, 0.5f, -0.2f);
                    Vector2 totarget = Vector2.Normalize(targetnpc.Center - spawnpos);
                    int     p        = Projectile.NewProjectile(spawnpos, totarget * 12, mod.ProjectileType("BigBrainIllusion"), (int)(projectile.damage * projectile.scale), projectile.knockBack, projectile.owner); //damage directly proportional to projectile scale, change later???
                    if (p < 1000)
                    {
                        Main.projectile[p].scale     = projectile.scale * 0.75f;
                        Main.projectile[p].netUpdate = true; //sync because randomized spawn position
                    }
                    projectile.localAI[0] = 0;
                }
            }

            projectile.Center = player.Center + new Vector2(0, (200 + projectile.alpha) * projectile.scale).RotatedBy(projectile.ai[1] + projectile.ai[0] / MathHelper.TwoPi);
        }
示例#11
0
 public void Update()
 {
   if (this.Cue == null)
     return;
   if (this.PauseViewTransitions)
   {
     if (this.Cue.State == SoundState.Paused && this.CameraManager.ViewTransitionReached && this.pausedForViewTransition)
     {
       this.pausedForViewTransition = false;
       this.Cue.Resume();
     }
     else if (this.Cue.State == SoundState.Playing && !this.CameraManager.ViewTransitionReached)
     {
       this.pausedForViewTransition = true;
       this.Cue.Pause();
     }
   }
   if (this.Cue.State == SoundState.Paused || this.EngineState.InMap && !this.OverrideMap)
     return;
   if (this.position.HasValue)
   {
     Vector3 right = this.CameraManager.InverseView.Right;
     Vector3 interpolatedCenter = this.CameraManager.InterpolatedCenter;
     Vector2 vector2 = new Vector2()
     {
       X = FezMath.Dot(this.Position - interpolatedCenter, right),
       Y = interpolatedCenter.Y - this.Position.Y
     };
     float num1 = 1f;
     if (!this.NoAttenuation)
     {
       float num2 = vector2.Length();
       num1 = (double) num2 > 10.0 ? (float) (0.600000023841858 / (((double) num2 - 10.0) / 5.0 + 1.0)) : (float) (1.0 - (double) Easing.EaseIn((double) num2 / 10.0, EasingType.Quadratic) * 0.400000005960464);
     }
     this.NonFactorizedVolume = num1;
     this.Cue.Volume = FezMath.Saturate(this.NonFactorizedVolume * this.VolumeFactor * this.VolumeLevel * this.VolumeMaster);
     this.Cue.Pan = MathHelper.Clamp((float) ((double) vector2.X / (double) this.SM.LimitDistance.X * 1.5), -1f, 1f);
   }
   else
   {
     this.Cue.Volume = FezMath.Saturate(this.VolumeFactor * this.VolumeLevel * this.VolumeMaster);
     this.Cue.Pan = this.Pan;
   }
 }
	protected virtual void OnUpdateMove(List<Player> players, int tiles) {
		int x = (int)(pos.X/16), y = (int)(pos.Y/16);
		if (IsTileSolid(x,y)) killMe = true;
		
		float speedMod = 1f;
		Tile tile = Main.tile[(int)(pos.X/16),(int)(pos.Y/16)];
		if (tile == null) return;
		if (tile.liquid > 0 && pos.Y > pos.Y/16+1-1f/tile.liquid) speedMod *= .5f;
		
		int iSpeed = (int)(200*speed);
		if (posList.Count == iSpeed) posList.RemoveAt(0);
		posList.Add(new Vector2(pos.X,pos.Y));
		if (posList.Count == iSpeed) {
			Vector2 diff = new Vector2();
			foreach (Vector2 oldPos in posList) {
				diff.X += pos.X-oldPos.X;
				diff.Y += pos.Y-oldPos.Y;
			}
			diff /= 1f*iSpeed;
			if (diff.Length() < speed*speedMod*8f) killMe = true;
		}
		
		int[] yys = new int[tiles+1];
		for (int xx = 0; xx <= tiles; xx++) yys[xx] = FindTileBelow(x+xx*dir,y);
		
		int yMin = -1;
		foreach (int yy in yys) if (yy != -1) if (yMin == -1 || yy < yMin) yMin = yy;
		if (yMin != -1) while (y-yMin > tiles/2f) yMin++;
		Vector2 target = yMin == -1 ? new Vector2(-1,-1) : new Vector2(pos.X+speed*dir,yMin*16+8-height*16f);
		
		if (!HandleLife(players)) return;
		
		if (target.X < 0 || target.Y < 0) {
			pos += vel*speedMod;
		} else {
			Vector2 move = Vector(speed*speedMod/32f,Direction(pos,target));
			vel += move;
			if (vel.Length() > speed*speedMod) vel *= speed*speedMod/vel.Length();
			
			Vector2 toMove = new Vector2(vel.X,vel.Y);
			Vector2 lastTile = new Vector2((int)(pos.X/16f),(int)(pos.Y/16f));
			Vector2 moveTo, newTile, pos2;
			while (toMove.X != 0 || toMove.Y != 0) {
				if (toMove.X != 0) {
					float xx = Math.Abs(toMove.X) <= 1 ? toMove.X : Math.Sign(toMove.X);
					toMove.X -= xx;
					
					pos2 = GetDrawPos();
					moveTo = new Vector2(pos2.X+xx,pos2.Y);
					newTile = new Vector2((int)(moveTo.X/16f),(int)(moveTo.Y/16f));
					if (lastTile.X != newTile.X) {
						lastTile = newTile;
						if (IsTileSolid((int)(moveTo.X/16f),(int)(moveTo.Y/16f))) {
							xx *= -1;
							vel.X *= -1;
							toMove.X *= -1;
							dir *= -1;
							
							int c = posList.Count/2;
							while (c-- > 0) posList.RemoveAt(0);
						}
					}
					pos.X += xx;
				}
				if (toMove.Y != 0) {
					float yy = Math.Abs(toMove.Y) <= 1 ? toMove.Y : Math.Sign(toMove.Y);
					toMove.Y -= yy;
					
					pos2 = GetDrawPos();
					moveTo = new Vector2(pos2.X,pos2.Y+yy);
					newTile = new Vector2((int)(moveTo.X/16f),(int)(moveTo.Y/16f));
					if (lastTile.Y != newTile.Y) {
						lastTile = newTile;
						if (IsTileSolid((int)(moveTo.X/16f),(int)(moveTo.Y/16f))) {
							yy *= -1;
							vel.Y *= -1;
							toMove.Y *= -1;
						}
					}
					pos.Y += yy;
				}
			}
		}
	}
示例#13
0
        protected override EnvShooter.Action GetAction()
        {
            color = Color.Orange;

            action.right  = action.left = action.up = action.down = false;
            action.charge = false;

            if (Keyboard.GetState().IsKeyDown(Keys.E))
            {
            }

            #region determine state

            #region gather bullet data

            Vector2 dist;

            Vector2 distToEnemy = enemies[0].Pos - Pos;
            float   dToEnemy    = distToEnemy.Length();

            Nearest <Bullet> nearestFriendlyBullet  = new Nearest <Bullet>();
            Nearest <Bullet> nearestEvilBullet      = new Nearest <Bullet>();
            Nearest <Bullet> nearestEvilBulletFocus = new Nearest <Bullet>();

            for (int i = 0; i < env.Bullets.Length; i++)
            {
                dist = env.Bullets[i].Pos - Pos;
                float d = dist.Length();
                if (env.Bullets[i].Collectible)
                {
                    //float danger = Raycast(env.Bullets[i].Pos, env.Bullets[i].Velocity);

                    nearestFriendlyBullet.SetIfNearer(d, env.Bullets[i]);
                }
                else
                {
                    float maxFriendlyBulletSpeed = 0.3f;

                    if (d < EnvShooter.Bot.RADIUS + Bullet.RADIUS + SPEED * 2f)
                    {
                        nearestEvilBullet.SetIfNearer(d, env.Bullets[i]);
                    }
                    else if (d > 3f && env.Bullets[i].Velocity.Length() < maxFriendlyBulletSpeed) // 0.1f is neutralize speed
                    {
                        float v = env.Bullets[i].Velocity.Length();
                        v -= 0.1f;
                        v /= maxFriendlyBulletSpeed - 0.1f;

                        nearestFriendlyBullet.SetIfNearer(d * (1f + v), env.Bullets[i]);
                    }
                    if (d < dangerDist)
                    {
                        float dot = Vector2.Dot(-Vector2.Normalize(env.Bullets[i].Pos - Vector2.Normalize(env.Bullets[i].Velocity) * 1f - Pos), env.Bullets[i].Velocity);
                        if (dot > 0f)
                        {
                            float projection = Vector2.Dot(dist, Vector2.Normalize(new Vector2(-env.Bullets[i].Velocity.Y, env.Bullets[i].Velocity.X)));

                            if (Math.Abs(projection) < RADIUS + Bullet.RADIUS + 0.1f * 2f) // check if it will hit eventually (also consider, that he will move in this direction (*2f)
                            {
                                //color = Color.Red;

                                nearestEvilBulletFocus.SetIfNearer(d, env.Bullets[i]);
                            }
                        }
                    }
                }
            }

            #endregion



            State s = state;

            if (nearestEvilBulletFocus.Available() || nearestEvilBullet.Available())// if attacking bullet near
            {
                state = State.EvadeBullet;
            }
            else if (enemies[0].Charge > 0 && dToEnemy < dangerDist && Charge < 1f && (Health <0.5f || enemies[0].Health> 0.25f)) // && dToEnemy - RADIUS * 1.5f < (1f - enemies[0].Charge) / EnvShooter.Bot.CHARGESPEED * SPEED * 0.75f)
            {
                if (dToEnemy - RADIUS * 1.5f < (1f - enemies[0].Charge) / EnvShooter.Bot.CHARGESPEED * SPEED * 0.75f)             // 0.75f because he can only walk in 8 directions
                {
                    state = State.FleeInsideEnemy;
                }
                else
                {
                    state = State.Flee;
                }
            }
            else if (nearestFriendlyBullet.Available() && nearestFriendlyBullet.dist < dToEnemy * 0.5f) // bullet to collect near
            {
                state = State.CollectBullets;
            }
            else if (enemies[0].Ammo == 0 && Ammo > 0)
            {
                state = State.TerrorizeNoob;
            }
            else if (Ammo == 0 && enemies[0].Ammo > 0)
            {
                state = State.Flee;
            }
            else if (Ammo > 0)
            {
                state = State.Attack;
            }
            else if (nearestFriendlyBullet.Available())
            {
                state = State.CollectBullets;
            }
            else
            {
                state = State.Flee;
            }

            //if (s != state)
            //    Console.WriteLine(env.Frame + " " + state);

            #endregion

            #region general

            if (dToEnemy < chargeDist)
            {
                if (enemies[0].Charge == 0 || Charge > 0.2f) // only charge if you already started, or if your enemy isn't charging
                {
                    action.charge = true;
                }
                float distFraction = 0.75f;
                if (enemies[0].Charge >= 1f)
                {
                    distFraction = 0.9f;
                }
                else if (enemies[0].Charge > 0f)
                {
                    distFraction = 1f;
                }
                if (Charge >= 1f && dToEnemy < chargeDist * distFraction && OutsideOfEnemy(dToEnemy - 0.5f)) // 0.5f for shooting distance
                {
                    action.charge = false;
                }
            }

            #endregion

            switch (state)
            {
            case State.EvadeBullet:

                if (nearestEvilBulletFocus.Available())
                {
                    dist = nearestEvilBulletFocus.obj.Pos - Pos;
                    Vector2 evade     = new Vector2(-dist.Y, dist.X);
                    Vector2 nVelocity = new Vector2(-nearestEvilBulletFocus.obj.Velocity.Y, nearestEvilBulletFocus.obj.Velocity.X);
                    if (Vector2.Dot(nVelocity, dist) < 0)
                    {
                        evade = -evade;
                    }

                    VelocityToAction(ref action, evade);

                    // stop charging in order to evade
                    if (action.charge && (Charge > 0.7f || Charge < 0.2f))
                    {
                        action.charge = false;
                    }
                }
                else
                {
                    VelocityToAction(ref action, Pos - nearestEvilBullet.obj.Pos);
                }

                break;

            case State.CollectBullets:

                VelocityToAction(ref action, nearestFriendlyBullet.obj.Pos - Pos);

                break;

            case State.TerrorizeNoob:

                if (OutsideOfEnemy(dToEnemy - 1f))
                {
                    VelocityToAction(ref action, distToEnemy);
                }
                else
                {
                    VelocityToAction(ref action, -distToEnemy);
                }


                break;

            case State.FleeInsideEnemy:
                VelocityToActionExact(ref action, distToEnemy);
                break;

            case State.Flee:

                Vector2 center = new Vector2(env.Width, env.Height) / 2f;

                float distToCenter = Vector2.Distance(center, Pos);

                distToCenter /= env.Width / 2f - 1f - RADIUS;     // 0 - 1 (max distance to center in x OR y direction)

                if (distToCenter > 0.9f)
                {
                    //TODO: check in which direction to go
                    Vector2 a = Pos - center;
                    Vector2 b = enemies[0].Pos - center;
                    b = new Vector2(-b.Y, b.X);
                    a.Normalize();
                    b.Normalize();

                    float dot = Vector2.Dot(a, b);
                    if (Math.Abs(dot) > 0.01f)
                    {
                        if (dot < 0f)
                        {
                            VelocityToAction(ref action, new Vector2(-distToEnemy.Y, distToEnemy.X));
                        }
                        else
                        {
                            VelocityToAction(ref action, new Vector2(distToEnemy.Y, -distToEnemy.X));
                        }
                    }
                }
                else
                {
                    VelocityToAction(ref action, -distToEnemy);
                }

                break;

            case State.Attack:

                if (dToEnemy > chargeDist * 0.7f)
                {
                    VelocityToAction(ref action, distToEnemy);
                }
                else
                {
                    VelocityToAction(ref action, -distToEnemy);
                }

                break;
            }

            if (!action.charge)
            {
                action.aim = (float)Math.Atan2(distToEnemy.Y, distToEnemy.X);

                float definitiveDistMax = chargeDist * 0.5f;

                if (dToEnemy < definitiveDistMax)
                {
                    Vector2 enemyBorderDist = enemies[0].Pos + Vector2.Normalize(new Vector2(-distToEnemy.Y, distToEnemy.X)) * EnvShooter.Bot.RADIUS;
                    enemyBorderDist = enemyBorderDist - Pos;

                    float maxAngle   = (float)Math.Atan2(enemyBorderDist.Y, enemyBorderDist.X);
                    float angleDist1 = action.aim - maxAngle;
                    float angleDist2 = action.aim + MathHelper.TwoPi;
                    if (Math.Abs(angleDist2) < Math.Abs(angleDist1))
                    {
                        angleDist1 = angleDist2;
                    }

                    angleDist1 *= 0.8f; // just in case the evasion of the enemy is very good

                    float min = RADIUS + Bullet.RADIUS + 0.5f + 0.5f;
                    float max = definitiveDistMax;

                    float d = dToEnemy;
                    d -= min;
                    d /= max - min;

                    action.aim += angleDist1 * (1f - d);//(float)Math.Pow((1f - (dToEnemy / definitiveDistMax)) * 2f, 0.5f) * angleDist1;
                }
            }


            if (!action.charge && Charge == 0f && rand.Next(60 * 5) == 0)
            {
                action.charge = true;
            }

            //Loop

            //action.right = action.left = action.up = action.down = false;

            //float border = 1f / 4f;

            //bool wall = false;
            //if (Pos.X < env.Width * border)
            //    action.right = true;
            //if (Pos.X > env.Width * (1 - border))
            //    action.left = true;
            //if (Pos.Y < env.Height * border)
            //    action.down = true;
            //if (Pos.Y > env.Height * (1 - border))
            //    action.up = true;

            //if (action.right || action.left || action.up || action.down)
            //    wall = true;

            //Vector2 enemyPos = enemies[0].Pos;

            //Vector2 dist = enemyPos - Pos;



            //if (enemies.Any(f => f.Ammo == 0) || Vector2.Distance(enemies[0].Pos, Pos) < 6f || env.Frame > 5 * 60 )
            //{
            //    action.charge = true;
            //}

            //if (Charge >= 1f)
            //{
            //    if (rand.Next(300) == 0 || enemies[0].Charge > 0 || Vector2.Distance(enemies[0].Pos, Pos) < 5f)
            //        action.charge = false;
            //}

            //Bullet nearestFriendly = null;
            //float nearestFriendlyDist = -1f;
            //Bullet nearestEnemy = null;
            //float nearestEnemyDist = -1f;
            //bool bulletEvasion = false;
            //bool anyFriendly = env.Bullets.Any(f => f.Collectible);

            //for (int i = 0; i < env.Bullets.Length; i++)
            //{
            //    dist = env.Bullets[i].Pos - Pos;
            //    float d = dist.Length();
            //    if (nearestFriendlyDist != -2 && env.Bullets[i].Collectible)
            //    {
            //        float danger = Raycast(env.Bullets[i].Pos, env.Bullets[i].Velocity);

            //        if (nearestFriendlyDist == -1f || danger > nearestFriendlyDist)//d < nearestFriendlyDist)
            //        {
            //            nearestFriendlyDist = d;
            //            nearestFriendly = env.Bullets[i];
            //        }
            //    }
            //    else
            //    {
            //        //if (d < 1f)
            //        if (d < 2f)
            //        {
            //            if (nearestEnemyDist == -1f || d < nearestEnemyDist)
            //            {
            //                nearestEnemyDist = d;
            //                nearestEnemy = env.Bullets[i];
            //            }
            //        }
            //        else if (!anyFriendly && d > 3f)
            //        {
            //            if (nearestFriendlyDist == -1f || d < nearestFriendlyDist)
            //            {
            //                nearestFriendlyDist = d;
            //                nearestFriendly = env.Bullets[i];
            //            }
            //        }


            //        if (Vector2.Dot(-dist, env.Bullets[i].Velocity) > 1)
            //        {
            //            nearestFriendlyDist = -2f;
            //            nearestFriendly = null;
            //            Vector2 evade = new Vector2(-dist.Y, dist.X);
            //            Vector2 nVelocity = new Vector2(-env.Bullets[i].Velocity.Y, env.Bullets[i].Velocity.X);

            //            if (Vector2.Dot(nVelocity, dist) < 0)
            //                evade = -evade;

            //            VelocityToAction(ref action, evade);
            //            bulletEvasion = true;

            //            if (Charge > 0.7f)
            //                action.charge = false;
            //            break;
            //        }
            //    }
            //}

            //bool wallSlide = false;

            //if (!bulletEvasion && env.Bullets.Length == 0 && Ammo == 0)
            //{
            //    // emergency mode! -> evasion extreme
            //    action.left = action.right = action.up = action.down = false;


            //    if (Pos.X < env.Width * border)
            //        action.right = true;
            //    if (Pos.X > env.Width * (1 - border))
            //        action.left = true;
            //    if (Pos.Y < env.Height * border)
            //        action.down = true;
            //    if (Pos.Y > env.Height * (1 - border))
            //        action.up = true;

            //    bool u = action.up;
            //    action.up = action.right;
            //    action.right = action.down;
            //    action.down = action.left;
            //    action.left = u;

            //    Vector2 dir = new Vector2(action.up ? -1f : action.down ? 1f : 0, action.right ? 1f : action.left ? -1f : 0f);

            //    if (rand.Next(60) == 0 && reverseDir != Vector2.Dot(dir, enemies[0].Pos - Pos) > 0f)
            //        reverseDir = !reverseDir;

            //        if (reverseDir)
            //    {
            //        bool a = action.up;
            //        action.up = action.down;
            //        action.down = a;

            //        a = action.right;
            //        action.right = action.left;
            //        action.left = a;
            //    }

            //    /*
            //    if (action.right)
            //    {


            //        if (action.up)
            //            action.left = true;
            //        else
            //            action.up = true;
            //    }

            //    if (Pos.Y > env.Height * (1 - border))
            //        action.right = true;
            //    else if (Pos.Y < env.Height * border)
            //        action.left = true;
            //    else if (Pos.X > env.Width * (1 - border))
            //        action.up = true;
            //    else if (Pos.X < env.Width * border)
            //        action.down = true;*/


            //    if (action.right || action.left || action.up || action.down)
            //        wallSlide = true;
            //}

            //if (!wallSlide)
            //{
            //    float noobDist = -1f;

            //    if (!bulletEvasion)
            //    {
            //        EnvShooter.Bot nearestBot = null;
            //        EnvShooter.Bot nearestNoob = null;
            //        float botDist = -1f;
            //        for (int i = 0; i < enemies.Length; i++)
            //        {
            //            float d = (Pos - enemies[i].Pos).Length();

            //            if (enemies[i].Ammo > 0)
            //            {
            //                if ((d < 10f || (enemies[i].Charge > 0 && d < 15f)) && (botDist == -1f || d < botDist))
            //                {
            //                    nearestBot = enemies[i];
            //                    botDist = d;
            //                }
            //            }
            //            else if (Ammo > 0)
            //            {
            //                //// aggro
            //                //if (noobDist == -1f || (d < noobDist && d > 2f))
            //                //{
            //                //    noobDist = d;
            //                //    nearestNoob = enemies[i];
            //                //}
            //            }
            //        }

            //        if (nearestBot != null)
            //        {
            //            VelocityToAction(ref action, Pos - nearestBot.Pos);


            //        }
            //        else if (nearestNoob != null)
            //        {
            //            VelocityToAction(ref action, nearestNoob.Pos - Pos);
            //        }
            //    }

            //    // collect bullets
            //    if (noobDist == -1f && nearestFriendly != null)
            //    {
            //        dist = nearestFriendly.Pos - Pos;

            //        VelocityToAction(ref action, dist);
            //    }
            //}



            //if (!bulletEvasion && nearestEnemy != null)
            //{
            //    VelocityToAction(ref action, Pos - nearestEnemy.Pos);
            //}


            return(action);
        }
示例#14
0
        public static void RotateVector(ref Vector2 vector, float radians)
        {
            float length = vector.Length();
            float newRadians = (float)Math.Atan2(vector.X, -(double)vector.Y) + radians;

            vector.X = (float)Math.Sin(newRadians) * length;
            vector.Y = -(float)Math.Cos(newRadians) * length;
        }
示例#15
0
文件: ColSquare.cs 项目: Milun/VWA
        public override Vector2 CheckColCircle(ColCircle other)
        {
            if (CheckColBounds(other))
            {
                if (other.Center.X > this.TL.X &&
                    other.Center.X < this.BR.X)
                {
                    if (other.Center.Y > this.Center.Y)
                    {
                        return(new Vector2(0.0f, other.Center.Y - other.Rad - this.TL.Y));
                    }
                    if (other.Center.Y < this.Center.Y)
                    {
                        return(new Vector2(0.0f, other.Center.Y + other.Rad - this.BR.Y));
                    }
                }
                if (other.Center.Y < this.BR.Y + leeway && other.Center.Y > this.TL.Y - leeway)
                {
                    if (other.Center.X > this.Center.X)
                    {
                        return(new Vector2(other.Center.X - other.Rad - this.TL.X, 0.0f));
                    }
                    if (other.Center.X < this.Center.X)
                    {
                        return(new Vector2(other.Center.X + other.Rad - this.BR.X, 0.0f));
                    }
                }

                Vector2 dist;
                dist = new Vector2(TL.X + leeway, BR.Y + leeway) - other.Center;
                float mag = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }

                dist = new Vector2(BR.X - leeway, BR.Y + leeway) - other.Center;
                mag  = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }

                dist = new Vector2(TL.X + leeway, TL.Y - leeway) - other.Center;
                mag  = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }

                dist = new Vector2(BR.X - leeway, TL.Y - leeway) - other.Center;
                mag  = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }
            }

            return(Vector2.Zero);
        }
示例#16
0
 static public float Cos(Vector2 u, Vector2 v)
 {
     return((u.X * v.X + u.Y * v.Y) / (u.Length() * v.Length()));
 }
示例#17
0
        internal override void InitVelocityConstraints(ref TimeStep step)
        {
            Body b1 = _bodyA;
            Body b2 = _bodyB;

            XForm xf1, xf2;
            b1.GetXForm(out xf1);
            b2.GetXForm(out xf2);

            Vector2 r1 = MathUtils.Multiply(ref xf1.R, _localAnchor1 - b1.GetLocalCenter());
            Vector2 r2 = MathUtils.Multiply(ref xf2.R, _localAnchor2 - b2.GetLocalCenter());

            Vector2 p1 = b1._sweep.c + r1;
            Vector2 p2 = b2._sweep.c + r2;

            Vector2 s1 = _groundAnchor1;
            Vector2 s2 = _groundAnchor2;

            // Get the pulley axes.
            _u1 = p1 - s1;
            _u2 = p2 - s2;

            float length1 = _u1.Length();
            float length2 = _u2.Length();

            if (length1 > Settings.b2_linearSlop)
            {
                _u1 *= 1.0f / length1;
            }
            else
            {
                _u1 = Vector2.Zero;
            }

            if (length2 > Settings.b2_linearSlop)
            {
                _u2 *= 1.0f / length2;
            }
            else
            {
                _u2 = Vector2.Zero;
            }

            float C = _ant - length1 - _ratio * length2;
            if (C > 0.0f)
            {
                _state = LimitState.Inactive;
                _impulse = 0.0f;
            }
            else
            {
                _state = LimitState.AtUpper;
            }

            if (length1 < _maxLength1)
            {
                _limitState1 = LimitState.Inactive;
                _limitImpulse1 = 0.0f;
            }
            else
            {
                _limitState1 = LimitState.AtUpper;
            }

            if (length2 < _maxLength2)
            {
                _limitState2 = LimitState.Inactive;
                _limitImpulse2 = 0.0f;
            }
            else
            {
                _limitState2 = LimitState.AtUpper;
            }

            // Compute effective mass.
            float cr1u1 = MathUtils.Cross(r1, _u1);
            float cr2u2 = MathUtils.Cross(r2, _u2);

            _limitMass1 = b1._invMass + b1._invI * cr1u1 * cr1u1;
            _limitMass2 = b2._invMass + b2._invI * cr2u2 * cr2u2;
            _pulleyMass = _limitMass1 + _ratio * _ratio * _limitMass2;
            Debug.Assert(_limitMass1 > Settings.b2_FLT_EPSILON);
            Debug.Assert(_limitMass2 > Settings.b2_FLT_EPSILON);
            Debug.Assert(_pulleyMass > Settings.b2_FLT_EPSILON);
            _limitMass1 = 1.0f / _limitMass1;
            _limitMass2 = 1.0f / _limitMass2;
            _pulleyMass = 1.0f / _pulleyMass;

            if (step.warmStarting)
            {
                // Scale impulses to support variable time steps.
                _impulse *= step.dtRatio;
                _limitImpulse1 *= step.dtRatio;
                _limitImpulse2 *= step.dtRatio;

                // Warm starting.
                Vector2 P1 = -(_impulse + _limitImpulse1) * _u1;
                Vector2 P2 = (-_ratio * _impulse - _limitImpulse2) * _u2;
                b1._linearVelocity += b1._invMass * P1;
                b1._angularVelocity += b1._invI * MathUtils.Cross(r1, P1);
                b2._linearVelocity += b2._invMass * P2;
                b2._angularVelocity += b2._invI * MathUtils.Cross(r2, P2);
            }
            else
            {
                _impulse = 0.0f;
                _limitImpulse1 = 0.0f;
                _limitImpulse2 = 0.0f;
            }
        }
示例#18
0
        internal override void InitVelocityConstraints(ref TimeStep step)
        {
            Body b1 = BodyA;
            Body b2 = BodyB;

            Transform xf1, xf2;

            b1.GetTransform(out xf1);
            b2.GetTransform(out xf2);

            Vector2 r1 = MathUtils.Multiply(ref xf1.R, LocalAnchorA - b1.LocalCenter);
            Vector2 r2 = MathUtils.Multiply(ref xf2.R, LocalAnchorB - b2.LocalCenter);

            Vector2 p1 = b1.Sweep.C + r1;
            Vector2 p2 = b2.Sweep.C + r2;

            Vector2 s1 = GroundAnchorA;
            Vector2 s2 = GroundAnchorB;

            // Get the pulley axes.
            _u1 = p1 - s1;
            _u2 = p2 - s2;

            float length1 = _u1.Length();
            float length2 = _u2.Length();

            if (length1 > Settings.LinearSlop)
            {
                _u1 *= 1.0f / length1;
            }
            else
            {
                _u1 = Vector2.Zero;
            }

            if (length2 > Settings.LinearSlop)
            {
                _u2 *= 1.0f / length2;
            }
            else
            {
                _u2 = Vector2.Zero;
            }

            float C = _ant - length1 - Ratio * length2;

            if (C > 0.0f)
            {
                _state   = LimitState.Inactive;
                _impulse = 0.0f;
            }
            else
            {
                _state = LimitState.AtUpper;
            }

            if (length1 < MaxLengthA)
            {
                _limitState1   = LimitState.Inactive;
                _limitImpulse1 = 0.0f;
            }
            else
            {
                _limitState1 = LimitState.AtUpper;
            }

            if (length2 < MaxLengthB)
            {
                _limitState2   = LimitState.Inactive;
                _limitImpulse2 = 0.0f;
            }
            else
            {
                _limitState2 = LimitState.AtUpper;
            }

            // Compute effective mass.
            float cr1u1 = MathUtils.Cross(r1, _u1);
            float cr2u2 = MathUtils.Cross(r2, _u2);

            _limitMass1 = b1.InvMass + b1.InvI * cr1u1 * cr1u1;
            _limitMass2 = b2.InvMass + b2.InvI * cr2u2 * cr2u2;
            _pulleyMass = _limitMass1 + Ratio * Ratio * _limitMass2;
            Debug.Assert(_limitMass1 > Settings.Epsilon);
            Debug.Assert(_limitMass2 > Settings.Epsilon);
            Debug.Assert(_pulleyMass > Settings.Epsilon);
            _limitMass1 = 1.0f / _limitMass1;
            _limitMass2 = 1.0f / _limitMass2;
            _pulleyMass = 1.0f / _pulleyMass;

            if (Settings.EnableWarmstarting)
            {
                // Scale impulses to support variable time steps.
                _impulse       *= step.dtRatio;
                _limitImpulse1 *= step.dtRatio;
                _limitImpulse2 *= step.dtRatio;

                // Warm starting.
                Vector2 P1 = -(_impulse + _limitImpulse1) * _u1;
                Vector2 P2 = (-Ratio * _impulse - _limitImpulse2) * _u2;
                b1.LinearVelocityInternal  += b1.InvMass * P1;
                b1.AngularVelocityInternal += b1.InvI * MathUtils.Cross(r1, P1);
                b2.LinearVelocityInternal  += b2.InvMass * P2;
                b2.AngularVelocityInternal += b2.InvI * MathUtils.Cross(r2, P2);
            }
            else
            {
                _impulse       = 0.0f;
                _limitImpulse1 = 0.0f;
                _limitImpulse2 = 0.0f;
            }
        }
示例#19
0
        internal override bool SolvePositionConstraints()
        {
            Body b1 = BodyA;
            Body b2 = BodyB;

            Vector2 s1 = GroundAnchorA;
            Vector2 s2 = GroundAnchorB;

            float linearError = 0.0f;

            if (_state == LimitState.AtUpper)
            {
                Transform xf1, xf2;
                b1.GetTransform(out xf1);
                b2.GetTransform(out xf2);

                Vector2 r1 = MathUtils.Multiply(ref xf1.R, LocalAnchorA - b1.LocalCenter);
                Vector2 r2 = MathUtils.Multiply(ref xf2.R, LocalAnchorB - b2.LocalCenter);

                Vector2 p1 = b1.Sweep.C + r1;
                Vector2 p2 = b2.Sweep.C + r2;

                // Get the pulley axes.
                _u1 = p1 - s1;
                _u2 = p2 - s2;

                float length1 = _u1.Length();
                float length2 = _u2.Length();

                if (length1 > Settings.LinearSlop)
                {
                    _u1 *= 1.0f / length1;
                }
                else
                {
                    _u1 = Vector2.Zero;
                }

                if (length2 > Settings.LinearSlop)
                {
                    _u2 *= 1.0f / length2;
                }
                else
                {
                    _u2 = Vector2.Zero;
                }

                float C = _ant - length1 - Ratio * length2;
                linearError = Math.Max(linearError, -C);

                C = MathUtils.Clamp(C + Settings.LinearSlop, -Settings.MaxLinearCorrection, 0.0f);
                float impulse = -_pulleyMass * C;

                Vector2 P1 = -impulse * _u1;
                Vector2 P2 = -Ratio * impulse * _u2;

                b1.Sweep.C += b1.InvMass * P1;
                b1.Sweep.A += b1.InvI * MathUtils.Cross(r1, P1);
                b2.Sweep.C += b2.InvMass * P2;
                b2.Sweep.A += b2.InvI * MathUtils.Cross(r2, P2);

                b1.SynchronizeTransform();
                b2.SynchronizeTransform();
            }

            if (_limitState1 == LimitState.AtUpper)
            {
                Transform xf1;
                b1.GetTransform(out xf1);

                Vector2 r1 = MathUtils.Multiply(ref xf1.R, LocalAnchorA - b1.LocalCenter);
                Vector2 p1 = b1.Sweep.C + r1;

                _u1 = p1 - s1;
                float length1 = _u1.Length();

                if (length1 > Settings.LinearSlop)
                {
                    _u1 *= 1.0f / length1;
                }
                else
                {
                    _u1 = Vector2.Zero;
                }

                float C = MaxLengthA - length1;
                linearError = Math.Max(linearError, -C);
                C           = MathUtils.Clamp(C + Settings.LinearSlop, -Settings.MaxLinearCorrection, 0.0f);
                float impulse = -_limitMass1 * C;

                Vector2 P1 = -impulse * _u1;
                b1.Sweep.C += b1.InvMass * P1;
                b1.Sweep.A += b1.InvI * MathUtils.Cross(r1, P1);

                b1.SynchronizeTransform();
            }

            if (_limitState2 == LimitState.AtUpper)
            {
                Transform xf2;
                b2.GetTransform(out xf2);

                Vector2 r2 = MathUtils.Multiply(ref xf2.R, LocalAnchorB - b2.LocalCenter);
                Vector2 p2 = b2.Sweep.C + r2;

                _u2 = p2 - s2;
                float length2 = _u2.Length();

                if (length2 > Settings.LinearSlop)
                {
                    _u2 *= 1.0f / length2;
                }
                else
                {
                    _u2 = Vector2.Zero;
                }

                float C = MaxLengthB - length2;
                linearError = Math.Max(linearError, -C);
                C           = MathUtils.Clamp(C + Settings.LinearSlop, -Settings.MaxLinearCorrection, 0.0f);
                float impulse = -_limitMass2 * C;

                Vector2 P2 = -impulse * _u2;
                b2.Sweep.C += b2.InvMass * P2;
                b2.Sweep.A += b2.InvI * MathUtils.Cross(r2, P2);

                b2.SynchronizeTransform();
            }

            return(linearError < Settings.LinearSlop);
        }
示例#20
0
        void UpdateSineAnim(float deltaTime)
        {
            if (CurrentSwimParams == null)
            {
                return;
            }
            movement = TargetMovement;

            if (movement.LengthSquared() > 0.00001f)
            {
                Collider.LinearVelocity = Vector2.Lerp(Collider.LinearVelocity, movement, 0.5f);
            }

            //limbs are disabled when simple physics is enabled, no need to move them
            if (SimplePhysicsEnabled)
            {
                return;
            }

            MainLimb.PullJointEnabled = true;
            //MainLimb.PullJointWorldAnchorB = Collider.SimPosition;

            if (movement.LengthSquared() < 0.00001f)
            {
                WalkPos = MathHelper.SmoothStep(WalkPos, MathHelper.PiOver2, deltaTime * 5);
                MainLimb.PullJointWorldAnchorB = Collider.SimPosition;
                return;
            }

            Vector2 transformedMovement = reverse ? -movement : movement;
            float   movementAngle       = MathUtils.VectorToAngle(transformedMovement) - MathHelper.PiOver2;
            float   mainLimbAngle       = 0;

            if (MainLimb.type == LimbType.Torso && TorsoAngle.HasValue)
            {
                mainLimbAngle = TorsoAngle.Value;
            }
            else if (MainLimb.type == LimbType.Head && HeadAngle.HasValue)
            {
                mainLimbAngle = HeadAngle.Value;
            }
            mainLimbAngle *= Dir;
            while (MainLimb.Rotation - (movementAngle + mainLimbAngle) > MathHelper.Pi)
            {
                movementAngle += MathHelper.TwoPi;
            }
            while (MainLimb.Rotation - (movementAngle + mainLimbAngle) < -MathHelper.Pi)
            {
                movementAngle -= MathHelper.TwoPi;
            }

            if (CurrentSwimParams.RotateTowardsMovement)
            {
                Collider.SmoothRotate(movementAngle, CurrentSwimParams.SteerTorque);
                if (TorsoAngle.HasValue)
                {
                    Limb torso = GetLimb(LimbType.Torso);
                    if (torso != null)
                    {
                        SmoothRotateWithoutWrapping(torso, movementAngle + TorsoAngle.Value * Dir, MainLimb, TorsoTorque);
                    }
                }
                if (HeadAngle.HasValue)
                {
                    Limb head = GetLimb(LimbType.Head);
                    if (head != null)
                    {
                        SmoothRotateWithoutWrapping(head, movementAngle + HeadAngle.Value * Dir, MainLimb, HeadTorque);
                    }
                }
                if (TailAngle.HasValue)
                {
                    Limb tail = GetLimb(LimbType.Tail);
                    if (tail != null)
                    {
                        SmoothRotateWithoutWrapping(tail, movementAngle + TailAngle.Value * Dir, MainLimb, TailTorque);
                    }
                }
            }
            else
            {
                movementAngle = Dir > 0 ? -MathHelper.PiOver2 : MathHelper.PiOver2;
                if (reverse)
                {
                    movementAngle = MathUtils.WrapAngleTwoPi(movementAngle - MathHelper.Pi);
                }
                if (MainLimb.type == LimbType.Head && HeadAngle.HasValue)
                {
                    Collider.SmoothRotate(HeadAngle.Value * Dir, CurrentSwimParams.SteerTorque);
                }
                else if (MainLimb.type == LimbType.Torso && TorsoAngle.HasValue)
                {
                    Collider.SmoothRotate(TorsoAngle.Value * Dir, CurrentSwimParams.SteerTorque);
                }
                if (TorsoAngle.HasValue)
                {
                    Limb torso = GetLimb(LimbType.Torso);
                    torso?.body.SmoothRotate(TorsoAngle.Value * Dir, TorsoTorque);
                }
                if (HeadAngle.HasValue)
                {
                    Limb head = GetLimb(LimbType.Head);
                    head?.body.SmoothRotate(HeadAngle.Value * Dir, HeadTorque);
                }
                if (TailAngle.HasValue)
                {
                    Limb tail = GetLimb(LimbType.Tail);
                    tail?.body.SmoothRotate(TailAngle.Value * Dir, TailTorque);
                }
            }

            var waveLength    = Math.Abs(CurrentSwimParams.WaveLength * RagdollParams.JointScale);
            var waveAmplitude = Math.Abs(CurrentSwimParams.WaveAmplitude);

            if (waveLength > 0 && waveAmplitude > 0)
            {
                WalkPos -= transformedMovement.Length() / Math.Abs(waveLength);
                WalkPos  = MathUtils.WrapAngleTwoPi(WalkPos);
            }

            foreach (var limb in Limbs)
            {
                switch (limb.type)
                {
                case LimbType.LeftFoot:
                case LimbType.RightFoot:
                    if (CurrentSwimParams.FootAnglesInRadians.ContainsKey(limb.limbParams.ID))
                    {
                        SmoothRotateWithoutWrapping(limb, movementAngle + CurrentSwimParams.FootAnglesInRadians[limb.limbParams.ID] * Dir, MainLimb, FootTorque);
                    }
                    break;

                case LimbType.Tail:
                    if (waveLength > 0 && waveAmplitude > 0)
                    {
                        float waveRotation = (float)Math.Sin(WalkPos);
                        limb.body.ApplyTorque(waveRotation * limb.Mass * CurrentSwimParams.TailTorque * waveAmplitude);
                    }
                    break;
                }
            }

            for (int i = 0; i < Limbs.Length; i++)
            {
                if (Limbs[i].SteerForce <= 0.0f)
                {
                    continue;
                }

                Vector2 pullPos = Limbs[i].PullJointWorldAnchorA;
                Limbs[i].body.ApplyForce(movement * Limbs[i].SteerForce * Limbs[i].Mass, pullPos);
            }

            Vector2 mainLimbDiff = MainLimb.PullJointWorldAnchorB - MainLimb.SimPosition;

            if (CurrentSwimParams.UseSineMovement)
            {
                MainLimb.PullJointWorldAnchorB = Vector2.SmoothStep(
                    MainLimb.PullJointWorldAnchorB,
                    Collider.SimPosition,
                    mainLimbDiff.LengthSquared() > 10.0f ? 1.0f : (float)Math.Abs(Math.Sin(WalkPos)));
            }
            else
            {
                //MainLimb.PullJointWorldAnchorB = Collider.SimPosition;
                MainLimb.PullJointWorldAnchorB = Vector2.Lerp(
                    MainLimb.PullJointWorldAnchorB,
                    Collider.SimPosition,
                    mainLimbDiff.LengthSquared() > 10.0f ? 1.0f : 0.5f);
            }

            floorY = Limbs[0].SimPosition.Y;
        }
示例#21
0
        public override void DragCharacter(Character target, float deltaTime)
        {
            if (target == null)
            {
                return;
            }

            Limb mouthLimb = Array.Find(Limbs, l => l != null && l.MouthPos.HasValue);

            if (mouthLimb == null)
            {
                mouthLimb = GetLimb(LimbType.Head);
            }

            if (mouthLimb == null)
            {
                DebugConsole.ThrowError("Character \"" + character.SpeciesName + "\" failed to eat a target (a head or a limb with a mouthpos required)");
                return;
            }

            if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient)
            {
                //stop dragging if there's something between the pull limb and the target
                Vector2 sourceSimPos = mouthLimb.SimPosition;
                Vector2 targetSimPos = target.SimPosition;
                if (character.Submarine != null && character.SelectedCharacter.Submarine == null)
                {
                    targetSimPos -= character.Submarine.SimPosition;
                }
                else if (character.Submarine == null && character.SelectedCharacter.Submarine != null)
                {
                    sourceSimPos -= character.SelectedCharacter.Submarine.SimPosition;
                }
                var body = Submarine.CheckVisibility(sourceSimPos, targetSimPos, ignoreSubs: true);
                if (body != null)
                {
                    character.DeselectCharacter();
                    return;
                }
            }

            Character targetCharacter = target;
            float     eatSpeed        = character.Mass / targetCharacter.Mass * 0.1f;

            eatTimer += deltaTime * eatSpeed;

            Vector2 mouthPos          = GetMouthPosition().Value;
            Vector2 attackSimPosition = character.Submarine == null?ConvertUnits.ToSimUnits(target.WorldPosition) : target.SimPosition;

            Vector2 limbDiff = attackSimPosition - mouthPos;
            float   limbDist = limbDiff.Length();

            if (limbDist < 1.0f)
            {
                //pull the target character to the position of the mouth
                //(+ make the force fluctuate to waggle the character a bit)
                if (CanDrag(target))
                {
                    targetCharacter.AnimController.MainLimb.MoveToPos(mouthPos, (float)(Math.Sin(eatTimer) + 10.0f));
                    targetCharacter.AnimController.MainLimb.body.SmoothRotate(mouthLimb.Rotation, 20.0f);
                    targetCharacter.AnimController.Collider.MoveToPos(mouthPos, (float)(Math.Sin(eatTimer) + 10.0f));
                }

                //pull the character's mouth to the target character (again with a fluctuating force)
                float pullStrength = (float)(Math.Sin(eatTimer) * Math.Max(Math.Sin(eatTimer * 0.5f), 0.0f));
                mouthLimb.body.ApplyForce(limbDiff * mouthLimb.Mass * 50.0f * pullStrength, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);

                character.ApplyStatusEffects(ActionType.OnEating, deltaTime);

                if (eatTimer % 1.0f < 0.5f && (eatTimer - deltaTime * eatSpeed) % 1.0f > 0.5f)
                {
                    //apply damage to the target character to get some blood particles flying
                    targetCharacter.AnimController.MainLimb.AddDamage(targetCharacter.SimPosition, 0.0f, 20.0f, 0.0f, false);

                    //keep severing joints until there is only one limb left
                    LimbJoint[] nonSeveredJoints = Array.FindAll(targetCharacter.AnimController.LimbJoints,
                                                                 l => !l.IsSevered && l.CanBeSevered && l.LimbA != null && !l.LimbA.IsSevered && l.LimbB != null && !l.LimbB.IsSevered);
                    if (nonSeveredJoints.Length == 0)
                    {
                        //only one limb left, the character is now full eaten
                        Entity.Spawner?.AddToRemoveQueue(targetCharacter);
                        character.SelectedCharacter = null;
                    }
                    else //sever a random joint
                    {
                        targetCharacter.AnimController.SeverLimbJoint(nonSeveredJoints[Rand.Int(nonSeveredJoints.Length)]);
                    }
                }
            }
            else
            {
                character.SelectedCharacter = null;
            }
        }
示例#22
0
        public override void Attack(GameTime gameTime, Level level, bool attackButton, Vector2 direction)
        {
            base.Update(gameTime, level);
            if (Parent == null)
            {
                return;
            }

            if (!attackButton && direction.Length() > 0.8)
            {
                attackButton = true;
            }
            else if (direction.Length() < 0.4)
            {
                direction = Parent.CurrentDirection / 5;
            }

            if (_currentAttackDirection == direction && attackButton == _currentAttackButton)
            {
                return;
            }

            CurrentDirection = direction;

            _currentAttackDirection = direction;
            _currentAttackButton    = attackButton;


            if (!attackButton || direction == Vector2.Zero)
            {
                _removeOnComplete = true;
                if (!_rotationCompleted)
                {
                    _keepRotating = 5;
                }
                else if (_keepRotating <= 0)
                {
                    level.RemoveEntity(this);
                }
                return;
            }

            _removeOnComplete  = false;
            _rotationCompleted = false;

            var oldDesired = _desiredAngle;

            _desiredAngle = (float)Math.Atan2(-direction.X, direction.Y);

            if (!level.ContainsEntity(this))
            {
                SoundManager.PlaySound("sword");
                if (_desiredAngle > 0)
                {
                    _swingedAngle = MathHelper.ToRadians(90);
                }
                else
                {
                    _swingedAngle = MathHelper.ToRadians(-90);
                }
                Angle = _swingedAngle;
                level.AddEntity(this);
            }
            else if (_swingedAngle == 0)
            {
                var oldAngle = _swingedAngle;
                _swingedAngle -= _desiredAngle - Angle + _swingedAngle;
                if (Math.Abs(_swingedAngle) - 0.1 > Math.PI)
                {
                    if (_swingedAngle > 0)
                    {
                        _swingedAngle -= (float)Math.PI * 2;
                    }
                    else
                    {
                        _swingedAngle += (float)Math.PI * 2;
                    }
                }
            }

            if (_swingedAngle > 0)
            {
                _swingDirection = -1;
            }
            else
            {
                _swingDirection = 1;
            }
        }
示例#23
0
 public void ItemCheck(int i)
 {
     TileObject tileObject;
     Vector2 vector2 = new Vector2();
     Vector2 x = new Vector2();
     Vector2 y = new Vector2();
     int num;
     Vector2 vector21;
     if (this.webbed || this.frozen || this.stoned)
     {
         return;
     }
     bool flag = false;
     float playerOffsetHitbox = (float)this.mount.PlayerOffsetHitbox;
     Item item = this.inventory[this.selectedItem];
     if (this.mount.Active)
     {
         if (this.mount.Type == 8)
         {
             this.noItems = true;
             if (this.controlUseItem)
             {
                 this.channel = true;
                 if (this.releaseUseItem)
                 {
                     this.mount.UseAbility(this, Vector2.Zero, true);
                 }
                 this.releaseUseItem = false;
             }
         }
         if (this.whoAmI == Main.myPlayer && this.gravDir == -1f)
         {
             this.mount.Dismount(this);
         }
     }
     int weaponDamage = this.GetWeaponDamage(item);
     if (item.autoReuse && !this.noItems)
     {
         this.releaseUseItem = true;
         if (this.itemAnimation == 1 && item.stack > 0)
         {
             if (item.shoot <= 0 || this.whoAmI == Main.myPlayer || !this.controlUseItem || item.useStyle != 5)
             {
                 this.itemAnimation = 0;
             }
             else
             {
                 this.ApplyAnimation(item);
             }
         }
     }
     if (item.fishingPole > 0)
     {
         item.holdStyle = 0;
         if (this.itemTime == 0 && this.itemAnimation == 0)
         {
             for (int i1 = 0; i1 < 1000; i1++)
             {
                 if (Main.projectile[i1].active && Main.projectile[i1].owner == this.whoAmI && Main.projectile[i1].bobber)
                 {
                     item.holdStyle = 1;
                 }
             }
         }
     }
     if (this.itemAnimation == 0 && this.altFunctionUse == 2)
     {
         this.altFunctionUse = 0;
     }
     if (this.itemAnimation == 0 && this.reuseDelay > 0)
     {
         this.itemAnimation = this.reuseDelay;
         this.itemTime = this.reuseDelay;
         this.reuseDelay = 0;
     }
     if (this.controlUseItem && this.releaseUseItem && (item.headSlot > 0 || item.bodySlot > 0 || item.legSlot > 0))
     {
         if (item.useStyle == 0)
         {
             this.releaseUseItem = false;
         }
         if (this.position.X / 16f - (float)Player.tileRangeX - (float)item.tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)item.tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)item.tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)item.tileBoost - 2f >= (float)Player.tileTargetY)
         {
             int num2 = Player.tileTargetX;
             int num3 = Player.tileTargetY;
             if (Main.tile[num2, num3].active() && (Main.tile[num2, num3].type == TileID.Mannequin || Main.tile[num2, num3].type == TileID.Womannequin))
             {
                 int j = Main.tile[num2, num3].frameY;
                 int num4 = 0;
                 if (item.bodySlot >= 0)
                 {
                     num4 = 1;
                 }
                 if (item.legSlot >= 0)
                 {
                     num4 = 2;
                 }
                 for (j = j / 18; num4 > j; j = j / 18)
                 {
                     num3++;
                     j = Main.tile[num2, num3].frameY;
                 }
                 while (num4 < j)
                 {
                     num3--;
                     j = Main.tile[num2, num3].frameY;
                     j = j / 18;
                 }
                 int num5 = Main.tile[num2, num3].frameX;
                 while (num5 >= 100)
                 {
                     num5 = num5 - 100;
                 }
                 if (num5 >= 36)
                 {
                     num5 = num5 - 36;
                 }
                 num2 = num2 - num5 / 18;
                 int num6 = Main.tile[num2, num3].frameX;
                 WorldGen.KillTile(num2, num3, true, false, false);
                 if (Main.netMode == 1)
                 {
                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)num2, (float)num3, 1f, 0, 0, 0);
                 }
                 while (num6 >= 100)
                 {
                     num6 = num6 - 100;
                 }
                 if (j == 0 && item.headSlot >= 0)
                 {
                     Main.blockMouse = true;
                     Main.tile[num2, num3].frameX = (short)(num6 + item.headSlot * 100);
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendTileSquare(-1, num2, num3, 1);
                     }
                     Item item1 = item;
                     item1.stack = item1.stack - 1;
                     if (item.stack <= 0)
                     {
                         item.SetDefaults(0, false);
                         Main.mouseItem.SetDefaults(0, false);
                     }
                     if (this.selectedItem == 58)
                     {
                         Main.mouseItem = item.Clone();
                     }
                     this.releaseUseItem = false;
                     this.mouseInterface = true;
                 }
                 else if (j == 1 && item.bodySlot >= 0)
                 {
                     Main.blockMouse = true;
                     Main.tile[num2, num3].frameX = (short)(num6 + item.bodySlot * 100);
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendTileSquare(-1, num2, num3, 1);
                     }
                     Item item2 = item;
                     item2.stack = item2.stack - 1;
                     if (item.stack <= 0)
                     {
                         item.SetDefaults(0, false);
                         Main.mouseItem.SetDefaults(0, false);
                     }
                     if (this.selectedItem == 58)
                     {
                         Main.mouseItem = item.Clone();
                     }
                     this.releaseUseItem = false;
                     this.mouseInterface = true;
                 }
                 else if (j == 2 && item.legSlot >= 0)
                 {
                     Main.blockMouse = true;
                     Main.tile[num2, num3].frameX = (short)(num6 + item.legSlot * 100);
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendTileSquare(-1, num2, num3, 1);
                     }
                     Item item3 = item;
                     item3.stack = item3.stack - 1;
                     if (item.stack <= 0)
                     {
                         item.SetDefaults(0, false);
                         Main.mouseItem.SetDefaults(0, false);
                     }
                     if (this.selectedItem == 58)
                     {
                         Main.mouseItem = item.Clone();
                     }
                     this.releaseUseItem = false;
                     this.mouseInterface = true;
                 }
             }
         }
     }
     if (Main.myPlayer == i && this.itemAnimation == 0 && TileObjectData.CustomPlace(item.createTile, item.placeStyle))
     {
         TileObject.CanPlace(Player.tileTargetX, Player.tileTargetY, item.createTile, item.placeStyle, this.direction, out tileObject, true);
     }
     if (this.controlUseItem && this.itemAnimation == 0 && this.releaseUseItem && item.useStyle > 0)
     {
         if (this.altFunctionUse == 1)
         {
             this.altFunctionUse = 2;
         }
         bool flag1 = true;
         if (item.shoot == 0)
         {
             this.itemRotation = 0f;
         }
         if (item.type == ItemID.DemonHeart && (this.extraAccessory || !Main.expertMode))
         {
             flag1 = false;
         }
         if (this.pulley && item.fishingPole > 0)
         {
             flag1 = false;
         }
         if (this.wet && (item.shoot == 85 || item.shoot == 15 || item.shoot == 34))
         {
             flag1 = false;
         }
         if (item.makeNPC > 0 && !NPC.CanReleaseNPCs(this.whoAmI))
         {
             flag1 = false;
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.Carrot && !Main.cEd)
         {
             flag1 = false;
         }
         if (item.type == ItemID.Paintbrush || item.type == ItemID.PaintRoller)
         {
             bool flag2 = false;
             int num7 = 0;
             while (num7 < 58)
             {
                 if (this.inventory[num7].paint <= 0)
                 {
                     num7++;
                 }
                 else
                 {
                     flag2 = true;
                     break;
                 }
             }
             if (!flag2)
             {
                 flag1 = false;
             }
         }
         if (this.noItems)
         {
             flag1 = false;
         }
         if (item.tileWand > 0)
         {
             int num8 = item.tileWand;
             flag1 = false;
             int num9 = 0;
             while (num9 < 58)
             {
                 if (num8 != this.inventory[num9].type || this.inventory[num9].stack <= 0)
                 {
                     num9++;
                 }
                 else
                 {
                     flag1 = true;
                     break;
                 }
             }
         }
         if (item.fishingPole > 0)
         {
             for (int k = 0; k < 1000; k++)
             {
                 if (Main.projectile[k].active && Main.projectile[k].owner == this.whoAmI && Main.projectile[k].bobber)
                 {
                     flag1 = false;
                     if (this.whoAmI == Main.myPlayer && Main.projectile[k].ai[0] == 0f)
                     {
                         Main.projectile[k].ai[0] = 1f;
                         float single1 = -10f;
                         if (Main.projectile[k].wet && Main.projectile[k].velocity.Y > single1)
                         {
                             Main.projectile[k].velocity.Y = single1;
                         }
                         Main.projectile[k].netUpdate2 = true;
                         if (Main.projectile[k].ai[1] < 0f && Main.projectile[k].localAI[1] != 0f)
                         {
                             bool flag3 = false;
                             int num10 = 0;
                             int num11 = 0;
                             while (num11 < 58)
                             {
                                 if (this.inventory[num11].stack <= 0 || this.inventory[num11].bait <= 0)
                                 {
                                     num11++;
                                 }
                                 else
                                 {
                                     bool flag4 = false;
                                     int num12 = 1 + this.inventory[num11].bait / 5;
                                     if (num12 < 1)
                                     {
                                         num12 = 1;
                                     }
                                     if (this.accTackleBox)
                                     {
                                         num12++;
                                     }
                                     if (Main.rand.Next(num12) == 0)
                                     {
                                         flag4 = true;
                                     }
                                     if (Main.projectile[k].localAI[1] < 0f)
                                     {
                                         flag4 = true;
                                     }
                                     if (Main.projectile[k].localAI[1] > 0f)
                                     {
                                         Item item4 = new Item();
                                         item4.SetDefaults((int)Main.projectile[k].localAI[1], false);
                                         if (item4.rare < 0)
                                         {
                                             flag4 = false;
                                         }
                                     }
                                     if (flag4)
                                     {
                                         num10 = this.inventory[num11].type;
                                         Item item5 = this.inventory[num11];
                                         item5.stack = item5.stack - 1;
                                         if (this.inventory[num11].stack <= 0)
                                         {
                                             this.inventory[num11].SetDefaults(0, false);
                                         }
                                     }
                                     flag3 = true;
                                     break;
                                 }
                             }
                             if (flag3)
                             {
                                 if (num10 == 2673)
                                 {
                                     if (Main.netMode == 1)
                                     {
                                         NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 370f, 0f, 0f, 0, 0, 0);
                                     }
                                     else
                                     {
                                         NPC.SpawnOnPlayer(this.whoAmI, 370);
                                     }
                                     Main.projectile[k].ai[0] = 2f;
                                 }
                                 else if (Main.rand.Next(7) != 0 || this.accFishingLine)
                                 {
                                     Main.projectile[k].ai[1] = Main.projectile[k].localAI[1];
                                 }
                                 else
                                 {
                                     Main.projectile[k].ai[0] = 2f;
                                 }
                                 Main.projectile[k].netUpdate = true;
                             }
                         }
                     }
                 }
             }
         }
         if (item.shoot == 6 || item.shoot == 19 || item.shoot == 33 || item.shoot == 52 || item.shoot == 113 || item.shoot == 320 || item.shoot == 333 || item.shoot == 383 || item.shoot == 491)
         {
             for (int l = 0; l < 1000; l++)
             {
                 if (Main.projectile[l].active && Main.projectile[l].owner == Main.myPlayer && Main.projectile[l].type == item.shoot)
                 {
                     flag1 = false;
                 }
             }
         }
         if (item.shoot == 106)
         {
             int num13 = 0;
             for (int m = 0; m < 1000; m++)
             {
                 if (Main.projectile[m].active && Main.projectile[m].owner == Main.myPlayer && Main.projectile[m].type == item.shoot)
                 {
                     num13++;
                 }
             }
             if (num13 >= item.stack)
             {
                 flag1 = false;
             }
         }
         if (item.shoot == 272)
         {
             int num14 = 0;
             for (int n = 0; n < 1000; n++)
             {
                 if (Main.projectile[n].active && Main.projectile[n].owner == Main.myPlayer && Main.projectile[n].type == item.shoot)
                 {
                     num14++;
                 }
             }
             if (num14 >= item.stack)
             {
                 flag1 = false;
             }
         }
         if (item.shoot == 13 || item.shoot == 32 || item.shoot >= 230 && item.shoot <= 235 || item.shoot == 315 || item.shoot == 331 || item.shoot == 372)
         {
             for (int o = 0; o < 1000; o++)
             {
                 if (Main.projectile[o].active && Main.projectile[o].owner == Main.myPlayer && Main.projectile[o].type == item.shoot && Main.projectile[o].ai[0] != 2f)
                 {
                     flag1 = false;
                 }
             }
         }
         if (item.shoot == 332)
         {
             int num15 = 0;
             for (int p = 0; p < 1000; p++)
             {
                 if (Main.projectile[p].active && Main.projectile[p].owner == Main.myPlayer && Main.projectile[p].type == item.shoot && Main.projectile[p].ai[0] != 2f)
                 {
                     num15++;
                 }
             }
             if (num15 >= 3)
             {
                 flag1 = false;
             }
         }
         if (item.potion && flag1)
         {
             if (this.potionDelay > 0)
             {
                 flag1 = false;
             }
             else if (item.type != ItemID.RestorationPotion)
             {
                 this.potionDelay = this.potionDelayTime;
                 this.AddBuff(BuffID.PotionSickness, this.potionDelay, true);
             }
             else
             {
                 this.potionDelay = this.restorationDelayTime;
                 this.AddBuff(BuffID.PotionSickness, this.potionDelay, true);
             }
         }
         if (item.mana > 0 && this.silence)
         {
             flag1 = false;
         }
         if (item.mana > 0 && flag1)
         {
             bool flag5 = false;
             if (item.type == ItemID.LaserMachinegun)
             {
                 flag5 = true;
             }
             if (item.type != ItemID.SpaceGun || !this.spaceGun)
             {
                 if (this.statMana >= (int)((float)item.mana * this.manaCost))
                 {
                     if (!flag5)
                     {
                         Player player = this;
                         player.statMana = player.statMana - (int)((float)item.mana * this.manaCost);
                     }
                 }
                 else if (!this.manaFlower)
                 {
                     flag1 = false;
                 }
                 else
                 {
                     this.QuickMana();
                     if (this.statMana < (int)((float)item.mana * this.manaCost))
                     {
                         flag1 = false;
                     }
                     else if (!flag5)
                     {
                         Player player1 = this;
                         player1.statMana = player1.statMana - (int)((float)item.mana * this.manaCost);
                     }
                 }
             }
             if (this.whoAmI == Main.myPlayer && item.buffType != 0 && flag1)
             {
                 this.AddBuff(item.buffType, item.buffTime, true);
             }
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.Carrot && Main.cEd)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.Fish)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.ShadowOrb)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.BoneRattle)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.CrimsonHeart)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.SuspiciousLookingTentacle)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.FairyBell)
         {
             int num16 = Main.rand.Next(3);
             if (num16 == 0)
             {
                 num16 = 27;
             }
             if (num16 == 1)
             {
                 num16 = 101;
             }
             if (num16 == 2)
             {
                 num16 = 102;
             }
             for (int q = 0; q < 22; q++)
             {
                 if (this.buffType[q] == BuffID.FairyBlue || this.buffType[q] == BuffID.FairyRed || this.buffType[q] == BuffID.FairyGreen)
                 {
                     this.DelBuff(q);
                     q--;
                 }
             }
             this.AddBuff(num16, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.Seaweed)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.EatersBone)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.BoneKey)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.Nectar)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.TikiTotem)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.LizardEgg)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.ParrotCracker)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.StrangeGlowingMushroom)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.Seedling)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.WispinaBottle)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.AmberMosquito)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.PygmyStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.SlimeStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.EyeSpring)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.CursedSapling)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.ToySled)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.SpiderEgg)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.MagicalPumpkinSeed)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.RavenStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.UnluckyYarn)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.DogWhistle)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.BabyGrinchMischiefWhistle)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.HornetStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.ImpStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.MagicLantern)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.ZephyrFish)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.OpticStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.SpiderStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.PirateStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.TartarSauce)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.TempestStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.XenoStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.DeadlySphereStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.StardustCellStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && item.type == ItemID.StardustDragonStaff)
         {
             this.AddBuff(item.buffType, 3600, true);
         }
         if (this.whoAmI == Main.myPlayer && this.gravDir == 1f && item.mountType != -1 && this.mount.CanMount(item.mountType, this))
         {
             this.mount.SetMount(item.mountType, this, false);
         }
         if (item.type == ItemID.SuspiciousLookingEye && Main.dayTime)
         {
             flag1 = false;
         }
         if (item.type == ItemID.MechanicalEye && Main.dayTime)
         {
             flag1 = false;
         }
         if (item.type == ItemID.MechanicalWorm && Main.dayTime)
         {
             flag1 = false;
         }
         if (item.type == ItemID.MechanicalSkull && Main.dayTime)
         {
             flag1 = false;
         }
         if (item.type == ItemID.WormFood && !this.ZoneCorrupt)
         {
             flag1 = false;
         }
         if (item.type == ItemID.Abeemination && !this.ZoneJungle)
         {
             flag1 = false;
         }
         if (item.type == ItemID.PumpkinMoonMedallion && (Main.dayTime || Main.pumpkinMoon || Main.snowMoon))
         {
             flag1 = false;
         }
         if (item.type == ItemID.NaughtyPresent && (Main.dayTime || Main.pumpkinMoon || Main.snowMoon))
         {
             flag1 = false;
         }
         if (item.type == ItemID.LunarTablet && (!Main.dayTime || Main.eclipse || !Main.hardMode))
         {
             flag1 = false;
         }
         if (item.type == ItemID.CelestialSigil && (!NPC.downedGolemBoss || !Main.hardMode || NPC.AnyDanger() || NPC.AnyoneNearCultists()))
         {
             flag1 = false;
         }
         if (!this.SummonItemCheck())
         {
             flag1 = false;
         }
         if (item.shoot == 17 && flag1 && i == Main.myPlayer)
         {
             int x1 = (int)((float)Main.mouseX + Main.screenPosition.X) / 16;
             int y1 = (int)((float)Main.mouseY + Main.screenPosition.Y) / 16;
             if (this.gravDir == -1f)
             {
                 y1 = (int)(Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY) / 16;
             }
             Tile tile = Main.tile[x1, y1];
             if (!tile.active() || tile.type != TileID.Dirt && tile.type != TileID.Grass && tile.type != TileID.CorruptGrass && tile.type != TileID.HallowedGrass && tile.type != TileID.FleshGrass)
             {
                 flag1 = false;
             }
             else
             {
                 WorldGen.KillTile(x1, y1, false, false, true);
                 if (Main.tile[x1, y1].active())
                 {
                     flag1 = false;
                 }
                 else if (Main.netMode == 1)
                 {
                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 4, (float)x1, (float)y1, 0f, 0, 0, 0);
                 }
             }
         }
         if (flag1)
         {
             flag1 = this.HasAmmo(item, flag1);
         }
         if (flag1)
         {
             if (item.pick > 0 || item.axe > 0 || item.hammer > 0)
             {
                 this.toolTime = 1;
             }
             if (this.grappling[0] > -1)
             {
                 this.pulley = false;
                 this.pulleyDir = 1;
                 if (this.controlRight)
                 {
                     this.direction = 1;
                 }
                 else if (this.controlLeft)
                 {
                     this.direction = -1;
                 }
             }
             this.channel = item.channel;
             this.attackCD = 0;
             this.ApplyAnimation(item);
         }
         if (flag1 && this.whoAmI == Main.myPlayer && item.shoot >= 0 && item.shoot < 651 && (ProjectileID.Sets.LightPet[item.shoot] || Main.projPet[item.shoot]))
         {
             if (!ProjectileID.Sets.MinionSacrificable[item.shoot])
             {
                 for (int r = 0; r < 1000; r++)
                 {
                     if (Main.projectile[r].active && Main.projectile[r].owner == i && Main.projectile[r].type == item.shoot)
                     {
                         Main.projectile[r].Kill();
                     }
                     if (item.shoot == 72)
                     {
                         if (Main.projectile[r].active && Main.projectile[r].owner == i && Main.projectile[r].type == ProjectileID.PinkFairy)
                         {
                             Main.projectile[r].Kill();
                         }
                         if (Main.projectile[r].active && Main.projectile[r].owner == i && Main.projectile[r].type == ProjectileID.GreenFairy)
                         {
                             Main.projectile[r].Kill();
                         }
                     }
                 }
             }
             else
             {
                 List<int> nums = new List<int>();
                 float single2 = 0f;
                 for (int s = 0; s < 1000; s++)
                 {
                     if (Main.projectile[s].active && Main.projectile[s].owner == i && Main.projectile[s].minion)
                     {
                         int num17 = 0;
                         while (num17 < nums.Count)
                         {
                             if (Main.projectile[nums[num17]].minionSlots <= Main.projectile[s].minionSlots)
                             {
                                 num17++;
                             }
                             else
                             {
                                 nums.Insert(num17, s);
                                 break;
                             }
                         }
                         if (num17 == nums.Count)
                         {
                             nums.Add(s);
                         }
                         single2 = single2 + Main.projectile[s].minionSlots;
                     }
                 }
                 float staffMinionSlotsRequired = (float)ItemID.Sets.StaffMinionSlotsRequired[item.type];
                 float single3 = 0f;
                 int num18 = 388;
                 int item6 = -1;
                 for (int t = 0; t < nums.Count; t++)
                 {
                     int num19 = Main.projectile[nums[t]].type;
                     if (num19 == 626)
                     {
                         nums.RemoveAt(t);
                         t--;
                     }
                     if (num19 == 627)
                     {
                         if (Main.projectile[(int)Main.projectile[nums[t]].localAI[1]].type == 628)
                         {
                             item6 = nums[t];
                         }
                         nums.RemoveAt(t);
                         t--;
                     }
                 }
                 if (item6 != -1)
                 {
                     nums.Add(item6);
                     nums.Add((int)Main.projectile[item6].ai[0]);
                 }
                 for (int u = 0; u < nums.Count && single2 - single3 > (float)this.maxMinions - staffMinionSlotsRequired; u++)
                 {
                     int num20 = Main.projectile[nums[u]].type;
                     if (num20 != num18 && num20 != 625 && num20 != 628)
                     {
                         if (num20 == 388 && num18 == 387)
                         {
                             num18 = 388;
                         }
                         if (num20 == 387 && num18 == 388)
                         {
                             num18 = 387;
                         }
                         single3 = single3 + Main.projectile[nums[u]].minionSlots;
                         if (num20 == 626 || num20 == 627)
                         {
                             int byUUID = Projectile.GetByUUID(Main.projectile[nums[u]].owner, Main.projectile[nums[u]].ai[0]);
                             if (byUUID >= 0)
                             {
                                 Projectile projectile = Main.projectile[byUUID];
                                 if (projectile.type != ProjectileID.StardustDragon1)
                                 {
                                     projectile.localAI[1] = Main.projectile[nums[u]].localAI[1];
                                 }
                                 projectile = Main.projectile[(int)Main.projectile[nums[u]].localAI[1]];
                                 projectile.ai[0] = Main.projectile[nums[u]].ai[0];
                                 projectile.ai[1] = 1f;
                                 projectile.netUpdate = true;
                             }
                         }
                         Main.projectile[nums[u]].Kill();
                     }
                 }
                 nums.Clear();
                 if (single2 + staffMinionSlotsRequired >= 9f)
                 {
                     AchievementsHelper.HandleSpecialEvent(this, 6);
                 }
             }
         }
     }
     if (!this.controlUseItem)
     {
         bool flag6 = this.channel;
         this.channel = false;
     }
     if (this.itemAnimation > 0)
     {
         if (!item.melee)
         {
             this.itemAnimationMax = item.useAnimation;
         }
         else
         {
             this.itemAnimationMax = (int)((float)item.useAnimation * this.meleeSpeed);
         }
         if (item.mana > 0 && !flag && (item.type != ItemID.SpaceGun || !this.spaceGun))
         {
             this.manaRegenDelay = (int)this.maxRegenDelay;
         }
             this.itemHeight = item.height;
             this.itemWidth = item.width;
         Player player2 = this;
         player2.itemAnimation = player2.itemAnimation - 1;
     }
     else if (item.holdStyle == 1 && !this.pulley)
     {
         if (Main.dedServ)
         {
             this.itemLocation.X = this.position.X + (float)this.width * 0.5f + 20f * (float)this.direction;
         }
         this.itemLocation.Y = this.position.Y + 24f + playerOffsetHitbox;
         if (item.type == ItemID.UnicornonaStick)
         {
             this.itemLocation.Y = this.position.Y + 34f + playerOffsetHitbox;
         }
         if (item.type == ItemID.FlareGun)
         {
             this.itemLocation.Y = this.position.Y + 9f + playerOffsetHitbox;
         }
         if (item.fishingPole > 0)
         {
             this.itemLocation.Y = this.itemLocation.Y + 4f;
         }
         else if (item.type == ItemID.NebulaArcanum)
         {
             this.itemLocation.X = base.Center.X + (float)(14 * this.direction);
             this.itemLocation.Y = this.MountedCenter.Y;
         }
         this.itemRotation = 0f;
         if (this.gravDir == -1f)
         {
             this.itemRotation = -this.itemRotation;
             this.itemLocation.Y = this.position.Y + (float)this.height + (this.position.Y - this.itemLocation.Y) + playerOffsetHitbox;
             if (item.type == ItemID.FlareGun)
             {
                 this.itemLocation.Y = this.itemLocation.Y - 24f;
             }
         }
     }
     else if (item.holdStyle == 2 && !this.pulley)
     {
         if (item.type != ItemID.Umbrella)
         {
             this.itemLocation.X = this.position.X + (float)this.width * 0.5f + (float)(6 * this.direction);
             this.itemLocation.Y = this.position.Y + 16f + playerOffsetHitbox;
             this.itemRotation = 0.79f * (float)(-this.direction);
             if (this.gravDir == -1f)
             {
                 this.itemRotation = -this.itemRotation;
                 this.itemLocation.Y = this.position.Y + (float)this.height + (this.position.Y - this.itemLocation.Y);
             }
         }
         else
         {
             this.itemRotation = 0f;
             this.itemLocation.X = this.position.X + (float)this.width * 0.5f - (float)(16 * this.direction);
             this.itemLocation.Y = this.position.Y + 22f + playerOffsetHitbox;
             this.fallStart = (int)(this.position.Y / 16f);
             if (this.gravDir == -1f)
             {
                 this.itemRotation = -this.itemRotation;
                 this.itemLocation.Y = this.position.Y + (float)this.height + (this.position.Y - this.itemLocation.Y);
                 if (this.velocity.Y < -2f)
                 {
                     this.velocity.Y = -2f;
                 }
             }
             else if (this.velocity.Y > 2f)
             {
                 this.velocity.Y = 2f;
             }
         }
     }
     if (((item.type == ItemID.IceTorch || item.type == ItemID.Torch || item.type == ItemID.OrangeTorch || item.type == ItemID.UltrabrightTorch || item.type == ItemID.BoneTorch || item.type == ItemID.RainbowTorch || item.type == ItemID.PinkTorch || item.type >= ItemID.BlueTorch && item.type <= ItemID.DemonTorch) && !this.wet || item.type == ItemID.CursedTorch || item.type == ItemID.IchorTorch) && !this.pulley)
     {
         float discoR = 1f;
         float discoG = 0.95f;
         float discoB = 0.8f;
         int num25 = 0;
         if (item.type == ItemID.CursedTorch)
         {
             num25 = 8;
         }
         else if (item.type == ItemID.IceTorch)
         {
             num25 = 9;
         }
         else if (item.type == ItemID.OrangeTorch)
         {
             num25 = 10;
         }
         else if (item.type == ItemID.IchorTorch)
         {
             num25 = 11;
         }
         else if (item.type == ItemID.UltrabrightTorch)
         {
             num25 = 12;
         }
         else if (item.type == ItemID.BoneTorch)
         {
             num25 = 13;
         }
         else if (item.type == ItemID.RainbowTorch)
         {
             num25 = 14;
         }
         else if (item.type == ItemID.PinkTorch)
         {
             num25 = 15;
         }
         else if (item.type >= ItemID.BlueTorch)
         {
             num25 = item.type - 426;
         }
         if (num25 == 1)
         {
             discoR = 0f;
             discoG = 0.1f;
             discoB = 1.3f;
         }
         else if (num25 == 2)
         {
             discoR = 1f;
             discoG = 0.1f;
             discoB = 0.1f;
         }
         else if (num25 == 3)
         {
             discoR = 0f;
             discoG = 1f;
             discoB = 0.1f;
         }
         else if (num25 == 4)
         {
             discoR = 0.9f;
             discoG = 0f;
             discoB = 0.9f;
         }
         else if (num25 == 5)
         {
             discoR = 1.3f;
             discoG = 1.3f;
             discoB = 1.3f;
         }
         else if (num25 == 6)
         {
             discoR = 0.9f;
             discoG = 0.9f;
             discoB = 0f;
         }
         else if (num25 == 7)
         {
             discoR = 0.5f * Main.demonTorch + 1f * (1f - Main.demonTorch);
             discoG = 0.3f;
             discoB = 1f * Main.demonTorch + 0.5f * (1f - Main.demonTorch);
         }
         else if (num25 == 8)
         {
             discoB = 0.7f;
             discoR = 0.85f;
             discoG = 1f;
         }
         else if (num25 == 9)
         {
             discoB = 1f;
             discoR = 0.7f;
             discoG = 0.85f;
         }
         else if (num25 == 10)
         {
             discoB = 0f;
             discoR = 1f;
             discoG = 0.5f;
         }
         else if (num25 == 11)
         {
             discoB = 0.8f;
             discoR = 1.25f;
             discoG = 1.25f;
         }
         else if (num25 == 12)
         {
             discoR = discoR * 0.75f;
             discoG = discoG * 1.3499999f;
             discoB = discoB * 1.5f;
         }
         else if (num25 == 13)
         {
             discoR = 0.95f;
             discoG = 0.65f;
             discoB = 1.3f;
         }
         else if (num25 == 14)
         {
             discoR = (float)Main.DiscoR / 255f;
             discoG = (float)Main.DiscoG / 255f;
             discoB = (float)Main.DiscoB / 255f;
         }
         else if (num25 == 15)
         {
             discoR = 1f;
             discoG = 0f;
             discoB = 1f;
         }
         int num26 = num25;
         if (num26 == 0)
         {
             num26 = 6;
         }
         else if (num26 == 8)
         {
             num26 = 75;
         }
         else if (num26 == 9)
         {
             num26 = 135;
         }
         else if (num26 == 10)
         {
             num26 = 158;
         }
         else if (num26 == 11)
         {
             num26 = 169;
         }
         else if (num26 == 12)
         {
             num26 = 156;
         }
         else if (num26 == 13)
         {
             num26 = 234;
         }
         else if (num26 != 14)
         {
             num26 = (num26 != 15 ? 58 + num26 : 242);
         }
         else
         {
             num26 = 66;
         }
     }
     else if (item.type == ItemID.PeaceCandle && !this.wet)
     {
         this.itemLocation.X = this.itemLocation.X - (float)(this.direction * 4);
     }
     if (item.type == ItemID.SpelunkerGlowstick && !this.pulley)
     {
         Player player5 = this;
         player5.spelunkerTimer = (byte)(player5.spelunkerTimer + 1);
         if (this.spelunkerTimer >= 10)
         {
             this.spelunkerTimer = 0;
         }
     }
     if (!this.controlUseItem)
     {
         this.releaseUseItem = true;
     }
     else
     {
         this.releaseUseItem = false;
     }
     if (this.itemTime > 0)
     {
         Player player6 = this;
         player6.itemTime = player6.itemTime - 1;
     }
     if (i == Main.myPlayer)
     {
         bool flag8 = true;
         int num45 = item.type;
         if ((num45 == 65 || num45 == 676 || num45 == 723 || num45 == 724 || num45 == 757 || num45 == 674 || num45 == 675 || num45 == 989 || num45 == 1226 || num45 == 1227) && this.itemAnimation != this.itemAnimationMax - 1)
         {
             flag8 = false;
         }
         if (item.shoot > 0 && this.itemAnimation > 0 && this.itemTime == 0 && flag8)
         {
             int num46 = item.shoot;
             float single14 = item.shootSpeed;
             if (this.inventory[this.selectedItem].thrown && single14 < 16f)
             {
                 single14 = single14 * this.thrownVelocity;
                 if (single14 > 16f)
                 {
                     single14 = 16f;
                 }
             }
             if (item.melee && num46 != 25 && num46 != 26 && num46 != 35)
             {
                 single14 = single14 / this.meleeSpeed;
             }
             bool flag9 = false;
             int num47 = weaponDamage;
             float single15 = item.knockBack;
             if (num46 == 13 || num46 == 32 || num46 == 315 || num46 >= 230 && num46 <= 235 || num46 == 331)
             {
                 this.grappling[0] = -1;
                 this.grapCount = 0;
                 for (int a = 0; a < 1000; a++)
                 {
                     if (Main.projectile[a].active && Main.projectile[a].owner == i)
                     {
                         if (Main.projectile[a].type == ProjectileID.Hook)
                         {
                             Main.projectile[a].Kill();
                         }
                         if (Main.projectile[a].type == ProjectileID.CandyCaneHook)
                         {
                             Main.projectile[a].Kill();
                         }
                         if (Main.projectile[a].type == ProjectileID.BatHook)
                         {
                             Main.projectile[a].Kill();
                         }
                         if (Main.projectile[a].type >= ProjectileID.GemHookAmethyst && Main.projectile[a].type <= ProjectileID.GemHookDiamond)
                         {
                             Main.projectile[a].Kill();
                         }
                     }
                 }
             }
             if (item.useAmmo <= 0)
             {
                 flag9 = true;
             }
             else
             {
                 this.PickAmmo(item, ref num46, ref single14, ref flag9, ref num47, ref single15, ItemID.Sets.gunProj[item.type]);
             }
             if (item.type == ItemID.VortexBeater || item.type == ItemID.Phantasm)
             {
                 single15 = item.knockBack;
                 num47 = weaponDamage;
                 single14 = item.shootSpeed;
             }
             if (item.type == ItemID.CopperCoin)
             {
                 flag9 = false;
             }
             if (item.type == ItemID.SilverCoin)
             {
                 flag9 = false;
             }
             if (item.type == ItemID.GoldCoin)
             {
                 flag9 = false;
             }
             if (item.type == ItemID.PlatinumCoin)
             {
                 flag9 = false;
             }
             if (item.type == ItemID.SniperRifle && num46 == 14)
             {
                 num46 = 242;
             }
             if (item.type == ItemID.VenusMagnum && num46 == 14)
             {
                 num46 = 242;
             }
             if (item.type == ItemID.Uzi && num46 == 14)
             {
                 num46 = 242;
             }
             if (item.type == ItemID.NebulaBlaze)
             {
                 if (Main.rand.Next(100) >= 20)
                 {
                     single14 = single14 - 1f;
                 }
                 else
                 {
                     num46++;
                     num47 = num47 * 3;
                 }
             }
             if (num46 == 73)
             {
                 for (int b = 0; b < 1000; b++)
                 {
                     if (Main.projectile[b].active && Main.projectile[b].owner == i)
                     {
                         if (Main.projectile[b].type == ProjectileID.DualHookBlue)
                         {
                             num46 = 74;
                         }
                         if (num46 == 74 && Main.projectile[b].type == ProjectileID.DualHookRed)
                         {
                             flag9 = false;
                         }
                     }
                 }
             }
             if (flag9)
             {
                 single15 = this.GetWeaponKnockback(item, single15);
                 if (num46 == 228)
                 {
                     single15 = 0f;
                 }
                 if (num46 == 1 && item.type == ItemID.MoltenFury)
                 {
                     num46 = 2;
                 }
                 if (item.type == ItemID.Marrow)
                 {
                     num46 = 117;
                 }
                 if (item.type == ItemID.IceBow)
                 {
                     num46 = 120;
                 }
                 if (item.type == ItemID.ElectrosphereLauncher)
                 {
                     num46 = 442;
                 }
                 if (item.type == ItemID.PulseBow)
                 {
                     num46 = 357;
                 }
                 this.itemTime = item.useTime;
                 Vector2 center = this.RotatedRelativePoint(this.MountedCenter, true);
                 Vector2 unitX = Vector2.UnitX;
                 double num48 = (double)this.fullRotation;
                 vector21 = new Vector2();
                 Vector2 vector230 = unitX.RotatedBy(num48, vector21);
                 Vector2 mouseWorld = Main.MouseWorld - center;
                 if (mouseWorld != Vector2.Zero)
                 {
                     mouseWorld.Normalize();
                 }
                 if (Vector2.Dot(vector230, mouseWorld) <= 0f)
                 {
                     this.ChangeDir(-1);
                 }
                 else
                 {
                     this.ChangeDir(1);
                 }
                 if (item.type == ItemID.Javelin || item.type == ItemID.BoneJavelin || item.type == ItemID.DayBreak)
                 {
                     center.Y = this.position.Y + (float)(this.height / 3);
                 }
                 if (num46 == 9)
                 {
                     center = new Vector2(this.position.X + (float)this.width * 0.5f + (float)(Main.rand.Next(201) * -this.direction) + ((float)Main.mouseX + Main.screenPosition.X - this.position.X), this.MountedCenter.Y - 600f);
                     single15 = 0f;
                     num47 = num47 * 2;
                 }
                 if (item.type == ItemID.Blowgun || item.type == ItemID.Blowpipe)
                 {
                     center.X = center.X + (float)(6 * this.direction);
                     center.Y = center.Y - 6f * this.gravDir;
                 }
                 if (item.type == ItemID.DartPistol)
                 {
                     center.X = center.X - (float)(4 * this.direction);
                     center.Y = center.Y - 1f * this.gravDir;
                 }
                 float x6 = (float)Main.mouseX + Main.screenPosition.X - center.X;
                 float y6 = (float)Main.mouseY + Main.screenPosition.Y - center.Y;
                 if (this.gravDir == -1f)
                 {
                     y6 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - center.Y;
                 }
                 float single16 = (float)Math.Sqrt((double)(x6 * x6 + y6 * y6));
                 float single17 = single16;
                 if ((!float.IsNaN(x6) || !float.IsNaN(y6)) && (x6 != 0f || y6 != 0f))
                 {
                     single16 = single14 / single16;
                 }
                 else
                 {
                     x6 = (float)this.direction;
                     y6 = 0f;
                     single16 = single14;
                 }
                 if (item.type == ItemID.ChainGun || item.type == ItemID.Gatligator)
                 {
                     x6 = x6 + (float)Main.rand.Next(-50, 51) * 0.03f / single16;
                     y6 = y6 + (float)Main.rand.Next(-50, 51) * 0.03f / single16;
                 }
                 x6 = x6 * single16;
                 y6 = y6 * single16;
                 if (item.type == ItemID.TerraBlade)
                 {
                     num47 = (int)((float)num47 * 1.25f);
                 }
                 if (num46 == 250)
                 {
                     for (int c = 0; c < 1000; c++)
                     {
                         if (Main.projectile[c].active && Main.projectile[c].owner == this.whoAmI && (Main.projectile[c].type == ProjectileID.RainbowFront || Main.projectile[c].type == ProjectileID.RainbowBack))
                         {
                             Main.projectile[c].Kill();
                         }
                     }
                 }
                 if (num46 == 12)
                 {
                     center.X = center.X + x6 * 3f;
                     center.Y = center.Y + y6 * 3f;
                 }
                 if (item.useStyle == 5)
                 {
                     if (item.type != ItemID.DaedalusStormbow)
                     {
                         this.itemRotation = (float)Math.Atan2((double)(y6 * (float)this.direction), (double)(x6 * (float)this.direction)) - this.fullRotation;
                         NetMessage.SendData((int)PacketTypes.PlayerUpdate, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                         NetMessage.SendData((int)PacketTypes.PlayerAnimation, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                     }
                     else
                     {
                         Vector2 vector231 = new Vector2(x6, y6)
                         {
                             X = (float)Main.mouseX + Main.screenPosition.X - center.X,
                             Y = (float)Main.mouseY + Main.screenPosition.Y - center.Y - 1000f
                         };
                         this.itemRotation = (float)Math.Atan2((double)(vector231.Y * (float)this.direction), (double)(vector231.X * (float)this.direction));
                         NetMessage.SendData((int)PacketTypes.PlayerUpdate, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                         NetMessage.SendData((int)PacketTypes.PlayerAnimation, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                     }
                 }
                 if (num46 == 17)
                 {
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     if (this.gravDir == -1f)
                     {
                         center.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;
                     }
                 }
                 if (num46 == 76)
                 {
                     num46 = num46 + Main.rand.Next(3);
                     single17 = single17 / (float)(Main.screenHeight / 2);
                     if (single17 > 1f)
                     {
                         single17 = 1f;
                     }
                     float single18 = x6 + (float)Main.rand.Next(-40, 41) * 0.01f;
                     float single19 = y6 + (float)Main.rand.Next(-40, 41) * 0.01f;
                     single18 = single18 * (single17 + 0.25f);
                     single19 = single19 * (single17 + 0.25f);
                     int num49 = Projectile.NewProjectile(center.X, center.Y, single18, single19, num46, num47, single15, i, 0f, 0f);
                     Main.projectile[num49].ai[1] = 1f;
                     single17 = single17 * 2f - 1f;
                     if (single17 < -1f)
                     {
                         single17 = -1f;
                     }
                     if (single17 > 1f)
                     {
                         single17 = 1f;
                     }
                     Main.projectile[num49].ai[0] = single17;
                     NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", num49, 0f, 0f, 0f, 0, 0, 0);
                 }
                 else if (item.type == ItemID.DaedalusStormbow)
                 {
                     int num50 = 3;
                     if (Main.rand.Next(3) == 0)
                     {
                         num50++;
                     }
                     for (int d = 0; d < num50; d++)
                     {
                         center = new Vector2(this.position.X + (float)this.width * 0.5f + (float)(Main.rand.Next(201) * -this.direction) + ((float)Main.mouseX + Main.screenPosition.X - this.position.X), this.MountedCenter.Y - 600f)
                         {
                             X = (center.X * 10f + base.Center.X) / 11f + (float)Main.rand.Next(-100, 101),
                             Y = center.Y - (float)(150 * d)
                         };
                         x6 = (float)Main.mouseX + Main.screenPosition.X - center.X;
                         y6 = (float)Main.mouseY + Main.screenPosition.Y - center.Y;
                         if (y6 < 0f)
                         {
                             y6 = y6 * -1f;
                         }
                         if (y6 < 20f)
                         {
                             y6 = 20f;
                         }
                         single16 = (float)Math.Sqrt((double)(x6 * x6 + y6 * y6));
                         single16 = single14 / single16;
                         x6 = x6 * single16;
                         y6 = y6 * single16;
                         float single20 = x6 + (float)Main.rand.Next(-40, 41) * 0.03f;
                         float single21 = y6 + (float)Main.rand.Next(-40, 41) * 0.03f;
                         single20 = single20 * ((float)Main.rand.Next(75, 150) * 0.01f);
                         center.X = center.X + (float)Main.rand.Next(-50, 51);
                         int num51 = Projectile.NewProjectile(center.X, center.Y, single20, single21, num46, num47, single15, i, 0f, 0f);
                         Main.projectile[num51].noDropItem = true;
                     }
                 }
                 else if (item.type == ItemID.Minishark || item.type == ItemID.Megashark)
                 {
                     float single22 = x6 + (float)Main.rand.Next(-40, 41) * 0.01f;
                     float single23 = y6 + (float)Main.rand.Next(-40, 41) * 0.01f;
                     Projectile.NewProjectile(center.X, center.Y, single22, single23, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.SnowballCannon)
                 {
                     float single24 = x6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                     float single25 = y6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                     int num52 = Projectile.NewProjectile(center.X, center.Y, single24, single25, num46, num47, single15, i, 0f, 0f);
                     Main.projectile[num52].ranged = true;
                     Main.projectile[num52].thrown = false;
                 }
                 else if (item.type == ItemID.NailGun)
                 {
                     float single26 = x6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                     float single27 = y6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                     Projectile.NewProjectile(center.X, center.Y, single26, single27, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.ShadowFlameHexDoll)
                 {
                     Vector2 vector232 = new Vector2(x6, y6);
                     vector232.Normalize();
                     Vector2 vector233 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
                     vector233.Normalize();
                     vector232 = (vector232 * 4f) + vector233;
                     vector232.Normalize();
                     vector232 = vector232 * item.shootSpeed;
                     float single28 = (float)Main.rand.Next(10, 80) * 0.001f;
                     if (Main.rand.Next(2) == 0)
                     {
                         single28 = single28 * -1f;
                     }
                     float single29 = (float)Main.rand.Next(10, 80) * 0.001f;
                     if (Main.rand.Next(2) == 0)
                     {
                         single29 = single29 * -1f;
                     }
                     Projectile.NewProjectile(center.X, center.Y, vector232.X, vector232.Y, num46, num47, single15, i, single29, single28);
                 }
                 else if (item.type == ItemID.HellwingBow)
                 {
                     Vector2 x7 = new Vector2(x6, y6);
                     float single30 = x7.Length();
                     x7.X = x7.X + (float)Main.rand.Next(-100, 101) * 0.01f * single30 * 0.15f;
                     x7.Y = x7.Y + (float)Main.rand.Next(-100, 101) * 0.01f * single30 * 0.15f;
                     float x8 = x6 + (float)Main.rand.Next(-40, 41) * 0.03f;
                     float y7 = y6 + (float)Main.rand.Next(-40, 41) * 0.03f;
                     x7.Normalize();
                     x7 = x7 * single30;
                     x8 = x8 * ((float)Main.rand.Next(50, 150) * 0.01f);
                     y7 = y7 * ((float)Main.rand.Next(50, 150) * 0.01f);
                     Vector2 vector234 = new Vector2(x8, y7);
                     vector234.Normalize();
                     vector234 = vector234 * single30;
                     x8 = vector234.X;
                     y7 = vector234.Y;
                     Projectile.NewProjectile(center.X, center.Y, x8, y7, num46, num47, single15, i, x7.X, x7.Y);
                 }
                 else if (item.type == ItemID.Xenopopper)
                 {
                     Vector2 vector235 = (Vector2.Normalize(new Vector2(x6, y6)) * 40f) * item.scale;
                     if (Collision.CanHit(center, 0, 0, center + vector235, 0, 0))
                     {
                         center = center + vector235;
                     }
                     float rotation = (new Vector2(x6, y6)).ToRotation();
                     float single31 = 2.09439516f;
                     int num53 = Main.rand.Next(4, 5);
                     if (Main.rand.Next(4) == 0)
                     {
                         num53++;
                     }
                     for (int e = 0; e < num53; e++)
                     {
                         float single32 = (float)Main.rand.NextDouble() * 0.2f + 0.05f;
                         Vector2 vector236 = new Vector2(x6, y6);
                         double num54 = (double)(single31 * (float)Main.rand.NextDouble() - single31 / 2f);
                         vector21 = new Vector2();
                         Vector2 vector237 = vector236.RotatedBy(num54, vector21) * single32;
                         int num55 = Projectile.NewProjectile(center.X, center.Y, vector237.X, vector237.Y, 444, num47, single15, i, rotation, 0f);
                         Main.projectile[num55].localAI[0] = (float)num46;
                         Main.projectile[num55].localAI[1] = single14;
                     }
                 }
                 else if (item.type == ItemID.Gatligator)
                 {
                     float single33 = x6 + (float)Main.rand.Next(-40, 41) * 0.05f;
                     float single34 = y6 + (float)Main.rand.Next(-40, 41) * 0.05f;
                     if (Main.rand.Next(3) == 0)
                     {
                         single33 = single33 * (1f + (float)Main.rand.Next(-30, 31) * 0.02f);
                         single34 = single34 * (1f + (float)Main.rand.Next(-30, 31) * 0.02f);
                     }
                     Projectile.NewProjectile(center.X, center.Y, single33, single34, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.Razorpine)
                 {
                     int num56 = 2 + Main.rand.Next(3);
                     for (int f = 0; f < num56; f++)
                     {
                         float single35 = x6;
                         float single36 = y6;
                         float single37 = 0.025f * (float)f;
                         single35 = single35 + (float)Main.rand.Next(-35, 36) * single37;
                         single36 = single36 + (float)Main.rand.Next(-35, 36) * single37;
                         single16 = (float)Math.Sqrt((double)(single35 * single35 + single36 * single36));
                         single16 = single14 / single16;
                         single35 = single35 * single16;
                         single36 = single36 * single16;
                         float x9 = center.X + x6 * (float)(num56 - f) * 1.75f;
                         float y8 = center.Y + y6 * (float)(num56 - f) * 1.75f;
                         Projectile.NewProjectile(x9, y8, single35, single36, num46, num47, single15, i, (float)Main.rand.Next(0, 10 * (f + 1)), 0f);
                     }
                 }
                 else if (item.type == ItemID.BlizzardStaff)
                 {
                     int num57 = 2;
                     for (int g = 0; g < num57; g++)
                     {
                         center = new Vector2(this.position.X + (float)this.width * 0.5f + (float)(Main.rand.Next(201) * -this.direction) + ((float)Main.mouseX + Main.screenPosition.X - this.position.X), this.MountedCenter.Y - 600f)
                         {
                             X = (center.X + base.Center.X) / 2f + (float)Main.rand.Next(-200, 201),
                             Y = center.Y - (float)(100 * g)
                         };
                         x6 = (float)Main.mouseX + Main.screenPosition.X - center.X;
                         y6 = (float)Main.mouseY + Main.screenPosition.Y - center.Y;
                         if (y6 < 0f)
                         {
                             y6 = y6 * -1f;
                         }
                         if (y6 < 20f)
                         {
                             y6 = 20f;
                         }
                         single16 = (float)Math.Sqrt((double)(x6 * x6 + y6 * y6));
                         single16 = single14 / single16;
                         x6 = x6 * single16;
                         y6 = y6 * single16;
                         float single38 = x6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                         float single39 = y6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                         Projectile.NewProjectile(center.X, center.Y, single38, single39, num46, num47, single15, i, 0f, (float)Main.rand.Next(5));
                     }
                 }
                 else if (item.type == ItemID.MeteorStaff)
                 {
                     int num58 = 1;
                     for (int h = 0; h < num58; h++)
                     {
                         center = new Vector2(this.position.X + (float)this.width * 0.5f + (float)(Main.rand.Next(201) * -this.direction) + ((float)Main.mouseX + Main.screenPosition.X - this.position.X), this.MountedCenter.Y - 600f)
                         {
                             X = (center.X + base.Center.X) / 2f + (float)Main.rand.Next(-200, 201),
                             Y = center.Y - (float)(100 * h)
                         };
                         x6 = (float)Main.mouseX + Main.screenPosition.X - center.X + (float)Main.rand.Next(-40, 41) * 0.03f;
                         y6 = (float)Main.mouseY + Main.screenPosition.Y - center.Y;
                         if (y6 < 0f)
                         {
                             y6 = y6 * -1f;
                         }
                         if (y6 < 20f)
                         {
                             y6 = 20f;
                         }
                         single16 = (float)Math.Sqrt((double)(x6 * x6 + y6 * y6));
                         single16 = single14 / single16;
                         x6 = x6 * single16;
                         y6 = y6 * single16;
                         float single40 = x6;
                         float single41 = y6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                         Projectile.NewProjectile(center.X, center.Y, single40 * 0.75f, single41 * 0.75f, num46 + Main.rand.Next(3), num47, single15, i, 0f, 0.5f + (float)Main.rand.NextDouble() * 0.3f);
                     }
                 }
                 else if (item.type == ItemID.LunarFlareBook)
                 {
                     int num59 = 3;
                     for (int i11 = 0; i11 < num59; i11++)
                     {
                         center = new Vector2(this.position.X + (float)this.width * 0.5f + (float)(Main.rand.Next(201) * -this.direction) + ((float)Main.mouseX + Main.screenPosition.X - this.position.X), this.MountedCenter.Y - 600f)
                         {
                             X = (center.X + base.Center.X) / 2f + (float)Main.rand.Next(-200, 201),
                             Y = center.Y - (float)(100 * i11)
                         };
                         x6 = (float)Main.mouseX + Main.screenPosition.X - center.X;
                         y6 = (float)Main.mouseY + Main.screenPosition.Y - center.Y;
                         float y9 = y6 + center.Y;
                         if (y6 < 0f)
                         {
                             y6 = y6 * -1f;
                         }
                         if (y6 < 20f)
                         {
                             y6 = 20f;
                         }
                         single16 = (float)Math.Sqrt((double)(x6 * x6 + y6 * y6));
                         single16 = single14 / single16;
                         x6 = x6 * single16;
                         y6 = y6 * single16;
                         Vector2 vector238 = new Vector2(x6, y6) / 2f;
                         Projectile.NewProjectile(center.X, center.Y, vector238.X, vector238.Y, num46, num47, single15, i, 0f, y9);
                     }
                 }
                 else if (item.type == ItemID.StarWrath)
                 {
                     Vector2 vector239 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY);
                     float y10 = vector239.Y;
                     if (y10 > base.Center.Y - 200f)
                     {
                         y10 = base.Center.Y - 200f;
                     }
                     for (int j1 = 0; j1 < 3; j1++)
                     {
                         center = base.Center + new Vector2((float)(-Main.rand.Next(0, 401) * this.direction), -600f);
                         center.Y = center.Y - (float)(100 * j1);
                         Vector2 y11 = vector239 - center;
                         if (y11.Y < 0f)
                         {
                             y11.Y = y11.Y * -1f;
                         }
                         if (y11.Y < 20f)
                         {
                             y11.Y = 20f;
                         }
                         y11.Normalize();
                         y11 = y11 * single14;
                         x6 = y11.X;
                         y6 = y11.Y;
                         float single42 = x6;
                         float single43 = y6 + (float)Main.rand.Next(-40, 41) * 0.02f;
                         Projectile.NewProjectile(center.X, center.Y, single42, single43, num46, num47 * 2, single15, i, 0f, y10);
                     }
                 }
                 else if (item.type == ItemID.Tsunami)
                 {
                     float single44 = 0.314159274f;
                     int num60 = 5;
                     Vector2 vector240 = new Vector2(x6, y6);
                     vector240.Normalize();
                     vector240 = vector240 * 40f;
                     bool flag10 = Collision.CanHit(center, 0, 0, center + vector240, 0, 0);
                     for (int k1 = 0; k1 < num60; k1++)
                     {
                         float single45 = (float)k1 - ((float)num60 - 1f) / 2f;
                         double num61 = (double)(single44 * single45);
                         vector21 = new Vector2();
                         Vector2 vector241 = vector240.RotatedBy(num61, vector21);
                         if (!flag10)
                         {
                             vector241 = vector241 - vector240;
                         }
                         int num62 = Projectile.NewProjectile(center.X + vector241.X, center.Y + vector241.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                         Main.projectile[num62].noDropItem = true;
                     }
                 }
                 else if (item.type == ItemID.ChainGun)
                 {
                     float single46 = x6 + (float)Main.rand.Next(-40, 41) * 0.03f;
                     float single47 = y6 + (float)Main.rand.Next(-40, 41) * 0.03f;
                     Projectile.NewProjectile(center.X, center.Y, single46, single47, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.SDMG)
                 {
                     float single48 = x6 + (float)Main.rand.Next(-40, 41) * 0.005f;
                     float single49 = y6 + (float)Main.rand.Next(-40, 41) * 0.005f;
                     Projectile.NewProjectile(center.X, center.Y, single48, single49, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.CrystalStorm)
                 {
                     float single50 = x6;
                     float single51 = y6;
                     single50 = single50 + (float)Main.rand.Next(-40, 41) * 0.04f;
                     single51 = single51 + (float)Main.rand.Next(-40, 41) * 0.04f;
                     Projectile.NewProjectile(center.X, center.Y, single50, single51, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.Uzi)
                 {
                     float single52 = x6;
                     float single53 = y6;
                     single52 = single52 + (float)Main.rand.Next(-30, 31) * 0.03f;
                     single53 = single53 + (float)Main.rand.Next(-30, 31) * 0.03f;
                     Projectile.NewProjectile(center.X, center.Y, single52, single53, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.Shotgun)
                 {
                     int num63 = Main.rand.Next(4, 6);
                     for (int l1 = 0; l1 < num63; l1++)
                     {
                         float single54 = x6;
                         float single55 = y6;
                         single54 = single54 + (float)Main.rand.Next(-40, 41) * 0.05f;
                         single55 = single55 + (float)Main.rand.Next(-40, 41) * 0.05f;
                         Projectile.NewProjectile(center.X, center.Y, single54, single55, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.VenomStaff)
                 {
                     int num64 = 4;
                     if (Main.rand.Next(3) == 0)
                     {
                         num64++;
                     }
                     if (Main.rand.Next(4) == 0)
                     {
                         num64++;
                     }
                     if (Main.rand.Next(5) == 0)
                     {
                         num64++;
                     }
                     for (int m1 = 0; m1 < num64; m1++)
                     {
                         float single56 = x6;
                         float single57 = y6;
                         float single58 = 0.05f * (float)m1;
                         single56 = single56 + (float)Main.rand.Next(-35, 36) * single58;
                         single57 = single57 + (float)Main.rand.Next(-35, 36) * single58;
                         single16 = (float)Math.Sqrt((double)(single56 * single56 + single57 * single57));
                         single16 = single14 / single16;
                         single56 = single56 * single16;
                         single57 = single57 * single16;
                         float x10 = center.X;
                         float y12 = center.Y;
                         Projectile.NewProjectile(x10, y12, single56, single57, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.PoisonStaff)
                 {
                     int num65 = 3;
                     if (Main.rand.Next(3) == 0)
                     {
                         num65++;
                     }
                     for (int n1 = 0; n1 < num65; n1++)
                     {
                         float single59 = x6;
                         float single60 = y6;
                         float single61 = 0.05f * (float)n1;
                         single59 = single59 + (float)Main.rand.Next(-35, 36) * single61;
                         single60 = single60 + (float)Main.rand.Next(-35, 36) * single61;
                         single16 = (float)Math.Sqrt((double)(single59 * single59 + single60 * single60));
                         single16 = single14 / single16;
                         single59 = single59 * single16;
                         single60 = single60 * single16;
                         float x11 = center.X;
                         float y13 = center.Y;
                         Projectile.NewProjectile(x11, y13, single59, single60, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.Stynger)
                 {
                     float single62 = x6;
                     float single63 = y6;
                     single62 = single62 + (float)Main.rand.Next(-40, 41) * 0.01f;
                     single63 = single63 + (float)Main.rand.Next(-40, 41) * 0.01f;
                     center.X = center.X + (float)Main.rand.Next(-40, 41) * 0.05f;
                     center.Y = center.Y + (float)Main.rand.Next(-45, 36) * 0.05f;
                     Projectile.NewProjectile(center.X, center.Y, single62, single63, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.Boomstick)
                 {
                     int num66 = Main.rand.Next(3, 5);
                     for (int o1 = 0; o1 < num66; o1++)
                     {
                         float single64 = x6;
                         float single65 = y6;
                         single64 = single64 + (float)Main.rand.Next(-35, 36) * 0.04f;
                         single65 = single65 + (float)Main.rand.Next(-35, 36) * 0.04f;
                         Projectile.NewProjectile(center.X, center.Y, single64, single65, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.VampireKnives)
                 {
                     int num67 = 4;
                     if (Main.rand.Next(2) == 0)
                     {
                         num67++;
                     }
                     if (Main.rand.Next(4) == 0)
                     {
                         num67++;
                     }
                     if (Main.rand.Next(8) == 0)
                     {
                         num67++;
                     }
                     if (Main.rand.Next(16) == 0)
                     {
                         num67++;
                     }
                     for (int p1 = 0; p1 < num67; p1++)
                     {
                         float single66 = x6;
                         float single67 = y6;
                         float single68 = 0.05f * (float)p1;
                         single66 = single66 + (float)Main.rand.Next(-35, 36) * single68;
                         single67 = single67 + (float)Main.rand.Next(-35, 36) * single68;
                         single16 = (float)Math.Sqrt((double)(single66 * single66 + single67 * single67));
                         single16 = single14 / single16;
                         single66 = single66 * single16;
                         single67 = single67 * single16;
                         float x12 = center.X;
                         float y14 = center.Y;
                         Projectile.NewProjectile(x12, y14, single66, single67, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.StaffoftheFrostHydra || item.type == ItemID.QueenSpiderStaff || item.type == ItemID.RainbowCrystalStaff || item.type == ItemID.MoonlordTurretStaff)
                 {
                     int num68 = item.shoot;
                     for (int q1 = 0; q1 < 1000; q1++)
                     {
                         if (Main.projectile[q1].owner == this.whoAmI && Main.projectile[q1].type == num68)
                         {
                             Main.projectile[q1].Kill();
                         }
                     }
                     bool flag11 = (item.type == ItemID.RainbowCrystalStaff ? true : item.type == ItemID.MoonlordTurretStaff);
                     int x13 = (int)((float)Main.mouseX + Main.screenPosition.X) / 16;
                     int y15 = (int)((float)Main.mouseY + Main.screenPosition.Y) / 16;
                     if (this.gravDir == -1f)
                     {
                         y15 = (int)(Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY) / 16;
                     }
                     if (!flag11)
                     {
                         while (y15 < Main.maxTilesY - 10 && Main.tile[x13, y15] != null && !WorldGen.SolidTile2(x13, y15) && Main.tile[x13 - 1, y15] != null && !WorldGen.SolidTile2(x13 - 1, y15) && Main.tile[x13 + 1, y15] != null && !WorldGen.SolidTile2(x13 + 1, y15))
                         {
                             y15++;
                         }
                         y15--;
                     }
                     Projectile.NewProjectile((float)Main.mouseX + Main.screenPosition.X, (float)(y15 * 16 - 24), 0f, 15f, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.NimbusRod || item.type == ItemID.CrimsonRod)
                 {
                     int num69 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                     Main.projectile[num69].ai[0] = (float)Main.mouseX + Main.screenPosition.X;
                     Main.projectile[num69].ai[1] = (float)Main.mouseY + Main.screenPosition.Y;
                 }
                 else if (item.type == ItemID.ChlorophyteShotbow)
                 {
                     int num70 = Main.rand.Next(2, 4);
                     if (Main.rand.Next(5) == 0)
                     {
                         num70++;
                     }
                     for (int r1 = 0; r1 < num70; r1++)
                     {
                         float single69 = x6;
                         float single70 = y6;
                         if (r1 > 0)
                         {
                             single69 = single69 + (float)Main.rand.Next(-35, 36) * 0.04f;
                             single70 = single70 + (float)Main.rand.Next(-35, 36) * 0.04f;
                         }
                         if (r1 > 1)
                         {
                             single69 = single69 + (float)Main.rand.Next(-35, 36) * 0.04f;
                             single70 = single70 + (float)Main.rand.Next(-35, 36) * 0.04f;
                         }
                         if (r1 > 2)
                         {
                             single69 = single69 + (float)Main.rand.Next(-35, 36) * 0.04f;
                             single70 = single70 + (float)Main.rand.Next(-35, 36) * 0.04f;
                         }
                         int num71 = Projectile.NewProjectile(center.X, center.Y, single69, single70, num46, num47, single15, i, 0f, 0f);
                         Main.projectile[num71].noDropItem = true;
                     }
                 }
                 else if (item.type == ItemID.BeeGun)
                 {
                     int num72 = Main.rand.Next(1, 4);
                     if (Main.rand.Next(6) == 0)
                     {
                         num72++;
                     }
                     if (Main.rand.Next(6) == 0)
                     {
                         num72++;
                     }
                     if (this.strongBees && Main.rand.Next(3) == 0)
                     {
                         num72++;
                     }
                     for (int s1 = 0; s1 < num72; s1++)
                     {
                         float single71 = x6;
                         float single72 = y6;
                         single71 = single71 + (float)Main.rand.Next(-35, 36) * 0.02f;
                         single72 = single72 + (float)Main.rand.Next(-35, 36) * 0.02f;
                         Projectile.NewProjectile(center.X, center.Y, single71, single72, this.beeType(), this.beeDamage(num47), this.beeKB(single15), i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.WaspGun)
                 {
                     int num73 = Main.rand.Next(2, 5);
                     if (Main.rand.Next(5) == 0)
                     {
                         num73++;
                     }
                     if (Main.rand.Next(5) == 0)
                     {
                         num73++;
                     }
                     for (int t1 = 0; t1 < num73; t1++)
                     {
                         float single73 = x6;
                         float single74 = y6;
                         single73 = single73 + (float)Main.rand.Next(-35, 36) * 0.02f;
                         single74 = single74 + (float)Main.rand.Next(-35, 36) * 0.02f;
                         Projectile.NewProjectile(center.X, center.Y, single73, single74, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.BatScepter)
                 {
                     int num74 = Main.rand.Next(1, 4);
                     for (int u1 = 0; u1 < num74; u1++)
                     {
                         float single75 = x6;
                         float single76 = y6;
                         single75 = single75 + (float)Main.rand.Next(-35, 36) * 0.05f;
                         single76 = single76 + (float)Main.rand.Next(-35, 36) * 0.05f;
                         Projectile.NewProjectile(center.X, center.Y, single75, single76, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.TacticalShotgun)
                 {
                     for (int v1 = 0; v1 < 6; v1++)
                     {
                         float single77 = x6;
                         float single78 = y6;
                         single77 = single77 + (float)Main.rand.Next(-40, 41) * 0.05f;
                         single78 = single78 + (float)Main.rand.Next(-40, 41) * 0.05f;
                         Projectile.NewProjectile(center.X, center.Y, single77, single78, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.BubbleGun)
                 {
                     for (int w1 = 0; w1 < 3; w1++)
                     {
                         float single79 = x6;
                         float single80 = y6;
                         single79 = single79 + (float)Main.rand.Next(-40, 41) * 0.1f;
                         single80 = single80 + (float)Main.rand.Next(-40, 41) * 0.1f;
                         Projectile.NewProjectile(center.X, center.Y, single79, single80, num46, num47, single15, i, 0f, 0f);
                     }
                 }
                 else if (item.type == ItemID.Toxikarp)
                 {
                     Vector2 x14 = new Vector2(x6, y6);
                     x14.Normalize();
                     x14 = x14 * ((float)Main.rand.Next(70, 91) * 0.1f);
                     x14.X = x14.X + (float)Main.rand.Next(-30, 31) * 0.04f;
                     x14.Y = x14.Y + (float)Main.rand.Next(-30, 31) * 0.03f;
                     Projectile.NewProjectile(center.X, center.Y, x14.X, x14.Y, num46, num47, single15, i, (float)Main.rand.Next(20), 0f);
                 }
                 else if (item.type == ItemID.ClockworkAssaultRifle)
                 {
                     float single81 = x6;
                     float single82 = y6;
                     if (this.itemAnimation < 5)
                     {
                         single81 = single81 + (float)Main.rand.Next(-40, 41) * 0.01f;
                         single82 = single82 + (float)Main.rand.Next(-40, 41) * 0.01f;
                         single81 = single81 * 1.1f;
                         single82 = single82 * 1.1f;
                     }
                     else if (this.itemAnimation < 10)
                     {
                         single81 = single81 + (float)Main.rand.Next(-20, 21) * 0.01f;
                         single82 = single82 + (float)Main.rand.Next(-20, 21) * 0.01f;
                         single81 = single81 * 1.05f;
                         single82 = single82 * 1.05f;
                     }
                     Projectile.NewProjectile(center.X, center.Y, single81, single82, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.PygmyStaff)
                 {
                     num46 = Main.rand.Next(191, 195);
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     int num75 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                     Main.projectile[num75].localAI[0] = 30f;
                 }
                 else if (item.type == ItemID.RavenStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.HornetStaff || item.type == ItemID.ImpStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.OpticStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Vector2 vector242 = new Vector2(x6, y6);
                     vector21 = new Vector2();
                     vector242 = vector242.RotatedBy(1.57079637050629, vector21);
                     Projectile.NewProjectile(center.X + vector242.X, center.Y + vector242.Y, vector242.X, vector242.Y, num46, num47, single15, i, 0f, 0f);
                     vector21 = new Vector2();
                     vector242 = vector242.RotatedBy(-3.14159274101257, vector21);
                     Projectile.NewProjectile(center.X + vector242.X, center.Y + vector242.Y, vector242.X, vector242.Y, num46 + 1, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.SpiderStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46 + Main.rand.Next(3), num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.PirateStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46 + Main.rand.Next(3), num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.TempestStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.XenoStaff || item.type == ItemID.DeadlySphereStaff || item.type == ItemID.StardustCellStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.StardustDragonStaff)
                 {
                     int num76 = -1;
                     int num77 = -1;
                     for (int x15 = 0; x15 < 1000; x15++)
                     {
                         if (Main.projectile[x15].active && Main.projectile[x15].owner == Main.myPlayer)
                         {
                             if (num76 == -1 && Main.projectile[x15].type == ProjectileID.StardustDragon1)
                             {
                                 num76 = x15;
                             }
                             if (num77 == -1 && Main.projectile[x15].type == ProjectileID.StardustDragon4)
                             {
                                 num77 = x15;
                             }
                             if (num76 != -1 && num77 != -1)
                             {
                                 break;
                             }
                         }
                     }
                     if (num76 == -1 && num77 == -1)
                     {
                         x6 = 0f;
                         y6 = 0f;
                         center.X = (float)Main.mouseX + Main.screenPosition.X;
                         center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                         int num78 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                         num78 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46 + 1, num47, single15, i, (float)num78, 0f);
                         int num79 = num78;
                         num78 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46 + 2, num47, single15, i, (float)num78, 0f);
                         Main.projectile[num79].localAI[1] = (float)num78;
                         num79 = num78;
                         num78 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46 + 3, num47, single15, i, (float)num78, 0f);
                         Main.projectile[num79].localAI[1] = (float)num78;
                     }
                     else if (num76 != -1 && num77 != -1)
                     {
                         int num80 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46 + 1, num47, single15, i, Main.projectile[num77].ai[0], 0f);
                         int num81 = num80;
                         num80 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46 + 2, num47, single15, i, (float)num80, 0f);
                         Main.projectile[num81].localAI[1] = (float)num80;
                         Main.projectile[num81].netUpdate = true;
                         Main.projectile[num81].ai[1] = 1f;
                         Main.projectile[num80].localAI[1] = (float)num77;
                         Main.projectile[num80].netUpdate = true;
                         Main.projectile[num80].ai[1] = 1f;
                         Main.projectile[num77].ai[0] = (float)Main.projectile[num80].projUUID;
                         Main.projectile[num77].netUpdate = true;
                         Main.projectile[num77].ai[1] = 1f;
                     }
                 }
                 else if (item.type == ItemID.SlimeStaff)
                 {
                     x6 = 0f;
                     y6 = 0f;
                     center.X = (float)Main.mouseX + Main.screenPosition.X;
                     center.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.shoot > 0 && (Main.projPet[item.shoot] || item.shoot == 72 || item.shoot == 18 || item.shoot == 500 || item.shoot == 650) && !item.summon)
                 {
                     for (int y16 = 0; y16 < 1000; y16++)
                     {
                         if (Main.projectile[y16].active && Main.projectile[y16].owner == this.whoAmI)
                         {
                             if (item.shoot == 72)
                             {
                                 if (Main.projectile[y16].type == ProjectileID.BlueFairy || Main.projectile[y16].type == ProjectileID.PinkFairy || Main.projectile[y16].type == ProjectileID.GreenFairy)
                                 {
                                     Main.projectile[y16].Kill();
                                 }
                             }
                             else if (item.shoot == Main.projectile[y16].type)
                             {
                                 Main.projectile[y16].Kill();
                             }
                         }
                     }
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.SoulDrain)
                 {
                     vector2.X = (float)Main.mouseX + Main.screenPosition.X;
                     vector2.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     while (Collision.CanHitLine(this.position, this.width, this.height, center, 1, 1))
                     {
                         center.X = center.X + x6;
                         center.Y = center.Y + y6;
                         if ((center - vector2).Length() >= 20f + Math.Abs(x6) + Math.Abs(y6))
                         {
                             continue;
                         }
                         center = vector2;
                         break;
                     }
                     Projectile.NewProjectile(center.X, center.Y, 0f, 0f, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.ClingerStaff)
                 {
                     x.X = (float)Main.mouseX + Main.screenPosition.X;
                     x.Y = (float)Main.mouseY + Main.screenPosition.Y;
                     while (Collision.CanHitLine(this.position, this.width, this.height, center, 1, 1))
                     {
                         center.X = center.X + x6;
                         center.Y = center.Y + y6;
                         if ((center - x).Length() >= 20f + Math.Abs(x6) + Math.Abs(y6))
                         {
                             continue;
                         }
                         center = x;
                         break;
                     }
                     bool flag12 = false;
                     int y17 = (int)center.Y / 16;
                     int x16 = (int)center.X / 16;
                     int num82 = y17;
                     while (y17 < Main.maxTilesY - 10 && y17 - num82 < 30 && !WorldGen.SolidTile(x16, y17))
                     {
                         y17++;
                     }
                     if (!WorldGen.SolidTile(x16, y17))
                     {
                         flag12 = true;
                     }
                     float single83 = (float)(y17 * 16);
                     y17 = num82;
                     while (y17 > 10 && num82 - y17 < 30 && !WorldGen.SolidTile(x16, y17))
                     {
                         y17--;
                     }
                     float single84 = (float)(y17 * 16 + 16);
                     float single85 = single83 - single84;
                     int num83 = 10;
                     if (single85 > (float)(16 * num83))
                     {
                         single85 = (float)(16 * num83);
                     }
                     single84 = single83 - single85;
                     center.X = (float)((int)(center.X / 16f) * 16);
                     if (!flag12)
                     {
                         Projectile.NewProjectile(center.X, center.Y, 0f, 0f, num46, num47, single15, i, single84, single85);
                     }
                 }
                 else if (item.type == ItemID.PortalGun)
                 {
                     int num84 = (this.altFunctionUse == 2 ? 1 : 0);
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, (float)num84);
                 }
                 else if (item.type == ItemID.SolarEruption)
                 {
                     float single86 = (Main.rand.NextFloat() - 0.5f) * 0.7853982f;
                     Vector2 vector243 = new Vector2(x6, y6);
                     Projectile.NewProjectile(center.X, center.Y, vector243.X, vector243.Y, num46, num47, single15, i, 0f, single86);
                 }
                 else if (item.type == ItemID.NebulaBlaze)
                 {
                     float single87 = (Main.rand.NextFloat() - 0.5f) * 0.7853982f;
                     for (int a1 = 0; a1 < 10; a1++)
                     {
                         Vector2 vector244 = new Vector2(x6, y6);
                         double num85 = (double)single87;
                         vector21 = new Vector2();
                         if (Collision.CanHit(center, 0, 0, center + (vector244.RotatedBy(num85, vector21) * 100f), 0, 0))
                         {
                             break;
                         }
                         single87 = (Main.rand.NextFloat() - 0.5f) * 0.7853982f;
                     }
                     Vector2 vector245 = new Vector2(x6, y6);
                     double num86 = (double)single87;
                     vector21 = new Vector2();
                     Vector2 vector246 = vector245.RotatedBy(num86, vector21) * (0.85f + Main.rand.NextFloat() * 0.3f);
                     Projectile.NewProjectile(center.X, center.Y, vector246.X, vector246.Y, num46, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.VortexBeater)
                 {
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, 615, num47, single15, i, (float)(5 * Main.rand.Next(0, 20)), 0f);
                 }
                 else if (item.type == ItemID.Phantasm)
                 {
                     Projectile.NewProjectile(center.X, center.Y, x6, y6, 630, num47, single15, i, 0f, 0f);
                 }
                 else if (item.type == ItemID.FireworksLauncher)
                 {
                     for (int b1 = 0; b1 < 2; b1++)
                     {
                         float single88 = x6;
                         float single89 = y6;
                         single88 = single88 + (float)Main.rand.Next(-40, 41) * 0.05f;
                         single89 = single89 + (float)Main.rand.Next(-40, 41) * 0.05f;
                         Vector2 vector247 = new Vector2(single88, single89);
                         double num87 = (double)(-1.57079637f * (float)this.direction);
                         vector21 = new Vector2();
                         Vector2 vector248 = center + (Vector2.Normalize(vector247.RotatedBy(num87, vector21)) * 6f);
                         Projectile.NewProjectile(vector248.X, vector248.Y, single88, single89, 167 + Main.rand.Next(4), num47, single15, i, 0f, 1f);
                     }
                 }
                 else if (item.type != ItemID.PainterPaintballGun)
                 {
                     int num88 = Projectile.NewProjectile(center.X, center.Y, x6, y6, num46, num47, single15, i, 0f, 0f);
                     if (item.type == ItemID.FrostStaff)
                     {
                         Main.projectile[num88].magic = true;
                     }
                     if (item.type == ItemID.IceBlade || item.type == ItemID.Frostbrand)
                     {
                         Main.projectile[num88].melee = true;
                     }
                     if (num46 == 80)
                     {
                         Main.projectile[num88].ai[0] = (float)Player.tileTargetX;
                         Main.projectile[num88].ai[1] = (float)Player.tileTargetY;
                     }
                     if (num46 == 442)
                     {
                         Main.projectile[num88].ai[0] = (float)Player.tileTargetX;
                         Main.projectile[num88].ai[1] = (float)Player.tileTargetY;
                     }
                     if ((this.thrownCost50 || this.thrownCost33) && this.inventory[this.selectedItem].thrown)
                     {
                         Main.projectile[num88].noDropItem = true;
                     }
                     if (Main.projectile[num88].aiStyle == 99)
                     {
                         AchievementsHelper.HandleSpecialEvent(this, 7);
                     }
                 }
                 else
                 {
                     float single90 = x6;
                     float single91 = y6;
                     single90 = single90 + (float)Main.rand.Next(-1, 2) * 0.5f;
                     single91 = single91 + (float)Main.rand.Next(-1, 2) * 0.5f;
                     if (Collision.CanHitLine(base.Center, 0, 0, center + (new Vector2(single90, single91) * 2f), 0, 0))
                     {
                         center = center + new Vector2(single90, single91);
                     }
                     Projectile.NewProjectile(center.X, center.Y - this.gravDir * 4f, single90, single91, num46, num47, single15, i, 0f, (float)Main.rand.Next(12) / 6f);
                 }
             }
             else if (item.useStyle == 5)
             {
                 this.itemRotation = 0f;
                 NetMessage.SendData((int)PacketTypes.PlayerAnimation, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
             }
         }
         if (this.whoAmI == Main.myPlayer && (item.type == ItemID.Wrench || item.type == ItemID.WireCutter || item.type == ItemID.Actuator || item.type == ItemID.BlueWrench || item.type == ItemID.GreenWrench) && this.position.X / 16f - (float)Player.tileRangeX - (float)item.tileBoost - (float)this.blockRange <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)item.tileBoost - 1f + (float)this.blockRange >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)item.tileBoost - (float)this.blockRange <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)item.tileBoost - 2f + (float)this.blockRange >= (float)Player.tileTargetY)
         {
             this.showItemIcon = true;
             if (this.itemAnimation > 0 && this.itemTime == 0 && this.controlUseItem)
             {
                 int num89 = Player.tileTargetX;
                 int num90 = Player.tileTargetY;
                 if (item.type == ItemID.Wrench)
                 {
                     int num91 = -1;
                     int num92 = 0;
                     while (num92 < 58)
                     {
                         if (this.inventory[num92].stack <= 0 || this.inventory[num92].type != 530)
                         {
                             num92++;
                         }
                         else
                         {
                             num91 = num92;
                             break;
                         }
                     }
                     if (num91 >= 0 && WorldGen.PlaceWire(num89, num90))
                     {
                         Item item8 = this.inventory[num91];
                         item8.stack = item8.stack - 1;
                         if (this.inventory[num91].stack <= 0)
                         {
                             this.inventory[num91].SetDefaults(0, false);
                         }
                         this.itemTime = item.useTime;
                         NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 5, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                     }
                 }
                 else if (item.type == ItemID.BlueWrench)
                 {
                     int num93 = -1;
                     int num94 = 0;
                     while (num94 < 58)
                     {
                         if (this.inventory[num94].stack <= 0 || this.inventory[num94].type != 530)
                         {
                             num94++;
                         }
                         else
                         {
                             num93 = num94;
                             break;
                         }
                     }
                     if (num93 >= 0 && WorldGen.PlaceWire2(num89, num90))
                     {
                         Item item9 = this.inventory[num93];
                         item9.stack = item9.stack - 1;
                         if (this.inventory[num93].stack <= 0)
                         {
                             this.inventory[num93].SetDefaults(0, false);
                         }
                         this.itemTime = item.useTime;
                         NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 10, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                     }
                 }
                 if (item.type == ItemID.GreenWrench)
                 {
                     int num95 = -1;
                     int num96 = 0;
                     while (num96 < 58)
                     {
                         if (this.inventory[num96].stack <= 0 || this.inventory[num96].type != 530)
                         {
                             num96++;
                         }
                         else
                         {
                             num95 = num96;
                             break;
                         }
                     }
                     if (num95 >= 0 && WorldGen.PlaceWire3(num89, num90))
                     {
                         Item item10 = this.inventory[num95];
                         item10.stack = item10.stack - 1;
                         if (this.inventory[num95].stack <= 0)
                         {
                             this.inventory[num95].SetDefaults(0, false);
                         }
                         this.itemTime = item.useTime;
                         NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 12, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                     }
                 }
                 else if (item.type != ItemID.WireCutter)
                 {
                     if (item.type == ItemID.Actuator && item.stack > 0 && WorldGen.PlaceActuator(num89, num90))
                     {
                         this.itemTime = item.useTime;
                         NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 8, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                         Item item11 = item;
                         item11.stack = item11.stack - 1;
                         if (item.stack <= 0)
                         {
                             item.SetDefaults(0, false);
                         }
                     }
                 }
                 else if (WorldGen.KillActuator(num89, num90))
                 {
                     this.itemTime = item.useTime;
                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 9, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                 }
                 else if (WorldGen.KillWire3(num89, num90))
                 {
                     this.itemTime = item.useTime;
                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 13, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                 }
                 else if (WorldGen.KillWire2(num89, num90))
                 {
                     this.itemTime = item.useTime;
                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 11, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                 }
                 else if (WorldGen.KillWire(num89, num90))
                 {
                     this.itemTime = item.useTime;
                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 6, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                 }
             }
         }
         if (this.itemAnimation > 0 && this.itemTime == 0 && (item.type == ItemID.Bell || item.type == ItemID.Harp))
         {
             this.itemTime = item.useTime;
             Vector2 vector249 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
             float x17 = (float)Main.mouseX + Main.screenPosition.X - vector249.X;
             float y18 = (float)Main.mouseY + Main.screenPosition.Y - vector249.Y;
             float single92 = (float)Math.Sqrt((double)(x17 * x17 + y18 * y18));
             single92 = single92 / (float)(Main.screenHeight / 2);
             if (single92 > 1f)
             {
                 single92 = 1f;
             }
             single92 = single92 * 2f - 1f;
             if (single92 < -1f)
             {
                 single92 = -1f;
             }
             if (single92 > 1f)
             {
                 single92 = 1f;
             }
             Main.harpNote = single92;
             NetMessage.SendData((int)PacketTypes.PlayHarp, -1, -1, "", this.whoAmI, single92, 0f, 0f, 0, 0, 0);
         }
         if ((item.type >= ItemID.EmptyBucket && item.type <= ItemID.LavaBucket || item.type == ItemID.HoneyBucket || item.type == ItemID.BottomlessBucket || item.type == ItemID.SuperAbsorbantSponge) && this.position.X / 16f - (float)Player.tileRangeX - (float)item.tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)item.tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)item.tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)item.tileBoost - 2f >= (float)Player.tileTargetY)
         {
             this.showItemIcon = true;
             if (this.itemTime == 0 && this.itemAnimation > 0 && this.controlUseItem)
             {
                 if (item.type == ItemID.EmptyBucket || item.type == ItemID.SuperAbsorbantSponge && Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() == 0)
                 {
                     int num98 = Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType();
                     int num99 = 0;
                     for (int c1 = Player.tileTargetX - 1; c1 <= Player.tileTargetX + 1; c1++)
                     {
                         for (int d1 = Player.tileTargetY - 1; d1 <= Player.tileTargetY + 1; d1++)
                         {
                             if (Main.tile[c1, d1].liquidType() == num98)
                             {
                                 num99 = num99 + Main.tile[c1, d1].liquid;
                             }
                         }
                     }
                     if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid > 0 && (num99 > 100 || item.type == ItemID.SuperAbsorbantSponge))
                     {
                         int num100 = Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType();
                         if (item.type != ItemID.SuperAbsorbantSponge)
                         {
                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].lava())
                             {
                                 Item item12 = item;
                                 item12.stack = item12.stack - 1;
                                 this.PutItemInInventory(207, this.selectedItem);
                             }
                             else if (!Main.tile[Player.tileTargetX, Player.tileTargetY].honey())
                             {
                                 Item item13 = item;
                                 item13.stack = item13.stack - 1;
                                 this.PutItemInInventory(206, this.selectedItem);
                             }
                             else
                             {
                                 Item item14 = item;
                                 item14.stack = item14.stack - 1;
                                 this.PutItemInInventory(1128, this.selectedItem);
                             }
                         }
                         this.itemTime = item.useTime;
                         int num101 = Main.tile[Player.tileTargetX, Player.tileTargetY].liquid;
                         Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = 0;
                         Main.tile[Player.tileTargetX, Player.tileTargetY].lava(false);
                         Main.tile[Player.tileTargetX, Player.tileTargetY].honey(false);
                         WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, false);
                         if (Main.netMode != 1)
                         {
                             Liquid.AddWater(Player.tileTargetX, Player.tileTargetY);
                         }
                         else
                         {
                             NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
                         }
                         for (int e1 = Player.tileTargetX - 1; e1 <= Player.tileTargetX + 1; e1++)
                         {
                             for (int f1 = Player.tileTargetY - 1; f1 <= Player.tileTargetY + 1; f1++)
                             {
                                 if (num101 < 256 && Main.tile[e1, f1].liquidType() == num98)
                                 {
                                     int num102 = Main.tile[e1, f1].liquid;
                                     if (num102 + num101 > 255)
                                     {
                                         num102 = 255 - num101;
                                     }
                                     num101 = num101 + num102;
                                     Tile tile1 = Main.tile[e1, f1];
                                     tile1.liquid = (byte)(tile1.liquid - (byte)num102);
                                     Main.tile[e1, f1].liquidType(num100);
                                     if (Main.tile[e1, f1].liquid == 0)
                                     {
                                         Main.tile[e1, f1].lava(false);
                                         Main.tile[e1, f1].honey(false);
                                     }
                                     WorldGen.SquareTileFrame(e1, f1, false);
                                     if (Main.netMode != 1)
                                     {
                                         Liquid.AddWater(e1, f1);
                                     }
                                     else
                                     {
                                         NetMessage.sendWater(e1, f1);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 else if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid < 200 && (!Main.tile[Player.tileTargetX, Player.tileTargetY].nactive() || !Main.tileSolid[Main.tile[Player.tileTargetX, Player.tileTargetY].type] || Main.tileSolidTop[Main.tile[Player.tileTargetX, Player.tileTargetY].type]))
                 {
                     if (item.type == ItemID.LavaBucket)
                     {
                         if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid == 0 || Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() == 1)
                         {
                             Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(1);
                             Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = 255;
                             WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, true);
                             Item item15 = item;
                             item15.stack = item15.stack - 1;
                             this.PutItemInInventory(205, this.selectedItem);
                             this.itemTime = item.useTime;
                             if (Main.netMode == 1)
                             {
                                 NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
                             }
                         }
                     }
                     else if (item.type != ItemID.WaterBucket && item.type != ItemID.BottomlessBucket)
                     {
                         if (item.type == ItemID.HoneyBucket && (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid == 0 || Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() == 2))
                         {
                             Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(2);
                             Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = 255;
                             WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, true);
                             Item item16 = item;
                             item16.stack = item16.stack - 1;
                             this.PutItemInInventory(205, this.selectedItem);
                             this.itemTime = item.useTime;
                             if (Main.netMode == 1)
                             {
                                 NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
                             }
                         }
                     }
                     else if (Main.tile[Player.tileTargetX, Player.tileTargetY].liquid == 0 || Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType() == 0)
                     {
                         Main.tile[Player.tileTargetX, Player.tileTargetY].liquidType(0);
                         Main.tile[Player.tileTargetX, Player.tileTargetY].liquid = 255;
                         WorldGen.SquareTileFrame(Player.tileTargetX, Player.tileTargetY, true);
                         if (item.type != ItemID.BottomlessBucket)
                         {
                             Item item17 = item;
                             item17.stack = item17.stack - 1;
                             this.PutItemInInventory(205, this.selectedItem);
                         }
                         this.itemTime = item.useTime;
                         if (Main.netMode == 1)
                         {
                             NetMessage.sendWater(Player.tileTargetX, Player.tileTargetY);
                         }
                     }
                 }
             }
         }
         if (this.channel)
         {
             Player player7 = this;
             player7.toolTime = player7.toolTime - 1;
             if (this.toolTime < 0)
             {
                 if (item.pick <= 0)
                 {
                     this.toolTime = (int)((float)item.useTime * this.pickSpeed);
                 }
                 else
                 {
                     this.toolTime = item.useTime;
                 }
             }
         }
         else
         {
             this.toolTime = this.itemTime;
         }
         if ((item.pick > 0 || item.axe > 0 || item.hammer > 0) && this.position.X / 16f - (float)Player.tileRangeX - (float)item.tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)item.tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)item.tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)item.tileBoost - 2f >= (float)Player.tileTargetY)
         {
             int num103 = -1;
             int num104 = 0;
             bool flag13 = true;
             this.showItemIcon = true;
             if (this.toolTime == 0 && this.itemAnimation > 0 && this.controlUseItem && (!Main.tile[Player.tileTargetX, Player.tileTargetY].active() || !Main.tileHammer[Main.tile[Player.tileTargetX, Player.tileTargetY].type] && !Main.tileSolid[Main.tile[Player.tileTargetX, Player.tileTargetY].type] && Main.tile[Player.tileTargetX, Player.tileTargetY].type != 314 && Main.tile[Player.tileTargetX, Player.tileTargetY].type != 351))
             {
                 this.poundRelease = false;
             }
             if (Main.tile[Player.tileTargetX, Player.tileTargetY].active())
             {
                 if (item.pick > 0 && !Main.tileAxe[Main.tile[Player.tileTargetX, Player.tileTargetY].type] && !Main.tileHammer[Main.tile[Player.tileTargetX, Player.tileTargetY].type] || item.axe > 0 && Main.tileAxe[Main.tile[Player.tileTargetX, Player.tileTargetY].type] || item.hammer > 0 && Main.tileHammer[Main.tile[Player.tileTargetX, Player.tileTargetY].type])
                 {
                     flag13 = false;
                 }
                 if (this.toolTime == 0 && this.itemAnimation > 0 && this.controlUseItem)
                 {
                     num103 = this.hitTile.HitObject(Player.tileTargetX, Player.tileTargetY, 1);
                     if (Main.tileNoFail[Main.tile[Player.tileTargetX, Player.tileTargetY].type])
                     {
                         num104 = 100;
                     }
                     if (Main.tileHammer[Main.tile[Player.tileTargetX, Player.tileTargetY].type])
                     {
                         flag13 = false;
                         if (item.hammer > 0)
                         {
                             num104 = num104 + item.hammer;
                             if (!WorldGen.CanKillTile(Player.tileTargetX, Player.tileTargetY))
                             {
                                 num104 = 0;
                             }
                             if (Main.tile[Player.tileTargetX, Player.tileTargetY].type == 26 && (item.hammer < 80 || !Main.hardMode))
                             {
                                 num104 = 0;
                                 this.Hurt(this.statLife / 2, -this.direction, false, false, Lang.deathMsg(-1, -1, -1, 4), false);
                             }
                             AchievementsHelper.CurrentlyMining = true;
                             if (this.hitTile.AddDamage(num103, num104, true) < 100)
                             {
                                 WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, false, false);
                                 if (Main.netMode == 1)
                                 {
                                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f, 0, 0, 0);
                                 }
                             }
                             else
                             {
                                 this.hitTile.Clear(num103);
                                 WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, false, false, false);
                                 if (Main.netMode == 1)
                                 {
                                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                                 }
                             }
                             if (num104 != 0)
                             {
                                 this.hitTile.Prune();
                             }
                             this.itemTime = item.useTime;
                             AchievementsHelper.CurrentlyMining = false;
                         }
                     }
                     else if (Main.tileAxe[Main.tile[Player.tileTargetX, Player.tileTargetY].type])
                     {
                         num104 = (Main.tile[Player.tileTargetX, Player.tileTargetY].type != 80 ? num104 + item.axe : num104 + item.axe * 3);
                         if (item.axe > 0)
                         {
                             AchievementsHelper.CurrentlyMining = true;
                             if (!WorldGen.CanKillTile(Player.tileTargetX, Player.tileTargetY))
                             {
                                 num104 = 0;
                             }
                             if (this.hitTile.AddDamage(num103, num104, true) < 100)
                             {
                                 WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, false, false);
                                 if (Main.netMode == 1)
                                 {
                                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f, 0, 0, 0);
                                 }
                             }
                             else
                             {
                                 this.hitTile.Clear(num103);
                                 WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, false, false, false);
                                 if (Main.netMode == 1)
                                 {
                                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)Player.tileTargetX, (float)Player.tileTargetY, 0f, 0, 0, 0);
                                 }
                             }
                             if (num104 != 0)
                             {
                                 this.hitTile.Prune();
                             }
                             this.itemTime = item.useTime;
                             AchievementsHelper.CurrentlyMining = false;
                         }
                     }
                     else if (item.pick > 0)
                     {
                         this.PickTile(Player.tileTargetX, Player.tileTargetY, item.pick);
                         this.itemTime = (int)((float)item.useTime * this.pickSpeed);
                     }
                     if (item.pick > 0)
                     {
                         this.itemTime = (int)((float)item.useTime * this.pickSpeed);
                     }
                     if (item.hammer <= 0 || !Main.tile[Player.tileTargetX, Player.tileTargetY].active() || (!Main.tileSolid[Main.tile[Player.tileTargetX, Player.tileTargetY].type] || Main.tile[Player.tileTargetX, Player.tileTargetY].type == 10) && Main.tile[Player.tileTargetX, Player.tileTargetY].type != 314 && Main.tile[Player.tileTargetX, Player.tileTargetY].type != 351 || !this.poundRelease)
                     {
                         this.poundRelease = false;
                     }
                     else
                     {
                         flag13 = false;
                         this.itemTime = item.useTime;
                         num104 = num104 + (int)((double)item.hammer * 1.25);
                         num104 = 100;
                         if (Main.tile[Player.tileTargetX, Player.tileTargetY - 1].active() && Main.tile[Player.tileTargetX, Player.tileTargetY - 1].type == 10)
                         {
                             num104 = 0;
                         }
                         if (Main.tile[Player.tileTargetX, Player.tileTargetY + 1].active() && Main.tile[Player.tileTargetX, Player.tileTargetY + 1].type == 10)
                         {
                             num104 = 0;
                         }
                         if (this.hitTile.AddDamage(num103, num104, true) < 100)
                         {
                             WorldGen.KillTile(Player.tileTargetX, Player.tileTargetY, true, true, false);
                         }
                         else
                         {
                             this.hitTile.Clear(num103);
                             if (this.poundRelease)
                             {
                                 int num105 = Player.tileTargetX;
                                 int num106 = Player.tileTargetY;
                                 if (Main.tile[num105, num106].type == TileID.Platforms)
                                 {
                                     if (!Main.tile[num105, num106].halfBrick())
                                     {
                                         int num107 = 1;
                                         int num108 = 2;
                                         if (Main.tile[num105 + 1, num106 - 1].type == 19 || Main.tile[num105 - 1, num106 + 1].type == 19 || WorldGen.SolidTile(num105 + 1, num106) && !WorldGen.SolidTile(num105 - 1, num106))
                                         {
                                             num107 = 2;
                                             num108 = 1;
                                         }
                                         if (Main.tile[num105, num106].slope() == 0)
                                         {
                                             WorldGen.SlopeTile(num105, num106, num107);
                                             int num109 = Main.tile[num105, num106].slope();
                                             if (Main.netMode == 1)
                                             {
                                                 NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 14, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)num109, 0, 0, 0);
                                             }
                                         }
                                         else if (Main.tile[num105, num106].slope() != num107)
                                         {
                                             WorldGen.SlopeTile(num105, num106, 0);
                                             int num110 = Main.tile[num105, num106].slope();
                                             if (Main.netMode == 1)
                                             {
                                                 NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 14, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)num110, 0, 0, 0);
                                             }
                                             WorldGen.PoundTile(num105, num106);
                                             if (Main.netMode == 1)
                                             {
                                                 NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 7, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f, 0, 0, 0);
                                             }
                                         }
                                         else
                                         {
                                             WorldGen.SlopeTile(num105, num106, num108);
                                             int num111 = Main.tile[num105, num106].slope();
                                             if (Main.netMode == 1)
                                             {
                                                 NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 14, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)num111, 0, 0, 0);
                                             }
                                         }
                                     }
                                     else
                                     {
                                         WorldGen.PoundTile(num105, num106);
                                         if (Main.netMode == 1)
                                         {
                                             NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 7, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f, 0, 0, 0);
                                         }
                                     }
                                 }
                                 else if (Main.tile[num105, num106].type == TileID.MinecartTrack)
                                 {
                                     if (Minecart.FrameTrack(num105, num106, true, false) && Main.netMode == 1)
                                     {
                                         NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 15, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f, 0, 0, 0);
                                     }
                                 }
                                 else if (Main.tile[num105, num106].type == TileID.Traps)
                                 {
                                     if (Main.tile[num105, num106].frameX != 18)
                                     {
                                         Main.tile[num105, num106].frameX = 18;
                                     }
                                     else
                                     {
                                         Main.tile[num105, num106].frameX = 0;
                                     }
                                     if (Main.netMode == 1)
                                     {
                                         NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1);
                                     }
                                 }
                                 else if ((Main.tile[num105, num106].halfBrick() || Main.tile[num105, num106].slope() != 0) && !Main.tileSolidTop[Main.tile[Player.tileTargetX, Player.tileTargetY].type])
                                 {
                                     int num112 = 1;
                                     int num113 = 1;
                                     int num114 = 2;
                                     if ((WorldGen.SolidTile(num105 + 1, num106) || Main.tile[num105 + 1, num106].slope() == 1 || Main.tile[num105 + 1, num106].slope() == 3) && !WorldGen.SolidTile(num105 - 1, num106))
                                     {
                                         num113 = 2;
                                         num114 = 1;
                                     }
                                     if (WorldGen.SolidTile(num105, num106 - 1) && !WorldGen.SolidTile(num105, num106 + 1))
                                     {
                                         num112 = -1;
                                     }
                                     if (num112 == 1)
                                     {
                                         if (Main.tile[num105, num106].slope() == 0)
                                         {
                                             WorldGen.SlopeTile(num105, num106, num113);
                                         }
                                         else if (Main.tile[num105, num106].slope() == num113)
                                         {
                                             WorldGen.SlopeTile(num105, num106, num114);
                                         }
                                         else if (Main.tile[num105, num106].slope() == num114)
                                         {
                                             WorldGen.SlopeTile(num105, num106, num113 + 2);
                                         }
                                         else if (Main.tile[num105, num106].slope() != num113 + 2)
                                         {
                                             WorldGen.SlopeTile(num105, num106, 0);
                                         }
                                         else
                                         {
                                             WorldGen.SlopeTile(num105, num106, num114 + 2);
                                         }
                                     }
                                     else if (Main.tile[num105, num106].slope() == 0)
                                     {
                                         WorldGen.SlopeTile(num105, num106, num113 + 2);
                                     }
                                     else if (Main.tile[num105, num106].slope() == num113 + 2)
                                     {
                                         WorldGen.SlopeTile(num105, num106, num114 + 2);
                                     }
                                     else if (Main.tile[num105, num106].slope() == num114 + 2)
                                     {
                                         WorldGen.SlopeTile(num105, num106, num113);
                                     }
                                     else if (Main.tile[num105, num106].slope() != num113)
                                     {
                                         WorldGen.SlopeTile(num105, num106, 0);
                                     }
                                     else
                                     {
                                         WorldGen.SlopeTile(num105, num106, num114);
                                     }
                                     int num115 = Main.tile[num105, num106].slope();
                                     if (Main.netMode == 1)
                                     {
                                         NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 14, (float)Player.tileTargetX, (float)Player.tileTargetY, (float)num115, 0, 0, 0);
                                     }
                                 }
                                 else
                                 {
                                     WorldGen.PoundTile(num105, num106);
                                     if (Main.netMode == 1)
                                     {
                                         NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 7, (float)Player.tileTargetX, (float)Player.tileTargetY, 1f, 0, 0, 0);
                                     }
                                 }
                                 this.poundRelease = false;
                             }
                         }
                     }
                 }
             }
             if (this.releaseUseItem)
             {
                 this.poundRelease = true;
             }
             int num116 = Player.tileTargetX;
             int num117 = Player.tileTargetY;
             bool flag14 = true;
             if (Main.tile[num116, num117].wall > 0)
             {
                 if (Main.wallHouse[Main.tile[num116, num117].wall])
                 {
                     flag14 = false;
                 }
                 else
                 {
                     for (int g1 = num116 - 1; g1 < num116 + 2; g1++)
                     {
                         int num118 = num117 - 1;
                         while (num118 < num117 + 2)
                         {
                             if (Main.tile[g1, num118].wall == Main.tile[num116, num117].wall)
                             {
                                 num118++;
                             }
                             else
                             {
                                 flag14 = false;
                                 break;
                             }
                         }
                     }
                 }
             }
             if (flag14 && !Main.tile[num116, num117].active())
             {
                 int num119 = -1;
                 if ((double)(((float)Main.mouseX + Main.screenPosition.X) / 16f) < Math.Round((double)(((float)Main.mouseX + Main.screenPosition.X) / 16f)))
                 {
                     num119 = 0;
                 }
                 int num120 = -1;
                 if ((double)(((float)Main.mouseY + Main.screenPosition.Y) / 16f) < Math.Round((double)(((float)Main.mouseY + Main.screenPosition.Y) / 16f)))
                 {
                     num120 = 0;
                 }
                 for (int h1 = Player.tileTargetX + num119; h1 <= Player.tileTargetX + num119 + 1; h1++)
                 {
                     for (int i2 = Player.tileTargetY + num120; i2 <= Player.tileTargetY + num120 + 1; i2++)
                     {
                         if (flag14)
                         {
                             num116 = h1;
                             num117 = i2;
                             if (Main.tile[num116, num117].wall > 0)
                             {
                                 if (Main.wallHouse[Main.tile[num116, num117].wall])
                                 {
                                     flag14 = false;
                                 }
                                 else
                                 {
                                     for (int j2 = num116 - 1; j2 < num116 + 2; j2++)
                                     {
                                         int num121 = num117 - 1;
                                         while (num121 < num117 + 2)
                                         {
                                             if (Main.tile[j2, num121].wall == Main.tile[num116, num117].wall)
                                             {
                                                 num121++;
                                             }
                                             else
                                             {
                                                 flag14 = false;
                                                 break;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if (flag13 && Main.tile[num116, num117].wall > 0 && (!Main.tile[num116, num117].active() || num116 != Player.tileTargetX || num117 != Player.tileTargetY || !Main.tileHammer[Main.tile[num116, num117].type] && !this.poundRelease) && this.toolTime == 0 && this.itemAnimation > 0 && this.controlUseItem && item.hammer > 0)
             {
                 bool flag15 = true;
                 if (!Main.wallHouse[Main.tile[num116, num117].wall])
                 {
                     flag15 = false;
                     for (int k2 = num116 - 1; k2 < num116 + 2; k2++)
                     {
                         int num122 = num117 - 1;
                         while (num122 < num117 + 2)
                         {
                             if (Main.tile[k2, num122].wall == WallID.None || Main.wallHouse[Main.tile[k2, num122].wall])
                             {
                                 flag15 = true;
                                 break;
                             }
                             else
                             {
                                 num122++;
                             }
                         }
                     }
                 }
                 if (flag15)
                 {
                     num103 = this.hitTile.HitObject(num116, num117, 2);
                     num104 = num104 + (int)((float)item.hammer * 1.5f);
                     if (this.hitTile.AddDamage(num103, num104, true) < 100)
                     {
                         WorldGen.KillWall(num116, num117, true);
                         if (Main.netMode == 1)
                         {
                             NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 2, (float)num116, (float)num117, 1f, 0, 0, 0);
                         }
                     }
                     else
                     {
                         this.hitTile.Clear(num103);
                         WorldGen.KillWall(num116, num117, false);
                         if (Main.netMode == 1)
                         {
                             NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 2, (float)num116, (float)num117, 0f, 0, 0, 0);
                         }
                     }
                     if (num104 != 0)
                     {
                         this.hitTile.Prune();
                     }
                     this.itemTime = item.useTime / 2;
                 }
             }
         }
         if (Main.myPlayer == this.whoAmI && item.type == ItemID.RodofDiscord && this.itemAnimation > 0 && this.itemTime == 0)
         {
             this.itemTime = item.useTime;
             y.X = (float)Main.mouseX + Main.screenPosition.X;
             if (this.gravDir != 1f)
             {
                 y.Y = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY;
             }
             else
             {
                 y.Y = (float)Main.mouseY + Main.screenPosition.Y - (float)this.height;
             }
             y.X = y.X - (float)(this.width / 2);
             if (y.X > 50f && y.X < (float)(Main.maxTilesX * 16 - 50) && y.Y > 50f && y.Y < (float)(Main.maxTilesY * 16 - 50))
             {
                 int x18 = (int)(y.X / 16f);
                 int y19 = (int)(y.Y / 16f);
                 if ((Main.tile[x18, y19].wall != WallID.LihzahrdBrickUnsafe || (double)y19 <= Main.worldSurface || NPC.downedPlantBoss) && !Collision.SolidCollision(y, this.width, this.height))
                 {
                     this.Teleport(y, 1, 0);
                     NetMessage.SendData((int)PacketTypes.Teleport, -1, -1, "", 0, (float)this.whoAmI, y.X, y.Y, 1, 0, 0);
                     if (this.chaosState)
                     {
                         Player player8 = this;
                         player8.statLife = player8.statLife - this.statLifeMax2 / 7;
                         if (Lang.lang <= 1)
                         {
                             string str = " didn't materialize";
                             if (Main.rand.Next(2) == 0)
                             {
                                 str = (!this.Male ? "'s legs appeared where her head should be" : "'s legs appeared where his head should be");
                             }
                             if (this.statLife <= 0)
                             {
                                 this.KillMe(1, 0, false, str);
                             }
                         }
                         else if (this.statLife <= 0)
                         {
                             this.KillMe(1, 0, false, "");
                         }
                         this.lifeRegenCount = 0;
                         this.lifeRegenTime = 0;
                     }
                     this.AddBuff(BuffID.ChaosState, 360, true);
                 }
             }
         }
         if (item.type == ItemID.LifeCrystal && this.itemAnimation > 0 && this.statLifeMax < 400 && this.itemTime == 0)
         {
             this.itemTime = item.useTime;
             Player player9 = this;
             player9.statLifeMax = player9.statLifeMax + 20;
             Player player10 = this;
             player10.statLifeMax2 = player10.statLifeMax2 + 20;
             Player player11 = this;
             player11.statLife = player11.statLife + 20;
             if (Main.myPlayer == this.whoAmI)
             {
                 this.HealEffect(20, true);
             }
             AchievementsHelper.HandleSpecialEvent(this, 0);
         }
         if (item.type == ItemID.LifeFruit && this.itemAnimation > 0 && this.statLifeMax >= 400 && this.statLifeMax < 500 && this.itemTime == 0)
         {
             this.itemTime = item.useTime;
             Player player12 = this;
             player12.statLifeMax = player12.statLifeMax + 5;
             Player player13 = this;
             player13.statLifeMax2 = player13.statLifeMax2 + 5;
             Player player14 = this;
             player14.statLife = player14.statLife + 5;
             if (Main.myPlayer == this.whoAmI)
             {
                 this.HealEffect(5, true);
             }
             AchievementsHelper.HandleSpecialEvent(this, 2);
         }
         if (item.type == ItemID.ManaCrystal && this.itemAnimation > 0 && this.statManaMax < 200 && this.itemTime == 0)
         {
             this.itemTime = item.useTime;
             Player player15 = this;
             player15.statManaMax = player15.statManaMax + 20;
             Player player16 = this;
             player16.statManaMax2 = player16.statManaMax2 + 20;
             Player player17 = this;
             player17.statMana = player17.statMana + 20;
             if (Main.myPlayer == this.whoAmI)
             {
                 this.ManaEffect(20);
             }
             AchievementsHelper.HandleSpecialEvent(this, 1);
         }
         if (item.type == ItemID.DemonHeart && this.itemAnimation > 0 && !this.extraAccessory && Main.expertMode && this.itemTime == 0)
         {
             this.itemTime = item.useTime;
             this.extraAccessory = true;
             NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, Main.player[this.whoAmI].name, this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
         }
         this.PlaceThing();
     }
     if (item.type == ItemID.NebulaBlaze)
     {
         Vector2 offsetsPlayerOnhand = Main.OffsetsPlayerOnhand[this.bodyFrame.Y / 56] * 2f;
         if (this.direction != 1)
         {
             offsetsPlayerOnhand.X = (float)this.bodyFrame.Width - offsetsPlayerOnhand.X;
         }
         if (this.gravDir != 1f)
         {
             offsetsPlayerOnhand.Y = (float)this.bodyFrame.Height - offsetsPlayerOnhand.Y;
         }
         offsetsPlayerOnhand = offsetsPlayerOnhand - (new Vector2((float)(this.bodyFrame.Width - this.width), (float)(this.bodyFrame.Height - 42)) / 2f);
     }
     if ((item.damage >= 0 && item.type > 0 && !item.noMelee || item.type == ItemID.BubbleWand || item.type == ItemID.BugNet || item.type == ItemID.GoldenBugNet || item.type == ItemID.NebulaBlaze) && this.itemAnimation > 0)
     {
         bool flag16 = false;
         Rectangle rectangle = new Rectangle((int)this.itemLocation.X, (int)this.itemLocation.Y, 32, 32);
         rectangle.Width = (int)((float)rectangle.Width * item.scale);
         rectangle.Height = (int)((float)rectangle.Height * item.scale);
         if (this.direction == -1)
         {
             rectangle.X = rectangle.X - rectangle.Width;
         }
         if (this.gravDir == 1f)
         {
             rectangle.Y = rectangle.Y - rectangle.Height;
         }
         if (item.useStyle != 1)
         {
             if (item.useStyle == 3)
             {
                 if ((double)this.itemAnimation <= (double)this.itemAnimationMax * 0.666)
                 {
                     if (this.direction == -1)
                     {
                         rectangle.X = rectangle.X - (int)((double)rectangle.Width * 1.4 - (double)rectangle.Width);
                     }
                     rectangle.Width = (int)((double)rectangle.Width * 1.4);
                     rectangle.Y = rectangle.Y + (int)((double)rectangle.Height * 0.6);
                     rectangle.Height = (int)((double)rectangle.Height * 0.6);
                 }
                 else
                 {
                     flag16 = true;
                 }
             }
         }
         else if ((double)this.itemAnimation < (double)this.itemAnimationMax * 0.333)
         {
             if (this.direction == -1)
             {
                 rectangle.X = rectangle.X - (int)((double)rectangle.Width * 1.4 - (double)rectangle.Width);
             }
             rectangle.Width = (int)((double)rectangle.Width * 1.4);
             rectangle.Y = rectangle.Y + (int)((double)rectangle.Height * 0.5 * (double)this.gravDir);
             rectangle.Height = (int)((double)rectangle.Height * 1.1);
         }
         else if ((double)this.itemAnimation >= (double)this.itemAnimationMax * 0.666)
         {
             if (this.direction == 1)
             {
                 rectangle.X = rectangle.X - (int)((double)rectangle.Width * 1.2);
             }
             rectangle.Width = rectangle.Width * 2;
             rectangle.Y = rectangle.Y - (int)(((double)rectangle.Height * 1.4 - (double)rectangle.Height) * (double)this.gravDir);
             rectangle.Height = (int)((double)rectangle.Height * 1.4);
         }
         float single94 = this.gravDir;
         if (item.type == ItemID.NebulaBlaze)
         {
             flag16 = true;
         }
         if (!flag16)
         {
             if (Main.myPlayer == i && (item.type == ItemID.BugNet || item.type == ItemID.GoldenBugNet))
             {
                 for (int n2 = 0; n2 < 200; n2++)
                 {
                     if (Main.npc[n2].active && Main.npc[n2].catchItem > 0)
                     {
                         Rectangle rectangle1 = new Rectangle((int)Main.npc[n2].position.X, (int)Main.npc[n2].position.Y, Main.npc[n2].width, Main.npc[n2].height);
                         if (rectangle.Intersects(rectangle1) && (item.type == ItemID.GoldenBugNet || Main.npc[n2].noTileCollide || Collision.CanHit(this.position, this.width, this.height, Main.npc[n2].position, Main.npc[n2].width, Main.npc[n2].height)))
                         {
                             NPC.CatchNPC(n2, i);
                         }
                     }
                 }
             }
             if (Main.myPlayer == i && (item.damage > 0 || item.type == ItemID.GoldenBugNet))
             {
                 int num155 = (int)((float)item.damage * this.meleeDamage);
                 float single102 = item.knockBack;
                 float single103 = 1f;
                 if (this.kbGlove)
                 {
                     single103 = single103 + 1f;
                 }
                 if (this.kbBuff)
                 {
                     single103 = single103 + 0.5f;
                 }
                 single102 = single102 * single103;
                 if (this.inventory[this.selectedItem].type == 3106)
                 {
                     single102 = single102 + single102 * (1f - this.stealth);
                 }
                 List<ushort> nums1 = null;
                 if (item.type == ItemID.StaffofRegrowth)
                 {
                     nums1 = new List<ushort>(new ushort[] { 3, 24, 52, 61, 62, 71, 73, 74, 82, 83, 84, 110, 113, 115, 184, 205, 201 });
                 }
                 int x36 = rectangle.X / 16;
                 int x37 = (rectangle.X + rectangle.Width) / 16 + 1;
                 int y22 = rectangle.Y / 16;
                 int y23 = (rectangle.Y + rectangle.Height) / 16 + 1;
                 for (int o2 = x36; o2 < x37; o2++)
                 {
                     for (int p2 = y22; p2 < y23; p2++)
                     {
                         if (Main.tile[o2, p2] != null && Main.tileCut[Main.tile[o2, p2].type] && (nums1 == null || !nums1.Contains(Main.tile[o2, p2].type)) && Main.tile[o2, p2 + 1] != null && Main.tile[o2, p2 + 1].type != 78 && Main.tile[o2, p2 + 1].type != 380)
                         {
                             if (item.type != ItemID.Sickle)
                             {
                                 WorldGen.KillTile(o2, p2, false, false, false);
                                 if (Main.netMode == 1)
                                 {
                                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)o2, (float)p2, 0f, 0, 0, 0);
                                 }
                             }
                             else
                             {
                                 int num156 = Main.tile[o2, p2].type;
                                 WorldGen.KillTile(o2, p2, false, false, false);
                                 if (!Main.tile[o2, p2].active())
                                 {
                                     int num157 = 0;
                                     if (num156 == 3 || num156 == 24 || num156 == 61 || num156 == 110 || num156 == 201)
                                     {
                                         num157 = Main.rand.Next(1, 3);
                                     }
                                     if (num156 == 73 || num156 == 74 || num156 == 113)
                                     {
                                         num157 = Main.rand.Next(2, 5);
                                     }
                                     if (num157 > 0)
                                     {
                                         int num158 = Item.NewItem(o2 * 16, p2 * 16, 16, 16, 1727, num157, false, 0, false);
                                         if (Main.netMode == 1)
                                         {
                                             NetMessage.SendData((int)PacketTypes.ItemDrop, -1, -1, "", num158, 1f, 0f, 0f, 0, 0, 0);
                                         }
                                     }
                                 }
                                 if (Main.netMode == 1)
                                 {
                                     NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)o2, (float)p2, 0f, 0, 0, 0);
                                 }
                             }
                         }
                     }
                 }
                 if (item.type != ItemID.GoldenBugNet)
                 {
                     for (int q2 = 0; q2 < 200; q2++)
                     {
                         if (Main.npc[q2].active && Main.npc[q2].immune[i] == 0 && this.attackCD == 0)
                         {
                             if (!Main.npc[q2].dontTakeDamage)
                             {
                                 if (!Main.npc[q2].friendly || Main.npc[q2].type == NPCID.Guide && this.killGuide || Main.npc[q2].type == NPCID.Clothier && this.killClothier)
                                 {
                                     Rectangle rectangle2 = new Rectangle((int)Main.npc[q2].position.X, (int)Main.npc[q2].position.Y, Main.npc[q2].width, Main.npc[q2].height);
                                     if (rectangle.Intersects(rectangle2) && (Main.npc[q2].noTileCollide || Collision.CanHit(this.position, this.width, this.height, Main.npc[q2].position, Main.npc[q2].width, Main.npc[q2].height)))
                                     {
                                         bool flag17 = false;
                                         if (Main.rand.Next(1, 101) <= this.meleeCrit)
                                         {
                                             flag17 = true;
                                         }
                                         int num159 = Main.DamageVar((float)num155);
                                         int num160 = Item.NPCtoBanner(Main.npc[q2].BannerID());
                                         if (num160 > 0 && this.NPCBannerBuff[num160])
                                         {
                                             num155 = (!Main.expertMode ? (int)((double)num155 * 1.5) : num155 * 2);
                                         }
                                         this.StatusNPC(item.type, q2);
                                         this.OnHit(Main.npc[q2].Center.X, Main.npc[q2].Center.Y, Main.npc[q2]);
                                         if (this.armorPenetration > 0)
                                         {
                                             num159 = num159 + Main.npc[q2].checkArmorPenetration(this.armorPenetration);
                                         }
                                         int num161 = (int)Main.npc[q2].StrikeNPC(num159, single102, this.direction, flag17, false, false, this);
                                         if (this.inventory[this.selectedItem].type == 3211)
                                         {
                                             Vector2 vector286 = new Vector2((float)(this.direction * 100 + Main.rand.Next(-25, 26)), (float)Main.rand.Next(-75, 76));
                                             vector286.Normalize();
                                             vector286 = vector286 * ((float)Main.rand.Next(30, 41) * 0.1f);
                                             Vector2 center2 = new Vector2((float)(rectangle.X + Main.rand.Next(rectangle.Width)), (float)(rectangle.Y + Main.rand.Next(rectangle.Height)));
                                             center2 = (center2 + (Main.npc[q2].Center * 2f)) / 3f;
                                             Projectile.NewProjectile(center2.X, center2.Y, vector286.X, vector286.Y, 524, (int)((double)num155 * 0.7), single102 * 0.7f, this.whoAmI, 0f, 0f);
                                         }
                                         if (this.beetleOffense)
                                         {
                                             Player player18 = this;
                                             player18.beetleCounter = player18.beetleCounter + (float)num161;
                                             this.beetleCountdown = 0;
                                         }
                                         if (item.type == ItemID.TheHorsemansBlade && Main.npc[q2].@value > 0f)
                                         {
                                             this.pumpkinSword(q2, (int)((double)num155 * 1.5), single102);
                                         }
                                         if (this.meleeEnchant == 7)
                                         {
                                             Projectile.NewProjectile(Main.npc[q2].Center.X, Main.npc[q2].Center.Y, Main.npc[q2].velocity.X, Main.npc[q2].velocity.Y, 289, 0, 0f, this.whoAmI, 0f, 0f);
                                         }
                                         if (this.inventory[this.selectedItem].type == 3106)
                                         {
                                             this.stealth = 1f;
                                             if (Main.netMode == 1)
                                             {
                                                 NetMessage.SendData((int)PacketTypes.PlayerStealth, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                             }
                                         }
                                         if (item.type == ItemID.BeeKeeper)
                                         {
                                             int num162 = Main.rand.Next(1, 4);
                                             if (this.strongBees && Main.rand.Next(3) == 0)
                                             {
                                                 num162++;
                                             }
                                             for (int r2 = 0; r2 < num162; r2++)
                                             {
                                                 float single104 = (float)(this.direction * 2) + (float)Main.rand.Next(-35, 36) * 0.02f;
                                                 float single105 = (float)Main.rand.Next(-35, 36) * 0.02f;
                                                 single104 = single104 * 0.2f;
                                                 single105 = single105 * 0.2f;
                                                 Projectile.NewProjectile((float)(rectangle.X + rectangle.Width / 2), (float)(rectangle.Y + rectangle.Height / 2), single104, single105, this.beeType(), this.beeDamage(num159 / 3), this.beeKB(0f), i, 0f, 0f);
                                             }
                                         }
                                         if (Main.npc[q2].@value > 0f && this.coins && Main.rand.Next(5) == 0)
                                         {
                                             int num163 = 71;
                                             if (Main.rand.Next(10) == 0)
                                             {
                                                 num163 = 72;
                                             }
                                             if (Main.rand.Next(100) == 0)
                                             {
                                                 num163 = 73;
                                             }
                                             int num164 = Item.NewItem((int)Main.npc[q2].position.X, (int)Main.npc[q2].position.Y, Main.npc[q2].width, Main.npc[q2].height, num163, 1, false, 0, false);
                                             Main.item[num164].stack = Main.rand.Next(1, 11);
                                             Main.item[num164].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
                                             Main.item[num164].velocity.X = (float)Main.rand.Next(10, 31) * 0.2f * (float)this.direction;
                                             if (Main.netMode == 1)
                                             {
                                                 NetMessage.SendData((int)PacketTypes.ItemDrop, -1, -1, "", num164, 0f, 0f, 0f, 0, 0, 0);
                                             }
                                         }
                                         int num165 = Item.NPCtoBanner(Main.npc[q2].BannerID());
                                         if (num165 >= 0)
                                         {
                                             this.lastCreatureHit = num165;
                                         }
                                         if (Main.netMode != 0)
                                         {
                                             if (!flag17)
                                             {
                                                 NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", q2, (float)num159, single102, (float)this.direction, 0, 0, 0);
                                             }
                                             else
                                             {
                                                 NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", q2, (float)num159, single102, (float)this.direction, 1, 0, 0);
                                             }
                                         }
                                         if (this.accDreamCatcher)
                                         {
                                             this.addDPS(num159);
                                         }
                                         Main.npc[q2].immune[i] = this.itemAnimation;
                                         this.attackCD = (int)((double)this.itemAnimationMax * 0.33);
                                     }
                                 }
                             }
                             else if (Main.npc[q2].type == NPCID.BlueJellyfish || Main.npc[q2].type == NPCID.PinkJellyfish || Main.npc[q2].type == NPCID.GreenJellyfish || Main.npc[q2].type == NPCID.BloodJelly)
                             {
                                 Rectangle rectangle3 = new Rectangle((int)Main.npc[q2].position.X, (int)Main.npc[q2].position.Y, Main.npc[q2].width, Main.npc[q2].height);
                                 if (rectangle.Intersects(rectangle3))
                                 {
                                     this.Hurt((int)((double)Main.npc[q2].damage * 1.3), -this.direction, false, false, " was slain...", false);
                                     Main.npc[q2].immune[i] = this.itemAnimation;
                                     this.attackCD = (int)((double)this.itemAnimationMax * 0.33);
                                 }
                             }
                         }
                     }
                     if (this.hostile)
                     {
                         for (int s2 = 0; s2 < 255; s2++)
                         {
                             if (s2 != i && Main.player[s2].active && Main.player[s2].hostile && !Main.player[s2].immune && !Main.player[s2].dead && (Main.player[i].team == 0 || Main.player[i].team != Main.player[s2].team))
                             {
                                 Rectangle rectangle4 = new Rectangle((int)Main.player[s2].position.X, (int)Main.player[s2].position.Y, Main.player[s2].width, Main.player[s2].height);
                                 if (rectangle.Intersects(rectangle4) && Collision.CanHit(this.position, this.width, this.height, Main.player[s2].position, Main.player[s2].width, Main.player[s2].height))
                                 {
                                     bool flag18 = false;
                                     if (Main.rand.Next(1, 101) <= 10)
                                     {
                                         flag18 = true;
                                     }
                                     int num166 = Main.DamageVar((float)num155);
                                     this.StatusPvP(item.type, s2);
                                     this.OnHit(Main.player[s2].Center.X, Main.player[s2].Center.Y, Main.player[s2]);
                                     int num167 = (int)Main.player[s2].Hurt(num166, this.direction, true, false, "", flag18);
                                     if (this.inventory[this.selectedItem].type == 3211)
                                     {
                                         Vector2 vector287 = new Vector2((float)(this.direction * 100 + Main.rand.Next(-25, 26)), (float)Main.rand.Next(-75, 76));
                                         vector287.Normalize();
                                         vector287 = vector287 * ((float)Main.rand.Next(30, 41) * 0.1f);
                                         Vector2 center3 = new Vector2((float)(rectangle.X + Main.rand.Next(rectangle.Width)), (float)(rectangle.Y + Main.rand.Next(rectangle.Height)));
                                         center3 = (center3 + (Main.player[s2].Center * 2f)) / 3f;
                                         Projectile.NewProjectile(center3.X, center3.Y, vector287.X, vector287.Y, 524, (int)((double)num155 * 0.7), single102 * 0.7f, this.whoAmI, 0f, 0f);
                                     }
                                     if (this.beetleOffense)
                                     {
                                         Player player19 = this;
                                         player19.beetleCounter = player19.beetleCounter + (float)num167;
                                         this.beetleCountdown = 0;
                                     }
                                     if (this.meleeEnchant == 7)
                                     {
                                         Projectile.NewProjectile(Main.player[s2].Center.X, Main.player[s2].Center.Y, Main.player[s2].velocity.X, Main.player[s2].velocity.Y, 289, 0, 0f, this.whoAmI, 0f, 0f);
                                     }
                                     if (item.type == ItemID.BeeKeeper)
                                     {
                                         int num168 = Main.rand.Next(1, 4);
                                         if (this.strongBees && Main.rand.Next(3) == 0)
                                         {
                                             num168++;
                                         }
                                         for (int t2 = 0; t2 < num168; t2++)
                                         {
                                             float single106 = (float)(this.direction * 2) + (float)Main.rand.Next(-35, 36) * 0.02f;
                                             float single107 = (float)Main.rand.Next(-35, 36) * 0.02f;
                                             single106 = single106 * 0.2f;
                                             single107 = single107 * 0.2f;
                                             Projectile.NewProjectile((float)(rectangle.X + rectangle.Width / 2), (float)(rectangle.Y + rectangle.Height / 2), single106, single107, this.beeType(), this.beeDamage(num166 / 3), this.beeKB(0f), i, 0f, 0f);
                                         }
                                     }
                                     if (this.inventory[this.selectedItem].type == 3106)
                                     {
                                         this.stealth = 1f;
                                         if (Main.netMode == 1)
                                         {
                                             NetMessage.SendData((int)PacketTypes.PlayerStealth, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                         }
                                     }
                                     if (item.type == ItemID.TheHorsemansBlade && Main.npc[s2].@value > 0f)
                                     {
                                         this.pumpkinSword(s2, (int)((double)num155 * 1.5), single102);
                                     }
                                     if (Main.netMode != 0)
                                     {
                                         if (!flag18)
                                         {
                                             NetMessage.SendData((int)PacketTypes.PlayerDamage, -1, -1, Lang.deathMsg(this.whoAmI, -1, -1, -1), s2, (float)this.direction, (float)num166, 1f, 0, 0, 0);
                                         }
                                         else
                                         {
                                             NetMessage.SendData((int)PacketTypes.PlayerDamage, -1, -1, Lang.deathMsg(this.whoAmI, -1, -1, -1), s2, (float)this.direction, (float)num166, 1f, 1, 0, 0);
                                         }
                                     }
                                     this.attackCD = (int)((double)this.itemAnimationMax * 0.33);
                                 }
                             }
                         }
                     }
                     if (item.type == ItemID.Hammush && (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.1) || this.itemAnimation == (int)((double)this.itemAnimationMax * 0.3) || this.itemAnimation == (int)((double)this.itemAnimationMax * 0.5) || this.itemAnimation == (int)((double)this.itemAnimationMax * 0.7) || this.itemAnimation == (int)((double)this.itemAnimationMax * 0.9)))
                     {
                         float single108 = 0f;
                         float single109 = 0f;
                         float single110 = 0f;
                         float single111 = 0f;
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.9))
                         {
                             single108 = -7f;
                         }
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.7))
                         {
                             single108 = -6f;
                             single109 = 2f;
                         }
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.5))
                         {
                             single108 = -4f;
                             single109 = 4f;
                         }
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.3))
                         {
                             single108 = -2f;
                             single109 = 6f;
                         }
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.1))
                         {
                             single109 = 7f;
                         }
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.7))
                         {
                             single111 = 26f;
                         }
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.3))
                         {
                             single111 = single111 - 4f;
                             single110 = single110 - 20f;
                         }
                         if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.1))
                         {
                             single110 = single110 + 6f;
                         }
                         if (this.direction == -1)
                         {
                             if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.9))
                             {
                                 single111 = single111 - 8f;
                             }
                             if (this.itemAnimation == (int)((double)this.itemAnimationMax * 0.7))
                             {
                                 single111 = single111 - 6f;
                             }
                         }
                         single108 = single108 * 1.5f;
                         single109 = single109 * 1.5f;
                         single111 = single111 * (float)this.direction;
                         single110 = single110 * this.gravDir;
                         Projectile.NewProjectile((float)(rectangle.X + rectangle.Width / 2) + single111, (float)(rectangle.Y + rectangle.Height / 2) + single110, (float)this.direction * single109, single108 * this.gravDir, 131, num155 / 2, 0f, i, 0f, 0f);
                     }
                 }
             }
         }
     }
     if (this.itemTime == 0 && this.itemAnimation > 0)
     {
         if (item.hairDye >= 0)
         {
             this.itemTime = item.useTime;
             if (this.whoAmI == Main.myPlayer)
             {
                 this.hairDye = (byte)item.hairDye;
                 NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, Main.player[this.whoAmI].name, this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
             }
         }
         if (item.healLife > 0)
         {
             Player player20 = this;
             player20.statLife = player20.statLife + item.healLife;
             this.itemTime = item.useTime;
             if (Main.myPlayer == this.whoAmI)
             {
                 this.HealEffect(item.healLife, true);
             }
         }
         if (item.healMana > 0)
         {
             Player player21 = this;
             player21.statMana = player21.statMana + item.healMana;
             this.itemTime = item.useTime;
             if (Main.myPlayer == this.whoAmI)
             {
                 this.AddBuff(BuffID.ManaSickness, Player.manaSickTime, true);
                 this.ManaEffect(item.healMana);
             }
         }
         if (item.buffType > 0)
         {
             if (this.whoAmI == Main.myPlayer && item.buffType != 90 && item.buffType != 27)
             {
                 this.AddBuff(item.buffType, item.buffTime, true);
             }
             this.itemTime = item.useTime;
         }
         if (item.type == ItemID.RedPotion)
         {
             this.itemTime = item.useTime;
             if (this.whoAmI == Main.myPlayer)
             {
                 this.AddBuff(BuffID.Poisoned, 216000, true);
                 this.AddBuff(BuffID.Darkness, 216000, true);
                 this.AddBuff(BuffID.Cursed, 216000, true);
                 this.AddBuff(BuffID.OnFire, 216000, true);
                 this.AddBuff(BuffID.Bleeding, 216000, true);
                 this.AddBuff(BuffID.Confused, 216000, true);
                 this.AddBuff(BuffID.Slow, 216000, true);
                 this.AddBuff(BuffID.Weak, 216000, true);
                 this.AddBuff(BuffID.Silenced, 216000, true);
                 this.AddBuff(BuffID.BrokenArmor, 216000, true);
                 this.AddBuff(BuffID.Suffocation, 216000, true);
             }
         }
     }
     if (this.whoAmI == Main.myPlayer)
     {
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.type == ItemID.GoblinBattleStandard && Main.CanStartInvasion(1, true))
         {
             this.itemTime = item.useTime;
             if (Main.netMode == 1)
             {
                 NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
             }
             else if (Main.invasionType == 0)
             {
                 Main.invasionDelay = 0;
                 Main.StartInvasion(1);
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.type == ItemID.SnowGlobe && Main.CanStartInvasion(2, true))
         {
             this.itemTime = item.useTime;
             if (Main.netMode == 1)
             {
                 NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, -2f, 0f, 0f, 0, 0, 0);
             }
             else if (Main.invasionType == 0)
             {
                 Main.invasionDelay = 0;
                 Main.StartInvasion(2);
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.type == ItemID.PirateMap && Main.CanStartInvasion(3, true))
         {
             this.itemTime = item.useTime;
             if (Main.netMode == 1)
             {
                 NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, -3f, 0f, 0f, 0, 0, 0);
             }
             else if (Main.invasionType == 0)
             {
                 Main.invasionDelay = 0;
                 Main.StartInvasion(3);
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.type == ItemID.PumpkinMoonMedallion && !Main.dayTime && !Main.pumpkinMoon && !Main.snowMoon)
         {
             this.itemTime = item.useTime;
             if (Main.netMode == 1)
             {
                 NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, -4f, 0f, 0f, 0, 0, 0);
             }
             else
             {
                 Main.NewText(Lang.misc[31], 50, 255, 130, false);
                 Main.startPumpkinMoon();
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.type == ItemID.LunarTablet && Main.dayTime && !Main.eclipse)
         {
             if (Main.netMode != 0)
             {
                 NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, -6f, 0f, 0f, 0, 0, 0);
             }
             else
             {
                 this.itemTime = item.useTime;
                 Main.eclipse = true;
                 Main.NewText(Lang.misc[20], 50, 255, 130, false);
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.type == ItemID.CelestialSigil && NPC.downedGolemBoss && Main.hardMode && !NPC.AnyDanger() && !NPC.AnyoneNearCultists())
         {
             this.itemTime = item.useTime;
             if (Main.netMode == 0)
             {
                 WorldGen.StartImpendingDoom();
             }
             else
             {
                 NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, -8f, 0f, 0f, 0, 0, 0);
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.type == ItemID.NaughtyPresent && !Main.dayTime && !Main.pumpkinMoon && !Main.snowMoon)
         {
             this.itemTime = item.useTime;
             if (Main.netMode == 1)
             {
                 NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, -5f, 0f, 0f, 0, 0, 0);
             }
             else
             {
                 Main.NewText(Lang.misc[34], 50, 255, 130, false);
                 Main.startSnowMoon();
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && item.makeNPC > 0 && this.controlUseItem && this.position.X / 16f - (float)Player.tileRangeX - (float)item.tileBoost <= (float)Player.tileTargetX && (this.position.X + (float)this.width) / 16f + (float)Player.tileRangeX + (float)item.tileBoost - 1f >= (float)Player.tileTargetX && this.position.Y / 16f - (float)Player.tileRangeY - (float)item.tileBoost <= (float)Player.tileTargetY && (this.position.Y + (float)this.height) / 16f + (float)Player.tileRangeY + (float)item.tileBoost - 2f >= (float)Player.tileTargetY)
         {
             int x38 = Main.mouseX + (int)Main.screenPosition.X;
             int y24 = Main.mouseY + (int)Main.screenPosition.Y;
             this.itemTime = item.useTime;
             if (!WorldGen.SolidTile(x38 / 16, y24 / 16))
             {
                 NPC.ReleaseNPC(x38, y24, item.makeNPC, item.placeStyle, this.whoAmI);
             }
         }
         if (this.itemTime == 0 && this.itemAnimation > 0 && (item.type == ItemID.SuspiciousLookingEye || item.type == ItemID.WormFood || item.type == ItemID.MechanicalEye || item.type == ItemID.MechanicalWorm || item.type == ItemID.MechanicalSkull || item.type == ItemID.SlimeCrown || item.type == ItemID.Abeemination || item.type == ItemID.BloodySpine) && this.SummonItemCheck())
         {
             if (item.type == ItemID.SlimeCrown)
             {
                 this.itemTime = item.useTime;
                 if (Main.netMode == 1)
                 {
                     NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 50f, 0f, 0f, 0, 0, 0);
                 }
                 else
                 {
                     NPC.SpawnOnPlayer(i, 50);
                 }
             }
             else if (item.type == ItemID.SuspiciousLookingEye)
             {
                 if (!Main.dayTime)
                 {
                     this.itemTime = item.useTime;
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 4f, 0f, 0f, 0, 0, 0);
                     }
                     else
                     {
                         NPC.SpawnOnPlayer(i, 4);
                     }
                 }
             }
             else if (item.type == ItemID.WormFood)
             {
                 if (this.ZoneCorrupt)
                 {
                     this.itemTime = item.useTime;
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 13f, 0f, 0f, 0, 0, 0);
                     }
                     else
                     {
                         NPC.SpawnOnPlayer(i, 13);
                     }
                 }
             }
             else if (item.type == ItemID.MechanicalEye)
             {
                 if (!Main.dayTime)
                 {
                     this.itemTime = item.useTime;
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 125f, 0f, 0f, 0, 0, 0);
                         NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 126f, 0f, 0f, 0, 0, 0);
                     }
                     else
                     {
                         NPC.SpawnOnPlayer(i, 125);
                         NPC.SpawnOnPlayer(i, 126);
                     }
                 }
             }
             else if (item.type == ItemID.MechanicalWorm)
             {
                 if (!Main.dayTime)
                 {
                     this.itemTime = item.useTime;
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 134f, 0f, 0f, 0, 0, 0);
                     }
                     else
                     {
                         NPC.SpawnOnPlayer(i, 134);
                     }
                 }
             }
             else if (item.type == ItemID.MechanicalSkull)
             {
                 if (!Main.dayTime)
                 {
                     this.itemTime = item.useTime;
                     if (Main.netMode == 1)
                     {
                         NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 127f, 0f, 0f, 0, 0, 0);
                     }
                     else
                     {
                         NPC.SpawnOnPlayer(i, 127);
                     }
                 }
             }
             else if (item.type == ItemID.Abeemination)
             {
                 this.itemTime = item.useTime;
                 if (Main.netMode == 1)
                 {
                     NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 222f, 0f, 0f, 0, 0, 0);
                 }
                 else
                 {
                     NPC.SpawnOnPlayer(i, 222);
                 }
             }
             else if (item.type == ItemID.BloodySpine && this.ZoneCrimson)
             {
                 this.itemTime = item.useTime;
                 if (Main.netMode == 1)
                 {
                     NetMessage.SendData((int)PacketTypes.SpawnBossorInvasion, -1, -1, "", this.whoAmI, 266f, 0f, 0f, 0, 0, 0);
                 }
                 else
                 {
                     NPC.SpawnOnPlayer(i, 266);
                 }
             }
         }
     }
     if ((item.type == ItemID.MagicMirror || item.type == ItemID.CellPhone || item.type == ItemID.IceMirror) && this.itemAnimation > 0)
     {
         if (this.itemTime == 0)
         {
             this.itemTime = item.useTime;
         }
         else if (this.itemTime == item.useTime / 2)
         {
             this.grappling[0] = -1;
             this.grapCount = 0;
             for (int v2 = 0; v2 < 1000; v2++)
             {
                 if (Main.projectile[v2].active && Main.projectile[v2].owner == i && Main.projectile[v2].aiStyle == 7)
                 {
                     Main.projectile[v2].Kill();
                 }
             }
             this.Spawn();
         }
     }
     if (item.type == ItemID.RecallPotion && this.itemAnimation > 0)
     {
         if (this.itemTime == 0)
         {
             this.itemTime = item.useTime;
         }
         else if (this.itemTime == 2)
         {
             this.grappling[0] = -1;
             this.grapCount = 0;
             for (int y25 = 0; y25 < 1000; y25++)
             {
                 if (Main.projectile[y25].active && Main.projectile[y25].owner == i && Main.projectile[y25].aiStyle == 7)
                 {
                     Main.projectile[y25].Kill();
                 }
             }
             bool flag19 = this.immune;
             int num175 = this.immuneTime;
             this.Spawn();
             this.immune = flag19;
             this.immuneTime = num175;
             if (item.stack > 0)
             {
                 Item item18 = item;
                 item18.stack = item18.stack - 1;
             }
         }
     }
     if (item.type == ItemID.TeleportationPotion && this.itemAnimation > 0)
     {
         if (this.itemTime == 0)
         {
             this.itemTime = item.useTime;
         }
         else if (this.itemTime == 2)
         {
             if (Main.netMode == 0)
             {
                 this.TeleportationPotion();
             }
             else if (Main.netMode == 1 && this.whoAmI == Main.myPlayer)
             {
                 NetMessage.SendData((int)PacketTypes.TeleportationPotion, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0);
             }
             if (item.stack > 0)
             {
                 Item item19 = item;
                 item19.stack = item19.stack - 1;
             }
         }
     }
     if (item.type == ItemID.GenderChangePotion && this.itemAnimation > 0)
     {
         if (this.itemTime == 0)
         {
             this.itemTime = item.useTime;
         }
         else if (this.itemTime != 2)
         {
         }
         else
         {
             if (this.whoAmI == Main.myPlayer)
             {
                 this.Male = !this.Male;
                 if (Main.netMode == 1)
                 {
                     NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, this.name, this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                 }
             }
             if (item.stack > 0)
             {
                 Item item20 = item;
                 item20.stack = item20.stack - 1;
             }
         }
     }
     if (i == Main.myPlayer)
     {
         if (this.itemTime == (int)((float)item.useTime * this.tileSpeed) && item.tileWand > 0)
         {
             int num179 = item.tileWand;
             int num180 = 0;
             while (num180 < 58)
             {
                 if (num179 != this.inventory[num180].type || this.inventory[num180].stack <= 0)
                 {
                     num180++;
                 }
                 else
                 {
                     Item item21 = this.inventory[num180];
                     item21.stack = item21.stack - 1;
                     if (this.inventory[num180].stack > 0)
                     {
                         break;
                     }
                     this.inventory[num180] = new Item();
                     break;
                 }
             }
         }
         if (item.createTile < 0)
         {
             num = (item.createWall <= 0 ? item.useTime : (int)((float)item.useTime * this.wallSpeed));
         }
         else
         {
             num = (int)((float)item.useTime * this.tileSpeed);
         }
         if (this.itemTime == num && item.consumable)
         {
             bool flag20 = true;
             if (item.type == ItemID.RecallPotion || item.type == ItemID.TeleportationPotion)
             {
                 flag20 = false;
             }
             if (item.type == ItemID.GenderChangePotion)
             {
                 flag20 = false;
             }
             if (item.ranged)
             {
                 if (this.ammoCost80 && Main.rand.Next(5) == 0)
                 {
                     flag20 = false;
                 }
                 if (this.ammoCost75 && Main.rand.Next(4) == 0)
                 {
                     flag20 = false;
                 }
             }
             if (item.thrown)
             {
                 if (this.thrownCost50 && Main.rand.Next(100) < 50)
                 {
                     flag20 = false;
                 }
                 if (this.thrownCost33 && Main.rand.Next(100) < 33)
                 {
                     flag20 = false;
                 }
             }
             if (item.type >= ItemID.CopperCoin && item.type <= ItemID.PlatinumCoin)
             {
                 flag20 = true;
             }
             if (flag20)
             {
                 if (item.stack > 0)
                 {
                     Item item22 = item;
                     item22.stack = item22.stack - 1;
                 }
                 if (item.stack <= 0)
                 {
                     this.itemTime = this.itemAnimation;
                     Main.blockMouse = true;
                 }
             }
         }
         if (item.stack <= 0 && this.itemAnimation == 0)
         {
             this.inventory[this.selectedItem] = new Item();
         }
         if (this.selectedItem == 58)
         {
             if (this.itemAnimation == 0)
             {
                 return;
             }
             Main.mouseItem = item.Clone();
         }
     }
 }
示例#24
0
 static public float Sin(Vector2 u, Vector2 v)
 {
     return((u.X * v.Y - u.Y * v.X) / (u.Length() * v.Length()));
 }
示例#25
0
 private static void HitWireSingle(int i, int j)
 {
     int num;
     int num1;
     short num2;
     Tile tile = Main.tile[i, j];
     int num3 = tile.type;
     if (tile.active() && num3 >= 255 && num3 <= 268)
     {
         if (num3 < 262)
         {
             Tile tile1 = tile;
             tile1.type = (ushort)(tile1.type + 7);
         }
         else
         {
             Tile tile2 = tile;
             tile2.type = (ushort)(tile2.type - 7);
         }
         NetMessage.SendTileSquare(-1, i, j, 1);
     }
     if (tile.actuator() && (num3 != 226 || (double)j <= Main.worldSurface || NPC.downedPlantBoss))
     {
         if (!tile.inActive())
         {
             Wiring.DeActive(i, j);
         }
         else
         {
             Wiring.ReActive(i, j);
         }
     }
     if (tile.active())
     {
         if (num3 == 144)
         {
             Wiring.HitSwitch(i, j);
             WorldGen.SquareTileFrame(i, j, true);
             NetMessage.SendTileSquare(-1, i, j, 1);
             return;
         }
         if (num3 == 406)
         {
             int num4 = tile.frameX % 54 / 18;
             int num5 = tile.frameY % 54 / 18;
             int num6 = i - num4;
             int num7 = j - num5;
             int num8 = 54;
             if (Main.tile[num6, num7].frameY >= 108)
             {
                 num8 = -108;
             }
             for (int i1 = num6; i1 < num6 + 3; i1++)
             {
                 for (int j1 = num7; j1 < num7 + 3; j1++)
                 {
                     Wiring.SkipWire(i1, j1);
                     Main.tile[i1, j1].frameY = (short)(Main.tile[i1, j1].frameY + num8);
                 }
             }
             NetMessage.SendTileSquare(-1, num6 + 1, num7 + 1, 3);
             return;
         }
         if (num3 == 411)
         {
             int num9 = tile.frameX % 36 / 18;
             int num10 = tile.frameY % 36 / 18;
             int num11 = i - num9;
             int num12 = j - num10;
             int num13 = 36;
             if (Main.tile[num11, num12].frameX >= 36)
             {
                 num13 = -36;
             }
             for (int k = num11; k < num11 + 2; k++)
             {
                 for (int l = num12; l < num12 + 2; l++)
                 {
                     Wiring.SkipWire(k, l);
                     Main.tile[k, l].frameX = (short)(Main.tile[k, l].frameX + num13);
                 }
             }
             NetMessage.SendTileSquare(-1, num11, num12, 2);
             return;
         }
         if (num3 == 405)
         {
             int num14 = tile.frameX % 54 / 18;
             int num15 = tile.frameY % 36 / 18;
             int num16 = i - num14;
             int num17 = j - num15;
             int num18 = 54;
             if (Main.tile[num16, num17].frameX >= 54)
             {
                 num18 = -54;
             }
             for (int m = num16; m < num16 + 3; m++)
             {
                 for (int n = num17; n < num17 + 2; n++)
                 {
                     Wiring.SkipWire(m, n);
                     Main.tile[m, n].frameX = (short)(Main.tile[m, n].frameX + num18);
                 }
             }
             NetMessage.SendTileSquare(-1, num16 + 1, num17 + 1, 3);
             return;
         }
         if (num3 == 215)
         {
             int num19 = tile.frameX % 54 / 18;
             int num20 = tile.frameY % 36 / 18;
             int num21 = i - num19;
             int num22 = j - num20;
             int num23 = 36;
             if (Main.tile[num21, num22].frameY >= 36)
             {
                 num23 = -36;
             }
             for (int o = num21; o < num21 + 3; o++)
             {
                 for (int p = num22; p < num22 + 2; p++)
                 {
                     Wiring.SkipWire(o, p);
                     Main.tile[o, p].frameY = (short)(Main.tile[o, p].frameY + num23);
                 }
             }
             NetMessage.SendTileSquare(-1, num21 + 1, num22 + 1, 3);
             return;
         }
         if (num3 != 130)
         {
             if (num3 == 131)
             {
                 tile.type = 130;
                 WorldGen.SquareTileFrame(i, j, true);
                 NetMessage.SendTileSquare(-1, i, j, 1);
                 return;
             }
             if (num3 == 387 || num3 == 386)
             {
                 bool flag = num3 == 387;
                 int num24 = WorldGen.ShiftTrapdoor(i, j, true, -1).ToInt();
                 if (num24 == 0)
                 {
                     num24 = -WorldGen.ShiftTrapdoor(i, j, false, -1).ToInt();
                 }
                 if (num24 != 0)
                 {
                     NetMessage.SendData(19, -1, -1, "", 2 + flag.ToInt(), (float)i, (float)j, (float)num24, 0, 0, 0);
                     return;
                 }
             }
             else
             {
                 if (num3 == 389 || num3 == 388)
                 {
                     bool flag1 = num3 == 389;
                     WorldGen.ShiftTallGate(i, j, flag1);
                     NetMessage.SendData(19, -1, -1, "", 4 + flag1.ToInt(), (float)i, (float)j, 0f, 0, 0, 0);
                     return;
                 }
                 if (num3 == 11)
                 {
                     if (WorldGen.CloseDoor(i, j, true))
                     {
                         NetMessage.SendData(19, -1, -1, "", 1, (float)i, (float)j, 0f, 0, 0, 0);
                         return;
                     }
                 }
                 else if (num3 != 10)
                 {
                     if (num3 == 216)
                     {
                         WorldGen.LaunchRocket(i, j);
                         Wiring.SkipWire(i, j);
                         return;
                     }
                     if (num3 == 335)
                     {
                         int num25 = j - tile.frameY / 18;
                         int num26 = i - tile.frameX / 18;
                         Wiring.SkipWire(num26, num25);
                         Wiring.SkipWire(num26, num25 + 1);
                         Wiring.SkipWire(num26 + 1, num25);
                         Wiring.SkipWire(num26 + 1, num25 + 1);
                         if (Wiring.CheckMech(num26, num25, 30))
                         {
                             WorldGen.LaunchRocketSmall(num26, num25);
                             return;
                         }
                     }
                     else if (num3 == 338)
                     {
                         int num27 = j - tile.frameY / 18;
                         int num28 = i - tile.frameX / 18;
                         Wiring.SkipWire(num28, num27);
                         Wiring.SkipWire(num28, num27 + 1);
                         if (Wiring.CheckMech(num28, num27, 30))
                         {
                             bool flag2 = false;
                             int num29 = 0;
                             while (num29 < 1000)
                             {
                                 if (!Main.projectile[num29].active || Main.projectile[num29].aiStyle != 73 || Main.projectile[num29].ai[0] != (float)num28 || Main.projectile[num29].ai[1] != (float)num27)
                                 {
                                     num29++;
                                 }
                                 else
                                 {
                                     flag2 = true;
                                     break;
                                 }
                             }
                             if (!flag2)
                             {
                                 Projectile.NewProjectile((float)(num28 * 16 + 8), (float)(num27 * 16 + 2), 0f, 0f, 419 + Main.rand.Next(4), 0, 0f, Main.myPlayer, (float)num28, (float)num27);
                                 return;
                             }
                         }
                     }
                     else if (num3 != 235)
                     {
                         if (num3 == 4)
                         {
                             if (tile.frameX >= 66)
                             {
                                 Tile tile3 = tile;
                                 tile3.frameX = (short)(tile3.frameX - 66);
                             }
                             else
                             {
                                 Tile tile4 = tile;
                                 tile4.frameX = (short)(tile4.frameX + 66);
                             }
                             NetMessage.SendTileSquare(-1, i, j, 1);
                             return;
                         }
                         if (num3 == 149)
                         {
                             if (tile.frameX >= 54)
                             {
                                 Tile tile5 = tile;
                                 tile5.frameX = (short)(tile5.frameX - 54);
                             }
                             else
                             {
                                 Tile tile6 = tile;
                                 tile6.frameX = (short)(tile6.frameX + 54);
                             }
                             NetMessage.SendTileSquare(-1, i, j, 1);
                             return;
                         }
                         if (num3 == 244)
                         {
                             int num30 = tile.frameX / 18;
                             while (num30 >= 3)
                             {
                                 num30 = num30 - 3;
                             }
                             int num31 = tile.frameY / 18;
                             while (num31 >= 3)
                             {
                                 num31 = num31 - 3;
                             }
                             int num32 = i - num30;
                             int num33 = j - num31;
                             int num34 = 54;
                             if (Main.tile[num32, num33].frameX >= 54)
                             {
                                 num34 = -54;
                             }
                             for (int q = num32; q < num32 + 3; q++)
                             {
                                 for (int r = num33; r < num33 + 2; r++)
                                 {
                                     Wiring.SkipWire(q, r);
                                     Main.tile[q, r].frameX = (short)(Main.tile[q, r].frameX + num34);
                                 }
                             }
                             NetMessage.SendTileSquare(-1, num32 + 1, num33 + 1, 3);
                             return;
                         }
                         if (num3 == 42)
                         {
                             int num35 = tile.frameY / 18;
                             while (num35 >= 2)
                             {
                                 num35 = num35 - 2;
                             }
                             int num36 = j - num35;
                             short num37 = 18;
                             if (tile.frameX > 0)
                             {
                                 num37 = -18;
                             }
                             Tile tile7 = Main.tile[i, num36];
                             tile7.frameX = (short)(tile7.frameX + num37);
                             Tile tile8 = Main.tile[i, num36 + 1];
                             tile8.frameX = (short)(tile8.frameX + num37);
                             Wiring.SkipWire(i, num36);
                             Wiring.SkipWire(i, num36 + 1);
                             NetMessage.SendTileSquare(-1, i, j, 2);
                             return;
                         }
                         if (num3 == 93)
                         {
                             int num38 = tile.frameY / 18;
                             while (num38 >= 3)
                             {
                                 num38 = num38 - 3;
                             }
                             num38 = j - num38;
                             short num39 = 18;
                             if (tile.frameX > 0)
                             {
                                 num39 = -18;
                             }
                             Tile tile9 = Main.tile[i, num38];
                             tile9.frameX = (short)(tile9.frameX + num39);
                             Tile tile10 = Main.tile[i, num38 + 1];
                             tile10.frameX = (short)(tile10.frameX + num39);
                             Tile tile11 = Main.tile[i, num38 + 2];
                             tile11.frameX = (short)(tile11.frameX + num39);
                             Wiring.SkipWire(i, num38);
                             Wiring.SkipWire(i, num38 + 1);
                             Wiring.SkipWire(i, num38 + 2);
                             NetMessage.SendTileSquare(-1, i, num38 + 1, 3);
                             return;
                         }
                         if (num3 == 126 || num3 == 95 || num3 == 100 || num3 == 173)
                         {
                             int num40 = tile.frameY / 18;
                             while (num40 >= 2)
                             {
                                 num40 = num40 - 2;
                             }
                             num40 = j - num40;
                             int num41 = tile.frameX / 18;
                             if (num41 > 1)
                             {
                                 num41 = num41 - 2;
                             }
                             num41 = i - num41;
                             short num42 = 36;
                             if (Main.tile[num41, num40].frameX > 0)
                             {
                                 num42 = -36;
                             }
                             Tile tile12 = Main.tile[num41, num40];
                             tile12.frameX = (short)(tile12.frameX + num42);
                             Tile tile13 = Main.tile[num41, num40 + 1];
                             tile13.frameX = (short)(tile13.frameX + num42);
                             Tile tile14 = Main.tile[num41 + 1, num40];
                             tile14.frameX = (short)(tile14.frameX + num42);
                             Tile tile15 = Main.tile[num41 + 1, num40 + 1];
                             tile15.frameX = (short)(tile15.frameX + num42);
                             Wiring.SkipWire(num41, num40);
                             Wiring.SkipWire(num41 + 1, num40);
                             Wiring.SkipWire(num41, num40 + 1);
                             Wiring.SkipWire(num41 + 1, num40 + 1);
                             NetMessage.SendTileSquare(-1, num41, num40, 3);
                             return;
                         }
                         if (num3 == 34)
                         {
                             int num43 = tile.frameY / 18;
                             while (num43 >= 3)
                             {
                                 num43 = num43 - 3;
                             }
                             int num44 = j - num43;
                             int num45 = tile.frameX / 18;
                             if (num45 > 2)
                             {
                                 num45 = num45 - 3;
                             }
                             num45 = i - num45;
                             short num46 = 54;
                             if (Main.tile[num45, num44].frameX > 0)
                             {
                                 num46 = -54;
                             }
                             for (int s = num45; s < num45 + 3; s++)
                             {
                                 for (int t = num44; t < num44 + 3; t++)
                                 {
                                     Tile tile16 = Main.tile[s, t];
                                     tile16.frameX = (short)(tile16.frameX + num46);
                                     Wiring.SkipWire(s, t);
                                 }
                             }
                             NetMessage.SendTileSquare(-1, num45 + 1, num44 + 1, 3);
                             return;
                         }
                         if (num3 != 314)
                         {
                             if (num3 == 33 || num3 == 174)
                             {
                                 short num47 = 18;
                                 if (tile.frameX > 0)
                                 {
                                     num47 = -18;
                                 }
                                 Tile tile17 = tile;
                                 tile17.frameX = (short)(tile17.frameX + num47);
                                 NetMessage.SendTileSquare(-1, i, j, 3);
                                 return;
                             }
                             if (num3 == 92)
                             {
                                 int num48 = j - tile.frameY / 18;
                                 short num49 = 18;
                                 if (tile.frameX > 0)
                                 {
                                     num49 = -18;
                                 }
                                 for (int u = num48; u < num48 + 6; u++)
                                 {
                                     Tile tile18 = Main.tile[i, u];
                                     tile18.frameX = (short)(tile18.frameX + num49);
                                     Wiring.SkipWire(i, u);
                                 }
                                 NetMessage.SendTileSquare(-1, i, num48 + 3, 7);
                                 return;
                             }
                             if (num3 != 137)
                             {
                                 if (num3 == 139 || num3 == 35)
                                 {
                                     WorldGen.SwitchMB(i, j);
                                     return;
                                 }
                                 if (num3 == 207)
                                 {
                                     WorldGen.SwitchFountain(i, j);
                                     return;
                                 }
                                 if (num3 == 410)
                                 {
                                     WorldGen.SwitchMonolith(i, j);
                                     return;
                                 }
                                 if (num3 == 141)
                                 {
                                     WorldGen.KillTile(i, j, false, false, true);
                                     NetMessage.SendTileSquare(-1, i, j, 1);
                                     Projectile.NewProjectile((float)(i * 16 + 8), (float)(j * 16 + 8), 0f, 0f, 108, 500, 10f, Main.myPlayer, 0f, 0f);
                                     return;
                                 }
                                 if (num3 == 210)
                                 {
                                     WorldGen.ExplodeMine(i, j);
                                     return;
                                 }
                                 if (num3 == 142 || num3 == 143)
                                 {
                                     int num50 = j - tile.frameY / 18;
                                     int num51 = tile.frameX / 18;
                                     if (num51 > 1)
                                     {
                                         num51 = num51 - 2;
                                     }
                                     num51 = i - num51;
                                     Wiring.SkipWire(num51, num50);
                                     Wiring.SkipWire(num51, num50 + 1);
                                     Wiring.SkipWire(num51 + 1, num50);
                                     Wiring.SkipWire(num51 + 1, num50 + 1);
                                     if (num3 == 142)
                                     {
                                         for (int v = 0; v < 4; v++)
                                         {
                                             if (Wiring._numInPump >= 19)
                                             {
                                                 return;
                                             }
                                             if (v == 0)
                                             {
                                                 num = num51;
                                                 num1 = num50 + 1;
                                             }
                                             else if (v == 1)
                                             {
                                                 num = num51 + 1;
                                                 num1 = num50 + 1;
                                             }
                                             else if (v != 2)
                                             {
                                                 num = num51 + 1;
                                                 num1 = num50;
                                             }
                                             else
                                             {
                                                 num = num51;
                                                 num1 = num50;
                                             }
                                             Wiring._inPumpX[Wiring._numInPump] = num;
                                             Wiring._inPumpY[Wiring._numInPump] = num1;
                                             Wiring._numInPump = Wiring._numInPump + 1;
                                         }
                                         return;
                                     }
                                     for (int w = 0; w < 4; w++)
                                     {
                                         if (Wiring._numOutPump >= 19)
                                         {
                                             return;
                                         }
                                         if (w == 0)
                                         {
                                             num = num51;
                                             num1 = num50 + 1;
                                         }
                                         else if (w == 1)
                                         {
                                             num = num51 + 1;
                                             num1 = num50 + 1;
                                         }
                                         else if (w != 2)
                                         {
                                             num = num51 + 1;
                                             num1 = num50;
                                         }
                                         else
                                         {
                                             num = num51;
                                             num1 = num50;
                                         }
                                         Wiring._outPumpX[Wiring._numOutPump] = num;
                                         Wiring._outPumpY[Wiring._numOutPump] = num1;
                                         Wiring._numOutPump = Wiring._numOutPump + 1;
                                     }
                                     return;
                                 }
                                 if (num3 == 105)
                                 {
                                     int num52 = j - tile.frameY / 18;
                                     int num53 = tile.frameX / 18;
                                     int num54 = 0;
                                     while (num53 >= 2)
                                     {
                                         num53 = num53 - 2;
                                         num54++;
                                     }
                                     num53 = i - num53;
                                     Wiring.SkipWire(num53, num52);
                                     Wiring.SkipWire(num53, num52 + 1);
                                     Wiring.SkipWire(num53, num52 + 2);
                                     Wiring.SkipWire(num53 + 1, num52);
                                     Wiring.SkipWire(num53 + 1, num52 + 1);
                                     Wiring.SkipWire(num53 + 1, num52 + 2);
                                     int num55 = num53 * 16 + 16;
                                     int num56 = (num52 + 3) * 16;
                                     int num57 = -1;
                                     if (num54 == 4)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 1))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 1, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 7)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 49))
                                         {
                                             num57 = NPC.NewNPC(num55 - 4, num56 - 6, 49, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 8)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 55))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 55, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 9)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 46))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 46, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 10)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 21))
                                         {
                                             num57 = NPC.NewNPC(num55, num56, 21, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 18)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 67))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 67, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 23)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 63))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 63, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 27)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 85))
                                         {
                                             num57 = NPC.NewNPC(num55 - 9, num56, 85, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 28)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 74))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 74, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 34)
                                     {
                                         for (int x = 0; x < 2; x++)
                                         {
                                             for (int y = 0; y < 3; y++)
                                             {
                                                 Tile tile19 = Main.tile[num53 + x, num52 + y];
                                                 tile19.type = 349;
                                                 tile19.frameX = (short)(x * 18 + 216);
                                                 tile19.frameY = (short)(y * 18);
                                             }
                                         }
                                         Animation.NewTemporaryAnimation(0, 349, num53, num52);
                                         if (Main.netMode == 2)
                                         {
                                             NetMessage.SendTileRange(-1, num53, num52, 2, 3);
                                         }
                                     }
                                     else if (num54 == 42)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 58))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 58, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 37)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 600) && Item.MechSpawn((float)num55, (float)num56, 58) && Item.MechSpawn((float)num55, (float)num56, 1734) && Item.MechSpawn((float)num55, (float)num56, 1867))
                                         {
                                             Item.NewItem(num55, num56 - 16, 0, 0, 58, 1, false, 0, false);
                                         }
                                     }
                                     else if (num54 == 50)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 30) && NPC.MechSpawn((float)num55, (float)num56, 65) && !Collision.SolidTiles(num53 - 2, num53 + 3, num52, num52 + 2))
                                         {
                                             num57 = NPC.NewNPC(num55, num56 - 12, 65, 0, 0f, 0f, 0f, 0f, 255);
                                         }
                                     }
                                     else if (num54 == 2)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 600) && Item.MechSpawn((float)num55, (float)num56, 184) && Item.MechSpawn((float)num55, (float)num56, 1735) && Item.MechSpawn((float)num55, (float)num56, 1868))
                                         {
                                             Item.NewItem(num55, num56 - 16, 0, 0, 184, 1, false, 0, false);
                                         }
                                     }
                                     else if (num54 == 17)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 600) && Item.MechSpawn((float)num55, (float)num56, 166))
                                         {
                                             Item.NewItem(num55, num56 - 20, 0, 0, 166, 1, false, 0, false);
                                         }
                                     }
                                     else if (num54 == 40)
                                     {
                                         if (Wiring.CheckMech(num53, num52, 300))
                                         {
                                             int[] numArray = new int[10];
                                             int num58 = 0;
                                             for (int a = 0; a < 200; a++)
                                             {
                                                 if (Main.npc[a].active && (Main.npc[a].type == 17 || Main.npc[a].type == 19 || Main.npc[a].type == 22 || Main.npc[a].type == 38 || Main.npc[a].type == 54 || Main.npc[a].type == 107 || Main.npc[a].type == 108 || Main.npc[a].type == 142 || Main.npc[a].type == 160 || Main.npc[a].type == 207 || Main.npc[a].type == 209 || Main.npc[a].type == 227 || Main.npc[a].type == 228 || Main.npc[a].type == 229 || Main.npc[a].type == 358 || Main.npc[a].type == 369))
                                                 {
                                                     numArray[num58] = a;
                                                     num58++;
                                                     if (num58 >= 9)
                                                     {
                                                         break;
                                                     }
                                                 }
                                             }
                                             if (num58 > 0)
                                             {
                                                 int num59 = numArray[Main.rand.Next(num58)];
                                                 Main.npc[num59].position.X = (float)(num55 - Main.npc[num59].width / 2);
                                                 Main.npc[num59].position.Y = (float)(num56 - Main.npc[num59].height - 1);
                                                 NetMessage.SendData(23, -1, -1, "", num59, 0f, 0f, 0f, 0, 0, 0);
                                             }
                                         }
                                     }
                                     else if (num54 == 41 && Wiring.CheckMech(num53, num52, 300))
                                     {
                                         int[] numArray1 = new int[10];
                                         int num60 = 0;
                                         for (int b = 0; b < 200; b++)
                                         {
                                             if (Main.npc[b].active && (Main.npc[b].type == 18 || Main.npc[b].type == 20 || Main.npc[b].type == 124 || Main.npc[b].type == 178 || Main.npc[b].type == 208 || Main.npc[b].type == 353))
                                             {
                                                 numArray1[num60] = b;
                                                 num60++;
                                                 if (num60 >= 9)
                                                 {
                                                     break;
                                                 }
                                             }
                                         }
                                         if (num60 > 0)
                                         {
                                             int num61 = numArray1[Main.rand.Next(num60)];
                                             Main.npc[num61].position.X = (float)(num55 - Main.npc[num61].width / 2);
                                             Main.npc[num61].position.Y = (float)(num56 - Main.npc[num61].height - 1);
                                             NetMessage.SendData(23, -1, -1, "", num61, 0f, 0f, 0f, 0, 0, 0);
                                         }
                                     }
                                     if (num57 >= 0)
                                     {
                                         Main.npc[num57].@value = 0f;
                                         Main.npc[num57].npcSlots = 0f;
                                         return;
                                     }
                                 }
                                 else if (num3 == 349)
                                 {
                                     int num62 = j - tile.frameY / 18;
                                     int num63 = tile.frameX / 18;
                                     while (num63 >= 2)
                                     {
                                         num63 = num63 - 2;
                                     }
                                     num63 = i - num63;
                                     Wiring.SkipWire(num63, num62);
                                     Wiring.SkipWire(num63, num62 + 1);
                                     Wiring.SkipWire(num63, num62 + 2);
                                     Wiring.SkipWire(num63 + 1, num62);
                                     Wiring.SkipWire(num63 + 1, num62 + 1);
                                     Wiring.SkipWire(num63 + 1, num62 + 2);
                                     num2 = (short)(Main.tile[num63, num62].frameX != 0 ? -216 : 216);
                                     for (int c = 0; c < 2; c++)
                                     {
                                         for (int d = 0; d < 3; d++)
                                         {
                                             Tile tile20 = Main.tile[num63 + c, num62 + d];
                                             tile20.frameX = (short)(tile20.frameX + num2);
                                         }
                                     }
                                     if (Main.netMode == 2)
                                     {
                                         NetMessage.SendTileRange(-1, num63, num62, 2, 3);
                                     }
                                     Animation.NewTemporaryAnimation((num2 > 0 ? 0 : 1), 349, num63, num62);
                                 }
                             }
                             else
                             {
                                 int num64 = tile.frameY / 18;
                                 Vector2 zero = Vector2.Zero;
                                 float single = 0f;
                                 float single1 = 0f;
                                 int num65 = 0;
                                 int num66 = 0;
                                 switch (num64)
                                 {
                                     case 0:
                                     {
                                         if (!Wiring.CheckMech(i, j, 200))
                                         {
                                             break;
                                         }
                                         int num67 = -1;
                                         if (tile.frameX != 0)
                                         {
                                             num67 = 1;
                                         }
                                         single = (float)(12 * num67);
                                         num66 = 20;
                                         num65 = 98;
                                         zero = new Vector2((float)(i * 16 + 8), (float)(j * 16 + 7))
                                         {
                                             X = zero.X + (float)(10 * num67),
                                             Y = zero.Y + 2f
                                         };
                                         break;
                                     }
                                     case 1:
                                     {
                                         if (!Wiring.CheckMech(i, j, 200))
                                         {
                                             break;
                                         }
                                         int num68 = -1;
                                         if (tile.frameX != 0)
                                         {
                                             num68 = 1;
                                         }
                                         single = (float)(12 * num68);
                                         num66 = 40;
                                         num65 = 184;
                                         zero = new Vector2((float)(i * 16 + 8), (float)(j * 16 + 7))
                                         {
                                             X = zero.X + (float)(10 * num68),
                                             Y = zero.Y + 2f
                                         };
                                         break;
                                     }
                                     case 2:
                                     {
                                         if (!Wiring.CheckMech(i, j, 200))
                                         {
                                             break;
                                         }
                                         int num69 = -1;
                                         if (tile.frameX != 0)
                                         {
                                             num69 = 1;
                                         }
                                         single = (float)(5 * num69);
                                         num66 = 40;
                                         num65 = 187;
                                         zero = new Vector2((float)(i * 16 + 8), (float)(j * 16 + 7))
                                         {
                                             X = zero.X + (float)(10 * num69),
                                             Y = zero.Y + 2f
                                         };
                                         break;
                                     }
                                     case 3:
                                     {
                                         if (!Wiring.CheckMech(i, j, 300))
                                         {
                                             break;
                                         }
                                         num65 = 185;
                                         int num70 = 200;
                                         for (int e = 0; e < 1000; e++)
                                         {
                                             if (Main.projectile[e].active && Main.projectile[e].type == num65)
                                             {
                                                 Vector2 vector2 = new Vector2((float)(i * 16 + 8), (float)(j * 18 + 8)) - Main.projectile[e].Center;
                                                 float single2 = vector2.Length();
                                                 if (single2 < 50f)
                                                 {
                                                     num70 = num70 - 50;
                                                 }
                                                 else if (single2 < 100f)
                                                 {
                                                     num70 = num70 - 15;
                                                 }
                                                 else if (single2 < 200f)
                                                 {
                                                     num70 = num70 - 10;
                                                 }
                                                 else if (single2 < 300f)
                                                 {
                                                     num70 = num70 - 8;
                                                 }
                                                 else if (single2 < 400f)
                                                 {
                                                     num70 = num70 - 6;
                                                 }
                                                 else if (single2 < 500f)
                                                 {
                                                     num70 = num70 - 5;
                                                 }
                                                 else if (single2 < 700f)
                                                 {
                                                     num70 = num70 - 4;
                                                 }
                                                 else if (single2 >= 900f)
                                                 {
                                                     num70 = (single2 >= 1200f ? num70 - 1 : num70 - 2);
                                                 }
                                                 else
                                                 {
                                                     num70 = num70 - 3;
                                                 }
                                             }
                                         }
                                         if (num70 <= 0)
                                         {
                                             break;
                                         }
                                         single = (float)Main.rand.Next(-20, 21) * 0.05f;
                                         single1 = 4f + (float)Main.rand.Next(0, 21) * 0.05f;
                                         num66 = 40;
                                         zero = new Vector2((float)(i * 16 + 8), (float)(j * 16 + 16))
                                         {
                                             Y = zero.Y + 6f
                                         };
                                         Projectile.NewProjectile((float)((int)zero.X), (float)((int)zero.Y), single, single1, num65, num66, 2f, Main.myPlayer, 0f, 0f);
                                         break;
                                     }
                                     case 4:
                                     {
                                         if (!Wiring.CheckMech(i, j, 90))
                                         {
                                             break;
                                         }
                                         single = 0f;
                                         single1 = 8f;
                                         num66 = 60;
                                         num65 = 186;
                                         zero = new Vector2((float)(i * 16 + 8), (float)(j * 16 + 16))
                                         {
                                             Y = zero.Y + 10f
                                         };
                                         break;
                                     }
                                 }
                                 if (num65 != 0)
                                 {
                                     Projectile.NewProjectile((float)((int)zero.X), (float)((int)zero.Y), single, single1, num65, num66, 2f, Main.myPlayer, 0f, 0f);
                                     return;
                                 }
                             }
                         }
                         else if (Wiring.CheckMech(i, j, 5))
                         {
                             Minecart.FlipSwitchTrack(i, j);
                             return;
                         }
                     }
                     else
                     {
                         int num71 = i - tile.frameX / 18;
                         if (tile.wall == 87 && (double)j > Main.worldSurface && !NPC.downedPlantBoss)
                         {
                             return;
                         }
                         if (Wiring._teleport[0].X == -1f)
                         {
                             Wiring._teleport[0].X = (float)num71;
                             Wiring._teleport[0].Y = (float)j;
                             if (tile.halfBrick())
                             {
                                 Wiring._teleport[0].Y = Wiring._teleport[0].Y + 0.5f;
                                 return;
                             }
                         }
                         else if (Wiring._teleport[0].X != (float)num71 || Wiring._teleport[0].Y != (float)j)
                         {
                             Wiring._teleport[1].X = (float)num71;
                             Wiring._teleport[1].Y = (float)j;
                             if (tile.halfBrick())
                             {
                                 Wiring._teleport[1].Y = Wiring._teleport[1].Y + 0.5f;
                                 return;
                             }
                         }
                     }
                 }
                 else
                 {
                     int num72 = 1;
                     if (Main.rand.Next(2) == 0)
                     {
                         num72 = -1;
                     }
                     if (WorldGen.OpenDoor(i, j, num72))
                     {
                         NetMessage.SendData(19, -1, -1, "", 0, (float)i, (float)j, (float)num72, 0, 0, 0);
                         return;
                     }
                     if (WorldGen.OpenDoor(i, j, -num72))
                     {
                         NetMessage.SendData(19, -1, -1, "", 0, (float)i, (float)j, (float)(-num72), 0, 0, 0);
                         return;
                     }
                 }
             }
         }
         else
         {
             if (Main.tile[i, j - 1] != null && Main.tile[i, j - 1].active())
             {
                 if (Main.tile[i, j - 1].type == 21)
                 {
                     return;
                 }
                 if (Main.tile[i, j - 1].type == 88)
                 {
                     return;
                 }
             }
             tile.type = 131;
             WorldGen.SquareTileFrame(i, j, true);
             NetMessage.SendTileSquare(-1, i, j, 1);
             return;
         }
     }
 }
示例#26
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture      = ModContent.GetTexture("JoostMod/Projectiles/NightsFury_Chain");
            Player    player       = Main.player[projectile.owner];
            Vector2   position     = projectile.Center;
            Vector2   playerCenter = player.MountedCenter;

            if (player.bodyFrame.Y == player.bodyFrame.Height * 3)
            {
                playerCenter.X += 8 * player.direction;
                playerCenter.Y += 2 * player.gravDir;
            }
            else if (player.bodyFrame.Y == player.bodyFrame.Height * 2)
            {
                playerCenter.X += 6 * player.direction;
                playerCenter.Y += -12 * player.gravDir;
            }
            else if (player.bodyFrame.Y == player.bodyFrame.Height * 4)
            {
                playerCenter.X += 6 * player.direction;
                playerCenter.Y += 8 * player.gravDir;
            }
            else if (player.bodyFrame.Y == player.bodyFrame.Height)
            {
                playerCenter.X += -10 * player.direction;
                playerCenter.Y += -14 * player.gravDir;
            }
            Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
            Vector2   origin          = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
            float     num1            = (float)texture.Height * projectile.scale;
            Vector2   vector2_4       = playerCenter - position;
            float     rotation        = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
            bool      flag            = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if ((double)vector2_4.Length() < (double)num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector2_1 = vector2_4;
                    vector2_1.Normalize();
                    position += vector2_1 * num1;
                    vector2_4 = playerCenter - position;
                    Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
                    color2 = projectile.GetAlpha(color2);
                    Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, projectile.scale, SpriteEffects.None, 0.0f);
                }
            }

            Texture2D     tex     = Main.projectileTexture[projectile.type];
            SpriteEffects effects = SpriteEffects.None;

            if (projectile.spriteDirection == -1)
            {
                effects = SpriteEffects.FlipHorizontally;
            }
            Color color = Lighting.GetColor((int)(projectile.Center.X / 16), (int)(projectile.Center.Y / 16.0));

            spriteBatch.Draw(tex, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Rectangle?(new Rectangle(0, 0, tex.Width, tex.Height)), color, projectile.rotation, new Vector2(tex.Width / 2, tex.Height / 2), projectile.scale, effects, 0f);
            return(false);
        }
示例#27
0
 private void CalculateScale(ref Vector2 difference)
 {
     float desiredLength = difference.Length();
     _scale.X = desiredLength / _lineTexture.Width;
     _scale.Y = 1;
 }
示例#28
0
        // localai0 : 0 when spawned, 1 when otherNPC spawned.
        // ai0 = npc number of other NPC
        // ai1 = charge time for gun.
        // ai2 = used for frame??
        // ai3 =
        public override void AI()
        {
            int     otherNPC           = -1;
            Vector2 offsetFromOtherNPC = Vector2.Zero;

            if (npc.localAI[0] == 0f && Main.netMode != 1)
            {
                npc.localAI[0] = 1f;
                int newNPC = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, mod.NPCType("GreenFinTrapper"), npc.whoAmI, 0f, 0f, 0f, 0f, 255);
                npc.ai[0]     = (float)newNPC;
                npc.netUpdate = true;
            }
            int otherNPCCheck = (int)npc.ai[0];

            if (Main.npc[otherNPCCheck].active && Main.npc[otherNPCCheck].type == mod.NPCType("GreenFinTrapper"))
            {
                if (npc.timeLeft < 60)
                {
                    npc.timeLeft = 60;
                }
                otherNPC           = otherNPCCheck;
                offsetFromOtherNPC = Vector2.UnitY * -10f;
            }

            // If otherNPC exists, do this
            if (otherNPC != -1)
            {
                NPC nPC7 = Main.npc[otherNPC];
                npc.velocity        = Vector2.Zero;
                npc.position        = nPC7.Center;
                npc.position.X      = npc.position.X - (float)(npc.width / 2);
                npc.position.Y      = npc.position.Y - (float)(npc.height / 2);
                npc.position       += offsetFromOtherNPC;
                npc.gfxOffY         = nPC7.gfxOffY;
                npc.direction       = nPC7.direction;
                npc.spriteDirection = nPC7.spriteDirection;
                npc.timeLeft        = nPC7.timeLeft;
                npc.velocity        = nPC7.velocity;
                npc.target          = nPC7.target;
                if (npc.ai[1] < 60f)
                {
                    npc.ai[1] += 1f;
                }
                if (npc.justHit)
                {
                    npc.ai[1] = -30f;
                }
                int   projectileType   = Terraria.ID.ProjectileID.RayGunnerLaser;// 438;
                int   projectileDamage = 30;
                float scaleFactor20    = 7f;
                if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
                {
                    Vector2 vectorToPlayer           = Main.player[npc.target].Center - npc.Center;
                    Vector2 vectorToPlayerNormalized = Vector2.Normalize(vectorToPlayer);
                    float   num1547 = vectorToPlayer.Length();
                    float   num1548 = 700f;

                    if (num1547 < num1548)
                    {
                        if (npc.ai[1] == 60f && Math.Sign(vectorToPlayer.X) == npc.direction)
                        {
                            npc.ai[1] = -60f;
                            Vector2 center12  = Main.player[npc.target].Center;
                            Vector2 value26   = npc.Center - Vector2.UnitY * 4f;
                            Vector2 vector188 = center12 - value26;
                            vector188.X += (float)Main.rand.Next(-50, 51);
                            vector188.Y += (float)Main.rand.Next(-50, 51);
                            vector188.X *= (float)Main.rand.Next(80, 121) * 0.01f;
                            vector188.Y *= (float)Main.rand.Next(80, 121) * 0.01f;
                            vector188.Normalize();
                            if (float.IsNaN(vector188.X) || float.IsNaN(vector188.Y))
                            {
                                vector188 = -Vector2.UnitY;
                            }
                            vector188 *= scaleFactor20;
                            Projectile.NewProjectile(value26.X, value26.Y, vector188.X, vector188.Y, projectileType, projectileDamage, 0f, Main.myPlayer, 0f, 0f);
                            npc.netUpdate = true;
                        }
                        else
                        {
                            float oldAI2 = npc.ai[2];
                            npc.velocity.X = npc.velocity.X * 0.5f;
                            npc.ai[2]      = 3f;
                            if (Math.Abs(vectorToPlayerNormalized.Y) > Math.Abs(vectorToPlayerNormalized.X) * 2f)
                            {
                                if (vectorToPlayerNormalized.Y > 0f)
                                {
                                    npc.ai[2] = 1f;
                                }
                                else
                                {
                                    npc.ai[2] = 5f;
                                }
                            }
                            else if (Math.Abs(vectorToPlayerNormalized.X) > Math.Abs(vectorToPlayerNormalized.Y) * 2f)
                            {
                                npc.ai[2] = 3f;
                            }
                            else if (vectorToPlayerNormalized.Y > 0f)
                            {
                                npc.ai[2] = 2f;
                            }
                            else
                            {
                                npc.ai[2] = 4f;
                            }
                            if (npc.ai[2] != oldAI2)
                            {
                                npc.netUpdate = true;
                            }
                        }
                    }
                }
            }
            else
            {
                // This code is called when Bottom is dead. Top is transformed into a new NPC.
                npc.Transform(mod.NPCType("Kakamora2"));
                return;
            }
        }
示例#29
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            FollowState s;
            if (state == null) s = new FollowState();
            else s = (FollowState) state;

            Status = CycleStatus.NotStarted;

            if (host.HasConditionEffect(ConditionEffects.Paralyzed)) return;

            var player = host.GetNearestEntity(acquireRange, null);
            Vector2 vect;
            switch (s.State)
            {
                case F.DontKnowWhere:
                    if (player != null && s.RemainingTime <= 0)
                    {
                        s.State = F.Acquired;
                        if (duration > 0)
                            s.RemainingTime = duration;
                        goto case F.Acquired;
                    }
                    if (s.RemainingTime > 0)
                        s.RemainingTime -= time.thisTickTimes;
                    break;
                case F.Acquired:
                    if (player == null)
                    {
                        s.State = F.DontKnowWhere;
                        s.RemainingTime = 0;
                        break;
                    }
                    if (s.RemainingTime <= 0 && duration > 0)
                    {
                        s.State = F.DontKnowWhere;
                        s.RemainingTime = coolDown.Next(Random);
                        Status = CycleStatus.Completed;
                        break;
                    }
                    if (s.RemainingTime > 0)
                        s.RemainingTime -= time.thisTickTimes;

                    vect = new Vector2(player.X - host.X, player.Y - host.Y);
                    if (vect.Length() > range)
                    {
                        Status = CycleStatus.InProgress;
                        vect.X -= Random.Next(-2, 2)/2f;
                        vect.Y -= Random.Next(-2, 2)/2f;
                        vect.Normalize();
                        float dist = host.GetSpeed(speed)*(time.thisTickTimes/1000f);
                        host.ValidateAndMove(host.X + vect.X*dist, host.Y + vect.Y*dist);
                        host.UpdateCount++;
                    }
                    else
                    {
                        Status = CycleStatus.Completed;
                        s.State = F.Resting;
                        s.RemainingTime = 0;
                    }
                    break;
                case F.Resting:
                    if (player == null)
                    {
                        s.State = F.DontKnowWhere;
                        if (duration > 0)
                            s.RemainingTime = duration;
                        break;
                    }
                    Status = CycleStatus.Completed;
                    vect = new Vector2(player.X - host.X, player.Y - host.Y);
                    if (vect.Length() > range + 1)
                    {
                        s.State = F.Acquired;
                        s.RemainingTime = duration;
                        goto case F.Acquired;
                    }
                    break;
            }

            state = s;
        }
示例#30
0
        /// <summary>
        /// Gets fast-predicted unit position
        /// </summary>
        /// <param name="target">Target</param>
        /// <param name="path">Path</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="from">Spell casted position</param>
        /// <param name="moveSpeed">Move speed</param>
        /// <param name="distanceSet"></param>
        /// <returns></returns>
        public static Vector2 GetFastUnitPosition(Obj_AI_Base target, List <Vector2> path, float delay, float missileSpeed = 0, Vector2?from = null, float moveSpeed = 0, float distanceSet = 0)
        {
            if (from == null)
            {
                from = target.ServerPosition.To2D();
            }

            if (moveSpeed == 0)
            {
                moveSpeed = target.MoveSpeed;
            }

            if (path.Count <= 1 || (target is AIHeroClient && ((AIHeroClient)target).IsChannelingImportantSpell()) || Utility.IsImmobileTarget(target))
            {
                return(target.ServerPosition.To2D());
            }

            if (target.IsDashing())
            {
                return(target.GetDashInfo().Path.Last());
            }

            float distance = distanceSet;

            if (distance == 0)
            {
                float targetDistance = from.Value.Distance(target.ServerPosition);
                float flyTime        = 0f;

                if (missileSpeed != 0) //skillshot with a missile
                {
                    Vector2 Vt = (path[path.Count - 1] - path[0]).Normalized() * moveSpeed;
                    Vector2 Vs = (target.ServerPosition.To2D() - from.Value).Normalized() * missileSpeed;
                    Vector2 Vr = Vs - Vt;

                    flyTime = targetDistance / Vr.Length();

                    if (path.Count > 5) //complicated movement
                    {
                        flyTime = targetDistance / missileSpeed;
                    }
                }

                float t = flyTime + delay + Game.Ping / 2000f + ConfigMenu.SpellDelay / 1000f;
                distance = t * moveSpeed;
            }

            for (int i = 0; i < path.Count - 1; i++)
            {
                float d = path[i + 1].Distance(path[i]);
                if (distance == d)
                {
                    return(path[i + 1]);
                }
                else if (distance < d)
                {
                    return(path[i] + distance * (path[i + 1] - path[i]).Normalized());
                }
                else
                {
                    distance -= d;
                }
            }

            return(path.Last());
        }
        /// <summary>
        /// Starts a new combat stage.  Called right after the stage changes.
        /// </summary>
        /// <remarks>The stage never changes into NotStarted.</remarks>
        protected override void StartStage()
        {
            switch (stage)
            {
            case CombatActionStage.Preparing:     // called from Start()
            {
                // play the animations
                combatant.CombatSprite.PlayAnimation("ItemCast");
                itemSpritePosition = Combatant.Position;
                item.SpellSprite.PlayAnimation("Creation");
                Session.Party.RemoveFromInventory(item, 1);
            }
            break;

            case CombatActionStage.Advancing:
            {
                // play the animations
                item.SpellSprite.PlayAnimation("Traveling");
                // calculate the projectile destination
                projectileDirection = Target.Position -
                                      Combatant.OriginalPosition;
                totalProjectileDistance = projectileDirection.Length();
                projectileDirection.Normalize();
                projectileDistanceCovered = 0f;
                // determine if the projectile is flipped
                if (Target.Position.X > Combatant.Position.X)
                {
                    projectileSpriteEffect = SpriteEffects.FlipHorizontally;
                }
                else
                {
                    projectileSpriteEffect = SpriteEffects.None;
                }
                // get the projectile's cue and play it
                projectileCue = AudioManager.GetCue(item.TravelingCueName);
                if (projectileCue != null)
                {
                    projectileCue.Play();
                }
            }
            break;

            case CombatActionStage.Executing:
                // play the animation
                item.SpellSprite.PlayAnimation("Impact");
                // stop the projectile sound effect
                if (projectileCue != null)
                {
                    projectileCue.Stop(AudioStopOptions.Immediate);
                }
                // apply the item effect to the primary target
                bool damagedAnyone = ApplyItem(Target);
                // apply the item effect to the secondary targets
                foreach (Combatant targetCombatant in
                         CombatEngine.SecondaryTargetedCombatants)
                {
                    // skip any dead or dying combatants
                    if (targetCombatant.IsDeadOrDying)
                    {
                        continue;
                    }
                    // apply the effect
                    damagedAnyone |= ApplyItem(targetCombatant);
                }
                // play the impact sound effect
                if (damagedAnyone)
                {
                    AudioManager.PlayCue(item.ImpactCueName);
                    if (item.Overlay != null)
                    {
                        item.Overlay.PlayAnimation(0);
                        item.Overlay.ResetAnimation();
                    }
                }

                break;

            case CombatActionStage.Returning:
                // play the animation
                combatant.CombatSprite.PlayAnimation("Idle");
                break;

            case CombatActionStage.Finishing:
                // play the animation
                combatant.CombatSprite.PlayAnimation("Idle");
                break;

            case CombatActionStage.Complete:
                // play the animation
                combatant.CombatSprite.PlayAnimation("Idle");
                break;
            }
        }
示例#32
0
        public override void Behavior()
        {
            Player player = Main.player[base.projectile.owner];
            float  num    = (float)base.projectile.width * 1.1f;

            for (int i = 0; i < 1000; i++)
            {
                Terraria.Projectile projectile = Main.projectile[i];
                if (i != base.projectile.whoAmI && projectile.active && projectile.owner == base.projectile.owner && projectile.type == base.projectile.type && Math.Abs(base.projectile.position.X - projectile.position.X) + Math.Abs(base.projectile.position.Y - projectile.position.Y) < num)
                {
                    if (base.projectile.position.X < Main.projectile[i].position.X)
                    {
                        Terraria.Projectile expr_F3_cp_0 = base.projectile;
                        expr_F3_cp_0.velocity.X = expr_F3_cp_0.velocity.X - 0.08f;
                    }
                    else
                    {
                        Terraria.Projectile expr_111_cp_0 = base.projectile;
                        expr_111_cp_0.velocity.X = expr_111_cp_0.velocity.X + 0.08f;
                    }
                    if (base.projectile.position.Y < Main.projectile[i].position.Y)
                    {
                        Terraria.Projectile expr_150_cp_0 = base.projectile;
                        expr_150_cp_0.velocity.Y = expr_150_cp_0.velocity.Y - 0.08f;
                    }
                    else
                    {
                        Terraria.Projectile expr_16E_cp_0 = base.projectile;
                        expr_16E_cp_0.velocity.Y = expr_16E_cp_0.velocity.Y + 0.08f;
                    }
                }
            }
            Vector2 value = base.projectile.position;
            float   num2  = 500f;
            bool    flag  = false;

            base.projectile.tileCollide = true;
            for (int j = 0; j < 200; j++)
            {
                NPC nPC = Main.npc[j];
                if (nPC.CanBeChasedBy(this, false))
                {
                    float num3 = Vector2.Distance(nPC.Center, base.projectile.Center);
                    if ((num3 < num2 || !flag) && Collision.CanHitLine(base.projectile.position, base.projectile.width, base.projectile.height, nPC.position, nPC.width, nPC.height))
                    {
                        num2  = num3;
                        value = nPC.Center;
                        flag  = true;
                    }
                }
            }
            if (Vector2.Distance(player.Center, base.projectile.Center) > (flag ? 1000f : 500f))
            {
                base.projectile.ai[0]     = 1f;
                base.projectile.netUpdate = true;
            }
            if (base.projectile.ai[0] == 1f)
            {
                base.projectile.tileCollide = false;
            }
            if (flag && base.projectile.ai[0] == 0f)
            {
                Vector2 value2 = value - base.projectile.Center;
                if (value2.Length() > 200f)
                {
                    value2.Normalize();
                    base.projectile.velocity = (base.projectile.velocity * 20f + value2 * 6f) / 21f;
                }
                else
                {
                    base.projectile.velocity *= (float)Math.Pow(0.97, 2.0);
                }
            }
            else
            {
                if (!Collision.CanHitLine(base.projectile.Center, 1, 1, player.Center, 1, 1))
                {
                    base.projectile.ai[0] = 1f;
                }
                float num4 = 6f;
                if (base.projectile.ai[0] == 1f)
                {
                    num4 = 15f;
                }
                Vector2 center = base.projectile.Center;
                Vector2 vector = player.Center - center;
                base.projectile.ai[1]     = 3600f;
                base.projectile.netUpdate = true;
                int num5 = 1;
                for (int k = 0; k < base.projectile.whoAmI; k++)
                {
                    if (Main.projectile[k].active && Main.projectile[k].owner == base.projectile.owner && Main.projectile[k].type == base.projectile.type)
                    {
                        num5++;
                    }
                }
                vector.X -= (float)((10 + num5 * 40) * player.direction);
                vector.Y -= 70f;
                float num6 = vector.Length();
                if (num6 > 200f && num4 < 9f)
                {
                    num4 = 9f;
                }
                if (num6 < 100f && base.projectile.ai[0] == 1f && !Collision.SolidCollision(base.projectile.position, base.projectile.width, base.projectile.height))
                {
                    base.projectile.ai[0]     = 0f;
                    base.projectile.netUpdate = true;
                }
                if (num6 > 2000f)
                {
                    base.projectile.Center = player.Center;
                }
                if (num6 > 48f)
                {
                    vector.Normalize();
                    vector *= num4;
                    float num7 = 10f;
                    base.projectile.velocity = (base.projectile.velocity * num7 + vector) / (num7 + 1f);
                }
                else
                {
                    base.projectile.direction = Main.player[base.projectile.owner].direction;
                    base.projectile.velocity *= (float)Math.Pow(0.9, 2.0);
                }
            }
            base.projectile.rotation = base.projectile.velocity.X * 0.05f;
            if (base.projectile.velocity.X > 0f)
            {
                base.projectile.spriteDirection = (base.projectile.direction = -1);
            }
            else if (base.projectile.velocity.X < 0f)
            {
                base.projectile.spriteDirection = (base.projectile.direction = 1);
            }
            if (base.projectile.ai[1] > 0f)
            {
                base.projectile.ai[1] += 1f;
            }
            if (base.projectile.ai[1] > 140f)
            {
                base.projectile.ai[1]     = 0f;
                base.projectile.netUpdate = true;
            }
            if (base.projectile.ai[0] == 0f && flag)
            {
                if ((value - base.projectile.Center).X > 0f)
                {
                    base.projectile.spriteDirection = (base.projectile.direction = -1);
                }
                else if ((value - base.projectile.Center).X < 0f)
                {
                    base.projectile.spriteDirection = (base.projectile.direction = 1);
                }
                if (base.projectile.ai[1] == 0f)
                {
                    base.projectile.ai[1] = 1f;
                    if (Main.myPlayer == base.projectile.owner)
                    {
                        Vector2 vector2 = value - base.projectile.Center;
                        if (vector2 == Vector2.Zero)
                        {
                            vector2 = new Vector2(0f, 1f);
                        }
                        vector2.Normalize();
                        vector2 *= 9f;
                        int num8 = Terraria.Projectile.NewProjectile(base.projectile.Center.X, base.projectile.Center.Y, vector2.X, vector2.Y, base.mod.ProjectileType("SoulRune"), 34, base.projectile.knockBack, Main.myPlayer, 0f, 0f);
                        Main.projectile[num8].timeLeft  = 300;
                        Main.projectile[num8].netUpdate = true;
                        base.projectile.netUpdate       = true;
                    }
                }
            }
            if (base.projectile.ai[0] == 0f)
            {
                if (Main.rand.Next(5) == 0)
                {
                    int  num9          = Dust.NewDust(base.projectile.position, base.projectile.width, base.projectile.height / 2, 187, 0f, 0f, 0, default(Color), 1f);
                    Dust expr_8EC_cp_0 = Main.dust[num9];
                    expr_8EC_cp_0.velocity.Y = expr_8EC_cp_0.velocity.Y - 1.2f;
                }
            }
            else if (Main.rand.Next(3) == 0)
            {
                Vector2 velocity = base.projectile.velocity;
                if (velocity != Vector2.Zero)
                {
                    velocity.Normalize();
                }
                int num10 = Dust.NewDust(base.projectile.position, base.projectile.width, base.projectile.height, 187, 0f, 0f, 0, default(Color), 1f);
                Main.dust[num10].velocity -= 1.2f * velocity;
            }
            Lighting.AddLight((int)(base.projectile.Center.X / 16f), (int)(base.projectile.Center.Y / 16f), 0.2f, 0.2f, 0.9f);
        }
        /// <summary>
        /// Handles the input and movement of the character.
        /// </summary>
        /// <param name="dt">Time since last frame in simulation seconds.</param>
        /// <param name="previousKeyboardInput">The last frame's keyboard state.</param>
        /// <param name="keyboardInput">The current frame's keyboard state.</param>
        /// <param name="previousGamePadInput">The last frame's gamepad state.</param>
        /// <param name="gamePadInput">The current frame's keyboard state.</param>
        public void Update(float dt, KeyboardState previousKeyboardInput, KeyboardState keyboardInput, GamePadState previousGamePadInput, GamePadState gamePadInput)
        {
            if (IsActive)
            {
                CameraControlScheme.Update(dt);

                Vector2 totalMovement = Vector2.Zero;

#if XBOX360
                totalMovement += new Vector2(gamePadInput.ThumbSticks.Left.X, gamePadInput.ThumbSticks.Left.Y);

                CharacterController.HorizontalMotionConstraint.SpeedScale = Math.Min(totalMovement.Length(), 1); //Don't trust the game pad to output perfectly normalized values.
                CharacterController.HorizontalMotionConstraint.MovementDirection = totalMovement;
                
                CharacterController.StanceManager.DesiredStance = gamePadInput.IsButtonDown(Buttons.RightStick) ? Stance.Crouching : Stance.Standing;

                //Jumping
                if (previousGamePadInput.IsButtonUp(Buttons.LeftStick) && gamePadInput.IsButtonDown(Buttons.LeftStick))
                {
                    CharacterController.Jump();
                }
#else

                //Collect the movement impulses.

                if (keyboardInput.IsKeyDown(Keys.E))
                {
                    totalMovement += new Vector2(0, 1);
                }
                if (keyboardInput.IsKeyDown(Keys.D))
                {
                    totalMovement += new Vector2(0, -1);
                }
                if (keyboardInput.IsKeyDown(Keys.S))
                {
                    totalMovement += new Vector2(-1, 0);
                }
                if (keyboardInput.IsKeyDown(Keys.F))
                {
                    totalMovement += new Vector2(1, 0);
                }
                if (totalMovement == Vector2.Zero)
                    CharacterController.HorizontalMotionConstraint.MovementDirection = Vector2.Zero;
                else
                    CharacterController.HorizontalMotionConstraint.MovementDirection = Vector2.Normalize(totalMovement);


                //Jumping
                if (previousKeyboardInput.IsKeyUp(Keys.A) && keyboardInput.IsKeyDown(Keys.A))
                {
                    CharacterController.Jump();
                }
#endif
                CharacterController.ViewDirection = Camera.WorldMatrix.Forward;

            }
        }
        public override void AI()
        {
            if (projectile.ai[0] < 0 || projectile.ai[0] >= Main.maxNPCs)
            {
                projectile.Kill();
                return;
            }

            if (!drawLoaded)
            {
                drawLoaded      = true;
                drawBase        = Main.rand.Next(8);
                projectile.hide = false;
            }

            NPC npc = Main.npc[(int)projectile.ai[0]];

            Vector2 target;

            target.X = npc.Center.X;
            target.Y = Main.player[npc.target].Center.Y;

            target.X += 1100 * (float)Math.Sin(2 * Math.PI / 600 * projectile.ai[1]++);
            target.Y -= 400;

            Vector2 distance = target - projectile.Center;
            float   length   = distance.Length();

            if (length > 25f)
            {
                distance           /= 8f;
                projectile.velocity = (projectile.velocity * 23f + distance) / 24f;
            }
            else
            {
                if (projectile.velocity.Length() < 12f)
                {
                    projectile.velocity *= 1.05f;
                }
            }

            if (++projectile.localAI[0] > 90) //spray shards
            {
                if (projectile.localAI[0] > (npc.localAI[3] > 1 ? 120 : 105))
                {
                    projectile.localAI[0] = npc.localAI[3] > 1 ? 30 : 45;
                }

                if (++projectile.localAI[1] > 3)
                {
                    projectile.localAI[1] = 0;

                    if (Main.netMode != NetmodeID.MultiplayerClient)
                    {
                        Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 3, mod.ProjectileType("DeviLightBall2"),
                                                 projectile.damage, projectile.knockBack, projectile.owner);
                    }
                }

                /*Main.PlaySound(SoundID.Item27, projectile.position);
                 * projectile.localAI[1] = 0f;
                 * if (Main.netMode != NetmodeID.MultiplayerClient)
                 * {
                 *  if (Math.Abs(npc.Center.X - projectile.Center.X) > (npc.localAI[3] > 1 ? 300 : 450))
                 *  {
                 *      Vector2 speed = new Vector2(Main.rand.Next(-1000, 1001), Main.rand.Next(-1000, 1001));
                 *      speed.Normalize();
                 *      speed *= 8f;
                 *      Projectile.NewProjectile(projectile.Center + speed * 4f, speed, mod.ProjectileType("AbomFrostShard"), projectile.damage, projectile.knockBack, projectile.owner);
                 *      Projectile.NewProjectile(projectile.Center + Vector2.UnitY * 8f, Vector2.UnitY * 8f, mod.ProjectileType("AbomFrostShard"), projectile.damage, projectile.knockBack, projectile.owner);
                 *  }
                 *  if (Main.player[npc.target].active && !Main.player[npc.target].dead && Main.player[npc.target].Center.Y < projectile.Center.Y)
                 *  {
                 *      Main.PlaySound(SoundID.Item120, projectile.position);
                 *      if (Main.netMode != NetmodeID.MultiplayerClient)
                 *      {
                 *          Vector2 vel = projectile.DirectionTo(Main.player[npc.target].Center + new Vector2(Main.rand.Next(-200, 201), Main.rand.Next(-200, 201))) * 12f;
                 *          Projectile.NewProjectile(projectile.Center, vel, mod.ProjectileType("AbomFrostWave"), projectile.damage, projectile.knockBack, projectile.owner);
                 *      }
                 *  }
                 * }*/
            }

            projectile.direction = projectile.spriteDirection = Math.Sign(projectile.velocity.X);

            projectile.frameCounter++;
            if (projectile.frameCounter < 4)
            {
                projectile.frame = 0;
            }
            else if (projectile.frameCounter < 8)
            {
                projectile.frame = 1;
            }
            else if (projectile.frameCounter < 12)
            {
                projectile.frame = 2;
            }
            else if (projectile.frameCounter < 16)
            {
                projectile.frame = 1;
            }
            else
            {
                projectile.frameCounter = 0;
            }

            /*if (projectile.frame < drawBase)
             *  projectile.frame = drawBase;
             *
             * if (++projectile.frameCounter > 6)
             * {
             *  projectile.frameCounter = 0;
             *
             *  if (++projectile.frame >= drawBase + 3)
             *      projectile.frame = drawBase;
             * }*/
        }
示例#35
0
        public void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 lookAtPosition)
        {
            if ((!LosEnabled || LosMode == LosMode.None) && !ObstructVision)
            {
                return;
            }
            if (ViewTarget == null)
            {
                return;
            }

            graphics.SetRenderTarget(LosTexture);

            spriteBatch.Begin(SpriteSortMode.Deferred, transformMatrix: cam.Transform * Matrix.CreateScale(new Vector3(GameMain.Config.LightMapScale, GameMain.Config.LightMapScale, 1.0f)));
            if (ObstructVision)
            {
                graphics.Clear(Color.Black);
                Vector2 diff = lookAtPosition - ViewTarget.WorldPosition;
                diff.Y = -diff.Y;
                float rotation = MathUtils.VectorToAngle(diff);

                Vector2 scale = new Vector2(
                    MathHelper.Clamp(diff.Length() / 256.0f, 2.0f, 5.0f), 2.0f);

                spriteBatch.Draw(visionCircle, new Vector2(ViewTarget.WorldPosition.X, -ViewTarget.WorldPosition.Y), null, Color.White, rotation,
                                 new Vector2(visionCircle.Width * 0.2f, visionCircle.Height / 2), scale, SpriteEffects.None, 0.0f);
            }
            else
            {
                graphics.Clear(Color.White);
            }
            spriteBatch.End();


            //--------------------------------------

            if (LosEnabled && LosMode != LosMode.None && ViewTarget != null)
            {
                Vector2 pos = ViewTarget.DrawPosition;

                Rectangle camView = new Rectangle(cam.WorldView.X, cam.WorldView.Y - cam.WorldView.Height, cam.WorldView.Width, cam.WorldView.Height);

                Matrix shadowTransform = cam.ShaderTransform
                                         * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;

                var convexHulls = ConvexHull.GetHullsInRange(ViewTarget.Position, cam.WorldView.Width * 0.75f, ViewTarget.Submarine);
                if (convexHulls != null)
                {
                    List <VertexPositionColor>   shadowVerts   = new List <VertexPositionColor>();
                    List <VertexPositionTexture> penumbraVerts = new List <VertexPositionTexture>();
                    foreach (ConvexHull convexHull in convexHulls)
                    {
                        if (!convexHull.Enabled || !convexHull.Intersects(camView))
                        {
                            continue;
                        }

                        Vector2 relativeLightPos = pos;
                        if (convexHull.ParentEntity?.Submarine != null)
                        {
                            relativeLightPos -= convexHull.ParentEntity.Submarine.Position;
                        }

                        convexHull.CalculateShadowVertices(relativeLightPos, true);

                        //convert triangle strips to a triangle list
                        for (int i = 0; i < convexHull.ShadowVertexCount * 2 - 2; i++)
                        {
                            if (i % 2 == 0)
                            {
                                shadowVerts.Add(convexHull.ShadowVertices[i]);
                                shadowVerts.Add(convexHull.ShadowVertices[i + 1]);
                                shadowVerts.Add(convexHull.ShadowVertices[i + 2]);
                            }
                            else
                            {
                                shadowVerts.Add(convexHull.ShadowVertices[i]);
                                shadowVerts.Add(convexHull.ShadowVertices[i + 2]);
                                shadowVerts.Add(convexHull.ShadowVertices[i + 1]);
                            }
                        }

                        penumbraVerts.AddRange(convexHull.PenumbraVertices);
                    }

                    if (shadowVerts.Count > 0)
                    {
                        ConvexHull.shadowEffect.World = shadowTransform;
                        ConvexHull.shadowEffect.CurrentTechnique.Passes[0].Apply();
                        graphics.DrawUserPrimitives(PrimitiveType.TriangleList, shadowVerts.ToArray(), 0, shadowVerts.Count / 3, VertexPositionColor.VertexDeclaration);

                        if (penumbraVerts.Count > 0)
                        {
                            ConvexHull.penumbraEffect.World = shadowTransform;
                            ConvexHull.penumbraEffect.CurrentTechnique.Passes[0].Apply();
                            graphics.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVerts.ToArray(), 0, penumbraVerts.Count / 3, VertexPositionTexture.VertexDeclaration);
                        }
                    }
                }
            }
            graphics.SetRenderTarget(null);
        }
示例#36
0
        public override void AI()
        {
            if (projectile.ai[1] > -1f && projectile.ai[1] < 200f)
            {
                NPC npc = Main.npc[(int)projectile.ai[1]];
                if (npc.CanBeChasedBy(projectile))
                {
                    float   rotation = projectile.velocity.ToRotation();
                    Vector2 vel      = npc.Center - projectile.Center;
                    if (vel.Length() < 20f)
                    {
                        projectile.Kill();
                        return;
                    }
                    float targetAngle = vel.ToRotation();
                    projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(rotation.AngleLerp(targetAngle, 0.008f));
                }
                else
                {
                    projectile.ai[1] = -1f;
                }
            }
            else if (projectile.localAI[0] == 0f) //also used for dust timer btw
            {
                float maxDistance    = 1000f;
                int   possibleTarget = -1;
                for (int i = 0; i < 200; i++)
                {
                    NPC npc = Main.npc[i];
                    if (npc.CanBeChasedBy(projectile))// && Collision.CanHitLine(projectile.Center, 0, 0, npc.Center, 0, 0))
                    {
                        float npcDistance = projectile.Distance(npc.Center);
                        if (npcDistance < maxDistance)
                        {
                            maxDistance    = npcDistance;
                            possibleTarget = i;
                        }
                    }
                }
                projectile.ai[1] = possibleTarget;
            }

            projectile.alpha -= 40;
            if (projectile.alpha < 0)
            {
                projectile.alpha = 0;
            }

            projectile.frameCounter++;
            if (projectile.frameCounter > 2)
            {
                projectile.frameCounter = 0;
                projectile.frame++;
                if (projectile.frame > 3)
                {
                    projectile.frame = 0;
                }
            }

            Lighting.AddLight(projectile.Center, 1.1f, 0.9f, 0.4f);
            projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2;

            ++projectile.localAI[0];
            if ((double)projectile.localAI[0] == 12.0) //loads of vanilla dust :echprime:
            {
                projectile.localAI[0] = 0.0f;
                for (int index1 = 0; index1 < 12; ++index1)
                {
                    Vector2 vector2 = (Vector2.UnitX * (float)-projectile.width / 2f + -Vector2.UnitY.RotatedBy((double)index1 * 3.14159274101257 / 6.0, new Vector2()) * new Vector2(8f, 16f)).RotatedBy((double)projectile.rotation - 1.57079637050629, new Vector2());
                    int     index2  = Dust.NewDust(projectile.Center, 0, 0, 6, 0.0f, 0.0f, 160, new Color(), 1f);
                    Main.dust[index2].scale     = 1.1f;
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].position  = projectile.Center + vector2;
                    Main.dust[index2].velocity  = projectile.velocity * 0.1f;
                    Main.dust[index2].velocity  = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[index2].position) * 1.25f;
                }
            }
            if (Main.rand.Next(4) == 0)
            {
                for (int index1 = 0; index1 < 1; ++index1)
                {
                    Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.196349546313286).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2());
                    int     index2  = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0.0f, 0.0f, 100, new Color(), 1f);
                    Main.dust[index2].velocity *= 0.1f;
                    Main.dust[index2].position  = projectile.Center + vector2 * (float)projectile.width / 2f;
                    Main.dust[index2].fadeIn    = 0.9f;
                }
            }
            if (Main.rand.Next(32) == 0)
            {
                for (int index1 = 0; index1 < 1; ++index1)
                {
                    Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.392699092626572).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2());
                    int     index2  = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0.0f, 0.0f, 155, new Color(), 0.8f);
                    Main.dust[index2].velocity *= 0.3f;
                    Main.dust[index2].position  = projectile.Center + vector2 * (float)projectile.width / 2f;
                    if (Main.rand.Next(2) == 0)
                    {
                        Main.dust[index2].fadeIn = 1.4f;
                    }
                }
            }
            if (Main.rand.Next(2) == 0)
            {
                for (int index1 = 0; index1 < 2; ++index1)
                {
                    Vector2 vector2 = -Vector2.UnitX.RotatedByRandom(0.785398185253143).RotatedBy((double)projectile.velocity.ToRotation(), new Vector2());
                    int     index2  = Dust.NewDust(projectile.position, projectile.width, projectile.height, 6, 0.0f, 0.0f, 0, new Color(), 1.2f);
                    Main.dust[index2].velocity *= 0.3f;
                    Main.dust[index2].noGravity = true;
                    Main.dust[index2].position  = projectile.Center + vector2 * (float)projectile.width / 2f;
                    if (Main.rand.Next(2) == 0)
                    {
                        Main.dust[index2].fadeIn = 1.4f;
                    }
                }
            }
        }
示例#37
0
 /// <summary>
 /// Converts a cartesian (X, Y) vector to a polar (angle, distance) vector.
 /// </summary>
 /// <param Name="other">The cartesian vector</param>
 /// <returns>A polar vector.</returns>
 public static Vector2 RectangularToPolar(Vector2 other)
 {
     return(new Vector2((float)other.Length(), (float)Math.Atan2(other.Y, other.X)));
 }
        internal override void InitVelocityConstraints(ref SolverData data)
        {
            Body b1 = BodyA;
            Body b2 = BodyB;

            Transform xf1, xf2;

            b1.GetTransform(out xf1);
            b2.GetTransform(out xf2);

            // Compute the effective mass matrix.
            Vector2 r1 = MathUtils.Mul(ref xf1.q, LocalAnchorA - b1.LocalCenter);
            Vector2 r2 = MathUtils.Mul(ref xf2.q, LocalAnchorB - b2.LocalCenter);

            _u = b2.Sweep.C + r2 - b1.Sweep.C - r1;

            // Handle singularity.
            float length = _u.Length();

            if (length < MaxLength && length > MinLength)
            {
                return;
            }

            if (length > Settings.LinearSlop)
            {
                _u *= 1.0f / length;
            }
            else
            {
                _u = Vector2.Zero;
            }

            float cr1u    = MathUtils.Cross(r1, _u);
            float cr2u    = MathUtils.Cross(r2, _u);
            float invMass = b1.InvMass + b1.InvI * cr1u * cr1u + b2.InvMass + b2.InvI * cr2u * cr2u;

            Debug.Assert(invMass > Settings.Epsilon);
            _mass = invMass != 0.0f ? 1.0f / invMass : 0.0f;

            if (Frequency > 0.0f)
            {
                float C = length - MaxLength;

                // Frequency
                float omega = 2.0f * Settings.Pi * Frequency;

                // Damping coefficient
                float d = 2.0f * _mass * DampingRatio * omega;

                // Spring stiffness
                float k = _mass * omega * omega;

                // magic formulas
                _gamma = data.step.dt * (d + data.step.dt * k);
                _gamma = _gamma != 0.0f ? 1.0f / _gamma : 0.0f;
                _bias  = C * data.step.dt * k * _gamma;

                _mass = invMass + _gamma;
                _mass = _mass != 0.0f ? 1.0f / _mass : 0.0f;
            }

            if (Settings.EnableWarmstarting)
            {
                // Scale the impulse to support a variable time step.
                _impulse *= data.step.dtRatio;

                Vector2 P = _impulse * _u;
                b1.LinearVelocityInternal  -= b1.InvMass * P;
                b1.AngularVelocityInternal -= b1.InvI * MathUtils.Cross(r1, P);
                b2.LinearVelocityInternal  += b2.InvMass * P;
                b2.AngularVelocityInternal += b2.InvI * MathUtils.Cross(r2, P);
            }
            else
            {
                _impulse = 0.0f;
            }
        }
示例#39
0
 public void OnHit(float x, float y, Entity victim)
 {
     if (Main.myPlayer != this.whoAmI)
     {
         return;
     }
     if (this.onHitDodge && this.shadowDodgeTimer == 0 && Main.rand.Next(4) == 0)
     {
         if (!this.shadowDodge)
         {
             this.shadowDodgeTimer = 1800;
         }
         this.AddBuff(BuffID.ShadowDodge, 1800, true);
     }
     if (this.onHitRegen)
     {
         this.AddBuff(BuffID.RapidHealing, 300, true);
     }
     if (this.stardustMinion && victim is NPC)
     {
         for (int i = 0; i < 1000; i++)
         {
             Projectile projectile = Main.projectile[i];
             if (projectile.active && projectile.owner == this.whoAmI && projectile.type == ProjectileID.StardustCellMinion && projectile.localAI[1] <= 0f && Main.rand.Next(2) == 0)
             {
                 Vector2 vector2 = new Vector2(x, y) - projectile.Center;
                 if (vector2.Length() > 0f)
                 {
                     vector2.Normalize();
                 }
                 vector2 = vector2 * 20f;
                 Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector2.X, vector2.Y, 614, projectile.damage / 3, 0f, projectile.owner, 0f, (float)victim.whoAmI);
                 projectile.localAI[1] = (float)(30 + Main.rand.Next(4) * 10);
             }
         }
     }
     if (this.onHitPetal && this.petalTimer == 0)
     {
         this.petalTimer = 20;
         int num = 1;
         if (x < this.position.X + (float)(this.width / 2))
         {
             num = -1;
         }
         num = this.direction;
         float single = Main.screenPosition.X;
         if (num < 0)
         {
             single = single + (float)Main.screenWidth;
         }
         float single1 = Main.screenPosition.Y;
         single1 = single1 + (float)Main.rand.Next(Main.screenHeight);
         Vector2 vector21 = new Vector2(single, single1);
         float single2 = x - vector21.X;
         float single3 = y - vector21.Y;
         single2 = single2 + (float)Main.rand.Next(-50, 51) * 0.1f;
         single3 = single3 + (float)Main.rand.Next(-50, 51) * 0.1f;
         int num1 = 24;
         float single4 = (float)Math.Sqrt((double)(single2 * single2 + single3 * single3));
         single4 = (float)num1 / single4;
         single2 = single2 * single4;
         single3 = single3 * single4;
         Projectile.NewProjectile(single, single1, single2, single3, ProjectileID.FlowerPetal, 36, 0f, this.whoAmI, 0f, 0f);
     }
     if (this.crystalLeaf && this.petalTimer == 0)
     {
         int num2 = this.inventory[this.selectedItem].type;
         for (int j = 0; j < 1000; j++)
         {
             if (Main.projectile[j].owner == this.whoAmI && Main.projectile[j].type == ProjectileID.CrystalLeaf)
             {
                 this.petalTimer = 50;
                 float single5 = 12f;
                 Vector2 vector22 = new Vector2(Main.projectile[j].position.X + (float)this.width * 0.5f, Main.projectile[j].position.Y + (float)this.height * 0.5f);
                 float single6 = x - vector22.X;
                 float single7 = y - vector22.Y;
                 float single8 = (float)Math.Sqrt((double)(single6 * single6 + single7 * single7));
                 single8 = single5 / single8;
                 single6 = single6 * single8;
                 single7 = single7 * single8;
                 Projectile.NewProjectile(Main.projectile[j].Center.X - 4f, Main.projectile[j].Center.Y, single6, single7, 227, Player.crystalLeafDamage, (float)Player.crystalLeafKB, this.whoAmI, 0f, 0f);
                 return;
             }
         }
     }
 }
示例#40
0
        private void ProcessInput()
        {
            float deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;

            translation = Vector3.Zero;
            yaw         = 0f;
            pitch       = 0f;

            // Keyboard and Gamepad based movement
            {
                // Our base speed is: one unit per second:
                //    deltaTime contains the duration of the previous frame, let's say that in this update
                //    or frame it is equal to 1/60, that means that the previous update ran 1/60 of a second ago
                //    and the next will, in most cases, run in around 1/60 of a second from now. Knowing that,
                //    we can move 1/60 of a unit on this frame so that in around 60 frames(1 second)
                //    we will have travelled one whole unit in a second.
                //    If you don't use deltaTime your speed will be dependant on the amount of frames rendered
                //    on screen which often are inconsistent, meaning that if the player has performance issues,
                //    this entity will move around slower.
                float speed = 1f * deltaTime;

                Vector3 dir = Vector3.Zero;

                if (Gamepad && Input.HasGamePad)
                {
                    GamePadState padState = Input.DefaultGamePad.State;
                    // LeftThumb can be positive or negative on both axis (pushed to the right or to the left)
                    dir.Z += padState.LeftThumb.Y;
                    dir.X += padState.LeftThumb.X;

                    // Triggers are always positive, in this case using one to increase and the other to decrease
                    dir.Y -= padState.LeftTrigger;
                    dir.Y += padState.RightTrigger;

                    // Increase speed when pressing A, LeftShoulder or RightShoulder
                    // Here:does the enum flag 'Buttons' has one of the flag ('A','LeftShoulder' or 'RightShoulder') set
                    if ((padState.Buttons & (GamePadButton.A | GamePadButton.LeftShoulder | GamePadButton.RightShoulder)) != 0)
                    {
                        speed *= SpeedFactor;
                    }
                }

                if (Input.HasKeyboard)
                {
                    // Move with keyboard
                    // Forward/Backward
                    if (Input.IsKeyDown(Keys.W) || Input.IsKeyDown(Keys.Up))
                    {
                        dir.Z += 1;
                    }
                    if (Input.IsKeyDown(Keys.S) || Input.IsKeyDown(Keys.Down))
                    {
                        dir.Z -= 1;
                    }

                    // Left/Right
                    if (Input.IsKeyDown(Keys.A) || Input.IsKeyDown(Keys.Left))
                    {
                        dir.X -= 1;
                    }
                    if (Input.IsKeyDown(Keys.D) || Input.IsKeyDown(Keys.Right))
                    {
                        dir.X += 1;
                    }

                    // Down/Up
                    if (Input.IsKeyDown(Keys.Q))
                    {
                        dir.Y -= 1;
                    }
                    if (Input.IsKeyDown(Keys.E))
                    {
                        dir.Y += 1;
                    }

                    // Increase speed when pressing shift
                    if (Input.IsKeyDown(Keys.LeftShift) || Input.IsKeyDown(Keys.RightShift))
                    {
                        speed *= SpeedFactor;
                    }

                    // If the player pushes down two or more buttons, the direction and ultimately the base speed
                    // will be greater than one (vector(1, 1) is farther away from zero than vector(0, 1)),
                    // normalizing the vector ensures that whichever direction the player chooses, that direction
                    // will always be at most one unit in length.
                    // We're keeping dir as is if isn't longer than one to retain sub unit movement:
                    // a stick not entirely pushed forward should make the entity move slower.
                    if (dir.Length() > 1f)
                    {
                        dir = Vector3.Normalize(dir);
                    }
                }

                // Finally, push all of that to the translation variable which will be used within UpdateTransform()
                translation += dir * KeyboardMovementSpeed * speed;
            }

            // Keyboard and Gamepad based Rotation
            {
                // See Keyboard & Gamepad translation's deltaTime usage
                float   speed    = 1f * deltaTime;
                Vector2 rotation = Vector2.Zero;
                if (Gamepad && Input.HasGamePad)
                {
                    GamePadState padState = Input.DefaultGamePad.State;
                    rotation.X += padState.RightThumb.Y;
                    rotation.Y += -padState.RightThumb.X;
                }

                if (Input.HasKeyboard)
                {
                    if (Input.IsKeyDown(Keys.NumPad2))
                    {
                        rotation.X += 1;
                    }
                    if (Input.IsKeyDown(Keys.NumPad8))
                    {
                        rotation.X -= 1;
                    }

                    if (Input.IsKeyDown(Keys.NumPad4))
                    {
                        rotation.Y += 1;
                    }
                    if (Input.IsKeyDown(Keys.NumPad6))
                    {
                        rotation.Y -= 1;
                    }

                    // See Keyboard & Gamepad translation's Normalize() usage
                    if (rotation.Length() > 1f)
                    {
                        rotation = Vector2.Normalize(rotation);
                    }
                }

                // Modulate by speed
                rotation *= KeyboardRotationSpeed * speed;

                // Finally, push all of that to pitch & yaw which are going to be used within UpdateTransform()
                pitch += rotation.X;
                yaw   += rotation.Y;
            }

            // Mouse movement and gestures
            {
                // This type of input should not use delta time at all, they already are frame-rate independent.
                //    Lets say that you are going to move your finger/mouse for one second over 40 units, it doesn't matter
                //    the amount of frames occuring within that time frame, each frame will receive the right amount of delta:
                //    a quarter of a second -> 10 units, half a second -> 20 units, one second -> your 40 units.

                if (Input.HasMouse)
                {
                    // Rotate with mouse
                    if (Input.IsMouseButtonDown(MouseButton.Right))
                    {
                        Input.LockMousePosition();
                        Game.IsMouseVisible = false;

                        yaw   -= Input.MouseDelta.X * MouseRotationSpeed.X;
                        pitch -= Input.MouseDelta.Y * MouseRotationSpeed.Y;
                    }
                    else
                    {
                        Input.UnlockMousePosition();
                        Game.IsMouseVisible = true;
                    }
                }

                // Handle gestures
                foreach (var gestureEvent in Input.GestureEvents)
                {
                    switch (gestureEvent.Type)
                    {
                    // Rotate by dragging
                    case GestureType.Drag:
                        var drag         = (GestureEventDrag)gestureEvent;
                        var dragDistance = drag.DeltaTranslation;
                        yaw   = -dragDistance.X * TouchRotationSpeed.X;
                        pitch = -dragDistance.Y * TouchRotationSpeed.Y;
                        break;

                    // Move along z-axis by scaling and in xy-plane by multi-touch dragging
                    case GestureType.Composite:
                        var composite = (GestureEventComposite)gestureEvent;
                        translation.X = -composite.DeltaTranslation.X * TouchMovementSpeed.X;
                        translation.Y = -composite.DeltaTranslation.Y * TouchMovementSpeed.Y;
                        translation.Z = (float)Math.Log(composite.DeltaScale + 1) * TouchMovementSpeed.Z;
                        break;
                    }
                }
            }
        }
        internal override void SolveVelocityConstraints(ref SolverData data)
        {
            Vector2 vA = data.velocities[_indexA].v;
            float wA = data.velocities[_indexA].w;

            // Cdot = v + cross(w, r)
            Vector2 Cdot = vA + MathUtils.Cross(wA, _rA);
            Vector2 impulse = MathUtils.Mul(ref _mass, -(Cdot + _C + _gamma * _impulse));

            Vector2 oldImpulse = _impulse;
            _impulse += impulse;
            float maxImpulse = data.step.dt * MaxForce;
            if (_impulse.LengthSquared() > maxImpulse * maxImpulse)
            {
                _impulse *= maxImpulse / _impulse.Length();
            }
            impulse = _impulse - oldImpulse;

            vA += _invMassA * impulse;
            wA += _invIA * MathUtils.Cross(_rA, impulse);

            data.velocities[_indexA].v = vA;
            data.velocities[_indexA].w = wA;
        }
示例#42
0
        public override bool PreAI()
        {
            Player     owner = Main.player[projectile.owner];
            SoulPlayer sp    = owner.GetModPlayer <SoulPlayer>();

            if (owner.active && !owner.dead && sp.BlueSoulNet.soulNPC == NPCID.StardustJellyfishBig)
            {
                projectile.timeLeft = 2;
            }

            for (int i = 0; i < Main.maxProjectiles; ++i)
            {
                if (Main.projectile[i].active && Main.projectile[i].owner == projectile.owner && Main.projectile[i].type == projectile.type)
                {
                    Vector2 directionToOther = projectile.Center - Main.projectile[i].Center;
                    if (directionToOther.HasNaNs() || directionToOther == Vector2.Zero)
                    {
                        directionToOther = -Vector2.UnitY;
                    }

                    if (directionToOther.Length() <= projectile.width * 2)
                    {
                        projectile.velocity += Vector2.Normalize(directionToOther) * 0.05f;
                    }
                }
            }

            if (projectile.ai[1] == 0)
            {
                projectile.ai[1] = 1;
                bodyParts        = new BodyPart[bodyLength];
                for (int i = 0; i < bodyParts.Length; ++i)
                {
                    bodyParts[i] = new BodyPart(projectile.position);
                }
            }
            else
            {
                Vector2 targetPosition = owner.Center;

                // Searching for a target.
                if (this.target == 255)
                {
                    float distance = maxTargetingDistance;
                    for (int i = 0; i < Main.maxNPCs; ++i)
                    {
                        if (Main.npc[i].CanBeChasedBy(projectile))
                        {
                            float d = Vector2.Distance(Main.npc[i].Center, owner.Center);
                            if (d <= distance)
                            {
                                target               = i;
                                distance             = d;
                                projectile.netUpdate = true;
                            }
                        }
                    }
                }
                else
                {
                    if (!Main.npc[target].active || Vector2.Distance(Main.npc[target].Center, owner.Center) > maxTargetingDistance * 2)
                    {
                        this.target = 255;
                    }
                    else
                    {
                        targetPosition = Main.npc[target].Center;
                    }
                }

                // Calculate desired velocity towards target.
                Vector2 projectileCenter = new Vector2((int)(projectile.Center.X / 16) * 16, (int)(projectile.Center.Y / 16) * 16);
                targetPosition = new Vector2((int)(targetPosition.X / 16) * 16, (int)(targetPosition.Y / 16) * 16);

                targetPosition = Vector2.Normalize(targetPosition - projectileCenter) * speed;
                if (this.target != 255)
                {
                    targetPosition *= 2;
                }
                else
                {
                    if ((projectile.position - owner.position).Length() >= 800)
                    {
                        DustEffect();
                        projectile.position = owner.Center + new Vector2(Main.rand.NextFloat(-1, 1) * 60, Main.rand.NextFloat(-1, 1) * 60);
                        DustEffect();
                    }
                }

                // Update velocity.
                if (Math.Sign(projectile.velocity.X) == Math.Sign(targetPosition.X) ||
                    Math.Sign(projectile.velocity.Y) == Math.Sign(targetPosition.Y))
                {
                    if (projectile.velocity.X < targetPosition.X)
                    {
                        projectile.velocity.X += acceleration;
                    }
                    else if (projectile.velocity.X > targetPosition.X)
                    {
                        projectile.velocity.X -= acceleration;
                    }

                    if (projectile.velocity.Y < targetPosition.Y)
                    {
                        projectile.velocity.Y += acceleration;
                    }
                    else if (projectile.velocity.Y > targetPosition.Y)
                    {
                        projectile.velocity.Y -= acceleration;
                    }

                    if (Math.Abs(targetPosition.Y) < speed * .2f && ((projectile.velocity.X > 0 && targetPosition.X < 0) || (projectile.velocity.X < 0 && targetPosition.X > 0)))
                    {
                        if (projectile.velocity.Y > 0)
                        {
                            projectile.velocity.Y += acceleration * 2f;
                        }
                        else
                        {
                            projectile.velocity.Y -= acceleration * 2;
                        }
                    }
                    if (Math.Abs(targetPosition.X) < speed * .2 && ((projectile.velocity.Y > 0 && targetPosition.Y < 0) || (projectile.velocity.Y < 0 && targetPosition.Y > 0)))
                    {
                        if (projectile.velocity.X > 0)
                        {
                            projectile.velocity.X += acceleration * .2f;
                        }
                        else
                        {
                            projectile.velocity.X -= acceleration * .2f;
                        }
                    }
                }
                else if (Math.Abs(targetPosition.X) > Math.Abs(targetPosition.Y))
                {
                    if (projectile.velocity.X < targetPosition.X)
                    {
                        projectile.velocity.X += acceleration * 1.1f;
                    }
                    else if (projectile.velocity.X > targetPosition.X)
                    {
                        projectile.velocity.X -= acceleration * 1.1f;
                    }

                    if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < speed * .5f)
                    {
                        if (projectile.velocity.Y > 0)
                        {
                            projectile.velocity.Y += acceleration;
                        }
                        else
                        {
                            projectile.velocity.Y -= acceleration;
                        }
                    }
                }
                else
                {
                    if (projectile.velocity.Y < targetPosition.Y)
                    {
                        projectile.velocity.Y += acceleration * 1.1f;
                    }
                    else if (projectile.velocity.Y > targetPosition.Y)
                    {
                        projectile.velocity.Y -= acceleration * 1.1f;
                    }

                    if (Math.Abs(projectile.velocity.X) + Math.Abs(projectile.velocity.Y) < speed * .5f)
                    {
                        if (projectile.velocity.X > 0)
                        {
                            projectile.velocity.X += acceleration;
                        }
                        else
                        {
                            projectile.velocity.X -= acceleration;
                        }
                    }
                }

                UpdateBodyParts();
            }

            projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2;

            return(false);
        }
示例#43
0
        public override void AI()
        {
            Player   player    = Main.player[projectile.owner];
            MyPlayer modPlayer = player.GetModPlayer <MyPlayer>();

            projectile.frameCounter++;
            modPlayer.poseSoundName = poseSoundName;
            if (modPlayer.tuskActNumber == 2)
            {
                projectile.timeLeft = 2;
            }
            float   num   = 4f;
            Vector2 value = new Vector2((float)(player.direction * 30), -20f);

            projectile.direction = (projectile.spriteDirection = player.direction);
            Vector2 vector = player.MountedCenter + value;
            float   num6   = Vector2.Distance(projectile.Center, vector);

            if (num6 > 1000f)
            {
                projectile.Center = player.Center + value;
            }
            Vector2 vector2 = vector - projectile.Center;

            if (num6 < num)
            {
                projectile.velocity *= 0.25f;
            }
            if (vector2 != Vector2.Zero)
            {
                if (vector2.Length() < num * 0.5f)
                {
                    projectile.velocity = vector2;
                }
                else
                {
                    projectile.velocity = vector2 * 0.1f;
                }
            }
            if (projectile.velocity.Length() > 6f)
            {
                float num7 = projectile.velocity.X * 0.08f + projectile.velocity.Y * (float)projectile.spriteDirection * 0.02f;
                if (Math.Abs(projectile.rotation - num7) >= 3.14159274f)
                {
                    if (num7 < projectile.rotation)
                    {
                        projectile.rotation -= 6.28318548f;
                    }
                    else
                    {
                        projectile.rotation += 6.28318548f;
                    }
                }
                float num8 = 12f;
                projectile.rotation = (projectile.rotation * (num8 - 1f) + num7) / num8;
            }
            else
            {
                if (projectile.rotation > 3.14159274f)
                {
                    projectile.rotation -= 6.28318548f;
                }
                if (projectile.rotation > -0.005f && projectile.rotation < 0.005f)
                {
                    projectile.rotation = 0f;
                }
                else
                {
                    projectile.rotation *= 0.96f;
                }
            }
            projectile.localAI[0] += 1f;
            if (projectile.localAI[0] > 120f)
            {
                projectile.localAI[0] = 0f;
            }
            if (projectile.frameCounter >= 10)
            {
                projectile.frame       += 1;
                projectile.frameCounter = 0;
            }
            if (projectile.frame >= 4)
            {
                projectile.frame = 0;
            }
            projectile.netUpdate = true;
        }
示例#44
0
 private void AI_099_2()
 {
     bool flag = false;
     for (int i = 0; i < this.whoAmI; i++)
     {
         if (Main.projectile[i].active && Main.projectile[i].owner == this.owner && Main.projectile[i].type == this.type)
         {
             flag = true;
         }
     }
     if (this.owner == Main.myPlayer)
     {
         this.localAI[0] += 1f;
         if (flag)
         {
             this.localAI[0] += (float)Main.rand.Next(10, 31) * 0.1f;
         }
         float num = this.localAI[0] / 60f;
         num /= (1f + Main.player[this.owner].meleeSpeed) / 2f;
         if (this.type == ProjectileID.WoodYoyo && num > 3f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Rally && num > 5f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.CorruptYoyo && num > 7f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.CrimsonYoyo && num > 6f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.JungleYoyo && num > 8f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Code1 && num > 9f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Valor && num > 11f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Cascade && num > 13f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Gradient && num > 10f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.FormatC && num > 8f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.HelFire && num > 12f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Chik && num > 16f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Amarok && num > 15f)
         {
             this.ai[0] = -1f;
         }
         if (this.type == ProjectileID.Yelets && num > 14f)
         {
             this.ai[0] = -1f;
         }
     }
     if (this.type == ProjectileID.Terrarian && this.owner == Main.myPlayer)
     {
         this.localAI[1] += 1f;
         if (this.localAI[1] >= 6f)
         {
             float num2 = 400f;
             Vector2 vector = this.velocity;
             Vector2 vector2 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
             vector2.Normalize();
             vector2 *= (float)Main.rand.Next(10, 41) * 0.1f;
             if (Main.rand.Next(3) == 0)
             {
                 vector2 *= 2f;
             }
             vector *= 0.25f;
             vector += vector2;
             for (int j = 0; j < 200; j++)
             {
                 if (Main.npc[j].CanBeChasedBy(this, false))
                 {
                     float num3 = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
                     float num4 = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
                     float num5 = Math.Abs(this.position.X + (float)(this.width / 2) - num3) + Math.Abs(this.position.Y + (float)(this.height / 2) - num4);
                     if (num5 < num2 && Collision.CanHit(this.position, this.width, this.height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height))
                     {
                         num2 = num5;
                         vector.X = num3;
                         vector.Y = num4;
                         vector -= base.Center;
                         vector.Normalize();
                         vector *= 8f;
                     }
                 }
             }
             vector *= 0.8f;
             Projectile.NewProjectile(base.Center.X, base.Center.Y, vector.X, vector.Y, 604, this.damage, this.knockBack, this.owner, 0f, 0f);
             this.localAI[1] = 0f;
         }
     }
     bool flag2 = false;
     if (this.type >= ProjectileID.BlackCounterweight && this.type <= ProjectileID.YellowCounterweight)
     {
         flag2 = true;
     }
     if (Main.player[this.owner].dead)
     {
         this.Kill();
         return;
     }
     if (!flag2 && !flag)
     {
         Main.player[this.owner].heldProj = this.whoAmI;
         Main.player[this.owner].itemAnimation = 2;
         Main.player[this.owner].itemTime = 2;
         if (this.position.X + (float)(this.width / 2) > Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2))
         {
             Main.player[this.owner].ChangeDir(1);
             this.direction = 1;
         }
         else
         {
             Main.player[this.owner].ChangeDir(-1);
             this.direction = -1;
         }
     }
     if (this.velocity.HasNaNs())
     {
         this.Kill();
     }
     this.timeLeft = 6;
     float num6 = 10f;
     float num7 = 200f;
     if (this.type == ProjectileID.WoodYoyo)
     {
         num7 = 130f;
         num6 = 9f;
     }
     else if (this.type == ProjectileID.Rally)
     {
         num7 = 170f;
         num6 = 11f;
     }
     else if (this.type == ProjectileID.CorruptYoyo)
     {
         num7 = 195f;
         num6 = 12.5f;
     }
     else if (this.type == ProjectileID.CrimsonYoyo)
     {
         num7 = 207f;
         num6 = 12f;
     }
     else if (this.type == ProjectileID.JungleYoyo)
     {
         num7 = 215f;
         num6 = 13f;
     }
     else if (this.type == ProjectileID.Code1)
     {
         num7 = 220f;
         num6 = 13f;
     }
     else if (this.type == ProjectileID.Valor)
     {
         num7 = 225f;
         num6 = 14f;
     }
     else if (this.type == ProjectileID.Cascade)
     {
         num7 = 235f;
         num6 = 14f;
     }
     else if (this.type == ProjectileID.FormatC)
     {
         num7 = 235f;
         num6 = 15f;
     }
     else if (this.type == ProjectileID.Gradient)
     {
         num7 = 250f;
         num6 = 12f;
     }
     else if (this.type == ProjectileID.Chik)
     {
         num7 = 275f;
         num6 = 17f;
     }
     else if (this.type == ProjectileID.Amarok)
     {
         num7 = 270f;
         num6 = 14f;
     }
     else if (this.type == ProjectileID.HelFire)
     {
         num7 = 275f;
         num6 = 15f;
     }
     else if (this.type == ProjectileID.Code2)
     {
         num7 = 280f;
         num6 = 17f;
     }
     else if (this.type == ProjectileID.Yelets)
     {
         num7 = 290f;
         num6 = 16f;
     }
     else if (this.type == ProjectileID.Kraken)
     {
         num7 = 340f;
         num6 = 16f;
     }
     else if (this.type == ProjectileID.RedsYoyo || this.type == ProjectileID.ValkyrieYoyo)
     {
         num7 = 370f;
         num6 = 16f;
     }
     else if (this.type == ProjectileID.TheEyeOfCthulhu)
     {
         num7 = 360f;
         num6 = 16.5f;
     }
     else if (this.type == ProjectileID.Terrarian)
     {
         num7 = 400f;
         num6 = 17.5f;
     }
     if (Main.player[this.owner].yoyoString)
     {
         num7 = num7 * 1.25f + 30f;
     }
     num7 /= (1f + Main.player[this.owner].meleeSpeed * 3f) / 4f;
     num6 /= (1f + Main.player[this.owner].meleeSpeed * 3f) / 4f;
     float num10 = 14f - num6 / 2f;
     float num11 = 5f + num6 / 2f;
     if (flag)
     {
         num11 += 20f;
     }
     if (this.ai[0] >= 0f)
     {
         if (this.velocity.Length() > num6)
         {
             this.velocity *= 0.98f;
         }
         bool flag3 = false;
         bool flag4 = false;
         Vector2 vector3 = Main.player[this.owner].Center - base.Center;
         if (vector3.Length() > num7)
         {
             flag3 = true;
             if ((double)vector3.Length() > (double)num7 * 1.3)
             {
                 flag4 = true;
             }
         }
         if (this.owner == Main.myPlayer)
         {
             if (!Main.player[this.owner].channel || Main.player[this.owner].stoned || Main.player[this.owner].frozen)
             {
                 this.ai[0] = -1f;
                 this.ai[1] = 0f;
                 this.netUpdate = true;
             }
             else
             {
                 Vector2 vector4 = Main.ReverseGravitySupport(Main.MouseScreen, 0f) + Main.screenPosition;
                 float x = vector4.X;
                 float y = vector4.Y;
                 Vector2 vector5 = new Vector2(x, y) - Main.player[this.owner].Center;
                 if (vector5.Length() > num7)
                 {
                     vector5.Normalize();
                     vector5 *= num7;
                     vector5 = Main.player[this.owner].Center + vector5;
                     x = vector5.X;
                     y = vector5.Y;
                 }
                 if (this.ai[0] != x || this.ai[1] != y)
                 {
                     Vector2 vector6 = new Vector2(x, y);
                     Vector2 vector7 = vector6 - Main.player[this.owner].Center;
                     if (vector7.Length() > num7 - 1f)
                     {
                         vector7.Normalize();
                         vector7 *= num7 - 1f;
                         vector6 = Main.player[this.owner].Center + vector7;
                         x = vector6.X;
                         y = vector6.Y;
                     }
                     this.ai[0] = x;
                     this.ai[1] = y;
                     this.netUpdate = true;
                 }
             }
         }
         if (flag4 && this.owner == Main.myPlayer)
         {
             this.ai[0] = -1f;
             this.netUpdate = true;
         }
         if (this.ai[0] >= 0f)
         {
             if (flag3)
             {
                 num10 /= 2f;
                 num6 *= 2f;
                 if (base.Center.X > Main.player[this.owner].Center.X && this.velocity.X > 0f)
                 {
                     this.velocity.X = this.velocity.X * 0.5f;
                 }
                 if (base.Center.Y > Main.player[this.owner].Center.Y && this.velocity.Y > 0f)
                 {
                     this.velocity.Y = this.velocity.Y * 0.5f;
                 }
                 if (base.Center.X < Main.player[this.owner].Center.X && this.velocity.X > 0f)
                 {
                     this.velocity.X = this.velocity.X * 0.5f;
                 }
                 if (base.Center.Y < Main.player[this.owner].Center.Y && this.velocity.Y > 0f)
                 {
                     this.velocity.Y = this.velocity.Y * 0.5f;
                 }
             }
             Vector2 vector8 = new Vector2(this.ai[0], this.ai[1]);
             Vector2 vector9 = vector8 - base.Center;
             this.velocity.Length();
             if (vector9.Length() > num11)
             {
                 vector9.Normalize();
                 vector9 *= num6;
                 this.velocity = (this.velocity * (num10 - 1f) + vector9) / num10;
             }
             else if (flag)
             {
                 if ((double)this.velocity.Length() < (double)num6 * 0.6)
                 {
                     vector9 = this.velocity;
                     vector9.Normalize();
                     vector9 *= num6 * 0.6f;
                     this.velocity = (this.velocity * (num10 - 1f) + vector9) / num10;
                 }
             }
             else
             {
                 this.velocity *= 0.8f;
             }
             if (flag && !flag3 && (double)this.velocity.Length() < (double)num6 * 0.6)
             {
                 this.velocity.Normalize();
                 this.velocity *= num6 * 0.6f;
             }
         }
     }
     else
     {
         num10 = (float)((int)((double)num10 * 0.8));
         num6 *= 1.5f;
         this.tileCollide = false;
         Vector2 vector10 = Main.player[this.owner].position - base.Center;
         float num12 = vector10.Length();
         if (num12 < num6 + 10f || num12 == 0f)
         {
             this.Kill();
         }
         else
         {
             vector10.Normalize();
             vector10 *= num6;
             this.velocity = (this.velocity * (num10 - 1f) + vector10) / num10;
         }
     }
     this.rotation += 0.45f;
 }
示例#45
0
        internal override bool SolvePositionConstraints(float baumgarte)
        {
            Body b1 = _bodyA;
            Body b2 = _bodyB;

            Vector2 s1 = _groundAnchor1;
            Vector2 s2 = _groundAnchor2;

            float linearError = 0.0f;

            if (_state == LimitState.AtUpper)
            {
                XForm xf1, xf2;
                b1.GetXForm(out xf1);
                b2.GetXForm(out xf2);

                Vector2 r1 = MathUtils.Multiply(ref xf1.R, _localAnchor1 - b1.GetLocalCenter());
                Vector2 r2 = MathUtils.Multiply(ref xf2.R, _localAnchor2 - b2.GetLocalCenter());

                Vector2 p1 = b1._sweep.c + r1;
                Vector2 p2 = b2._sweep.c + r2;

                // Get the pulley axes.
                _u1 = p1 - s1;
                _u2 = p2 - s2;

                float length1 = _u1.Length();
                float length2 = _u2.Length();

                if (length1 > Settings.b2_linearSlop)
                {
                    _u1 *= 1.0f / length1;
                }
                else
                {
                    _u1 = Vector2.Zero;
                }

                if (length2 > Settings.b2_linearSlop)
                {
                    _u2 *= 1.0f / length2;
                }
                else
                {
                    _u2 = Vector2.Zero;
                }

                float C = _ant - length1 - _ratio * length2;
                linearError = Math.Max(linearError, -C);

                C = MathUtils.Clamp(C + Settings.b2_linearSlop, -Settings.b2_maxLinearCorrection, 0.0f);
                float impulse = -_pulleyMass * C;

                Vector2 P1 = -impulse * _u1;
                Vector2 P2 = -_ratio * impulse * _u2;

                b1._sweep.c += b1._invMass * P1;
                b1._sweep.a += b1._invI * MathUtils.Cross(r1, P1);
                b2._sweep.c += b2._invMass * P2;
                b2._sweep.a += b2._invI * MathUtils.Cross(r2, P2);

                b1.SynchronizeTransform();
                b2.SynchronizeTransform();
            }

            if (_limitState1 == LimitState.AtUpper)
            {
                XForm xf1;
                b1.GetXForm(out xf1);

                Vector2 r1 = MathUtils.Multiply(ref xf1.R, _localAnchor1 - b1.GetLocalCenter());
                Vector2 p1 = b1._sweep.c + r1;

                _u1 = p1 - s1;
                float length1 = _u1.Length();

                if (length1 > Settings.b2_linearSlop)
                {
                    _u1 *= 1.0f / length1;
                }
                else
                {
                    _u1 = Vector2.Zero;
                }

                float C = _maxLength1 - length1;
                linearError = Math.Max(linearError, -C);
                C = MathUtils.Clamp(C + Settings.b2_linearSlop, -Settings.b2_maxLinearCorrection, 0.0f);
                float impulse = -_limitMass1 * C;

                Vector2 P1 = -impulse * _u1;
                b1._sweep.c += b1._invMass * P1;
                b1._sweep.a += b1._invI * MathUtils.Cross(r1, P1);

                b1.SynchronizeTransform();
            }

            if (_limitState2 == LimitState.AtUpper)
            {
                XForm xf2;
                b2.GetXForm(out xf2);

                Vector2 r2 = MathUtils.Multiply(ref xf2.R, _localAnchor2 - b2.GetLocalCenter());
                Vector2 p2 = b2._sweep.c + r2;

                _u2 = p2 - s2;
                float length2 = _u2.Length();

                if (length2 > Settings.b2_linearSlop)
                {
                    _u2 *= 1.0f / length2;
                }
                else
                {
                    _u2 = Vector2.Zero;
                }

                float C = _maxLength2 - length2;
                linearError = Math.Max(linearError, -C);
                C = MathUtils.Clamp(C + Settings.b2_linearSlop, -Settings.b2_maxLinearCorrection, 0.0f);
                float impulse = -_limitMass2 * C;

                Vector2 P2 = -impulse * _u2;
                b2._sweep.c += b2._invMass * P2;
                b2._sweep.a += b2._invI * MathUtils.Cross(r2, P2);

                b2.SynchronizeTransform();
            }

            return linearError < Settings.b2_linearSlop;
        }
示例#46
0
        bool IsArcRadiusTooSmall()
        {
            // Get the distance between the arc start/end points.
            Vector2 arc = arcPoints[1] - arcPoints[0];

            // Compensate for any ellipse rotation.
            arc = Vector2.Transform(arc, Matrix3x2.CreateRotation(-Utils.DegreesToRadians(ArcRotation)));

            // Normalize to a unit circle.
            arc /= new Vector2(ArcRadiusX, ArcRadiusY);

            // If the length is greater than 2, there is no possible way to fit an arc of
            // the specified radius between the specified endpoints. D2D will compensate
            // by scaling up the radius, but the result may not be what was intended.
            return arc.Length() > 2;
        }
示例#47
0
 public static void Truncate(ref Vector2 vector, float maxLength, out Vector2 truncatedVector)
 {
     float length = vector.Length();
     length = Math.Min(length, maxLength);
     if (length > 0)
     {
         vector.Normalize();
     }
     Vector2.Multiply(ref vector, length, out truncatedVector);
 }
    bool CheckXBoxLeftThumbInput()
    {
        if (usingXboxControl)
        {
            if (FakeInput)
            {
                speedX = 0.0f;
                speedX += MonkeyInput.GetMovementXFloat();// Input.GetHeld(0, "right");
                //speedX -= MonkeyInput.GetMovementFloat();
                speedZ = 0.0f;
                speedZ += MonkeyInput.GetMovementZFloat();
                //speedZ -= MonkeyInput.GetMovementFloat();
                thumbstickMagnitude = 1;
            }
            else
            {
                // update how much left thumb is pressed
                speedX = Input.GetValue((char)0, "LThumbX");
                speedZ = Input.GetValue((char)0, "LThumbY");
                Vector2 stickInput = new Vector2(speedX, speedZ);
                // only use values for movment if the thumbstick is out of the deadzone
                thumbstickMagnitude = stickInput.Length();
            }
        }
        else
        {
                speedX = 0.0f;
                speedX += Input.GetHeld(0, "right");
                speedX -= Input.GetHeld(0, "left");
                speedZ = 0.0f;
                speedZ += Input.GetHeld(0, "up");
                speedZ -= Input.GetHeld(0, "down");
                thumbstickMagnitude = 1;
        }

        if (movementLocked || Common.isPaused)
        {
            speedX = 0.0f;
            speedZ = 0.0f;
        }

        /*
        if (Common.isPaused) // Prevent player inputs when paused
        {
            speedX = 0.0f;
            speedZ = 0.0f;
        }

        if (Common.isPaused) // Prevent player inputs when paused
        {
            if (prevIsPaused != Common.isPaused)
            {
                lastPositionToFreezeAt = gameObject.transform.GetGlobalPosition();
                playerPhysics.mIsGravityOn = false;
            }
            gameObject.transform.SetPosition(lastPositionToFreezeAt);
            speedX = 0.0f;
            speedZ = 0.0f;
        }
        else
        {
            if (prevIsPaused != Common.isPaused)
            {
                playerPhysics.mIsGravityOn = true;
            }
        }
        prevIsPaused = Common.isPaused;*/

        if (speedX == 0 && speedZ == 0)
            return false;
        else
            return true;
    }
示例#49
0
        public void Vector2LengthTest1()
        {
            Vector2 target = new Vector2();
            target.X = 0.0f;
            target.Y = 0.0f;

            float expected = 0.0f;
            float actual;

            actual = target.Length();

            Assert.IsTrue(MathHelper.Equal(expected, actual), "Vector2.Length did not return the expected value.");
        }
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            Vector2 speedto = Main.MouseWorld - position;
            Vector2 speed   = Vector2.Normalize(speedto) * (Math.Min(400f * player.Throwing().thrownVelocity, speedto.Length()));

            speed /= 30f;

            speedX = speed.X;
            speedY = speed.Y;

            //position = Main.MouseWorld;
            Projectile proj = Projectile.NewProjectileDirect(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f);

            if (proj != null)
            {
                SGAmod.GemColors.TryGetValue(gemType, out Color color);
                ((LaserMarkerProj)proj.modProjectile).gemColor = color;
            }

            return(false);
        }
示例#51
0
            private void DrawLine(SpriteBatch spriteBatch)
            {
                if (this.active || (double)this._lineOpacity == 0.0)
                {
                    return;
                }
                Vector2 vector2_1 = Main.MouseScreen;
                Vector2 vector2_2 = new Vector2((float)(Main.screenWidth / 2), (float)(Main.screenHeight - 70));

                if (PlayerInput.UsingGamepad)
                {
                    vector2_1 = Vector2.Zero;
                }
                Vector2 v                  = vector2_1 - vector2_2;
                double  num1               = (double)Vector2.Dot(Vector2.Normalize(v), Vector2.UnitX);
                double  num2               = (double)Vector2.Dot(Vector2.Normalize(v), Vector2.UnitY);
                double  rotation           = (double)v.ToRotation();
                double  num3               = (double)v.Length();
                bool    flag1              = false;
                bool    toolAllowActuators = WiresUI.Settings.DrawToolAllowActuators;

                for (int index = 0; index < 6; ++index)
                {
                    if (toolAllowActuators || index != 5)
                    {
                        bool flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum)(WiresUI.Settings.MultiToolMode)(1 << index));
                        if (index == 5)
                        {
                            flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum)WiresUI.Settings.MultiToolMode.Actuator);
                        }
                        Vector2 vector2_3 = vector2_2 + Vector2.UnitX * (float)(45.0 * ((double)index - 1.5));
                        int     num4      = index;
                        if (index == 0)
                        {
                            num4 = 3;
                        }
                        if (index == 3)
                        {
                            num4 = 0;
                        }
                        switch (num4)
                        {
                        case 0:
                        case 1:
                            vector2_3 = vector2_2 + new Vector2((float)(45.0 + (toolAllowActuators ? 15.0 : 0.0)) * (float)(2 - num4), 0.0f) * this._lineOpacity;
                            break;

                        case 2:
                        case 3:
                            vector2_3 = vector2_2 + new Vector2((float)-(45.0 + (toolAllowActuators ? 15.0 : 0.0)) * (float)(num4 - 1), 0.0f) * this._lineOpacity;
                            break;

                        case 4:
                            flag2     = false;
                            vector2_3 = vector2_2 - new Vector2(0.0f, toolAllowActuators ? 22f : 0.0f) * this._lineOpacity;
                            break;

                        case 5:
                            vector2_3 = vector2_2 + new Vector2(0.0f, 22f) * this._lineOpacity;
                            break;
                        }
                        bool flag3 = false;
                        if (!PlayerInput.UsingGamepad)
                        {
                            flag3 = (double)Vector2.Distance(vector2_3, vector2_1) < 19.0 * (double)this._lineOpacity;
                        }
                        if (flag1)
                        {
                            flag3 = false;
                        }
                        if (flag3)
                        {
                            flag1 = true;
                        }
                        Texture2D texture2D1 = Main.wireUITexture[(WiresUI.Settings.ToolMode.HasFlag((Enum)WiresUI.Settings.MultiToolMode.Cutter) ? 8 : 0) + (flag3 ? 1 : 0)];
                        Texture2D texture2D2 = (Texture2D)null;
                        switch (index)
                        {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                            texture2D2 = Main.wireUITexture[2 + index];
                            break;

                        case 4:
                            texture2D2 = Main.wireUITexture[WiresUI.Settings.ToolMode.HasFlag((Enum)WiresUI.Settings.MultiToolMode.Cutter) ? 7 : 6];
                            break;

                        case 5:
                            texture2D2 = Main.wireUITexture[10];
                            break;
                        }
                        Color color1 = Color.White;
                        Color color2 = Color.White;
                        if (!flag2 && index != 4)
                        {
                            if (flag3)
                            {
                                color2 = new Color(100, 100, 100);
                                color2 = new Color(120, 120, 120);
                                color1 = new Color(200, 200, 200);
                            }
                            else
                            {
                                color2 = new Color(150, 150, 150);
                                color2 = new Color(80, 80, 80);
                                color1 = new Color(100, 100, 100);
                            }
                        }
                        Utils.CenteredRectangle(vector2_3, new Vector2(40f));
                        if (flag3)
                        {
                            if (Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                switch (index)
                                {
                                case 0:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Red;
                                    break;

                                case 1:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Green;
                                    break;

                                case 2:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Blue;
                                    break;

                                case 3:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Yellow;
                                    break;

                                case 4:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Cutter;
                                    break;

                                case 5:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Actuator;
                                    break;
                                }
                            }
                            if (!Main.mouseLeft || Main.player[Main.myPlayer].mouseInterface)
                            {
                                Main.player[Main.myPlayer].mouseInterface = true;
                            }
                            this.OnWiresMenu = true;
                        }
                        int num5 = flag3 ? 1 : 0;
                        spriteBatch.Draw(texture2D1, vector2_3, new Rectangle?(), color1 * this._lineOpacity, 0.0f, texture2D1.Size() / 2f, this._lineOpacity, SpriteEffects.None, 0.0f);
                        spriteBatch.Draw(texture2D2, vector2_3, new Rectangle?(), color2 * this._lineOpacity, 0.0f, texture2D2.Size() / 2f, this._lineOpacity, SpriteEffects.None, 0.0f);
                    }
                }
                if (!Main.mouseLeft || !Main.mouseLeftRelease || flag1)
                {
                    return;
                }
                this.active = false;
            }
        public override void AI()
        {
            projectile.ai[0]      += 1;
            projectile.ai[1]      += 1;
            projectile.localAI[0] += 1;

            if (projectile.ai[0] < -1000)
            {
                return;
            }

            Player player = Main.player[projectile.owner];

            if (!player.channel || player.dead)
            {
                projectile.ai[0] = -10000;
            }
            else
            {
                projectile.timeLeft = 250;
                Vector2 mousePos = Main.MouseWorld;
                player.itemTime      = 60;
                player.itemAnimation = 60;

                if (projectile.owner == Main.myPlayer)
                {
                    Vector2 diff = mousePos - projectile.Center;
                    if (diff.Length() > 1800 || projectile.ai[1] > 1200)
                    {
                        if (!player.CheckMana(player.HeldItem, 8, true))
                        {
                            projectile.ai[0]     = -10000;
                            projectile.netUpdate = true;
                            return;
                        }



                        if (projectile.localAI[0] > 1000)
                        {
                            projectile.extraUpdates = (int)MathHelper.Clamp(projectile.extraUpdates + 1, 10, 40);
                            projectile.numUpdates   = projectile.extraUpdates;
                        }
                        diff.Normalize();
                        projectile.direction = Main.MouseWorld.X > player.position.X ? 1 : -1;
                        Vector2 randAng = Main.rand.NextVector2CircularEdge(1500f, 1500f);
                        projectile.Center   = mousePos + randAng;
                        projectile.velocity = Vector2.Normalize(mousePos - projectile.Center) * (projectile.velocity.Length());
                        there            = Main.MouseWorld;
                        projectile.ai[1] = 0;

                        Vector2 dir = (there - player.Center);
                        player.ChangeDir(dir.X > 0 ? 1 : -1);
                        player.itemRotation = dir.ToRotation() - (player.direction < 0 ? MathHelper.Pi : 0);

                        for (int i = 0; i < projectile.oldPos.Length; i += 1)                        //dumb hack to get the trails to not appear at 0,0
                        {
                            projectile.oldPos[i] = projectile.position;
                        }
                        projectile.netUpdate = true;
                    }
                }


                if (there != default)
                {
                    if (Vector2.Dot(Vector2.Normalize(there - projectile.Center), Vector2.Normalize(projectile.velocity)) < -0.9f)
                    {
                        projectile.ai[1] = 1000;
                        there            = default;
                        NoiseGenerator noise = new NoiseGenerator(projectile.whoAmI);
                        noise.Amplitude = 5;
                        noise.Frequency = 0.5;
                        for (float i = 0; i < 1f; i += 1f / 5f)
                        {
                            Vector2 there2 = (projectile.velocity); there.Normalize(); there2 = there2.RotatedBy(i * MathHelper.TwoPi);
                            int     prog   = Projectile.NewProjectile(projectile.Center, Vector2.Normalize(there2) * (2f + (float)noise.Noise((int)(i * 80), (int)projectile.ai[0])) * 5f, ProjectileID.HallowStar, (int)((1f - Main.player[projectile.owner].manaSickReduction) / 5f), projectile.knockBack / 10f, projectile.owner);
                            Main.projectile[prog].timeLeft             = 20 + (int)(noise.Noise((int)(i * 40), (int)projectile.ai[0] + 800) * 40);
                            Main.projectile[prog].alpha                = 150;
                            Main.projectile[prog].localNPCHitCooldown  = -1;
                            Main.projectile[prog].penetrate            = 2;
                            Main.projectile[prog].usesLocalNPCImmunity = true;
                            Main.projectile[prog].netUpdate            = true;
                        }
                    }
                }
            }
        }
示例#53
0
 /// <summary>
 /// Calculates the angle, measured in radians, between two vectors.
 /// </summary>
 public static float AngleBetween(Vector2 value1, Vector2 value2)
 {
     float a = Vector2.Dot(value1, value2) / (value1.Length() * value2.Length());
     return (float)Math.Acos((double)MathHelper.Clamp(a, -1F, 1F));
 }
示例#54
0
            private void DrawFlower(SpriteBatch spriteBatch)
            {
                if (!this.active)
                {
                    return;
                }
                Vector2 vector2_1 = Main.MouseScreen;
                Vector2 position  = this.position;

                if (PlayerInput.UsingGamepad && Main.SmartCursorEnabled)
                {
                    vector2_1 = !(PlayerInput.GamepadThumbstickRight != Vector2.Zero) ? (!(PlayerInput.GamepadThumbstickLeft != Vector2.Zero) ? this.position : this.position + PlayerInput.GamepadThumbstickLeft * 40f) : this.position + PlayerInput.GamepadThumbstickRight * 40f;
                }
                Vector2 v                  = vector2_1 - position;
                double  num1               = (double)Vector2.Dot(Vector2.Normalize(v), Vector2.UnitX);
                double  num2               = (double)Vector2.Dot(Vector2.Normalize(v), Vector2.UnitY);
                float   rotation           = v.ToRotation();
                float   num3               = v.Length();
                bool    flag1              = false;
                bool    toolAllowActuators = WiresUI.Settings.DrawToolAllowActuators;
                float   num4               = (float)(4 + toolAllowActuators.ToInt());
                float   num5               = toolAllowActuators ? 11f : -0.5f;

                for (int index = 0; index < 6; ++index)
                {
                    if (toolAllowActuators || index != 5)
                    {
                        bool flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum)(WiresUI.Settings.MultiToolMode)(1 << index));
                        if (index == 5)
                        {
                            flag2 = WiresUI.Settings.ToolMode.HasFlag((Enum)WiresUI.Settings.MultiToolMode.Actuator);
                        }
                        Vector2 vector2_2 = position + Vector2.UnitX * (float)(45.0 * ((double)index - 1.5));
                        switch (index)
                        {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                            float num6 = (float)index;
                            if (index == 0)
                            {
                                num6 = 3f;
                            }
                            if (index == 3)
                            {
                                num6 = 0.0f;
                            }
                            vector2_2 = position + Vector2.UnitX.RotatedBy((double)num6 * 6.28318548202515 / (double)num4 - 3.14159274101257 / (double)num5, new Vector2()) * 45f;
                            break;

                        case 4:
                            flag2     = false;
                            vector2_2 = position;
                            break;

                        case 5:
                            vector2_2 = position + Vector2.UnitX.RotatedBy((double)(index - 1) * 6.28318548202515 / (double)num4 - 3.14159274101257 / (double)num5, new Vector2()) * 45f;
                            break;
                        }
                        bool flag3 = false;
                        if (index == 4)
                        {
                            flag3 = (double)num3 < 20.0;
                        }
                        switch (index)
                        {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                        case 5:
                            float num7 = (vector2_2 - position).ToRotation().AngleTowards(rotation, (float)(6.28318548202515 / ((double)num4 * 2.0))) - rotation;
                            if ((double)num3 >= 20.0 && (double)Math.Abs(num7) < 0.00999999977648258)
                            {
                                flag3 = true;
                                break;
                            }
                            break;

                        case 4:
                            flag3 = (double)num3 < 20.0;
                            break;
                        }
                        if (!PlayerInput.UsingGamepad)
                        {
                            flag3 = (double)Vector2.Distance(vector2_2, vector2_1) < 19.0;
                        }
                        if (flag1)
                        {
                            flag3 = false;
                        }
                        if (flag3)
                        {
                            flag1 = true;
                        }
                        Texture2D texture2D1 = Main.wireUITexture[(WiresUI.Settings.ToolMode.HasFlag((Enum)WiresUI.Settings.MultiToolMode.Cutter) ? 8 : 0) + (flag3 ? 1 : 0)];
                        Texture2D texture2D2 = (Texture2D)null;
                        switch (index)
                        {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                            texture2D2 = Main.wireUITexture[2 + index];
                            break;

                        case 4:
                            texture2D2 = Main.wireUITexture[WiresUI.Settings.ToolMode.HasFlag((Enum)WiresUI.Settings.MultiToolMode.Cutter) ? 7 : 6];
                            break;

                        case 5:
                            texture2D2 = Main.wireUITexture[10];
                            break;
                        }
                        Color color1 = Color.White;
                        Color color2 = Color.White;
                        if (!flag2 && index != 4)
                        {
                            if (flag3)
                            {
                                color2 = new Color(100, 100, 100);
                                color2 = new Color(120, 120, 120);
                                color1 = new Color(200, 200, 200);
                            }
                            else
                            {
                                color2 = new Color(150, 150, 150);
                                color2 = new Color(80, 80, 80);
                                color1 = new Color(100, 100, 100);
                            }
                        }
                        Utils.CenteredRectangle(vector2_2, new Vector2(40f));
                        if (flag3)
                        {
                            if (Main.mouseLeft && Main.mouseLeftRelease)
                            {
                                switch (index)
                                {
                                case 0:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Red;
                                    break;

                                case 1:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Green;
                                    break;

                                case 2:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Blue;
                                    break;

                                case 3:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Yellow;
                                    break;

                                case 4:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Cutter;
                                    break;

                                case 5:
                                    WiresUI.Settings.ToolMode ^= WiresUI.Settings.MultiToolMode.Actuator;
                                    break;
                                }
                            }
                            Main.player[Main.myPlayer].mouseInterface = true;
                            this.OnWiresMenu = true;
                        }
                        int num8 = flag3 ? 1 : 0;
                        spriteBatch.Draw(texture2D1, vector2_2, new Rectangle?(), color1, 0.0f, texture2D1.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
                        spriteBatch.Draw(texture2D2, vector2_2, new Rectangle?(), color2, 0.0f, texture2D2.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
                    }
                }
                if (!Main.mouseLeft || !Main.mouseLeftRelease || flag1)
                {
                    return;
                }
                this.active = false;
            }
示例#55
0
        public void AI()
        {
            if (ServerApi.Hooks.InvokeProjectileAIUpdate(this))
            {
                return;
            }
            if (this.aiStyle == 1)
            {
                this.AI_001();
                return;
            }
            if (this.aiStyle == 2)
            {
                if (this.type == ProjectileID.VampireKnife && this.localAI[0] == 0f)
                {
                    this.localAI[0] += 1f;
                    this.alpha = 0;
                }
                if (this.type == ProjectileID.OrnamentFriendly)
                {
                    this.frame = (int)this.ai[1];
                }
                if (this.type == ProjectileID.ToxicFlask)
                {
                    this.rotation += Math.Abs(this.velocity.X) * 0.04f * (float)this.direction;
                }
                else
                {
                    this.rotation += (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * 0.03f * (float)this.direction;
                }
                if (this.type == ProjectileID.CannonballFriendly)
                {
                    if (this.ai[1] == 0f)
                    {
                        this.ai[1] = 1f;
                    }
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 18f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.28f;
                        this.velocity.X = this.velocity.X * 0.99f;
                    }
                    if (this.ai[0] > 2f)
                    {
                        this.alpha = 0;
                    }
                }
                else if (this.type == ProjectileID.ExplosiveBunny)
                {
                    if (this.ai[1] == 0f)
                    {
                        this.ai[1] = 1f;
                    }
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 18f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.28f;
                        this.velocity.X = this.velocity.X * 0.99f;
                    }
                    if (this.ai[0] > 2f)
                    {
                        this.alpha = 0;
                    }
                }
                else if (this.type == ProjectileID.CannonballHostile)
                {
                    if (this.ai[1] == 0f)
                    {
                        this.ai[1] = 1f;
                    }
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 16f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.18f;
                        this.velocity.X = this.velocity.X * 0.991f;
                    }
                    if (this.ai[0] > 2f)
                    {
                        this.alpha = 0;
                    }
                }
                if (this.type == ProjectileID.ShadowFlameKnife)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 30f)
                    {
                        this.velocity.X = this.velocity.X * 0.99f;
                        this.velocity.Y = this.velocity.Y + 0.5f;
                    }
                    else
                    {
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    }
                }
                else if (this.type == ProjectileID.StyngerShrapnel)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 0f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.25f;
                    }
                }
                else if (this.type == ProjectileID.OrnamentHostileShrapnel)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 5f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.25f;
                    }
                }
                else if (this.type == ProjectileID.DrManFlyFlask)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 18f)
                    {
                        this.velocity.X = this.velocity.X * 0.995f;
                        this.velocity.Y = this.velocity.Y + 0.2f;
                    }
                }
                else if (this.type == ProjectileID.Spark)
                {
                    this.alpha = 255;
                    this.ai[0] += 1f;
                    if (this.ai[0] > 3f)
                    {
                        int num15 = 100;
                        if (this.ai[0] > 20f)
                        {
                            int num16 = 40;
                            float num17 = this.ai[0] - 20f;
                            num15 = (int)(100f * (1f - num17 / (float)num16));
                            if (num17 >= (float)num16)
                            {
                                this.Kill();
                            }
                        }
                        if (this.ai[0] <= 10f)
                        {
                            num15 = (int)this.ai[0] * 10;
                        }
                    }
                    if (this.ai[0] >= 20f)
                    {
                        this.velocity.X = this.velocity.X * 0.99f;
                        this.velocity.Y = this.velocity.Y + 0.1f;
                    }
                }
                else if (this.type == ProjectileID.HolyWater || this.type == ProjectileID.UnholyWater || this.type == ProjectileID.BloodWater)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 10f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.25f;
                        this.velocity.X = this.velocity.X * 0.99f;
                    }
                }
                else if (this.type == ProjectileID.SnowBallFriendly)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 20f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.3f;
                        this.velocity.X = this.velocity.X * 0.98f;
                    }
                }
                else if (this.type == ProjectileID.PaladinsHammerHostile)
                {
                    if (this.ai[0] == 0f)
                    {
                    }
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 60f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.2f;
                        this.velocity.X = this.velocity.X * 0.99f;
                    }
                }
                else if (this.type == ProjectileID.EatersBite)
                {
                    this.alpha -= 50;
                    if (this.alpha < 0)
                    {
                        this.alpha = 0;
                    }
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 0.785f;
                }
                else if (this.type == ProjectileID.VampireKnife)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 30f)
                    {
                        this.alpha += 10;
                        this.damage = (int)((double)this.damage * 0.9);
                        this.knockBack = (float)((int)((double)this.knockBack * 0.9));
                        if (this.alpha >= 255)
                        {
                            this.active = false;
                        }
                    }
                    if (this.ai[0] < 30f)
                    {
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    }
                }
                else if (this.type == ProjectileID.LovePotion || this.type == ProjectileID.FoulPotion)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 15f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.3f;
                        this.velocity.X = this.velocity.X * 0.98f;
                    }
                }
                else
                {
                    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 == ProjectileID.ThrowingKnife || this.type == ProjectileID.PoisonedKnife || this.type == ProjectileID.MagicDagger || this.type == ProjectileID.FrostDaggerfish || this.type == ProjectileID.BoneDagger)
                    {
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    }
                }
                if (this.velocity.Y > 16f)
                {
                    this.velocity.Y = 16f;
                }
                if (this.type == ProjectileID.PoisonedKnife && Main.rand.Next(20) == 0)
                {
                    return;
                }
            }
            else if (this.aiStyle == 3)
            {
                if (this.ai[0] == 0f)
                {
                    this.ai[1] += 1f;
                    if (this.type == ProjectileID.LightDisc && this.ai[1] >= 45f)
                    {
                        this.ai[0] = 1f;
                        this.ai[1] = 0f;
                        this.netUpdate = true;
                    }
                    if (this.type == ProjectileID.BloodyMachete || this.type == ProjectileID.Anchor)
                    {
                        if (this.ai[1] >= 10f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.5f;
                            if (this.type == ProjectileID.Anchor && this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.35f;
                            }
                            this.velocity.X = this.velocity.X * 0.95f;
                            if (this.velocity.Y > 16f)
                            {
                                this.velocity.Y = 16f;
                            }
                            if (this.type == ProjectileID.Anchor && Vector2.Distance(base.Center, Main.player[this.owner].Center) > 800f)
                            {
                                this.ai[0] = 1f;
                            }
                        }
                    }
                    else if (this.type == ProjectileID.PossessedHatchet)
                    {
                        if (this.velocity.X > 0f)
                        {
                            this.spriteDirection = 1;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.spriteDirection = -1;
                        }
                        float num30 = this.position.X;
                        float num31 = this.position.Y;
                        bool flag = false;
                        if (this.ai[1] > 10f)
                        {
                            for (int num32 = 0; num32 < 200; num32++)
                            {
                                if (Main.npc[num32].CanBeChasedBy(this, false))
                                {
                                    float num33 = Main.npc[num32].position.X + (float)(Main.npc[num32].width / 2);
                                    float num34 = Main.npc[num32].position.Y + (float)(Main.npc[num32].height / 2);
                                    float num35 = Math.Abs(this.position.X + (float)(this.width / 2) - num33) + Math.Abs(this.position.Y + (float)(this.height / 2) - num34);
                                    if (num35 < 800f && Collision.CanHit(new Vector2(this.position.X + (float)(this.width / 2), this.position.Y + (float)(this.height / 2)), 1, 1, Main.npc[num32].position, Main.npc[num32].width, Main.npc[num32].height))
                                    {
                                        num30 = num33;
                                        num31 = num34;
                                        flag = true;
                                    }
                                }
                            }
                        }
                        if (!flag)
                        {
                            num30 = this.position.X + (float)(this.width / 2) + this.velocity.X * 100f;
                            num31 = this.position.Y + (float)(this.height / 2) + this.velocity.Y * 100f;
                            if (this.ai[1] >= 30f)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = 0f;
                                this.netUpdate = true;
                            }
                        }
                        float num36 = 12f;
                        float num37 = 0.25f;
                        Vector2 vector = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num38 = num30 - vector.X;
                        float num39 = num31 - vector.Y;
                        float num40 = (float)Math.Sqrt((double)(num38 * num38 + num39 * num39));
                        num40 = num36 / num40;
                        num38 *= num40;
                        num39 *= num40;
                        if (this.velocity.X < num38)
                        {
                            this.velocity.X = this.velocity.X + num37;
                            if (this.velocity.X < 0f && num38 > 0f)
                            {
                                this.velocity.X = this.velocity.X + num37 * 2f;
                            }
                        }
                        else if (this.velocity.X > num38)
                        {
                            this.velocity.X = this.velocity.X - num37;
                            if (this.velocity.X > 0f && num38 < 0f)
                            {
                                this.velocity.X = this.velocity.X - num37 * 2f;
                            }
                        }
                        if (this.velocity.Y < num39)
                        {
                            this.velocity.Y = this.velocity.Y + num37;
                            if (this.velocity.Y < 0f && num39 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num37 * 2f;
                            }
                        }
                        else if (this.velocity.Y > num39)
                        {
                            this.velocity.Y = this.velocity.Y - num37;
                            if (this.velocity.Y > 0f && num39 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num37 * 2f;
                            }
                        }
                    }
                    else if (this.type == ProjectileID.PaladinsHammerFriendly)
                    {
                        if (this.ai[1] >= 20f)
                        {
                            this.ai[0] = 1f;
                            this.ai[1] = 0f;
                            this.netUpdate = true;
                        }
                    }
                    else if (this.ai[1] >= 30f)
                    {
                        this.ai[0] = 1f;
                        this.ai[1] = 0f;
                        this.netUpdate = true;
                    }
                }
                else
                {
                    this.tileCollide = false;
                    float num41 = 9f;
                    float num42 = 0.4f;
                    if (this.type == ProjectileID.Flamarang)
                    {
                        num41 = 13f;
                        num42 = 0.6f;
                    }
                    else if (this.type == ProjectileID.ThornChakram)
                    {
                        num41 = 15f;
                        num42 = 0.8f;
                    }
                    else if (this.type == ProjectileID.PossessedHatchet)
                    {
                        num41 = 16f;
                        num42 = 1.2f;
                    }
                    else if (this.type == ProjectileID.LightDisc)
                    {
                        num41 = 16f;
                        num42 = 1.2f;
                    }
                    else if (this.type == ProjectileID.Bananarang)
                    {
                        num41 = 15f;
                        num42 = 1f;
                    }
                    else if (this.type == ProjectileID.FruitcakeChakram)
                    {
                        num41 = 12f;
                        num42 = 0.6f;
                    }
                    else if (this.type == ProjectileID.PaladinsHammerFriendly)
                    {
                        num41 = 15f;
                        num42 = 3f;
                    }
                    else if (this.type == ProjectileID.BloodyMachete)
                    {
                        num41 = 15f;
                        num42 = 3f;
                    }
                    else if (this.type == ProjectileID.Anchor)
                    {
                        num41 = 16f;
                        num42 = 4f;
                    }
                    Vector2 vector2 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num43 = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - vector2.X;
                    float num44 = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - vector2.Y;
                    float num45 = (float)Math.Sqrt((double)(num43 * num43 + num44 * num44));
                    if (num45 > 3000f)
                    {
                        this.Kill();
                    }
                    num45 = num41 / num45;
                    num43 *= num45;
                    num44 *= num45;
                    if (this.type == ProjectileID.Anchor)
                    {
                        Vector2 vector3 = new Vector2(num43, num44) - this.velocity;
                        if (vector3 != Vector2.Zero)
                        {
                            Vector2 vector4 = vector3;
                            vector4.Normalize();
                            this.velocity += vector4 * Math.Min(num42, vector3.Length());
                        }
                    }
                    else
                    {
                        if (this.velocity.X < num43)
                        {
                            this.velocity.X = this.velocity.X + num42;
                            if (this.velocity.X < 0f && num43 > 0f)
                            {
                                this.velocity.X = this.velocity.X + num42;
                            }
                        }
                        else if (this.velocity.X > num43)
                        {
                            this.velocity.X = this.velocity.X - num42;
                            if (this.velocity.X > 0f && num43 < 0f)
                            {
                                this.velocity.X = this.velocity.X - num42;
                            }
                        }
                        if (this.velocity.Y < num44)
                        {
                            this.velocity.Y = this.velocity.Y + num42;
                            if (this.velocity.Y < 0f && num44 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num42;
                            }
                        }
                        else if (this.velocity.Y > num44)
                        {
                            this.velocity.Y = this.velocity.Y - num42;
                            if (this.velocity.Y > 0f && num44 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num42;
                            }
                        }
                    }
                    if (Main.myPlayer == this.owner)
                    {
                        Rectangle rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                        Rectangle rectangle2 = new Rectangle((int)Main.player[this.owner].position.X, (int)Main.player[this.owner].position.Y, Main.player[this.owner].width, Main.player[this.owner].height);
                        if (rectangle.Intersects(rectangle2))
                        {
                            this.Kill();
                        }
                    }
                }
                if (this.type == ProjectileID.LightDisc)
                {
                    this.rotation += 0.3f * (float)this.direction;
                    return;
                }
                if (this.type != ProjectileID.Anchor)
                {
                    this.rotation += 0.4f * (float)this.direction;
                    return;
                }
                if (this.ai[0] == 0f)
                {
                    Vector2 velocity = this.velocity;
                    velocity.Normalize();
                    this.rotation = (float)Math.Atan2((double)velocity.Y, (double)velocity.X) + 1.57f;
                    return;
                }
                Vector2 vector5 = base.Center - Main.player[this.owner].Center;
                vector5.Normalize();
                this.rotation = (float)Math.Atan2((double)vector5.Y, (double)vector5.X) + 1.57f;
                return;
            }
            else if (this.aiStyle == 4)
            {
                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                if (this.ai[0] == 0f)
                {
                    if (this.type >= ProjectileID.NettleBurstRight && this.type <= ProjectileID.NettleBurstEnd && this.ai[1] == 0f && this.alpha == 255 && Main.rand.Next(2) == 0)
                    {
                        this.type++;
                        this.netUpdate = true;
                    }
                    this.alpha -= 50;
                    if (this.type >= ProjectileID.NettleBurstRight && this.type <= ProjectileID.NettleBurstEnd)
                    {
                        this.alpha -= 25;
                    }
                    else if (this.type == ProjectileID.CrystalVileShardHead || this.type == ProjectileID.CrystalVileShardShaft)
                    {
                        this.alpha -= 50;
                    }
                    if (this.alpha <= 0)
                    {
                        this.alpha = 0;
                        this.ai[0] = 1f;
                        if (this.ai[1] == 0f)
                        {
                            this.ai[1] += 1f;
                            this.position += this.velocity * 1f;
                        }
                        if (this.type == ProjectileID.VilethornBase && Main.myPlayer == this.owner)
                        {
                            int num46 = this.type;
                            if (this.ai[1] >= 6f)
                            {
                                num46++;
                            }
                            int num47 = Projectile.NewProjectile(this.position.X + this.velocity.X + (float)(this.width / 2), this.position.Y + this.velocity.Y + (float)(this.height / 2), this.velocity.X, this.velocity.Y, num46, this.damage, this.knockBack, this.owner, 0f, 0f);
                            Main.projectile[num47].damage = this.damage;
                            Main.projectile[num47].ai[1] = this.ai[1] + 1f;
                            NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", num47, 0f, 0f, 0f, 0, 0, 0);
                            return;
                        }
                        if (this.type == ProjectileID.CrystalVileShardShaft && Main.myPlayer == this.owner)
                        {
                            int num48 = this.type;
                            if (this.ai[1] >= (float)(7 + Main.rand.Next(2)))
                            {
                                num48--;
                            }
                            int num49 = this.damage;
                            float num50 = this.knockBack;
                            if (num48 == 493)
                            {
                                num49 = (int)((double)this.damage * 1.25);
                                num50 = this.knockBack * 1.25f;
                            }
                            int number = Projectile.NewProjectile(this.position.X + this.velocity.X + (float)(this.width / 2), this.position.Y + this.velocity.Y + (float)(this.height / 2), this.velocity.X, this.velocity.Y, num48, num49, num50, this.owner, 0f, this.ai[1] + 1f);
                            NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", number, 0f, 0f, 0f, 0, 0, 0);
                            return;
                        }
                        if ((this.type == ProjectileID.NettleBurstRight || this.type == ProjectileID.NettleBurstLeft) && Main.myPlayer == this.owner)
                        {
                            int num51 = this.type;
                            if (this.type == ProjectileID.NettleBurstRight)
                            {
                                num51 = 151;
                            }
                            else if (this.type == ProjectileID.NettleBurstLeft)
                            {
                                num51 = 150;
                            }
                            if (this.ai[1] >= 10f && this.type == ProjectileID.NettleBurstLeft)
                            {
                                num51 = 152;
                            }
                            int num52 = Projectile.NewProjectile(this.position.X + this.velocity.X + (float)(this.width / 2), this.position.Y + this.velocity.Y + (float)(this.height / 2), this.velocity.X, this.velocity.Y, num51, this.damage, this.knockBack, this.owner, 0f, 0f);
                            Main.projectile[num52].damage = this.damage;
                            Main.projectile[num52].ai[1] = this.ai[1] + 1f;
                            NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", num52, 0f, 0f, 0f, 0, 0, 0);
                            return;
                        }
                    }
                }
                else
                {
                    if (this.type >= ProjectileID.NettleBurstRight && this.type <= ProjectileID.NettleBurstEnd)
                    {
                        this.alpha += 3;
                    }
                    else if (this.type == ProjectileID.CrystalVileShardHead || this.type == ProjectileID.CrystalVileShardShaft)
                    {
                        this.alpha += 7;
                    }
                    else
                    {
                        this.alpha += 5;
                    }
                    if (this.alpha >= 255)
                    {
                        this.Kill();
                        return;
                    }
                }
            }
            else if (this.aiStyle == 5)
            {
                if (this.type == ProjectileID.StarWrath)
                {
                    if (base.Center.Y > this.ai[1])
                    {
                        this.tileCollide = true;
                    }
                }
                else if (this.type == ProjectileID.HallowStar)
                {
                    if (this.position.Y > this.ai[1])
                    {
                        this.tileCollide = true;
                    }
                }
                else
                {
                    if (this.ai[1] == 0f && !Collision.SolidCollision(this.position, this.width, this.height))
                    {
                        this.ai[1] = 1f;
                        this.netUpdate = true;
                    }
                    if (this.ai[1] != 0f)
                    {
                        this.tileCollide = true;
                    }
                }
                if (this.type == ProjectileID.StarWrath)
                {
                    this.alpha -= 15;
                    int num58 = 150;
                    if (base.Center.Y >= this.ai[1])
                    {
                        num58 = 0;
                    }
                    if (this.alpha < num58)
                    {
                        this.alpha = num58;
                    }
                    this.localAI[0] += (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * 0.01f * (float)this.direction;
                }
                else
                {
                    if (this.localAI[0] == 0f)
                    {
                        this.localAI[0] = 1f;
                    }
                    this.alpha += (int)(25f * this.localAI[0]);
                    if (this.alpha > 200)
                    {
                        this.alpha = 200;
                        this.localAI[0] = -1f;
                    }
                    if (this.alpha < 0)
                    {
                        this.alpha = 0;
                        this.localAI[0] = 1f;
                    }
                }
                if (this.type == ProjectileID.StarWrath)
                {
                    this.rotation = this.velocity.ToRotation() - 1.57079637f;
                }
                else
                {
                    this.rotation += (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * 0.01f * (float)this.direction;
                }
                if (this.ai[1] == 1f || this.type == ProjectileID.HallowStar)
                {
                    this.light = 0.9f;
                    if (Main.rand.Next(20) == 0)
                    {
                        return;
                    }
                }
            }
            else if (this.aiStyle == 6)
            {
                this.velocity *= 0.95f;
                this.ai[0] += 1f;
                if (this.ai[0] == 180f)
                {
                    this.Kill();
                }
                if (this.ai[1] == 0f)
                {
                    this.ai[1] = 1f;
                }
                if (this.type == ProjectileID.PurificationPowder || this.type == ProjectileID.VilePowder || this.type == ProjectileID.ViciousPowder)
                {
                    int num63 = (int)(this.position.X / 16f) - 1;
                    int num64 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                    int num65 = (int)(this.position.Y / 16f) - 1;
                    int num66 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                    if (num63 < 0)
                    {
                        num63 = 0;
                    }
                    if (num64 > Main.maxTilesX)
                    {
                        num64 = Main.maxTilesX;
                    }
                    if (num65 < 0)
                    {
                        num65 = 0;
                    }
                    if (num66 > Main.maxTilesY)
                    {
                        num66 = Main.maxTilesY;
                    }
                    for (int num67 = num63; num67 < num64; num67++)
                    {
                        for (int num68 = num65; num68 < num66; num68++)
                        {
                            Vector2 vector7;
                            vector7.X = (float)(num67 * 16);
                            vector7.Y = (float)(num68 * 16);
                            if (this.position.X + (float)this.width > vector7.X && this.position.X < vector7.X + 16f && this.position.Y + (float)this.height > vector7.Y && this.position.Y < vector7.Y + 16f && Main.myPlayer == this.owner && Main.tile[num67, num68].active())
                            {
                                if (this.type == ProjectileID.PurificationPowder)
                                {
                                    if (Main.tile[num67, num68].type == TileID.CorruptGrass || Main.tile[num67, num68].type == TileID.FleshGrass)
                                    {
                                        Main.tile[num67, num68].type = 2;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.Ebonstone || Main.tile[num67, num68].type == TileID.Crimstone)
                                    {
                                        Main.tile[num67, num68].type = 1;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.Ebonsand || Main.tile[num67, num68].type == TileID.Crimsand)
                                    {
                                        Main.tile[num67, num68].type = 53;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.CorruptIce || Main.tile[num67, num68].type == TileID.FleshIce)
                                    {
                                        Main.tile[num67, num68].type = 161;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.CorruptSandstone || Main.tile[num67, num68].type == TileID.CrimsonSandstone)
                                    {
                                        Main.tile[num67, num68].type = 396;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.CorruptHardenedSand || Main.tile[num67, num68].type == TileID.CrimsonHardenedSand)
                                    {
                                        Main.tile[num67, num68].type = 397;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                }
                                else if (this.type == ProjectileID.VilePowder || this.type == ProjectileID.ViciousPowder)
                                {
                                    if (Main.tile[num67, num68].type == TileID.HallowedGrass)
                                    {
                                        Main.tile[num67, num68].type = 2;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.Pearlsand)
                                    {
                                        Main.tile[num67, num68].type = 53;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.Pearlstone)
                                    {
                                        Main.tile[num67, num68].type = 1;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.HallowedIce)
                                    {
                                        Main.tile[num67, num68].type = 161;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.HallowSandstone)
                                    {
                                        Main.tile[num67, num68].type = 396;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                    if (Main.tile[num67, num68].type == TileID.HallowHardenedSand)
                                    {
                                        Main.tile[num67, num68].type = 397;
                                        WorldGen.SquareTileFrame(num67, num68, true);
                                        if (Main.netMode == 1)
                                        {
                                            NetMessage.SendTileSquare(-1, num67, num68, 1);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    return;
                }
            }
            else if (this.aiStyle == 7)
            {
                if (Main.player[this.owner].dead || Main.player[this.owner].stoned || Main.player[this.owner].webbed || Main.player[this.owner].frozen)
                {
                    this.Kill();
                    return;
                }
                Vector2 mountedCenter = Main.player[this.owner].MountedCenter;
                Vector2 vector8 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num69 = mountedCenter.X - vector8.X;
                float num70 = mountedCenter.Y - vector8.Y;
                float num71 = (float)Math.Sqrt((double)(num69 * num69 + num70 * num70));
                this.rotation = (float)Math.Atan2((double)num70, (double)num69) - 1.57f;
                if (this.type == ProjectileID.SkeletronHand)
                {
                    this.rotation = (float)Math.Atan2((double)num70, (double)num69) + 3.92500019f;
                }
                if (this.type == ProjectileID.AntiGravityHook)
                {
                    this.localAI[0] += 1f;
                    if (this.localAI[0] >= 28f)
                    {
                        this.localAI[0] = 0f;
                    }
                    DelegateMethods.v3_1 = new Vector3(0f, 0.4f, 0.3f);
                }
                if (this.type >= ProjectileID.LunarHookSolar && this.type <= ProjectileID.LunarHookStardust)
                {
                    Vector3 zero = Vector3.Zero;
                    switch (this.type)
                    {
                        case 646:
                            zero = new Vector3(0.7f, 0.5f, 0.1f);
                            break;
                        case 647:
                            zero = new Vector3(0f, 0.6f, 0.7f);
                            break;
                        case 648:
                            zero = new Vector3(0.6f, 0.2f, 0.6f);
                            break;
                        case 649:
                            zero = new Vector3(0.6f, 0.6f, 0.9f);
                            break;
                    }
                    DelegateMethods.v3_1 = zero;
                }
                if (this.ai[0] == 0f)
                {
                    if ((num71 > 300f && this.type == ProjectileID.Hook) || (num71 > 400f && this.type == ProjectileID.IvyWhip) || (num71 > 440f && this.type == ProjectileID.DualHookBlue) || (num71 > 440f && this.type == ProjectileID.DualHookRed) || (num71 > 250f && this.type == ProjectileID.Web) || (num71 > 350f && this.type == ProjectileID.SkeletronHand) || (num71 > 500f && this.type == ProjectileID.BatHook) || (num71 > 550f && this.type == ProjectileID.WoodHook) || (num71 > 400f && this.type == ProjectileID.CandyCaneHook) || (num71 > 550f && this.type == ProjectileID.ChristmasHook) || (num71 > 400f && this.type == ProjectileID.FishHook) || (num71 > 300f && this.type == ProjectileID.SlimeHook) || (num71 > 550f && this.type >= ProjectileID.LunarHookSolar && this.type <= ProjectileID.LunarHookStardust) || (num71 > 480f && this.type >= ProjectileID.TendonHook && this.type <= ProjectileID.WormHook) || (num71 > 500f && this.type == ProjectileID.AntiGravityHook))
                    {
                        this.ai[0] = 1f;
                    }
                    else if (this.type >= ProjectileID.GemHookAmethyst && this.type <= ProjectileID.GemHookDiamond)
                    {
                        int num72 = 300 + (this.type - 230) * 30;
                        if (num71 > (float)num72)
                        {
                            this.ai[0] = 1f;
                        }
                    }
                    Vector2 vector9 = base.Center - new Vector2(5f);
                    Vector2 vector10 = base.Center + new Vector2(5f);
                    Point point = (vector9 - new Vector2(16f)).ToTileCoordinates();
                    Point point2 = (vector10 + new Vector2(32f)).ToTileCoordinates();
                    int num73 = point.X;
                    int num74 = point2.X;
                    int num75 = point.Y;
                    int num76 = point2.Y;
                    if (num73 < 0)
                    {
                        num73 = 0;
                    }
                    if (num74 > Main.maxTilesX)
                    {
                        num74 = Main.maxTilesX;
                    }
                    if (num75 < 0)
                    {
                        num75 = 0;
                    }
                    if (num76 > Main.maxTilesY)
                    {
                        num76 = Main.maxTilesY;
                    }
                    for (int num77 = num73; num77 < num74; num77++)
                    {
                        int num78 = num75;
                        while (num78 < num76)
                        {
                            if (Main.tile[num77, num78] == null)
                            {
                                Main.tile[num77, num78] = new Tile();
                            }
                            Vector2 vector11;
                            vector11.X = (float)(num77 * 16);
                            vector11.Y = (float)(num78 * 16);
                            if (vector9.X + 10f > vector11.X && vector9.X < vector11.X + 16f && vector9.Y + 10f > vector11.Y && vector9.Y < vector11.Y + 16f && Main.tile[num77, num78].nactive() && (Main.tileSolid[(int)Main.tile[num77, num78].type] || Main.tile[num77, num78].type == TileID.MinecartTrack) && (this.type != ProjectileID.TrackHook || Main.tile[num77, num78].type == TileID.MinecartTrack))
                            {
                                if (Main.player[this.owner].grapCount < 10)
                                {
                                    Main.player[this.owner].grappling[Main.player[this.owner].grapCount] = this.whoAmI;
                                    Main.player[this.owner].grapCount++;
                                }
                                if (Main.myPlayer == this.owner)
                                {
                                    int num79 = 0;
                                    int num80 = -1;
                                    int num81 = 100000;
                                    if (this.type == ProjectileID.DualHookBlue || this.type == ProjectileID.DualHookRed)
                                    {
                                        for (int num82 = 0; num82 < 1000; num82++)
                                        {
                                            if (num82 != this.whoAmI && Main.projectile[num82].active && Main.projectile[num82].owner == this.owner && Main.projectile[num82].aiStyle == 7 && Main.projectile[num82].ai[0] == 2f)
                                            {
                                                Main.projectile[num82].Kill();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        int num83 = 3;
                                        if (this.type == ProjectileID.Web)
                                        {
                                            num83 = 8;
                                        }
                                        if (this.type == ProjectileID.SkeletronHand)
                                        {
                                            num83 = 2;
                                        }
                                        if (this.type == ProjectileID.FishHook)
                                        {
                                            num83 = 2;
                                        }
                                        if (this.type >= ProjectileID.LunarHookSolar && this.type <= ProjectileID.LunarHookStardust)
                                        {
                                            num83 = 4;
                                        }
                                        for (int num84 = 0; num84 < 1000; num84++)
                                        {
                                            if (Main.projectile[num84].active && Main.projectile[num84].owner == this.owner && Main.projectile[num84].aiStyle == 7)
                                            {
                                                if (Main.projectile[num84].timeLeft < num81)
                                                {
                                                    num80 = num84;
                                                    num81 = Main.projectile[num84].timeLeft;
                                                }
                                                num79++;
                                            }
                                        }
                                        if (num79 > num83)
                                        {
                                            Main.projectile[num80].Kill();
                                        }
                                    }
                                }
                                WorldGen.KillTile(num77, num78, true, true, false);
                                this.velocity.X = 0f;
                                this.velocity.Y = 0f;
                                this.ai[0] = 2f;
                                this.position.X = (float)(num77 * 16 + 8 - this.width / 2);
                                this.position.Y = (float)(num78 * 16 + 8 - this.height / 2);
                                this.damage = 0;
                                this.netUpdate = true;
                                if (Main.myPlayer == this.owner)
                                {
                                    NetMessage.SendData((int)PacketTypes.PlayerUpdate, -1, -1, "", this.owner, 0f, 0f, 0f, 0, 0, 0);
                                    break;
                                }
                                break;
                            }
                            else
                            {
                                num78++;
                            }
                        }
                        if (this.ai[0] == 2f)
                        {
                            return;
                        }
                    }
                    return;
                }
                if (this.ai[0] == 1f)
                {
                    float num85 = 11f;
                    if (this.type == ProjectileID.IvyWhip)
                    {
                        num85 = 15f;
                    }
                    if (this.type == ProjectileID.DualHookBlue || this.type == ProjectileID.DualHookRed)
                    {
                        num85 = 17f;
                    }
                    if (this.type == ProjectileID.BatHook)
                    {
                        num85 = 20f;
                    }
                    if (this.type == ProjectileID.WoodHook)
                    {
                        num85 = 22f;
                    }
                    if (this.type >= ProjectileID.GemHookAmethyst && this.type <= ProjectileID.GemHookDiamond)
                    {
                        num85 = 11f + (float)(this.type - 230) * 0.75f;
                    }
                    if (this.type == ProjectileID.AntiGravityHook)
                    {
                        num85 = 20f;
                    }
                    if (this.type >= ProjectileID.TendonHook && this.type <= ProjectileID.WormHook)
                    {
                        num85 = 18f;
                    }
                    if (this.type >= ProjectileID.LunarHookSolar && this.type <= ProjectileID.LunarHookStardust)
                    {
                        num85 = 24f;
                    }
                    if (this.type == ProjectileID.ChristmasHook)
                    {
                        num85 = 17f;
                    }
                    if (num71 < 24f)
                    {
                        this.Kill();
                    }
                    num71 = num85 / num71;
                    num69 *= num71;
                    num70 *= num71;
                    this.velocity.X = num69;
                    this.velocity.Y = num70;
                    return;
                }
                if (this.ai[0] == 2f)
                {
                    int num86 = (int)(this.position.X / 16f) - 1;
                    int num87 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                    int num88 = (int)(this.position.Y / 16f) - 1;
                    int num89 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                    if (num86 < 0)
                    {
                        num86 = 0;
                    }
                    if (num87 > Main.maxTilesX)
                    {
                        num87 = Main.maxTilesX;
                    }
                    if (num88 < 0)
                    {
                        num88 = 0;
                    }
                    if (num89 > Main.maxTilesY)
                    {
                        num89 = Main.maxTilesY;
                    }
                    bool flag2 = true;
                    for (int num90 = num86; num90 < num87; num90++)
                    {
                        for (int num91 = num88; num91 < num89; num91++)
                        {
                            if (Main.tile[num90, num91] == null)
                            {
                                Main.tile[num90, num91] = new Tile();
                            }
                            Vector2 vector12;
                            vector12.X = (float)(num90 * 16);
                            vector12.Y = (float)(num91 * 16);
                            if (this.position.X + (float)(this.width / 2) > vector12.X && this.position.X + (float)(this.width / 2) < vector12.X + 16f && this.position.Y + (float)(this.height / 2) > vector12.Y && this.position.Y + (float)(this.height / 2) < vector12.Y + 16f && Main.tile[num90, num91].nactive() && (Main.tileSolid[(int)Main.tile[num90, num91].type] || Main.tile[num90, num91].type == TileID.MinecartTrack || Main.tile[num90, num91].type == TileID.Trees))
                            {
                                flag2 = false;
                            }
                        }
                    }
                    if (flag2)
                    {
                        this.ai[0] = 1f;
                        return;
                    }
                    if (Main.player[this.owner].grapCount < 10)
                    {
                        Main.player[this.owner].grappling[Main.player[this.owner].grapCount] = this.whoAmI;
                        Main.player[this.owner].grapCount++;
                        return;
                    }
                }
            }
            else if (this.aiStyle == 8)
            {
                if (this.type == ProjectileID.Fireball && this.localAI[0] == 0f)
                {
                    this.localAI[0] = 1f;
                }
                if (this.type == ProjectileID.CursedFlameHostile && this.localAI[0] == 0f)
                {
                    this.localAI[0] = 1f;
                }
                if (this.type != ProjectileID.WaterBolt && this.type != ProjectileID.CursedFlameHostile && this.type != ProjectileID.Fireball)
                {
                    this.ai[1] += 1f;
                }
                if (this.ai[1] >= 20f)
                {
                    this.velocity.Y = this.velocity.Y + 0.2f;
                }
                if (this.type == ProjectileID.Meowmere)
                {
                    this.rotation = this.velocity.ToRotation() + 1.57079637f;
                    if (this.velocity.X != 0f)
                    {
                        this.spriteDirection = (this.direction = Math.Sign(this.velocity.X));
                    }
                }
                else
                {
                    this.rotation += 0.3f * (float)this.direction;
                }
                if (this.velocity.Y > 16f)
                {
                    this.velocity.Y = 16f;
                    return;
                }
            }
            else if (this.aiStyle == 9)
            {
                if (Main.myPlayer == this.owner && this.ai[0] <= 0f)
                {
                    if (Main.player[this.owner].channel)
                    {
                        float num113 = 12f;
                        if (this.type == ProjectileID.MagicMissile)
                        {
                            num113 = 15f;
                        }
                        if (this.type == ProjectileID.FlyingKnife)
                        {
                            num113 = 20f;
                        }
                        Vector2 vector13 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num114 = (float)Main.mouseX + Main.screenPosition.X - vector13.X;
                        float num115 = (float)Main.mouseY + Main.screenPosition.Y - vector13.Y;
                        if (Main.player[this.owner].gravDir == -1f)
                        {
                            num115 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector13.Y;
                        }
                        float num116 = (float)Math.Sqrt((double)(num114 * num114 + num115 * num115));
                        num116 = (float)Math.Sqrt((double)(num114 * num114 + num115 * num115));
                        if (this.ai[0] < 0f)
                        {
                            this.ai[0] += 1f;
                        }
                        if (this.type == ProjectileID.FlyingKnife && num116 < 100f)
                        {
                            if (this.velocity.Length() < num113)
                            {
                                this.velocity *= 1.1f;
                                if (this.velocity.Length() > num113)
                                {
                                    this.velocity.Normalize();
                                    this.velocity *= num113;
                                }
                            }
                            if (this.ai[0] == 0f)
                            {
                                this.ai[0] = -10f;
                            }
                        }
                        else if (num116 > num113)
                        {
                            num116 = num113 / num116;
                            num114 *= num116;
                            num115 *= num116;
                            int num117 = (int)(num114 * 1000f);
                            int num118 = (int)(this.velocity.X * 1000f);
                            int num119 = (int)(num115 * 1000f);
                            int num120 = (int)(this.velocity.Y * 1000f);
                            if (num117 != num118 || num119 != num120)
                            {
                                this.netUpdate = true;
                            }
                            if (this.type == ProjectileID.FlyingKnife)
                            {
                                Vector2 vector14 = new Vector2(num114, num115);
                                this.velocity = (this.velocity * 4f + vector14) / 5f;
                            }
                            else
                            {
                                this.velocity.X = num114;
                                this.velocity.Y = num115;
                            }
                        }
                        else
                        {
                            int num121 = (int)(num114 * 1000f);
                            int num122 = (int)(this.velocity.X * 1000f);
                            int num123 = (int)(num115 * 1000f);
                            int num124 = (int)(this.velocity.Y * 1000f);
                            if (num121 != num122 || num123 != num124)
                            {
                                this.netUpdate = true;
                            }
                            this.velocity.X = num114;
                            this.velocity.Y = num115;
                        }
                    }
                    else if (this.ai[0] <= 0f)
                    {
                        this.netUpdate = true;
                        if (this.type != ProjectileID.FlyingKnife)
                        {
                            float num125 = 12f;
                            Vector2 vector15 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num126 = (float)Main.mouseX + Main.screenPosition.X - vector15.X;
                            float num127 = (float)Main.mouseY + Main.screenPosition.Y - vector15.Y;
                            if (Main.player[this.owner].gravDir == -1f)
                            {
                                num127 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector15.Y;
                            }
                            float num128 = (float)Math.Sqrt((double)(num126 * num126 + num127 * num127));
                            if (num128 == 0f || this.ai[0] < 0f)
                            {
                                vector15 = new Vector2(Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2), Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2));
                                num126 = this.position.X + (float)this.width * 0.5f - vector15.X;
                                num127 = this.position.Y + (float)this.height * 0.5f - vector15.Y;
                                num128 = (float)Math.Sqrt((double)(num126 * num126 + num127 * num127));
                            }
                            num128 = num125 / num128;
                            num126 *= num128;
                            num127 *= num128;
                            this.velocity.X = num126;
                            this.velocity.Y = num127;
                            if (this.velocity.X == 0f && this.velocity.Y == 0f)
                            {
                                this.Kill();
                            }
                        }
                        this.ai[0] = 1f;
                    }
                }
                if (this.type == ProjectileID.FlyingKnife)
                {
                    this.localAI[0] += 1f;
                    if (this.ai[0] > 0f && this.localAI[0] > 15f)
                    {
                        this.tileCollide = false;
                        Vector2 vector16 = Main.player[this.owner].Center - base.Center;
                        if (vector16.Length() < 20f)
                        {
                            this.Kill();
                        }
                        vector16.Normalize();
                        vector16 *= 25f;
                        this.velocity = (this.velocity * 5f + vector16) / 6f;
                    }
                    if (this.ai[0] < 0f || (this.velocity.X == 0f && this.velocity.Y == 0f))
                    {
                        this.rotation += 0.3f;
                    }
                    else if (this.ai[0] > 0f)
                    {
                        this.rotation += 0.3f * (float)this.direction;
                    }
                    else
                    {
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    }
                }
                else if (this.type == ProjectileID.Flamelash)
                {
                    this.rotation += 0.3f * (float)this.direction;
                }
                else if (this.velocity.X != 0f || this.velocity.Y != 0f)
                {
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 2.355f;
                }
                if (this.velocity.Y > 16f)
                {
                    this.velocity.Y = 16f;
                    return;
                }
            }
            else if (this.aiStyle == 10)
            {
                this.tileCollide = true;
                this.localAI[1] = 0f;
                if (Main.myPlayer == this.owner && this.ai[0] == 0f)
                {
                    this.tileCollide = false;
                    if (Main.player[this.owner].channel)
                    {
                        this.localAI[1] = -1f;
                        float num140 = 12f;
                        Vector2 vector17 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num141 = (float)Main.mouseX + Main.screenPosition.X - vector17.X;
                        float num142 = (float)Main.mouseY + Main.screenPosition.Y - vector17.Y;
                        if (Main.player[this.owner].gravDir == -1f)
                        {
                            num142 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector17.Y;
                        }
                        float num143 = (float)Math.Sqrt((double)(num141 * num141 + num142 * num142));
                        num143 = (float)Math.Sqrt((double)(num141 * num141 + num142 * num142));
                        if (num143 > num140)
                        {
                            num143 = num140 / num143;
                            num141 *= num143;
                            num142 *= num143;
                            if (num141 != this.velocity.X || num142 != this.velocity.Y)
                            {
                                this.netUpdate = true;
                            }
                            this.velocity.X = num141;
                            this.velocity.Y = num142;
                        }
                        else
                        {
                            if (num141 != this.velocity.X || num142 != this.velocity.Y)
                            {
                                this.netUpdate = true;
                            }
                            this.velocity.X = num141;
                            this.velocity.Y = num142;
                        }
                    }
                    else
                    {
                        this.ai[0] = 1f;
                        this.netUpdate = true;
                    }
                }
                if (this.ai[0] == 1f && this.type != ProjectileID.SnowBallHostile)
                {
                    if (this.type == ProjectileID.SandBallGun || this.type == ProjectileID.EbonsandBallGun || this.type == ProjectileID.PearlSandBallGun || this.type == ProjectileID.CrimsandBallGun)
                    {
                        this.ai[1] += 1f;
                        if (this.ai[1] >= 60f)
                        {
                            this.ai[1] = 60f;
                            this.velocity.Y = this.velocity.Y + 0.2f;
                        }
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y + 0.41f;
                    }
                }
                else if (this.ai[0] == 2f && this.type != ProjectileID.SnowBallHostile)
                {
                    this.velocity.Y = this.velocity.Y + 0.2f;
                    if ((double)this.velocity.X < -0.04)
                    {
                        this.velocity.X = this.velocity.X + 0.04f;
                    }
                    else if ((double)this.velocity.X > 0.04)
                    {
                        this.velocity.X = this.velocity.X - 0.04f;
                    }
                    else
                    {
                        this.velocity.X = 0f;
                    }
                }
                this.rotation += 0.1f;
                if (this.velocity.Y > 10f)
                {
                    this.velocity.Y = 10f;
                    return;
                }
            }
            else if (this.aiStyle == 11)
            {
                if (this.type == ProjectileID.BlueFairy || this.type == ProjectileID.PinkFairy || this.type == ProjectileID.GreenFairy)
                {
                    if (this.velocity.X > 0f)
                    {
                        this.spriteDirection = -1;
                    }
                    else if (this.velocity.X < 0f)
                    {
                        this.spriteDirection = 1;
                    }
                    this.rotation = this.velocity.X * 0.1f;
                    this.frameCounter++;
                    if (this.frameCounter >= 4)
                    {
                        this.frame++;
                        this.frameCounter = 0;
                    }
                    if (this.frame >= 4)
                    {
                        this.frame = 0;
                    }
                }
                else
                {
                    this.rotation += 0.02f;
                }
                if (Main.myPlayer == this.owner)
                {
                    if (this.type == ProjectileID.BlueFairy)
                    {
                        if (Main.player[Main.myPlayer].blueFairy)
                        {
                            this.timeLeft = 2;
                        }
                    }
                    else if (this.type == ProjectileID.PinkFairy)
                    {
                        if (Main.player[Main.myPlayer].redFairy)
                        {
                            this.timeLeft = 2;
                        }
                    }
                    else if (this.type == ProjectileID.GreenFairy)
                    {
                        if (Main.player[Main.myPlayer].greenFairy)
                        {
                            this.timeLeft = 2;
                        }
                    }
                    else if (Main.player[Main.myPlayer].lightOrb)
                    {
                        this.timeLeft = 2;
                    }
                }
                if (Main.player[this.owner].dead)
                {
                    this.Kill();
                    return;
                }
                float num146 = 3f;
                if (this.type == ProjectileID.BlueFairy || this.type == ProjectileID.PinkFairy || this.type == ProjectileID.GreenFairy)
                {
                    num146 = 3.75f;
                }
                Vector2 vector18 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num147 = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - vector18.X;
                float num148 = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - vector18.Y;
                int num149 = 70;
                if (this.type == ProjectileID.ShadowOrb)
                {
                    if (Main.player[this.owner].controlUp)
                    {
                        num148 = Main.player[this.owner].position.Y - 40f - vector18.Y;
                        num147 -= 6f;
                        num149 = 4;
                    }
                    else if (Main.player[this.owner].controlDown)
                    {
                        num148 = Main.player[this.owner].position.Y + (float)Main.player[this.owner].height + 40f - vector18.Y;
                        num147 -= 6f;
                        num149 = 4;
                    }
                }
                float num150 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
                num150 = (float)Math.Sqrt((double)(num147 * num147 + num148 * num148));
                if (this.type == ProjectileID.BlueFairy || this.type == ProjectileID.PinkFairy || this.type == ProjectileID.GreenFairy)
                {
                    num149 = 40;
                }
                if (num150 > 800f)
                {
                    this.position.X = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - (float)(this.width / 2);
                    this.position.Y = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - (float)(this.height / 2);
                    return;
                }
                if (num150 > (float)num149)
                {
                    num150 = num146 / num150;
                    num147 *= num150;
                    num148 *= num150;
                    this.velocity.X = num147;
                    this.velocity.Y = num148;
                    return;
                }
                this.velocity.X = 0f;
                this.velocity.Y = 0f;
                return;
            }
            else if (this.aiStyle == 12)
            {
                if (this.type == ProjectileID.GoldenShowerHostile && this.localAI[0] == 0f)
                {
                    this.localAI[0] = 1f;
                }
                if (this.type == ProjectileID.GoldenShowerFriendly || this.type == ProjectileID.GoldenShowerHostile)
                {
                    this.scale -= 0.002f;
                    if (this.scale <= 0f)
                    {
                        this.Kill();
                    }
                    if (this.type == ProjectileID.GoldenShowerHostile)
                    {
                        this.ai[0] = 4f;
                    }
                    if (this.ai[0] <= 3f)
                    {
                        this.ai[0] += 1f;
                        return;
                    }
                    this.velocity.Y = this.velocity.Y + 0.075f;
                    if (Main.rand.Next(8) == 0)
                    {
                        return;
                    }
                }
                else
                {
                    this.scale -= 0.02f;
                    if (this.scale <= 0f)
                    {
                        this.Kill();
                    }
                    if (this.ai[0] > 3f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.2f;
                        return;
                    }
                    this.ai[0] += 1f;
                    return;
                }
            }
            else if (this.aiStyle == 13)
            {
                if (Main.player[this.owner].dead)
                {
                    this.Kill();
                    return;
                }
                if (this.type != ProjectileID.ChainGuillotine)
                {
                    Main.player[this.owner].itemAnimation = 5;
                    Main.player[this.owner].itemTime = 5;
                }
                if (this.alpha == 0)
                {
                    if (this.position.X + (float)(this.width / 2) > Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2))
                    {
                        Main.player[this.owner].ChangeDir(1);
                    }
                    else
                    {
                        Main.player[this.owner].ChangeDir(-1);
                    }
                }
                if (this.type == ProjectileID.ChainGuillotine)
                {
                    if (this.ai[0] == 0f)
                    {
                        this.extraUpdates = 0;
                    }
                    else
                    {
                        this.extraUpdates = 1;
                    }
                }
                Vector2 vector19 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num166 = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - vector19.X;
                float num167 = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - vector19.Y;
                float num168 = (float)Math.Sqrt((double)(num166 * num166 + num167 * num167));
                if (this.ai[0] == 0f)
                {
                    if (num168 > 700f)
                    {
                        this.ai[0] = 1f;
                    }
                    else if (this.type == ProjectileID.GolemFist && num168 > 500f)
                    {
                        this.ai[0] = 1f;
                    }
                    else if (this.type == ProjectileID.BoxingGlove && num168 > 200f)
                    {
                        this.ai[0] = 1f;
                    }
                    else if (this.type == ProjectileID.ChainKnife && num168 > 150f)
                    {
                        this.ai[0] = 1f;
                    }
                    else if (this.type == ProjectileID.ChainGuillotine && num168 > 350f)
                    {
                        this.ai[0] = 1f;
                    }
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    this.ai[1] += 1f;
                    if (this.ai[1] > 5f)
                    {
                        this.alpha = 0;
                    }
                    if (this.type == ProjectileID.GolemFist && this.ai[1] > 8f)
                    {
                        this.ai[1] = 8f;
                    }
                    if (this.type == ProjectileID.BoxingGlove && this.ai[1] > 8f)
                    {
                        this.ai[1] = 8f;
                    }
                    if (this.type == ProjectileID.ChainKnife && this.ai[1] > 8f)
                    {
                        this.ai[1] = 8f;
                    }
                    if (this.type == ProjectileID.ChainGuillotine && this.ai[1] > 8f)
                    {
                        this.ai[1] = 8f;
                    }
                    if (this.type == ProjectileID.Flairon && this.ai[1] > 8f)
                    {
                        this.ai[1] = 0f;
                    }
                    if (this.ai[1] >= 10f)
                    {
                        this.ai[1] = 15f;
                        this.velocity.Y = this.velocity.Y + 0.3f;
                    }
                    if (this.type == ProjectileID.GolemFist && this.velocity.X < 0f)
                    {
                        this.spriteDirection = -1;
                    }
                    else if (this.type == ProjectileID.GolemFist)
                    {
                        this.spriteDirection = 1;
                    }
                    if (this.type == ProjectileID.BoxingGlove && this.velocity.X < 0f)
                    {
                        this.spriteDirection = -1;
                        return;
                    }
                    if (this.type == ProjectileID.BoxingGlove)
                    {
                        this.spriteDirection = 1;
                        return;
                    }
                }
                else if (this.ai[0] == 1f)
                {
                    this.tileCollide = false;
                    this.rotation = (float)Math.Atan2((double)num167, (double)num166) - 1.57f;
                    float num169 = 20f;
                    if (this.type == ProjectileID.GolemFist)
                    {
                        num169 = 30f;
                    }
                    if (num168 < 50f)
                    {
                        this.Kill();
                    }
                    num168 = num169 / num168;
                    num166 *= num168;
                    num167 *= num168;
                    this.velocity.X = num166;
                    this.velocity.Y = num167;
                    if (this.type == ProjectileID.GolemFist && this.velocity.X < 0f)
                    {
                        this.spriteDirection = 1;
                    }
                    else if (this.type == ProjectileID.GolemFist)
                    {
                        this.spriteDirection = -1;
                    }
                    if (this.type == ProjectileID.BoxingGlove && this.velocity.X < 0f)
                    {
                        this.spriteDirection = 1;
                        return;
                    }
                    if (this.type == ProjectileID.BoxingGlove)
                    {
                        this.spriteDirection = -1;
                        return;
                    }
                }
            }
            else if (this.aiStyle == 14)
            {
                if (this.type == ProjectileID.SpelunkerGlowstick && Main.netMode != 2)
                {
                    this.localAI[0] += 1f;
                    if (this.localAI[0] >= 10f)
                    {
                        this.localAI[0] = 0f;
                    }
                }
                if (this.type == ProjectileID.Spike)
                {
                    if (this.localAI[1] == 0f)
                    {
                        this.localAI[1] = 1f;
                    }
                    this.alpha += (int)(25f * this.localAI[1]);
                    if (this.alpha <= 0)
                    {
                        this.alpha = 0;
                        this.localAI[1] = 1f;
                    }
                    else if (this.alpha >= 255)
                    {
                        this.alpha = 255;
                        this.localAI[1] = -1f;
                    }
                    this.scale += this.localAI[1] * 0.01f;
                }
                if (this.type == ProjectileID.OrnamentHostile)
                {
                    if (this.localAI[0] == 0f)
                    {
                        this.localAI[0] = 1f;
                    }
                    this.frame = (int)this.ai[1];
                    if (this.owner == Main.myPlayer && this.timeLeft == 1)
                    {
                        for (int num176 = 0; num176 < 5; num176++)
                        {
                            float num177 = 10f;
                            Vector2 vector21 = new Vector2(base.Center.X, base.Center.Y);
                            float num178 = (float)Main.rand.Next(-20, 21);
                            float num179 = (float)Main.rand.Next(-20, 0);
                            float num180 = (float)Math.Sqrt((double)(num178 * num178 + num179 * num179));
                            num180 = num177 / num180;
                            num178 *= num180;
                            num179 *= num180;
                            num178 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                            num179 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                            Projectile.NewProjectile(vector21.X, vector21.Y, num178, num179, 347, 40, 0f, Main.myPlayer, 0f, this.ai[1]);
                        }
                    }
                }
                if (this.type == ProjectileID.StickyGlowstick)
                {
                    try
                    {
                        Vector2 vector22 = Collision.TileCollision(this.position, this.velocity, this.width, this.height, false, false, 1);
                        int num184 = (int)(this.position.X / 16f) - 1;
                        int num185 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                        int num186 = (int)(this.position.Y / 16f) - 1;
                        int num187 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                        if (num184 < 0)
                        {
                            num184 = 0;
                        }
                        if (num185 > Main.maxTilesX)
                        {
                            num185 = Main.maxTilesX;
                        }
                        if (num186 < 0)
                        {
                            num186 = 0;
                        }
                        if (num187 > Main.maxTilesY)
                        {
                            num187 = Main.maxTilesY;
                        }
                        for (int num188 = num184; num188 < num185; num188++)
                        {
                            for (int num189 = num186; num189 < num187; num189++)
                            {
                                if (Main.tile[num188, num189] != null && Main.tile[num188, num189].nactive() && (Main.tileSolid[(int)Main.tile[num188, num189].type] || (Main.tileSolidTop[(int)Main.tile[num188, num189].type] && Main.tile[num188, num189].frameY == 0)))
                                {
                                    Vector2 vector23;
                                    vector23.X = (float)(num188 * 16);
                                    vector23.Y = (float)(num189 * 16);
                                    if (this.position.X + (float)this.width > vector23.X && this.position.X < vector23.X + 16f && this.position.Y + (float)this.height > vector23.Y && this.position.Y < vector23.Y + 16f)
                                    {
                                        this.velocity.X = 0f;
                                        this.velocity.Y = -0.2f;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
            #if DEBUG
                        Console.WriteLine(ex);
                        System.Diagnostics.Debugger.Break();

            #endif
                    }
                }
                if (this.type == ProjectileID.ThornBall)
                {
                    if (this.alpha > 0)
                    {
                        this.alpha -= 30;
                        if (this.alpha < 0)
                        {
                            this.alpha = 0;
                        }
                    }
                    if (Main.expertMode)
                    {
                        float num190 = 12f;
                        int num191 = (int)Player.FindClosest(base.Center, 1, 1);
                        Vector2 vector24 = Main.player[num191].Center - base.Center;
                        vector24.Normalize();
                        vector24 *= num190;
                        int num192 = 200;
                        this.velocity.X = (this.velocity.X * (float)(num192 - 1) + vector24.X) / (float)num192;
                        if (this.velocity.Length() > 16f)
                        {
                            this.velocity.Normalize();
                            this.velocity *= 16f;
                        }
                    }
                }
                if (this.type == ProjectileID.BoulderStaffOfEarth || this.type == ProjectileID.ThornBall)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] > 15f)
                    {
                        this.ai[0] = 15f;
                        if (this.velocity.Y == 0f && this.velocity.X != 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.97f;
                            if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                            {
                                this.Kill();
                            }
                        }
                        this.velocity.Y = this.velocity.Y + 0.2f;
                    }
                    this.rotation += this.velocity.X * 0.05f;
                }
                else if (this.type == ProjectileID.SpiderEgg)
                {
                    if (this.localAI[0] == 0f)
                    {
                        this.localAI[0] += 1f;
                    }
                    Rectangle rectangle3 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                    for (int num193 = 0; num193 < 200; num193++)
                    {
                        if (Main.npc[num193].CanBeChasedBy(this, true))
                        {
                            Rectangle rectangle4 = new Rectangle((int)Main.npc[num193].position.X, (int)Main.npc[num193].position.Y, Main.npc[num193].width, Main.npc[num193].height);
                            if (rectangle3.Intersects(rectangle4))
                            {
                                this.Kill();
                                return;
                            }
                        }
                    }
                    this.ai[0] += 1f;
                    if (this.ai[0] > 10f)
                    {
                        this.ai[0] = 90f;
                        if (this.velocity.Y == 0f && this.velocity.X != 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.96f;
                            if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                            {
                                this.Kill();
                            }
                        }
                        this.velocity.Y = this.velocity.Y + 0.2f;
                    }
                    this.rotation += this.velocity.X * 0.1f;
                }
                else if (this.type == ProjectileID.SeedlerNut)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] > 5f)
                    {
                        if (this.owner == Main.myPlayer && this.ai[0] > (float)Main.rand.Next(20, 130))
                        {
                            this.Kill();
                        }
                        if (this.velocity.Y == 0f && this.velocity.X != 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.97f;
                            if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                            {
                                this.velocity.X = 0f;
                                this.netUpdate = true;
                            }
                        }
                        this.velocity.Y = this.velocity.Y + 0.3f;
                        this.velocity.X = this.velocity.X * 0.99f;
                    }
                    this.rotation += this.velocity.X * 0.05f;
                }
                else if (this.type == ProjectileID.Twinkle)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] > 60f || this.velocity.Y >= 0f)
                    {
                        this.alpha += 6;
                        this.velocity *= 0.5f;
                    }
                    else if (this.ai[0] > 5f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        this.velocity.X = this.velocity.X * 1.025f;
                        this.alpha -= 23;
                        this.scale = 0.8f * (255f - (float)this.alpha) / 255f;
                        if (this.alpha < 0)
                        {
                            this.alpha = 0;
                        }
                    }
                    if (this.alpha >= 255 && this.ai[0] > 5f)
                    {
                        this.Kill();
                        return;
                    }
                }
                else
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] > 5f)
                    {
                        this.ai[0] = 5f;
                        if (this.velocity.Y == 0f && this.velocity.X != 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.97f;
                            if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                            {
                                this.velocity.X = 0f;
                                this.netUpdate = true;
                            }
                        }
                        this.velocity.Y = this.velocity.Y + 0.2f;
                    }
                    this.rotation += this.velocity.X * 0.1f;
                }
                if (this.type == ProjectileID.Twinkle)
                {
                    if (this.localAI[1] == 0f)
                    {
                        this.localAI[1] = 1f;
                    }
                }
                if (this.type == ProjectileID.SaucerScrap)
                {
                    if (this.ai[1] == 0f)
                    {
                        this.ai[1] = 1f;
                    }
                    if (++this.frameCounter >= 3)
                    {
                        this.frameCounter = 0;
                        if (++this.frame >= 5)
                        {
                            this.frame = 0;
                        }
                    }
                    if ((double)this.velocity.Y < 0.25 && (double)this.velocity.Y > 0.15)
                    {
                        this.velocity.X = this.velocity.X * 0.8f;
                    }
                    this.rotation = -this.velocity.X * 0.05f;
                }
                if (this.type == ProjectileID.CursedDartFlame)
                {
                    this.alpha = 255;
                }
                if ((this.type >= ProjectileID.GreekFire1 && this.type <= ProjectileID.GreekFire3) || (this.type >= ProjectileID.MolotovFire && this.type <= ProjectileID.MolotovFire3))
                {
                    if (this.wet)
                    {
                        this.Kill();
                    }
                    if (this.ai[1] == 0f && this.type >= ProjectileID.GreekFire1 && this.type <= ProjectileID.GreekFire3)
                    {
                        this.ai[1] = 1f;
                    }
                    if ((double)this.velocity.Y < 0.25 && (double)this.velocity.Y > 0.15)
                    {
                        this.velocity.X = this.velocity.X * 0.8f;
                    }
                    this.rotation = -this.velocity.X * 0.05f;
                }
                if (this.velocity.Y > 16f)
                {
                    this.velocity.Y = 16f;
                    return;
                }
            }
            else if (this.aiStyle == 15)
            {
                if (Main.player[this.owner].dead)
                {
                    this.Kill();
                    return;
                }
                Main.player[this.owner].itemAnimation = 10;
                Main.player[this.owner].itemTime = 10;
                if (this.position.X + (float)(this.width / 2) > Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2))
                {
                    Main.player[this.owner].ChangeDir(1);
                    this.direction = 1;
                }
                else
                {
                    Main.player[this.owner].ChangeDir(-1);
                    this.direction = -1;
                }
                Vector2 mountedCenter2 = Main.player[this.owner].MountedCenter;
                Vector2 vector25 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num205 = mountedCenter2.X - vector25.X;
                float num206 = mountedCenter2.Y - vector25.Y;
                float num207 = (float)Math.Sqrt((double)(num205 * num205 + num206 * num206));
                if (this.ai[0] == 0f)
                {
                    float num208 = 160f;
                    if (this.type == ProjectileID.TheDaoofPow)
                    {
                        num208 *= 1.5f;
                    }
                    if (this.type == ProjectileID.FlowerPow)
                    {
                        num208 *= 1.5f;
                    }
                    this.tileCollide = true;
                    if (num207 > num208)
                    {
                        this.ai[0] = 1f;
                        this.netUpdate = true;
                    }
                    else if (!Main.player[this.owner].channel)
                    {
                        if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.9f;
                        }
                        this.velocity.Y = this.velocity.Y + 1f;
                        this.velocity.X = this.velocity.X * 0.9f;
                    }
                }
                else if (this.ai[0] == 1f)
                {
                    float num209 = 14f / Main.player[this.owner].meleeSpeed;
                    float num210 = 0.9f / Main.player[this.owner].meleeSpeed;
                    float num211 = 300f;
                    if (this.type == ProjectileID.TheDaoofPow)
                    {
                        num211 *= 1.5f;
                        num209 *= 1.5f;
                        num210 *= 1.5f;
                    }
                    if (this.type == ProjectileID.FlowerPow)
                    {
                        num211 *= 1.5f;
                        num209 = 15.9f;
                        num210 *= 2f;
                    }
                    Math.Abs(num205);
                    Math.Abs(num206);
                    if (this.ai[1] == 1f)
                    {
                        this.tileCollide = false;
                    }
                    if (!Main.player[this.owner].channel || num207 > num211 || !this.tileCollide)
                    {
                        this.ai[1] = 1f;
                        if (this.tileCollide)
                        {
                            this.netUpdate = true;
                        }
                        this.tileCollide = false;
                        if (num207 < 20f)
                        {
                            this.Kill();
                        }
                    }
                    if (!this.tileCollide)
                    {
                        num210 *= 2f;
                    }
                    int num212 = 60;
                    if (this.type == ProjectileID.FlowerPow)
                    {
                        num212 = 100;
                    }
                    if (num207 > (float)num212 || !this.tileCollide)
                    {
                        num207 = num209 / num207;
                        num205 *= num207;
                        num206 *= num207;
                        new Vector2(this.velocity.X, this.velocity.Y);
                        float num213 = num205 - this.velocity.X;
                        float num214 = num206 - this.velocity.Y;
                        float num215 = (float)Math.Sqrt((double)(num213 * num213 + num214 * num214));
                        num215 = num210 / num215;
                        num213 *= num215;
                        num214 *= num215;
                        this.velocity.X = this.velocity.X * 0.98f;
                        this.velocity.Y = this.velocity.Y * 0.98f;
                        this.velocity.X = this.velocity.X + num213;
                        this.velocity.Y = this.velocity.Y + num214;
                    }
                    else
                    {
                        if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < 6f)
                        {
                            this.velocity.X = this.velocity.X * 0.96f;
                            this.velocity.Y = this.velocity.Y + 0.2f;
                        }
                        if (Main.player[this.owner].velocity.X == 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.96f;
                        }
                    }
                }
                if (this.type != ProjectileID.FlowerPow)
                {
                    this.rotation = (float)Math.Atan2((double)num206, (double)num205) - this.velocity.X * 0.1f;
                    return;
                }
                if (this.velocity.X < 0f)
                {
                    this.rotation -= (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * 0.01f;
                }
                else
                {
                    this.rotation += (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * 0.01f;
                }
                float num216 = this.position.X;
                float num217 = this.position.Y;
                float num218 = 600f;
                bool flag4 = false;
                if (this.owner == Main.myPlayer)
                {
                    this.localAI[1] += 1f;
                    if (this.localAI[1] > 20f)
                    {
                        this.localAI[1] = 20f;
                        for (int num219 = 0; num219 < 200; num219++)
                        {
                            if (Main.npc[num219].CanBeChasedBy(this, false))
                            {
                                float num220 = Main.npc[num219].position.X + (float)(Main.npc[num219].width / 2);
                                float num221 = Main.npc[num219].position.Y + (float)(Main.npc[num219].height / 2);
                                float num222 = Math.Abs(this.position.X + (float)(this.width / 2) - num220) + Math.Abs(this.position.Y + (float)(this.height / 2) - num221);
                                if (num222 < num218 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num219].position, Main.npc[num219].width, Main.npc[num219].height))
                                {
                                    num218 = num222;
                                    num216 = num220;
                                    num217 = num221;
                                    flag4 = true;
                                }
                            }
                        }
                    }
                }
                if (flag4)
                {
                    this.localAI[1] = 0f;
                    float num223 = 14f;
                    vector25 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    num205 = num216 - vector25.X;
                    num206 = num217 - vector25.Y;
                    num207 = (float)Math.Sqrt((double)(num205 * num205 + num206 * num206));
                    num207 = num223 / num207;
                    num205 *= num207;
                    num206 *= num207;
                    Projectile.NewProjectile(vector25.X, vector25.Y, num205, num206, 248, (int)((double)this.damage / 1.5), this.knockBack / 2f, Main.myPlayer, 0f, 0f);
                    return;
                }
            }
            else if (this.aiStyle == 16)
            {
                if (this.type == ProjectileID.Explosives || this.type == ProjectileID.Landmine)
                {
                    this.ai[0] += 1f;
                    if (this.ai[0] > 3f)
                    {
                        this.Kill();
                    }
                }
                if (this.type != ProjectileID.StickyBomb && this.type != ProjectileID.StickyGrenade && this.type != ProjectileID.StickyDynamite)
                {
                    if (this.type != ProjectileID.BombFish)
                    {
                        goto IL_990C;
                    }
                }
                try
                {
                    int num224 = (int)(this.position.X / 16f) - 1;
                    int num225 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                    int num226 = (int)(this.position.Y / 16f) - 1;
                    int num227 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                    if (num224 < 0)
                    {
                        num224 = 0;
                    }
                    if (num225 > Main.maxTilesX)
                    {
                        num225 = Main.maxTilesX;
                    }
                    if (num226 < 0)
                    {
                        num226 = 0;
                    }
                    if (num227 > Main.maxTilesY)
                    {
                        num227 = Main.maxTilesY;
                    }
                    for (int num228 = num224; num228 < num225; num228++)
                    {
                        for (int num229 = num226; num229 < num227; num229++)
                        {
                            if (Main.tile[num228, num229] != null && Main.tile[num228, num229].nactive() && (Main.tileSolid[(int)Main.tile[num228, num229].type] || (Main.tileSolidTop[(int)Main.tile[num228, num229].type] && Main.tile[num228, num229].frameY == 0)))
                            {
                                Vector2 vector26;
                                vector26.X = (float)(num228 * 16);
                                vector26.Y = (float)(num229 * 16);
                                if (this.position.X + (float)this.width - 4f > vector26.X && this.position.X + 4f < vector26.X + 16f && this.position.Y + (float)this.height - 4f > vector26.Y && this.position.Y + 4f < vector26.Y + 16f)
                                {
                                    this.velocity.X = 0f;
                                    this.velocity.Y = -0.2f;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
            #if DEBUG
                    Console.WriteLine(ex);
                    System.Diagnostics.Debugger.Break();

            #endif
                }
            IL_990C:
                if (this.type == ProjectileID.BombFish)
                {
                    this.localAI[1] += 1f;
                    float num230 = 180f - this.localAI[1];
                    if (num230 < 0f)
                    {
                        num230 = 0f;
                    }
                    this.frameCounter++;
                    if (num230 < 15f)
                    {
                        this.frameCounter++;
                    }
                    if ((float)this.frameCounter >= (num230 / 10f + 6f) / 2f)
                    {
                        this.frame++;
                        this.frameCounter = 0;
                        if (this.frame >= Main.projFrames[this.type])
                        {
                            this.frame = 0;
                        }
                    }
                }
                if (this.type == ProjectileID.BombSkeletronPrime)
                {
                    if (this.velocity.Y > 10f)
                    {
                        this.velocity.Y = 10f;
                    }
                    if (this.localAI[0] == 0f)
                    {
                        this.localAI[0] = 1f;
                    }
                    this.frameCounter++;
                    if (this.frameCounter > 3)
                    {
                        this.frame++;
                        this.frameCounter = 0;
                    }
                    if (this.frame > 1)
                    {
                        this.frame = 0;
                    }
                    if (this.velocity.Y == 0f)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)(this.height / 2);
                        this.width = 128;
                        this.height = 128;
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)(this.height / 2);
                        this.damage = 40;
                        this.knockBack = 8f;
                        this.timeLeft = 3;
                        this.netUpdate = true;
                    }
                }
                if (this.type == ProjectileID.RocketSkeleton && this.timeLeft <= 3 && this.hostile)
                {
                    this.position.X = this.position.X + (float)(this.width / 2);
                    this.position.Y = this.position.Y + (float)(this.height / 2);
                    this.width = 128;
                    this.height = 128;
                    this.position.X = this.position.X - (float)(this.width / 2);
                    this.position.Y = this.position.Y - (float)(this.height / 2);
                }
                if (this.owner == Main.myPlayer && this.timeLeft <= 3)
                {
                    this.tileCollide = false;
                    this.ai[1] = 0f;
                    this.alpha = 255;
                    if (this.type == ProjectileID.Bomb || this.type == ProjectileID.StickyBomb || this.type == ProjectileID.HappyBomb || this.type == ProjectileID.BouncyBomb || this.type == ProjectileID.BombFish)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)(this.height / 2);
                        this.width = 128;
                        this.height = 128;
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)(this.height / 2);
                        this.damage = 100;
                        this.knockBack = 8f;
                    }
                    else if (this.type == ProjectileID.Dynamite || this.type == ProjectileID.StickyDynamite || this.type == ProjectileID.BouncyDynamite)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)(this.height / 2);
                        this.width = 250;
                        this.height = 250;
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)(this.height / 2);
                        this.damage = 250;
                        this.knockBack = 10f;
                    }
                    else if (this.type == ProjectileID.Grenade || this.type == ProjectileID.StickyGrenade || this.type == ProjectileID.BouncyGrenade || this.type == ProjectileID.PartyGirlGrenade)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)(this.height / 2);
                        this.width = 128;
                        this.height = 128;
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)(this.height / 2);
                        this.knockBack = 8f;
                    }
                    else if (this.type == ProjectileID.GrenadeI || this.type == ProjectileID.RocketI || this.type == ProjectileID.ProximityMineI || this.type == ProjectileID.GrenadeII || this.type == ProjectileID.RocketII || this.type == ProjectileID.ProximityMineII || this.type == ProjectileID.RocketSnowmanI || this.type == ProjectileID.RocketSnowmanII)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)(this.height / 2);
                        this.width = 128;
                        this.height = 128;
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)(this.height / 2);
                        this.knockBack = 8f;
                    }
                    else if (this.type == ProjectileID.GrenadeIII || this.type == ProjectileID.RocketIII || this.type == ProjectileID.ProximityMineIII || this.type == ProjectileID.GrenadeIV || this.type == ProjectileID.RocketIV || this.type == ProjectileID.ProximityMineIV || this.type == ProjectileID.RocketSnowmanIII || this.type == ProjectileID.RocketSnowmanIV)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)(this.height / 2);
                        this.width = 200;
                        this.height = 200;
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)(this.height / 2);
                        this.knockBack = 10f;
                    }
                }
                else
                {
                    if (this.type != ProjectileID.Grenade && this.type != ProjectileID.BouncyGrenade && this.type != ProjectileID.PartyGirlGrenade && this.type != ProjectileID.StickyGrenade && this.type != ProjectileID.Explosives && this.type != ProjectileID.GrenadeI && this.type != ProjectileID.RocketI && this.type != ProjectileID.ProximityMineI && this.type != ProjectileID.GrenadeII && this.type != ProjectileID.RocketII && this.type != ProjectileID.ProximityMineII && this.type != ProjectileID.GrenadeIII && this.type != ProjectileID.RocketIII && this.type != ProjectileID.ProximityMineIII && this.type != ProjectileID.GrenadeIV && this.type != ProjectileID.RocketIV && this.type != ProjectileID.ProximityMineIV && this.type != ProjectileID.Landmine && this.type != ProjectileID.RocketSkeleton && this.type < 338 && this.type < 341)
                    {
                        this.damage = 0;
                    }
                    if (this.type == ProjectileID.RocketSnowmanI || this.type == ProjectileID.RocketSnowmanII || this.type == ProjectileID.RocketSnowmanIII || this.type == ProjectileID.RocketSnowmanIV)
                    {
                        this.localAI[1] += 1f;
                        if (this.localAI[1] > 6f)
                        {
                            this.alpha = 0;
                        }
                        else
                        {
                            this.alpha = (int)(255f - 42f * this.localAI[1]) + 100;
                            if (this.alpha > 255)
                            {
                                this.alpha = 255;
                            }
                        }
                        for (int num231 = 0; num231 < 2; num231++)
                        {
                            float num232 = 0f;
                            float num233 = 0f;
                            if (num231 == 1)
                            {
                                num232 = this.velocity.X * 0.5f;
                                num233 = this.velocity.Y * 0.5f;
                            }
                        }
                        float num236 = this.position.X;
                        float num237 = this.position.Y;
                        float num238 = 600f;
                        bool flag5 = false;
                        this.ai[0] += 1f;
                        if (this.ai[0] > 30f)
                        {
                            this.ai[0] = 30f;
                            for (int num239 = 0; num239 < 200; num239++)
                            {
                                if (Main.npc[num239].CanBeChasedBy(this, false))
                                {
                                    float num240 = Main.npc[num239].position.X + (float)(Main.npc[num239].width / 2);
                                    float num241 = Main.npc[num239].position.Y + (float)(Main.npc[num239].height / 2);
                                    float num242 = Math.Abs(this.position.X + (float)(this.width / 2) - num240) + Math.Abs(this.position.Y + (float)(this.height / 2) - num241);
                                    if (num242 < num238 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num239].position, Main.npc[num239].width, Main.npc[num239].height))
                                    {
                                        num238 = num242;
                                        num236 = num240;
                                        num237 = num241;
                                        flag5 = true;
                                    }
                                }
                            }
                        }
                        if (!flag5)
                        {
                            num236 = this.position.X + (float)(this.width / 2) + this.velocity.X * 100f;
                            num237 = this.position.Y + (float)(this.height / 2) + this.velocity.Y * 100f;
                        }
                        float num243 = 16f;
                        Vector2 vector27 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num244 = num236 - vector27.X;
                        float num245 = num237 - vector27.Y;
                        float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245));
                        num246 = num243 / num246;
                        num244 *= num246;
                        num245 *= num246;
                        this.velocity.X = (this.velocity.X * 11f + num244) / 12f;
                        this.velocity.Y = (this.velocity.Y * 11f + num245) / 12f;
                    }
                    else if (this.type == ProjectileID.RocketI || this.type == ProjectileID.RocketII || this.type == ProjectileID.RocketIII || this.type == ProjectileID.RocketIV || this.type == ProjectileID.RocketSkeleton)
                    {
                        if (Math.Abs(this.velocity.X) < 15f && Math.Abs(this.velocity.Y) < 15f)
                        {
                            this.velocity *= 1.1f;
                        }
                    }
                    else if (this.type == ProjectileID.ProximityMineI || this.type == ProjectileID.ProximityMineII || this.type == ProjectileID.ProximityMineIII || this.type == ProjectileID.ProximityMineIV)
                    {
                        if ((double)this.velocity.X > -0.2 && (double)this.velocity.X < 0.2 && (double)this.velocity.Y > -0.2 && (double)this.velocity.Y < 0.2)
                        {
                            this.alpha += 2;
                            if (this.alpha > 200)
                            {
                                this.alpha = 200;
                            }
                        }
                        else
                        {
                            this.alpha = 0;
                        }
                    }
                }
                this.ai[0] += 1f;
                if (this.type == ProjectileID.RocketSnowmanI || this.type == ProjectileID.RocketSnowmanII || this.type == ProjectileID.RocketSnowmanIII || this.type == ProjectileID.RocketSnowmanIV)
                {
                    if (this.velocity.X < 0f)
                    {
                        this.spriteDirection = -1;
                        this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X)) - 1.57f;
                    }
                    else
                    {
                        this.spriteDirection = 1;
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    }
                }
                else if (this.type == ProjectileID.RocketI || this.type == ProjectileID.RocketII || this.type == ProjectileID.RocketIII || this.type == ProjectileID.RocketIV || this.type == ProjectileID.RocketSkeleton)
                {
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                }
                else if (this.type == ProjectileID.ProximityMineI || this.type == ProjectileID.ProximityMineII || this.type == ProjectileID.ProximityMineIII || this.type == ProjectileID.ProximityMineIV)
                {
                    this.velocity.Y = this.velocity.Y + 0.2f;
                    this.velocity *= 0.97f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                    }
                    if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                    {
                        this.velocity.Y = 0f;
                    }
                }
                else if (this.type == ProjectileID.GrenadeI || this.type == ProjectileID.GrenadeII || this.type == ProjectileID.GrenadeIII || this.type == ProjectileID.GrenadeIV)
                {
                    if (this.ai[0] > 15f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.95f;
                        }
                        this.velocity.Y = this.velocity.Y + 0.2f;
                    }
                }
                else if (((this.type == ProjectileID.Grenade || this.type == ProjectileID.StickyGrenade || this.type == ProjectileID.BouncyGrenade || this.type == ProjectileID.PartyGirlGrenade) && this.ai[0] > 10f) || (this.type != ProjectileID.Grenade && this.type != ProjectileID.StickyGrenade && this.type != ProjectileID.BouncyGrenade && this.type != ProjectileID.PartyGirlGrenade && this.ai[0] > 5f))
                {
                    this.ai[0] = 10f;
                    if (this.velocity.Y == 0f && this.velocity.X != 0f)
                    {
                        this.velocity.X = this.velocity.X * 0.97f;
                        if (this.type == ProjectileID.Dynamite || this.type == ProjectileID.StickyDynamite || this.type == ProjectileID.BouncyDynamite)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                        {
                            this.velocity.X = 0f;
                            this.netUpdate = true;
                        }
                    }
                    this.velocity.Y = this.velocity.Y + 0.2f;
                }
                if (this.type == ProjectileID.BombFish)
                {
                    this.rotation += this.velocity.X * 0.06f;
                    return;
                }
                if (this.type != ProjectileID.RocketI && this.type != ProjectileID.RocketII && this.type != ProjectileID.RocketIII && this.type != ProjectileID.RocketIV && this.type != ProjectileID.RocketSkeleton && (this.type < 338 || this.type > 341))
                {
                    this.rotation += this.velocity.X * 0.1f;
                    return;
                }
            }
            else if (this.aiStyle == 17)
            {
                if (this.velocity.Y == 0f)
                {
                    this.velocity.X = this.velocity.X * 0.98f;
                }
                this.rotation += this.velocity.X * 0.1f;
                this.velocity.Y = this.velocity.Y + 0.2f;
                if (this.owner == Main.myPlayer)
                {
                    int num254 = (int)((this.position.X + (float)(this.width / 2)) / 16f);
                    int num255 = (int)((this.position.Y + (float)this.height - 4f) / 16f);
                    if (Main.tile[num254, num255] != null && !Main.tile[num254, num255].active())
                    {
                        int num256 = 0;
                        if (this.type >= ProjectileID.GraveMarker && this.type <= ProjectileID.Obelisk)
                        {
                            num256 = this.type - 200;
                        }
                        if (this.type >= ProjectileID.RichGravestone1 && this.type <= ProjectileID.RichGravestone5)
                        {
                            num256 = this.type - 527 + 6;
                        }
                        WorldGen.PlaceTile(num254, num255, 85, false, false, this.owner, num256);
                        if (Main.tile[num254, num255].active())
                        {
                            if (Main.netMode != 0)
                            {
                                NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 1, (float)num254, (float)num255, 85f, num256, 0, 0);
                            }
                            int num257 = Sign.ReadSign(num254, num255, true);
                            if (num257 >= 0)
                            {
                                Sign.TextSign(num257, this.miscText);
                            }
                            this.Kill();
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 18)
            {
                if (this.ai[1] == 0f && this.type == ProjectileID.DemonSickle)
                {
                    this.ai[1] = 1f;
                }
                if (this.type != ProjectileID.IceSickle && this.type != ProjectileID.DeathSickle)
                {
                    this.rotation += (float)this.direction * 0.8f;
                    this.ai[0] += 1f;
                    if (this.ai[0] >= 30f)
                    {
                        if (this.ai[0] < 100f)
                        {
                            this.velocity *= 1.06f;
                        }
                        else
                        {
                            this.ai[0] = 200f;
                        }
                    }
                    return;
                }
                if (this.type == ProjectileID.DeathSickle && this.velocity.X < 0f)
                {
                    this.spriteDirection = -1;
                }
                this.rotation += (float)this.direction * 0.05f;
                this.rotation += (float)this.direction * 0.5f * ((float)this.timeLeft / 180f);
                if (this.type == ProjectileID.DeathSickle)
                {
                    this.velocity *= 0.96f;
                    return;
                }
                this.velocity *= 0.95f;
                return;
            }
            else if (this.aiStyle == 19)
            {
                Vector2 vector28 = Main.player[this.owner].RotatedRelativePoint(Main.player[this.owner].MountedCenter, true);
                this.direction = Main.player[this.owner].direction;
                Main.player[this.owner].heldProj = this.whoAmI;
                Main.player[this.owner].itemTime = Main.player[this.owner].itemAnimation;
                this.position.X = vector28.X - (float)(this.width / 2);
                this.position.Y = vector28.Y - (float)(this.height / 2);
                if (!Main.player[this.owner].frozen)
                {
                    if (this.type == ProjectileID.DarkLance)
                    {
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.6f;
                        }
                        else
                        {
                            this.ai[0] += 1.4f;
                        }
                    }
                    else if (this.type == ProjectileID.Gungnir)
                    {
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 2.4f;
                        }
                        else
                        {
                            this.ai[0] += 2.1f;
                        }
                    }
                    else if (this.type == ProjectileID.ObsidianSwordfish)
                    {
                        this.spriteDirection = -this.direction;
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.6f;
                        }
                        else
                        {
                            this.ai[0] += 1.5f;
                        }
                    }
                    else if (this.type == ProjectileID.Swordfish)
                    {
                        this.spriteDirection = -this.direction;
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.5f;
                        }
                        else
                        {
                            this.ai[0] += 1.4f;
                        }
                    }
                    else if (this.type == ProjectileID.ChlorophytePartisan)
                    {
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 2.4f;
                            if (this.localAI[0] == 0f && Main.myPlayer == this.owner)
                            {
                                this.localAI[0] = 1f;
                                Projectile.NewProjectile(base.Center.X + this.velocity.X * this.ai[0], base.Center.Y + this.velocity.Y * this.ai[0], this.velocity.X, this.velocity.Y, 228, this.damage, this.knockBack, this.owner, 0f, 0f);
                            }
                        }
                        else
                        {
                            this.ai[0] += 2.1f;
                        }
                    }
                    else if (this.type == ProjectileID.NorthPoleWeapon)
                    {
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 2.4f;
                            if (this.localAI[0] == 0f && Main.myPlayer == this.owner)
                            {
                                this.localAI[0] = 1f;
                                if (Collision.CanHit(Main.player[this.owner].position, Main.player[this.owner].width, Main.player[this.owner].height, new Vector2(base.Center.X + this.velocity.X * this.ai[0], base.Center.Y + this.velocity.Y * this.ai[0]), this.width, this.height))
                                {
                                    Projectile.NewProjectile(base.Center.X + this.velocity.X * this.ai[0], base.Center.Y + this.velocity.Y * this.ai[0], this.velocity.X * 2.4f, this.velocity.Y * 2.4f, 343, (int)((double)this.damage * 0.8), this.knockBack * 0.85f, this.owner, 0f, 0f);
                                }
                            }
                        }
                        else
                        {
                            this.ai[0] += 2.1f;
                        }
                    }
                    else if (this.type == ProjectileID.Trident)
                    {
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 4f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.2f;
                        }
                        else
                        {
                            this.ai[0] += 0.9f;
                        }
                    }
                    else if (this.type == ProjectileID.TheRottedFork)
                    {
                        this.spriteDirection = -this.direction;
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 4f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.5f;
                        }
                        else
                        {
                            this.ai[0] += 1.3f;
                        }
                    }
                    else if (this.type == ProjectileID.Spear)
                    {
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 4f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.1f;
                        }
                        else
                        {
                            this.ai[0] += 0.85f;
                        }
                    }
                    else if (this.type == ProjectileID.MythrilHalberd || this.type == ProjectileID.OrichalcumHalberd)
                    {
                        this.spriteDirection = -this.direction;
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.9f;
                        }
                        else
                        {
                            this.ai[0] += 1.7f;
                        }
                    }
                    else if (this.type == ProjectileID.AdamantiteGlaive || this.type == ProjectileID.CobaltNaginata || this.type == ProjectileID.PalladiumPike || this.type == ProjectileID.TitaniumTrident)
                    {
                        this.spriteDirection = -this.direction;
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 2.1f;
                        }
                        else
                        {
                            this.ai[0] += 1.9f;
                        }
                    }
                    else if (this.type == ProjectileID.MushroomSpear)
                    {
                        this.spriteDirection = -this.direction;
                        if (this.ai[0] == 0f)
                        {
                            this.ai[0] = 3f;
                            this.netUpdate = true;
                        }
                        if (Main.player[this.owner].itemAnimation < Main.player[this.owner].itemAnimationMax / 3)
                        {
                            this.ai[0] -= 1.3f;
                        }
                        else
                        {
                            this.ai[0] += 1f;
                        }
                    }
                }
                this.position += this.velocity * this.ai[0];
                if (this.type == ProjectileID.MushroomSpear)
                {
                    if (this.ai[1] == 0f || this.ai[1] == 4f || this.ai[1] == 8f || this.ai[1] == 12f || this.ai[1] == 16f || this.ai[1] == 20f || this.ai[1] == 24f)
                    {
                        Projectile.NewProjectile(this.position.X + (float)(this.width / 2), this.position.Y + (float)(this.height / 2), this.velocity.X, this.velocity.Y, 131, this.damage / 3, 0f, this.owner, 0f, 0f);
                    }
                    this.ai[1] += 1f;
                }
                if (Main.player[this.owner].itemAnimation == 0)
                {
                    this.Kill();
                }
                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 2.355f;
                if (this.spriteDirection == -1)
                {
                    this.rotation -= 1.57f;
                }
                if (this.type == ProjectileID.DarkLance)
                {
                    return;
                }
                if (this.type == ProjectileID.Gungnir)
                {
                    if (Main.rand.Next(4) == 0)
                    {
                        return;
                    }
                }
                else if (this.type == ProjectileID.TheRottedFork)
                {
                    return;
                }
            }
            else if (this.aiStyle == 20)
            {
                if (this.type == ProjectileID.ChlorophyteJackhammer)
                {
                    this.frameCounter++;
                    if (this.frameCounter >= 4)
                    {
                        this.frameCounter = 0;
                        this.frame++;
                    }
                    if (this.frame > 3)
                    {
                        this.frame = 0;
                    }
                }
                if (this.type == ProjectileID.ButchersChainsaw)
                {
                    this.frameCounter++;
                    if (this.frameCounter >= 2)
                    {
                        this.frameCounter = 0;
                        this.frame++;
                    }
                    if (this.frame > 1)
                    {
                        this.frame = 0;
                    }
                }
                if (this.soundDelay <= 0)
                {
                    this.soundDelay = 30;
                }
                Vector2 vector29 = Main.player[this.owner].RotatedRelativePoint(Main.player[this.owner].MountedCenter, true);
                if (Main.myPlayer == this.owner)
                {
                    if (Main.player[this.owner].channel)
                    {
                        float num264 = Main.player[this.owner].inventory[Main.player[this.owner].selectedItem].shootSpeed * this.scale;
                        Vector2 vector30 = vector29;
                        float num265 = (float)Main.mouseX + Main.screenPosition.X - vector30.X;
                        float num266 = (float)Main.mouseY + Main.screenPosition.Y - vector30.Y;
                        if (Main.player[this.owner].gravDir == -1f)
                        {
                            num266 = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector30.Y;
                        }
                        float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266));
                        num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266));
                        num267 = num264 / num267;
                        num265 *= num267;
                        num266 *= num267;
                        if (num265 != this.velocity.X || num266 != this.velocity.Y)
                        {
                            this.netUpdate = true;
                        }
                        this.velocity.X = num265;
                        this.velocity.Y = num266;
                    }
                    else
                    {
                        this.Kill();
                    }
                }
                if (this.velocity.X > 0f)
                {
                    Main.player[this.owner].ChangeDir(1);
                }
                else if (this.velocity.X < 0f)
                {
                    Main.player[this.owner].ChangeDir(-1);
                }
                this.spriteDirection = this.direction;
                Main.player[this.owner].ChangeDir(this.direction);
                Main.player[this.owner].heldProj = this.whoAmI;
                Main.player[this.owner].itemTime = 2;
                Main.player[this.owner].itemAnimation = 2;
                this.position.X = vector29.X - (float)(this.width / 2);
                this.position.Y = vector29.Y - (float)(this.height / 2);
                this.rotation = (float)(Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.5700000524520874);
                if (Main.player[this.owner].direction == 1)
                {
                    Main.player[this.owner].itemRotation = (float)Math.Atan2((double)(this.velocity.Y * (float)this.direction), (double)(this.velocity.X * (float)this.direction));
                }
                else
                {
                    Main.player[this.owner].itemRotation = (float)Math.Atan2((double)(this.velocity.Y * (float)this.direction), (double)(this.velocity.X * (float)this.direction));
                }
                this.velocity.X = this.velocity.X * (1f + (float)Main.rand.Next(-3, 4) * 0.01f);
                if (Main.rand.Next(6) == 0)
                {
                    return;
                }
            }
            else if (this.aiStyle == 21)
            {
                this.rotation = this.velocity.X * 0.1f;
                this.spriteDirection = -this.direction;
                if (this.ai[1] == 1f)
                {
                    this.ai[1] = 0f;
                    Main.harpNote = this.ai[0];
                    return;
                }
            }
            else if (this.aiStyle == 22)
            {
                if (this.velocity.X == 0f && this.velocity.Y == 0f)
                {
                    this.alpha = 255;
                }
                if (this.ai[1] < 0f)
                {
                    if (this.velocity.X > 0f)
                    {
                        this.rotation += 0.3f;
                    }
                    else
                    {
                        this.rotation -= 0.3f;
                    }
                    int num270 = (int)(this.position.X / 16f) - 1;
                    int num271 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                    int num272 = (int)(this.position.Y / 16f) - 1;
                    int num273 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                    if (num270 < 0)
                    {
                        num270 = 0;
                    }
                    if (num271 > Main.maxTilesX)
                    {
                        num271 = Main.maxTilesX;
                    }
                    if (num272 < 0)
                    {
                        num272 = 0;
                    }
                    if (num273 > Main.maxTilesY)
                    {
                        num273 = Main.maxTilesY;
                    }
                    int num274 = (int)this.position.X + 4;
                    int num275 = (int)this.position.Y + 4;
                    for (int num276 = num270; num276 < num271; num276++)
                    {
                        for (int num277 = num272; num277 < num273; num277++)
                        {
                            if (Main.tile[num276, num277] != null && Main.tile[num276, num277].active() && Main.tile[num276, num277].type != TileID.MagicalIceBlock && Main.tileSolid[(int)Main.tile[num276, num277].type] && !Main.tileSolidTop[(int)Main.tile[num276, num277].type])
                            {
                                Vector2 vector31;
                                vector31.X = (float)(num276 * 16);
                                vector31.Y = (float)(num277 * 16);
                                if ((float)(num274 + 8) > vector31.X && (float)num274 < vector31.X + 16f && (float)(num275 + 8) > vector31.Y && (float)num275 < vector31.Y + 16f)
                                {
                                    this.Kill();
                                }
                            }
                        }
                    }
                    return;
                }
                if (this.ai[0] < 0f)
                {
                    int num282 = (int)this.position.X / 16;
                    int num283 = (int)this.position.Y / 16;
                    if (Main.tile[num282, num283] == null || !Main.tile[num282, num283].active())
                    {
                        this.Kill();
                    }
                    this.ai[0] -= 1f;
                    if (this.ai[0] <= -900f && (Main.myPlayer == this.owner || Main.netMode == 2) && Main.tile[num282, num283].active() && Main.tile[num282, num283].type == TileID.MagicalIceBlock)
                    {
                        WorldGen.KillTile(num282, num283, false, false, false);
                        if (Main.netMode == 1)
                        {
                            NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)num282, (float)num283, 0f, 0, 0, 0);
                        }
                        this.Kill();
                        return;
                    }
                }
                else
                {
                    int num284 = (int)(this.position.X / 16f) - 1;
                    int num285 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                    int num286 = (int)(this.position.Y / 16f) - 1;
                    int num287 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                    if (num284 < 0)
                    {
                        num284 = 0;
                    }
                    if (num285 > Main.maxTilesX)
                    {
                        num285 = Main.maxTilesX;
                    }
                    if (num286 < 0)
                    {
                        num286 = 0;
                    }
                    if (num287 > Main.maxTilesY)
                    {
                        num287 = Main.maxTilesY;
                    }
                    int num288 = (int)this.position.X + 4;
                    int num289 = (int)this.position.Y + 4;
                    for (int num290 = num284; num290 < num285; num290++)
                    {
                        for (int num291 = num286; num291 < num287; num291++)
                        {
                            if (Main.tile[num290, num291] != null && Main.tile[num290, num291].nactive() && Main.tile[num290, num291].type != TileID.MagicalIceBlock && Main.tileSolid[(int)Main.tile[num290, num291].type] && !Main.tileSolidTop[(int)Main.tile[num290, num291].type])
                            {
                                Vector2 vector32;
                                vector32.X = (float)(num290 * 16);
                                vector32.Y = (float)(num291 * 16);
                                if ((float)(num288 + 8) > vector32.X && (float)num288 < vector32.X + 16f && (float)(num289 + 8) > vector32.Y && (float)num289 < vector32.Y + 16f)
                                {
                                    this.Kill();
                                }
                            }
                        }
                    }
                    if (this.lavaWet)
                    {
                        this.Kill();
                    }
                    if (this.active)
                    {
                        int num293 = (int)this.ai[0];
                        int num294 = (int)this.ai[1];
                        if (WorldGen.SolidTile(num293, num294))
                        {
                            if (Math.Abs(this.velocity.X) > Math.Abs(this.velocity.Y))
                            {
                                if (base.Center.Y < (float)(num294 * 16 + 8) && !WorldGen.SolidTile(num293, num294 - 1))
                                {
                                    num294--;
                                }
                                else if (!WorldGen.SolidTile(num293, num294 + 1))
                                {
                                    num294++;
                                }
                                else if (!WorldGen.SolidTile(num293, num294 - 1))
                                {
                                    num294--;
                                }
                                else if (base.Center.X < (float)(num293 * 16 + 8) && !WorldGen.SolidTile(num293 - 1, num294))
                                {
                                    num293--;
                                }
                                else if (!WorldGen.SolidTile(num293 + 1, num294))
                                {
                                    num293++;
                                }
                                else if (!WorldGen.SolidTile(num293 - 1, num294))
                                {
                                    num293--;
                                }
                            }
                            else if (base.Center.X < (float)(num293 * 16 + 8) && !WorldGen.SolidTile(num293 - 1, num294))
                            {
                                num293--;
                            }
                            else if (!WorldGen.SolidTile(num293 + 1, num294))
                            {
                                num293++;
                            }
                            else if (!WorldGen.SolidTile(num293 - 1, num294))
                            {
                                num293--;
                            }
                            else if (base.Center.Y < (float)(num294 * 16 + 8) && !WorldGen.SolidTile(num293, num294 - 1))
                            {
                                num294--;
                            }
                            else if (!WorldGen.SolidTile(num293, num294 + 1))
                            {
                                num294++;
                            }
                            else if (!WorldGen.SolidTile(num293, num294 - 1))
                            {
                                num294--;
                            }
                        }
                        if (this.velocity.X > 0f)
                        {
                            this.rotation += 0.3f;
                        }
                        else
                        {
                            this.rotation -= 0.3f;
                        }
                        if (Main.myPlayer == this.owner)
                        {
                            int num295 = (int)((this.position.X + (float)(this.width / 2)) / 16f);
                            int num296 = (int)((this.position.Y + (float)(this.height / 2)) / 16f);
                            bool flag6 = false;
                            if (num295 == num293 && num296 == num294)
                            {
                                flag6 = true;
                            }
                            if (((this.velocity.X <= 0f && num295 <= num293) || (this.velocity.X >= 0f && num295 >= num293)) && ((this.velocity.Y <= 0f && num296 <= num294) || (this.velocity.Y >= 0f && num296 >= num294)))
                            {
                                flag6 = true;
                            }
                            if (flag6)
                            {
                                if (WorldGen.PlaceTile(num293, num294, 127, false, false, this.owner, 0))
                                {
                                    if (Main.netMode == 1)
                                    {
                                        NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 1, (float)((int)this.ai[0]), (float)((int)this.ai[1]), 127f, 0, 0, 0);
                                    }
                                    this.damage = 0;
                                    this.ai[0] = -1f;
                                    this.velocity *= 0f;
                                    this.alpha = 255;
                                    this.position.X = (float)(num293 * 16);
                                    this.position.Y = (float)(num294 * 16);
                                    this.netUpdate = true;
                                    return;
                                }
                                this.ai[1] = -1f;
                                return;
                            }
                        }
                    }
                }
            }
            else
            {
                if (this.aiStyle == 23)
                {
                    if (this.type == ProjectileID.FlamesTrap && this.ai[0] < 8f)
                    {
                        this.ai[0] = 8f;
                    }
                    if (this.timeLeft > 60)
                    {
                        this.timeLeft = 60;
                    }
                    if (this.ai[0] > 7f)
                    {
                        this.ai[0] += 1f;
                    }
                    else
                    {
                        this.ai[0] += 1f;
                    }
                    this.rotation += 0.3f * (float)this.direction;
                    return;
                }
                if (this.aiStyle == 24)
                {
                    this.light = this.scale * 0.5f;
                    this.rotation += this.velocity.X * 0.2f;
                    this.ai[1] += 1f;
                    if (this.type == ProjectileID.CrystalStorm)
                    {
                        this.velocity *= 0.985f;
                        if (this.ai[1] > 130f)
                        {
                            this.scale -= 0.05f;
                            if ((double)this.scale <= 0.2)
                            {
                                this.scale = 0.2f;
                                this.Kill();
                                return;
                            }
                        }
                    }
                    else
                    {
                        this.velocity *= 0.96f;
                        if (this.ai[1] > 15f)
                        {
                            this.scale -= 0.05f;
                            if ((double)this.scale <= 0.2)
                            {
                                this.scale = 0.2f;
                                this.Kill();
                                return;
                            }
                        }
                    }
                }
                else
                {
                    if (this.aiStyle == 25)
                    {
                        if (this.ai[0] != 0f && this.velocity.Y <= 0f && this.velocity.X == 0f)
                        {
                            float num302 = 0.5f;
                            int i2 = (int)((this.position.X - 8f) / 16f);
                            int num303 = (int)(this.position.Y / 16f);
                            bool flag7 = false;
                            bool flag8 = false;
                            if (WorldGen.SolidTile(i2, num303) || WorldGen.SolidTile(i2, num303 + 1))
                            {
                                flag7 = true;
                            }
                            i2 = (int)((this.position.X + (float)this.width + 8f) / 16f);
                            if (WorldGen.SolidTile(i2, num303) || WorldGen.SolidTile(i2, num303 + 1))
                            {
                                flag8 = true;
                            }
                            if (flag7)
                            {
                                this.velocity.X = num302;
                            }
                            else if (flag8)
                            {
                                this.velocity.X = -num302;
                            }
                            else
                            {
                                i2 = (int)((this.position.X - 8f - 16f) / 16f);
                                num303 = (int)(this.position.Y / 16f);
                                flag7 = false;
                                flag8 = false;
                                if (WorldGen.SolidTile(i2, num303) || WorldGen.SolidTile(i2, num303 + 1))
                                {
                                    flag7 = true;
                                }
                                i2 = (int)((this.position.X + (float)this.width + 8f + 16f) / 16f);
                                if (WorldGen.SolidTile(i2, num303) || WorldGen.SolidTile(i2, num303 + 1))
                                {
                                    flag8 = true;
                                }
                                if (flag7)
                                {
                                    this.velocity.X = num302;
                                }
                                else if (flag8)
                                {
                                    this.velocity.X = -num302;
                                }
                                else
                                {
                                    i2 = (int)((this.position.X + 4f) / 16f);
                                    num303 = (int)((this.position.Y + (float)this.height + 8f) / 16f);
                                    if (WorldGen.SolidTile(i2, num303) || WorldGen.SolidTile(i2, num303 + 1))
                                    {
                                        flag7 = true;
                                    }
                                    if (!flag7)
                                    {
                                        this.velocity.X = num302;
                                    }
                                    else
                                    {
                                        this.velocity.X = -num302;
                                    }
                                }
                            }
                        }
                        this.rotation += this.velocity.X * 0.06f;
                        this.ai[0] = 1f;
                        if (this.velocity.Y > 16f)
                        {
                            this.velocity.Y = 16f;
                        }
                        if (this.velocity.Y <= 6f)
                        {
                            if (this.velocity.X > 0f && this.velocity.X < 7f)
                            {
                                this.velocity.X = this.velocity.X + 0.05f;
                            }
                            if (this.velocity.X < 0f && this.velocity.X > -7f)
                            {
                                this.velocity.X = this.velocity.X - 0.05f;
                            }
                        }
                        this.velocity.Y = this.velocity.Y + 0.3f;
                        return;
                    }
                    if (this.aiStyle == 26)
                    {
                        this.AI_026();
                        return;
                    }
                    if (this.aiStyle == 27)
                    {
                        if (this.type == ProjectileID.UnholyTridentHostile)
                        {
                            this.ai[0] += 1f;
                            if (this.ai[0] < 30f)
                            {
                                this.velocity *= 1.125f;
                            }
                        }
                        if (this.type == ProjectileID.UnholyTridentHostile && this.localAI[1] < 5f)
                        {
                            this.localAI[1] = 5f;
                        }
                        if (this.localAI[1] < 15f)
                        {
                            this.localAI[1] += 1f;
                        }
                        else
                        {
                            if (this.localAI[0] == 0f)
                            {
                                this.scale -= 0.02f;
                                this.alpha += 30;
                                if (this.alpha >= 250)
                                {
                                    this.alpha = 255;
                                    this.localAI[0] = 1f;
                                }
                            }
                            else if (this.localAI[0] == 1f)
                            {
                                this.scale += 0.02f;
                                this.alpha -= 30;
                                if (this.alpha <= 0)
                                {
                                    this.alpha = 0;
                                    this.localAI[0] = 0f;
                                }
                            }
                        }
                        if (this.ai[1] == 0f)
                        {
                            this.ai[1] = 1f;
                        }
                        if (this.type == ProjectileID.NightBeam)
                        {
                            this.rotation += (float)this.direction * 0.4f;
                            this.spriteDirection = this.direction;
                        }
                        else
                        {
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 0.785f;
                        }
                        if (this.velocity.Y > 16f)
                        {
                            this.velocity.Y = 16f;
                            return;
                        }
                    }
                    else if (this.aiStyle == 28)
                    {
                        if (this.ai[1] == 0f)
                        {
                            this.ai[1] = 1f;
                            return;
                        }
                    }
                    else if (this.aiStyle == 29)
                    {
                        if (this.type == ProjectileID.NebulaArcanumExplosionShot)
                        {
                            int num323 = (int)this.ai[0];
                            return;
                        }
                        if (this.type == ProjectileID.NebulaArcanumExplosionShotShard)
                        {
                            int num327 = (int)this.ai[0];
                            this.ai[1] += 1f;
                            float num328 = (60f - this.ai[1]) / 60f;
                            if (this.ai[1] > 40f)
                            {
                                this.Kill();
                            }
                            this.velocity.Y = this.velocity.Y + 0.2f;
                            if (this.velocity.Y > 18f)
                            {
                                this.velocity.Y = 18f;
                            }
                            this.velocity.X = this.velocity.X * 0.98f;
                            return;
                        }
                        if (this.type == ProjectileID.CrystalPulse)
                        {
                            return;
                        }
                        if (this.type == ProjectileID.CrystalPulse2)
                        {
                            this.ai[1] += 1f;
                            float num335 = (60f - this.ai[1]) / 60f;
                            if (this.ai[1] > 40f)
                            {
                                this.Kill();
                            }
                            this.velocity.Y = this.velocity.Y + 0.2f;
                            if (this.velocity.Y > 18f)
                            {
                                this.velocity.Y = 18f;
                            }
                            this.velocity.X = this.velocity.X * 0.98f;
                            return;
                        }
                        int num339 = this.type - 121 + 86;
                        if (this.type == ProjectileID.EmberBolt)
                        {
                            num339 = 262;
                        }
                        if (this.ai[1] == 0f)
                        {
                            this.ai[1] = 1f;
                            return;
                        }
                    }
                    else if (this.aiStyle == 30)
                    {
                        this.velocity *= 0.8f;
                        this.rotation += 0.2f;
                        this.alpha += 4;
                        if (this.alpha >= 255)
                        {
                            this.Kill();
                            return;
                        }
                    }
                    else
                    {
                        if (this.aiStyle == 31)
                        {
                            int conversionType = 0;
                            if (this.type == ProjectileID.HallowSpray)
                            {
                                conversionType = 2;
                            }
                            if (this.type == ProjectileID.CorruptSpray)
                            {
                                conversionType = 1;
                            }
                            if (this.type == ProjectileID.MushroomSpray)
                            {
                                conversionType = 3;
                            }
                            if (this.type == ProjectileID.CrimsonSpray)
                            {
                                conversionType = 4;
                            }
                            if (this.owner == Main.myPlayer)
                            {
                                WorldGen.Convert((int)(this.position.X + (float)(this.width / 2)) / 16, (int)(this.position.Y + (float)(this.height / 2)) / 16, conversionType, 2);
                            }
                            if (this.timeLeft > 133)
                            {
                                this.timeLeft = 133;
                            }
                            if (this.ai[0] > 7f)
                            {
                                this.ai[0] += 1f;
                            }
                            else
                            {
                                this.ai[0] += 1f;
                            }
                            this.rotation += 0.3f * (float)this.direction;
                            return;
                        }
                        if (this.aiStyle == 32)
                        {
                            this.timeLeft = 10;
                            this.ai[0] += 1f;
                            if (this.ai[0] >= 20f)
                            {
                                this.ai[0] = 15f;
                                for (int num346 = 0; num346 < 255; num346++)
                                {
                                    Rectangle rectangle5 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                                    if (Main.player[num346].active)
                                    {
                                        Rectangle rectangle6 = new Rectangle((int)Main.player[num346].position.X, (int)Main.player[num346].position.Y, Main.player[num346].width, Main.player[num346].height);
                                        if (rectangle5.Intersects(rectangle6))
                                        {
                                            this.ai[0] = 0f;
                                            this.velocity.Y = -4.5f;
                                            if (this.velocity.X > 2f)
                                            {
                                                this.velocity.X = 2f;
                                            }
                                            if (this.velocity.X < -2f)
                                            {
                                                this.velocity.X = -2f;
                                            }
                                            this.velocity.X = (this.velocity.X + (float)Main.player[num346].direction * 1.75f) / 2f;
                                            this.velocity.X = this.velocity.X + Main.player[num346].velocity.X * 3f;
                                            this.velocity.Y = this.velocity.Y + Main.player[num346].velocity.Y;
                                            if (this.velocity.X > 6f)
                                            {
                                                this.velocity.X = 6f;
                                            }
                                            if (this.velocity.X < -6f)
                                            {
                                                this.velocity.X = -6f;
                                            }
                                            this.netUpdate = true;
                                            this.ai[1] += 1f;
                                        }
                                    }
                                }
                            }
                            if (this.velocity.X == 0f && this.velocity.Y == 0f)
                            {
                                this.Kill();
                            }
                            this.rotation += 0.02f * this.velocity.X;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            else if (this.wet)
                            {
                                this.velocity.X = this.velocity.X * 0.99f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X * 0.995f;
                            }
                            if ((double)this.velocity.X > -0.03 && (double)this.velocity.X < 0.03)
                            {
                                this.velocity.X = 0f;
                            }
                            if (this.wet)
                            {
                                this.ai[1] = 0f;
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.95f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y < -4f)
                                {
                                    this.velocity.Y = -4f;
                                }
                                if (this.velocity.X == 0f)
                                {
                                    this.Kill();
                                }
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y + 0.1f;
                            }
                            if (this.velocity.Y > 10f)
                            {
                                this.velocity.Y = 10f;
                                return;
                            }
                        }
                        else
                        {
                            if (this.aiStyle == 33)
                            {
                                if (this.alpha > 0)
                                {
                                    this.alpha -= 50;
                                    if (this.alpha < 0)
                                    {
                                        this.alpha = 0;
                                    }
                                }
                                float num347 = 4f;
                                float num348 = this.ai[0];
                                float num349 = this.ai[1];
                                if (num348 == 0f && num349 == 0f)
                                {
                                    num348 = 1f;
                                }
                                float num350 = (float)Math.Sqrt((double)(num348 * num348 + num349 * num349));
                                num350 = num347 / num350;
                                num348 *= num350;
                                num349 *= num350;
                                if (this.alpha < 70)
                                {
                                }
                                if (this.localAI[0] == 0f)
                                {
                                    this.ai[0] = this.velocity.X;
                                    this.ai[1] = this.velocity.Y;
                                    this.localAI[1] += 1f;
                                    if (this.localAI[1] >= 30f)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.09f;
                                        this.localAI[1] = 30f;
                                    }
                                }
                                else
                                {
                                    if (!Collision.SolidCollision(this.position, this.width, this.height))
                                    {
                                        this.localAI[0] = 0f;
                                        this.localAI[1] = 30f;
                                    }
                                    this.damage = 0;
                                }
                                if (this.velocity.Y > 16f)
                                {
                                    this.velocity.Y = 16f;
                                }
                                this.rotation = (float)Math.Atan2((double)this.ai[1], (double)this.ai[0]) + 1.57f;
                                return;
                            }
                            if (this.aiStyle == 34)
                            {
                                this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                if (this.ai[1] == 1f)
                                {
                                    this.ai[0] += 1f;
                                    if (this.ai[0] > 2f)
                                    {
                                        return;
                                    }
                                }
                                else
                                {
                                    if (this.type < 415 || this.type > 418)
                                    {
                                        return;
                                    }
                                    this.ai[0] += 1f;
                                    if (this.ai[0] > 4f)
                                    {
                                        return;
                                    }
                                }
                            }
                            else if (this.aiStyle == 35)
                            {
                                this.ai[0] += 1f;
                                if (this.ai[0] > 30f)
                                {
                                    this.velocity.Y = this.velocity.Y + 0.2f;
                                    this.velocity.X = this.velocity.X * 0.985f;
                                    if (this.velocity.Y > 14f)
                                    {
                                        this.velocity.Y = 14f;
                                    }
                                }
                                this.rotation += (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * (float)this.direction * 0.02f;
                                if (this.owner == Main.myPlayer)
                                {
                                    Vector2 vector33 = Collision.TileCollision(this.position, this.velocity, this.width, this.height, true, true, 1);
                                    bool flag9 = false;
                                    if (vector33 != this.velocity)
                                    {
                                        flag9 = true;
                                    }
                                    else
                                    {
                                        int num358 = (int)(base.Center.X + this.velocity.X) / 16;
                                        int num359 = (int)(base.Center.Y + this.velocity.Y) / 16;
                                        if (Main.tile[num358, num359] != null && Main.tile[num358, num359].active() && Main.tile[num358, num359].bottomSlope())
                                        {
                                            flag9 = true;
                                            this.position.Y = (float)(num359 * 16 + 16 + 8);
                                            this.position.X = (float)(num358 * 16 + 8);
                                        }
                                    }
                                    if (flag9)
                                    {
                                        int num360 = 213;
                                        if (this.type == ProjectileID.VineRopeCoil)
                                        {
                                            num360 = 353;
                                        }
                                        if (this.type == ProjectileID.WebRopeCoil)
                                        {
                                            num360 = 366;
                                        }
                                        if (this.type == ProjectileID.SilkRopeCoil)
                                        {
                                            num360 = 365;
                                        }
                                        int num361 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                                        int num362 = (int)(this.position.Y + (float)(this.height / 2)) / 16;
                                        this.position += vector33;
                                        int num363 = 10;
                                        if (Main.tile[num361, num362] != null)
                                        {
                                            while (Main.tile[num361, num362] != null && Main.tile[num361, num362].active())
                                            {
                                                if (!Main.tileRope[(int)Main.tile[num361, num362].type])
                                                {
                                                    break;
                                                }
                                                num362++;
                                            }
                                            while (num363 > 0)
                                            {
                                                num363--;
                                                if (Main.tile[num361, num362] == null)
                                                {
                                                    break;
                                                }
                                                if (Main.tile[num361, num362].active() && (Main.tileCut[(int)Main.tile[num361, num362].type] || Main.tile[num361, num362].type == TileID.Stalactite))
                                                {
                                                    WorldGen.KillTile(num361, num362, false, false, false);
                                                    NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)num361, (float)num362, 0f, 0, 0, 0);
                                                }
                                                if (!Main.tile[num361, num362].active())
                                                {
                                                    WorldGen.PlaceTile(num361, num362, num360, false, false, -1, 0);
                                                    NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 1, (float)num361, (float)num362, (float)num360, 0, 0, 0);
                                                    this.ai[1] += 1f;
                                                }
                                                else
                                                {
                                                    num363 = 0;
                                                }
                                                num362++;
                                            }
                                            this.Kill();
                                            return;
                                        }
                                    }
                                }
                            }
                            else if (this.aiStyle == 36)
                            {
                                if (this.type != ProjectileID.TinyEater && this.wet && !this.honeyWet)
                                {
                                    this.Kill();
                                }
                                if (this.alpha > 0)
                                {
                                    this.alpha -= 50;
                                }
                                else
                                {
                                    this.extraUpdates = 0;
                                }
                                if (this.alpha < 0)
                                {
                                    this.alpha = 0;
                                }
                                if (this.type == ProjectileID.TinyEater)
                                {
                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                    this.frameCounter++;
                                    if (this.frameCounter >= 6)
                                    {
                                        this.frame++;
                                        this.frameCounter = 0;
                                    }
                                    if (this.frame >= 2)
                                    {
                                        this.frame = 0;
                                    }
                                }
                                else
                                {
                                    if (this.type == ProjectileID.Bat)
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.spriteDirection = -1;
                                        }
                                        else if (this.velocity.X < 0f)
                                        {
                                            this.spriteDirection = 1;
                                        }
                                    }
                                    else if (this.velocity.X > 0f)
                                    {
                                        this.spriteDirection = 1;
                                    }
                                    else if (this.velocity.X < 0f)
                                    {
                                        this.spriteDirection = -1;
                                    }
                                    this.rotation = this.velocity.X * 0.1f;
                                    this.frameCounter++;
                                    if (this.frameCounter >= 3)
                                    {
                                        this.frame++;
                                        this.frameCounter = 0;
                                    }
                                    if (this.frame >= 3)
                                    {
                                        this.frame = 0;
                                    }
                                }
                                float num368 = this.position.X;
                                float num369 = this.position.Y;
                                float num370 = 100000f;
                                bool flag10 = false;
                                this.ai[0] += 1f;
                                if (this.ai[0] > 30f)
                                {
                                    this.ai[0] = 30f;
                                    for (int num371 = 0; num371 < 200; num371++)
                                    {
                                        if (Main.npc[num371].CanBeChasedBy(this, false) && (!Main.npc[num371].wet || this.type == ProjectileID.TinyEater))
                                        {
                                            float num372 = Main.npc[num371].position.X + (float)(Main.npc[num371].width / 2);
                                            float num373 = Main.npc[num371].position.Y + (float)(Main.npc[num371].height / 2);
                                            float num374 = Math.Abs(this.position.X + (float)(this.width / 2) - num372) + Math.Abs(this.position.Y + (float)(this.height / 2) - num373);
                                            if (num374 < 800f && num374 < num370 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num371].position, Main.npc[num371].width, Main.npc[num371].height))
                                            {
                                                num370 = num374;
                                                num368 = num372;
                                                num369 = num373;
                                                flag10 = true;
                                            }
                                        }
                                    }
                                }
                                if (!flag10)
                                {
                                    num368 = this.position.X + (float)(this.width / 2) + this.velocity.X * 100f;
                                    num369 = this.position.Y + (float)(this.height / 2) + this.velocity.Y * 100f;
                                }
                                else if (this.type == ProjectileID.TinyEater)
                                {
                                    this.friendly = true;
                                }
                                float num375 = 6f;
                                float num376 = 0.1f;
                                if (this.type == ProjectileID.Wasp)
                                {
                                    num375 = 7f;
                                    num376 = 0.15f;
                                }
                                if (this.type == ProjectileID.TinyEater)
                                {
                                    num375 = 9f;
                                    num376 = 0.2f;
                                }
                                if (this.type == ProjectileID.Bat)
                                {
                                    num375 = 10f;
                                    num376 = 0.25f;
                                }
                                if (this.type == ProjectileID.GiantBee)
                                {
                                    num375 = 6.8f;
                                    num376 = 0.14f;
                                }
                                Vector2 vector34 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num377 = num368 - vector34.X;
                                float num378 = num369 - vector34.Y;
                                float num379 = (float)Math.Sqrt((double)(num377 * num377 + num378 * num378));
                                num379 = num375 / num379;
                                num377 *= num379;
                                num378 *= num379;
                                if (this.velocity.X < num377)
                                {
                                    this.velocity.X = this.velocity.X + num376;
                                    if (this.velocity.X < 0f && num377 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num376 * 2f;
                                    }
                                }
                                else if (this.velocity.X > num377)
                                {
                                    this.velocity.X = this.velocity.X - num376;
                                    if (this.velocity.X > 0f && num377 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num376 * 2f;
                                    }
                                }
                                if (this.velocity.Y < num378)
                                {
                                    this.velocity.Y = this.velocity.Y + num376;
                                    if (this.velocity.Y < 0f && num378 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num376 * 2f;
                                        return;
                                    }
                                }
                                else if (this.velocity.Y > num378)
                                {
                                    this.velocity.Y = this.velocity.Y - num376;
                                    if (this.velocity.Y > 0f && num378 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num376 * 2f;
                                        return;
                                    }
                                }
                            }
                            else if (this.aiStyle == 37)
                            {
                                if (this.ai[1] == 0f)
                                {
                                    this.ai[1] = this.position.Y - 5f;
                                }
                                if (this.ai[0] == 0f)
                                {
                                    if (Collision.SolidCollision(this.position, this.width, this.height))
                                    {
                                        this.velocity.Y = this.velocity.Y * -1f;
                                        this.ai[0] += 1f;
                                        return;
                                    }
                                    float num380 = this.position.Y - this.ai[1];
                                    if (num380 > 300f)
                                    {
                                        this.velocity.Y = this.velocity.Y * -1f;
                                        this.ai[0] += 1f;
                                        return;
                                    }
                                }
                                else if (Collision.SolidCollision(this.position, this.width, this.height) || this.position.Y < this.ai[1])
                                {
                                    this.Kill();
                                    return;
                                }
                            }
                            else if (this.aiStyle == 38)
                            {
                                this.ai[0] += 1f;
                                if (this.ai[0] >= 6f)
                                {
                                    this.ai[0] = 0f;
                                    if (Main.myPlayer == this.owner)
                                    {
                                        Projectile.NewProjectile(this.position.X, this.position.Y, this.velocity.X, this.velocity.Y, 188, this.damage, this.knockBack, this.owner, 0f, 0f);
                                        return;
                                    }
                                }
                            }
                            else if (this.aiStyle == 39)
                            {
                                this.alpha -= 50;
                                if (this.alpha < 0)
                                {
                                    this.alpha = 0;
                                }
                                if (Main.player[this.owner].dead)
                                {
                                    this.Kill();
                                    return;
                                }
                                if (this.alpha == 0)
                                {
                                    Main.player[this.owner].itemAnimation = 5;
                                    Main.player[this.owner].itemTime = 5;
                                    if (this.position.X + (float)(this.width / 2) > Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2))
                                    {
                                        Main.player[this.owner].ChangeDir(1);
                                    }
                                    else
                                    {
                                        Main.player[this.owner].ChangeDir(-1);
                                    }
                                }
                                Vector2 vector35 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num381 = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - vector35.X;
                                float num382 = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - vector35.Y;
                                float num383 = (float)Math.Sqrt((double)(num381 * num381 + num382 * num382));
                                if (!Main.player[this.owner].channel && this.alpha == 0)
                                {
                                    this.ai[0] = 1f;
                                    this.ai[1] = -1f;
                                }
                                if (this.ai[1] > 0f && num383 > 1500f)
                                {
                                    this.ai[1] = 0f;
                                    this.ai[0] = 1f;
                                }
                                if (this.ai[1] > 0f)
                                {
                                    this.tileCollide = false;
                                    int num384 = (int)this.ai[1] - 1;
                                    if (Main.npc[num384].active && Main.npc[num384].life > 0)
                                    {
                                        float num385 = 16f;
                                        vector35 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        num381 = Main.npc[num384].position.X + (float)(Main.npc[num384].width / 2) - vector35.X;
                                        num382 = Main.npc[num384].position.Y + (float)(Main.npc[num384].height / 2) - vector35.Y;
                                        num383 = (float)Math.Sqrt((double)(num381 * num381 + num382 * num382));
                                        if (num383 < num385)
                                        {
                                            this.velocity.X = num381;
                                            this.velocity.Y = num382;
                                            if (num383 > num385 / 2f)
                                            {
                                                if (this.velocity.X < 0f)
                                                {
                                                    this.spriteDirection = -1;
                                                    this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                                }
                                                else
                                                {
                                                    this.spriteDirection = 1;
                                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            num383 = num385 / num383;
                                            num381 *= num383;
                                            num382 *= num383;
                                            this.velocity.X = num381;
                                            this.velocity.Y = num382;
                                            if (this.velocity.X < 0f)
                                            {
                                                this.spriteDirection = -1;
                                                this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                            }
                                            else
                                            {
                                                this.spriteDirection = 1;
                                                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                            }
                                        }
                                        this.ai[0] = 1f;
                                    }
                                    else
                                    {
                                        this.ai[1] = 0f;
                                        float num386 = this.position.X;
                                        float num387 = this.position.Y;
                                        float num388 = 3000f;
                                        int num389 = -1;
                                        for (int num390 = 0; num390 < 200; num390++)
                                        {
                                            if (Main.npc[num390].CanBeChasedBy(this, false))
                                            {
                                                float num391 = Main.npc[num390].position.X + (float)(Main.npc[num390].width / 2);
                                                float num392 = Main.npc[num390].position.Y + (float)(Main.npc[num390].height / 2);
                                                float num393 = Math.Abs(this.position.X + (float)(this.width / 2) - num391) + Math.Abs(this.position.Y + (float)(this.height / 2) - num392);
                                                if (num393 < num388 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num390].position, Main.npc[num390].width, Main.npc[num390].height))
                                                {
                                                    num388 = num393;
                                                    num386 = num391;
                                                    num387 = num392;
                                                    num389 = num390;
                                                }
                                            }
                                        }
                                        if (num389 >= 0)
                                        {
                                            float num394 = 16f;
                                            vector35 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            num381 = num386 - vector35.X;
                                            num382 = num387 - vector35.Y;
                                            num383 = (float)Math.Sqrt((double)(num381 * num381 + num382 * num382));
                                            num383 = num394 / num383;
                                            num381 *= num383;
                                            num382 *= num383;
                                            this.velocity.X = num381;
                                            this.velocity.Y = num382;
                                            this.ai[0] = 0f;
                                            this.ai[1] = (float)(num389 + 1);
                                        }
                                    }
                                }
                                else if (this.ai[0] == 0f)
                                {
                                    if (num383 > 700f)
                                    {
                                        this.ai[0] = 1f;
                                    }
                                    if (this.velocity.X < 0f)
                                    {
                                        this.spriteDirection = -1;
                                        this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                    }
                                    else
                                    {
                                        this.spriteDirection = 1;
                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                    }
                                }
                                else if (this.ai[0] == 1f)
                                {
                                    this.tileCollide = false;
                                    if (this.velocity.X < 0f)
                                    {
                                        this.spriteDirection = 1;
                                        this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                    }
                                    else
                                    {
                                        this.spriteDirection = -1;
                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                    }
                                    if (this.velocity.X < 0f)
                                    {
                                        this.spriteDirection = -1;
                                        this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                    }
                                    else
                                    {
                                        this.spriteDirection = 1;
                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                    }
                                    float num395 = 20f;
                                    if (num383 < 70f)
                                    {
                                        this.Kill();
                                    }
                                    num383 = num395 / num383;
                                    num381 *= num383;
                                    num382 *= num383;
                                    this.velocity.X = num381;
                                    this.velocity.Y = num382;
                                }
                                this.frameCounter++;
                                if (this.frameCounter >= 4)
                                {
                                    this.frame++;
                                    this.frameCounter = 0;
                                }
                                if (this.frame >= 4)
                                {
                                    this.frame = 0;
                                    return;
                                }
                            }
                            else
                            {
                                if (this.aiStyle == 40)
                                {
                                    this.localAI[0] += 1f;
                                    if (this.localAI[0] > 3f)
                                    {
                                        this.localAI[0] = 100f;
                                        this.alpha -= 50;
                                        if (this.alpha < 0)
                                        {
                                            this.alpha = 0;
                                        }
                                    }
                                    this.frameCounter++;
                                    if (this.frameCounter >= 3)
                                    {
                                        this.frame++;
                                        this.frameCounter = 0;
                                    }
                                    if (this.frame >= 5)
                                    {
                                        this.frame = 0;
                                    }
                                    this.velocity.X = this.velocity.X + this.ai[0];
                                    this.velocity.Y = this.velocity.Y + this.ai[1];
                                    this.localAI[1] += 1f;
                                    if (this.localAI[1] == 50f)
                                    {
                                        this.localAI[1] = 51f;
                                        this.ai[0] = (float)Main.rand.Next(-100, 101) * 6E-05f;
                                        this.ai[1] = (float)Main.rand.Next(-100, 101) * 6E-05f;
                                    }
                                    if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) > 16f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.95f;
                                        this.velocity.Y = this.velocity.Y * 0.95f;
                                    }
                                    if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < 12f)
                                    {
                                        this.velocity.X = this.velocity.X * 1.05f;
                                        this.velocity.Y = this.velocity.Y * 1.05f;
                                    }
                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 3.14f;
                                    return;
                                }
                                if (this.aiStyle == 41)
                                {
                                    if (this.localAI[0] == 0f)
                                    {
                                        this.localAI[0] = 1f;
                                        this.frame = Main.rand.Next(3);
                                    }
                                    this.rotation += this.velocity.X * 0.01f;
                                    return;
                                }
                                if (this.aiStyle == 42)
                                {
                                    if (!Main.player[this.owner].crystalLeaf)
                                    {
                                        this.Kill();
                                        return;
                                    }
                                    this.position.X = Main.player[this.owner].Center.X - (float)(this.width / 2);
                                    this.position.Y = Main.player[this.owner].Center.Y - (float)(this.height / 2) + Main.player[this.owner].gfxOffY - 60f;
                                    if (Main.player[this.owner].gravDir == -1f)
                                    {
                                        this.position.Y = this.position.Y + 120f;
                                        this.rotation = 3.14f;
                                    }
                                    else
                                    {
                                        this.rotation = 0f;
                                    }
                                    this.position.X = (float)((int)this.position.X);
                                    this.position.Y = (float)((int)this.position.Y);
                                    float num396 = (float)Main.mouseTextColor / 200f - 0.35f;
                                    num396 *= 0.2f;
                                    this.scale = num396 + 0.95f;
                                    if (this.owner == Main.myPlayer)
                                    {
                                        if (this.ai[0] != 0f)
                                        {
                                            this.ai[0] -= 1f;
                                            return;
                                        }
                                        float num397 = this.position.X;
                                        float num398 = this.position.Y;
                                        float num399 = 700f;
                                        bool flag11 = false;
                                        for (int num400 = 0; num400 < 200; num400++)
                                        {
                                            if (Main.npc[num400].CanBeChasedBy(this, true))
                                            {
                                                float num401 = Main.npc[num400].position.X + (float)(Main.npc[num400].width / 2);
                                                float num402 = Main.npc[num400].position.Y + (float)(Main.npc[num400].height / 2);
                                                float num403 = Math.Abs(this.position.X + (float)(this.width / 2) - num401) + Math.Abs(this.position.Y + (float)(this.height / 2) - num402);
                                                if (num403 < num399 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num400].position, Main.npc[num400].width, Main.npc[num400].height))
                                                {
                                                    num399 = num403;
                                                    num397 = num401;
                                                    num398 = num402;
                                                    flag11 = true;
                                                }
                                            }
                                        }
                                        if (flag11)
                                        {
                                            float num404 = 12f;
                                            Vector2 vector36 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float num405 = num397 - vector36.X;
                                            float num406 = num398 - vector36.Y;
                                            float num407 = (float)Math.Sqrt((double)(num405 * num405 + num406 * num406));
                                            num407 = num404 / num407;
                                            num405 *= num407;
                                            num406 *= num407;
                                            Projectile.NewProjectile(base.Center.X - 4f, base.Center.Y, num405, num406, 227, Player.crystalLeafDamage, (float)Player.crystalLeafKB, this.owner, 0f, 0f);
                                            this.ai[0] = 50f;
                                            return;
                                        }
                                    }
                                }
                                else
                                {
                                    if (this.aiStyle == 43)
                                    {
                                        if (this.localAI[1] == 0f)
                                        {
                                            this.localAI[1] += 1f;
                                        }
                                        this.ai[0] = (float)Main.rand.Next(-100, 101) * 0.0025f;
                                        this.ai[1] = (float)Main.rand.Next(-100, 101) * 0.0025f;
                                        if (this.localAI[0] == 0f)
                                        {
                                            this.scale += 0.05f;
                                            if ((double)this.scale > 1.2)
                                            {
                                                this.localAI[0] = 1f;
                                            }
                                        }
                                        else
                                        {
                                            this.scale -= 0.05f;
                                            if ((double)this.scale < 0.8)
                                            {
                                                this.localAI[0] = 0f;
                                            }
                                        }
                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 3.14f;
                                        return;
                                    }
                                    if (this.aiStyle == 44)
                                    {
                                        if (this.type == ProjectileID.SporeCloud)
                                        {
                                            this.velocity *= 0.96f;
                                            this.alpha += 4;
                                            if (this.alpha > 255)
                                            {
                                                this.Kill();
                                            }
                                        }
                                        else if (this.type == ProjectileID.ChlorophyteOrb)
                                        {
                                            this.ai[0] += 1f;
                                            if (this.ai[0] > 20f)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.3f;
                                                this.velocity.X = this.velocity.X * 0.98f;
                                            }
                                        }
                                        this.frameCounter++;
                                        if (this.frameCounter > 5)
                                        {
                                            this.frame++;
                                            this.frameCounter = 0;
                                        }
                                        if (this.frame >= Main.projFrames[this.type])
                                        {
                                            this.frame = 0;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 45)
                                    {
                                        if (this.type == ProjectileID.RainCloudMoving || this.type == ProjectileID.BloodCloudMoving)
                                        {
                                            float num411 = this.ai[0];
                                            float num412 = this.ai[1];
                                            if (num411 != 0f && num412 != 0f)
                                            {
                                                bool flag12 = false;
                                                bool flag13 = false;
                                                if ((this.velocity.X < 0f && base.Center.X < num411) || (this.velocity.X > 0f && base.Center.X > num411))
                                                {
                                                    flag12 = true;
                                                }
                                                if ((this.velocity.Y < 0f && base.Center.Y < num412) || (this.velocity.Y > 0f && base.Center.Y > num412))
                                                {
                                                    flag13 = true;
                                                }
                                                if (flag12 && flag13)
                                                {
                                                    this.Kill();
                                                }
                                            }
                                            this.rotation += this.velocity.X * 0.02f;
                                            this.frameCounter++;
                                            if (this.frameCounter > 4)
                                            {
                                                this.frameCounter = 0;
                                                this.frame++;
                                                if (this.frame > 3)
                                                {
                                                    this.frame = 0;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.type == ProjectileID.RainCloudRaining || this.type == ProjectileID.BloodCloudRaining)
                                        {
                                            this.frameCounter++;
                                            if (this.frameCounter > 8)
                                            {
                                                this.frameCounter = 0;
                                                this.frame++;
                                                if (this.frame > 5)
                                                {
                                                    this.frame = 0;
                                                }
                                            }
                                            this.ai[1] += 1f;
                                            if (this.type == ProjectileID.BloodCloudRaining && this.ai[1] >= 3600f)
                                            {
                                                this.alpha += 5;
                                                if (this.alpha > 255)
                                                {
                                                    this.alpha = 255;
                                                    this.Kill();
                                                }
                                            }
                                            else if (this.type == ProjectileID.RainCloudRaining && this.ai[1] >= 7200f)
                                            {
                                                this.alpha += 5;
                                                if (this.alpha > 255)
                                                {
                                                    this.alpha = 255;
                                                    this.Kill();
                                                }
                                            }
                                            else
                                            {
                                                this.ai[0] += 1f;
                                                if (this.type == ProjectileID.BloodCloudRaining)
                                                {
                                                    if (this.ai[0] > 10f)
                                                    {
                                                        this.ai[0] = 0f;
                                                        if (this.owner == Main.myPlayer)
                                                        {
                                                            int num413 = (int)(this.position.X + 14f + (float)Main.rand.Next(this.width - 28));
                                                            int num414 = (int)(this.position.Y + (float)this.height + 4f);
                                                            Projectile.NewProjectile((float)num413, (float)num414, 0f, 5f, 245, this.damage, 0f, this.owner, 0f, 0f);
                                                        }
                                                    }
                                                }
                                                else if (this.ai[0] > 8f)
                                                {
                                                    this.ai[0] = 0f;
                                                    if (this.owner == Main.myPlayer)
                                                    {
                                                        int num415 = (int)(this.position.X + 14f + (float)Main.rand.Next(this.width - 28));
                                                        int num416 = (int)(this.position.Y + (float)this.height + 4f);
                                                        Projectile.NewProjectile((float)num415, (float)num416, 0f, 5f, 239, this.damage, 0f, this.owner, 0f, 0f);
                                                    }
                                                }
                                            }
                                            this.localAI[0] += 1f;
                                            if (this.localAI[0] >= 10f)
                                            {
                                                this.localAI[0] = 0f;
                                                int num417 = 0;
                                                int num418 = 0;
                                                float num419 = 0f;
                                                int num420 = this.type;
                                                for (int num421 = 0; num421 < 1000; num421++)
                                                {
                                                    if (Main.projectile[num421].active && Main.projectile[num421].owner == this.owner && Main.projectile[num421].type == num420 && Main.projectile[num421].ai[1] < 3600f)
                                                    {
                                                        num417++;
                                                        if (Main.projectile[num421].ai[1] > num419)
                                                        {
                                                            num418 = num421;
                                                            num419 = Main.projectile[num421].ai[1];
                                                        }
                                                    }
                                                }
                                                if (this.type == ProjectileID.BloodCloudRaining)
                                                {
                                                    if (num417 > 1)
                                                    {
                                                        Main.projectile[num418].netUpdate = true;
                                                        Main.projectile[num418].ai[1] = 36000f;
                                                        return;
                                                    }
                                                }
                                                else if (num417 > 2)
                                                {
                                                    Main.projectile[num418].netUpdate = true;
                                                    Main.projectile[num418].ai[1] = 36000f;
                                                    return;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (this.type == ProjectileID.RainFriendly)
                                            {
                                                this.alpha = 50;
                                                return;
                                            }
                                            if (this.type == ProjectileID.BloodRain)
                                            {
                                                this.alpha = 100;
                                                return;
                                            }
                                            if (this.type == ProjectileID.RainNimbus)
                                            {
                                                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 46)
                                    {
                                        int num422 = 1200;
                                        if (this.type == ProjectileID.RainbowFront)
                                        {
                                            if (this.owner == Main.myPlayer)
                                            {
                                                this.localAI[0] += 1f;
                                                if (this.localAI[0] > 4f)
                                                {
                                                    this.localAI[0] = 3f;
                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, this.velocity.X * 0.001f, this.velocity.Y * 0.001f, 251, this.damage, this.knockBack, this.owner, 0f, 0f);
                                                }
                                                if (this.timeLeft > num422)
                                                {
                                                    this.timeLeft = num422;
                                                }
                                            }
                                            float num423 = 1f;
                                            if (this.velocity.Y < 0f)
                                            {
                                                num423 -= this.velocity.Y / 3f;
                                            }
                                            this.ai[0] += num423;
                                            if (this.ai[0] > 30f)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.5f;
                                                if (this.velocity.Y > 0f)
                                                {
                                                    this.velocity.X = this.velocity.X * 0.95f;
                                                }
                                                else
                                                {
                                                    this.velocity.X = this.velocity.X * 1.05f;
                                                }
                                            }
                                            float num424 = this.velocity.X;
                                            float num425 = this.velocity.Y;
                                            float num426 = (float)Math.Sqrt((double)(num424 * num424 + num425 * num425));
                                            num426 = 15.95f * this.scale / num426;
                                            num424 *= num426;
                                            num425 *= num426;
                                            this.velocity.X = num424;
                                            this.velocity.Y = num425;
                                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                            return;
                                        }
                                        if (this.localAI[0] == 0f)
                                        {
                                            if (this.velocity.X > 0f)
                                            {
                                                this.spriteDirection = -1;
                                                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                            }
                                            else
                                            {
                                                this.spriteDirection = 1;
                                                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                            }
                                            this.localAI[0] = 1f;
                                            this.timeLeft = num422;
                                        }
                                        this.velocity.X = this.velocity.X * 0.98f;
                                        this.velocity.Y = this.velocity.Y * 0.98f;
                                        if (this.rotation == 0f)
                                        {
                                            this.alpha = 255;
                                            return;
                                        }
                                        if (this.timeLeft < 10)
                                        {
                                            this.alpha = 255 - (int)(255f * (float)this.timeLeft / 10f);
                                            return;
                                        }
                                        if (this.timeLeft > num422 - 10)
                                        {
                                            int num427 = num422 - this.timeLeft;
                                            this.alpha = 255 - (int)(255f * (float)num427 / 10f);
                                            return;
                                        }
                                        this.alpha = 0;
                                        return;
                                    }
                                    else if (this.aiStyle == 47)
                                    {
                                        if (this.ai[0] == 0f)
                                        {
                                            this.ai[0] = this.velocity.X;
                                            this.ai[1] = this.velocity.Y;
                                        }
                                        if (this.velocity.X > 0f)
                                        {
                                            this.rotation += (Math.Abs(this.velocity.Y) + Math.Abs(this.velocity.X)) * 0.001f;
                                        }
                                        else
                                        {
                                            this.rotation -= (Math.Abs(this.velocity.Y) + Math.Abs(this.velocity.X)) * 0.001f;
                                        }
                                        this.frameCounter++;
                                        if (this.frameCounter > 6)
                                        {
                                            this.frameCounter = 0;
                                            this.frame++;
                                            if (this.frame > 4)
                                            {
                                                this.frame = 0;
                                            }
                                        }
                                        if (Math.Sqrt((double)(this.velocity.X * this.velocity.X + this.velocity.Y * this.velocity.Y)) > 2.0)
                                        {
                                            this.velocity *= 0.98f;
                                        }
                                        for (int num428 = 0; num428 < 1000; num428++)
                                        {
                                            if (num428 != this.whoAmI && Main.projectile[num428].active && Main.projectile[num428].owner == this.owner && Main.projectile[num428].type == this.type && this.timeLeft > Main.projectile[num428].timeLeft && Main.projectile[num428].timeLeft > 30)
                                            {
                                                Main.projectile[num428].timeLeft = 30;
                                            }
                                        }
                                        int[] array = new int[20];
                                        int num429 = 0;
                                        float num430 = 300f;
                                        bool flag14 = false;
                                        for (int num431 = 0; num431 < 200; num431++)
                                        {
                                            if (Main.npc[num431].CanBeChasedBy(this, false))
                                            {
                                                float num432 = Main.npc[num431].position.X + (float)(Main.npc[num431].width / 2);
                                                float num433 = Main.npc[num431].position.Y + (float)(Main.npc[num431].height / 2);
                                                float num434 = Math.Abs(this.position.X + (float)(this.width / 2) - num432) + Math.Abs(this.position.Y + (float)(this.height / 2) - num433);
                                                if (num434 < num430 && Collision.CanHit(base.Center, 1, 1, Main.npc[num431].Center, 1, 1))
                                                {
                                                    if (num429 < 20)
                                                    {
                                                        array[num429] = num431;
                                                        num429++;
                                                    }
                                                    flag14 = true;
                                                }
                                            }
                                        }
                                        if (this.timeLeft < 30)
                                        {
                                            flag14 = false;
                                        }
                                        if (flag14)
                                        {
                                            int num435 = Main.rand.Next(num429);
                                            num435 = array[num435];
                                            float num436 = Main.npc[num435].position.X + (float)(Main.npc[num435].width / 2);
                                            float num437 = Main.npc[num435].position.Y + (float)(Main.npc[num435].height / 2);
                                            this.localAI[0] += 1f;
                                            if (this.localAI[0] > 8f)
                                            {
                                                this.localAI[0] = 0f;
                                                float num438 = 6f;
                                                Vector2 vector37 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                vector37 += this.velocity * 4f;
                                                float num439 = num436 - vector37.X;
                                                float num440 = num437 - vector37.Y;
                                                float num441 = (float)Math.Sqrt((double)(num439 * num439 + num440 * num440));
                                                num441 = num438 / num441;
                                                num439 *= num441;
                                                num440 *= num441;
                                                Projectile.NewProjectile(vector37.X, vector37.Y, num439, num440, 255, this.damage, this.knockBack, this.owner, 0f, 0f);
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 48)
                                    {
                                        if (this.type == ProjectileID.MagnetSphereBolt)
                                        {
                                            this.alpha = 255;
                                            return;
                                        }
                                        if (this.type == ProjectileID.UFOLaser)
                                        {
                                            this.alpha = 255;
                                            return;
                                        }
                                        if (this.type == ProjectileID.ShadowBeamHostile)
                                        {
                                            this.localAI[0] += 1f;
                                            if (this.localAI[0] > 3f)
                                            {
                                                this.alpha = 255;
                                                return;
                                            }
                                        }
                                        else if (this.type == ProjectileID.ShadowBeamFriendly)
                                        {
                                            this.localAI[0] += 1f;
                                            if (this.localAI[0] > 9f)
                                            {
                                                this.alpha = 255;
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            this.localAI[0] += 1f;
                                            if (this.localAI[0] > 3f)
                                            {
                                                this.alpha = 255;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 49)
                                    {
                                        if (this.ai[1] == 0f)
                                        {
                                            this.ai[1] = 1f;
                                        }
                                        if (this.ai[1] == 1f)
                                        {
                                            if (this.velocity.X > 0f)
                                            {
                                                this.direction = 1;
                                            }
                                            else if (this.velocity.X < 0f)
                                            {
                                                this.direction = -1;
                                            }
                                            this.spriteDirection = this.direction;
                                            this.ai[0] += 1f;
                                            this.rotation += this.velocity.X * 0.05f + (float)this.direction * 0.05f;
                                            if (this.ai[0] >= 18f)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.28f;
                                                this.velocity.X = this.velocity.X * 0.99f;
                                            }
                                            if ((double)this.velocity.Y > 15.9)
                                            {
                                                this.velocity.Y = 15.9f;
                                            }
                                            if (this.ai[0] > 2f)
                                            {
                                                this.alpha = 0;
                                                if (this.ai[0] == 3f)
                                                {
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.ai[1] == 2f)
                                        {
                                            this.rotation = 0f;
                                            this.velocity.X = this.velocity.X * 0.95f;
                                            this.velocity.Y = this.velocity.Y + 0.2f;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 50)
                                    {
                                        if (this.type == ProjectileID.InfernoHostileBolt)
                                        {
                                            if (this.localAI[0] == 0f)
                                            {
                                                this.localAI[0] += 1f;
                                            }
                                            bool flag15 = false;
                                            bool flag16 = false;
                                            if (this.velocity.X < 0f && this.position.X < this.ai[0])
                                            {
                                                flag15 = true;
                                            }
                                            if (this.velocity.X > 0f && this.position.X > this.ai[0])
                                            {
                                                flag15 = true;
                                            }
                                            if (this.velocity.Y < 0f && this.position.Y < this.ai[1])
                                            {
                                                flag16 = true;
                                            }
                                            if (this.velocity.Y > 0f && this.position.Y > this.ai[1])
                                            {
                                                flag16 = true;
                                            }
                                            if (flag15 && flag16)
                                            {
                                                this.Kill();
                                            }
                                            return;
                                        }
                                        if (this.type == ProjectileID.InfernoFriendlyBolt)
                                        {
                                            return;
                                        }
                                        if (this.localAI[0] == 0f)
                                        {
                                            this.localAI[0] += 1f;
                                        }
                                        this.ai[0] += 1f;
                                        if (this.type == ProjectileID.InfernoFriendlyBlast)
                                        {
                                            this.ai[0] += 3f;
                                        }
                                        float num462 = 25f;
                                        if (this.ai[0] > 180f)
                                        {
                                            num462 -= (this.ai[0] - 180f) / 2f;
                                        }
                                        if (num462 <= 0f)
                                        {
                                            num462 = 0f;
                                            this.Kill();
                                        }
                                        if (this.type == ProjectileID.InfernoFriendlyBlast)
                                        {
                                            num462 *= 0.7f;
                                        }
                                        return;
                                    }
                                    else if (this.aiStyle == 51)
                                    {
                                        if (this.type == ProjectileID.LostSoulFriendly)
                                        {
                                            this.localAI[0] += 1f;
                                        }
                                        else
                                        {
                                            if (this.localAI[0] == 0f)
                                            {
                                                this.localAI[0] += 1f;
                                            }
                                        }
                                        float num473 = base.Center.X;
                                        float num474 = base.Center.Y;
                                        float num475 = 400f;
                                        bool flag17 = false;
                                        if (this.type == ProjectileID.LostSoulFriendly)
                                        {
                                            for (int num476 = 0; num476 < 200; num476++)
                                            {
                                                if (Main.npc[num476].CanBeChasedBy(this, false) && Collision.CanHit(base.Center, 1, 1, Main.npc[num476].Center, 1, 1))
                                                {
                                                    float num477 = Main.npc[num476].position.X + (float)(Main.npc[num476].width / 2);
                                                    float num478 = Main.npc[num476].position.Y + (float)(Main.npc[num476].height / 2);
                                                    float num479 = Math.Abs(this.position.X + (float)(this.width / 2) - num477) + Math.Abs(this.position.Y + (float)(this.height / 2) - num478);
                                                    if (num479 < num475)
                                                    {
                                                        num475 = num479;
                                                        num473 = num477;
                                                        num474 = num478;
                                                        flag17 = true;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            num475 = 200f;
                                            for (int num480 = 0; num480 < 255; num480++)
                                            {
                                                if (Main.player[num480].active && !Main.player[num480].dead)
                                                {
                                                    float num481 = Main.player[num480].position.X + (float)(Main.player[num480].width / 2);
                                                    float num482 = Main.player[num480].position.Y + (float)(Main.player[num480].height / 2);
                                                    float num483 = Math.Abs(this.position.X + (float)(this.width / 2) - num481) + Math.Abs(this.position.Y + (float)(this.height / 2) - num482);
                                                    if (num483 < num475)
                                                    {
                                                        num475 = num483;
                                                        num473 = num481;
                                                        num474 = num482;
                                                        flag17 = true;
                                                    }
                                                }
                                            }
                                        }
                                        if (flag17)
                                        {
                                            float num484 = 3f;
                                            if (this.type == ProjectileID.LostSoulFriendly)
                                            {
                                                num484 = 6f;
                                            }
                                            Vector2 vector43 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float num485 = num473 - vector43.X;
                                            float num486 = num474 - vector43.Y;
                                            float num487 = (float)Math.Sqrt((double)(num485 * num485 + num486 * num486));
                                            num487 = num484 / num487;
                                            num485 *= num487;
                                            num486 *= num487;
                                            if (this.type == ProjectileID.LostSoulFriendly)
                                            {
                                                this.velocity.X = (this.velocity.X * 20f + num485) / 21f;
                                                this.velocity.Y = (this.velocity.Y * 20f + num486) / 21f;
                                                return;
                                            }
                                            this.velocity.X = (this.velocity.X * 100f + num485) / 101f;
                                            this.velocity.Y = (this.velocity.Y * 100f + num486) / 101f;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 52)
                                    {
                                        int num488 = (int)this.ai[0];
                                        float num489 = 4f;
                                        Vector2 vector44 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num490 = Main.player[num488].Center.X - vector44.X;
                                        float num491 = Main.player[num488].Center.Y - vector44.Y;
                                        float num492 = (float)Math.Sqrt((double)(num490 * num490 + num491 * num491));
                                        if (num492 < 50f && this.position.X < Main.player[num488].position.X + (float)Main.player[num488].width && this.position.X + (float)this.width > Main.player[num488].position.X && this.position.Y < Main.player[num488].position.Y + (float)Main.player[num488].height && this.position.Y + (float)this.height > Main.player[num488].position.Y)
                                        {
                                            if (this.owner == Main.myPlayer)
                                            {
                                                int num493 = (int)this.ai[1];
                                                Main.player[num488].HealEffect(num493, false);
                                                Main.player[num488].statLife += num493;
                                                if (Main.player[num488].statLife > Main.player[num488].statLifeMax2)
                                                {
                                                    Main.player[num488].statLife = Main.player[num488].statLifeMax2;
                                                }
                                                NetMessage.SendData((int)PacketTypes.PlayerHealOther, -1, -1, "", num488, (float)num493, 0f, 0f, 0, 0, 0);
                                            }
                                            this.Kill();
                                        }
                                        num492 = num489 / num492;
                                        num490 *= num492;
                                        num491 *= num492;
                                        this.velocity.X = (this.velocity.X * 15f + num490) / 16f;
                                        this.velocity.Y = (this.velocity.Y * 15f + num491) / 16f;
                                        if (this.type == ProjectileID.VampireHeal)
                                        {
                                            return;
                                        }
                                        return;
                                    }
                                    else if (this.aiStyle == 53)
                                    {
                                        if (this.localAI[0] == 0f)
                                        {
                                            this.localAI[1] = 1f;
                                            this.localAI[0] = 1f;
                                            this.ai[0] = 120f;
                                            if (this.type == ProjectileID.SpiderHiver)
                                            {
                                                this.frame = 4;
                                            }
                                        }
                                        this.velocity.X = 0f;
                                        this.velocity.Y = this.velocity.Y + 0.2f;
                                        if (this.velocity.Y > 16f)
                                        {
                                            this.velocity.Y = 16f;
                                        }
                                        bool flag18 = false;
                                        float num507 = base.Center.X;
                                        float num508 = base.Center.Y;
                                        float num509 = 1000f;
                                        for (int num510 = 0; num510 < 200; num510++)
                                        {
                                            if (Main.npc[num510].CanBeChasedBy(this, false))
                                            {
                                                float num511 = Main.npc[num510].position.X + (float)(Main.npc[num510].width / 2);
                                                float num512 = Main.npc[num510].position.Y + (float)(Main.npc[num510].height / 2);
                                                float num513 = Math.Abs(this.position.X + (float)(this.width / 2) - num511) + Math.Abs(this.position.Y + (float)(this.height / 2) - num512);
                                                if (num513 < num509 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num510].position, Main.npc[num510].width, Main.npc[num510].height))
                                                {
                                                    num509 = num513;
                                                    num507 = num511;
                                                    num508 = num512;
                                                    flag18 = true;
                                                }
                                            }
                                        }
                                        if (flag18)
                                        {
                                            float num514 = num507;
                                            float num515 = num508;
                                            num507 -= base.Center.X;
                                            num508 -= base.Center.Y;
                                            if (num507 < 0f)
                                            {
                                                this.spriteDirection = -1;
                                            }
                                            else
                                            {
                                                this.spriteDirection = 1;
                                            }
                                            int num516;
                                            if (num508 > 0f)
                                            {
                                                num516 = 0;
                                            }
                                            else if (Math.Abs(num508) > Math.Abs(num507) * 3f)
                                            {
                                                num516 = 4;
                                            }
                                            else if (Math.Abs(num508) > Math.Abs(num507) * 2f)
                                            {
                                                num516 = 3;
                                            }
                                            else if (Math.Abs(num507) > Math.Abs(num508) * 3f)
                                            {
                                                num516 = 0;
                                            }
                                            else if (Math.Abs(num507) > Math.Abs(num508) * 2f)
                                            {
                                                num516 = 1;
                                            }
                                            else
                                            {
                                                num516 = 2;
                                            }
                                            if (this.type == ProjectileID.FrostHydra)
                                            {
                                                this.frame = num516 * 2;
                                            }
                                            else if (this.type == ProjectileID.SpiderHiver)
                                            {
                                                this.frame = num516;
                                            }
                                            if (this.ai[0] > 40f && this.localAI[1] == 0f && this.type == ProjectileID.FrostHydra)
                                            {
                                                this.frame++;
                                            }
                                            if (this.ai[0] <= 0f)
                                            {
                                                this.localAI[1] = 0f;
                                                this.ai[0] = 60f;
                                                if (Main.myPlayer == this.owner)
                                                {
                                                    float num517 = 6f;
                                                    int num518 = 309;
                                                    if (this.type == ProjectileID.SpiderHiver)
                                                    {
                                                        num518 = 378;
                                                        num517 = 9f;
                                                    }
                                                    Vector2 vector45 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                    if (num516 == 0)
                                                    {
                                                        vector45.Y += 12f;
                                                        vector45.X += (float)(24 * this.spriteDirection);
                                                    }
                                                    else if (num516 == 1)
                                                    {
                                                        vector45.Y += 0f;
                                                        vector45.X += (float)(24 * this.spriteDirection);
                                                    }
                                                    else if (num516 == 2)
                                                    {
                                                        vector45.Y -= 2f;
                                                        vector45.X += (float)(24 * this.spriteDirection);
                                                    }
                                                    else if (num516 == 3)
                                                    {
                                                        vector45.Y -= 6f;
                                                        vector45.X += (float)(14 * this.spriteDirection);
                                                    }
                                                    else if (num516 == 4)
                                                    {
                                                        vector45.Y -= 14f;
                                                        vector45.X += (float)(2 * this.spriteDirection);
                                                    }
                                                    if (this.spriteDirection < 0)
                                                    {
                                                        vector45.X += 10f;
                                                    }
                                                    float num519 = num514 - vector45.X;
                                                    float num520 = num515 - vector45.Y;
                                                    float num521 = (float)Math.Sqrt((double)(num519 * num519 + num520 * num520));
                                                    num521 = num517 / num521;
                                                    num519 *= num521;
                                                    num520 *= num521;
                                                    int num522 = this.damage;
                                                    Projectile.NewProjectile(vector45.X, vector45.Y, num519, num520, num518, num522, this.knockBack, Main.myPlayer, 0f, 0f);
                                                }
                                            }
                                        }
                                        else if (this.ai[0] <= 60f && (this.frame == 1 || this.frame == 3 || this.frame == 5 || this.frame == 7 || this.frame == 9))
                                        {
                                            this.frame--;
                                        }
                                        if (this.ai[0] > 0f)
                                        {
                                            this.ai[0] -= 1f;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 54)
                                    {
                                        if (this.type == ProjectileID.Raven)
                                        {
                                            if (Main.player[Main.myPlayer].dead)
                                            {
                                                Main.player[Main.myPlayer].raven = false;
                                            }
                                            if (Main.player[Main.myPlayer].raven)
                                            {
                                                this.timeLeft = 2;
                                            }
                                        }
                                        for (int num523 = 0; num523 < 1000; num523++)
                                        {
                                            if (num523 != this.whoAmI && Main.projectile[num523].active && Main.projectile[num523].owner == this.owner && Main.projectile[num523].type == this.type && Math.Abs(this.position.X - Main.projectile[num523].position.X) + Math.Abs(this.position.Y - Main.projectile[num523].position.Y) < (float)this.width)
                                            {
                                                if (this.position.X < Main.projectile[num523].position.X)
                                                {
                                                    this.velocity.X = this.velocity.X - 0.05f;
                                                }
                                                else
                                                {
                                                    this.velocity.X = this.velocity.X + 0.05f;
                                                }
                                                if (this.position.Y < Main.projectile[num523].position.Y)
                                                {
                                                    this.velocity.Y = this.velocity.Y - 0.05f;
                                                }
                                                else
                                                {
                                                    this.velocity.Y = this.velocity.Y + 0.05f;
                                                }
                                            }
                                        }
                                        float num524 = this.position.X;
                                        float num525 = this.position.Y;
                                        float num526 = 900f;
                                        bool flag19 = false;
                                        int num527 = 500;
                                        if (this.ai[1] != 0f || this.friendly)
                                        {
                                            num527 = 1400;
                                        }
                                        if (Math.Abs(base.Center.X - Main.player[this.owner].Center.X) + Math.Abs(base.Center.Y - Main.player[this.owner].Center.Y) > (float)num527)
                                        {
                                            this.ai[0] = 1f;
                                        }
                                        if (this.ai[0] == 0f)
                                        {
                                            this.tileCollide = true;
                                            for (int num528 = 0; num528 < 200; num528++)
                                            {
                                                if (Main.npc[num528].CanBeChasedBy(this, false))
                                                {
                                                    float num529 = Main.npc[num528].position.X + (float)(Main.npc[num528].width / 2);
                                                    float num530 = Main.npc[num528].position.Y + (float)(Main.npc[num528].height / 2);
                                                    float num531 = Math.Abs(this.position.X + (float)(this.width / 2) - num529) + Math.Abs(this.position.Y + (float)(this.height / 2) - num530);
                                                    if (num531 < num526 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num528].position, Main.npc[num528].width, Main.npc[num528].height))
                                                    {
                                                        num526 = num531;
                                                        num524 = num529;
                                                        num525 = num530;
                                                        flag19 = true;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            this.tileCollide = false;
                                        }
                                        if (!flag19)
                                        {
                                            this.friendly = true;
                                            float num532 = 8f;
                                            if (this.ai[0] == 1f)
                                            {
                                                num532 = 12f;
                                            }
                                            Vector2 vector46 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float num533 = Main.player[this.owner].Center.X - vector46.X;
                                            float num534 = Main.player[this.owner].Center.Y - vector46.Y - 60f;
                                            float num535 = (float)Math.Sqrt((double)(num533 * num533 + num534 * num534));
                                            if (num535 < 100f && this.ai[0] == 1f && !Collision.SolidCollision(this.position, this.width, this.height))
                                            {
                                                this.ai[0] = 0f;
                                            }
                                            if (num535 > 2000f)
                                            {
                                                this.position.X = Main.player[this.owner].Center.X - (float)(this.width / 2);
                                                this.position.Y = Main.player[this.owner].Center.Y - (float)(this.width / 2);
                                            }
                                            if (num535 > 70f)
                                            {
                                                num535 = num532 / num535;
                                                num533 *= num535;
                                                num534 *= num535;
                                                this.velocity.X = (this.velocity.X * 20f + num533) / 21f;
                                                this.velocity.Y = (this.velocity.Y * 20f + num534) / 21f;
                                            }
                                            else
                                            {
                                                if (this.velocity.X == 0f && this.velocity.Y == 0f)
                                                {
                                                    this.velocity.X = -0.15f;
                                                    this.velocity.Y = -0.05f;
                                                }
                                                this.velocity *= 1.01f;
                                            }
                                            this.friendly = false;
                                            this.rotation = this.velocity.X * 0.05f;
                                            this.frameCounter++;
                                            if (this.frameCounter >= 4)
                                            {
                                                this.frameCounter = 0;
                                                this.frame++;
                                            }
                                            if (this.frame > 3)
                                            {
                                                this.frame = 0;
                                            }
                                            if ((double)Math.Abs(this.velocity.X) > 0.2)
                                            {
                                                this.spriteDirection = -this.direction;
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            if (this.ai[1] == -1f)
                                            {
                                                this.ai[1] = 17f;
                                            }
                                            if (this.ai[1] > 0f)
                                            {
                                                this.ai[1] -= 1f;
                                            }
                                            if (this.ai[1] == 0f)
                                            {
                                                this.friendly = true;
                                                float num536 = 8f;
                                                Vector2 vector47 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                float num537 = num524 - vector47.X;
                                                float num538 = num525 - vector47.Y;
                                                float num539 = (float)Math.Sqrt((double)(num537 * num537 + num538 * num538));
                                                if (num539 < 100f)
                                                {
                                                    num536 = 10f;
                                                }
                                                num539 = num536 / num539;
                                                num537 *= num539;
                                                num538 *= num539;
                                                this.velocity.X = (this.velocity.X * 14f + num537) / 15f;
                                                this.velocity.Y = (this.velocity.Y * 14f + num538) / 15f;
                                            }
                                            else
                                            {
                                                this.friendly = false;
                                                if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < 10f)
                                                {
                                                    this.velocity *= 1.05f;
                                                }
                                            }
                                            this.rotation = this.velocity.X * 0.05f;
                                            this.frameCounter++;
                                            if (this.frameCounter >= 4)
                                            {
                                                this.frameCounter = 0;
                                                this.frame++;
                                            }
                                            if (this.frame < 4)
                                            {
                                                this.frame = 4;
                                            }
                                            if (this.frame > 7)
                                            {
                                                this.frame = 4;
                                            }
                                            if ((double)Math.Abs(this.velocity.X) > 0.2)
                                            {
                                                this.spriteDirection = -this.direction;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 55)
                                    {
                                        this.frameCounter++;
                                        if (this.frameCounter > 0)
                                        {
                                            this.frame++;
                                            this.frameCounter = 0;
                                            if (this.frame > 2)
                                            {
                                                this.frame = 0;
                                            }
                                        }
                                        if (this.velocity.X < 0f)
                                        {
                                            this.spriteDirection = -1;
                                            this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                        }
                                        else
                                        {
                                            this.spriteDirection = 1;
                                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                        }
                                        if (this.ai[0] >= 0f && this.ai[0] < 200f)
                                        {
                                            int num540 = (int)this.ai[0];
                                            if (Main.npc[num540].active)
                                            {
                                                float num541 = 8f;
                                                Vector2 vector48 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                float num542 = Main.npc[num540].position.X - vector48.X;
                                                float num543 = Main.npc[num540].position.Y - vector48.Y;
                                                float num544 = (float)Math.Sqrt((double)(num542 * num542 + num543 * num543));
                                                num544 = num541 / num544;
                                                num542 *= num544;
                                                num543 *= num544;
                                                this.velocity.X = (this.velocity.X * 14f + num542) / 15f;
                                                this.velocity.Y = (this.velocity.Y * 14f + num543) / 15f;
                                            }
                                            else
                                            {
                                                float num545 = 1000f;
                                                for (int num546 = 0; num546 < 200; num546++)
                                                {
                                                    if (Main.npc[num546].CanBeChasedBy(this, false))
                                                    {
                                                        float num547 = Main.npc[num546].position.X + (float)(Main.npc[num546].width / 2);
                                                        float num548 = Main.npc[num546].position.Y + (float)(Main.npc[num546].height / 2);
                                                        float num549 = Math.Abs(this.position.X + (float)(this.width / 2) - num547) + Math.Abs(this.position.Y + (float)(this.height / 2) - num548);
                                                        if (num549 < num545 && Collision.CanHit(this.position, this.width, this.height, Main.npc[num546].position, Main.npc[num546].width, Main.npc[num546].height))
                                                        {
                                                            num545 = num549;
                                                            this.ai[0] = (float)num546;
                                                        }
                                                    }
                                                }
                                            }
                                            return;
                                        }
                                        this.Kill();
                                        return;
                                    }
                                    else
                                    {
                                        if (this.aiStyle == 56)
                                        {
                                            if (this.localAI[0] == 0f)
                                            {
                                                this.localAI[0] = 1f;
                                                this.rotation = this.ai[0];
                                                this.spriteDirection = -(int)this.ai[1];
                                            }
                                            if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < 16f)
                                            {
                                                this.velocity *= 1.05f;
                                            }
                                            if (this.velocity.X < 0f)
                                            {
                                                this.direction = -1;
                                            }
                                            else
                                            {
                                                this.direction = 1;
                                            }
                                            this.rotation += (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) * 0.025f * (float)this.direction;
                                            return;
                                        }
                                        if (this.aiStyle == 57)
                                        {
                                            this.ai[0] += 1f;
                                            if (this.ai[0] > 30f)
                                            {
                                                this.ai[0] = 30f;
                                                this.velocity.Y = this.velocity.Y + 0.25f;
                                                if (this.velocity.Y > 16f)
                                                {
                                                    this.velocity.Y = 16f;
                                                }
                                                this.velocity.X = this.velocity.X * 0.995f;
                                            }
                                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                                            this.alpha -= 50;
                                            if (this.alpha < 0)
                                            {
                                                this.alpha = 0;
                                            }
                                            if (this.owner == Main.myPlayer)
                                            {
                                                this.localAI[0] += 1f;
                                                if (this.localAI[0] >= 4f)
                                                {
                                                    this.localAI[0] = 0f;
                                                    int num552 = 0;
                                                    for (int num553 = 0; num553 < 1000; num553++)
                                                    {
                                                        if (Main.projectile[num553].active && Main.projectile[num553].owner == this.owner && Main.projectile[num553].type == ProjectileID.NorthPoleSnowflake)
                                                        {
                                                            num552++;
                                                        }
                                                    }
                                                    float num554 = (float)this.damage * 0.8f;
                                                    if (num552 > 100)
                                                    {
                                                        float num555 = (float)(num552 - 100);
                                                        num555 = 1f - num555 / 100f;
                                                        num554 *= num555;
                                                    }
                                                    if (num552 > 100)
                                                    {
                                                        this.localAI[0] -= 1f;
                                                    }
                                                    if (num552 > 120)
                                                    {
                                                        this.localAI[0] -= 1f;
                                                    }
                                                    if (num552 > 140)
                                                    {
                                                        this.localAI[0] -= 1f;
                                                    }
                                                    if (num552 > 150)
                                                    {
                                                        this.localAI[0] -= 1f;
                                                    }
                                                    if (num552 > 160)
                                                    {
                                                        this.localAI[0] -= 1f;
                                                    }
                                                    if (num552 > 165)
                                                    {
                                                        this.localAI[0] -= 1f;
                                                    }
                                                    if (num552 > 170)
                                                    {
                                                        this.localAI[0] -= 2f;
                                                    }
                                                    if (num552 > 175)
                                                    {
                                                        this.localAI[0] -= 3f;
                                                    }
                                                    if (num552 > 180)
                                                    {
                                                        this.localAI[0] -= 4f;
                                                    }
                                                    if (num552 > 185)
                                                    {
                                                        this.localAI[0] -= 5f;
                                                    }
                                                    if (num552 > 190)
                                                    {
                                                        this.localAI[0] -= 6f;
                                                    }
                                                    if (num552 > 195)
                                                    {
                                                        this.localAI[0] -= 7f;
                                                    }
                                                    if (num554 > (float)this.damage * 0.1f)
                                                    {
                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, 0f, 0f, 344, (int)num554, this.knockBack * 0.55f, this.owner, 0f, (float)Main.rand.Next(3));
                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (this.aiStyle == 58)
                                            {
                                                this.alpha -= 50;
                                                if (this.alpha < 0)
                                                {
                                                    this.alpha = 0;
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.frame = 0;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] > 30f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                                    }
                                                    if (this.velocity.Y >= 0f)
                                                    {
                                                        this.ai[0] = 1f;
                                                    }
                                                }
                                                if (this.ai[0] == 1f)
                                                {
                                                    this.frame = 1;
                                                    this.velocity.Y = this.velocity.Y + 0.1f;
                                                    if (this.velocity.Y > 3f)
                                                    {
                                                        this.velocity.Y = 3f;
                                                    }
                                                    this.velocity.X = this.velocity.X * 0.99f;
                                                }
                                                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                                                return;
                                            }
                                            if (this.aiStyle == 59)
                                            {
                                                this.ai[1] += 1f;
                                                if (this.ai[1] >= 60f)
                                                {
                                                    this.friendly = true;
                                                    int num556 = (int)this.ai[0];
                                                    if (!Main.npc[num556].active)
                                                    {
                                                        int[] array2 = new int[200];
                                                        int num557 = 0;
                                                        for (int num558 = 0; num558 < 200; num558++)
                                                        {
                                                            if (Main.npc[num558].CanBeChasedBy(this, false))
                                                            {
                                                                float num559 = Math.Abs(Main.npc[num558].position.X + (float)(Main.npc[num558].width / 2) - this.position.X + (float)(this.width / 2)) + Math.Abs(Main.npc[num558].position.Y + (float)(Main.npc[num558].height / 2) - this.position.Y + (float)(this.height / 2));
                                                                if (num559 < 800f)
                                                                {
                                                                    array2[num557] = num558;
                                                                    num557++;
                                                                }
                                                            }
                                                        }
                                                        if (num557 == 0)
                                                        {
                                                            this.Kill();
                                                            return;
                                                        }
                                                        num556 = array2[Main.rand.Next(num557)];
                                                        this.ai[0] = (float)num556;
                                                    }
                                                    float num560 = 4f;
                                                    Vector2 vector49 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                    float num561 = Main.npc[num556].Center.X - vector49.X;
                                                    float num562 = Main.npc[num556].Center.Y - vector49.Y;
                                                    float num563 = (float)Math.Sqrt((double)(num561 * num561 + num562 * num562));
                                                    num563 = num560 / num563;
                                                    num561 *= num563;
                                                    num562 *= num563;
                                                    int num564 = 30;
                                                    this.velocity.X = (this.velocity.X * (float)(num564 - 1) + num561) / (float)num564;
                                                    this.velocity.Y = (this.velocity.Y * (float)(num564 - 1) + num562) / (float)num564;
                                                }
                                                return;
                                            }
                                            if (this.aiStyle == 60)
                                            {
                                                this.scale -= 0.015f;
                                                if (this.scale <= 0f)
                                                {
                                                    this.velocity *= 5f;
                                                    this.oldVelocity = this.velocity;
                                                    this.Kill();
                                                }
                                                if (this.ai[0] <= 3f)
                                                {
                                                    this.ai[0] += 1f;
                                                    return;
                                                }
                                                int num569 = 103;
                                                if (this.type == ProjectileID.SlimeGun)
                                                {
                                                    num569 = 137;
                                                }
                                                if (this.owner == Main.myPlayer)
                                                {
                                                    Rectangle rectangle7 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                                                    for (int num570 = 0; num570 < 200; num570++)
                                                    {
                                                        if (Main.npc[num570].active && !Main.npc[num570].dontTakeDamage && Main.npc[num570].lifeMax > 1)
                                                        {
                                                            Rectangle rectangle8 = new Rectangle((int)Main.npc[num570].position.X, (int)Main.npc[num570].position.Y, Main.npc[num570].width, Main.npc[num570].height);
                                                            if (rectangle7.Intersects(rectangle8))
                                                            {
                                                                Main.npc[num570].AddBuff(num569, 1500, false);
                                                                this.Kill();
                                                            }
                                                        }
                                                    }
                                                    for (int num571 = 0; num571 < 255; num571++)
                                                    {
                                                        if (num571 != this.owner && Main.player[num571].active && !Main.player[num571].dead)
                                                        {
                                                            Rectangle rectangle9 = new Rectangle((int)Main.player[num571].position.X, (int)Main.player[num571].position.Y, Main.player[num571].width, Main.player[num571].height);
                                                            if (rectangle7.Intersects(rectangle9))
                                                            {
                                                                Main.player[num571].AddBuff(num569, 1500, false);
                                                                this.Kill();
                                                            }
                                                        }
                                                    }
                                                }
                                                this.ai[0] += this.ai[1];
                                                if (this.ai[0] > 30f)
                                                {
                                                    this.velocity.Y = this.velocity.Y + 0.1f;
                                                }
                                            }
                                            else if (this.aiStyle == 61)
                                            {
                                                this.timeLeft = 60;
                                                if (Main.player[this.owner].inventory[Main.player[this.owner].selectedItem].fishingPole == 0 || Main.player[this.owner].CCed || Main.player[this.owner].noItems)
                                                {
                                                    this.Kill();
                                                }
                                                else if (Main.player[this.owner].inventory[Main.player[this.owner].selectedItem].shoot != this.type)
                                                {
                                                    this.Kill();
                                                }
                                                else if (Main.player[this.owner].pulley)
                                                {
                                                    this.Kill();
                                                }
                                                else if (Main.player[this.owner].dead)
                                                {
                                                    this.Kill();
                                                }
                                                if (this.ai[1] > 0f && this.localAI[1] >= 0f)
                                                {
                                                    this.localAI[1] = -1f;
                                                }
                                                if (this.ai[0] >= 1f)
                                                {
                                                    if (this.ai[0] == 2f)
                                                    {
                                                        this.ai[0] += 1f;
                                                    }
                                                    if (this.localAI[0] < 100f)
                                                    {
                                                        this.localAI[0] += 1f;
                                                    }
                                                    this.tileCollide = false;
                                                    float num590 = 15.9f;
                                                    int num591 = 10;
                                                    Vector2 vector51 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                    float num592 = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - vector51.X;
                                                    float num593 = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - vector51.Y;
                                                    float num594 = (float)Math.Sqrt((double)(num592 * num592 + num593 * num593));
                                                    if (num594 > 3000f)
                                                    {
                                                        this.Kill();
                                                    }
                                                    num594 = num590 / num594;
                                                    num592 *= num594;
                                                    num593 *= num594;
                                                    this.velocity.X = (this.velocity.X * (float)(num591 - 1) + num592) / (float)num591;
                                                    this.velocity.Y = (this.velocity.Y * (float)(num591 - 1) + num593) / (float)num591;
                                                    if (Main.myPlayer == this.owner)
                                                    {
                                                        Rectangle rectangle10 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                                                        Rectangle rectangle11 = new Rectangle((int)Main.player[this.owner].position.X, (int)Main.player[this.owner].position.Y, Main.player[this.owner].width, Main.player[this.owner].height);
                                                        if (rectangle10.Intersects(rectangle11))
                                                        {
                                                            if (this.ai[1] > 0f && this.ai[1] < 3602f)
                                                            {
                                                                int num595 = (int)this.ai[1];
                                                                Item item = new Item();
                                                                item.SetDefaults(num595, false);
                                                                if (num595 == 3196)
                                                                {
                                                                    int num596 = Main.player[this.owner].FishingLevel();
                                                                    int minValue = (num596 / 20 + 3) / 2;
                                                                    int num597 = (num596 / 10 + 6) / 2;
                                                                    if (Main.rand.Next(50) < num596)
                                                                    {
                                                                        num597++;
                                                                    }
                                                                    if (Main.rand.Next(100) < num596)
                                                                    {
                                                                        num597++;
                                                                    }
                                                                    if (Main.rand.Next(150) < num596)
                                                                    {
                                                                        num597++;
                                                                    }
                                                                    if (Main.rand.Next(200) < num596)
                                                                    {
                                                                        num597++;
                                                                    }
                                                                    int stack = Main.rand.Next(minValue, num597 + 1);
                                                                    item.stack = stack;
                                                                }
                                                                if (num595 == 3197)
                                                                {
                                                                    int num598 = Main.player[this.owner].FishingLevel();
                                                                    int minValue2 = (num598 / 4 + 15) / 2;
                                                                    int num599 = (num598 / 2 + 30) / 2;
                                                                    if (Main.rand.Next(50) < num598)
                                                                    {
                                                                        num599 += 4;
                                                                    }
                                                                    if (Main.rand.Next(100) < num598)
                                                                    {
                                                                        num599 += 4;
                                                                    }
                                                                    if (Main.rand.Next(150) < num598)
                                                                    {
                                                                        num599 += 4;
                                                                    }
                                                                    if (Main.rand.Next(200) < num598)
                                                                    {
                                                                        num599 += 4;
                                                                    }
                                                                    int stack2 = Main.rand.Next(minValue2, num599 + 1);
                                                                    item.stack = stack2;
                                                                }
                                                                Item item2 = Main.player[this.owner].GetItem(this.owner, item, false, false);
                                                                if (item2.stack > 0)
                                                                {
                                                                    int number2 = Item.NewItem((int)this.position.X, (int)this.position.Y, this.width, this.height, num595, 1, false, 0, true);
                                                                    if (Main.netMode == 1)
                                                                    {
                                                                        NetMessage.SendData((int)PacketTypes.ItemDrop, -1, -1, "", number2, 1f, 0f, 0f, 0, 0, 0);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    item.position.X = base.Center.X - (float)(item.width / 2);
                                                                    item.position.Y = base.Center.Y - (float)(item.height / 2);
                                                                    item.active = true;
                                                                    ItemText.NewText(item, 0, false, false);
                                                                }
                                                            }
                                                            this.Kill();
                                                        }
                                                    }
                                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                                                    return;
                                                }
                                                bool flag20 = false;
                                                Vector2 vector52 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                float num600 = Main.player[this.owner].position.X + (float)(Main.player[this.owner].width / 2) - vector52.X;
                                                float num601 = Main.player[this.owner].position.Y + (float)(Main.player[this.owner].height / 2) - vector52.Y;
                                                this.rotation = (float)Math.Atan2((double)num601, (double)num600) + 1.57f;
                                                float num602 = (float)Math.Sqrt((double)(num600 * num600 + num601 * num601));
                                                if (num602 > 900f)
                                                {
                                                    this.ai[0] = 1f;
                                                }
                                                if (this.wet)
                                                {
                                                    this.rotation = 0f;
                                                    this.velocity.X = this.velocity.X * 0.9f;
                                                    int num603 = (int)(base.Center.X + (float)((this.width / 2 + 8) * this.direction)) / 16;
                                                    int num604 = (int)(base.Center.Y / 16f);
                                                    float arg_18826_0 = this.position.Y / 16f;
                                                    int num605 = (int)((this.position.Y + (float)this.height) / 16f);
                                                    if (Main.tile[num603, num604] == null)
                                                    {
                                                        Main.tile[num603, num604] = new Tile();
                                                    }
                                                    if (Main.tile[num603, num605] == null)
                                                    {
                                                        Main.tile[num603, num605] = new Tile();
                                                    }
                                                    if (this.velocity.Y > 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.5f;
                                                    }
                                                    num603 = (int)(base.Center.X / 16f);
                                                    num604 = (int)(base.Center.Y / 16f);
                                                    float num606 = this.position.Y + (float)this.height;
                                                    if (Main.tile[num603, num604 - 1] == null)
                                                    {
                                                        Main.tile[num603, num604 - 1] = new Tile();
                                                    }
                                                    if (Main.tile[num603, num604] == null)
                                                    {
                                                        Main.tile[num603, num604] = new Tile();
                                                    }
                                                    if (Main.tile[num603, num604 + 1] == null)
                                                    {
                                                        Main.tile[num603, num604 + 1] = new Tile();
                                                    }
                                                    if (Main.tile[num603, num604 - 1].liquid > 0)
                                                    {
                                                        num606 = (float)(num604 * 16);
                                                        num606 -= (float)(Main.tile[num603, num604 - 1].liquid / 16);
                                                    }
                                                    else if (Main.tile[num603, num604].liquid > 0)
                                                    {
                                                        num606 = (float)((num604 + 1) * 16);
                                                        num606 -= (float)(Main.tile[num603, num604].liquid / 16);
                                                    }
                                                    else if (Main.tile[num603, num604 + 1].liquid > 0)
                                                    {
                                                        num606 = (float)((num604 + 2) * 16);
                                                        num606 -= (float)(Main.tile[num603, num604 + 1].liquid / 16);
                                                    }
                                                    if (base.Center.Y > num606)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - 0.1f;
                                                        if (this.velocity.Y < -8f)
                                                        {
                                                            this.velocity.Y = -8f;
                                                        }
                                                        if (base.Center.Y + this.velocity.Y < num606)
                                                        {
                                                            this.velocity.Y = num606 - base.Center.Y;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.velocity.Y = num606 - base.Center.Y;
                                                    }
                                                    if ((double)this.velocity.Y >= -0.01 && (double)this.velocity.Y <= 0.01)
                                                    {
                                                        flag20 = true;
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.velocity.Y == 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X * 0.95f;
                                                    }
                                                    this.velocity.X = this.velocity.X * 0.98f;
                                                    this.velocity.Y = this.velocity.Y + 0.2f;
                                                    if (this.velocity.Y > 15.9f)
                                                    {
                                                        this.velocity.Y = 15.9f;
                                                    }
                                                }
                                                if (this.ai[1] != 0f)
                                                {
                                                    flag20 = true;
                                                }
                                                if (flag20)
                                                {
                                                    if (this.ai[1] == 0f && Main.myPlayer == this.owner)
                                                    {
                                                        int num607 = Main.player[this.owner].FishingLevel();
                                                        if (num607 == -9000)
                                                        {
                                                            this.localAI[1] += 5f;
                                                            this.localAI[1] += (float)Main.rand.Next(1, 3);
                                                            if (this.localAI[1] > 660f)
                                                            {
                                                                this.localAI[1] = 0f;
                                                                this.FishingCheck();
                                                                return;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (Main.rand.Next(300) < num607)
                                                            {
                                                                this.localAI[1] += (float)Main.rand.Next(1, 3);
                                                            }
                                                            this.localAI[1] += (float)(num607 / 30);
                                                            this.localAI[1] += (float)Main.rand.Next(1, 3);
                                                            if (Main.rand.Next(60) == 0)
                                                            {
                                                                this.localAI[1] += 60f;
                                                            }
                                                            if (this.localAI[1] > 660f)
                                                            {
                                                                this.localAI[1] = 0f;
                                                                this.FishingCheck();
                                                                return;
                                                            }
                                                        }
                                                    }
                                                    else if (this.ai[1] < 0f)
                                                    {
                                                        if (this.velocity.Y == 0f || (this.honeyWet && (double)this.velocity.Y >= -0.01 && (double)this.velocity.Y <= 0.01))
                                                        {
                                                            this.velocity.Y = (float)Main.rand.Next(100, 500) * 0.015f;
                                                            this.velocity.X = (float)Main.rand.Next(-100, 101) * 0.015f;
                                                            this.wet = false;
                                                            this.lavaWet = false;
                                                            this.honeyWet = false;
                                                        }
                                                        this.ai[1] += (float)Main.rand.Next(1, 5);
                                                        if (this.ai[1] >= 0f)
                                                        {
                                                            this.ai[1] = 0f;
                                                            this.localAI[1] = 0f;
                                                            this.netUpdate = true;
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (this.aiStyle == 62)
                                                {
                                                    this.AI_062();
                                                    return;
                                                }
                                                if (this.aiStyle == 63)
                                                {
                                                    if (!Main.player[this.owner].active)
                                                    {
                                                        this.active = false;
                                                        return;
                                                    }
                                                    Vector2 vector53 = this.position;
                                                    bool flag21 = false;
                                                    float num608 = 500f;
                                                    for (int num609 = 0; num609 < 200; num609++)
                                                    {
                                                        NPC nPC = Main.npc[num609];
                                                        if (nPC.CanBeChasedBy(this, false))
                                                        {
                                                            float num610 = Vector2.Distance(nPC.Center, base.Center);
                                                            if (((Vector2.Distance(base.Center, vector53) > num610 && num610 < num608) || !flag21) && Collision.CanHit(this.position, this.width, this.height, nPC.position, nPC.width, nPC.height))
                                                            {
                                                                num608 = num610;
                                                                vector53 = nPC.Center;
                                                                flag21 = true;
                                                            }
                                                        }
                                                    }
                                                    if (!flag21)
                                                    {
                                                        this.velocity.X = this.velocity.X * 0.95f;
                                                    }
                                                    else
                                                    {
                                                        float num611 = 5f;
                                                        float num612 = 0.08f;
                                                        if (this.velocity.Y == 0f)
                                                        {
                                                            bool flag22 = false;
                                                            if (base.Center.Y - 50f > vector53.Y)
                                                            {
                                                                flag22 = true;
                                                            }
                                                            if (flag22)
                                                            {
                                                                this.velocity.Y = -6f;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            num611 = 8f;
                                                            num612 = 0.12f;
                                                        }
                                                        this.velocity.X = this.velocity.X + (float)Math.Sign(vector53.X - base.Center.X) * num612;
                                                        if (this.velocity.X < -num611)
                                                        {
                                                            this.velocity.X = -num611;
                                                        }
                                                        if (this.velocity.X > num611)
                                                        {
                                                            this.velocity.X = num611;
                                                        }
                                                    }
                                                    float num613 = 0f;
                                                    Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref num613, ref this.gfxOffY, 1, false, 0);
                                                    if (this.velocity.Y != 0f)
                                                    {
                                                        this.frame = 3;
                                                    }
                                                    else
                                                    {
                                                        if (Math.Abs(this.velocity.X) > 0.2f)
                                                        {
                                                            this.frameCounter++;
                                                        }
                                                        if (this.frameCounter >= 9)
                                                        {
                                                            this.frameCounter = 0;
                                                        }
                                                        if (this.frameCounter >= 6)
                                                        {
                                                            this.frame = 2;
                                                        }
                                                        else if (this.frameCounter >= 3)
                                                        {
                                                            this.frame = 1;
                                                        }
                                                        else
                                                        {
                                                            this.frame = 0;
                                                        }
                                                    }
                                                    if (this.velocity.X != 0f)
                                                    {
                                                        this.direction = Math.Sign(this.velocity.X);
                                                    }
                                                    this.spriteDirection = -this.direction;
                                                    this.velocity.Y = this.velocity.Y + 0.2f;
                                                    if (this.velocity.Y > 16f)
                                                    {
                                                        this.velocity.Y = 16f;
                                                        return;
                                                    }
                                                }
                                                else if (this.aiStyle == 64)
                                                {
                                                    int num614 = 10;
                                                    int num615 = 15;
                                                    float num616 = 1f;
                                                    int num617 = 150;
                                                    int num618 = 42;
                                                    if (this.type == ProjectileID.Cthulunado)
                                                    {
                                                        num614 = 16;
                                                        num615 = 16;
                                                        num616 = 1.5f;
                                                    }
                                                    if (this.velocity.X != 0f)
                                                    {
                                                        this.direction = (this.spriteDirection = -Math.Sign(this.velocity.X));
                                                    }
                                                    this.frameCounter++;
                                                    if (this.frameCounter > 2)
                                                    {
                                                        this.frame++;
                                                        this.frameCounter = 0;
                                                    }
                                                    if (this.frame >= 6)
                                                    {
                                                        this.frame = 0;
                                                    }
                                                    if (this.localAI[0] == 0f && Main.myPlayer == this.owner)
                                                    {
                                                        this.localAI[0] = 1f;
                                                        this.position.X = this.position.X + (float)(this.width / 2);
                                                        this.position.Y = this.position.Y + (float)(this.height / 2);
                                                        this.scale = ((float)(num614 + num615) - this.ai[1]) * num616 / (float)(num615 + num614);
                                                        this.width = (int)((float)num617 * this.scale);
                                                        this.height = (int)((float)num618 * this.scale);
                                                        this.position.X = this.position.X - (float)(this.width / 2);
                                                        this.position.Y = this.position.Y - (float)(this.height / 2);
                                                        this.netUpdate = true;
                                                    }
                                                    if (this.ai[1] != -1f)
                                                    {
                                                        this.scale = ((float)(num614 + num615) - this.ai[1]) * num616 / (float)(num615 + num614);
                                                        this.width = (int)((float)num617 * this.scale);
                                                        this.height = (int)((float)num618 * this.scale);
                                                    }
                                                    if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        this.alpha -= 30;
                                                        if (this.alpha < 60)
                                                        {
                                                            this.alpha = 60;
                                                        }
                                                        if (this.type == ProjectileID.Cthulunado && this.alpha < 100)
                                                        {
                                                            this.alpha = 100;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.alpha += 30;
                                                        if (this.alpha > 150)
                                                        {
                                                            this.alpha = 150;
                                                        }
                                                    }
                                                    if (this.ai[0] > 0f)
                                                    {
                                                        this.ai[0] -= 1f;
                                                    }
                                                    if (this.ai[0] == 1f && this.ai[1] > 0f && this.owner == Main.myPlayer)
                                                    {
                                                        this.netUpdate = true;
                                                        Vector2 center = base.Center;
                                                        center.Y -= (float)num618 * this.scale / 2f;
                                                        float num619 = ((float)(num614 + num615) - this.ai[1] + 1f) * num616 / (float)(num615 + num614);
                                                        center.Y -= (float)num618 * num619 / 2f;
                                                        center.Y += 2f;
                                                        Projectile.NewProjectile(center.X, center.Y, this.velocity.X, this.velocity.Y, this.type, this.damage, this.knockBack, this.owner, 10f, this.ai[1] - 1f);
                                                        int num620 = 4;
                                                        if (this.type == ProjectileID.Cthulunado)
                                                        {
                                                            num620 = 2;
                                                        }
                                                        if ((int)this.ai[1] % num620 == 0 && this.ai[1] != 0f)
                                                        {
                                                            int num621 = 372;
                                                            if (this.type == ProjectileID.Cthulunado)
                                                            {
                                                                num621 = 373;
                                                            }
                                                            int num622 = NPC.NewNPC((int)center.X, (int)center.Y, num621, 0, 0f, 0f, 0f, 0f, 255);
                                                            Main.npc[num622].velocity = this.velocity;
                                                            Main.npc[num622].netUpdate = true;
                                                            if (this.type == ProjectileID.Cthulunado)
                                                            {
                                                                Main.npc[num622].ai[2] = (float)this.width;
                                                                Main.npc[num622].ai[3] = -1.5f;
                                                            }
                                                        }
                                                    }
                                                    if (this.ai[0] <= 0f)
                                                    {
                                                        float num623 = 0.104719758f;
                                                        float num624 = (float)this.width / 5f;
                                                        if (this.type == ProjectileID.Cthulunado)
                                                        {
                                                            num624 *= 2f;
                                                        }
                                                        float num625 = (float)(Math.Cos((double)(num623 * -(double)this.ai[0])) - 0.5) * num624;
                                                        this.position.X = this.position.X - num625 * (float)(-(float)this.direction);
                                                        this.ai[0] -= 1f;
                                                        num625 = (float)(Math.Cos((double)(num623 * -(double)this.ai[0])) - 0.5) * num624;
                                                        this.position.X = this.position.X + num625 * (float)(-(float)this.direction);
                                                        return;
                                                    }
                                                }
                                                else if (this.aiStyle == 65)
                                                {
                                                    if (this.ai[1] > 0f)
                                                    {
                                                        int num626 = (int)this.ai[1] - 1;
                                                        if (num626 < 255)
                                                        {
                                                            this.localAI[0] += 1f;
                                                            if (this.localAI[0] > 10f)
                                                            {
                                                                this.alpha -= 5;
                                                                if (this.alpha < 100)
                                                                {
                                                                    this.alpha = 100;
                                                                }
                                                                this.rotation += this.velocity.X * 0.1f;
                                                                this.frame = (int)(this.localAI[0] / 3f) % 3;
                                                            }
                                                            Vector2 vector56 = Main.player[num626].Center - base.Center;
                                                            float num630 = 4f;
                                                            num630 += this.localAI[0] / 20f;
                                                            this.velocity = Vector2.Normalize(vector56) * num630;
                                                            if (vector56.Length() < 50f)
                                                            {
                                                                this.Kill();
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        float num631 = 0.209439516f;
                                                        float num632 = 4f;
                                                        float num633 = (float)(Math.Cos((double)(num631 * this.ai[0])) - 0.5) * num632;
                                                        this.velocity.Y = this.velocity.Y - num633;
                                                        this.ai[0] += 1f;
                                                        num633 = (float)(Math.Cos((double)(num631 * this.ai[0])) - 0.5) * num632;
                                                        this.velocity.Y = this.velocity.Y + num633;
                                                        this.localAI[0] += 1f;
                                                        if (this.localAI[0] > 10f)
                                                        {
                                                            this.alpha -= 5;
                                                            if (this.alpha < 100)
                                                            {
                                                                this.alpha = 100;
                                                            }
                                                            this.rotation += this.velocity.X * 0.1f;
                                                            this.frame = (int)(this.localAI[0] / 3f) % 3;
                                                        }
                                                    }
                                                    if (this.wet)
                                                    {
                                                        this.position.Y = this.position.Y - 16f;
                                                        this.Kill();
                                                        return;
                                                    }
                                                }
                                                else if (this.aiStyle == 66)
                                                {
                                                    float num634 = 0f;
                                                    float num635 = 0f;
                                                    float num636 = 0f;
                                                    float num637 = 0f;
                                                    if (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini)
                                                    {
                                                        num634 = 700f;
                                                        num635 = 800f;
                                                        num636 = 1200f;
                                                        num637 = 150f;
                                                        if (Main.player[this.owner].dead)
                                                        {
                                                            Main.player[this.owner].twinsMinion = false;
                                                        }
                                                        if (Main.player[this.owner].twinsMinion)
                                                        {
                                                            this.timeLeft = 2;
                                                        }
                                                    }
                                                    if (this.type == ProjectileID.DeadlySphere)
                                                    {
                                                        num634 = 1500f;
                                                        num635 = 900f;
                                                        num636 = 1500f;
                                                        num637 = 450f;
                                                        if (Main.player[this.owner].dead)
                                                        {
                                                            Main.player[this.owner].DeadlySphereMinion = false;
                                                        }
                                                        if (Main.player[this.owner].DeadlySphereMinion)
                                                        {
                                                            this.timeLeft = 2;
                                                        }
                                                    }
                                                    float num638 = 0.05f;
                                                    for (int num639 = 0; num639 < 1000; num639++)
                                                    {
                                                        bool flag23 = (Main.projectile[num639].type == ProjectileID.Retanimini || Main.projectile[num639].type == ProjectileID.Spazmamini) && (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini);
                                                        if (!flag23)
                                                        {
                                                            flag23 = (this.type == ProjectileID.DeadlySphere && Main.projectile[num639].type == ProjectileID.DeadlySphere);
                                                        }
                                                        if (num639 != this.whoAmI && Main.projectile[num639].active && Main.projectile[num639].owner == this.owner && flag23 && Math.Abs(this.position.X - Main.projectile[num639].position.X) + Math.Abs(this.position.Y - Main.projectile[num639].position.Y) < (float)this.width)
                                                        {
                                                            if (this.position.X < Main.projectile[num639].position.X)
                                                            {
                                                                this.velocity.X = this.velocity.X - num638;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X + num638;
                                                            }
                                                            if (this.position.Y < Main.projectile[num639].position.Y)
                                                            {
                                                                this.velocity.Y = this.velocity.Y - num638;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.Y = this.velocity.Y + num638;
                                                            }
                                                        }
                                                    }
                                                    bool flag24 = false;
                                                    if (this.ai[0] == 2f && this.type == ProjectileID.Spazmamini)
                                                    {
                                                        this.ai[1] += 1f;
                                                        this.extraUpdates = 1;
                                                        this.rotation = this.velocity.ToRotation() + 3.14159274f;
                                                        this.frameCounter++;
                                                        if (this.frameCounter > 1)
                                                        {
                                                            this.frame++;
                                                            this.frameCounter = 0;
                                                        }
                                                        if (this.frame > 2)
                                                        {
                                                            this.frame = 0;
                                                        }
                                                        if (this.ai[1] > 40f)
                                                        {
                                                            this.ai[1] = 1f;
                                                            this.ai[0] = 0f;
                                                            this.extraUpdates = 0;
                                                            this.numUpdates = 0;
                                                            this.netUpdate = true;
                                                        }
                                                        else
                                                        {
                                                            flag24 = true;
                                                        }
                                                    }
                                                    if (this.type == ProjectileID.DeadlySphere && this.ai[0] >= 3f && this.ai[0] <= 5f)
                                                    {
                                                        int num640 = 2;
                                                        flag24 = true;
                                                        this.velocity *= 0.9f;
                                                        this.ai[1] += 1f;
                                                        int num641 = (int)this.ai[1] / num640 + (int)(this.ai[0] - 3f) * 8;
                                                        if (num641 < 4)
                                                        {
                                                            this.frame = 17 + num641;
                                                        }
                                                        else if (num641 < 5)
                                                        {
                                                            this.frame = 0;
                                                        }
                                                        else if (num641 < 8)
                                                        {
                                                            this.frame = 1 + num641 - 5;
                                                        }
                                                        else if (num641 < 11)
                                                        {
                                                            this.frame = 11 - num641;
                                                        }
                                                        else if (num641 < 12)
                                                        {
                                                            this.frame = 0;
                                                        }
                                                        else if (num641 < 16)
                                                        {
                                                            this.frame = num641 - 2;
                                                        }
                                                        else if (num641 < 20)
                                                        {
                                                            this.frame = 29 - num641;
                                                        }
                                                        else if (num641 < 21)
                                                        {
                                                            this.frame = 0;
                                                        }
                                                        else
                                                        {
                                                            this.frame = num641 - 4;
                                                        }
                                                        if (this.ai[1] > (float)(num640 * 8))
                                                        {
                                                            this.ai[0] -= 3f;
                                                            this.ai[1] = 0f;
                                                        }
                                                    }
                                                    if (this.type == ProjectileID.DeadlySphere && this.ai[0] >= 6f && this.ai[0] <= 8f)
                                                    {
                                                        this.ai[1] += 1f;
                                                        this.MaxUpdates = 2;
                                                        if (this.ai[0] == 7f)
                                                        {
                                                            this.rotation = this.velocity.ToRotation() + 3.14159274f;
                                                        }
                                                        else
                                                        {
                                                            this.rotation += 0.5235988f;
                                                        }
                                                        int num642 = 0;
                                                        switch ((int)this.ai[0])
                                                        {
                                                            case 6:
                                                                this.frame = 5;
                                                                num642 = 40;
                                                                break;
                                                            case 7:
                                                                this.frame = 13;
                                                                num642 = 30;
                                                                break;
                                                            case 8:
                                                                this.frame = 17;
                                                                num642 = 30;
                                                                break;
                                                        }
                                                        if (this.ai[1] > (float)num642)
                                                        {
                                                            this.ai[1] = 1f;
                                                            this.ai[0] -= 6f;
                                                            this.localAI[0] += 1f;
                                                            this.extraUpdates = 0;
                                                            this.numUpdates = 0;
                                                            this.netUpdate = true;
                                                        }
                                                        else
                                                        {
                                                            flag24 = true;
                                                        }
                                                    }
                                                    if (flag24)
                                                    {
                                                        return;
                                                    }
                                                    Vector2 vector58 = this.position;
                                                    bool flag25 = false;
                                                    if (this.ai[0] != 1f && (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini))
                                                    {
                                                        this.tileCollide = true;
                                                    }
                                                    if (this.type == ProjectileID.DeadlySphere && this.ai[0] < 9f)
                                                    {
                                                        this.tileCollide = true;
                                                    }
                                                    if (this.tileCollide && WorldGen.SolidTile(Framing.GetTileSafely((int)base.Center.X / 16, (int)base.Center.Y / 16)))
                                                    {
                                                        this.tileCollide = false;
                                                    }
                                                    for (int num646 = 0; num646 < 200; num646++)
                                                    {
                                                        NPC nPC2 = Main.npc[num646];
                                                        if (nPC2.CanBeChasedBy(this, false))
                                                        {
                                                            float num647 = Vector2.Distance(nPC2.Center, base.Center);
                                                            if (((Vector2.Distance(base.Center, vector58) > num647 && num647 < num634) || !flag25) && Collision.CanHitLine(this.position, this.width, this.height, nPC2.position, nPC2.width, nPC2.height))
                                                            {
                                                                num634 = num647;
                                                                vector58 = nPC2.Center;
                                                                flag25 = true;
                                                            }
                                                        }
                                                    }
                                                    float num648 = num635;
                                                    if (flag25)
                                                    {
                                                        num648 = num636;
                                                    }
                                                    Player player = Main.player[this.owner];
                                                    if (Vector2.Distance(player.Center, base.Center) > num648)
                                                    {
                                                        if (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini)
                                                        {
                                                            this.ai[0] = 1f;
                                                        }
                                                        if (this.type == ProjectileID.DeadlySphere && this.ai[0] < 9f)
                                                        {
                                                            this.ai[0] += (float)(3 * (3 - (int)(this.ai[0] / 3f)));
                                                        }
                                                        this.tileCollide = false;
                                                        this.netUpdate = true;
                                                    }
                                                    if ((this.type == ProjectileID.Spazmamini || this.type == ProjectileID.Retanimini) && flag25 && this.ai[0] == 0f)
                                                    {
                                                        Vector2 vector59 = vector58 - base.Center;
                                                        float num649 = vector59.Length();
                                                        vector59.Normalize();
                                                        if (num649 > 200f)
                                                        {
                                                            float num650 = 6f;
                                                            if (this.type == ProjectileID.Spazmamini)
                                                            {
                                                                num650 = 8f;
                                                            }
                                                            vector59 *= num650;
                                                            this.velocity = (this.velocity * 40f + vector59) / 41f;
                                                        }
                                                        else
                                                        {
                                                            float num651 = 4f;
                                                            vector59 *= -num651;
                                                            this.velocity = (this.velocity * 40f + vector59) / 41f;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        bool flag26 = false;
                                                        if (!flag26)
                                                        {
                                                            flag26 = (this.ai[0] == 1f && (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini));
                                                        }
                                                        if (!flag26)
                                                        {
                                                            flag26 = (this.ai[0] >= 9f && this.type == ProjectileID.DeadlySphere);
                                                        }
                                                        float num652 = 6f;
                                                        if (this.type == ProjectileID.DeadlySphere)
                                                        {
                                                            num652 = 12f;
                                                        }
                                                        if (flag26)
                                                        {
                                                            num652 = 15f;
                                                        }
                                                        Vector2 center2 = base.Center;
                                                        Vector2 vector60 = player.Center - center2 + new Vector2(0f, -60f);
                                                        float num653 = vector60.Length();
                                                        if (num653 > 200f && num652 < 8f)
                                                        {
                                                            num652 = 8f;
                                                        }
                                                        if (num653 < num637 && flag26 && !Collision.SolidCollision(this.position, this.width, this.height))
                                                        {
                                                            if (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini)
                                                            {
                                                                this.ai[0] = 0f;
                                                            }
                                                            if (this.type == ProjectileID.DeadlySphere)
                                                            {
                                                                this.ai[0] -= 9f;
                                                            }
                                                            this.netUpdate = true;
                                                        }
                                                        if (num653 > 2000f)
                                                        {
                                                            this.position.X = Main.player[this.owner].Center.X - (float)(this.width / 2);
                                                            this.position.Y = Main.player[this.owner].Center.Y - (float)(this.height / 2);
                                                            this.netUpdate = true;
                                                        }
                                                        if (num653 > 70f)
                                                        {
                                                            vector60.Normalize();
                                                            vector60 *= num652;
                                                            this.velocity = (this.velocity * 40f + vector60) / 41f;
                                                        }
                                                        else if (this.velocity.X == 0f && this.velocity.Y == 0f)
                                                        {
                                                            this.velocity.X = -0.15f;
                                                            this.velocity.Y = -0.05f;
                                                        }
                                                    }
                                                    if (this.type == ProjectileID.Spazmamini)
                                                    {
                                                        this.rotation = this.velocity.ToRotation() + 3.14159274f;
                                                    }
                                                    if (this.type == ProjectileID.Retanimini)
                                                    {
                                                        if (flag25)
                                                        {
                                                            this.rotation = (vector58 - base.Center).ToRotation() + 3.14159274f;
                                                        }
                                                        else
                                                        {
                                                            this.rotation = this.velocity.ToRotation() + 3.14159274f;
                                                        }
                                                    }
                                                    if (this.type == ProjectileID.DeadlySphere && (this.ai[0] < 3f || this.ai[0] >= 9f))
                                                    {
                                                        this.rotation += this.velocity.X * 0.04f;
                                                    }
                                                    if (this.type == ProjectileID.Spazmamini || this.type == ProjectileID.Retanimini)
                                                    {
                                                        this.frameCounter++;
                                                        if (this.frameCounter > 3)
                                                        {
                                                            this.frame++;
                                                            this.frameCounter = 0;
                                                        }
                                                        if (this.frame > 2)
                                                        {
                                                            this.frame = 0;
                                                        }
                                                    }
                                                    else if (this.type == ProjectileID.DeadlySphere)
                                                    {
                                                        if (this.ai[0] < 3f || this.ai[0] >= 9f)
                                                        {
                                                            this.frameCounter++;
                                                            if (this.frameCounter >= 24)
                                                            {
                                                                this.frameCounter = 0;
                                                            }
                                                            int num654 = this.frameCounter / 4;
                                                            this.frame = 4 + num654;
                                                            int num655 = (int)this.ai[0];
                                                            switch (num655)
                                                            {
                                                                case 0:
                                                                    break;
                                                                case 1:
                                                                    goto IL_1AB7D;
                                                                case 2:
                                                                    goto IL_1AB98;
                                                                default:
                                                                    switch (num655)
                                                                    {
                                                                        case 9:
                                                                            break;
                                                                        case 10:
                                                                            goto IL_1AB7D;
                                                                        case 11:
                                                                            goto IL_1AB98;
                                                                        default:
                                                                            goto IL_1ABC2;
                                                                    }
                                                                    break;
                                                            }
                                                            this.frame = 4 + num654;
                                                            goto IL_1ABC2;
                                                        IL_1AB7D:
                                                            num654 = this.frameCounter / 8;
                                                            this.frame = 14 + num654;
                                                            goto IL_1ABC2;
                                                        IL_1AB98:
                                                            num654 = this.frameCounter / 3;
                                                            if (num654 >= 4)
                                                            {
                                                                num654 -= 4;
                                                            }
                                                            this.frame = 17 + num654;
                                                        }
                                                    IL_1ABC2:

                                                        if (this.ai[1] > 0f && (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini))
                                                        {
                                                            this.ai[1] += (float)Main.rand.Next(1, 4);
                                                        }
                                                        if (this.ai[1] > 90f && this.type == ProjectileID.Retanimini)
                                                        {
                                                            this.ai[1] = 0f;
                                                            this.netUpdate = true;
                                                        }
                                                        if (this.ai[1] > 40f && this.type == ProjectileID.Spazmamini)
                                                        {
                                                            this.ai[1] = 0f;
                                                            this.netUpdate = true;
                                                        }
                                                        if (this.ai[1] > 0f && this.type == ProjectileID.DeadlySphere)
                                                        {
                                                            this.ai[1] += 1f;
                                                            int num659 = 10;
                                                            if (this.ai[1] > (float)num659)
                                                            {
                                                                this.ai[1] = 0f;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        if (this.ai[0] == 0f && (this.type == ProjectileID.Retanimini || this.type == ProjectileID.Spazmamini))
                                                        {
                                                            if (this.type == ProjectileID.Retanimini)
                                                            {
                                                                float num660 = 8f;
                                                                int num661 = 389;
                                                                if (flag25 && this.ai[1] == 0f)
                                                                {
                                                                    this.ai[1] += 1f;
                                                                    if (Main.myPlayer == this.owner && Collision.CanHitLine(this.position, this.width, this.height, vector58, 0, 0))
                                                                    {
                                                                        Vector2 vector62 = vector58 - base.Center;
                                                                        vector62.Normalize();
                                                                        vector62 *= num660;
                                                                        int num662 = Projectile.NewProjectile(base.Center.X, base.Center.Y, vector62.X, vector62.Y, num661, (int)((float)this.damage * 0.8f), 0f, Main.myPlayer, 0f, 0f);
                                                                        Main.projectile[num662].timeLeft = 300;
                                                                        this.netUpdate = true;
                                                                    }
                                                                }
                                                            }
                                                            if (this.type == ProjectileID.Spazmamini && this.ai[1] == 0f && flag25 && num634 < 500f)
                                                            {
                                                                this.ai[1] += 1f;
                                                                if (Main.myPlayer == this.owner)
                                                                {
                                                                    this.ai[0] = 2f;
                                                                    Vector2 vector63 = vector58 - base.Center;
                                                                    vector63.Normalize();
                                                                    this.velocity = vector63 * 8f;
                                                                    this.netUpdate = true;
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                        else if (this.type == ProjectileID.DeadlySphere && this.ai[0] < 3f)
                                                        {
                                                            int num663 = 0;
                                                            switch ((int)this.ai[0])
                                                            {
                                                                case 0:
                                                                case 3:
                                                                case 6:
                                                                    num663 = 400;
                                                                    break;
                                                                case 1:
                                                                case 4:
                                                                case 7:
                                                                    num663 = 400;
                                                                    break;
                                                                case 2:
                                                                case 5:
                                                                case 8:
                                                                    num663 = 600;
                                                                    break;
                                                            }
                                                            if (this.ai[1] == 0f && flag25 && num634 < (float)num663)
                                                            {
                                                                this.ai[1] += 1f;
                                                                if (Main.myPlayer == this.owner)
                                                                {
                                                                    if (this.localAI[0] >= 3f)
                                                                    {
                                                                        this.ai[0] += 4f;
                                                                        if (this.ai[0] == 6f)
                                                                        {
                                                                            this.ai[0] = 3f;
                                                                        }
                                                                        this.localAI[0] = 0f;
                                                                        return;
                                                                    }
                                                                    this.ai[0] += 6f;
                                                                    Vector2 vector64 = vector58 - base.Center;
                                                                    vector64.Normalize();
                                                                    float num664 = (this.ai[0] == 8f) ? 12f : 10f;
                                                                    this.velocity = vector64 * num664;
                                                                    this.netUpdate = true;
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                    else if (this.aiStyle == 67)
                                                    {
                                                        Player player2 = Main.player[this.owner];
                                                        if (!player2.active)
                                                        {
                                                            this.active = false;
                                                            return;
                                                        }
                                                        bool flag27 = this.type == ProjectileID.OneEyedPirate || this.type == ProjectileID.SoulscourgePirate || this.type == ProjectileID.PirateCaptain;
                                                        if (flag27)
                                                        {
                                                            if (player2.dead)
                                                            {
                                                                player2.pirateMinion = false;
                                                            }
                                                            if (player2.pirateMinion)
                                                            {
                                                                this.timeLeft = 2;
                                                            }
                                                        }
                                                        if (this.type == ProjectileID.CrimsonHeart)
                                                        {
                                                            if (player2.dead)
                                                            {
                                                                player2.crimsonHeart = false;
                                                            }
                                                            if (player2.crimsonHeart)
                                                            {
                                                                this.timeLeft = 2;
                                                            }
                                                        }
                                                        Vector2 vector65 = player2.Center;
                                                        if (flag27)
                                                        {
                                                            vector65.X -= (float)((15 + player2.width / 2) * player2.direction);
                                                            vector65.X -= (float)(this.minionPos * 40 * player2.direction);
                                                        }
                                                        if (this.type == ProjectileID.CrimsonHeart)
                                                        {
                                                            vector65.X -= (float)((15 + player2.width / 2) * player2.direction);
                                                            vector65.X -= (float)(40 * player2.direction);
                                                        }
                                                        if (this.type == ProjectileID.CrimsonHeart)
                                                        {
                                                            int num665 = 6;
                                                            if (this.frame == 0 || this.frame == 2)
                                                            {
                                                                num665 = 12;
                                                            }
                                                            if (++this.frameCounter >= num665)
                                                            {
                                                                this.frameCounter = 0;
                                                                if (++this.frame >= Main.projFrames[this.type])
                                                                {
                                                                    this.frame = 0;
                                                                }
                                                            }
                                                            this.rotation += this.velocity.X / 20f;
                                                            Vector2 vector66 = (-Vector2.UnitY).RotatedBy((double)this.rotation, default(Vector2)).RotatedBy((double)((float)this.direction * 0.2f), default(Vector2));
                                                        }
                                                        bool flag28 = true;
                                                        if (this.type == ProjectileID.CrimsonHeart)
                                                        {
                                                            flag28 = false;
                                                        }
                                                        int num667 = -1;
                                                        float num668 = 450f;
                                                        if (flag27)
                                                        {
                                                            num668 = 800f;
                                                        }
                                                        int num669 = 15;
                                                        if (this.ai[0] == 0f && flag28)
                                                        {
                                                            for (int num670 = 0; num670 < 200; num670++)
                                                            {
                                                                NPC nPC3 = Main.npc[num670];
                                                                if (nPC3.CanBeChasedBy(this, false))
                                                                {
                                                                    float num671 = (nPC3.Center - base.Center).Length();
                                                                    if (num671 < num668)
                                                                    {
                                                                        num667 = num670;
                                                                        num668 = num671;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        if (this.ai[0] == 1f)
                                                        {
                                                            this.tileCollide = false;
                                                            float num672 = 0.2f;
                                                            float num673 = 10f;
                                                            int num674 = 200;
                                                            if (num673 < Math.Abs(player2.velocity.X) + Math.Abs(player2.velocity.Y))
                                                            {
                                                                num673 = Math.Abs(player2.velocity.X) + Math.Abs(player2.velocity.Y);
                                                            }
                                                            Vector2 vector67 = player2.Center - base.Center;
                                                            float num675 = vector67.Length();
                                                            if (num675 > 2000f)
                                                            {
                                                                this.position = player2.Center - new Vector2((float)this.width, (float)this.height) / 2f;
                                                            }
                                                            if (num675 < (float)num674 && player2.velocity.Y == 0f && this.position.Y + (float)this.height <= player2.position.Y + (float)player2.height && !Collision.SolidCollision(this.position, this.width, this.height))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.netUpdate = true;
                                                                if (this.velocity.Y < -6f)
                                                                {
                                                                    this.velocity.Y = -6f;
                                                                }
                                                            }
                                                            if (num675 >= 60f)
                                                            {
                                                                vector67.Normalize();
                                                                vector67 *= num673;
                                                                if (this.velocity.X < vector67.X)
                                                                {
                                                                    this.velocity.X = this.velocity.X + num672;
                                                                    if (this.velocity.X < 0f)
                                                                    {
                                                                        this.velocity.X = this.velocity.X + num672 * 1.5f;
                                                                    }
                                                                }
                                                                if (this.velocity.X > vector67.X)
                                                                {
                                                                    this.velocity.X = this.velocity.X - num672;
                                                                    if (this.velocity.X > 0f)
                                                                    {
                                                                        this.velocity.X = this.velocity.X - num672 * 1.5f;
                                                                    }
                                                                }
                                                                if (this.velocity.Y < vector67.Y)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y + num672;
                                                                    if (this.velocity.Y < 0f)
                                                                    {
                                                                        this.velocity.Y = this.velocity.Y + num672 * 1.5f;
                                                                    }
                                                                }
                                                                if (this.velocity.Y > vector67.Y)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - num672;
                                                                    if (this.velocity.Y > 0f)
                                                                    {
                                                                        this.velocity.Y = this.velocity.Y - num672 * 1.5f;
                                                                    }
                                                                }
                                                            }
                                                            if (this.velocity.X != 0f)
                                                            {
                                                                this.spriteDirection = Math.Sign(this.velocity.X);
                                                            }
                                                            if (flag27)
                                                            {
                                                                this.frameCounter++;
                                                                if (this.frameCounter > 3)
                                                                {
                                                                    this.frame++;
                                                                    this.frameCounter = 0;
                                                                }
                                                                if (this.frame < 10 | this.frame > 13)
                                                                {
                                                                    this.frame = 10;
                                                                }
                                                                this.rotation = this.velocity.X * 0.1f;
                                                            }
                                                        }
                                                        if (this.ai[0] == 2f)
                                                        {
                                                            this.friendly = true;
                                                            this.spriteDirection = this.direction;
                                                            this.rotation = 0f;
                                                            this.frame = 4 + (int)((float)num669 - this.ai[1]) / (num669 / 3);
                                                            if (this.velocity.Y != 0f)
                                                            {
                                                                this.frame += 3;
                                                            }
                                                            this.velocity.Y = this.velocity.Y + 0.4f;
                                                            if (this.velocity.Y > 10f)
                                                            {
                                                                this.velocity.Y = 10f;
                                                            }
                                                            this.ai[1] -= 1f;
                                                            if (this.ai[1] <= 0f)
                                                            {
                                                                this.ai[1] = 0f;
                                                                this.ai[0] = 0f;
                                                                this.friendly = false;
                                                                this.netUpdate = true;
                                                                return;
                                                            }
                                                        }
                                                        if (num667 >= 0)
                                                        {
                                                            float num676 = 400f;
                                                            float num677 = 20f;
                                                            if (flag27)
                                                            {
                                                                num676 = 700f;
                                                            }
                                                            if ((double)this.position.Y > Main.worldSurface * 16.0)
                                                            {
                                                                num676 *= 0.7f;
                                                            }
                                                            NPC nPC4 = Main.npc[num667];
                                                            Vector2 center3 = nPC4.Center;
                                                            float num678 = (center3 - base.Center).Length();
                                                            Collision.CanHit(this.position, this.width, this.height, nPC4.position, nPC4.width, nPC4.height);
                                                            if (num678 < num676)
                                                            {
                                                                vector65 = center3;
                                                                if (center3.Y < base.Center.Y - 30f && this.velocity.Y == 0f)
                                                                {
                                                                    float num679 = Math.Abs(center3.Y - base.Center.Y);
                                                                    if (num679 < 120f)
                                                                    {
                                                                        this.velocity.Y = -10f;
                                                                    }
                                                                    else if (num679 < 210f)
                                                                    {
                                                                        this.velocity.Y = -13f;
                                                                    }
                                                                    else if (num679 < 270f)
                                                                    {
                                                                        this.velocity.Y = -15f;
                                                                    }
                                                                    else if (num679 < 310f)
                                                                    {
                                                                        this.velocity.Y = -17f;
                                                                    }
                                                                    else if (num679 < 380f)
                                                                    {
                                                                        this.velocity.Y = -18f;
                                                                    }
                                                                }
                                                            }
                                                            if (num678 < num677)
                                                            {
                                                                this.ai[0] = 2f;
                                                                this.ai[1] = (float)num669;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        if (this.ai[0] == 0f && num667 < 0)
                                                        {
                                                            float num680 = 500f;
                                                            if (this.type == ProjectileID.CrimsonHeart)
                                                            {
                                                                num680 = 200f;
                                                            }
                                                            if (Main.player[this.owner].rocketDelay2 > 0)
                                                            {
                                                                this.ai[0] = 1f;
                                                                this.netUpdate = true;
                                                            }
                                                            Vector2 vector68 = player2.Center - base.Center;
                                                            if (vector68.Length() > 2000f)
                                                            {
                                                                this.position = player2.Center - new Vector2((float)this.width, (float)this.height) / 2f;
                                                            }
                                                            else if (vector68.Length() > num680 || Math.Abs(vector68.Y) > 300f)
                                                            {
                                                                this.ai[0] = 1f;
                                                                this.netUpdate = true;
                                                                if (this.velocity.Y > 0f && vector68.Y < 0f)
                                                                {
                                                                    this.velocity.Y = 0f;
                                                                }
                                                                if (this.velocity.Y < 0f && vector68.Y > 0f)
                                                                {
                                                                    this.velocity.Y = 0f;
                                                                }
                                                            }
                                                        }
                                                        if (this.ai[0] == 0f)
                                                        {
                                                            this.tileCollide = true;
                                                            float num681 = 0.5f;
                                                            float num682 = 4f;
                                                            float num683 = 4f;
                                                            float num684 = 0.1f;
                                                            if (num683 < Math.Abs(player2.velocity.X) + Math.Abs(player2.velocity.Y))
                                                            {
                                                                num683 = Math.Abs(player2.velocity.X) + Math.Abs(player2.velocity.Y);
                                                                num681 = 0.7f;
                                                            }
                                                            int num685 = 0;
                                                            bool flag29 = false;
                                                            float num686 = vector65.X - base.Center.X;
                                                            if (Math.Abs(num686) > 5f)
                                                            {
                                                                if (num686 < 0f)
                                                                {
                                                                    num685 = -1;
                                                                    if (this.velocity.X > -num682)
                                                                    {
                                                                        this.velocity.X = this.velocity.X - num681;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.X = this.velocity.X - num684;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    num685 = 1;
                                                                    if (this.velocity.X < num682)
                                                                    {
                                                                        this.velocity.X = this.velocity.X + num681;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.X = this.velocity.X + num684;
                                                                    }
                                                                }
                                                                flag29 = true;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X * 0.9f;
                                                                if (Math.Abs(this.velocity.X) < num681 * 2f)
                                                                {
                                                                    this.velocity.X = 0f;
                                                                }
                                                            }
                                                            if (num685 != 0)
                                                            {
                                                                int num687 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                                                                int num688 = (int)this.position.Y / 16;
                                                                num687 += num685;
                                                                num687 += (int)this.velocity.X;
                                                                for (int num689 = num688; num689 < num688 + this.height / 16 + 1; num689++)
                                                                {
                                                                    if (WorldGen.SolidTile(num687, num689))
                                                                    {
                                                                        flag29 = true;
                                                                    }
                                                                }
                                                            }
                                                            if (this.type == ProjectileID.CrimsonHeart && this.velocity.X != 0f)
                                                            {
                                                                flag29 = true;
                                                            }
                                                            Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, 1, false, 0);
                                                            if (this.velocity.Y == 0f && flag29)
                                                            {
                                                                int num690 = 0;
                                                                while (num690 < 3)
                                                                {
                                                                    int num691 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                                                                    if (num690 == 0)
                                                                    {
                                                                        num691 = (int)this.position.X / 16;
                                                                    }
                                                                    if (num690 == 2)
                                                                    {
                                                                        num691 = (int)(this.position.X + (float)this.width) / 16;
                                                                    }
                                                                    int num692 = (int)(this.position.Y + (float)this.height) / 16 + 1;
                                                                    if (WorldGen.SolidTile(num691, num692) || Main.tile[num691, num692].halfBrick())
                                                                    {
                                                                        goto Block_1931;
                                                                    }
                                                                    if (Main.tile[num691, num692].slope() > 0)
                                                                    {
                                                                        goto Block_1931;
                                                                    }
                                                                IL_1C28D:
                                                                    num690++;
                                                                    continue;
                                                                Block_1931:
                                                                    try
                                                                    {
                                                                        num691 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                                                                        num692 = (int)(this.position.Y + (float)(this.height / 2)) / 16;
                                                                        num691 += num685;
                                                                        num691 += (int)this.velocity.X;
                                                                        if (!WorldGen.SolidTile(num691, num692 - 1) && !WorldGen.SolidTile(num691, num692 - 2))
                                                                        {
                                                                            this.velocity.Y = -5.1f;
                                                                        }
                                                                        else if (!WorldGen.SolidTile(num691, num692 - 2))
                                                                        {
                                                                            this.velocity.Y = -7.1f;
                                                                        }
                                                                        else if (WorldGen.SolidTile(num691, num692 - 5))
                                                                        {
                                                                            this.velocity.Y = -11.1f;
                                                                        }
                                                                        else if (WorldGen.SolidTile(num691, num692 - 4))
                                                                        {
                                                                            this.velocity.Y = -10.1f;
                                                                        }
                                                                        else
                                                                        {
                                                                            this.velocity.Y = -9.1f;
                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                        this.velocity.Y = -9.1f;
                                                                    }
                                                                    goto IL_1C28D;
                                                                }
                                                            }
                                                            if (this.velocity.X > num683)
                                                            {
                                                                this.velocity.X = num683;
                                                            }
                                                            if (this.velocity.X < -num683)
                                                            {
                                                                this.velocity.X = -num683;
                                                            }
                                                            if (this.velocity.X < 0f)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            if (this.velocity.X > 0f)
                                                            {
                                                                this.direction = 1;
                                                            }
                                                            if (this.velocity.X > num681 && num685 == 1)
                                                            {
                                                                this.direction = 1;
                                                            }
                                                            if (this.velocity.X < -num681 && num685 == -1)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            this.spriteDirection = this.direction;
                                                            if (flag27)
                                                            {
                                                                this.rotation = 0f;
                                                                if (this.velocity.Y == 0f)
                                                                {
                                                                    if (this.velocity.X == 0f)
                                                                    {
                                                                        this.frame = 0;
                                                                        this.frameCounter = 0;
                                                                    }
                                                                    else if (Math.Abs(this.velocity.X) >= 0.5f)
                                                                    {
                                                                        this.frameCounter += (int)Math.Abs(this.velocity.X);
                                                                        this.frameCounter++;
                                                                        if (this.frameCounter > 10)
                                                                        {
                                                                            this.frame++;
                                                                            this.frameCounter = 0;
                                                                        }
                                                                        if (this.frame >= 4)
                                                                        {
                                                                            this.frame = 0;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        this.frame = 0;
                                                                        this.frameCounter = 0;
                                                                    }
                                                                }
                                                                else if (this.velocity.Y != 0f)
                                                                {
                                                                    this.frameCounter = 0;
                                                                    this.frame = 14;
                                                                }
                                                            }
                                                            this.velocity.Y = this.velocity.Y + 0.4f;
                                                            if (this.velocity.Y > 10f)
                                                            {
                                                                this.velocity.Y = 10f;
                                                            }
                                                        }
                                                        if (flag27)
                                                        {
                                                            this.localAI[0] += 1f;
                                                            if (this.velocity.X == 0f)
                                                            {
                                                                this.localAI[0] += 1f;
                                                            }
                                                            if (this.localAI[0] >= (float)Main.rand.Next(900, 1200))
                                                            {
                                                                return;
                                                            }
                                                        }
                                                    }
                                                    else if (this.aiStyle == 68)
                                                    {
                                                        this.rotation += 0.25f * (float)this.direction;
                                                        this.ai[0] += 1f;
                                                        if (this.ai[0] >= 3f)
                                                        {
                                                            this.alpha -= 40;
                                                            if (this.alpha < 0)
                                                            {
                                                                this.alpha = 0;
                                                            }
                                                        }
                                                        if (this.ai[0] >= 15f)
                                                        {
                                                            this.velocity.Y = this.velocity.Y + 0.2f;
                                                            if (this.velocity.Y > 16f)
                                                            {
                                                                this.velocity.Y = 16f;
                                                            }
                                                            this.velocity.X = this.velocity.X * 0.99f;
                                                        }
                                                        if (this.alpha == 0)
                                                        {
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        if (this.owner == Main.myPlayer && this.timeLeft <= 3)
                                                        {
                                                            this.tileCollide = false;
                                                            this.alpha = 255;
                                                            this.position.X = this.position.X + (float)(this.width / 2);
                                                            this.position.Y = this.position.Y + (float)(this.height / 2);
                                                            this.width = 80;
                                                            this.height = 80;
                                                            this.position.X = this.position.X - (float)(this.width / 2);
                                                            this.position.Y = this.position.Y - (float)(this.height / 2);
                                                            this.knockBack = 8f;
                                                        }
                                                        if (this.wet && this.timeLeft > 3)
                                                        {
                                                            this.timeLeft = 3;
                                                            return;
                                                        }
                                                    }
                                                    else if (this.aiStyle == 69)
                                                    {
                                                        Vector2 vector70 = Main.player[this.owner].Center - base.Center;
                                                        this.rotation = vector70.ToRotation() - 1.57f;
                                                        if (Main.player[this.owner].dead)
                                                        {
                                                            this.Kill();
                                                            return;
                                                        }
                                                        Main.player[this.owner].itemAnimation = 10;
                                                        Main.player[this.owner].itemTime = 10;
                                                        if (vector70.X < 0f)
                                                        {
                                                            Main.player[this.owner].ChangeDir(1);
                                                            this.direction = 1;
                                                        }
                                                        else
                                                        {
                                                            Main.player[this.owner].ChangeDir(-1);
                                                            this.direction = -1;
                                                        }
                                                        Main.player[this.owner].itemRotation = (vector70 * -1f * (float)this.direction).ToRotation();
                                                        this.spriteDirection = ((vector70.X > 0f) ? -1 : 1);
                                                        if (this.ai[0] == 0f && vector70.Length() > 400f)
                                                        {
                                                            this.ai[0] = 1f;
                                                        }
                                                        if (this.ai[0] == 1f || this.ai[0] == 2f)
                                                        {
                                                            float num699 = vector70.Length();
                                                            if (num699 > 1500f)
                                                            {
                                                                this.Kill();
                                                                return;
                                                            }
                                                            if (num699 > 600f)
                                                            {
                                                                this.ai[0] = 2f;
                                                            }
                                                            this.tileCollide = false;
                                                            float num700 = 20f;
                                                            if (this.ai[0] == 2f)
                                                            {
                                                                num700 = 40f;
                                                            }
                                                            this.velocity = Vector2.Normalize(vector70) * num700;
                                                            if (vector70.Length() < num700)
                                                            {
                                                                this.Kill();
                                                                return;
                                                            }
                                                        }
                                                        this.ai[1] += 1f;
                                                        if (this.ai[1] > 5f)
                                                        {
                                                            this.alpha = 0;
                                                        }
                                                        if ((int)this.ai[1] % 4 == 0 && this.owner == Main.myPlayer)
                                                        {
                                                            Vector2 vector71 = vector70 * -1f;
                                                            vector71.Normalize();
                                                            vector71 *= (float)Main.rand.Next(45, 65) * 0.1f;
                                                            vector71 = vector71.RotatedBy((Main.rand.NextDouble() - 0.5) * 1.5707963705062866, default(Vector2));
                                                            Projectile.NewProjectile(base.Center.X, base.Center.Y, vector71.X, vector71.Y, 405, this.damage, this.knockBack, this.owner, -10f, 0f);
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (this.aiStyle == 70)
                                                        {
                                                            if (this.ai[0] == 0f)
                                                            {
                                                                float num701 = 500f;
                                                                int num702 = -1;
                                                                for (int num703 = 0; num703 < 200; num703++)
                                                                {
                                                                    NPC nPC5 = Main.npc[num703];
                                                                    if (nPC5.CanBeChasedBy(this, false) && Collision.CanHit(this.position, this.width, this.height, nPC5.position, nPC5.width, nPC5.height))
                                                                    {
                                                                        float num704 = (nPC5.Center - base.Center).Length();
                                                                        if (num704 < num701)
                                                                        {
                                                                            num702 = num703;
                                                                            num701 = num704;
                                                                        }
                                                                    }
                                                                }
                                                                this.ai[0] = (float)(num702 + 1);
                                                                if (this.ai[0] == 0f)
                                                                {
                                                                    this.ai[0] = -15f;
                                                                }
                                                                if (this.ai[0] > 0f)
                                                                {
                                                                    float num705 = (float)Main.rand.Next(35, 75) / 30f;
                                                                    this.velocity = (this.velocity * 20f + Vector2.Normalize(Main.npc[(int)this.ai[0] - 1].Center - base.Center + new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101))) * num705) / 21f;
                                                                    this.netUpdate = true;
                                                                }
                                                            }
                                                            else if (this.ai[0] > 0f)
                                                            {
                                                                Vector2 vector72 = Vector2.Normalize(Main.npc[(int)this.ai[0] - 1].Center - base.Center);
                                                                this.velocity = (this.velocity * 40f + vector72 * 12f) / 41f;
                                                            }
                                                            else
                                                            {
                                                                this.ai[0] += 1f;
                                                                this.alpha -= 25;
                                                                if (this.alpha < 50)
                                                                {
                                                                    this.alpha = 50;
                                                                }
                                                                this.velocity *= 0.95f;
                                                            }
                                                            if (this.ai[1] == 0f)
                                                            {
                                                                this.ai[1] = (float)Main.rand.Next(80, 121) / 100f;
                                                                this.netUpdate = true;
                                                            }
                                                            this.scale = this.ai[1];
                                                            return;
                                                        }
                                                        if (this.aiStyle == 71)
                                                        {
                                                            this.localAI[1] += 1f;
                                                            if (this.localAI[1] > 10f && Main.rand.Next(3) == 0)
                                                            {
                                                                this.alpha -= 5;
                                                                if (this.alpha < 50)
                                                                {
                                                                    this.alpha = 50;
                                                                }
                                                                this.rotation += this.velocity.X * 0.1f;
                                                                this.frame = (int)(this.localAI[1] / 3f) % 3;
                                                            }
                                                            int num709 = -1;
                                                            Vector2 vector75 = base.Center;
                                                            float num710 = 500f;
                                                            if (this.localAI[0] > 0f)
                                                            {
                                                                this.localAI[0] -= 1f;
                                                            }
                                                            if (this.ai[0] == 0f && this.localAI[0] == 0f)
                                                            {
                                                                for (int num711 = 0; num711 < 200; num711++)
                                                                {
                                                                    NPC nPC6 = Main.npc[num711];
                                                                    if (nPC6.CanBeChasedBy(this, false) && (this.ai[0] == 0f || this.ai[0] == (float)(num711 + 1)))
                                                                    {
                                                                        Vector2 center4 = nPC6.Center;
                                                                        float num712 = Vector2.Distance(center4, vector75);
                                                                        if (num712 < num710 && Collision.CanHit(this.position, this.width, this.height, nPC6.position, nPC6.width, nPC6.height))
                                                                        {
                                                                            num710 = num712;
                                                                            vector75 = center4;
                                                                            num709 = num711;
                                                                        }
                                                                    }
                                                                }
                                                                if (num709 >= 0)
                                                                {
                                                                    this.ai[0] = (float)(num709 + 1);
                                                                    this.netUpdate = true;
                                                                }
                                                            }
                                                            if (this.localAI[0] == 0f && this.ai[0] == 0f)
                                                            {
                                                                this.localAI[0] = 30f;
                                                            }
                                                            bool flag30 = false;
                                                            if (this.ai[0] != 0f)
                                                            {
                                                                int num713 = (int)(this.ai[0] - 1f);
                                                                if (Main.npc[num713].active && !Main.npc[num713].dontTakeDamage && Main.npc[num713].immune[this.owner] == 0)
                                                                {
                                                                    float num714 = Main.npc[num713].position.X + (float)(Main.npc[num713].width / 2);
                                                                    float num715 = Main.npc[num713].position.Y + (float)(Main.npc[num713].height / 2);
                                                                    float num716 = Math.Abs(this.position.X + (float)(this.width / 2) - num714) + Math.Abs(this.position.Y + (float)(this.height / 2) - num715);
                                                                    if (num716 < 1000f)
                                                                    {
                                                                        flag30 = true;
                                                                        vector75 = Main.npc[num713].Center;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    this.ai[0] = 0f;
                                                                    flag30 = false;
                                                                    this.netUpdate = true;
                                                                }
                                                            }
                                                            if (flag30)
                                                            {
                                                                Vector2 v = vector75 - base.Center;
                                                                float num717 = this.velocity.ToRotation();
                                                                float num718 = v.ToRotation();
                                                                double num719 = (double)(num718 - num717);
                                                                if (num719 > 3.1415926535897931)
                                                                {
                                                                    num719 -= 6.2831853071795862;
                                                                }
                                                                if (num719 < -3.1415926535897931)
                                                                {
                                                                    num719 += 6.2831853071795862;
                                                                }
                                                                this.velocity = this.velocity.RotatedBy(num719 * 0.10000000149011612, default(Vector2));
                                                            }
                                                            float num720 = this.velocity.Length();
                                                            this.velocity.Normalize();
                                                            this.velocity *= num720 + 0.0025f;
                                                            return;
                                                        }
                                                        if (this.aiStyle == 72)
                                                        {
                                                            this.localAI[0] += 1f;
                                                            if (this.localAI[0] > 5f)
                                                            {
                                                                this.alpha -= 25;
                                                                if (this.alpha < 50)
                                                                {
                                                                    this.alpha = 50;
                                                                }
                                                            }
                                                            this.velocity *= 0.96f;
                                                            if (this.ai[1] == 0f)
                                                            {
                                                                this.ai[1] = (float)Main.rand.Next(60, 121) / 100f;
                                                                this.netUpdate = true;
                                                            }
                                                            this.scale = this.ai[1];
                                                            this.position = base.Center;
                                                            int num721 = 14;
                                                            int num722 = 14;
                                                            this.width = (int)((float)num721 * this.ai[1]);
                                                            this.height = (int)((float)num722 * this.ai[1]);
                                                            this.position -= new Vector2((float)(this.width / 2), (float)(this.height / 2));
                                                            return;
                                                        }
                                                        if (this.aiStyle == 73)
                                                        {
                                                            int num723 = (int)this.ai[0];
                                                            int num724 = (int)this.ai[1];
                                                            Tile tile = Main.tile[num723, num724];
                                                            if (tile == null || !tile.active() || tile.type != TileID.FireworkFountain)
                                                            {
                                                                this.Kill();
                                                                return;
                                                            }
                                                            float num725 = 2f;
                                                            float num726 = (float)this.timeLeft / 60f;
                                                            if (num726 < 1f)
                                                            {
                                                                num725 *= num726;
                                                            }
                                                            if (this.type == ProjectileID.FireworkFountainRainbow)
                                                            {
                                                                return;
                                                            }
                                                        }
                                                        else if (this.aiStyle == 74)
                                                        {
                                                            if (this.extraUpdates == 1)
                                                            {
                                                                this.localAI[0] *= this.localAI[1];
                                                                this.localAI[1] -= 0.001f;
                                                                if ((double)this.localAI[0] < 0.01)
                                                                {
                                                                    this.Kill();
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (this.aiStyle == 75)
                                                            {
                                                                this.AI_075();
                                                                return;
                                                            }
                                                            if (this.aiStyle == 76)
                                                            {
                                                                Player player3 = Main.player[this.owner];
                                                                player3.heldProj = this.whoAmI;
                                                                if (this.type == ProjectileID.ScutlixLaserCrosshair)
                                                                {
                                                                    if (player3.mount.Type != 9)
                                                                    {
                                                                        this.Kill();
                                                                        return;
                                                                    }
                                                                }
                                                                else if (this.type == ProjectileID.DrillMountCrosshair && player3.mount.Type != 8)
                                                                {
                                                                    this.Kill();
                                                                    return;
                                                                }
                                                                if (Main.myPlayer != this.owner)
                                                                {
                                                                    this.position.X = player3.position.X + this.ai[0];
                                                                    this.position.Y = player3.position.Y + this.ai[1];
                                                                    if (this.type == ProjectileID.ScutlixLaserCrosshair)
                                                                    {
                                                                        if (!player3.mount.AbilityCharging)
                                                                        {
                                                                            player3.mount.StartAbilityCharge(player3);
                                                                        }
                                                                    }
                                                                    else if (this.type == ProjectileID.DrillMountCrosshair && !player3.mount.AbilityActive)
                                                                    {
                                                                        player3.mount.UseAbility(player3, this.position, false);
                                                                    }
                                                                    player3.mount.AimAbility(player3, this.position);
                                                                    return;
                                                                }
                                                                this.position.X = Main.screenPosition.X + (float)Main.mouseX;
                                                                this.position.Y = Main.screenPosition.Y + (float)Main.mouseY;
                                                                if (this.ai[0] != this.position.X - player3.position.X || this.ai[1] != this.position.Y - player3.position.Y)
                                                                {
                                                                    this.netUpdate = true;
                                                                }
                                                                this.ai[0] = this.position.X - player3.position.X;
                                                                this.ai[1] = this.position.Y - player3.position.Y;
                                                                player3.mount.AimAbility(player3, this.position);
                                                                if (!player3.channel)
                                                                {
                                                                    player3.mount.UseAbility(player3, this.position, false);
                                                                    this.Kill();
                                                                    return;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (this.aiStyle == 77)
                                                                {
                                                                    if (this.ai[1] == 1f)
                                                                    {
                                                                        this.friendly = false;
                                                                        if (this.alpha < 255)
                                                                        {
                                                                            this.alpha += 51;
                                                                        }
                                                                        if (this.alpha >= 255)
                                                                        {
                                                                            this.alpha = 255;
                                                                            this.Kill();
                                                                            return;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (this.alpha > 0)
                                                                        {
                                                                            this.alpha -= 50;
                                                                        }
                                                                        if (this.alpha < 0)
                                                                        {
                                                                            this.alpha = 0;
                                                                        }
                                                                    }
                                                                    float num739 = 30f;
                                                                    float num740 = num739 * 4f;
                                                                    this.ai[0] += 1f;
                                                                    if (this.ai[0] > num740)
                                                                    {
                                                                        this.ai[0] = 0f;
                                                                    }
                                                                    Vector2 vector81 = -Vector2.UnitY.RotatedBy((double)(6.28318548f * this.ai[0] / num739), default(Vector2));
                                                                    float val = 0.75f + vector81.Y * 0.25f;
                                                                    float val2 = 0.8f - vector81.Y * 0.2f;
                                                                    float num741 = Math.Max(val, val2);
                                                                    this.position += new Vector2((float)this.width, (float)this.height) / 2f;
                                                                    this.width = (this.height = (int)(80f * num741));
                                                                    this.position -= new Vector2((float)this.width, (float)this.height) / 2f;
                                                                    this.frameCounter++;
                                                                    if (this.frameCounter >= 3)
                                                                    {
                                                                        this.frameCounter = 0;
                                                                        this.frame++;
                                                                        if (this.frame >= 4)
                                                                        {
                                                                            this.frame = 0;
                                                                        }
                                                                    }
                                                                    return;
                                                                }
                                                                if (this.aiStyle == 78)
                                                                {
                                                                    if (this.alpha > 0)
                                                                    {
                                                                        this.alpha -= 30;
                                                                    }
                                                                    if (this.alpha < 0)
                                                                    {
                                                                        this.alpha = 0;
                                                                    }
                                                                    Vector2 v2 = this.ai[0].ToRotationVector2();
                                                                    float num747 = this.velocity.ToRotation();
                                                                    float num748 = v2.ToRotation();
                                                                    double num749 = (double)(num748 - num747);
                                                                    if (num749 > 3.1415926535897931)
                                                                    {
                                                                        num749 -= 6.2831853071795862;
                                                                    }
                                                                    if (num749 < -3.1415926535897931)
                                                                    {
                                                                        num749 += 6.2831853071795862;
                                                                    }
                                                                    this.velocity = this.velocity.RotatedBy(num749 * 0.05000000074505806, default(Vector2));
                                                                    this.velocity *= 0.96f;
                                                                    this.rotation = this.velocity.ToRotation() - 1.57079637f;
                                                                    if (Main.myPlayer == this.owner && this.timeLeft > 60)
                                                                    {
                                                                        this.timeLeft = 60;
                                                                        return;
                                                                    }
                                                                }
                                                                else if (this.aiStyle == 79)
                                                                {
                                                                    bool flag31 = true;
                                                                    int num750 = (int)this.ai[0] - 1;
                                                                    if (this.type == ProjectileID.SaucerDeathray && (this.ai[0] == 0f || ((!Main.npc[num750].active || Main.npc[num750].type != NPCID.MartianSaucer) && (!Main.npc[num750].active || Main.npc[num750].type != NPCID.MartianSaucerCore || Main.npc[num750].ai[3] % 120f < 60f || Main.npc[num750].ai[0] != 2f))))
                                                                    {
                                                                        flag31 = false;
                                                                    }
                                                                    if (!flag31)
                                                                    {
                                                                        this.Kill();
                                                                        return;
                                                                    }
                                                                    NPC nPC7 = Main.npc[num750];
                                                                    float num751 = nPC7.Center.Y + 46f;
                                                                    int num752 = (int)nPC7.Center.X / 16;
                                                                    int num753 = (int)num751 / 16;
                                                                    int num754 = 0;
                                                                    bool flag32 = Main.tile[num752, num753].nactive() && Main.tileSolid[(int)Main.tile[num752, num753].type] && !Main.tileSolidTop[(int)Main.tile[num752, num753].type];
                                                                    if (flag32)
                                                                    {
                                                                        num754 = 1;
                                                                    }
                                                                    else
                                                                    {
                                                                        while (num754 < 150 && num753 + num754 < Main.maxTilesY)
                                                                        {
                                                                            int num755 = num753 + num754;
                                                                            bool flag33 = Main.tile[num752, num755].nactive() && Main.tileSolid[(int)Main.tile[num752, num755].type] && !Main.tileSolidTop[(int)Main.tile[num752, num755].type];
                                                                            if (flag33)
                                                                            {
                                                                                num754--;
                                                                                break;
                                                                            }
                                                                            num754++;
                                                                        }
                                                                    }
                                                                    this.position.X = nPC7.Center.X - (float)(this.width / 2);
                                                                    this.position.Y = num751;
                                                                    this.height = (num754 + 1) * 16;
                                                                    int num756 = (int)this.position.Y + this.height;
                                                                    if (Main.tile[num752, num756 / 16].nactive() && Main.tileSolid[(int)Main.tile[num752, num756 / 16].type] && !Main.tileSolidTop[(int)Main.tile[num752, num756 / 16].type])
                                                                    {
                                                                        int num757 = num756 % 16;
                                                                        this.height -= num757 - 2;
                                                                    }
                                                                    if (this.type == ProjectileID.SaucerDeathray && ++this.frameCounter >= 5)
                                                                    {
                                                                        this.frameCounter = 0;
                                                                        if (++this.frame >= 4)
                                                                        {
                                                                            this.frame = 0;
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (this.aiStyle == 80)
                                                                    {
                                                                        if (this.ai[0] == 0f && this.ai[1] > 0f)
                                                                        {
                                                                            this.ai[1] -= 1f;
                                                                        }
                                                                        else if (this.ai[0] == 0f && this.ai[1] == 0f)
                                                                        {
                                                                            this.ai[0] = 1f;
                                                                            this.ai[1] = (float)Player.FindClosest(this.position, this.width, this.height);
                                                                            this.netUpdate = true;
                                                                            float num761 = this.velocity.Length();
                                                                            this.velocity = Vector2.Normalize(this.velocity) * (num761 + 4f);
                                                                        }
                                                                        else if (this.ai[0] == 1f)
                                                                        {
                                                                            this.tileCollide = true;
                                                                            this.localAI[1] += 1f;
                                                                            float num764 = 180f;
                                                                            float num765 = 0f;
                                                                            float num766 = 30f;
                                                                            if (this.localAI[1] == num764)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            if (this.localAI[1] >= num765 && this.localAI[1] < num765 + num766)
                                                                            {
                                                                                Vector2 v3 = Main.player[(int)this.ai[1]].Center - base.Center;
                                                                                float num767 = this.velocity.ToRotation();
                                                                                float num768 = v3.ToRotation();
                                                                                double num769 = (double)(num768 - num767);
                                                                                if (num769 > 3.1415926535897931)
                                                                                {
                                                                                    num769 -= 6.2831853071795862;
                                                                                }
                                                                                if (num769 < -3.1415926535897931)
                                                                                {
                                                                                    num769 += 6.2831853071795862;
                                                                                }
                                                                                this.velocity = this.velocity.RotatedBy(num769 * 0.20000000298023224, default(Vector2));
                                                                            }
                                                                        }
                                                                        this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                                                        if (++this.frameCounter >= 3)
                                                                        {
                                                                            this.frameCounter = 0;
                                                                            if (++this.frame >= 3)
                                                                            {
                                                                                this.frame = 0;
                                                                            }
                                                                        }
                                                                        for (int num774 = 0; num774 < 255; num774++)
                                                                        {
                                                                            Player player4 = Main.player[num774];
                                                                            if (player4.active && !player4.dead && Vector2.Distance(player4.Center, base.Center) <= 42f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                        }
                                                                        return;
                                                                    }
                                                                    if (this.aiStyle == 81)
                                                                    {
                                                                        int num775 = this.penetrate;
                                                                        if (this.ai[0] == 0f)
                                                                        {
                                                                            this.tileCollide = true;
                                                                            this.localAI[0] += 1f;
                                                                            float num780 = 0.01f;
                                                                            int num781 = 5;
                                                                            int num782 = num781 * 15;
                                                                            int num783 = 0;
                                                                            if (this.localAI[0] > 7f)
                                                                            {
                                                                                if (this.localAI[1] == 0f)
                                                                                {
                                                                                    this.scale -= num780;
                                                                                    this.alpha += num781;
                                                                                    if (this.alpha > num782)
                                                                                    {
                                                                                        this.alpha = num782;
                                                                                        this.localAI[1] = 1f;
                                                                                    }
                                                                                }
                                                                                else if (this.localAI[1] == 1f)
                                                                                {
                                                                                    this.scale += num780;
                                                                                    this.alpha -= num781;
                                                                                    if (this.alpha <= num783)
                                                                                    {
                                                                                        this.alpha = num783;
                                                                                        this.localAI[1] = 0f;
                                                                                    }
                                                                                }
                                                                            }
                                                                            this.rotation = this.velocity.ToRotation() + 0.7853982f;
                                                                        }
                                                                        else if (this.ai[0] >= (float)1 && this.ai[0] < (float)(1 + num775))
                                                                        {
                                                                            this.tileCollide = false;
                                                                            this.alpha += 15;
                                                                            this.velocity *= 0.98f;
                                                                            this.localAI[0] = 0f;
                                                                            if (this.alpha >= 255)
                                                                            {
                                                                                if (this.ai[0] == 1f)
                                                                                {
                                                                                    this.Kill();
                                                                                    return;
                                                                                }
                                                                                int num784 = -1;
                                                                                Vector2 vector86 = base.Center;
                                                                                float num785 = 250f;
                                                                                for (int num786 = 0; num786 < 200; num786++)
                                                                                {
                                                                                    NPC nPC8 = Main.npc[num786];
                                                                                    if (nPC8.CanBeChasedBy(this, false))
                                                                                    {
                                                                                        Vector2 center6 = nPC8.Center;
                                                                                        float num787 = Vector2.Distance(center6, base.Center);
                                                                                        if (num787 < num785)
                                                                                        {
                                                                                            num785 = num787;
                                                                                            vector86 = center6;
                                                                                            num784 = num786;
                                                                                        }
                                                                                    }
                                                                                }
                                                                                if (num784 >= 0)
                                                                                {
                                                                                    this.netUpdate = true;
                                                                                    this.ai[0] += (float)num775;
                                                                                    this.position = vector86 + ((float)Main.rand.NextDouble() * 6.28318548f).ToRotationVector2() * 100f - new Vector2((float)this.width, (float)this.height) / 2f;
                                                                                    this.velocity = Vector2.Normalize(vector86 - base.Center) * 15f;
                                                                                    this.rotation = this.velocity.ToRotation() + 0.7853982f;
                                                                                }
                                                                                else
                                                                                {
                                                                                    this.Kill();
                                                                                }
                                                                            }
                                                                        }
                                                                        else if (this.ai[0] >= (float)(1 + num775) && this.ai[0] < (float)(1 + num775 * 2))
                                                                        {
                                                                            this.scale = 0.9f;
                                                                            this.tileCollide = false;
                                                                            this.rotation = this.velocity.ToRotation() + 0.7853982f;
                                                                            this.ai[1] += 1f;
                                                                            if (this.ai[1] >= 15f)
                                                                            {
                                                                                this.alpha += 51;
                                                                                this.velocity *= 0.8f;
                                                                                if (this.alpha >= 255)
                                                                                {
                                                                                    this.Kill();
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                this.alpha -= 125;
                                                                                if (this.alpha < 0)
                                                                                {
                                                                                    this.alpha = 0;
                                                                                }
                                                                                this.velocity *= 0.98f;
                                                                            }
                                                                            this.localAI[0] += 1f;
                                                                        }
                                                                        return;
                                                                    }
                                                                    if (this.aiStyle == 82)
                                                                    {
                                                                        this.alpha -= 40;
                                                                        if (this.alpha < 0)
                                                                        {
                                                                            this.alpha = 0;
                                                                        }
                                                                        if (this.ai[0] == 0f)
                                                                        {
                                                                            this.localAI[0] += 1f;
                                                                            if (this.localAI[0] >= 45f)
                                                                            {
                                                                                this.localAI[0] = 0f;
                                                                                this.ai[0] = 1f;
                                                                                this.ai[1] = -this.ai[1];
                                                                                this.netUpdate = true;
                                                                            }
                                                                            this.velocity.X = this.velocity.RotatedBy((double)this.ai[1], default(Vector2)).X;
                                                                            this.velocity.X = MathHelper.Clamp(this.velocity.X, -6f, 6f);
                                                                            this.velocity.Y = this.velocity.Y - 0.08f;
                                                                            if (this.velocity.Y > 0f)
                                                                            {
                                                                                this.velocity.Y = this.velocity.Y - 0.2f;
                                                                            }
                                                                            if (this.velocity.Y < -7f)
                                                                            {
                                                                                this.velocity.Y = -7f;
                                                                            }
                                                                        }
                                                                        else if (this.ai[0] == 1f)
                                                                        {
                                                                            this.localAI[0] += 1f;
                                                                            if (this.localAI[0] >= 90f)
                                                                            {
                                                                                this.localAI[0] = 0f;
                                                                                this.ai[0] = 2f;
                                                                                this.ai[1] = (float)Player.FindClosest(this.position, this.width, this.height);
                                                                                this.netUpdate = true;
                                                                            }
                                                                            this.velocity.X = this.velocity.RotatedBy((double)this.ai[1], default(Vector2)).X;
                                                                            this.velocity.X = MathHelper.Clamp(this.velocity.X, -6f, 6f);
                                                                            this.velocity.Y = this.velocity.Y - 0.08f;
                                                                            if (this.velocity.Y > 0f)
                                                                            {
                                                                                this.velocity.Y = this.velocity.Y - 0.2f;
                                                                            }
                                                                            if (this.velocity.Y < -7f)
                                                                            {
                                                                                this.velocity.Y = -7f;
                                                                            }
                                                                        }
                                                                        else if (this.ai[0] == 2f)
                                                                        {
                                                                            Vector2 vector89 = Main.player[(int)this.ai[1]].Center - base.Center;
                                                                            if (vector89.Length() < 30f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            vector89.Normalize();
                                                                            vector89 *= 14f;
                                                                            vector89 = Vector2.Lerp(this.velocity, vector89, 0.6f);
                                                                            if (vector89.Y < 6f)
                                                                            {
                                                                                vector89.Y = 6f;
                                                                            }
                                                                            float num797 = 0.4f;
                                                                            if (this.velocity.X < vector89.X)
                                                                            {
                                                                                this.velocity.X = this.velocity.X + num797;
                                                                                if (this.velocity.X < 0f && vector89.X > 0f)
                                                                                {
                                                                                    this.velocity.X = this.velocity.X + num797;
                                                                                }
                                                                            }
                                                                            else if (this.velocity.X > vector89.X)
                                                                            {
                                                                                this.velocity.X = this.velocity.X - num797;
                                                                                if (this.velocity.X > 0f && vector89.X < 0f)
                                                                                {
                                                                                    this.velocity.X = this.velocity.X - num797;
                                                                                }
                                                                            }
                                                                            if (this.velocity.Y < vector89.Y)
                                                                            {
                                                                                this.velocity.Y = this.velocity.Y + num797;
                                                                                if (this.velocity.Y < 0f && vector89.Y > 0f)
                                                                                {
                                                                                    this.velocity.Y = this.velocity.Y + num797;
                                                                                }
                                                                            }
                                                                            else if (this.velocity.Y > vector89.Y)
                                                                            {
                                                                                this.velocity.Y = this.velocity.Y - num797;
                                                                                if (this.velocity.Y > 0f && vector89.Y < 0f)
                                                                                {
                                                                                    this.velocity.Y = this.velocity.Y - num797;
                                                                                }
                                                                            }
                                                                        }
                                                                        this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                                                        return;
                                                                    }
                                                                    if (this.aiStyle == 83)
                                                                    {
                                                                        if (this.alpha > 200)
                                                                        {
                                                                            this.alpha = 200;
                                                                        }
                                                                        this.alpha -= 5;
                                                                        if (this.alpha < 0)
                                                                        {
                                                                            this.alpha = 0;
                                                                        }
                                                                        float num799 = (float)this.alpha / 255f;
                                                                        this.scale = 1f - num799;
                                                                        if (this.ai[0] >= 0f)
                                                                        {
                                                                            this.ai[0] += 1f;
                                                                        }
                                                                        if (this.ai[0] == -1f)
                                                                        {
                                                                            this.frame = 1;
                                                                            this.extraUpdates = 1;
                                                                        }
                                                                        else if (this.ai[0] < 30f)
                                                                        {
                                                                            this.position = Main.npc[(int)this.ai[1]].Center - new Vector2((float)this.width, (float)this.height) / 2f - this.velocity;
                                                                        }
                                                                        else
                                                                        {
                                                                            this.velocity *= 0.96f;
                                                                            if (++this.frameCounter >= 6)
                                                                            {
                                                                                this.frameCounter = 0;
                                                                                if (++this.frame >= 2)
                                                                                {
                                                                                    this.frame = 0;
                                                                                }
                                                                            }
                                                                        }
                                                                        if (this.alpha < 40)
                                                                        {
                                                                            for (int num800 = 0; num800 < 2; num800++)
                                                                            {
                                                                                float num801 = (float)Main.rand.NextDouble() * 1f - 0.5f;
                                                                                if (num801 < -0.5f)
                                                                                {
                                                                                    num801 = -0.5f;
                                                                                }
                                                                                if (num801 > 0.5f)
                                                                                {
                                                                                    num801 = 0.5f;
                                                                                }
                                                                            }
                                                                            return;
                                                                        }
                                                                    }
                                                                    else if (this.aiStyle == 84)
                                                                    {
                                                                        Vector2? vector91 = null;
                                                                        if (this.velocity.HasNaNs() || this.velocity == Vector2.Zero)
                                                                        {
                                                                            this.velocity = -Vector2.UnitY;
                                                                        }
                                                                        if (this.type == ProjectileID.PhantasmalDeathray && Main.npc[(int)this.ai[1]].active && Main.npc[(int)this.ai[1]].type == 396)
                                                                        {
                                                                            Vector2 vector92 = new Vector2(27f, 59f);
                                                                            Vector2 vector93 = Utils.Vector2FromElipse(Main.npc[(int)this.ai[1]].localAI[0].ToRotationVector2(), vector92 * Main.npc[(int)this.ai[1]].localAI[1]);
                                                                            this.position = Main.npc[(int)this.ai[1]].Center + vector93 - new Vector2((float)this.width, (float)this.height) / 2f;
                                                                        }
                                                                        else if (this.type == ProjectileID.PhantasmalDeathray && Main.npc[(int)this.ai[1]].active && Main.npc[(int)this.ai[1]].type == 400)
                                                                        {
                                                                            Vector2 vector94 = new Vector2(30f, 30f);
                                                                            Vector2 vector95 = Utils.Vector2FromElipse(Main.npc[(int)this.ai[1]].localAI[0].ToRotationVector2(), vector94 * Main.npc[(int)this.ai[1]].localAI[1]);
                                                                            this.position = Main.npc[(int)this.ai[1]].Center + vector95 - new Vector2((float)this.width, (float)this.height) / 2f;
                                                                        }
                                                                        else if (this.type == ProjectileID.StardustSoldierLaser && Main.npc[(int)this.ai[1]].active && Main.npc[(int)this.ai[1]].type == 411)
                                                                        {
                                                                            Vector2 vector96 = new Vector2((float)(Main.npc[(int)this.ai[1]].direction * 6), -4f);
                                                                            this.position = Main.npc[(int)this.ai[1]].Center + vector96 - base.Size / 2f + new Vector2(0f, -Main.npc[(int)this.ai[1]].gfxOffY);
                                                                        }
                                                                        else if (this.type == ProjectileID.ChargedBlasterLaser && Main.projectile[(int)this.ai[1]].active && Main.projectile[(int)this.ai[1]].type == 460)
                                                                        {
                                                                            Vector2 vector97 = Vector2.Normalize(Main.projectile[(int)this.ai[1]].velocity);
                                                                            this.position = Main.projectile[(int)this.ai[1]].Center + vector97 * 16f - new Vector2((float)this.width, (float)this.height) / 2f + new Vector2(0f, -Main.projectile[(int)this.ai[1]].gfxOffY);
                                                                            this.velocity = Vector2.Normalize(Main.projectile[(int)this.ai[1]].velocity);
                                                                        }
                                                                        else if (this.type == ProjectileID.MoonlordTurretLaser && Main.projectile[(int)this.ai[1]].active && Main.projectile[(int)this.ai[1]].type == 641)
                                                                        {
                                                                            base.Center = Main.projectile[(int)this.ai[1]].Center;
                                                                            this.velocity = Vector2.Normalize(Main.projectile[(int)this.ai[1]].ai[1].ToRotationVector2());
                                                                        }
                                                                        else
                                                                        {
                                                                            if (this.type != ProjectileID.LastPrismLaser || !Main.projectile[(int)this.ai[1]].active || Main.projectile[(int)this.ai[1]].type != 633)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            float num803 = (float)((int)this.ai[0]) - 2.5f;
                                                                            Vector2 vector98 = Vector2.Normalize(Main.projectile[(int)this.ai[1]].velocity);
                                                                            Projectile projectile = Main.projectile[(int)this.ai[1]];
                                                                            float num804 = num803 * 0.5235988f;
                                                                            Vector2 vector99 = Vector2.Zero;
                                                                            float num805;
                                                                            float num806;
                                                                            float num807;
                                                                            float num808;
                                                                            if (projectile.ai[0] < 180f)
                                                                            {
                                                                                num805 = 1f - projectile.ai[0] / 180f;
                                                                                num806 = 20f - projectile.ai[0] / 180f * 14f;
                                                                                if (projectile.ai[0] < 120f)
                                                                                {
                                                                                    num807 = 20f - 4f * (projectile.ai[0] / 120f);
                                                                                    this.Opacity = projectile.ai[0] / 120f * 0.4f;
                                                                                }
                                                                                else
                                                                                {
                                                                                    num807 = 16f - 10f * ((projectile.ai[0] - 120f) / 60f);
                                                                                    this.Opacity = 0.4f + (projectile.ai[0] - 120f) / 60f * 0.6f;
                                                                                }
                                                                                num808 = -22f + projectile.ai[0] / 180f * 20f;
                                                                            }
                                                                            else
                                                                            {
                                                                                num805 = 0f;
                                                                                num807 = 1.75f;
                                                                                num806 = 6f;
                                                                                this.Opacity = 1f;
                                                                                num808 = -2f;
                                                                            }
                                                                            float num809 = (projectile.ai[0] + num803 * num807) / (num807 * 6f) * 6.28318548f;
                                                                            num804 = Vector2.UnitY.RotatedBy((double)num809, default(Vector2)).Y * 0.5235988f * num805;
                                                                            vector99 = (Vector2.UnitY.RotatedBy((double)num809, default(Vector2)) * new Vector2(4f, num806)).RotatedBy((double)projectile.velocity.ToRotation(), default(Vector2));
                                                                            this.position = projectile.Center + vector98 * 16f - base.Size / 2f + new Vector2(0f, -Main.projectile[(int)this.ai[1]].gfxOffY);
                                                                            this.position += projectile.velocity.ToRotation().ToRotationVector2() * num808;
                                                                            this.position += vector99;
                                                                            this.velocity = Vector2.Normalize(projectile.velocity).RotatedBy((double)num804, default(Vector2));
                                                                            this.scale = 1.4f * (1f - num805);
                                                                            this.damage = projectile.damage;
                                                                            if (projectile.ai[0] >= 180f)
                                                                            {
                                                                                this.damage *= 3;
                                                                                vector91 = new Vector2?(projectile.Center);
                                                                            }
                                                                            if (!Collision.CanHitLine(Main.player[this.owner].Center, 0, 0, projectile.Center, 0, 0))
                                                                            {
                                                                                vector91 = new Vector2?(Main.player[this.owner].Center);
                                                                            }
                                                                            this.friendly = (projectile.ai[0] > 30f);
                                                                        }
                                                                        if (this.velocity.HasNaNs() || this.velocity == Vector2.Zero)
                                                                        {
                                                                            this.velocity = -Vector2.UnitY;
                                                                        }
                                                                        if (this.type == ProjectileID.ChargedBlasterLaser)
                                                                        {
                                                                            this.ai[0] += 1f;
                                                                            if (this.ai[0] >= 300f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            this.scale = (float)Math.Sin((double)(this.ai[0] * 3.14159274f / 300f)) * 10f;
                                                                            if (this.scale > 1f)
                                                                            {
                                                                                this.scale = 1f;
                                                                            }
                                                                        }
                                                                        if (this.type == ProjectileID.PhantasmalDeathray)
                                                                        {
                                                                            float num810 = 1f;
                                                                            if (Main.npc[(int)this.ai[1]].type == 400)
                                                                            {
                                                                                num810 = 0.4f;
                                                                            }
                                                                            this.localAI[0] += 1f;
                                                                            if (this.localAI[0] >= 180f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            this.scale = (float)Math.Sin((double)(this.localAI[0] * 3.14159274f / 180f)) * 10f * num810;
                                                                            if (this.scale > num810)
                                                                            {
                                                                                this.scale = num810;
                                                                            }
                                                                        }
                                                                        if (this.type == ProjectileID.MoonlordTurretLaser)
                                                                        {
                                                                            float num811 = 1f;
                                                                            this.localAI[0] += 1f;
                                                                            if (this.localAI[0] >= 50f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            this.scale = (float)Math.Sin((double)(this.localAI[0] * 3.14159274f / 50f)) * 10f * num811;
                                                                            if (this.scale > num811)
                                                                            {
                                                                                this.scale = num811;
                                                                            }
                                                                        }
                                                                        if (this.type == ProjectileID.StardustSoldierLaser)
                                                                        {
                                                                            float num812 = 0.8f;
                                                                            this.localAI[0] += 1f;
                                                                            if (this.localAI[0] >= 60f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            this.scale = (float)Math.Sin((double)(this.localAI[0] * 3.14159274f / 60f)) * 10f * num812;
                                                                            if (this.scale > num812)
                                                                            {
                                                                                this.scale = num812;
                                                                            }
                                                                        }
                                                                        float num813 = this.velocity.ToRotation();
                                                                        if (this.type == ProjectileID.PhantasmalDeathray)
                                                                        {
                                                                            num813 += this.ai[0];
                                                                        }
                                                                        this.rotation = num813 - 1.57079637f;
                                                                        this.velocity = num813.ToRotationVector2();
                                                                        float num814 = 0f;
                                                                        float num815 = 0f;
                                                                        Vector2 vector100 = base.Center;
                                                                        if (vector91.HasValue)
                                                                        {
                                                                            vector100 = vector91.Value;
                                                                        }
                                                                        if (this.type == ProjectileID.PhantasmalDeathray)
                                                                        {
                                                                            num814 = 3f;
                                                                            num815 = (float)this.width;
                                                                        }
                                                                        else if (this.type == ProjectileID.ChargedBlasterLaser)
                                                                        {
                                                                            num814 = 2f;
                                                                            num815 = 0f;
                                                                        }
                                                                        else if (this.type == ProjectileID.MoonlordTurretLaser)
                                                                        {
                                                                            num814 = 2f;
                                                                            num815 = 0f;
                                                                        }
                                                                        else if (this.type == ProjectileID.LastPrismLaser)
                                                                        {
                                                                            num814 = 2f;
                                                                            num815 = 0f;
                                                                        }
                                                                        else if (this.type == ProjectileID.StardustSoldierLaser)
                                                                        {
                                                                            num814 = 2f;
                                                                            num815 = 0f;
                                                                        }
                                                                        float[] array3 = new float[(int)num814];
                                                                        int num816 = 0;
                                                                        while ((float)num816 < num814)
                                                                        {
                                                                            float num817 = (float)num816 / (num814 - 1f);
                                                                            Vector2 vector101 = vector100 + this.velocity.RotatedBy(1.5707963705062866, default(Vector2)) * (num817 - 0.5f) * num815 * this.scale;
                                                                            int num818 = (int)vector101.X / 16;
                                                                            int num819 = (int)vector101.Y / 16;
                                                                            Vector2 vector102 = vector101 + this.velocity * 16f * 150f;
                                                                            int num820 = (int)vector102.X / 16;
                                                                            int num821 = (int)vector102.Y / 16;
                                                                            Tuple<int, int> tuple;
                                                                            float num822;
                                                                            if (!Collision.TupleHitLine(num818, num819, num820, num821, 0, 0, new List<Tuple<int, int>>(), out tuple))
                                                                            {
                                                                                num822 = new Vector2((float)Math.Abs(num818 - tuple.Item1), (float)Math.Abs(num819 - tuple.Item2)).Length() * 16f;
                                                                            }
                                                                            else if (tuple.Item1 == num820 && tuple.Item2 == num821)
                                                                            {
                                                                                num822 = 2400f;
                                                                            }
                                                                            else
                                                                            {
                                                                                num822 = new Vector2((float)Math.Abs(num818 - tuple.Item1), (float)Math.Abs(num819 - tuple.Item2)).Length() * 16f;
                                                                            }
                                                                            array3[num816] = num822;
                                                                            num816++;
                                                                        }
                                                                        float num823 = 0f;
                                                                        for (int num824 = 0; num824 < array3.Length; num824++)
                                                                        {
                                                                            num823 += array3[num824];
                                                                        }
                                                                        num823 /= num814;
                                                                        float num825 = 0.5f;
                                                                        if (this.type == ProjectileID.LastPrismLaser)
                                                                        {
                                                                            num825 = 0.75f;
                                                                        }
                                                                        this.localAI[1] = MathHelper.Lerp(this.localAI[1], num823, num825);
                                                                        if (this.type == ProjectileID.PhantasmalDeathray)
                                                                        {
                                                                            DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f);
                                                                        }
                                                                        else if (this.type == ProjectileID.MoonlordTurretLaser)
                                                                        {
                                                                            DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f);
                                                                        }
                                                                        if (this.type == ProjectileID.ChargedBlasterLaser)
                                                                        {
                                                                            DelegateMethods.v3_1 = new Vector3(0.4f, 0.85f, 0.9f);
                                                                        }
                                                                        if (this.type == ProjectileID.StardustSoldierLaser)
                                                                        {
                                                                            DelegateMethods.v3_1 = new Vector3(0.4f, 0.85f, 0.9f);
                                                                        }
                                                                        if (this.type == ProjectileID.LastPrismLaser && Math.Abs(this.localAI[1] - num823) < 100f && this.scale > 0.15f)
                                                                        {
                                                                            float prismHue = this.GetPrismHue(this.ai[0]);
                                                                            Color color = Main.HslToRgb(prismHue, 1f, 0.5f);
                                                                            color.A = 0;
                                                                            Vector2 vector115 = base.Center + this.velocity * (this.localAI[1] - 14.5f * this.scale);
                                                                            float x = Main.RgbToHsl(new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB)).X;
                                                                            DelegateMethods.v3_1 = color.ToVector3() * 0.3f;
                                                                            return;
                                                                        }
                                                                    }
                                                                    else if (this.aiStyle == 85)
                                                                    {
                                                                        Vector2 vector118 = new Vector2(0f, 216f);
                                                                        this.alpha -= 15;
                                                                        if (this.alpha < 0)
                                                                        {
                                                                            this.alpha = 0;
                                                                        }
                                                                        int num851 = (int)Math.Abs(this.ai[0]) - 1;
                                                                        int num852 = (int)this.ai[1];
                                                                        if (!Main.npc[num851].active || Main.npc[num851].type != NPCID.MoonLordHead)
                                                                        {
                                                                            this.Kill();
                                                                            return;
                                                                        }
                                                                        this.localAI[0] += 1f;
                                                                        if (this.localAI[0] >= 330f && this.ai[0] > 0f && Main.netMode != 1)
                                                                        {
                                                                            this.ai[0] *= -1f;
                                                                            this.netUpdate = true;
                                                                        }
                                                                        if (Main.netMode != 1 && this.ai[0] > 0f && (!Main.player[(int)this.ai[1]].active || Main.player[(int)this.ai[1]].dead))
                                                                        {
                                                                            this.ai[0] *= -1f;
                                                                            this.netUpdate = true;
                                                                        }
                                                                        this.rotation = (Main.npc[(int)Math.Abs(this.ai[0]) - 1].Center - Main.player[(int)this.ai[1]].Center + vector118).ToRotation() + 1.57079637f;
                                                                        if (this.ai[0] > 0f)
                                                                        {
                                                                            Vector2 vector119 = Main.player[(int)this.ai[1]].Center - base.Center;
                                                                            if (vector119.X != 0f || vector119.Y != 0f)
                                                                            {
                                                                                this.velocity = Vector2.Normalize(vector119) * Math.Min(16f, vector119.Length());
                                                                            }
                                                                            else
                                                                            {
                                                                                this.velocity = Vector2.Zero;
                                                                            }
                                                                            if (vector119.Length() < 20f && this.localAI[1] == 0f)
                                                                            {
                                                                                this.localAI[1] = 1f;
                                                                                Main.player[num852].AddBuff(BuffID.MoonLeech, 600, true);
                                                                                return;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            if (this.localAI[1] == 1f)
                                                                            {
                                                                                int num853 = Main.player[num852].HasBuff(BuffID.MoonLeech);
                                                                                if (num853 != -1)
                                                                                {
                                                                                    Main.player[num852].DelBuff(num853);
                                                                                }
                                                                            }
                                                                            Vector2 vector120 = Main.npc[(int)Math.Abs(this.ai[0]) - 1].Center - base.Center + vector118;
                                                                            if (vector120.X != 0f || vector120.Y != 0f)
                                                                            {
                                                                                this.velocity = Vector2.Normalize(vector120) * Math.Min(16f, vector120.Length());
                                                                            }
                                                                            else
                                                                            {
                                                                                this.velocity = Vector2.Zero;
                                                                            }
                                                                            if (vector120.Length() < 20f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                        }
                                                                    }
                                                                    else if (this.aiStyle == 86)
                                                                    {
                                                                        if (this.localAI[1] == 0f)
                                                                        {
                                                                            this.localAI[1] = 1f;
                                                                        }
                                                                        this.ai[0] += 1f;
                                                                        if (this.ai[1] == 1f)
                                                                        {
                                                                            if (this.ai[0] >= 130f)
                                                                            {
                                                                                this.alpha += 10;
                                                                            }
                                                                            else
                                                                            {
                                                                                this.alpha -= 10;
                                                                            }
                                                                            if (this.alpha < 0)
                                                                            {
                                                                                this.alpha = 0;
                                                                            }
                                                                            if (this.alpha > 255)
                                                                            {
                                                                                this.alpha = 255;
                                                                            }
                                                                            if (this.ai[0] >= 150f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            if (this.ai[0] % 30f == 0f && Main.netMode != 1)
                                                                            {
                                                                                Vector2 vector121 = this.rotation.ToRotationVector2();
                                                                                Projectile.NewProjectile(base.Center.X, base.Center.Y, vector121.X, vector121.Y, 464, this.damage, this.knockBack, this.owner, 0f, 0f);
                                                                            }
                                                                            this.rotation += 0.104719758f;
                                                                            return;
                                                                        }
                                                                        else
                                                                        {
                                                                            this.position -= this.velocity;
                                                                            if (this.ai[0] >= 40f)
                                                                            {
                                                                                this.alpha += 3;
                                                                            }
                                                                            else
                                                                            {
                                                                                this.alpha -= 40;
                                                                            }
                                                                            if (this.alpha < 0)
                                                                            {
                                                                                this.alpha = 0;
                                                                            }
                                                                            if (this.alpha > 255)
                                                                            {
                                                                                this.alpha = 255;
                                                                            }
                                                                            if (this.ai[0] >= 45f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            Vector2 vector122 = new Vector2(0f, -720f).RotatedBy((double)this.velocity.ToRotation(), default(Vector2));
                                                                            float num854 = this.ai[0] % 45f / 45f;
                                                                            Vector2 spinningpoint = vector122 * num854;
                                                                            return;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (this.aiStyle == 87)
                                                                        {
                                                                            this.position.Y = this.ai[0];
                                                                            this.height = (int)this.ai[1];
                                                                            if (base.Center.X > Main.player[this.owner].Center.X)
                                                                            {
                                                                                this.direction = 1;
                                                                            }
                                                                            else
                                                                            {
                                                                                this.direction = -1;
                                                                            }
                                                                            this.velocity.X = (float)this.direction * 1E-06f;
                                                                            if (this.owner == Main.myPlayer)
                                                                            {
                                                                                for (int num858 = 0; num858 < 1000; num858++)
                                                                                {
                                                                                    if (Main.projectile[num858].active && num858 != this.whoAmI && Main.projectile[num858].type == this.type && Main.projectile[num858].owner == this.owner && Main.projectile[num858].timeLeft > this.timeLeft)
                                                                                    {
                                                                                        this.Kill();
                                                                                        return;
                                                                                    }
                                                                                }
                                                                            }
                                                                            return;
                                                                        }
                                                                        if (this.aiStyle == 88)
                                                                        {
                                                                            if (this.type == ProjectileID.CultistBossLightningOrb)
                                                                            {
                                                                                if (this.localAI[1] == 0f)
                                                                                {
                                                                                    this.localAI[1] = 1f;
                                                                                }
                                                                                if (this.ai[0] < 180f)
                                                                                {
                                                                                    this.alpha -= 5;
                                                                                    if (this.alpha < 0)
                                                                                    {
                                                                                        this.alpha = 0;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    this.alpha += 5;
                                                                                    if (this.alpha > 255)
                                                                                    {
                                                                                        this.alpha = 255;
                                                                                        this.Kill();
                                                                                        return;
                                                                                    }
                                                                                }
                                                                                this.ai[0] += 1f;
                                                                                if (this.ai[0] % 30f == 0f && this.ai[0] < 180f && Main.netMode != 1)
                                                                                {
                                                                                    int[] array4 = new int[5];
                                                                                    Vector2[] array5 = new Vector2[5];
                                                                                    int num862 = 0;
                                                                                    float num863 = 2000f;
                                                                                    for (int num864 = 0; num864 < 255; num864++)
                                                                                    {
                                                                                        if (Main.player[num864].active && !Main.player[num864].dead)
                                                                                        {
                                                                                            Vector2 center9 = Main.player[num864].Center;
                                                                                            float num865 = Vector2.Distance(center9, base.Center);
                                                                                            if (num865 < num863 && Collision.CanHit(base.Center, 1, 1, center9, 1, 1))
                                                                                            {
                                                                                                array4[num862] = num864;
                                                                                                array5[num862] = center9;
                                                                                                if (++num862 >= array5.Length)
                                                                                                {
                                                                                                    break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    for (int num866 = 0; num866 < num862; num866++)
                                                                                    {
                                                                                        Vector2 vector124 = array5[num866] - base.Center;
                                                                                        float ai = (float)Main.rand.Next(100);
                                                                                        Vector2 vector125 = Vector2.Normalize(vector124.RotatedByRandom(0.78539818525314331)) * 7f;
                                                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, vector125.X, vector125.Y, 466, this.damage, 0f, Main.myPlayer, vector124.ToRotation(), ai);
                                                                                    }
                                                                                }
                                                                                if (++this.frameCounter >= 4)
                                                                                {
                                                                                    this.frameCounter = 0;
                                                                                    if (++this.frame >= Main.projFrames[this.type])
                                                                                    {
                                                                                        this.frame = 0;
                                                                                    }
                                                                                }
                                                                                if (this.alpha < 150 && this.ai[0] < 180f)
                                                                                {
                                                                                    for (int num867 = 0; num867 < 1; num867++)
                                                                                    {
                                                                                        float num868 = (float)Main.rand.NextDouble() * 1f - 0.5f;
                                                                                        if (num868 < -0.5f)
                                                                                        {
                                                                                            num868 = -0.5f;
                                                                                        }
                                                                                        if (num868 > 0.5f)
                                                                                        {
                                                                                            num868 = 0.5f;
                                                                                        }
                                                                                    }
                                                                                    for (int num870 = 0; num870 < 1; num870++)
                                                                                    {
                                                                                        float num871 = (float)Main.rand.NextDouble() * 1f - 0.5f;
                                                                                        if (num871 < -0.5f)
                                                                                        {
                                                                                            num871 = -0.5f;
                                                                                        }
                                                                                        if (num871 > 0.5f)
                                                                                        {
                                                                                            num871 = 0.5f;
                                                                                        }
                                                                                    }
                                                                                    return;
                                                                                }
                                                                            }
                                                                            else if (this.type == ProjectileID.CultistBossLightningOrbArc)
                                                                            {
                                                                                this.frameCounter++;
                                                                                if (this.velocity == Vector2.Zero)
                                                                                {
                                                                                    if (this.frameCounter >= this.extraUpdates * 2)
                                                                                    {
                                                                                        this.frameCounter = 0;
                                                                                        bool flag34 = true;
                                                                                        for (int num873 = 1; num873 < this.oldPos.Length; num873++)
                                                                                        {
                                                                                            if (this.oldPos[num873] != this.oldPos[0])
                                                                                            {
                                                                                                flag34 = false;
                                                                                            }
                                                                                        }
                                                                                        if (flag34)
                                                                                        {
                                                                                            this.Kill();
                                                                                            return;
                                                                                        }
                                                                                    }
                                                                                    if (Main.rand.Next(this.extraUpdates) == 0)
                                                                                    {
                                                                                        if (Main.rand.Next(5) == 0)
                                                                                        {
                                                                                            return;
                                                                                        }
                                                                                    }
                                                                                }
                                                                                else if (this.frameCounter >= this.extraUpdates * 2)
                                                                                {
                                                                                    this.frameCounter = 0;
                                                                                    float num879 = this.velocity.Length();
                                                                                    Random random = new Random((int)this.ai[1]);
                                                                                    int num880 = 0;
                                                                                    Vector2 spinningpoint2 = -Vector2.UnitY;
                                                                                    Vector2 vector130;
                                                                                    do
                                                                                    {
                                                                                        int num881 = random.Next();
                                                                                        this.ai[1] = (float)num881;
                                                                                        num881 %= 100;
                                                                                        float f = (float)num881 / 100f * 6.28318548f;
                                                                                        vector130 = f.ToRotationVector2();
                                                                                        if (vector130.Y > 0f)
                                                                                        {
                                                                                            vector130.Y *= -1f;
                                                                                        }
                                                                                        bool flag35 = false;
                                                                                        if (vector130.Y > -0.02f)
                                                                                        {
                                                                                            flag35 = true;
                                                                                        }
                                                                                        if (vector130.X * (float)(this.extraUpdates + 1) * 2f * num879 + this.localAI[0] > 40f)
                                                                                        {
                                                                                            flag35 = true;
                                                                                        }
                                                                                        if (vector130.X * (float)(this.extraUpdates + 1) * 2f * num879 + this.localAI[0] < -40f)
                                                                                        {
                                                                                            flag35 = true;
                                                                                        }
                                                                                        if (!flag35)
                                                                                        {
                                                                                            goto IL_2363F;
                                                                                        }
                                                                                    }
                                                                                    while (num880++ < 100);
                                                                                    this.velocity = Vector2.Zero;
                                                                                    this.localAI[1] = 1f;
                                                                                    goto IL_23647;
                                                                                IL_2363F:
                                                                                    spinningpoint2 = vector130;
                                                                                IL_23647:
                                                                                    if (this.velocity != Vector2.Zero)
                                                                                    {
                                                                                        this.localAI[0] += spinningpoint2.X * (float)(this.extraUpdates + 1) * 2f * num879;
                                                                                        this.velocity = spinningpoint2.RotatedBy((double)(this.ai[0] + 1.57079637f), default(Vector2)) * num879;
                                                                                        this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                                                                        return;
                                                                                    }
                                                                                }
                                                                            }
                                                                            else if (this.type == ProjectileID.VortexLightning)
                                                                            {
                                                                                if (this.localAI[1] == 0f && this.ai[0] >= 900f)
                                                                                {
                                                                                    this.ai[0] -= 1000f;
                                                                                    this.localAI[1] = -1f;
                                                                                }
                                                                                this.frameCounter++;
                                                                                if (this.velocity == Vector2.Zero)
                                                                                {
                                                                                    if (this.frameCounter >= this.extraUpdates * 2)
                                                                                    {
                                                                                        this.frameCounter = 0;
                                                                                        bool flag36 = true;
                                                                                        for (int num882 = 1; num882 < this.oldPos.Length; num882++)
                                                                                        {
                                                                                            if (this.oldPos[num882] != this.oldPos[0])
                                                                                            {
                                                                                                flag36 = false;
                                                                                            }
                                                                                        }
                                                                                        if (flag36)
                                                                                        {
                                                                                            this.Kill();
                                                                                            return;
                                                                                        }
                                                                                    }
                                                                                    if (Main.rand.Next(this.extraUpdates) == 0 && (this.velocity != Vector2.Zero || Main.rand.Next((this.localAI[1] == 2f) ? 2 : 6) == 0))
                                                                                    {
                                                                                        if (Main.rand.Next(5) == 0)
                                                                                        {
                                                                                            return;
                                                                                        }
                                                                                    }
                                                                                }
                                                                                else if (this.frameCounter >= this.extraUpdates * 2)
                                                                                {
                                                                                    this.frameCounter = 0;
                                                                                    float num888 = this.velocity.Length();
                                                                                    Random random2 = new Random((int)this.ai[1]);
                                                                                    int num889 = 0;
                                                                                    Vector2 spinningpoint3 = -Vector2.UnitY;
                                                                                    Vector2 vector133;
                                                                                    do
                                                                                    {
                                                                                        int num890 = random2.Next();
                                                                                        this.ai[1] = (float)num890;
                                                                                        num890 %= 100;
                                                                                        float f2 = (float)num890 / 100f * 6.28318548f;
                                                                                        vector133 = f2.ToRotationVector2();
                                                                                        if (vector133.Y > 0f)
                                                                                        {
                                                                                            vector133.Y *= -1f;
                                                                                        }
                                                                                        bool flag37 = false;
                                                                                        if (vector133.Y > -0.02f)
                                                                                        {
                                                                                            flag37 = true;
                                                                                        }
                                                                                        if (vector133.X * (float)(this.extraUpdates + 1) * 2f * num888 + this.localAI[0] > 40f)
                                                                                        {
                                                                                            flag37 = true;
                                                                                        }
                                                                                        if (vector133.X * (float)(this.extraUpdates + 1) * 2f * num888 + this.localAI[0] < -40f)
                                                                                        {
                                                                                            flag37 = true;
                                                                                        }
                                                                                        if (!flag37)
                                                                                        {
                                                                                            goto IL_23BA3;
                                                                                        }
                                                                                    }
                                                                                    while (num889++ < 100);
                                                                                    this.velocity = Vector2.Zero;
                                                                                    if (this.localAI[1] < 1f)
                                                                                    {
                                                                                        this.localAI[1] += 2f;
                                                                                        goto IL_23BAB;
                                                                                    }
                                                                                    goto IL_23BAB;
                                                                                IL_23BA3:
                                                                                    spinningpoint3 = vector133;
                                                                                IL_23BAB:
                                                                                    if (this.velocity != Vector2.Zero)
                                                                                    {
                                                                                        this.localAI[0] += spinningpoint3.X * (float)(this.extraUpdates + 1) * 2f * num888;
                                                                                        this.velocity = spinningpoint3.RotatedBy((double)(this.ai[0] + 1.57079637f), default(Vector2)) * num888;
                                                                                        this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                                                                        if (Main.rand.Next(4) == 0 && Main.netMode != 1 && this.localAI[1] == 0f)
                                                                                        {
                                                                                            float num891 = (float)Main.rand.Next(-3, 4) * 1.04719758f / 3f;
                                                                                            Vector2 vector134 = this.ai[0].ToRotationVector2().RotatedBy((double)num891, default(Vector2)) * this.velocity.Length();
                                                                                            if (!Collision.CanHitLine(base.Center, 0, 0, base.Center + vector134 * 50f, 0, 0))
                                                                                            {
                                                                                                Projectile.NewProjectile(base.Center.X - vector134.X, base.Center.Y - vector134.Y, vector134.X, vector134.Y, this.type, this.damage, this.knockBack, this.owner, vector134.ToRotation() + 1000f, this.ai[1]);
                                                                                                return;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else if (this.aiStyle == 89)
                                                                        {
                                                                            if (this.ai[1] == -1f)
                                                                            {
                                                                                this.alpha += 12;
                                                                            }
                                                                            else if (this.ai[0] < 300f)
                                                                            {
                                                                                this.alpha -= 5;
                                                                            }
                                                                            else
                                                                            {
                                                                                this.alpha += 12;
                                                                            }
                                                                            if (this.alpha < 0)
                                                                            {
                                                                                this.alpha = 0;
                                                                            }
                                                                            if (this.alpha > 255)
                                                                            {
                                                                                this.alpha = 255;
                                                                            }
                                                                            this.scale = 1f - (float)this.alpha / 255f;
                                                                            this.scale *= 0.6f;
                                                                            this.rotation += 0.0149599658f;
                                                                            if (this.localAI[1] == 0f)
                                                                            {
                                                                                this.localAI[1] = 1f;
                                                                            }
                                                                            this.ai[0] += 1f;
                                                                            if (this.ai[0] >= 60f)
                                                                            {
                                                                            }
                                                                            if (this.ai[0] == 300f && this.ai[1] != -1f && Main.netMode != 1)
                                                                            {
                                                                                if (!NPC.AnyNPCs(NPCID.CultistDragonHead))
                                                                                {
                                                                                    this.ai[1] = (float)NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 454, 0, 0f, 0f, 0f, 0f, 255);
                                                                                }
                                                                                else
                                                                                {
                                                                                    this.ai[1] = (float)NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 521, 0, 0f, 0f, 0f, 0f, 255);
                                                                                }
                                                                            }
                                                                            else if (this.ai[0] == 320f)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                            bool flag38 = false;
                                                                            if (this.ai[1] == -1f)
                                                                            {
                                                                                if (this.alpha == 255)
                                                                                {
                                                                                    flag38 = true;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                flag38 = (this.ai[1] < 0f || !Main.npc[(int)this.ai[1]].active);
                                                                                if ((flag38 || Main.npc[(int)this.ai[1]].type != 439) && (flag38 || Main.npc[(int)this.ai[1]].type != 454) && (flag38 || Main.npc[(int)this.ai[1]].type != 521))
                                                                                {
                                                                                    flag38 = true;
                                                                                }
                                                                            }
                                                                            if (flag38)
                                                                            {
                                                                                this.Kill();
                                                                                return;
                                                                            }
                                                                        }
                                                                        else if (this.aiStyle == 90)
                                                                        {
                                                                            if (Main.player[this.owner].dead)
                                                                            {
                                                                                this.Kill();
                                                                            }
                                                                            if (Main.myPlayer == this.owner && Main.player[this.owner].magicLantern)
                                                                            {
                                                                                this.timeLeft = 2;
                                                                            }
                                                                            if (this.tileCollide)
                                                                            {
                                                                                if (!Collision.CanHit(this.position, this.width, this.height, Main.player[this.owner].Center, 1, 1))
                                                                                {
                                                                                    this.tileCollide = false;
                                                                                }
                                                                                else if (!Collision.SolidCollision(this.position, this.width, this.height) && Collision.CanHitLine(this.position, this.width, this.height, Main.player[this.owner].Center, 1, 1))
                                                                                {
                                                                                    this.tileCollide = true;
                                                                                }
                                                                            }
                                                                            this.direction = Main.player[this.owner].direction;
                                                                            this.spriteDirection = this.direction;
                                                                            this.localAI[0] += 1f;
                                                                            if (this.localAI[0] >= 10f)
                                                                            {
                                                                                this.localAI[0] = 0f;
                                                                            }
                                                                            Vector2 vector138 = Main.player[this.owner].Center - base.Center;
                                                                            vector138.X += (float)(40 * this.direction);
                                                                            vector138.Y -= 40f;
                                                                            float num905 = vector138.Length();
                                                                            if (num905 > 1000f)
                                                                            {
                                                                                base.Center = Main.player[this.owner].Center;
                                                                            }
                                                                            float num906 = 3f;
                                                                            float num907 = 4f;
                                                                            if (num905 > 200f)
                                                                            {
                                                                                num907 += (num905 - 200f) * 0.1f;
                                                                                this.tileCollide = false;
                                                                            }
                                                                            if (num905 < num907)
                                                                            {
                                                                                this.velocity *= 0.25f;
                                                                                num907 = num905;
                                                                            }
                                                                            if (vector138.X != 0f || vector138.Y != 0f)
                                                                            {
                                                                                vector138.Normalize();
                                                                                vector138 *= num907;
                                                                            }
                                                                            this.velocity = (this.velocity * (num906 - 1f) + vector138) / num906;
                                                                            if (this.velocity.Length() > 6f)
                                                                            {
                                                                                float num908 = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                                                                                if ((double)Math.Abs(this.rotation - num908) >= 3.14)
                                                                                {
                                                                                    if (num908 < this.rotation)
                                                                                    {
                                                                                        this.rotation -= 6.28f;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        this.rotation += 6.28f;
                                                                                    }
                                                                                }
                                                                                this.rotation = (this.rotation * 4f + num908) / 5f;
                                                                                this.frameCounter++;
                                                                                if (this.frameCounter > 4)
                                                                                {
                                                                                    this.frameCounter = 0;
                                                                                    this.frame++;
                                                                                    if (this.frame > 7)
                                                                                    {
                                                                                        this.frame = 4;
                                                                                    }
                                                                                }
                                                                                if (this.frame < 4)
                                                                                {
                                                                                    this.frame = 7;
                                                                                    return;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if ((double)this.rotation > 3.14)
                                                                                {
                                                                                    this.rotation -= 6.28f;
                                                                                }
                                                                                if ((double)this.rotation > -0.01 && (double)this.rotation < 0.01)
                                                                                {
                                                                                    this.rotation = 0f;
                                                                                }
                                                                                else
                                                                                {
                                                                                    this.rotation *= 0.9f;
                                                                                }
                                                                                this.frameCounter++;
                                                                                if (this.frameCounter > 6)
                                                                                {
                                                                                    this.frameCounter = 0;
                                                                                    this.frame++;
                                                                                    if (this.frame > 3)
                                                                                    {
                                                                                        this.frame = 0;
                                                                                        return;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else if (this.aiStyle == 91)
                                                                        {
                                                                            Vector2 center10 = base.Center;
                                                                            this.scale = 1f - this.localAI[0];
                                                                            this.width = (int)(20f * this.scale);
                                                                            this.height = this.width;
                                                                            this.position.X = center10.X - (float)(this.width / 2);
                                                                            this.position.Y = center10.Y - (float)(this.height / 2);
                                                                            if ((double)this.localAI[0] < 0.1)
                                                                            {
                                                                                this.localAI[0] += 0.01f;
                                                                            }
                                                                            else
                                                                            {
                                                                                this.localAI[0] += 0.025f;
                                                                            }
                                                                            if (this.localAI[0] >= 0.95f)
                                                                            {
                                                                                this.Kill();
                                                                            }
                                                                            this.velocity.X = this.velocity.X + this.ai[0] * 1.5f;
                                                                            this.velocity.Y = this.velocity.Y + this.ai[1] * 1.5f;
                                                                            if (this.velocity.Length() > 16f)
                                                                            {
                                                                                this.velocity.Normalize();
                                                                                this.velocity *= 16f;
                                                                            }
                                                                            this.ai[0] *= 1.05f;
                                                                            this.ai[1] *= 1.05f;
                                                                            if (this.scale < 1f)
                                                                            {
                                                                                return;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            if (this.aiStyle == 92)
                                                                            {
                                                                                this.tileCollide = false;
                                                                                this.ai[1] += 1f;
                                                                                if (this.ai[1] > 60f)
                                                                                {
                                                                                    this.ai[0] += 10f;
                                                                                }
                                                                                if (this.ai[0] > 255f)
                                                                                {
                                                                                    this.Kill();
                                                                                    this.ai[0] = 255f;
                                                                                }
                                                                                this.alpha = (int)(100.0 + (double)this.ai[0] * 0.7);
                                                                                this.rotation += this.velocity.X * 0.1f;
                                                                                this.rotation += (float)this.direction * 0.003f;
                                                                                this.velocity *= 0.96f;
                                                                                Rectangle rectangle12 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                                                                                for (int num911 = 0; num911 < 1000; num911++)
                                                                                {
                                                                                    if (num911 != this.whoAmI && Main.projectile[num911].active && Main.projectile[num911].type >= ProjectileID.ToxicCloud && Main.projectile[num911].type <= ProjectileID.ToxicCloud3)
                                                                                    {
                                                                                        Rectangle rectangle13 = new Rectangle((int)Main.projectile[num911].position.X, (int)Main.projectile[num911].position.Y, Main.projectile[num911].width, Main.projectile[num911].height);
                                                                                        if (rectangle12.Intersects(rectangle13))
                                                                                        {
                                                                                            Vector2 vector139 = Main.projectile[num911].Center - base.Center;
                                                                                            if (vector139.X == 0f && vector139.Y == 0f)
                                                                                            {
                                                                                                if (num911 < this.whoAmI)
                                                                                                {
                                                                                                    vector139.X = -1f;
                                                                                                    vector139.Y = 1f;
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    vector139.X = 1f;
                                                                                                    vector139.Y = -1f;
                                                                                                }
                                                                                            }
                                                                                            vector139.Normalize();
                                                                                            vector139 *= 0.005f;
                                                                                            this.velocity -= vector139;
                                                                                            Main.projectile[num911].velocity += vector139;
                                                                                        }
                                                                                    }
                                                                                }
                                                                                return;
                                                                            }
                                                                            if (this.aiStyle == 93)
                                                                            {
                                                                                if (this.alpha > 0)
                                                                                {
                                                                                    this.alpha -= 25;
                                                                                    if (this.alpha <= 0)
                                                                                    {
                                                                                        this.alpha = 0;
                                                                                    }
                                                                                }
                                                                                if (this.velocity.Y > 18f)
                                                                                {
                                                                                    this.velocity.Y = 18f;
                                                                                }
                                                                                if (this.ai[0] == 0f)
                                                                                {
                                                                                    this.ai[1] += 1f;
                                                                                    if (this.ai[1] > 20f)
                                                                                    {
                                                                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                                                                        this.velocity.X = this.velocity.X * 0.992f;
                                                                                    }
                                                                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                                                                                    return;
                                                                                }
                                                                                this.tileCollide = false;
                                                                                if (this.ai[0] == 1f)
                                                                                {
                                                                                    this.tileCollide = false;
                                                                                    this.velocity *= 0.6f;
                                                                                }
                                                                                else
                                                                                {
                                                                                    this.tileCollide = false;
                                                                                    int num912 = (int)(-(int)this.ai[0]);
                                                                                    num912--;
                                                                                    this.position = Main.npc[num912].Center - this.velocity;
                                                                                    this.position.X = this.position.X - (float)(this.width / 2);
                                                                                    this.position.Y = this.position.Y - (float)(this.height / 2);
                                                                                    if (!Main.npc[num912].active || Main.npc[num912].life < 0)
                                                                                    {
                                                                                        this.tileCollide = true;
                                                                                        this.ai[0] = 0f;
                                                                                        this.ai[1] = 20f;
                                                                                        this.velocity = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
                                                                                        this.velocity.Normalize();
                                                                                        this.velocity *= 6f;
                                                                                        this.netUpdate = true;
                                                                                    }
                                                                                    else if (this.velocity.Length() > (float)((Main.npc[num912].width + Main.npc[num912].height) / 3))
                                                                                    {
                                                                                        this.velocity *= 0.99f;
                                                                                    }
                                                                                }
                                                                                if (this.ai[0] != 0f)
                                                                                {
                                                                                    this.ai[1] += 1f;
                                                                                    if (this.ai[1] > 90f)
                                                                                    {
                                                                                        this.Kill();
                                                                                        return;
                                                                                    }
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (this.aiStyle == 94)
                                                                                {
                                                                                    if (++this.frameCounter >= 4)
                                                                                    {
                                                                                        this.frameCounter = 0;
                                                                                        if (++this.frame >= Main.projFrames[this.type])
                                                                                        {
                                                                                            this.frame = 0;
                                                                                        }
                                                                                    }
                                                                                    this.ai[0] += 1f;
                                                                                    if (this.ai[0] <= 40f)
                                                                                    {
                                                                                        this.alpha -= 5;
                                                                                        if (this.alpha < 0)
                                                                                        {
                                                                                            this.alpha = 0;
                                                                                        }
                                                                                        this.velocity *= 0.85f;
                                                                                        if (this.ai[0] == 40f)
                                                                                        {
                                                                                            this.netUpdate = true;
                                                                                            switch (Main.rand.Next(3))
                                                                                            {
                                                                                                case 0:
                                                                                                    this.ai[1] = 10f;
                                                                                                    break;
                                                                                                case 1:
                                                                                                    this.ai[1] = 15f;
                                                                                                    break;
                                                                                                case 2:
                                                                                                    this.ai[1] = 30f;
                                                                                                    break;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else if (this.ai[0] <= 60f)
                                                                                    {
                                                                                        this.velocity = Vector2.Zero;
                                                                                        if (this.ai[0] == 60f)
                                                                                        {
                                                                                            this.netUpdate = true;
                                                                                        }
                                                                                    }
                                                                                    else if (this.ai[0] <= 210f)
                                                                                    {
                                                                                        if (Main.netMode != 1 && (this.localAI[0] += 1f) >= this.ai[1])
                                                                                        {
                                                                                            this.localAI[0] = 0f;
                                                                                            int num913 = Item.NewItem((int)base.Center.X, (int)base.Center.Y, 0, 0, 73, 1, false, 0, false);
                                                                                            Main.item[num913].velocity = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * new Vector2(3f, 2f) * (Main.rand.NextFloat() * 0.5f + 0.5f) - Vector2.UnitY * 1f;
                                                                                        }
                                                                                        if (this.ai[0] == 210f)
                                                                                        {
                                                                                            this.netUpdate = true;
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        this.scale -= 0.0333333351f;
                                                                                        this.alpha += 15;
                                                                                        if (this.ai[0] == 239f)
                                                                                        {
                                                                                            this.netUpdate = true;
                                                                                        }
                                                                                        if (this.ai[0] == 240f)
                                                                                        {
                                                                                            this.Kill();
                                                                                        }
                                                                                    }
                                                                                    return;
                                                                                }
                                                                                if (this.aiStyle == 95)
                                                                                {
                                                                                    if (this.localAI[0] > 2f)
                                                                                    {
                                                                                        this.alpha -= 20;
                                                                                        if (this.alpha < 100)
                                                                                        {
                                                                                            this.alpha = 100;
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        this.localAI[0] += 1f;
                                                                                    }
                                                                                    if (this.ai[0] > 30f)
                                                                                    {
                                                                                        if (this.velocity.Y > -8f)
                                                                                        {
                                                                                            this.velocity.Y = this.velocity.Y - 0.05f;
                                                                                        }
                                                                                        this.velocity.X = this.velocity.X * 0.98f;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        this.ai[0] += 1f;
                                                                                    }
                                                                                    this.rotation = this.velocity.X * 0.1f;
                                                                                    if (this.wet)
                                                                                    {
                                                                                        if (this.velocity.Y > 0f)
                                                                                        {
                                                                                            this.velocity.Y = this.velocity.Y * 0.98f;
                                                                                        }
                                                                                        if (this.velocity.Y > -8f)
                                                                                        {
                                                                                            this.velocity.Y = this.velocity.Y - 0.2f;
                                                                                        }
                                                                                        this.velocity.X = this.velocity.X * 0.94f;
                                                                                        return;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (this.aiStyle == 96)
                                                                                    {
                                                                                        this.ai[0] += 0.6f;
                                                                                        if (this.ai[0] > 500f)
                                                                                        {
                                                                                            this.Kill();
                                                                                        }
                                                                                        this.velocity.Y = this.velocity.Y + 0.008f;
                                                                                        return;
                                                                                    }
                                                                                    if (this.aiStyle == 97)
                                                                                    {
                                                                                        this.frameCounter++;
                                                                                        float num921 = 4f;
                                                                                        if ((float)this.frameCounter < num921 * 1f)
                                                                                        {
                                                                                            this.frame = 0;
                                                                                        }
                                                                                        else if ((float)this.frameCounter < num921 * 2f)
                                                                                        {
                                                                                            this.frame = 1;
                                                                                        }
                                                                                        else if ((float)this.frameCounter < num921 * 3f)
                                                                                        {
                                                                                            this.frame = 2;
                                                                                        }
                                                                                        else if ((float)this.frameCounter < num921 * 4f)
                                                                                        {
                                                                                            this.frame = 3;
                                                                                        }
                                                                                        else if ((float)this.frameCounter < num921 * 5f)
                                                                                        {
                                                                                            this.frame = 4;
                                                                                        }
                                                                                        else if ((float)this.frameCounter < num921 * 6f)
                                                                                        {
                                                                                            this.frame = 3;
                                                                                        }
                                                                                        else if ((float)this.frameCounter < num921 * 7f)
                                                                                        {
                                                                                            this.frame = 2;
                                                                                        }
                                                                                        else if ((float)this.frameCounter < num921 * 8f)
                                                                                        {
                                                                                            this.frame = 1;
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            this.frameCounter = 0;
                                                                                            this.frame = 0;
                                                                                        }
                                                                                        if (this.owner == Main.myPlayer)
                                                                                        {
                                                                                            for (int num922 = 0; num922 < 1000; num922++)
                                                                                            {
                                                                                                if (num922 != this.whoAmI && Main.projectile[num922].active && Main.projectile[num922].owner == this.owner && Main.projectile[num922].type == this.type)
                                                                                                {
                                                                                                    if (this.timeLeft >= Main.projectile[num922].timeLeft)
                                                                                                    {
                                                                                                        Main.projectile[num922].Kill();
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        if (this.ai[0] == 0f)
                                                                                        {
                                                                                            if ((double)this.velocity.Length() < 0.1)
                                                                                            {
                                                                                                this.velocity.X = 0f;
                                                                                                this.velocity.Y = 0f;
                                                                                                this.ai[0] = 1f;
                                                                                                this.ai[1] = 45f;
                                                                                                return;
                                                                                            }
                                                                                            this.velocity *= 0.94f;
                                                                                            if (this.velocity.X < 0f)
                                                                                            {
                                                                                                this.direction = -1;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                this.direction = 1;
                                                                                            }
                                                                                            this.spriteDirection = this.direction;
                                                                                            return;
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            if (Main.player[this.owner].Center.X < base.Center.X)
                                                                                            {
                                                                                                this.direction = -1;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                this.direction = 1;
                                                                                            }
                                                                                            this.spriteDirection = this.direction;
                                                                                            this.ai[1] += 1f;
                                                                                            float num923 = 0.005f;
                                                                                            if (this.ai[1] > 0f)
                                                                                            {
                                                                                                this.velocity.Y = this.velocity.Y - num923;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                this.velocity.Y = this.velocity.Y + num923;
                                                                                            }
                                                                                            if (this.ai[1] >= 90f)
                                                                                            {
                                                                                                this.ai[1] *= -1f;
                                                                                                return;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    else if (this.aiStyle == 98)
                                                                                    {
                                                                                        Vector2 vector142 = new Vector2(this.ai[0], this.ai[1]);
                                                                                        Vector2 vector143 = vector142 - base.Center;
                                                                                        if (vector143.Length() < this.velocity.Length())
                                                                                        {
                                                                                            this.Kill();
                                                                                            return;
                                                                                        }
                                                                                        vector143.Normalize();
                                                                                        vector143 *= 15f;
                                                                                        this.velocity = Vector2.Lerp(this.velocity, vector143, 0.1f);
                                                                                        return;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (this.aiStyle == 99 && this.type >= ProjectileID.BlackCounterweight && this.type <= ProjectileID.YellowCounterweight)
                                                                                        {
                                                                                            this.AI_099_1();
                                                                                            return;
                                                                                        }
                                                                                        if (this.aiStyle == 99)
                                                                                        {
                                                                                            this.AI_099_2();
                                                                                            return;
                                                                                        }
                                                                                        if (this.aiStyle == 100)
                                                                                        {
                                                                                            Player player5 = Main.player[this.owner];
                                                                                            Vector2 zero2 = Vector2.Zero;
                                                                                            if (this.type == ProjectileID.MedusaHead)
                                                                                            {
                                                                                                zero2.X = (float)player5.direction * 6f;
                                                                                                zero2.Y = player5.gravDir * -14f;
                                                                                                this.ai[0] += 1f;
                                                                                                int num926 = 0;
                                                                                                if (this.ai[0] >= 60f)
                                                                                                {
                                                                                                    num926++;
                                                                                                }
                                                                                                if (this.ai[0] >= 180f)
                                                                                                {
                                                                                                    num926++;
                                                                                                }
                                                                                                if (this.ai[0] >= 240f)
                                                                                                {
                                                                                                    this.Kill();
                                                                                                    return;
                                                                                                }
                                                                                                bool flag40 = false;
                                                                                                if (this.ai[0] == 60f || this.ai[0] == 180f)
                                                                                                {
                                                                                                    flag40 = true;
                                                                                                }
                                                                                                bool flag41 = this.ai[0] >= 180f;
                                                                                                if (flag41)
                                                                                                {
                                                                                                    if (this.frame < 8)
                                                                                                    {
                                                                                                        this.frame = 8;
                                                                                                    }
                                                                                                    if (this.frame >= 12)
                                                                                                    {
                                                                                                        this.frame = 8;
                                                                                                    }
                                                                                                    this.frameCounter++;
                                                                                                    if (++this.frameCounter >= 5)
                                                                                                    {
                                                                                                        this.frameCounter = 0;
                                                                                                        if (++this.frame >= 12)
                                                                                                        {
                                                                                                            this.frame = 8;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                else if (++this.frameCounter >= 5)
                                                                                                {
                                                                                                    this.frameCounter = 0;
                                                                                                    if (++this.frame >= 8)
                                                                                                    {
                                                                                                        this.frame = 0;
                                                                                                    }
                                                                                                }
                                                                                                Vector2 center11 = player5.Center;
                                                                                                Vector2 vector144 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - center11;
                                                                                                if (player5.gravDir == -1f)
                                                                                                {
                                                                                                    vector144.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - center11.Y;
                                                                                                }
                                                                                                Vector2 velocity2 = new Vector2((float)Math.Sign((vector144.X == 0f) ? ((float)player5.direction) : vector144.X), 0f);
                                                                                                if (velocity2.X != this.velocity.X || velocity2.Y != this.velocity.Y)
                                                                                                {
                                                                                                    this.netUpdate = true;
                                                                                                }
                                                                                                this.velocity = velocity2;
                                                                                                if (this.soundDelay <= 0 && !flag41)
                                                                                                {
                                                                                                    this.soundDelay = 10;
                                                                                                    this.soundDelay *= 2;
                                                                                                }
                                                                                                if (Main.myPlayer == this.owner)
                                                                                                {
                                                                                                    bool flag42 = !flag40 || player5.CheckMana(player5.inventory[player5.selectedItem].mana, true, false);
                                                                                                    bool flag43 = player5.channel && flag42;
                                                                                                    if ((!flag41 && !flag43) || this.ai[0] == 180f)
                                                                                                    {
                                                                                                        Vector2 vector149 = player5.Center + new Vector2((float)(player5.direction * 4), player5.gravDir * 2f);
                                                                                                        int num932 = this.damage * (1 + num926);
                                                                                                        vector149 = base.Center;
                                                                                                        int num933 = 0;
                                                                                                        float num934 = 0f;
                                                                                                        for (int num935 = 0; num935 < 200; num935++)
                                                                                                        {
                                                                                                            NPC nPC9 = Main.npc[num935];
                                                                                                            if (nPC9.active && base.Distance(nPC9.Center) < 500f && nPC9.CanBeChasedBy(this, false) && Collision.CanHitLine(nPC9.position, nPC9.width, nPC9.height, vector149, 0, 0))
                                                                                                            {
                                                                                                                Vector2 v4 = nPC9.Center - vector149;
                                                                                                                num934 += v4.ToRotation();
                                                                                                                num933++;
                                                                                                                int num936 = Projectile.NewProjectile(vector149.X, vector149.Y, v4.X, v4.Y, 536, 0, 0f, this.owner, (float)this.whoAmI, 0f);
                                                                                                                Main.projectile[num936].Center = nPC9.Center;
                                                                                                                Main.projectile[num936].damage = num932;
                                                                                                                Main.projectile[num936].Damage();
                                                                                                                Main.projectile[num936].damage = 0;
                                                                                                                Main.projectile[num936].Center = vector149;
                                                                                                                this.ai[0] = 180f;
                                                                                                            }
                                                                                                        }
                                                                                                        if (num933 != 0)
                                                                                                        {
                                                                                                            num934 /= (float)num933;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            num934 = ((player5.direction == 1) ? 0f : 3.14159274f);
                                                                                                        }
                                                                                                        for (int num937 = 0; num937 < 6; num937++)
                                                                                                        {
                                                                                                            Vector2 vector150 = Vector2.Zero;
                                                                                                            if (Main.rand.Next(4) != 0)
                                                                                                            {
                                                                                                                vector150 = Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy((double)num934, default(Vector2)) * new Vector2(200f, 50f) * (Main.rand.NextFloat() * 0.7f + 0.3f);
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                vector150 = Vector2.UnitX.RotatedByRandom(6.2831854820251465) * new Vector2(200f, 50f) * (Main.rand.NextFloat() * 0.7f + 0.3f);
                                                                                                            }
                                                                                                            Projectile.NewProjectile(vector149.X, vector149.Y, vector150.X, vector150.Y, 536, 0, 0f, this.owner, (float)this.whoAmI, 0f);
                                                                                                        }
                                                                                                        this.ai[0] = 180f;
                                                                                                        this.netUpdate = true;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            this.rotation = ((player5.gravDir == 1f) ? 0f : 3.14159274f);
                                                                                            this.spriteDirection = this.direction;
                                                                                            this.timeLeft = 2;
                                                                                            Vector2 vector151 = Main.OffsetsPlayerOnhand[player5.bodyFrame.Y / 56] * 2f;
                                                                                            if (player5.direction != 1)
                                                                                            {
                                                                                                vector151.X = (float)player5.bodyFrame.Width - vector151.X;
                                                                                            }
                                                                                            vector151 -= (player5.bodyFrame.Size() - new Vector2((float)player5.width, 42f)) / 2f;
                                                                                            base.Center = (player5.position + vector151 + zero2 - this.velocity).Floor();
                                                                                            player5.ChangeDir(this.direction);
                                                                                            player5.heldProj = this.whoAmI;
                                                                                            player5.itemTime = 2;
                                                                                            player5.itemAnimation = 2;
                                                                                            return;
                                                                                        }
                                                                                        if (this.aiStyle == 101)
                                                                                        {
                                                                                            float num938 = 20f;
                                                                                            this.localAI[0] += 1f;
                                                                                            this.alpha = (int)MathHelper.Lerp(0f, 255f, this.localAI[0] / num938);
                                                                                            int num939 = (int)this.ai[0];
                                                                                            int num940 = -1;
                                                                                            int num941 = -1;
                                                                                            int num655 = this.type;
                                                                                            if (num655 != 536)
                                                                                            {
                                                                                                if (num655 == 591)
                                                                                                {
                                                                                                    num941 = 1;
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                num940 = 535;
                                                                                                num941 = 0;
                                                                                            }
                                                                                            if (num941 == 1)
                                                                                            {
                                                                                                if (this.localAI[0] >= num938 || num939 < 0 || num939 > 255 || !Main.player[num939].active || Main.player[num939].dead)
                                                                                                {
                                                                                                    this.Kill();
                                                                                                    return;
                                                                                                }
                                                                                                if (this.type == ProjectileID.MinecartMechLaser)
                                                                                                {
                                                                                                    base.Center = Mount.GetMinecartMechPoint(Main.player[num939], 20, -19) - this.velocity;
                                                                                                    this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                                                                                    if (Math.Sign(this.velocity.X) != Math.Sign(Main.player[num939].velocity.X) && Main.player[num939].velocity.X != 0f)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    base.Center = Main.player[num939].Center - this.velocity;
                                                                                                }
                                                                                            }
                                                                                            else if (num941 == 0)
                                                                                            {
                                                                                                if (this.localAI[0] >= num938 || num939 < 0 || num939 > 1000 || !Main.projectile[num939].active || Main.projectile[num939].type != num940)
                                                                                                {
                                                                                                    this.Kill();
                                                                                                    return;
                                                                                                }
                                                                                                base.Center = Main.projectile[num939].Center - this.velocity;
                                                                                            }
                                                                                            this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                                                                            return;
                                                                                        }
                                                                                        if (this.aiStyle == 102)
                                                                                        {
                                                                                            int num942 = 0;
                                                                                            float num943 = 0f;
                                                                                            float num944 = 0f;
                                                                                            float num945 = 0f;
                                                                                            int num946 = -1;
                                                                                            int num947 = 0;
                                                                                            float num948 = 0f;
                                                                                            bool flag44 = true;
                                                                                            bool flag45 = false;
                                                                                            bool flag46 = false;
                                                                                            int num655 = this.type;
                                                                                            if (num655 != 539)
                                                                                            {
                                                                                                switch (num655)
                                                                                                {
                                                                                                    case 573:
                                                                                                        num942 = 424;
                                                                                                        num943 = 90f;
                                                                                                        num948 = 20f;
                                                                                                        flag44 = false;
                                                                                                        flag45 = true;
                                                                                                        break;
                                                                                                    case 574:
                                                                                                        num942 = 420;
                                                                                                        num943 = 180f;
                                                                                                        num944 = 0.15f;
                                                                                                        num945 = 0.075f;
                                                                                                        num948 = 8f;
                                                                                                        flag44 = false;
                                                                                                        num946 = 576;
                                                                                                        num947 = 65;
                                                                                                        if (Main.expertMode)
                                                                                                        {
                                                                                                            num947 = 50;
                                                                                                        }
                                                                                                        flag46 = true;
                                                                                                        break;
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                num942 = 407;
                                                                                                num943 = 210f;
                                                                                                num944 = 0.15f;
                                                                                                num945 = 0.075f;
                                                                                                num948 = 16f;
                                                                                            }
                                                                                            if (flag46)
                                                                                            {
                                                                                                int num949 = (int)this.ai[1];
                                                                                                if (!Main.npc[num949].active || Main.npc[num949].type != num942)
                                                                                                {
                                                                                                    this.Kill();
                                                                                                    return;
                                                                                                }
                                                                                                this.timeLeft = 2;
                                                                                            }
                                                                                            this.ai[0] += 1f;
                                                                                            if (this.ai[0] < num943)
                                                                                            {
                                                                                                bool flag47 = true;
                                                                                                int num950 = (int)this.ai[1];
                                                                                                if (Main.npc[num950].active && Main.npc[num950].type == num942)
                                                                                                {
                                                                                                    if (!flag45 && Main.npc[num950].oldPos[1] != Vector2.Zero)
                                                                                                    {
                                                                                                        this.position += Main.npc[num950].position - Main.npc[num950].oldPos[1];
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    this.ai[0] = num943;
                                                                                                    flag47 = false;
                                                                                                }
                                                                                                if (flag47 && !flag45)
                                                                                                {
                                                                                                    this.velocity += new Vector2((float)Math.Sign(Main.npc[num950].Center.X - base.Center.X), (float)Math.Sign(Main.npc[num950].Center.Y - base.Center.Y)) * new Vector2(num944, num945);
                                                                                                    if (this.velocity.Length() > 6f)
                                                                                                    {
                                                                                                        this.velocity *= 6f / this.velocity.Length();
                                                                                                    }
                                                                                                }
                                                                                                if (this.type == ProjectileID.StardustJellyfishSmall)
                                                                                                {
                                                                                                    if (++this.frameCounter >= 4)
                                                                                                    {
                                                                                                        this.frameCounter = 0;
                                                                                                        if (++this.frame >= Main.projFrames[this.type])
                                                                                                        {
                                                                                                            this.frame = 0;
                                                                                                        }
                                                                                                    }
                                                                                                    this.rotation = this.velocity.X * 0.1f;
                                                                                                }
                                                                                                if (this.type == ProjectileID.NebulaBolt)
                                                                                                {
                                                                                                    this.alpha = 255;
                                                                                                }
                                                                                                if (this.type == ProjectileID.NebulaEye)
                                                                                                {
                                                                                                    if (flag47)
                                                                                                    {
                                                                                                        int target = Main.npc[num950].target;
                                                                                                        float num954 = this.velocity.ToRotation();
                                                                                                        if (Collision.CanHitLine(base.Center, 0, 0, Main.player[target].Center, 0, 0))
                                                                                                        {
                                                                                                            num954 = base.DirectionTo(Main.player[target].Center).ToRotation();
                                                                                                        }
                                                                                                        this.rotation = this.rotation.AngleLerp(num954 + 1.57079637f, 0.2f);
                                                                                                    }
                                                                                                    this.frame = 1;
                                                                                                }
                                                                                            }
                                                                                            if (this.ai[0] == num943)
                                                                                            {
                                                                                                bool flag48 = true;
                                                                                                int num955 = -1;
                                                                                                if (!flag44)
                                                                                                {
                                                                                                    int num956 = (int)this.ai[1];
                                                                                                    if (Main.npc[num956].active && Main.npc[num956].type == num942)
                                                                                                    {
                                                                                                        num955 = Main.npc[num956].target;
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        flag48 = false;
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    flag48 = false;
                                                                                                }
                                                                                                if (!flag48)
                                                                                                {
                                                                                                    num955 = (int)Player.FindClosest(this.position, this.width, this.height);
                                                                                                }
                                                                                                Vector2 vector152 = Main.player[num955].Center - base.Center;
                                                                                                vector152.X += (float)Main.rand.Next(-50, 51);
                                                                                                vector152.Y += (float)Main.rand.Next(-50, 51);
                                                                                                vector152.X *= (float)Main.rand.Next(80, 121) * 0.01f;
                                                                                                vector152.Y *= (float)Main.rand.Next(80, 121) * 0.01f;
                                                                                                Vector2 vector153 = Vector2.Normalize(vector152);
                                                                                                if (vector153.HasNaNs())
                                                                                                {
                                                                                                    vector153 = Vector2.UnitY;
                                                                                                }
                                                                                                if (num946 == -1)
                                                                                                {
                                                                                                    this.velocity = vector153 * num948;
                                                                                                    this.netUpdate = true;
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    if (Main.netMode != 1 && Collision.CanHitLine(base.Center, 0, 0, Main.player[num955].Center, 0, 0))
                                                                                                    {
                                                                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, vector153.X * num948, vector153.Y * num948, num946, num947, 1f, Main.myPlayer, 0f, 0f);
                                                                                                    }
                                                                                                    this.ai[0] = 0f;
                                                                                                }
                                                                                            }
                                                                                            if (this.ai[0] >= num943)
                                                                                            {
                                                                                                this.rotation = this.rotation.AngleLerp(this.velocity.ToRotation() + 1.57079637f, 0.4f);
                                                                                                if (this.type == ProjectileID.StardustJellyfishSmall)
                                                                                                {
                                                                                                    if (++this.frameCounter >= 2)
                                                                                                    {
                                                                                                        this.frameCounter = 0;
                                                                                                        if (++this.frame >= Main.projFrames[this.type])
                                                                                                        {
                                                                                                            this.frame = 0;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                if (this.type == ProjectileID.NebulaBolt)
                                                                                                {
                                                                                                    this.alpha = 0;
                                                                                                    return;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        else if (this.aiStyle == 103)
                                                                                        {
                                                                                            this.scale = this.ai[1];
                                                                                            this.ai[0] += 1f;
                                                                                            if (this.ai[0] >= 30f)
                                                                                            {
                                                                                                this.alpha += 25;
                                                                                                if (this.alpha >= 250)
                                                                                                {
                                                                                                    this.Kill();
                                                                                                    return;
                                                                                                }
                                                                                            }
                                                                                            else if (this.ai[0] >= 0f)
                                                                                            {
                                                                                                this.alpha -= 25;
                                                                                                if (this.alpha < 0)
                                                                                                {
                                                                                                    this.alpha = 0;
                                                                                                    if (this.localAI[1] == 0f && Main.netMode != 1 && this.localAI[0] != 0f)
                                                                                                    {
                                                                                                        this.localAI[1] = 1f;
                                                                                                        NPC.NewNPC((int)base.Center.X, (int)base.Bottom.Y, (int)this.localAI[0], 0, 0f, 0f, 0f, 0f, 255);
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            if (this.aiStyle == 104)
                                                                                            {
                                                                                                if (this.ai[0] == 1f)
                                                                                                {
                                                                                                    this.scale *= 0.995f;
                                                                                                    this.alpha += 3;
                                                                                                    if (this.alpha >= 250)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    this.scale *= 1.01f;
                                                                                                    this.alpha -= 7;
                                                                                                    if (this.alpha < 0)
                                                                                                    {
                                                                                                        this.alpha = 0;
                                                                                                        this.ai[0] = 1f;
                                                                                                    }
                                                                                                }
                                                                                                this.frameCounter++;
                                                                                                if (this.frameCounter > 6)
                                                                                                {
                                                                                                    this.frameCounter = 0;
                                                                                                    this.frame++;
                                                                                                    if (this.frame > 3)
                                                                                                    {
                                                                                                        this.frame = 0;
                                                                                                    }
                                                                                                }
                                                                                                this.velocity.Y = this.velocity.Y - 0.03f;
                                                                                                this.velocity.X = this.velocity.X * 0.97f;
                                                                                                return;
                                                                                            }
                                                                                            if (this.aiStyle == 105)
                                                                                            {
                                                                                                this.localAI[0] += 1f;
                                                                                                if (this.localAI[0] >= 90f)
                                                                                                {
                                                                                                    this.localAI[0] *= -1f;
                                                                                                }
                                                                                                if (this.localAI[0] >= 0f)
                                                                                                {
                                                                                                    this.scale += 0.003f;
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    this.scale -= 0.003f;
                                                                                                }
                                                                                                this.rotation += 0.0025f * this.scale;
                                                                                                float num961 = 1f;
                                                                                                float num962 = 1f;
                                                                                                if (this.identity % 6 == 0)
                                                                                                {
                                                                                                    num962 *= -1f;
                                                                                                }
                                                                                                if (this.identity % 6 == 1)
                                                                                                {
                                                                                                    num961 *= -1f;
                                                                                                }
                                                                                                if (this.identity % 6 == 2)
                                                                                                {
                                                                                                    num962 *= -1f;
                                                                                                    num961 *= -1f;
                                                                                                }
                                                                                                if (this.identity % 6 == 3)
                                                                                                {
                                                                                                    num962 = 0f;
                                                                                                }
                                                                                                if (this.identity % 6 == 4)
                                                                                                {
                                                                                                    num961 = 0f;
                                                                                                }
                                                                                                this.localAI[1] += 1f;
                                                                                                if (this.localAI[1] > 60f)
                                                                                                {
                                                                                                    this.localAI[1] = -180f;
                                                                                                }
                                                                                                if (this.localAI[1] >= -60f)
                                                                                                {
                                                                                                    this.velocity.X = this.velocity.X + 0.002f * num962;
                                                                                                    this.velocity.Y = this.velocity.Y + 0.002f * num961;
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    this.velocity.X = this.velocity.X - 0.002f * num962;
                                                                                                    this.velocity.Y = this.velocity.Y - 0.002f * num961;
                                                                                                }
                                                                                                this.ai[0] += 1f;
                                                                                                if (this.ai[0] > 5400f)
                                                                                                {
                                                                                                    this.damage = 0;
                                                                                                    this.ai[1] = 1f;
                                                                                                    if (this.alpha < 255)
                                                                                                    {
                                                                                                        this.alpha += 5;
                                                                                                        if (this.alpha > 255)
                                                                                                        {
                                                                                                            this.alpha = 255;
                                                                                                        }
                                                                                                    }
                                                                                                    else if (this.owner == Main.myPlayer)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    float num963 = (base.Center - Main.player[this.owner].Center).Length() / 100f;
                                                                                                    if (num963 > 4f)
                                                                                                    {
                                                                                                        num963 *= 1.1f;
                                                                                                    }
                                                                                                    if (num963 > 5f)
                                                                                                    {
                                                                                                        num963 *= 1.2f;
                                                                                                    }
                                                                                                    if (num963 > 6f)
                                                                                                    {
                                                                                                        num963 *= 1.3f;
                                                                                                    }
                                                                                                    if (num963 > 7f)
                                                                                                    {
                                                                                                        num963 *= 1.4f;
                                                                                                    }
                                                                                                    if (num963 > 8f)
                                                                                                    {
                                                                                                        num963 *= 1.5f;
                                                                                                    }
                                                                                                    if (num963 > 9f)
                                                                                                    {
                                                                                                        num963 *= 1.6f;
                                                                                                    }
                                                                                                    if (num963 > 10f)
                                                                                                    {
                                                                                                        num963 *= 1.7f;
                                                                                                    }
                                                                                                    if (!Main.player[this.owner].sporeSac)
                                                                                                    {
                                                                                                        num963 += 100f;
                                                                                                    }
                                                                                                    this.ai[0] += num963;
                                                                                                    if (this.alpha > 50)
                                                                                                    {
                                                                                                        this.alpha -= 10;
                                                                                                        if (this.alpha < 50)
                                                                                                        {
                                                                                                            this.alpha = 50;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                bool flag49 = false;
                                                                                                Vector2 center12 = new Vector2(0f, 0f);
                                                                                                float num964 = 280f;
                                                                                                for (int num965 = 0; num965 < 200; num965++)
                                                                                                {
                                                                                                    if (Main.npc[num965].CanBeChasedBy(this, false))
                                                                                                    {
                                                                                                        float num966 = Main.npc[num965].position.X + (float)(Main.npc[num965].width / 2);
                                                                                                        float num967 = Main.npc[num965].position.Y + (float)(Main.npc[num965].height / 2);
                                                                                                        float num968 = Math.Abs(this.position.X + (float)(this.width / 2) - num966) + Math.Abs(this.position.Y + (float)(this.height / 2) - num967);
                                                                                                        if (num968 < num964)
                                                                                                        {
                                                                                                            num964 = num968;
                                                                                                            center12 = Main.npc[num965].Center;
                                                                                                            flag49 = true;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                if (flag49)
                                                                                                {
                                                                                                    Vector2 vector154 = center12 - base.Center;
                                                                                                    vector154.Normalize();
                                                                                                    vector154 *= 0.75f;
                                                                                                    this.velocity = (this.velocity * 10f + vector154) / 11f;
                                                                                                    return;
                                                                                                }
                                                                                                if ((double)this.velocity.Length() > 0.2)
                                                                                                {
                                                                                                    this.velocity *= 0.98f;
                                                                                                    return;
                                                                                                }
                                                                                            }
                                                                                            else if (this.aiStyle == 106)
                                                                                            {
                                                                                                this.rotation += this.velocity.X * 0.02f;
                                                                                                if (this.velocity.X < 0f)
                                                                                                {
                                                                                                    this.rotation -= Math.Abs(this.velocity.Y) * 0.02f;
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    this.rotation += Math.Abs(this.velocity.Y) * 0.02f;
                                                                                                }
                                                                                                this.velocity *= 0.98f;
                                                                                                this.ai[0] += 1f;
                                                                                                if (this.ai[0] >= 60f)
                                                                                                {
                                                                                                    if (this.alpha < 255)
                                                                                                    {
                                                                                                        this.alpha += 5;
                                                                                                        if (this.alpha > 255)
                                                                                                        {
                                                                                                            this.alpha = 255;
                                                                                                            return;
                                                                                                        }
                                                                                                    }
                                                                                                    else if (this.owner == Main.myPlayer)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                                else if (this.alpha > 80)
                                                                                                {
                                                                                                    this.alpha -= 30;
                                                                                                    if (this.alpha < 80)
                                                                                                    {
                                                                                                        this.alpha = 80;
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            else if (this.aiStyle == 107)
                                                                                            {
                                                                                                float num969 = 10f;
                                                                                                float num970 = 5f;
                                                                                                float num971 = 40f;
                                                                                                if (this.type == ProjectileID.NebulaSphere)
                                                                                                {
                                                                                                    if (this.timeLeft > 30 && this.alpha > 0)
                                                                                                    {
                                                                                                        this.alpha -= 25;
                                                                                                    }
                                                                                                    if (this.timeLeft > 30 && this.alpha < 128 && Collision.SolidCollision(this.position, this.width, this.height))
                                                                                                    {
                                                                                                        this.alpha = 128;
                                                                                                    }
                                                                                                    if (this.alpha < 0)
                                                                                                    {
                                                                                                        this.alpha = 0;
                                                                                                    }
                                                                                                    if (++this.frameCounter > 4)
                                                                                                    {
                                                                                                        this.frameCounter = 0;
                                                                                                        if (++this.frame >= 4)
                                                                                                        {
                                                                                                            this.frame = 0;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                else if (this.type == ProjectileID.DesertDjinnCurse)
                                                                                                {
                                                                                                    num969 = 10f;
                                                                                                    num970 = 7.5f;
                                                                                                    if (this.timeLeft > 30 && this.alpha > 0)
                                                                                                    {
                                                                                                        this.alpha -= 25;
                                                                                                    }
                                                                                                    if (this.timeLeft > 30 && this.alpha < 128 && Collision.SolidCollision(this.position, this.width, this.height))
                                                                                                    {
                                                                                                        this.alpha = 128;
                                                                                                    }
                                                                                                    if (this.alpha < 0)
                                                                                                    {
                                                                                                        this.alpha = 0;
                                                                                                    }
                                                                                                    if (++this.frameCounter > 4)
                                                                                                    {
                                                                                                        this.frameCounter = 0;
                                                                                                        if (++this.frame >= 4)
                                                                                                        {
                                                                                                            this.frame = 0;
                                                                                                        }
                                                                                                    }
                                                                                                    this.ai[1] += 1f;
                                                                                                    float arg_282A8_0 = this.ai[1] / 180f;
                                                                                                    for (float num973 = 0f; num973 < 3f; num973 += 1f)
                                                                                                    {
                                                                                                        if (Main.rand.Next(3) != 0)
                                                                                                        {
                                                                                                            return;
                                                                                                        }
                                                                                                    }
                                                                                                    if (this.timeLeft < 4)
                                                                                                    {
                                                                                                        int num974 = 40;
                                                                                                        if (Main.expertMode)
                                                                                                        {
                                                                                                            num974 = 30;
                                                                                                        }
                                                                                                        this.position = base.Center;
                                                                                                        this.width = (this.height = 60);
                                                                                                        base.Center = this.position;
                                                                                                        this.damage = num974;
                                                                                                    }
                                                                                                }
                                                                                                int num976 = (int)this.ai[0];
                                                                                                if (num976 >= 0 && Main.player[num976].active && !Main.player[num976].dead)
                                                                                                {
                                                                                                    if (base.Distance(Main.player[num976].Center) > num971)
                                                                                                    {
                                                                                                        Vector2 vector155 = base.DirectionTo(Main.player[num976].Center);
                                                                                                        if (vector155.HasNaNs())
                                                                                                        {
                                                                                                            vector155 = Vector2.UnitY;
                                                                                                        }
                                                                                                        this.velocity = (this.velocity * (num969 - 1f) + vector155 * num970) / num969;
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    if (this.timeLeft > 30)
                                                                                                    {
                                                                                                        this.timeLeft = 30;
                                                                                                    }
                                                                                                    if (this.ai[0] != -1f)
                                                                                                    {
                                                                                                        this.ai[0] = -1f;
                                                                                                        this.netUpdate = true;
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            else if (this.aiStyle == 108)
                                                                                            {
                                                                                                if (this.type == ProjectileID.VortexVortexLightning && this.localAI[0] == 0f)
                                                                                                {
                                                                                                    this.localAI[0] = 1f;
                                                                                                    int num977 = (int)Player.FindClosest(base.Center, 0, 0);
                                                                                                    Vector2 vector156 = Main.player[num977].Center - base.Center;
                                                                                                    if (vector156 == Vector2.Zero)
                                                                                                    {
                                                                                                        vector156 = Vector2.UnitY;
                                                                                                    }
                                                                                                    this.ai[1] = vector156.ToRotation();
                                                                                                    this.netUpdate = true;
                                                                                                }
                                                                                                this.ai[0] += 1f;
                                                                                                if (this.ai[0] <= 90f)
                                                                                                {
                                                                                                    if (this.type == ProjectileID.VortexVortexPortal)
                                                                                                    {
                                                                                                    }
                                                                                                    if (this.type == ProjectileID.VortexVortexLightning && Main.rand.Next(2) == 0)
                                                                                                    {
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                                else if (this.ai[0] <= 90f)
                                                                                                {
                                                                                                    this.scale = (this.ai[0] - 50f) / 40f;
                                                                                                    this.alpha = 255 - (int)(255f * this.scale);
                                                                                                    this.rotation -= 0.157079637f;
                                                                                                    if (this.type == ProjectileID.VortexVortexLightning)
                                                                                                    {
                                                                                                        if (this.ai[0] == 90f && Main.netMode != 1)
                                                                                                        {
                                                                                                            Vector2 vector168 = this.ai[1].ToRotationVector2() * 8f;
                                                                                                            float ai2 = (float)Main.rand.Next(80);
                                                                                                            Projectile.NewProjectile(base.Center.X - vector168.X, base.Center.Y - vector168.Y, vector168.X, vector168.Y, 580, 15, 1f, Main.myPlayer, this.ai[1], ai2);
                                                                                                            return;
                                                                                                        }
                                                                                                    }
                                                                                                    else if (this.type == ProjectileID.VortexVortexPortal && this.ai[0] == 90f && Main.netMode != 1)
                                                                                                    {
                                                                                                        for (int num980 = 0; num980 < 2; num980++)
                                                                                                        {
                                                                                                            int num981 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 427, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                                                                            Main.npc[num981].velocity = -Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (float)Main.rand.Next(4, 9) - Vector2.UnitY * 2f;
                                                                                                            Main.npc[num981].netUpdate = true;
                                                                                                        }
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    if (this.ai[0] > 120f)
                                                                                                    {
                                                                                                        this.scale = 1f - (this.ai[0] - 120f) / 60f;
                                                                                                        this.alpha = 255 - (int)(255f * this.scale);
                                                                                                        this.rotation -= 0.104719758f;
                                                                                                        if (this.alpha >= 255)
                                                                                                        {
                                                                                                            this.Kill();
                                                                                                        }
                                                                                                        return;
                                                                                                    }
                                                                                                    this.scale = 1f;
                                                                                                    this.alpha = 0;
                                                                                                    this.rotation -= 0.05235988f;
                                                                                                    return;
                                                                                                }
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if (this.aiStyle == 109)
                                                                                                {
                                                                                                    if (this.localAI[1] == 0f)
                                                                                                    {
                                                                                                        this.localAI[1] = this.velocity.Length();
                                                                                                    }
                                                                                                    if (this.ai[0] == 0f)
                                                                                                    {
                                                                                                        this.localAI[0] += 1f;
                                                                                                        if (this.localAI[0] > 30f)
                                                                                                        {
                                                                                                            this.ai[0] = 1f;
                                                                                                            this.localAI[0] = 0f;
                                                                                                            return;
                                                                                                        }
                                                                                                    }
                                                                                                    else if (this.ai[0] == 1f)
                                                                                                    {
                                                                                                        Vector2 vector173 = Vector2.Zero;
                                                                                                        if (this.type != ProjectileID.MechanicWrench || !Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].type != 124)
                                                                                                        {
                                                                                                            this.Kill();
                                                                                                            return;
                                                                                                        }
                                                                                                        vector173 = Main.npc[(int)this.ai[1]].Center;
                                                                                                        this.tileCollide = false;
                                                                                                        float num984 = this.localAI[1];
                                                                                                        Vector2 vector174 = vector173 - base.Center;
                                                                                                        if (vector174.Length() < num984)
                                                                                                        {
                                                                                                            this.Kill();
                                                                                                            return;
                                                                                                        }
                                                                                                        vector174.Normalize();
                                                                                                        vector174 *= num984;
                                                                                                        this.velocity = Vector2.Lerp(this.velocity, vector174, 0.04f);
                                                                                                    }
                                                                                                    this.rotation += 0.314159274f;
                                                                                                    return;
                                                                                                }
                                                                                                if (this.aiStyle == 110)
                                                                                                {
                                                                                                    if (this.localAI[1] == 0f)
                                                                                                    {
                                                                                                        this.localAI[1] = this.velocity.Length();
                                                                                                    }
                                                                                                    Vector2 vector175 = Vector2.Zero;
                                                                                                    if (!Main.npc[(int)this.ai[0]].active || !Main.npc[(int)this.ai[0]].townNPC)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                        return;
                                                                                                    }
                                                                                                    vector175 = Main.npc[(int)this.ai[0]].Center;
                                                                                                    float num985 = this.localAI[1];
                                                                                                    Vector2 vector176 = vector175 - base.Center;
                                                                                                    if (vector176.Length() < num985 || base.Hitbox.Intersects(Main.npc[(int)this.ai[0]].Hitbox))
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                        int num986 = Main.npc[(int)this.ai[0]].lifeMax - Main.npc[(int)this.ai[0]].life;
                                                                                                        if (num986 > 20)
                                                                                                        {
                                                                                                            num986 = 20;
                                                                                                        }
                                                                                                        if (num986 > 0)
                                                                                                        {
                                                                                                            Main.npc[(int)this.ai[0]].life += num986;
                                                                                                            Main.npc[(int)this.ai[0]].HealEffect(num986, true);
                                                                                                        }
                                                                                                        return;
                                                                                                    }
                                                                                                    vector176.Normalize();
                                                                                                    vector176 *= num985;
                                                                                                    if (vector176.Y < this.velocity.Y)
                                                                                                    {
                                                                                                        vector176.Y = this.velocity.Y;
                                                                                                    }
                                                                                                    vector176.Y += 1f;
                                                                                                    this.velocity = Vector2.Lerp(this.velocity, vector176, 0.04f);
                                                                                                    this.rotation += this.velocity.X * 0.05f;
                                                                                                    return;
                                                                                                }
                                                                                                else if (this.aiStyle == 111)
                                                                                                {
                                                                                                    if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].type != 20 || Main.npc[(int)this.ai[1]].ai[0] != 14f)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                        return;
                                                                                                    }
                                                                                                    this.ai[0] += 1f;
                                                                                                    this.rotation += 0.0104719754f;
                                                                                                    this.scale = this.ai[0] / 100f;
                                                                                                    if (this.scale > 1f)
                                                                                                    {
                                                                                                        this.scale = 1f;
                                                                                                    }
                                                                                                    this.alpha = (int)(255f * (1f - this.scale));
                                                                                                    float num987 = 300f;
                                                                                                    if (this.ai[0] >= 100f)
                                                                                                    {
                                                                                                        num987 = MathHelper.Lerp(300f, 600f, (this.ai[0] - 100f) / 200f);
                                                                                                    }
                                                                                                    if (num987 > 600f)
                                                                                                    {
                                                                                                        num987 = 600f;
                                                                                                    }
                                                                                                    if (this.ai[0] >= 500f)
                                                                                                    {
                                                                                                        this.alpha = (int)MathHelper.Lerp(0f, 255f, (this.ai[0] - 500f) / 100f);
                                                                                                        num987 = MathHelper.Lerp(600f, 1200f, (this.ai[0] - 500f) / 100f);
                                                                                                        this.rotation += 0.0104719754f;
                                                                                                    }
                                                                                                    if (this.ai[0] >= 30f && Main.netMode != 2)
                                                                                                    {
                                                                                                        Player player6 = Main.player[Main.myPlayer];
                                                                                                        if (player6.active && !player6.dead && base.Distance(player6.Center) <= num987 && player6.HasBuff(BuffID.DryadsWard) == -1)
                                                                                                        {
                                                                                                            player6.AddBuff(BuffID.DryadsWard, 120, true);
                                                                                                        }
                                                                                                    }
                                                                                                    if (this.ai[0] >= 30f && this.ai[0] % 10f == 0f && Main.netMode != 1)
                                                                                                    {
                                                                                                        for (int num993 = 0; num993 < 200; num993++)
                                                                                                        {
                                                                                                            NPC nPC10 = Main.npc[num993];
                                                                                                            if (nPC10.type != 488 && nPC10.active && base.Distance(nPC10.Center) <= num987)
                                                                                                            {
                                                                                                                if (nPC10.townNPC && (nPC10.HasBuff(BuffID.DryadsWard) == -1 || nPC10.buffTime[nPC10.HasBuff(BuffID.DryadsWard)] <= 20))
                                                                                                                {
                                                                                                                    nPC10.AddBuff(BuffID.DryadsWard, 120, false);
                                                                                                                }
                                                                                                                else if (!nPC10.friendly && nPC10.lifeMax > 5 && !nPC10.dontTakeDamage && (nPC10.HasBuff(BuffID.DryadsWardDebuff) == -1 || nPC10.buffTime[nPC10.HasBuff(BuffID.DryadsWardDebuff)] <= 20) && (nPC10.dryadBane || Collision.CanHit(base.Center, 1, 1, nPC10.position, nPC10.width, nPC10.height)))
                                                                                                                {
                                                                                                                    nPC10.AddBuff(BuffID.DryadsWardDebuff, 120, false);
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                    if (this.ai[0] >= 570f)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                        return;
                                                                                                    }
                                                                                                }
                                                                                                else if (this.aiStyle == 112)
                                                                                                {
                                                                                                    if (this.type == ProjectileID.TruffleSpore)
                                                                                                    {
                                                                                                        if (++this.frameCounter >= 4)
                                                                                                        {
                                                                                                            this.frameCounter = 0;
                                                                                                            if (++this.frame >= 3)
                                                                                                            {
                                                                                                                this.frame = 0;
                                                                                                            }
                                                                                                        }
                                                                                                        if (this.alpha > 0)
                                                                                                        {
                                                                                                            this.alpha -= 15;
                                                                                                        }
                                                                                                        if (this.alpha < 0)
                                                                                                        {
                                                                                                            this.alpha = 0;
                                                                                                        }
                                                                                                        this.velocity = new Vector2(0f, (float)Math.Sin((double)(6.28318548f * this.ai[0] / 180f)) * 0.15f);
                                                                                                        this.ai[0] += 1f;
                                                                                                        if (this.ai[0] >= 180f)
                                                                                                        {
                                                                                                            this.ai[0] = 0f;
                                                                                                        }
                                                                                                    }
                                                                                                    if (this.type == ProjectileID.RainbowCrystalExplosion)
                                                                                                    {
                                                                                                        Color newColor2 = Main.HslToRgb(this.ai[0], 1f, 0.5f);
                                                                                                        int num999 = (int)this.ai[1];
                                                                                                        if (num999 < 0 || num999 >= 1000 || (!Main.projectile[num999].active && Main.projectile[num999].type != ProjectileID.RainbowCrystal))
                                                                                                        {
                                                                                                            this.ai[1] = -1f;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            DelegateMethods.v3_1 = newColor2.ToVector3() * 0.5f;
                                                                                                        }
                                                                                                        if (this.localAI[0] == 0f)
                                                                                                        {
                                                                                                            this.localAI[0] = Main.rand.NextFloat() * 0.8f + 0.8f;
                                                                                                            this.direction = ((Main.rand.Next(2) > 0) ? 1 : -1);
                                                                                                        }
                                                                                                        this.rotation = this.localAI[1] / 40f * 6.28318548f * (float)this.direction;
                                                                                                        if (this.alpha > 0)
                                                                                                        {
                                                                                                            this.alpha -= 8;
                                                                                                        }
                                                                                                        if (this.alpha < 0)
                                                                                                        {
                                                                                                            this.alpha = 0;
                                                                                                        }
                                                                                                        if (Main.rand.Next(10) == 0)
                                                                                                        {
                                                                                                            float num1002 = 1f + Main.rand.NextFloat() * 2f;
                                                                                                            float fadeIn = 1f + Main.rand.NextFloat();
                                                                                                            float num1003 = 1f + Main.rand.NextFloat();
                                                                                                            Vector2 vector181 = Utils.RandomVector2(Main.rand, -1f, 1f);
                                                                                                            if (vector181 != Vector2.Zero)
                                                                                                            {
                                                                                                                vector181.Normalize();
                                                                                                            }
                                                                                                            vector181 *= 20f + Main.rand.NextFloat() * 100f;
                                                                                                            Vector2 vector182 = base.Center + vector181;
                                                                                                            Point point3 = vector182.ToTileCoordinates();
                                                                                                            bool flag50 = true;
                                                                                                            if (!WorldGen.InWorld(point3.X, point3.Y, 0))
                                                                                                            {
                                                                                                                flag50 = false;
                                                                                                            }
                                                                                                            if (flag50 && WorldGen.SolidTile(point3.X, point3.Y))
                                                                                                            {
                                                                                                                flag50 = false;
                                                                                                            }
                                                                                                        }
                                                                                                        this.scale = this.Opacity / 2f * this.localAI[0];
                                                                                                        this.velocity = Vector2.Zero;
                                                                                                        this.localAI[1] += 1f;
                                                                                                        if (this.localAI[1] >= 60f)
                                                                                                        {
                                                                                                            this.Kill();
                                                                                                            return;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                else if (this.aiStyle == 113)
                                                                                                {
                                                                                                    int num1004 = 25;
                                                                                                    if (this.type == ProjectileID.StardustCellMinionShot)
                                                                                                    {
                                                                                                        num1004 = 63;
                                                                                                    }
                                                                                                    if (this.alpha > 0)
                                                                                                    {
                                                                                                        this.alpha -= num1004;
                                                                                                    }
                                                                                                    if (this.alpha < 0)
                                                                                                    {
                                                                                                        this.alpha = 0;
                                                                                                    }
                                                                                                    if (this.ai[0] == 0f)
                                                                                                    {
                                                                                                        bool flag51 = this.type == ProjectileID.StardustCellMinionShot;
                                                                                                        if (flag51)
                                                                                                        {
                                                                                                            int num1005 = (int)this.ai[1];
                                                                                                            if (!Main.npc[num1005].active)
                                                                                                            {
                                                                                                                this.Kill();
                                                                                                                return;
                                                                                                            }
                                                                                                            this.velocity.ToRotation();
                                                                                                            Vector2 vector183 = Main.npc[num1005].Center - base.Center;
                                                                                                            if (vector183 != Vector2.Zero)
                                                                                                            {
                                                                                                                vector183.Normalize();
                                                                                                                vector183 *= 14f;
                                                                                                            }
                                                                                                            float num1006 = 5f;
                                                                                                            this.velocity = (this.velocity * (num1006 - 1f) + vector183) / num1006;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            this.ai[1] += 1f;
                                                                                                            if (this.ai[1] >= 45f)
                                                                                                            {
                                                                                                                float num1007 = 0.98f;
                                                                                                                float num1008 = 0.35f;
                                                                                                                if (this.type == ProjectileID.Daybreak)
                                                                                                                {
                                                                                                                    num1007 = 0.995f;
                                                                                                                    num1008 = 0.15f;
                                                                                                                }
                                                                                                                this.ai[1] = 45f;
                                                                                                                this.velocity.X = this.velocity.X * num1007;
                                                                                                                this.velocity.Y = this.velocity.Y + num1008;
                                                                                                            }
                                                                                                            this.rotation = this.velocity.ToRotation() + 1.57079637f;
                                                                                                        }
                                                                                                    }
                                                                                                    if (this.ai[0] == 1f)
                                                                                                    {
                                                                                                        this.ignoreWater = true;
                                                                                                        this.tileCollide = false;
                                                                                                        int num1009 = 15;
                                                                                                        if (this.type == ProjectileID.Daybreak)
                                                                                                        {
                                                                                                            num1009 = 5 * this.MaxUpdates;
                                                                                                        }
                                                                                                        bool flag52 = false;
                                                                                                        bool flag53 = false;
                                                                                                        this.localAI[0] += 1f;
                                                                                                        if (this.localAI[0] % 30f == 0f)
                                                                                                        {
                                                                                                            flag53 = true;
                                                                                                        }
                                                                                                        int num1010 = (int)this.ai[1];
                                                                                                        if (this.localAI[0] >= (float)(60 * num1009))
                                                                                                        {
                                                                                                            flag52 = true;
                                                                                                        }
                                                                                                        else if (num1010 < 0 || num1010 >= 200)
                                                                                                        {
                                                                                                            flag52 = true;
                                                                                                        }
                                                                                                        else if (Main.npc[num1010].active && !Main.npc[num1010].dontTakeDamage)
                                                                                                        {
                                                                                                            base.Center = Main.npc[num1010].Center - this.velocity * 2f;
                                                                                                            this.gfxOffY = Main.npc[num1010].gfxOffY;
                                                                                                            if (flag53)
                                                                                                            {
                                                                                                                Main.npc[num1010].HitEffect(0, 1.0);
                                                                                                            }
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            flag52 = true;
                                                                                                        }
                                                                                                        if (flag52)
                                                                                                        {
                                                                                                            this.Kill();
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                else if (this.aiStyle == 114)
                                                                                                {
                                                                                                    if (Main.netMode == 2 && this.localAI[0] == 0f)
                                                                                                    {
                                                                                                        PortalHelper.SyncPortalSections(base.Center, 1);
                                                                                                        this.localAI[0] = 1f;
                                                                                                    }
                                                                                                    this.timeLeft = 3;
                                                                                                    bool flag54 = false;
                                                                                                    if (!Main.player[this.owner].active || Main.player[this.owner].dead || base.Distance(Main.player[this.owner].Center) > 12800f)
                                                                                                    {
                                                                                                        flag54 = true;
                                                                                                    }
                                                                                                    if (!flag54 && !WorldGen.InWorld((int)base.Center.X / 16, (int)base.Center.Y / 16))
                                                                                                    {
                                                                                                        flag54 = true;
                                                                                                    }
                                                                                                    if (!flag54 && !PortalHelper.SupportedTilesAreFine(base.Center, this.ai[0]))
                                                                                                    {
                                                                                                        flag54 = true;
                                                                                                    }
                                                                                                    if (flag54)
                                                                                                    {
                                                                                                        this.Kill();
                                                                                                        return;
                                                                                                    }
                                                                                                    Color portalColor = PortalHelper.GetPortalColor(this.owner, (int)this.ai[1]);
                                                                                                    this.alpha -= 25;
                                                                                                    if (this.alpha < 0)
                                                                                                    {
                                                                                                        this.alpha = 0;
                                                                                                    }
                                                                                                    if (++this.frameCounter >= 6)
                                                                                                    {
                                                                                                        this.frameCounter = 0;
                                                                                                        if (++this.frame >= Main.projFrames[this.type])
                                                                                                        {
                                                                                                            this.frame = 0;
                                                                                                        }
                                                                                                    }
                                                                                                    this.rotation = this.ai[0] - 1.57079637f;
                                                                                                    return;
                                                                                                }
                                                                                                else if (this.aiStyle == 115)
                                                                                                {
                                                                                                    this.velocity *= 0.985f;
                                                                                                    this.rotation += this.velocity.X * 0.2f;
                                                                                                    if (this.velocity.X > 0f)
                                                                                                    {
                                                                                                        this.rotation += 0.08f;
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        this.rotation -= 0.08f;
                                                                                                    }
                                                                                                    this.ai[1] += 1f;
                                                                                                    if (this.ai[1] > 30f)
                                                                                                    {
                                                                                                        this.alpha += 10;
                                                                                                        if (this.alpha >= 255)
                                                                                                        {
                                                                                                            this.alpha = 255;
                                                                                                            this.Kill();
                                                                                                            return;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    if (this.aiStyle == 116)
                                                                                                    {
                                                                                                        if (this.localAI[0] == 0f)
                                                                                                        {
                                                                                                            this.rotation = this.ai[1];
                                                                                                            this.localAI[0] = 1f;
                                                                                                        }
                                                                                                        Player player7 = Main.player[this.owner];
                                                                                                        if (player7.setSolar)
                                                                                                        {
                                                                                                            this.timeLeft = 2;
                                                                                                        }
                                                                                                        float num1011 = (float)player7.miscCounter / 300f * 12.566371f + this.ai[1];
                                                                                                        num1011 = MathHelper.WrapAngle(num1011);
                                                                                                        this.rotation = this.rotation.AngleLerp(num1011, 0.05f);
                                                                                                        this.alpha -= 15;
                                                                                                        if (this.alpha < 0)
                                                                                                        {
                                                                                                            this.alpha = 0;
                                                                                                        }
                                                                                                        this.velocity = this.rotation.ToRotationVector2() * 100f - player7.velocity;
                                                                                                        base.Center = player7.Center - this.velocity;
                                                                                                        return;
                                                                                                    }
                                                                                                    if (this.aiStyle == 117)
                                                                                                    {
                                                                                                        this.ai[1] += 0.01f;
                                                                                                        this.scale = this.ai[1];
                                                                                                        this.ai[0] += 1f;
                                                                                                        if (this.ai[0] >= (float)(3 * Main.projFrames[this.type]))
                                                                                                        {
                                                                                                            this.Kill();
                                                                                                            return;
                                                                                                        }
                                                                                                        if (++this.frameCounter >= 3)
                                                                                                        {
                                                                                                            this.frameCounter = 0;
                                                                                                            if (++this.frame >= Main.projFrames[this.type])
                                                                                                            {
                                                                                                                this.hide = true;
                                                                                                            }
                                                                                                        }
                                                                                                        this.alpha -= 63;
                                                                                                        if (this.alpha < 0)
                                                                                                        {
                                                                                                            this.alpha = 0;
                                                                                                        }
                                                                                                        bool flag55 = this.type == ProjectileID.SolarWhipSwordExplosion;
                                                                                                        bool flag56 = this.type == ProjectileID.StardustGuardianExplosion;
                                                                                                        if (this.ai[0] == 1f)
                                                                                                        {
                                                                                                            this.position = base.Center;
                                                                                                            this.width = (this.height = (int)(52f * this.scale));
                                                                                                            base.Center = this.position;
                                                                                                            this.Damage();
                                                                                                            if (flag55)
                                                                                                            {
                                                                                                                if (flag56)
                                                                                                                {
                                                                                                                    return;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                        else if (this.aiStyle == 118)
                                                                                                        {
                                                                                                            this.ai[0] += 1f;
                                                                                                            int num1035 = 0;
                                                                                                            if (this.velocity.Length() <= 4f)
                                                                                                            {
                                                                                                                num1035 = 1;
                                                                                                            }
                                                                                                            this.alpha -= 15;
                                                                                                            if (this.alpha < 0)
                                                                                                            {
                                                                                                                this.alpha = 0;
                                                                                                            }
                                                                                                            if (num1035 == 0)
                                                                                                            {
                                                                                                                this.rotation -= 0.104719758f;
                                                                                                                if (this.ai[0] >= 30f)
                                                                                                                {
                                                                                                                    this.velocity *= 0.98f;
                                                                                                                    this.scale += 0.00744680827f;
                                                                                                                    if (this.scale > 1.3f)
                                                                                                                    {
                                                                                                                        this.scale = 1.3f;
                                                                                                                    }
                                                                                                                    this.rotation -= 0.0174532924f;
                                                                                                                }
                                                                                                                if (this.velocity.Length() < 4.1f)
                                                                                                                {
                                                                                                                    this.velocity.Normalize();
                                                                                                                    this.velocity *= 4f;
                                                                                                                    this.ai[0] = 0f;
                                                                                                                }
                                                                                                            }
                                                                                                            else if (num1035 == 1)
                                                                                                            {
                                                                                                                this.rotation -= 0.104719758f;
                                                                                                                if (this.ai[0] % 30f == 0f && this.ai[0] < 241f && Main.myPlayer == this.owner)
                                                                                                                {
                                                                                                                    Vector2 vector189 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * 12f;
                                                                                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, vector189.X, vector189.Y, 618, this.damage / 2, 0f, this.owner, 0f, (float)this.whoAmI);
                                                                                                                }
                                                                                                                Vector2 vector190 = base.Center;
                                                                                                                float num1037 = 800f;
                                                                                                                bool flag57 = false;
                                                                                                                int num1038 = 0;
                                                                                                                if (this.ai[1] == 0f)
                                                                                                                {
                                                                                                                    for (int num1039 = 0; num1039 < 200; num1039++)
                                                                                                                    {
                                                                                                                        if (Main.npc[num1039].CanBeChasedBy(this, false))
                                                                                                                        {
                                                                                                                            Vector2 center13 = Main.npc[num1039].Center;
                                                                                                                            if (base.Distance(center13) < num1037 && Collision.CanHit(new Vector2(this.position.X + (float)(this.width / 2), this.position.Y + (float)(this.height / 2)), 1, 1, Main.npc[num1039].position, Main.npc[num1039].width, Main.npc[num1039].height))
                                                                                                                            {
                                                                                                                                num1037 = base.Distance(center13);
                                                                                                                                vector190 = center13;
                                                                                                                                flag57 = true;
                                                                                                                                num1038 = num1039;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                    if (flag57)
                                                                                                                    {
                                                                                                                        if (this.ai[1] != (float)(num1038 + 1))
                                                                                                                        {
                                                                                                                            this.netUpdate = true;
                                                                                                                        }
                                                                                                                        this.ai[1] = (float)(num1038 + 1);
                                                                                                                    }
                                                                                                                    flag57 = false;
                                                                                                                }
                                                                                                                if (this.ai[1] != 0f)
                                                                                                                {
                                                                                                                    int num1040 = (int)(this.ai[1] - 1f);
                                                                                                                    if (Main.npc[num1040].active && Main.npc[num1040].CanBeChasedBy(this, true) && base.Distance(Main.npc[num1040].Center) < 1000f)
                                                                                                                    {
                                                                                                                        flag57 = true;
                                                                                                                        vector190 = Main.npc[num1040].Center;
                                                                                                                    }
                                                                                                                }
                                                                                                                if (!this.friendly)
                                                                                                                {
                                                                                                                    flag57 = false;
                                                                                                                }
                                                                                                                if (flag57)
                                                                                                                {
                                                                                                                    float num1041 = 4f;
                                                                                                                    Vector2 vector191 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                                                                                    float num1042 = vector190.X - vector191.X;
                                                                                                                    float num1043 = vector190.Y - vector191.Y;
                                                                                                                    float num1044 = (float)Math.Sqrt((double)(num1042 * num1042 + num1043 * num1043));
                                                                                                                    num1044 = num1041 / num1044;
                                                                                                                    num1042 *= num1044;
                                                                                                                    num1043 *= num1044;
                                                                                                                    int num1045 = 8;
                                                                                                                    this.velocity.X = (this.velocity.X * (float)(num1045 - 1) + num1042) / (float)num1045;
                                                                                                                    this.velocity.Y = (this.velocity.Y * (float)(num1045 - 1) + num1043) / (float)num1045;
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.ai[0] >= 600f)
                                                                                                            {
                                                                                                                this.Kill();
                                                                                                                return;
                                                                                                            }
                                                                                                        }
                                                                                                        else if (this.aiStyle == 119)
                                                                                                        {
                                                                                                            int num1046 = 0;
                                                                                                            float num1047 = 0f;
                                                                                                            float num1048 = 0f;
                                                                                                            float num1049 = 0f;
                                                                                                            bool flag58 = false;
                                                                                                            bool flag59 = false;
                                                                                                            int num655 = this.type;
                                                                                                            if (num655 == 618)
                                                                                                            {
                                                                                                                num1046 = 617;
                                                                                                                num1047 = 420f;
                                                                                                                num1048 = 0.15f;
                                                                                                                num1049 = 0.15f;
                                                                                                            }
                                                                                                            if (flag59)
                                                                                                            {
                                                                                                                int num1050 = (int)this.ai[1];
                                                                                                                if (!Main.projectile[num1050].active || Main.projectile[num1050].type != num1046)
                                                                                                                {
                                                                                                                    this.Kill();
                                                                                                                    return;
                                                                                                                }
                                                                                                                this.timeLeft = 2;
                                                                                                            }
                                                                                                            this.ai[0] += 1f;
                                                                                                            if (this.ai[0] < num1047)
                                                                                                            {
                                                                                                                bool flag60 = true;
                                                                                                                int num1051 = (int)this.ai[1];
                                                                                                                if (Main.projectile[num1051].active && Main.projectile[num1051].type == num1046)
                                                                                                                {
                                                                                                                    if (!flag58 && Main.projectile[num1051].oldPos[1] != Vector2.Zero)
                                                                                                                    {
                                                                                                                        this.position += Main.projectile[num1051].position - Main.projectile[num1051].oldPos[1];
                                                                                                                    }
                                                                                                                    if (base.Center.HasNaNs())
                                                                                                                    {
                                                                                                                        this.Kill();
                                                                                                                        return;
                                                                                                                    }
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    this.ai[0] = num1047;
                                                                                                                    flag60 = false;
                                                                                                                    this.Kill();
                                                                                                                }
                                                                                                                if (flag60 && !flag58)
                                                                                                                {
                                                                                                                    this.velocity += new Vector2((float)Math.Sign(Main.projectile[num1051].Center.X - base.Center.X), (float)Math.Sign(Main.projectile[num1051].Center.Y - base.Center.Y)) * new Vector2(num1048, num1049);
                                                                                                                    if (this.velocity.Length() > 6f)
                                                                                                                    {
                                                                                                                        this.velocity *= 6f / this.velocity.Length();
                                                                                                                    }
                                                                                                                }
                                                                                                                if (this.type == ProjectileID.NebulaArcanumSubshot)
                                                                                                                {
                                                                                                                    this.alpha = 255;
                                                                                                                    return;
                                                                                                                }
                                                                                                                this.Kill();
                                                                                                                return;
                                                                                                            }
                                                                                                        }
                                                                                                        else if (this.aiStyle == 120)
                                                                                                        {
                                                                                                            Player player8 = Main.player[this.owner];
                                                                                                            if (!player8.active)
                                                                                                            {
                                                                                                                this.active = false;
                                                                                                                return;
                                                                                                            }
                                                                                                            bool flag61 = this.type == ProjectileID.StardustGuardian;
                                                                                                            Vector2 vector192 = player8.Center;
                                                                                                            float num1053 = 100f;
                                                                                                            float num1054 = 300f;
                                                                                                            float num1055 = 100f;
                                                                                                            float num1056 = 100f;
                                                                                                            if (flag61)
                                                                                                            {
                                                                                                                if (player8.dead)
                                                                                                                {
                                                                                                                    player8.stardustGuardian = false;
                                                                                                                }
                                                                                                                if (player8.stardustGuardian)
                                                                                                                {
                                                                                                                    this.timeLeft = 2;
                                                                                                                }
                                                                                                                num1053 = 150f;
                                                                                                                num1054 = 250f;
                                                                                                                num1055 = 200f;
                                                                                                                vector192.X -= (float)((5 + player8.width / 2) * player8.direction);
                                                                                                                vector192.Y -= 25f;
                                                                                                                if (this.ai[0] != 3f && this.alpha == 255)
                                                                                                                {
                                                                                                                    this.alpha = 0;
                                                                                                                }
                                                                                                                if (this.localAI[0] > 0f)
                                                                                                                {
                                                                                                                    this.localAI[0] -= 1f;
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.ai[0] != 0f)
                                                                                                            {
                                                                                                                Main.player[this.owner].tankPet = this.whoAmI;
                                                                                                                Main.player[this.owner].tankPetReset = false;
                                                                                                            }
                                                                                                            if (this.ai[0] == 0f)
                                                                                                            {
                                                                                                                if (player8.HasMinionTarget)
                                                                                                                {
                                                                                                                    this.ai[0] = 3f;
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                                base.Center = Vector2.Lerp(base.Center, vector192, 0.2f);
                                                                                                                this.velocity *= 0.8f;
                                                                                                                this.direction = (this.spriteDirection = player8.direction);
                                                                                                                if (flag61 && ++this.frameCounter >= 9)
                                                                                                                {
                                                                                                                    this.frameCounter = 0;
                                                                                                                    if (++this.frame >= Main.projFrames[this.type] - 4)
                                                                                                                    {
                                                                                                                        this.frame = 0;
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            else if (this.ai[0] == 1f)
                                                                                                            {
                                                                                                                if (player8.HasMinionTarget)
                                                                                                                {
                                                                                                                    vector192 = player8.MinionTargetPoint;
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    this.ai[0] = 0f;
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                                int num1059 = -1;
                                                                                                                bool flag62 = true;
                                                                                                                if (flag61 && Math.Abs(base.Center.X - vector192.X) > num1053 + 20f)
                                                                                                                {
                                                                                                                    flag62 = false;
                                                                                                                }
                                                                                                                if (flag62)
                                                                                                                {
                                                                                                                    for (int num1060 = 0; num1060 < 200; num1060++)
                                                                                                                    {
                                                                                                                        NPC nPC11 = Main.npc[num1060];
                                                                                                                        if (nPC11.CanBeChasedBy(this, false))
                                                                                                                        {
                                                                                                                            float num1061 = base.Distance(nPC11.Center);
                                                                                                                            if (num1061 < num1054)
                                                                                                                            {
                                                                                                                                num1059 = num1060;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                if (num1059 != -1)
                                                                                                                {
                                                                                                                    NPC nPC12 = Main.npc[num1059];
                                                                                                                    this.direction = (this.spriteDirection = (nPC12.Center.X > base.Center.X).ToDirectionInt());
                                                                                                                    float num1062 = Math.Abs(vector192.X - base.Center.X);
                                                                                                                    float num1063 = Math.Abs(nPC12.Center.X - base.Center.X);
                                                                                                                    float num1064 = Math.Abs(vector192.Y - base.Center.Y);
                                                                                                                    float num1065 = Math.Abs(nPC12.Center.Y - base.Bottom.Y);
                                                                                                                    float num1066 = (float)(nPC12.Center.Y > base.Bottom.Y).ToDirectionInt();
                                                                                                                    if ((num1062 < num1053 || (vector192.X - base.Center.X) * (float)this.direction < 0f) && num1063 > 20f && num1063 < num1053 - num1062 + 100f)
                                                                                                                    {
                                                                                                                        this.velocity.X = this.velocity.X + 0.1f * (float)this.direction;
                                                                                                                    }
                                                                                                                    else
                                                                                                                    {
                                                                                                                        this.velocity.X = this.velocity.X * 0.7f;
                                                                                                                    }
                                                                                                                    if ((num1064 < num1056 || (vector192.Y - base.Bottom.Y) * num1066 < 0f) && num1065 > 10f && num1065 < num1056 - num1064 + 10f)
                                                                                                                    {
                                                                                                                        this.velocity.Y = this.velocity.Y + 0.1f * num1066;
                                                                                                                    }
                                                                                                                    else
                                                                                                                    {
                                                                                                                        this.velocity.Y = this.velocity.Y * 0.7f;
                                                                                                                    }
                                                                                                                    if (this.localAI[0] == 0f && this.owner == Main.myPlayer && num1063 < num1055)
                                                                                                                    {
                                                                                                                        this.ai[1] = 0f;
                                                                                                                        this.ai[0] = 2f;
                                                                                                                        this.netUpdate = true;
                                                                                                                        this.localAI[0] = 90f;
                                                                                                                    }
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    if (Math.Abs(vector192.X - base.Center.X) > num1053 + 40f)
                                                                                                                    {
                                                                                                                        this.ai[0] = 3f;
                                                                                                                        this.netUpdate = true;
                                                                                                                    }
                                                                                                                    else if (Math.Abs(vector192.X - base.Center.X) > 20f)
                                                                                                                    {
                                                                                                                        this.direction = (this.spriteDirection = (vector192.X > base.Center.X).ToDirectionInt());
                                                                                                                        this.velocity.X = this.velocity.X + 0.06f * (float)this.direction;
                                                                                                                    }
                                                                                                                    else
                                                                                                                    {
                                                                                                                        this.velocity.X = this.velocity.X * 0.8f;
                                                                                                                        this.direction = (this.spriteDirection = (player8.Center.X < base.Center.X).ToDirectionInt());
                                                                                                                    }
                                                                                                                    if (Math.Abs(vector192.Y - base.Center.Y) > num1056)
                                                                                                                    {
                                                                                                                        this.ai[0] = 3f;
                                                                                                                        this.netUpdate = true;
                                                                                                                    }
                                                                                                                    else if (Math.Abs(vector192.Y - base.Center.Y) > 10f)
                                                                                                                    {
                                                                                                                        this.velocity.Y = this.velocity.Y + 0.06f * (float)Math.Sign(vector192.Y - base.Center.Y);
                                                                                                                    }
                                                                                                                    else
                                                                                                                    {
                                                                                                                        this.velocity.Y = this.velocity.Y * 0.8f;
                                                                                                                    }
                                                                                                                }
                                                                                                                if (flag61 && ++this.frameCounter >= 9)
                                                                                                                {
                                                                                                                    this.frameCounter = 0;
                                                                                                                    if (++this.frame >= Main.projFrames[this.type] - 4)
                                                                                                                    {
                                                                                                                        this.frame = 0;
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            else if (this.ai[0] == 2f)
                                                                                                            {
                                                                                                                this.velocity.X = this.velocity.X * 0.9f;
                                                                                                                this.ai[1] += 1f;
                                                                                                                float num1067 = 0f;
                                                                                                                if (flag61)
                                                                                                                {
                                                                                                                    num1067 = 20f;
                                                                                                                    if (this.ai[1] == 10f && this.owner == Main.myPlayer)
                                                                                                                    {
                                                                                                                        int num1068 = (int)(20f * Main.player[this.owner].minionDamage);
                                                                                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, 0f, 0f, 624, num1068, 6f, this.owner, 0f, 5f);
                                                                                                                    }
                                                                                                                }
                                                                                                                if (this.ai[1] >= num1067)
                                                                                                                {
                                                                                                                    this.ai[1] = 0f;
                                                                                                                    this.ai[0] = 1f;
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                                if (flag61)
                                                                                                                {
                                                                                                                    if (this.frame < Main.projFrames[this.type] - 4)
                                                                                                                    {
                                                                                                                        this.frame = Main.projFrames[this.type] - 1;
                                                                                                                        this.frameCounter = 0;
                                                                                                                    }
                                                                                                                    if (++this.frameCounter >= 5)
                                                                                                                    {
                                                                                                                        this.frameCounter = 0;
                                                                                                                        if (--this.frame < Main.projFrames[this.type] - 5)
                                                                                                                        {
                                                                                                                            this.frame = Main.projFrames[this.type] - 1;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.ai[0] == 3f)
                                                                                                            {
                                                                                                                if (player8.HasMinionTarget)
                                                                                                                {
                                                                                                                    vector192 = player8.MinionTargetPoint;
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    this.ai[0] = 0f;
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                                if (this.alpha == 0)
                                                                                                                {
                                                                                                                    this.alpha = 255;
                                                                                                                }
                                                                                                                this.velocity *= 0.7f;
                                                                                                                base.Center = Vector2.Lerp(base.Center, vector192, 0.2f);
                                                                                                                if (base.Distance(vector192) < 10f)
                                                                                                                {
                                                                                                                    this.ai[0] = 1f;
                                                                                                                    this.netUpdate = true;
                                                                                                                    return;
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                        else if (this.aiStyle == 121)
                                                                                                        {
                                                                                                            Player player9 = Main.player[this.owner];
                                                                                                            if ((int)Main.time % 120 == 0)
                                                                                                            {
                                                                                                                this.netUpdate = true;
                                                                                                            }
                                                                                                            if (!player9.active)
                                                                                                            {
                                                                                                                this.active = false;
                                                                                                                return;
                                                                                                            }
                                                                                                            bool flag63 = this.type == ProjectileID.StardustDragon1;
                                                                                                            bool flag64 = this.type == ProjectileID.StardustDragon1 || this.type == ProjectileID.StardustDragon2 || this.type == ProjectileID.StardustDragon3 || this.type == ProjectileID.StardustDragon4;
                                                                                                            int num1051 = 10;
                                                                                                            if (flag64)
                                                                                                            {
                                                                                                                if (player9.dead)
                                                                                                                {
                                                                                                                    player9.stardustDragon = false;
                                                                                                                }
                                                                                                                if (player9.stardustDragon)
                                                                                                                {
                                                                                                                    this.timeLeft = 2;
                                                                                                                }
                                                                                                                num1051 = 30;
                                                                                                            }
                                                                                                            if (flag63)
                                                                                                            {
                                                                                                                Vector2 center14 = player9.Center;
                                                                                                                float num1077 = 700f;
                                                                                                                float num1078 = 1000f;
                                                                                                                int num1079 = -1;
                                                                                                                if (base.Distance(center14) > 2000f)
                                                                                                                {
                                                                                                                    base.Center = center14;
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                                bool flag65 = true;
                                                                                                                if (flag65)
                                                                                                                {
                                                                                                                    for (int num1080 = 0; num1080 < 200; num1080++)
                                                                                                                    {
                                                                                                                        NPC nPC13 = Main.npc[num1080];
                                                                                                                        if (nPC13.CanBeChasedBy(this, false) && player9.Distance(nPC13.Center) < num1078)
                                                                                                                        {
                                                                                                                            float num1081 = base.Distance(nPC13.Center);
                                                                                                                            if (num1081 < num1077)
                                                                                                                            {
                                                                                                                                num1079 = num1080;
                                                                                                                                bool arg_2D71A_0 = nPC13.boss;
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                if (num1079 != -1)
                                                                                                                {
                                                                                                                    NPC nPC14 = Main.npc[num1079];
                                                                                                                    Vector2 vector193 = nPC14.Center - base.Center;
                                                                                                                    (vector193.X > 0f).ToDirectionInt();
                                                                                                                    (vector193.Y > 0f).ToDirectionInt();
                                                                                                                    float num1082 = 0.4f;
                                                                                                                    if (vector193.Length() < 600f)
                                                                                                                    {
                                                                                                                        num1082 = 0.6f;
                                                                                                                    }
                                                                                                                    if (vector193.Length() < 300f)
                                                                                                                    {
                                                                                                                        num1082 = 0.8f;
                                                                                                                    }
                                                                                                                    if (vector193.Length() > nPC14.Size.Length() * 0.75f)
                                                                                                                    {
                                                                                                                        this.velocity += Vector2.Normalize(vector193) * num1082 * 1.5f;
                                                                                                                        if (Vector2.Dot(this.velocity, vector193) < 0.25f)
                                                                                                                        {
                                                                                                                            this.velocity *= 0.8f;
                                                                                                                        }
                                                                                                                    }
                                                                                                                    float num1083 = 30f;
                                                                                                                    if (this.velocity.Length() > num1083)
                                                                                                                    {
                                                                                                                        this.velocity = Vector2.Normalize(this.velocity) * num1083;
                                                                                                                    }
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    float num1084 = 0.2f;
                                                                                                                    Vector2 vector194 = center14 - base.Center;
                                                                                                                    if (vector194.Length() < 200f)
                                                                                                                    {
                                                                                                                        num1084 = 0.12f;
                                                                                                                    }
                                                                                                                    if (vector194.Length() < 140f)
                                                                                                                    {
                                                                                                                        num1084 = 0.06f;
                                                                                                                    }
                                                                                                                    if (vector194.Length() > 100f)
                                                                                                                    {
                                                                                                                        if (Math.Abs(center14.X - base.Center.X) > 20f)
                                                                                                                        {
                                                                                                                            this.velocity.X = this.velocity.X + num1084 * (float)Math.Sign(center14.X - base.Center.X);
                                                                                                                        }
                                                                                                                        if (Math.Abs(center14.Y - base.Center.Y) > 10f)
                                                                                                                        {
                                                                                                                            this.velocity.Y = this.velocity.Y + num1084 * (float)Math.Sign(center14.Y - base.Center.Y);
                                                                                                                        }
                                                                                                                    }
                                                                                                                    else if (this.velocity.Length() > 2f)
                                                                                                                    {
                                                                                                                        this.velocity *= 0.96f;
                                                                                                                    }
                                                                                                                    if (Math.Abs(this.velocity.Y) < 1f)
                                                                                                                    {
                                                                                                                        this.velocity.Y = this.velocity.Y - 0.1f;
                                                                                                                    }
                                                                                                                    float num1085 = 15f;
                                                                                                                    if (this.velocity.Length() > num1085)
                                                                                                                    {
                                                                                                                        this.velocity = Vector2.Normalize(this.velocity) * num1085;
                                                                                                                    }
                                                                                                                }
                                                                                                                this.rotation = this.velocity.ToRotation() + (float)(Math.PI / 2f);
                                                                                                                int direction = this.direction;
                                                                                                                this.direction = (this.spriteDirection = ((this.velocity.X > 0f) ? 1 : -1));
                                                                                                                if (direction != this.direction)
                                                                                                                {
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                                this.position = base.Center;
                                                                                                                this.scale = 1f + this.localAI[0] * 0.01f;
                                                                                                                this.width = (this.height = (int)((float)num1051 * this.scale));
                                                                                                                base.Center = this.position;
                                                                                                                if (this.alpha > 0)
                                                                                                                {
                                                                                                                    this.alpha -= 42;
                                                                                                                    if (this.alpha < 0)
                                                                                                                    {
                                                                                                                        this.alpha = 0;
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                bool flag66 = false;
                                                                                                                Vector2 vector195 = Vector2.Zero;
                                                                                                                Vector2 arg_2DBC1_0 = Vector2.Zero;
                                                                                                                float num1088 = 0f;
                                                                                                                float num1089 = 0f;
                                                                                                                float num1090 = 1f;
                                                                                                                if (this.ai[1] == 1f)
                                                                                                                {
                                                                                                                    this.ai[1] = 0f;
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                                int byUUID = Projectile.GetByUUID(this.owner, (int)this.ai[0]);
                                                                                                                if (flag64 && byUUID >= 0 && Main.projectile[byUUID].active && (Main.projectile[byUUID].type == ProjectileID.StardustDragon1 || Main.projectile[byUUID].type == ProjectileID.StardustDragon2 || Main.projectile[byUUID].type == ProjectileID.StardustDragon3))
                                                                                                                {
                                                                                                                    flag66 = true;
                                                                                                                    vector195 = Main.projectile[byUUID].Center;
                                                                                                                    Vector2 arg_2DE6A_0 = Main.projectile[byUUID].velocity;
                                                                                                                    num1088 = Main.projectile[byUUID].rotation;
                                                                                                                    float num1065 = MathHelper.Clamp(Main.projectile[byUUID].scale, 0f, 50f);
                                                                                                                    num1089 = num1065;
                                                                                                                    num1090 = 16f;
                                                                                                                    int arg_2DEC0_0 = Main.projectile[byUUID].alpha;
                                                                                                                    Main.projectile[byUUID].localAI[0] = this.localAI[0] + 1f;
                                                                                                                    if (Main.projectile[byUUID].type != ProjectileID.StardustDragon1)
                                                                                                                    {
                                                                                                                        Main.projectile[byUUID].localAI[1] = (float)this.whoAmI;
                                                                                                                    }
                                                                                                                    if (this.owner == Main.myPlayer && Main.projectile[byUUID].type == ProjectileID.StardustDragon1 && this.type == ProjectileID.StardustDragon4)
                                                                                                                    {
                                                                                                                        Main.projectile[byUUID].Kill();
                                                                                                                        this.Kill();
                                                                                                                        return;
                                                                                                                    }
                                                                                                                }
                                                                                                                if (!flag66)
                                                                                                                {
                                                                                                                    return;
                                                                                                                }
                                                                                                                this.alpha -= 42;
                                                                                                                if (this.alpha < 0)
                                                                                                                {
                                                                                                                    this.alpha = 0;
                                                                                                                }
                                                                                                                this.velocity = Vector2.Zero;
                                                                                                                Vector2 vector134 = vector195 - base.Center;
                                                                                                                if (num1088 != this.rotation)
                                                                                                                {
                                                                                                                    float num1068 = MathHelper.WrapAngle(num1088 - this.rotation);
                                                                                                                    vector134 = vector134.RotatedBy((double)(num1068 * 0.1f), default(Vector2));
                                                                                                                }
                                                                                                                this.rotation = vector134.ToRotation() + 1.57079637f;
                                                                                                                this.position = base.Center;
                                                                                                                this.scale = num1090;
                                                                                                                this.width = (this.height = (int)((float)num1051 * this.scale));
                                                                                                                base.Center = this.position;
                                                                                                                if (vector134 != Vector2.Zero)
                                                                                                                {
                                                                                                                    base.Center = vector195 - Vector2.Normalize(vector134) * num1090 * num1090;
                                                                                                                }
                                                                                                                this.spriteDirection = ((vector134.X > 0f) ? 1 : -1);
                                                                                                                return;
                                                                                                            }
                                                                                                        }
                                                                                                        else if (this.aiStyle == 122)
                                                                                                        {
                                                                                                            int num1096 = (int)this.ai[0];
                                                                                                            bool flag67 = false;
                                                                                                            if (num1096 == -1 || !Main.npc[num1096].active)
                                                                                                            {
                                                                                                                flag67 = true;
                                                                                                            }
                                                                                                            if (flag67)
                                                                                                            {
                                                                                                                if (this.type == ProjectileID.TowerDamageBolt)
                                                                                                                {
                                                                                                                    this.Kill();
                                                                                                                    return;
                                                                                                                }
                                                                                                                if (this.type == ProjectileID.PhantasmArrow && this.ai[0] != -1f)
                                                                                                                {
                                                                                                                    this.ai[0] = -1f;
                                                                                                                    this.netUpdate = true;
                                                                                                                }
                                                                                                            }
                                                                                                            if (!flag67 && base.Hitbox.Intersects(Main.npc[num1096].Hitbox))
                                                                                                            {
                                                                                                                this.Kill();
                                                                                                                if (this.type == ProjectileID.PhantasmArrow)
                                                                                                                {
                                                                                                                    this.localAI[1] = 1f;
                                                                                                                    this.Damage();
                                                                                                                }
                                                                                                                return;
                                                                                                            }
                                                                                                            if (this.type == ProjectileID.TowerDamageBolt)
                                                                                                            {
                                                                                                                Vector2 vector197 = Main.npc[num1096].Center - base.Center;
                                                                                                                this.velocity = Vector2.Normalize(vector197) * 5f;
                                                                                                            }
                                                                                                            if (this.type == ProjectileID.PhantasmArrow)
                                                                                                            {
                                                                                                                if (this.ai[1] > 0f)
                                                                                                                {
                                                                                                                    this.ai[1] -= 1f;
                                                                                                                    this.velocity = Vector2.Zero;
                                                                                                                    return;
                                                                                                                }
                                                                                                                if (flag67)
                                                                                                                {
                                                                                                                    if (this.velocity == Vector2.Zero)
                                                                                                                    {
                                                                                                                        this.Kill();
                                                                                                                    }
                                                                                                                    this.tileCollide = true;
                                                                                                                    this.alpha += 10;
                                                                                                                    if (this.alpha > 255)
                                                                                                                    {
                                                                                                                        this.Kill();
                                                                                                                    }
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    Vector2 vector198 = Main.npc[num1096].Center - base.Center;
                                                                                                                    this.velocity = Vector2.Normalize(vector198) * 12f;
                                                                                                                    this.alpha -= 15;
                                                                                                                    if (this.alpha < 0)
                                                                                                                    {
                                                                                                                        this.alpha = 0;
                                                                                                                    }
                                                                                                                }
                                                                                                                this.rotation = this.velocity.ToRotation() - 1.57079637f;
                                                                                                                return;
                                                                                                            }
                                                                                                        }
                                                                                                        else if (this.aiStyle == 123)
                                                                                                        {
                                                                                                            bool flag68 = this.type == ProjectileID.MoonlordTurret;
                                                                                                            bool flag69 = this.type == ProjectileID.RainbowCrystal;
                                                                                                            float num1097 = 1000f;
                                                                                                            this.velocity = Vector2.Zero;
                                                                                                            if (flag68)
                                                                                                            {
                                                                                                                this.alpha -= 5;
                                                                                                                if (this.alpha < 0)
                                                                                                                {
                                                                                                                    this.alpha = 0;
                                                                                                                }
                                                                                                                if (this.direction == 0)
                                                                                                                {
                                                                                                                    this.direction = Main.player[this.owner].direction;
                                                                                                                }
                                                                                                                this.rotation -= (float)this.direction * 6.28318548f / 120f;
                                                                                                                this.scale = this.Opacity;
                                                                                                            }
                                                                                                            if (flag69)
                                                                                                            {
                                                                                                                this.alpha -= 5;
                                                                                                                if (this.alpha < 0)
                                                                                                                {
                                                                                                                    this.alpha = 0;
                                                                                                                }
                                                                                                                if (this.direction == 0)
                                                                                                                {
                                                                                                                    this.direction = Main.player[this.owner].direction;
                                                                                                                }
                                                                                                                if (++this.frameCounter >= 3)
                                                                                                                {
                                                                                                                    this.frameCounter = 0;
                                                                                                                    if (++this.frame >= Main.projFrames[this.type])
                                                                                                                    {
                                                                                                                        this.frame = 0;
                                                                                                                    }
                                                                                                                }
                                                                                                                this.localAI[0] += 1f;
                                                                                                                if (this.localAI[0] >= 60f)
                                                                                                                {
                                                                                                                    this.localAI[0] = 0f;
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.ai[0] < 0f)
                                                                                                            {
                                                                                                                this.ai[0] += 1f;
                                                                                                                if (flag68)
                                                                                                                {
                                                                                                                    this.ai[1] -= (float)this.direction * 0.3926991f / 50f;
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.ai[0] == 0f)
                                                                                                            {
                                                                                                                int num1099 = -1;
                                                                                                                float num1100 = num1097;
                                                                                                                for (int num1101 = 0; num1101 < 200; num1101++)
                                                                                                                {
                                                                                                                    NPC nPC15 = Main.npc[num1101];
                                                                                                                    if (nPC15.CanBeChasedBy(this, false))
                                                                                                                    {
                                                                                                                        float num1102 = base.Distance(nPC15.Center);
                                                                                                                        if (num1102 < num1100 && Collision.CanHitLine(base.Center, 0, 0, nPC15.Center, 0, 0))
                                                                                                                        {
                                                                                                                            num1100 = num1102;
                                                                                                                            num1099 = num1101;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                                if (num1099 != -1)
                                                                                                                {
                                                                                                                    this.ai[0] = 1f;
                                                                                                                    this.ai[1] = (float)num1099;
                                                                                                                    this.netUpdate = true;
                                                                                                                    return;
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.ai[0] > 0f)
                                                                                                            {
                                                                                                                int num1103 = (int)this.ai[1];
                                                                                                                if (!Main.npc[num1103].CanBeChasedBy(this, false))
                                                                                                                {
                                                                                                                    this.ai[0] = 0f;
                                                                                                                    this.ai[1] = 0f;
                                                                                                                    this.netUpdate = true;
                                                                                                                    return;
                                                                                                                }
                                                                                                                this.ai[0] += 1f;
                                                                                                                float num1104 = 30f;
                                                                                                                if (flag69)
                                                                                                                {
                                                                                                                    num1104 = 5f;
                                                                                                                }
                                                                                                                if (this.ai[0] >= num1104)
                                                                                                                {
                                                                                                                    Vector2 vector201 = base.DirectionTo(Main.npc[num1103].Center);
                                                                                                                    if (vector201.HasNaNs())
                                                                                                                    {
                                                                                                                        vector201 = Vector2.UnitY;
                                                                                                                    }
                                                                                                                    float num1105 = vector201.ToRotation();
                                                                                                                    int num1106 = (vector201.X > 0f) ? 1 : -1;
                                                                                                                    if (flag68)
                                                                                                                    {
                                                                                                                        this.direction = num1106;
                                                                                                                        this.ai[0] = -60f;
                                                                                                                        this.ai[1] = num1105 + (float)num1106 * 3.14159274f / 16f;
                                                                                                                        this.netUpdate = true;
                                                                                                                        if (this.owner == Main.myPlayer)
                                                                                                                        {
                                                                                                                            Projectile.NewProjectile(base.Center.X, base.Center.Y, vector201.X, vector201.Y, 642, this.damage, this.knockBack, this.owner, 0f, (float)this.whoAmI);
                                                                                                                        }
                                                                                                                    }
                                                                                                                    if (flag69)
                                                                                                                    {
                                                                                                                        this.direction = num1106;
                                                                                                                        this.ai[0] = -20f;
                                                                                                                        this.netUpdate = true;
                                                                                                                        if (this.owner == Main.myPlayer)
                                                                                                                        {
                                                                                                                            Vector2 vector202 = Main.npc[num1103].position + Main.npc[num1103].Size * Utils.RandomVector2(Main.rand, 0f, 1f) - base.Center;
                                                                                                                            for (int num1107 = 0; num1107 < 3; num1107++)
                                                                                                                            {
                                                                                                                                Vector2 vector203 = base.Center + vector202;
                                                                                                                                if (num1107 > 0)
                                                                                                                                {
                                                                                                                                    vector203 = base.Center + vector202.RotatedByRandom(0.78539818525314331) * (Main.rand.NextFloat() * 0.5f + 0.75f);
                                                                                                                                }
                                                                                                                                float x2 = Main.RgbToHsl(new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB)).X;
                                                                                                                                Projectile.NewProjectile(vector203.X, vector203.Y, 0f, 0f, 644, this.damage, this.knockBack, this.owner, x2, (float)this.whoAmI);
                                                                                                                            }
                                                                                                                            return;
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                        else if (this.aiStyle == 124)
                                                                                                        {
                                                                                                            Player player10 = Main.player[this.owner];
                                                                                                            if (player10.dead)
                                                                                                            {
                                                                                                                this.Kill();
                                                                                                                return;
                                                                                                            }
                                                                                                            if (Main.myPlayer == this.owner && player10.suspiciouslookingTentacle)
                                                                                                            {
                                                                                                                this.timeLeft = 2;
                                                                                                            }
                                                                                                            this.direction = (this.spriteDirection = player10.direction);
                                                                                                            Vector3 v3_ = new Vector3(0.5f, 0.9f, 1f) * 1.5f;
                                                                                                            DelegateMethods.v3_1 = v3_;
                                                                                                            Vector2 vector204 = new Vector2((float)(player10.direction * 30), -20f);
                                                                                                            Vector2 vector205 = player10.MountedCenter + vector204;
                                                                                                            float num1108 = Vector2.Distance(base.Center, vector205);
                                                                                                            if (num1108 > 1000f)
                                                                                                            {
                                                                                                                base.Center = player10.Center + vector204;
                                                                                                            }
                                                                                                            Vector2 vector206 = vector205 - base.Center;
                                                                                                            float num1109 = 4f;
                                                                                                            if (num1108 < num1109)
                                                                                                            {
                                                                                                                this.velocity *= 0.25f;
                                                                                                            }
                                                                                                            if (vector206 != Vector2.Zero)
                                                                                                            {
                                                                                                                if (vector206.Length() < num1109)
                                                                                                                {
                                                                                                                    this.velocity = vector206;
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    this.velocity = vector206 * 0.1f;
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.velocity.Length() > 6f)
                                                                                                            {
                                                                                                                float num1110 = this.velocity.ToRotation() + 1.57079637f;
                                                                                                                if (Math.Abs(this.rotation - num1110) >= 3.14159274f)
                                                                                                                {
                                                                                                                    if (num1110 < this.rotation)
                                                                                                                    {
                                                                                                                        this.rotation -= 6.28318548f;
                                                                                                                    }
                                                                                                                    else
                                                                                                                    {
                                                                                                                        this.rotation += 6.28318548f;
                                                                                                                    }
                                                                                                                }
                                                                                                                float num1111 = 12f;
                                                                                                                this.rotation = (this.rotation * (num1111 - 1f) + num1110) / num1111;
                                                                                                                if (++this.frameCounter >= 4)
                                                                                                                {
                                                                                                                    this.frameCounter = 0;
                                                                                                                    if (++this.frame >= Main.projFrames[this.type])
                                                                                                                    {
                                                                                                                        this.frame = 0;
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                if (this.rotation > 3.14159274f)
                                                                                                                {
                                                                                                                    this.rotation -= 6.28318548f;
                                                                                                                }
                                                                                                                if (this.rotation > -0.005f && this.rotation < 0.005f)
                                                                                                                {
                                                                                                                    this.rotation = 0f;
                                                                                                                }
                                                                                                                else
                                                                                                                {
                                                                                                                    this.rotation *= 0.96f;
                                                                                                                }
                                                                                                                if (++this.frameCounter >= 6)
                                                                                                                {
                                                                                                                    this.frameCounter = 0;
                                                                                                                    if (++this.frame >= Main.projFrames[this.type])
                                                                                                                    {
                                                                                                                        this.frame = 0;
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            if (this.ai[0] > 0f && (this.ai[0] += 1f) >= 60f)
                                                                                                            {
                                                                                                                this.ai[0] = 0f;
                                                                                                                this.ai[1] = 0f;
                                                                                                            }
                                                                                                            if (Main.rand.Next(15) == 0)
                                                                                                            {
                                                                                                                float num1112 = -1f;
                                                                                                                int num1113 = 17;
                                                                                                                if ((base.Center - player10.Center).Length() < (float)Main.screenWidth)
                                                                                                                {
                                                                                                                    int num1114 = (int)base.Center.X / 16;
                                                                                                                    int num1115 = (int)base.Center.Y / 16;
                                                                                                                    num1114 = (int)MathHelper.Clamp((float)num1114, (float)(num1113 + 1), (float)(Main.maxTilesX - num1113 - 1));
                                                                                                                    num1115 = (int)MathHelper.Clamp((float)num1115, (float)(num1113 + 1), (float)(Main.maxTilesY - num1113 - 1));
                                                                                                                    for (int num1116 = num1114 - num1113; num1116 <= num1114 + num1113; num1116++)
                                                                                                                    {
                                                                                                                        for (int num1117 = num1115 - num1113; num1117 <= num1115 + num1113; num1117++)
                                                                                                                        {
                                                                                                                            int num1118 = Main.rand.Next(8);
                                                                                                                            if (num1118 < 4)
                                                                                                                            {
                                                                                                                                Vector2 vector207 = new Vector2((float)(num1114 - num1116), (float)(num1115 - num1117));
                                                                                                                                if (vector207.Length() < (float)num1113 && Main.tile[num1116, num1117] != null && Main.tile[num1116, num1117].active())
                                                                                                                                {
                                                                                                                                    bool flag70 = false;
                                                                                                                                    if (Main.tile[num1116, num1117].type == TileID.SmallPiles && Main.tile[num1116, num1117].frameY == 18)
                                                                                                                                    {
                                                                                                                                        if (Main.tile[num1116, num1117].frameX >= 576 && Main.tile[num1116, num1117].frameX <= 882)
                                                                                                                                        {
                                                                                                                                            flag70 = true;
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                    else if (Main.tile[num1116, num1117].type == TileID.LargePiles && Main.tile[num1116, num1117].frameX >= 864 && Main.tile[num1116, num1117].frameX <= 1170)
                                                                                                                                    {
                                                                                                                                        flag70 = true;
                                                                                                                                    }
                                                                                                                                    if (flag70 || Main.tileSpelunker[(int)Main.tile[num1116, num1117].type] || (Main.tileAlch[(int)Main.tile[num1116, num1117].type] && Main.tile[num1116, num1117].type != TileID.ImmatureHerbs))
                                                                                                                                    {
                                                                                                                                        float num1119 = base.Distance(new Vector2((float)(num1116 * 16 + 8), (float)(num1117 * 16 + 8)));
                                                                                                                                        if (num1119 < num1112 || num1112 == -1f)
                                                                                                                                        {
                                                                                                                                            num1112 = num1119;
                                                                                                                                            this.ai[0] = 1f;
                                                                                                                                            this.ai[1] = base.AngleTo(new Vector2((float)(num1116 * 16 + 8), (float)(num1117 * 16 + 8)));
                                                                                                                                        }
                                                                                                                                    }
                                                                                                                                }
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            float f3 = this.localAI[0] % 6.28318548f - 3.14159274f;
                                                                                                            float num1121 = (float)Math.IEEERemainder((double)this.localAI[1], 1.0);
                                                                                                            if (num1121 < 0f)
                                                                                                            {
                                                                                                                num1121 += 1f;
                                                                                                            }
                                                                                                            float num1122 = (float)Math.Floor((double)this.localAI[1]);
                                                                                                            float num1123 = 0.999f;
                                                                                                            int num1124 = 0;
                                                                                                            float num1125 = 0.1f;
                                                                                                            bool flag71 = player10.velocity.Length() > 3f;
                                                                                                            int num1126 = -1;
                                                                                                            int num1127 = -1;
                                                                                                            float num1128 = 300f;
                                                                                                            float num1129 = 500f;
                                                                                                            for (int num1130 = 0; num1130 < 200; num1130++)
                                                                                                            {
                                                                                                                NPC nPC16 = Main.npc[num1130];
                                                                                                                if (nPC16.active && nPC16.chaseable && !nPC16.dontTakeDamage && !nPC16.immortal)
                                                                                                                {
                                                                                                                    float num1131 = base.Distance(nPC16.Center);
                                                                                                                    if (nPC16.friendly || nPC16.lifeMax <= 5)
                                                                                                                    {
                                                                                                                        if (num1131 < num1128 && !flag71)
                                                                                                                        {
                                                                                                                            num1128 = num1131;
                                                                                                                            num1127 = num1130;
                                                                                                                        }
                                                                                                                    }
                                                                                                                    else if (num1131 < num1129)
                                                                                                                    {
                                                                                                                        num1129 = num1131;
                                                                                                                        num1126 = num1130;
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                            float num1132;
                                                                                                            if (flag71)
                                                                                                            {
                                                                                                                num1132 = base.AngleTo(base.Center + player10.velocity);
                                                                                                                num1124 = 1;
                                                                                                                num1121 = MathHelper.Clamp(num1121 + 0.05f, 0f, num1123);
                                                                                                                num1122 += (float)Math.Sign(-10f - num1122);
                                                                                                            }
                                                                                                            else if (num1126 != -1)
                                                                                                            {
                                                                                                                num1132 = base.AngleTo(Main.npc[num1126].Center);
                                                                                                                num1124 = 2;
                                                                                                                num1121 = MathHelper.Clamp(num1121 + 0.05f, 0f, num1123);
                                                                                                                num1122 += (float)Math.Sign(-12f - num1122);
                                                                                                            }
                                                                                                            else if (num1127 != -1)
                                                                                                            {
                                                                                                                num1132 = base.AngleTo(Main.npc[num1127].Center);
                                                                                                                num1124 = 3;
                                                                                                                num1121 = MathHelper.Clamp(num1121 + 0.05f, 0f, num1123);
                                                                                                                num1122 += (float)Math.Sign(6f - num1122);
                                                                                                            }
                                                                                                            else if (this.ai[0] > 0f)
                                                                                                            {
                                                                                                                num1132 = this.ai[1];
                                                                                                                num1121 = MathHelper.Clamp(num1121 + (float)Math.Sign(0.75f - num1121) * 0.05f, 0f, num1123);
                                                                                                                num1124 = 4;
                                                                                                                num1122 += (float)Math.Sign(10f - num1122);
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                num1132 = ((player10.direction == 1) ? 0f : 3.14160275f);
                                                                                                                num1121 = MathHelper.Clamp(num1121 + (float)Math.Sign(0.75f - num1121) * 0.05f, 0f, num1123);
                                                                                                                num1122 += (float)Math.Sign(0f - num1122);
                                                                                                                num1125 = 0.12f;
                                                                                                            }
                                                                                                            Vector2 vector208 = num1132.ToRotationVector2();
                                                                                                            num1132 = Vector2.Lerp(f3.ToRotationVector2(), vector208, num1125).ToRotation();
                                                                                                            this.localAI[0] = num1132 + (float)num1124 * 6.28318548f + 3.14159274f;
                                                                                                            this.localAI[1] = num1122 + num1121;
                                                                                                        }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#56
0
        /// <summary>
        /// Handles input for quitting the game.
        /// </summary>
        void HandleInput()
        {
#if WINDOWS_PHONE
            KeyboardState currentKeyboardState = new KeyboardState();
#else
            KeyboardState currentKeyboardState = Keyboard.GetState();
#endif
            GamePadState    currentGamePadState = GamePad.GetState(PlayerIndex.One);
            MouseState      currentMouseState   = Mouse.GetState();
            TouchCollection currentTouchState   = TouchPanel.GetState();

            // Check for exit.
            if (currentKeyboardState.IsKeyDown(Keys.Escape) ||
                currentGamePadState.Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }
            // check to see if the user wants to move the cat. we'll create a vector
            // called catMovement, which will store the sum of all the user's inputs.
            Vector2 catMovement = currentGamePadState.ThumbSticks.Left;

            // flip y: on the thumbsticks, down is -1, but on the screen, down is bigger
            // numbers.
            catMovement.Y *= -1;

            if (currentKeyboardState.IsKeyDown(Keys.Left) ||
                currentGamePadState.DPad.Left == ButtonState.Pressed)
            {
                catMovement.X -= 1.0f;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Right) ||
                currentGamePadState.DPad.Right == ButtonState.Pressed)
            {
                catMovement.X += 1.0f;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Up) ||
                currentGamePadState.DPad.Up == ButtonState.Pressed)
            {
                catMovement.Y -= 1.0f;
            }
            if (currentKeyboardState.IsKeyDown(Keys.Down) ||
                currentGamePadState.DPad.Down == ButtonState.Pressed)
            {
                catMovement.Y += 1.0f;
            }

            //Move toward the touch point. We slow down the cat when it gets within a distance of CatSpeed to the touch point.
            float smoothStop = 1;

            if (currentTouchState != null)
            {
                if (currentTouchState.Count > 0)
                {
                    Vector2 touchPosition = currentTouchState[0].Position;
                    if (touchPosition != catPosition)
                    {
                        catMovement = touchPosition - catPosition;
                        float delta = CatSpeed - MathHelper.Clamp(catMovement.Length(), 0, CatSpeed);
                        smoothStop = 1 - delta / CatSpeed;
                    }
                }
            }

            Vector2 mousePosition = new Vector2(currentMouseState.X, currentMouseState.Y);
            if (currentMouseState.LeftButton == ButtonState.Pressed && mousePosition != catPosition)
            {
                catMovement = mousePosition - catPosition;
                float delta = CatSpeed - MathHelper.Clamp(catMovement.Length(), 0, CatSpeed);
                smoothStop = 1 - delta / CatSpeed;
            }

            // normalize the user's input, so the cat can never be going faster than
            // CatSpeed.
            if (catMovement != Vector2.Zero)
            {
                catMovement.Normalize();
            }

            catPosition += catMovement * CatSpeed * smoothStop;
        }
示例#57
0
        public void AI()
        {
            Vector2 vector2 = new Vector2();
            Vector2 vector21 = new Vector2();
            Vector2 vector22 = new Vector2();
            int num = 0;
            int num1 = 0;
            int num2 = 0;
            bool flag;
            Vector2 vector23 = new Vector2();
            int x;
            int x1;
            int num3;
            float single;
            Vector2 center;
            Vector2 y;
            int num4;
            int num5;
            bool flag1;
            Color skyBlue;
            int num6;
            int[] numArray;
            float single1;
            Vector2 vector24;
            int num7;
            int num8;
            int num9;
            int num10;
            bool flag2;
            bool flag3;
            bool flag4;
            bool flag5;
            if (this.aiStyle == 0)
            {
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active && Main.player[i].talkNPC == this.whoAmI)
                    {
                        if (this.type == 105)
                        {
                            this.Transform(107);
                            return;
                        }
                        if (this.type == 106)
                        {
                            this.Transform(108);
                            return;
                        }
                        if (this.type == 123)
                        {
                            this.Transform(124);
                            return;
                        }
                        if (this.type == 354)
                        {
                            this.Transform(353);
                            return;
                        }
                        if (this.type == 376)
                        {
                            this.Transform(369);
                            return;
                        }
                    }
                }
                if (this.type != 376)
                {
                    this.TargetClosest(true);
                    this.spriteDirection = this.direction;
                }
                if (this.type != 376)
                {
                    this.velocity.X = this.velocity.X * 0.93f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                        return;
                    }
                }
                else if (this.wet || Main.tile[(int)(base.Center.X / 16f), (int)(this.position.Y - 4f) / 16].liquid > 0)
                {
                    this.velocity.Y = -0.4f;
                    int num11 = 1;
                    if (base.Center.X / 16f > (float)(Main.maxTilesX / 2))
                    {
                        num11 = -1;
                    }
                    int num12 = 12;
                    int x2 = (int)base.Center.X / 16;
                    int y1 = (int)base.Center.Y / 16;
                    bool flag6 = false;
                    if (num11 <= 0)
                    {
                        for (int j = x2; j > x2 - num12; j--)
                        {
                            if (WorldGen.SolidTile(j, y1))
                            {
                                flag6 = true;
                            }
                        }
                    }
                    else
                    {
                        for (int k = x2; k < x2 + num12; k++)
                        {
                            if (WorldGen.SolidTile(k, y1))
                            {
                                flag6 = true;
                            }
                        }
                    }
                    if (!flag6)
                    {
                        this.velocity.X = this.velocity.X + (float)num11 * 0.01f;
                        if (this.velocity.X > 0.2f)
                        {
                            this.velocity.X = this.velocity.X * 0.95f;
                        }
                        if (this.velocity.X < -0.2f)
                        {
                            this.velocity.X = this.velocity.X * 0.95f;
                            return;
                        }
                    }
                    else
                    {
                        this.velocity.X = this.velocity.X * 0.99f;
                        if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                        {
                            this.velocity.X = 0f;
                            return;
                        }
                    }
                }
                else
                {
                    this.velocity.X = this.velocity.X * 0.93f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                        return;
                    }
                }
            }
            else if (this.aiStyle == 1)
            {
                if (this.type == 1 && (this.ai[1] == 1f || this.ai[1] == 2f || this.ai[1] == 3f))
                {
                    this.ai[1] = -1f;
                }
                if (this.type == 1 && this.ai[1] == 0f && Main.netMode != 1 && this.@value > 0f)
                {
                    this.ai[1] = -1f;
                    if (Main.rand.Next(20) == 0)
                    {
                        int num13 = Main.rand.Next(4);
                        if (num13 == 0)
                        {
                            num13 = Main.rand.Next(7);
                            if (num13 == 0)
                            {
                                num13 = 290;
                            }
                            else if (num13 == 1)
                            {
                                num13 = 292;
                            }
                            else if (num13 == 2)
                            {
                                num13 = 296;
                            }
                            else if (num13 != 3)
                            {
                                num13 = (Main.netMode == 0 || Main.rand.Next(2) != 0 ? 2350 : 2997);
                            }
                            else
                            {
                                num13 = 2322;
                            }
                        }
                        else if (num13 == 1)
                        {
                            num13 = Main.rand.Next(4);
                            if (num13 == 0)
                            {
                                num13 = 8;
                            }
                            else if (num13 != 1)
                            {
                                num13 = (num13 != 2 ? 58 : 965);
                            }
                            else
                            {
                                num13 = 166;
                            }
                        }
                        else if (num13 != 2)
                        {
                            num13 = Main.rand.Next(3);
                            if (num13 != 0)
                            {
                                num13 = (num13 != 1 ? 73 : 72);
                            }
                            else
                            {
                                num13 = 71;
                            }
                        }
                        else
                        {
                            num13 = (Main.rand.Next(2) != 0 ? Main.rand.Next(699, 703) : Main.rand.Next(11, 15));
                        }
                        this.ai[1] = (float)num13;
                        this.netUpdate = true;
                    }
                }
                if (this.type == 244)
                {
                    float discoR = (float)Main.DiscoR / 255f;
                    float discoG = (float)Main.DiscoG / 255f;
                    float discoB = (float)Main.DiscoB / 255f;
                    discoR = discoR * 1f;
                    discoG = discoG * 1f;
                    discoB = discoB * 1f;
                    this.color.R = (byte)Main.DiscoR;
                    this.color.G = (byte)Main.DiscoG;
                    this.color.B = (byte)Main.DiscoB;
                    this.color.A = 100;
                    this.alpha = 175;
                }
                bool flag7 = false;
                if (!Main.dayTime || this.life != this.lifeMax || (double)this.position.Y > Main.worldSurface * 16 || Main.slimeRain)
                {
                    flag7 = true;
                }
                if (this.type == 81)
                {
                    flag7 = true;
                }
                if ((this.type == 377 || this.type == 446) && this.target != 255 && !Main.player[this.target].dead && Vector2.Distance(base.Center, Main.player[this.target].Center) <= 200f)
                {
                    flag7 = true;
                }
                if (this.type == 183)
                {
                    flag7 = true;
                }
                if (this.type == 304)
                {
                    flag7 = true;
                }
                if (this.type == 244)
                {
                    flag7 = true;
                    this.ai[0] = this.ai[0] + 2f;
                }
                if (this.type == 184)
                {
                    flag7 = true;
                    if (this.localAI[0] > 0f)
                    {
                        this.localAI[0] = this.localAI[0] - 1f;
                    }
                    if (!this.wet && !Main.player[this.target].npcTypeNoAggro[this.type])
                    {
                        Vector2 vector27 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float single2 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector27.X;
                        float y2 = Main.player[this.target].position.Y - vector27.Y;
                        float single3 = (float)Math.Sqrt((double)(single2 * single2 + y2 * y2));
                        if (Main.expertMode && single3 < 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                for (int l = 0; l < 5; l++)
                                {
                                    Vector2 vector28 = new Vector2((float)(l - 2), -4f);
                                    vector28.Normalize();
                                    vector28 = vector28 * (4f + (float)Main.rand.Next(-50, 51) * 0.01f);
                                    Projectile.NewProjectile(vector27.X, vector27.Y, vector28.X, vector28.Y, 174, 9, 0f, Main.myPlayer, 0f, 0f);
                                    this.localAI[0] = 30f;
                                }
                            }
                        }
                        else if (single3 < 200f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                y2 = Main.player[this.target].position.Y - vector27.Y - (float)Main.rand.Next(0, 200);
                                single3 = (float)Math.Sqrt((double)(single2 * single2 + y2 * y2));
                                single3 = 4.5f / single3;
                                single2 = single2 * single3;
                                y2 = y2 * single3;
                                this.localAI[0] = 50f;
                                Projectile.NewProjectile(vector27.X, vector27.Y, single2, y2, 174, 9, 0f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                if (this.type == 535)
                {
                    flag7 = true;
                    if (this.localAI[0] > 0f)
                    {
                        this.localAI[0] = this.localAI[0] - 1f;
                    }
                    if (!this.wet && !Main.player[this.target].npcTypeNoAggro[this.type])
                    {
                        Vector2 vector29 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x3 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector29.X;
                        float y3 = Main.player[this.target].position.Y - vector29.Y;
                        float single4 = (float)Math.Sqrt((double)(x3 * x3 + y3 * y3));
                        if (Main.expertMode && single4 < 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                for (int m = 0; m < 5; m++)
                                {
                                    Vector2 vector210 = new Vector2((float)(m - 2), -4f);
                                    vector210.Normalize();
                                    vector210 = vector210 * (4f + (float)Main.rand.Next(-50, 51) * 0.01f);
                                    Projectile.NewProjectile(vector29.X, vector29.Y, vector210.X, vector210.Y, 605, 9, 0f, Main.myPlayer, 0f, 0f);
                                    this.localAI[0] = 30f;
                                }
                            }
                        }
                        else if (single4 < 200f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                y3 = Main.player[this.target].position.Y - vector29.Y - (float)Main.rand.Next(0, 200);
                                single4 = (float)Math.Sqrt((double)(x3 * x3 + y3 * y3));
                                single4 = 4.5f / single4;
                                x3 = x3 * single4;
                                y3 = y3 * single4;
                                this.localAI[0] = 50f;
                                Projectile.NewProjectile(vector29.X, vector29.Y, x3, y3, 605, 9, 0f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                if (this.type == 204)
                {
                    flag7 = true;
                    if (this.localAI[0] > 0f)
                    {
                        this.localAI[0] = this.localAI[0] - 1f;
                    }
                    if (!this.wet && !Main.player[this.target].npcTypeNoAggro[this.type])
                    {
                        Vector2 vector211 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x4 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector211.X;
                        float y4 = Main.player[this.target].position.Y - vector211.Y;
                        float single5 = (float)Math.Sqrt((double)(x4 * x4 + y4 * y4));
                        if (Main.expertMode && single5 < 200f && Collision.CanHit(new Vector2(this.position.X, this.position.Y - 20f), this.width, this.height + 20, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                for (int n = 0; n < 5; n++)
                                {
                                    Vector2 vector212 = new Vector2((float)(n - 2), -2f);
                                    vector212.Normalize();
                                    vector212 = vector212 * (3f + (float)Main.rand.Next(-50, 51) * 0.01f);
                                    Projectile.NewProjectile(vector211.X, vector211.Y, vector212.X, vector212.Y, 176, 13, 0f, Main.myPlayer, 0f, 0f);
                                    this.localAI[0] = 80f;
                                }
                            }
                        }
                        if (single5 < 400f && Collision.CanHit(new Vector2(this.position.X, this.position.Y - 20f), this.width, this.height + 20, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -80f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                y4 = Main.player[this.target].position.Y - vector211.Y - (float)Main.rand.Next(-30, 20);
                                y4 = y4 - single5 * 0.05f;
                                x4 = Main.player[this.target].position.X - vector211.X - (float)Main.rand.Next(-20, 20);
                                single5 = (float)Math.Sqrt((double)(x4 * x4 + y4 * y4));
                                single5 = 7f / single5;
                                x4 = x4 * single5;
                                y4 = y4 * single5;
                                this.localAI[0] = 65f;
                                Projectile.NewProjectile(vector211.X, vector211.Y, x4, y4, 176, 13, 0f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                if (this.type == 377 || this.type == 446)
                {
                    if (this.localAI[2] >= 90f)
                    {
                        this.friendly = false;
                    }
                    else
                    {
                        this.localAI[2] = this.localAI[2] + 1f;
                    }
                }
                if (this.ai[2] > 1f)
                {
                    this.ai[2] = this.ai[2] - 1f;
                }
                if (this.wet)
                {
                    if (this.collideY)
                    {
                        this.velocity.Y = -2f;
                    }
                    if (this.velocity.Y < 0f && this.ai[3] == this.position.X)
                    {
                        NPC nPC = this;
                        nPC.direction = nPC.direction * -1;
                        this.ai[2] = 200f;
                    }
                    if (this.velocity.Y > 0f)
                    {
                        this.ai[3] = this.position.X;
                    }
                    if (this.type != 59)
                    {
                        if (this.velocity.Y > 2f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.9f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                    }
                    else
                    {
                        if (this.velocity.Y > 2f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.9f;
                        }
                        else if (this.directionY < 0)
                        {
                            this.velocity.Y = this.velocity.Y - 0.8f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -10f)
                        {
                            this.velocity.Y = -10f;
                        }
                    }
                    if (this.ai[2] == 1f && flag7)
                    {
                        this.TargetClosest(true);
                    }
                }
                this.aiAction = 0;
                if (this.ai[2] == 0f)
                {
                    this.ai[0] = -100f;
                    this.ai[2] = 1f;
                    this.TargetClosest(true);
                }
                if (this.velocity.Y == 0f)
                {
                    if (this.ai[3] == this.position.X)
                    {
                        NPC nPC1 = this;
                        nPC1.direction = nPC1.direction * -1;
                        this.ai[2] = 200f;
                    }
                    this.ai[3] = 0f;
                    this.velocity.X = this.velocity.X * 0.8f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                    }
                    if (flag7)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                    }
                    this.ai[0] = this.ai[0] + 1f;
                    if (this.type == 59)
                    {
                        this.ai[0] = this.ai[0] + 2f;
                    }
                    if (this.type == 71)
                    {
                        this.ai[0] = this.ai[0] + 3f;
                    }
                    if (this.type == 138)
                    {
                        this.ai[0] = this.ai[0] + 2f;
                    }
                    if (this.type == 183)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                    }
                    if (this.type == 304)
                    {
                        float single6 = (float)((1 - this.life / this.lifeMax) * 10);
                        this.ai[0] = this.ai[0] + single6;
                    }
                    if (this.type == 377 || this.type == 446)
                    {
                        this.ai[0] = this.ai[0] + 3f;
                    }
                    if (this.type == 81)
                    {
                        if (this.scale < 0f)
                        {
                            this.ai[0] = this.ai[0] + 1f;
                        }
                        else
                        {
                            this.ai[0] = this.ai[0] + 4f;
                        }
                    }
                    int num24 = 0;
                    if (this.ai[0] >= 0f)
                    {
                        num24 = 1;
                    }
                    if (this.ai[0] >= -1000f && this.ai[0] <= -500f)
                    {
                        num24 = 2;
                    }
                    if (this.ai[0] >= -2000f && this.ai[0] <= -1500f)
                    {
                        num24 = 3;
                    }
                    if (num24 > 0)
                    {
                        this.netUpdate = true;
                        if (flag7 && this.ai[2] == 1f)
                        {
                            this.TargetClosest(true);
                        }
                        if (num24 != 3)
                        {
                            this.velocity.Y = -6f;
                            this.velocity.X = this.velocity.X + (float)(2 * this.direction);
                            if (this.type == 59)
                            {
                                this.velocity.X = this.velocity.X + (float)(2 * this.direction);
                            }
                            this.ai[0] = -120f;
                            if (num24 != 1)
                            {
                                this.ai[0] = this.ai[0] - 2000f;
                            }
                            else
                            {
                                this.ai[0] = this.ai[0] - 1000f;
                            }
                        }
                        else
                        {
                            this.velocity.Y = -8f;
                            if (this.type == 59)
                            {
                                this.velocity.Y = this.velocity.Y - 2f;
                            }
                            this.velocity.X = this.velocity.X + (float)(3 * this.direction);
                            if (this.type == 59)
                            {
                                this.velocity.X = this.velocity.X + 0.5f * (float)this.direction;
                            }
                            this.ai[0] = -200f;
                            this.ai[3] = this.position.X;
                        }
                        if (this.type == 141)
                        {
                            this.velocity.Y = this.velocity.Y * 1.3f;
                            this.velocity.X = this.velocity.X * 1.2f;
                        }
                        if (this.type == 377 || this.type == 446)
                        {
                            this.velocity.Y = this.velocity.Y * 0.9f;
                            this.velocity.X = this.velocity.X * 0.6f;
                            if (flag7)
                            {
                                this.direction = -this.direction;
                                this.velocity.X = this.velocity.X * -1f;
                                return;
                            }
                        }
                    }
                    else if (this.ai[0] >= -30f)
                    {
                        this.aiAction = 1;
                        return;
                    }
                }
                else if (this.target < 255 && (this.direction == 1 && this.velocity.X < 3f || this.direction == -1 && this.velocity.X > -3f))
                {
                    if ((this.direction != -1 || (double)this.velocity.X >= 0.1) && (this.direction != 1 || (double)this.velocity.X <= -0.1))
                    {
                        this.velocity.X = this.velocity.X * 0.93f;
                        return;
                    }
                    this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                    return;
                }
            }
            else if (this.aiStyle == 2)
            {
                this.noGravity = true;
                if (!this.noTileCollide)
                {
                    if (this.collideX)
                    {
                        this.velocity.X = this.oldVelocity.X * -0.5f;
                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                        {
                            this.velocity.X = 2f;
                        }
                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                    if (this.collideY)
                    {
                        this.velocity.Y = this.oldVelocity.Y * -0.5f;
                        if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                        {
                            this.velocity.Y = 1f;
                        }
                        if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                        {
                            this.velocity.Y = -1f;
                        }
                    }
                }
                if (!Main.dayTime || (double)this.position.Y > Main.worldSurface * 16 || this.type != 2 && this.type != 133 && this.type != 190 && this.type != 191 && this.type != 192 && this.type != 193 && this.type != 194 && this.type != 317 && this.type != 318)
                {
                    this.TargetClosest(true);
                }
                else
                {
                    if (this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                    this.directionY = -1;
                    if (this.velocity.Y > 0f)
                    {
                        this.direction = 1;
                    }
                    this.direction = -1;
                    if (this.velocity.X > 0f)
                    {
                        this.direction = 1;
                    }
                }
                if (this.type == 170 || this.type == 171 || this.type == 180)
                {
                    if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        if (this.ai[1] > 0f && !Collision.SolidCollision(this.position, this.width, this.height))
                        {
                            this.ai[1] = 0f;
                            this.ai[0] = 0f;
                            this.netUpdate = true;
                        }
                    }
                    else if (this.ai[1] == 0f)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                    }
                    if (this.ai[0] >= 300f)
                    {
                        this.ai[1] = 1f;
                        this.ai[0] = 0f;
                        this.netUpdate = true;
                    }
                    if (this.ai[1] != 0f)
                    {
                        this.wet = false;
                        this.alpha = 200;
                        this.noTileCollide = true;
                    }
                    else
                    {
                        this.alpha = 0;
                        this.noTileCollide = false;
                    }
                    this.rotation = this.velocity.Y * 0.1f * (float)this.direction;
                    this.TargetClosest(true);
                    if (this.direction == -1 && this.velocity.X > -4f && this.position.X > Main.player[this.target].position.X + (float)Main.player[this.target].width)
                    {
                        this.velocity.X = this.velocity.X - 0.08f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.04f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.2f;
                        }
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 4f && this.position.X + (float)this.width < Main.player[this.target].position.X)
                    {
                        this.velocity.X = this.velocity.X + 0.08f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.04f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.2f;
                        }
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -2.5 && this.position.Y > Main.player[this.target].position.Y + (float)Main.player[this.target].height)
                    {
                        this.velocity.Y = this.velocity.Y - 0.1f;
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.15f;
                        }
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = -2.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 2.5 && this.position.Y + (float)this.height < Main.player[this.target].position.Y)
                    {
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.15f;
                        }
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = 2.5f;
                        }
                    }
                }
                else if (this.type == 116)
                {
                    this.TargetClosest(true);
                    if (this.direction == -1 && this.velocity.X > -6f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.2f;
                        }
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = -6f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 6f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.2f;
                        }
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = 6f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -2.5)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.15f;
                        }
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = -2.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.15f;
                        }
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = 2.5f;
                        }
                    }
                }
                else if (this.type != 133)
                {
                    float single7 = 4f;
                    float single8 = 1.5f;
                    single7 = single7 * (1f + (1f - this.scale));
                    single8 = single8 * (1f + (1f - this.scale));
                    if (this.direction == -1 && this.velocity.X > -single7)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > single7)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -single7)
                        {
                            this.velocity.X = -single7;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < single7)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -single7)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > single7)
                        {
                            this.velocity.X = single7;
                        }
                    }
                    if (this.directionY == -1 && this.velocity.Y > -single8)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if (this.velocity.Y > single8)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if (this.velocity.Y < -single8)
                        {
                            this.velocity.Y = -single8;
                        }
                    }
                    else if (this.directionY == 1 && this.velocity.Y < single8)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if (this.velocity.Y < -single8)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if (this.velocity.Y > single8)
                        {
                            this.velocity.Y = single8;
                        }
                    }
                }
                else if ((double)this.life >= (double)this.lifeMax * 0.5)
                {
                    if (this.direction == -1 && this.velocity.X > -4f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 4f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if ((double)this.velocity.Y > 1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if ((double)this.velocity.Y < -1.5)
                        {
                            this.velocity.Y = -1.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if ((double)this.velocity.Y < -1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if ((double)this.velocity.Y > 1.5)
                        {
                            this.velocity.Y = 1.5f;
                        }
                    }
                }
                else
                {
                    if (this.direction == -1 && this.velocity.X > -6f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = -6f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 6f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = 6f;
                        }
                    }
                    if (this.directionY == -1 && this.velocity.Y > -4f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.1f;
                        if (this.velocity.Y > 4f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.1f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                    }
                    else if (this.directionY == 1 && this.velocity.Y < 4f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.1f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        if (this.velocity.Y > 4f)
                        {
                            this.velocity.Y = 4f;
                        }
                    }
                }
                if (this.wet && this.type != 170 && this.type != 171 && this.type != 172)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.5f;
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                    this.TargetClosest(true);
                    return;
                }
            }
            else if (this.aiStyle == 3)
            {
                if (this.type == 466)
                {
                    int num31 = 200;
                    if (this.ai[2] == 0f)
                    {
                        this.alpha = num31;
                        this.TargetClosest(true);
                        if (!Main.player[this.target].dead && (Main.player[this.target].Center - base.Center).Length() < 170f)
                        {
                            this.ai[2] = -16f;
                        }
                        if (this.velocity.X != 0f || this.velocity.Y < 0f || this.velocity.Y > 2f || this.justHit)
                        {
                            this.ai[2] = -16f;
                        }
                        return;
                    }
                    if (this.ai[2] < 0f)
                    {
                        if (this.alpha > 0)
                        {
                            NPC nPC2 = this;
                            nPC2.alpha = nPC2.alpha - num31 / 16;
                            if (this.alpha < 0)
                            {
                                this.alpha = 0;
                            }
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] == 0f)
                        {
                            this.ai[2] = 1f;
                            this.velocity.X = (float)(this.direction * 2);
                        }
                        return;
                    }
                    this.alpha = 0;
                }
                if (this.type == 166)
                {
                    if (Main.netMode != 1 && Main.rand.Next(240) == 0)
                    {
                        this.ai[2] = (float)Main.rand.Next(-480, -60);
                        this.netUpdate = true;
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.TargetClosest(true);
                        if (this.justHit)
                        {
                            this.ai[2] = 0f;
                        }
                        if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[2] = 0f;
                        }
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.velocity.X = this.velocity.X * 0.9f;
                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                        {
                            this.velocity.X = 0f;
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] == 0f)
                        {
                            this.velocity.X = (float)this.direction * 0.1f;
                        }
                        return;
                    }
                }
                if (this.type == 461)
                {
                    if (this.wet)
                    {
                        this.knockBackResist = 0f;
                        this.ai[3] = -0.10101f;
                        this.noGravity = true;
                        Vector2 center1 = base.Center;
                        this.width = 34;
                        this.height = 24;
                        this.position.X = center1.X - (float)(this.width / 2);
                        this.position.Y = center1.Y - (float)(this.height / 2);
                        this.TargetClosest(true);
                        if (this.collideX)
                        {
                            this.velocity.X = -this.oldVelocity.X;
                        }
                        if (this.velocity.X < 0f)
                        {
                            this.direction = -1;
                        }
                        if (this.velocity.X > 0f)
                        {
                            this.direction = 1;
                        }
                        if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].Center, 1, 1))
                        {
                            Vector2 center2 = Main.player[this.target].Center - base.Center;
                            center2.Normalize();
                            center2 = center2 * 5f;
                            this.velocity = ((this.velocity * 19f) + center2) / 20f;
                            return;
                        }
                        float single9 = 5f;
                        if (this.velocity.Y > 0f)
                        {
                            single9 = 3f;
                        }
                        if (this.velocity.Y < 0f)
                        {
                            single9 = 8f;
                        }
                        Vector2 vector216 = new Vector2((float)this.direction, -1f);
                        vector216.Normalize();
                        vector216 = vector216 * single9;
                        if (single9 < 5f)
                        {
                            this.velocity = ((this.velocity * 24f) + vector216) / 25f;
                            return;
                        }
                        this.velocity = ((this.velocity * 9f) + vector216) / 10f;
                        return;
                    }
                    this.knockBackResist = 0.4f * Main.knockBackMultiplier;
                    this.noGravity = false;
                    Vector2 center3 = base.Center;
                    this.width = 18;
                    this.height = 40;
                    this.position.X = center3.X - (float)(this.width / 2);
                    this.position.Y = center3.Y - (float)(this.height / 2);
                    if (this.ai[3] == -0.10101f)
                    {
                        this.ai[3] = 0f;
                        float single10 = this.velocity.Length();
                        single10 = single10 * 2f;
                        if (single10 > 10f)
                        {
                            single10 = 10f;
                        }
                        this.velocity.Normalize();
                        NPC nPC3 = this;
                        nPC3.velocity = nPC3.velocity * single10;
                        if (this.velocity.X < 0f)
                        {
                            this.direction = -1;
                        }
                        if (this.velocity.X > 0f)
                        {
                            this.direction = 1;
                        }
                        this.spriteDirection = this.direction;
                    }
                }
                if (this.type == 379 || this.type == 380)
                {
                    if (this.ai[3] < 0f)
                    {
                        this.damage = 0;
                        this.velocity.X = this.velocity.X * 0.93f;
                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                        {
                            this.velocity.X = 0f;
                        }
                        int num32 = (int)(-this.ai[3] - 1f);
                        int num33 = Math.Sign(Main.npc[num32].Center.X - base.Center.X);
                        if (num33 != this.direction)
                        {
                            this.velocity.X = 0f;
                            this.direction = num33;
                            this.netUpdate = true;
                        }
                        if (this.justHit && Main.netMode != 1 && Main.npc[num32].localAI[0] == 0f)
                        {
                            Main.npc[num32].localAI[0] = 1f;
                        }
                        return;
                    }
                    this.damage = this.defDamage;
                }
                if (this.type == 383 && this.ai[2] == 0f && this.localAI[0] == 0f && Main.netMode != 1)
                {
                    int num34 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 384, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                    this.ai[2] = (float)(num34 + 1);
                    this.localAI[0] = -1f;
                    this.netUpdate = true;
                    Main.npc[num34].ai[0] = (float)this.whoAmI;
                    Main.npc[num34].netUpdate = true;
                }
                if (this.type == 383)
                {
                    int num35 = (int)this.ai[2] - 1;
                    if (num35 == -1 || !Main.npc[num35].active || Main.npc[num35].type != 384)
                    {
                        this.dontTakeDamage = false;
                        this.ai[2] = 0f;
                        if (this.localAI[0] == -1f)
                        {
                            this.localAI[0] = 180f;
                        }
                        if (this.localAI[0] > 0f)
                        {
                            this.localAI[0] = this.localAI[0] - 1f;
                        }
                    }
                    else
                    {
                        this.dontTakeDamage = true;
                    }
                }
                if (this.type == 482)
                {
                    int num36 = 300;
                    int num37 = 120;
                    this.dontTakeDamage = false;
                    if (this.ai[2] < 0f)
                    {
                        this.dontTakeDamage = true;
                        this.ai[2] = this.ai[2] + 1f;
                        this.velocity.X = this.velocity.X * 0.9f;
                        if ((double)Math.Abs(this.velocity.X) < 0.001)
                        {
                            this.velocity.X = 0.001f * (float)this.direction;
                        }
                        if (Math.Abs(this.velocity.Y) > 1f)
                        {
                            this.ai[2] = this.ai[2] + 10f;
                        }
                        if (this.ai[2] >= 0f)
                        {
                            this.netUpdate = true;
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.3f;
                        }
                        return;
                    }
                    if (this.ai[2] < (float)num36)
                    {
                        if (this.justHit)
                        {
                            this.ai[2] = this.ai[2] + 15f;
                        }
                        this.ai[2] = this.ai[2] + 1f;
                    }
                    else if (this.velocity.Y == 0f)
                    {
                        this.ai[2] = (float)(-num37);
                        this.netUpdate = true;
                    }
                }
                if (this.type == 480)
                {
                    int num38 = 180;
                    int num39 = 300;
                    int num40 = 180;
                    int num41 = 60;
                    int num42 = 15;
                    if (this.life < this.lifeMax / 3)
                    {
                        num38 = 120;
                        num39 = 240;
                        num40 = 240;
                        num41 = 90;
                    }
                    if (this.ai[2] > 0f)
                    {
                        this.ai[2] = this.ai[2] - 1f;
                    }
                    else if (this.ai[2] != 0f)
                    {
                        if (this.ai[2] < 0f && this.ai[2] < (float)(-num40))
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                            if (this.velocity.Y < -2f || this.velocity.Y > 4f || this.justHit)
                            {
                                this.ai[2] = (float)num38;
                                return;
                            }
                            this.ai[2] = this.ai[2] + 1f;
                            if (this.ai[2] == 0f)
                            {
                                this.ai[2] = (float)num39;
                            }
                            return;
                        }
                        if (this.ai[2] < 0f && this.ai[2] >= (float)(-num40))
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                            if (this.velocity.Y < -2f || this.velocity.Y > 4f || this.justHit)
                            {
                                this.ai[2] = (float)num38;
                            }
                            else
                            {
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] == 0f)
                                {
                                    this.ai[2] = (float)num39;
                                }
                            }
                            if (Main.netMode != 2)
                            {
                                Player player = Main.player[Main.myPlayer];
                                int num43 = Main.myPlayer;
                                if (!player.dead && player.active && player.HasBuff(156) == -1 && (player.Center - base.Center).Length() < 1000f && (player.Center.X < base.Center.X && this.direction < 0 && player.direction > 0 || player.Center.X > base.Center.X && this.direction > 0 && player.direction < 0) && Collision.CanHit(base.Center, 1, 1, player.Center, 1, 1))
                                {
                                    player.AddBuff(156, num41 + (int)this.ai[2] * -1, true);
                                }
                            }
                            return;
                        }
                    }
                    else if ((Main.player[this.target].Center.X < base.Center.X && this.direction < 0 || Main.player[this.target].Center.X > base.Center.X && this.direction > 0) && this.velocity.Y == 0f && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                    {
                        this.ai[2] = (float)(-num40 - num42);
                        this.netUpdate = true;
                    }
                }
                if (this.type == 471)
                {
                    if (this.ai[3] >= 0f)
                    {
                        this.localAI[3] = 0f;
                        this.knockBackResist = 0.35f * Main.knockBackMultiplier;
                        NPC nPC4 = this;
                        nPC4.rotation = nPC4.rotation * 0.9f;
                        this.defense = this.defDefense;
                        this.noGravity = false;
                        this.noTileCollide = false;
                    }
                    else
                    {
                        this.knockBackResist = 0f;
                        this.defense = (int)((double)this.defDefense * 1.1);
                        this.noGravity = true;
                        this.noTileCollide = true;
                        if (this.velocity.X < 0f)
                        {
                            this.direction = -1;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.direction = 1;
                        }
                        this.rotation = this.velocity.X * 0.1f;
                        if (Main.netMode != 1)
                        {
                            this.localAI[3] = this.localAI[3] + 1f;
                            if (this.localAI[3] > (float)Main.rand.Next(20, 180))
                            {
                                this.localAI[3] = 0f;
                                Vector2 center4 = base.Center;
                                center4 = center4 + this.velocity;
                                NPC.NewNPC((int)center4.X, (int)center4.Y, 30, 0, 0f, 0f, 0f, 0f, 255);
                            }
                        }
                    }
                    if (this.ai[3] == 1f)
                    {
                        this.knockBackResist = 0f;
                        NPC nPC5 = this;
                        nPC5.defense = nPC5.defense + 10;
                    }
                    if (this.ai[3] == -1f)
                    {
                        this.TargetClosest(true);
                        float single11 = 8f;
                        float single12 = 40f;
                        Vector2 center5 = Main.player[this.target].Center - base.Center;
                        float single13 = center5.Length();
                        single11 = single11 + single13 / 200f;
                        center5.Normalize();
                        center5 = center5 * single11;
                        this.velocity = ((this.velocity * (single12 - 1f)) + center5) / single12;
                        if (single13 < 500f && !Collision.SolidCollision(this.position, this.width, this.height))
                        {
                            this.ai[3] = 0f;
                            this.ai[2] = 0f;
                        }
                        return;
                    }
                    if (this.ai[3] == -2f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.2f;
                        if (this.velocity.Y < -10f)
                        {
                            this.velocity.Y = -10f;
                        }
                        if (Main.player[this.target].Center.Y - base.Center.Y > 200f)
                        {
                            this.TargetClosest(true);
                            this.ai[3] = -3f;
                            if (Main.player[this.target].Center.X <= base.Center.X)
                            {
                                this.ai[2] = -1f;
                            }
                            else
                            {
                                this.ai[2] = 1f;
                            }
                        }
                        this.velocity.X = this.velocity.X * 0.99f;
                        return;
                    }
                    if (this.ai[3] == -3f)
                    {
                        if (this.direction == 0)
                        {
                            this.TargetClosest(true);
                        }
                        if (this.ai[2] == 0f)
                        {
                            this.ai[2] = (float)this.direction;
                        }
                        this.velocity.Y = this.velocity.Y * 0.9f;
                        this.velocity.X = this.velocity.X + this.ai[2] * 0.3f;
                        if (this.velocity.X > 10f)
                        {
                            this.velocity.X = 10f;
                        }
                        if (this.velocity.X < -10f)
                        {
                            this.velocity.X = -10f;
                        }
                        float x7 = Main.player[this.target].Center.X - base.Center.X;
                        if (this.ai[2] < 0f && x7 > 300f || this.ai[2] > 0f && x7 < -300f)
                        {
                            this.ai[3] = -4f;
                            this.ai[2] = 0f;
                            return;
                        }
                        if (Math.Abs(x7) > 800f)
                        {
                            this.ai[3] = -1f;
                            this.ai[2] = 0f;
                        }
                        return;
                    }
                    if (this.ai[3] != -4f)
                    {
                        if (this.ai[3] == 1f)
                        {
                            Vector2 y5 = base.Center;
                            y5.Y = y5.Y - 70f;
                            this.velocity.X = this.velocity.X * 0.8f;
                            this.ai[2] = this.ai[2] + 1f;
                            if (this.ai[2] == 60f)
                            {
                                if (Main.netMode != 1)
                                {
                                    NPC.NewNPC((int)y5.X, (int)y5.Y + 18, 472, 0, 0f, 0f, 0f, 0f, 255);
                                }
                            }
                            else if (this.ai[2] >= 90f)
                            {
                                this.ai[3] = -2f;
                                this.ai[2] = 0f;
                            }
                            return;
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        int num45 = 10;
                        if (this.velocity.Y != 0f || NPC.CountNPCS(472) >= num45)
                        {
                            if (NPC.CountNPCS(472) >= num45)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if (this.ai[2] >= 360f)
                            {
                                this.ai[2] = 0f;
                                this.ai[3] = -2f;
                                this.velocity.Y = this.velocity.Y - 3f;
                            }
                        }
                        else if (this.ai[2] >= 180f)
                        {
                            this.ai[2] = 0f;
                            this.ai[3] = 1f;
                        }
                        if (this.target >= 0 && !Main.player[this.target].dead && (Main.player[this.target].Center - base.Center).Length() > 800f)
                        {
                            this.ai[3] = -1f;
                            this.ai[2] = 0f;
                        }
                    }
                    else
                    {
                        this.ai[2] = this.ai[2] + 1f;
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        if (this.velocity.Length() > 4f)
                        {
                            NPC nPC6 = this;
                            nPC6.velocity = nPC6.velocity * 0.9f;
                        }
                        int x8 = (int)base.Center.X / 16;
                        int y6 = (int)(this.position.Y + (float)this.height + 12f) / 16;
                        bool flag8 = false;
                        for (int p = x8 - 1; p <= x8 + 1; p++)
                        {
                            if (Main.tile[p, y6] == null)
                            {
                                Main.tile[x8, y6] = new Tile();
                            }
                            if (Main.tile[p, y6].active() && Main.tileSolid[Main.tile[p, y6].type])
                            {
                                flag8 = true;
                            }
                        }
                        if (flag8 && !Collision.SolidCollision(this.position, this.width, this.height))
                        {
                            this.ai[3] = 0f;
                            this.ai[2] = 0f;
                        }
                        else if (this.ai[2] > 300f || base.Center.Y > Main.player[this.target].Center.Y + 200f)
                        {
                            this.ai[3] = -1f;
                            this.ai[2] = 0f;
                        }
                    }
                    if (Main.player[this.target].dead)
                    {
                        this.TargetClosest(true);
                        if (Main.player[this.target].dead && this.timeLeft > 1)
                        {
                            this.timeLeft = 1;
                        }
                    }
                }
                if (this.type == 419)
                {
                    this.reflectingProjectiles = false;
                    this.takenDamageMultiplier = 1f;
                    int num46 = 6;
                    int num47 = 10;
                    float single14 = 16f;
                    if (this.ai[2] > 0f)
                    {
                        this.ai[2] = this.ai[2] - 1f;
                    }
                    if (this.ai[2] != 0f)
                    {
                        if (this.ai[2] < 0f && this.ai[2] > (float)(-num46))
                        {
                            this.ai[2] = this.ai[2] - 1f;
                            this.velocity.X = this.velocity.X * 0.9f;
                            return;
                        }
                        if (this.ai[2] == (float)(-num46))
                        {
                            this.ai[2] = this.ai[2] - 1f;
                            this.TargetClosest(true);
                            Vector2 vector219 = base.DirectionTo(Main.player[this.target].Top + new Vector2(0f, -30f));
                            if (vector219.HasNaNs())
                            {
                                vector219 = Vector2.Normalize(new Vector2((float)this.spriteDirection, -1f));
                            }
                            this.velocity = vector219 * single14;
                            this.netUpdate = true;
                            return;
                        }
                        if (this.ai[2] < (float)(-num46))
                        {
                            this.ai[2] = this.ai[2] - 1f;
                            if (this.velocity.Y == 0f)
                            {
                                this.ai[2] = 60f;
                            }
                            else if (this.ai[2] < (float)(-num46 - num47))
                            {
                                this.velocity.Y = this.velocity.Y + 0.15f;
                                if (this.velocity.Y > 24f)
                                {
                                    this.velocity.Y = 24f;
                                }
                            }
                            this.reflectingProjectiles = true;
                            this.takenDamageMultiplier = 3f;
                            if (this.justHit)
                            {
                                this.ai[2] = 60f;
                                this.netUpdate = true;
                            }
                            return;
                        }
                    }
                    else if ((Main.player[this.target].Center.X < base.Center.X && this.direction < 0 || Main.player[this.target].Center.X > base.Center.X && this.direction > 0) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                    {
                        this.ai[2] = -1f;
                        this.netUpdate = true;
                        this.TargetClosest(true);
                    }
                }
                if (this.type == 415)
                {
                    int num48 = 42;
                    int num49 = 18;
                    if (this.justHit)
                    {
                        this.ai[2] = 120f;
                        this.netUpdate = true;
                    }
                    if (this.ai[2] > 0f)
                    {
                        this.ai[2] = this.ai[2] - 1f;
                    }
                    if (this.ai[2] == 0f)
                    {
                        int num50 = 0;
                        for (int q = 0; q < 200; q++)
                        {
                            if (Main.npc[q].active && Main.npc[q].type == 516)
                            {
                                num50++;
                            }
                        }
                        if (num50 > 6)
                        {
                            this.ai[2] = 90f;
                        }
                        else if ((Main.player[this.target].Center.X < base.Center.X && this.direction < 0 || Main.player[this.target].Center.X > base.Center.X && this.direction > 0) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[2] = -1f;
                            this.netUpdate = true;
                            this.TargetClosest(true);
                        }
                    }
                    else if (this.ai[2] < 0f && this.ai[2] > (float)(-num48))
                    {
                        this.ai[2] = this.ai[2] - 1f;
                        if (this.ai[2] == (float)(-num48))
                        {
                            this.ai[2] = (float)(180 + 30 * Main.rand.Next(10));
                        }
                        this.velocity.X = this.velocity.X * 0.8f;
                        if (this.ai[2] == (float)(-num49) || this.ai[2] == (float)(-num49 - 8) || this.ai[2] == (float)(-num49 - 16))
                        {
                            if (this.velocity.X > -0.5f && this.velocity.X < 0.5f)
                            {
                                this.velocity.X = 0f;
                            }
                            if (Main.netMode != 1)
                            {
                                NPC.NewNPC((int)base.Center.X + this.spriteDirection * 45, (int)base.Center.Y + 8, 516, 0, 0f, 0f, 0f, 0f, this.target);
                            }
                        }
                        return;
                    }
                }
                if (this.type == 428)
                {
                    this.localAI[0] = this.localAI[0] + 1f;
                    if (this.localAI[0] >= 300f)
                    {
                        int x9 = (int)base.Center.X / 16 - 1;
                        int y7 = (int)base.Center.Y / 16 - 1;
                        if (!Collision.SolidTiles(x9, x9 + 2, y7, y7 + 1) && Main.netMode != 1)
                        {
                            this.Transform(427);
                            this.life = this.lifeMax;
                            this.localAI[0] = 0f;
                            return;
                        }
                    }
                    int num51 = 0;
                    if (this.localAI[0] < 60f)
                    {
                        num51 = 16;
                    }
                    else if (this.localAI[0] < 120f)
                    {
                        num51 = 8;
                    }
                    else if (this.localAI[0] < 180f)
                    {
                        num51 = 4;
                    }
                    else if (this.localAI[0] >= 240f)
                    {
                        num51 = (this.localAI[0] >= 300f ? 1 : 1);
                    }
                    else
                    {
                        num51 = 2;
                    }
                }
                if (this.type == 427)
                {
                    this.localAI[0] = this.localAI[0] + 1f;
                    this.localAI[0] = this.localAI[0] + Math.Abs(this.velocity.X) / 2f;
                    if (this.localAI[0] >= 1200f && Main.netMode != 1)
                    {
                        int x10 = (int)base.Center.X / 16 - 2;
                        int y8 = (int)base.Center.Y / 16 - 3;
                        if (!Collision.SolidTiles(x10, x10 + 4, y8, y8 + 4))
                        {
                            this.Transform(426);
                            this.life = this.lifeMax;
                            this.localAI[0] = 0f;
                            return;
                        }
                    }
                    int num54 = 0;
                    if (this.localAI[0] < 360f)
                    {
                        num54 = 32;
                    }
                    else if (this.localAI[0] < 720f)
                    {
                        num54 = 16;
                    }
                    else if (this.localAI[0] < 1080f)
                    {
                        num54 = 6;
                    }
                    else if (this.localAI[0] >= 1440f)
                    {
                        num54 = (this.localAI[0] >= 1800f ? 1 : 1);
                    }
                    else
                    {
                        num54 = 2;
                    }
                }
                bool flag9 = false;
                if (this.velocity.X == 0f)
                {
                    flag9 = true;
                }
                if (this.justHit)
                {
                    flag9 = false;
                }
                if (Main.netMode != 1 && this.type == 198 && (double)this.life <= (double)this.lifeMax * 0.55)
                {
                    this.Transform(199);
                }
                if (Main.netMode != 1 && this.type == 348 && (double)this.life <= (double)this.lifeMax * 0.55)
                {
                    this.Transform(349);
                }
                int num57 = 60;
                if (this.type == 120)
                {
                    num57 = 180;
                    if (this.ai[3] == -120f)
                    {
                        NPC nPC7 = this;
                        nPC7.velocity = nPC7.velocity * 0f;
                        this.ai[3] = 0f;
                    }
                }
                bool flag10 = false;
                bool flag11 = true;
                if (this.type == 343 || this.type == 47 || this.type == 67 || this.type == 109 || this.type == 110 || this.type == 111 || this.type == 120 || this.type == 163 || this.type == 164 || this.type == 239 || this.type == 168 || this.type == 199 || this.type == 206 || this.type == 214 || this.type == 215 || this.type == 216 || this.type == 217 || this.type == 218 || this.type == 219 || this.type == 220 || this.type == 226 || this.type == 243 || this.type == 251 || this.type == 257 || this.type == 258 || this.type == 290 || this.type == 291 || this.type == 292 || this.type == 293 || this.type == 305 || this.type == 306 || this.type == 307 || this.type == 308 || this.type == 309 || this.type == 348 || this.type == 349 || this.type == 350 || this.type == 351 || this.type == 379 || this.type >= 430 && this.type <= 436 || this.type == 380 || this.type == 381 || this.type == 382 || this.type == 383 || this.type == 386 || this.type == 391 || this.type >= 449 && this.type <= 452 || this.type == 466 || this.type == 464 || this.type == 166 || this.type == 469 || this.type == 468 || this.type == 471 || this.type == 470 || this.type == 480 || this.type == 481 || this.type == 482 || this.type == 411 || this.type == 424 || this.type == 409 || this.type >= 494 && this.type <= 506 || this.type == 425 || this.type == 427 || this.type == 426 || this.type == 428 || this.type == 508 || this.type == 415 || this.type == 419 || this.type == 520 || this.type >= 524 && this.type <= 527 || this.type == 528 || this.type == 529 || this.type == 530 || this.type == 532)
                {
                    flag11 = false;
                }
                bool flag12 = false;
                num6 = this.type;
                if (num6 == 425 || num6 == 471)
                {
                    flag12 = true;
                }
                bool flag13 = true;
                num6 = this.type;
                if (num6 <= 350)
                {
                    if (num6 > 206)
                    {
                        switch (num6)
                        {
                            case 214:
                            case 215:
                            case 216:
                            {
                                break;
                            }
                            default:
                            {
                                switch (num6)
                                {
                                    case 291:
                                    case 292:
                                    case 293:
                                    {
                                        break;
                                    }
                                    default:
                                    {
                                        if (num6 == 350)
                                        {
                                            goto Label9;
                                        }
                                        goto Label8;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (num6)
                        {
                            case 110:
                            case 111:
                            {
                                break;
                            }
                            default:
                            {
                                if (num6 == 206)
                                {
                                    break;
                                }
                                goto Label8;
                            }
                        }
                    }
                }
                else if (num6 <= 426)
                {
                    switch (num6)
                    {
                        case 379:
                        case 380:
                        case 381:
                        case 382:
                        {
                            break;
                        }
                        default:
                        {
                            switch (num6)
                            {
                                case 409:
                                case 411:
                                {
                                    break;
                                }
                                case 410:
                                {
                                    goto Label8;
                                }
                                default:
                                {
                                    switch (num6)
                                    {
                                        case 424:
                                        case 426:
                                        {
                                            break;
                                        }
                                        default:
                                        {
                                            goto Label8;
                                        }
                                    }
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
                else if (num6 != 466)
                {
                    switch (num6)
                    {
                        case 498:
                        case 499:
                        case 500:
                        case 501:
                        case 502:
                        case 503:
                        case 504:
                        case 505:
                        case 506:
                        {
                            break;
                        }
                        default:
                        {
                            if (num6 != 520)
                            {
                                goto Label8;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            Label9:
                if (this.ai[2] > 0f)
                {
                    flag13 = false;
                }
            Label8:
                if (!flag12 && flag13)
                {
                    if (this.velocity.Y == 0f && (this.velocity.X > 0f && this.direction < 0 || this.velocity.X < 0f && this.direction > 0))
                    {
                        flag10 = true;
                    }
                    if (this.position.X == this.oldPosition.X || this.ai[3] >= (float)num57 || flag10)
                    {
                        this.ai[3] = this.ai[3] + 1f;
                    }
                    else if ((double)Math.Abs(this.velocity.X) > 0.9 && this.ai[3] > 0f)
                    {
                        this.ai[3] = this.ai[3] - 1f;
                    }
                    if (this.ai[3] > (float)(num57 * 10))
                    {
                        this.ai[3] = 0f;
                    }
                    if (this.justHit)
                    {
                        this.ai[3] = 0f;
                    }
                    if (this.ai[3] == (float)num57)
                    {
                        this.netUpdate = true;
                    }
                }
                if (this.type == 463 && Main.netMode != 1)
                {
                    if (this.localAI[3] > 0f)
                    {
                        this.localAI[3] = this.localAI[3] - 1f;
                    }
                    if (this.justHit && this.localAI[3] <= 0f && Main.rand.Next(3) == 0)
                    {
                        this.localAI[3] = 30f;
                        int num64 = Main.rand.Next(3, 6);
                        int[] numArray1 = new int[num64];
                        int num65 = 0;
                        for (int u = 0; u < 255; u++)
                        {
                            if (Main.player[u].active && !Main.player[u].dead && Collision.CanHitLine(this.position, this.width, this.height, Main.player[u].position, Main.player[u].width, Main.player[u].height))
                            {
                                numArray1[num65] = u;
                                num65++;
                                if (num65 == num64)
                                {
                                    break;
                                }
                            }
                        }
                        if (num65 > 1)
                        {
                            for (int v = 0; v < 100; v++)
                            {
                                int num66 = Main.rand.Next(num65);
                                int num67 = num66;
                                while (num67 == num66)
                                {
                                    num67 = Main.rand.Next(num65);
                                }
                                int num68 = numArray1[num66];
                                numArray1[num66] = numArray1[num67];
                                numArray1[num67] = num68;
                            }
                        }
                        Vector2 vector225 = new Vector2(-1f, -1f);
                        for (int w = 0; w < num65; w++)
                        {
                            Vector2 center7 = Main.npc[numArray1[w]].Center - base.Center;
                            center7.Normalize();
                            vector225 = vector225 + center7;
                        }
                        vector225.Normalize();
                        for (int x12 = 0; x12 < num64; x12++)
                        {
                            float single16 = (float)Main.rand.Next(8, 13);
                            Vector2 center8 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
                            center8.Normalize();
                            if (num65 > 0)
                            {
                                center8 = center8 + vector225;
                                center8.Normalize();
                            }
                            center8 = center8 * single16;
                            if (num65 > 0)
                            {
                                num65--;
                                center8 = Main.player[numArray1[num65]].Center - base.Center;
                                center8.Normalize();
                                center8 = center8 * single16;
                            }
                            Projectile.NewProjectile(base.Center.X, this.position.Y + (float)(this.width / 4), center8.X, center8.Y, 498, (int)((double)this.damage * 0.15), 1f, 255, 0f, 0f);
                        }
                    }
                }
                if (this.type == 460)
                {
                    if (this.velocity.Y < -NPC.gravity || this.velocity.Y > NPC.gravity)
                    {
                        this.knockBackResist = 0f;
                    }
                    else
                    {
                        this.knockBackResist = 0.25f * Main.knockBackMultiplier;
                    }
                }
                if (this.type == 469)
                {
                    this.knockBackResist = 0.45f * Main.knockBackMultiplier;
                    if (this.ai[2] == 1f)
                    {
                        this.knockBackResist = 0f;
                    }
                    bool flag14 = false;
                    int x13 = (int)base.Center.X / 16;
                    int y10 = (int)base.Center.Y / 16;
                    for (int y11 = x13 - 1; y11 <= x13 + 1; y11++)
                    {
                        int num69 = y10 - 1;
                        while (num69 <= y10 + 1)
                        {
                            if (Main.tile[y11, num69] == null || Main.tile[y11, num69].wall <= 0)
                            {
                                num69++;
                            }
                            else
                            {
                                flag14 = true;
                                break;
                            }
                        }
                        if (flag14)
                        {
                            break;
                        }
                    }
                    if (this.ai[2] == 0f && flag14)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.Y = -4.6f;
                            this.velocity.X = this.velocity.X * 1.3f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.ai[2] = 1f;
                        }
                    }
                    if (flag14 && this.ai[2] == 1f && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                    {
                        Vector2 center9 = Main.player[this.target].Center - base.Center;
                        float single17 = center9.Length();
                        center9.Normalize();
                        center9 = center9 * (4.5f + single17 / 300f);
                        this.velocity = ((this.velocity * 29f) + center9) / 30f;
                        this.noGravity = true;
                        this.ai[2] = 1f;
                        return;
                    }
                    this.noGravity = false;
                    this.ai[2] = 0f;
                }
                if (this.type == 462 && this.velocity.Y == 0f && (Main.player[this.target].Center - base.Center).Length() < 150f && Math.Abs(this.velocity.X) > 3f && (this.velocity.X < 0f && base.Center.X > Main.player[this.target].Center.X || this.velocity.X > 0f && base.Center.X < Main.player[this.target].Center.X))
                {
                    this.velocity.X = this.velocity.X * 1.75f;
                    this.velocity.Y = this.velocity.Y - 4.5f;
                    if (base.Center.Y - Main.player[this.target].Center.Y > 20f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.5f;
                    }
                    if (base.Center.Y - Main.player[this.target].Center.Y > 40f)
                    {
                        this.velocity.Y = this.velocity.Y - 1f;
                    }
                    if (base.Center.Y - Main.player[this.target].Center.Y > 80f)
                    {
                        this.velocity.Y = this.velocity.Y - 1.5f;
                    }
                    if (base.Center.Y - Main.player[this.target].Center.Y > 100f)
                    {
                        this.velocity.Y = this.velocity.Y - 1.5f;
                    }
                    if (Math.Abs(this.velocity.X) > 7f)
                    {
                        if (this.velocity.X >= 0f)
                        {
                            this.velocity.X = 7f;
                        }
                        else
                        {
                            this.velocity.X = -7f;
                        }
                    }
                }
                if (this.ai[3] < (float)num57 && (Main.eclipse || !Main.dayTime || (double)this.position.Y > Main.worldSurface * 16 || Main.invasionType == 1 && (this.type == 343 || this.type == 350) || Main.invasionType == 1 && (this.type == 26 || this.type == 27 || this.type == 28 || this.type == 73 || this.type == 111 || this.type == 471) || Main.invasionType == 3 && this.type >= 212 && this.type <= 216 || Main.invasionType == 4 && (this.type == 381 || this.type == 382 || this.type == 383 || this.type == 385 || this.type == 386 || this.type == 389 || this.type == 391 || this.type == 520) || this.type == 31 || this.type == 294 || this.type == 295 || this.type == 296 || this.type == 47 || this.type == 67 || this.type == 77 || this.type == 78 || this.type == 79 || this.type == 80 || this.type == 110 || this.type == 120 || this.type == 168 || this.type == 181 || this.type == 185 || this.type == 198 || this.type == 199 || this.type == 206 || this.type == 217 || this.type == 218 || this.type == 219 || this.type == 220 || this.type == 239 || this.type == 243 || this.type == 254 || this.type == 255 || this.type == 257 || this.type == 258 || this.type == 291 || this.type == 292 || this.type == 293 || this.type == 379 || this.type == 380 || this.type == 464 || this.type == 470 || this.type == 424 || this.type == 411 && (this.ai[1] >= 180f || this.ai[1] < 90f) || this.type == 409 || this.type == 425 || this.type == 429 || this.type == 427 || this.type == 428 || this.type == 508 || this.type == 415 || this.type == 419 || this.type >= 524 && this.type <= 527 || this.type == 528 || this.type == 529 || this.type == 530 || this.type == 532))
                {
                    this.TargetClosest(true);
                }
                else if (this.ai[2] <= 0f || this.type != 110 && this.type != 111 && this.type != 206 && this.type != 216 && this.type != 214 && this.type != 215 && this.type != 291 && this.type != 292 && this.type != 293 && this.type != 350 && this.type != 381 && this.type != 382 && this.type != 383 && this.type != 385 && this.type != 386 && this.type != 389 && this.type != 391 && this.type != 469 && this.type != 166 && this.type != 466 && this.type != 471 && this.type != 411 && this.type != 409 && this.type != 424 && this.type != 425 && this.type != 426 && this.type != 415 && this.type != 419 && this.type != 520)
                {
                    if (Main.dayTime && (double)(this.position.Y / 16f) < Main.worldSurface && this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                    if (this.velocity.X != 0f)
                    {
                        this.ai[0] = 0f;
                    }
                    else if (this.velocity.Y == 0f)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                        if (this.ai[0] >= 2f)
                        {
                            NPC nPC8 = this;
                            nPC8.direction = nPC8.direction * -1;
                            this.spriteDirection = this.direction;
                            this.ai[0] = 0f;
                        }
                    }
                    if (this.direction == 0)
                    {
                        this.direction = 1;
                    }
                }
                if (this.type == 159 || this.type == 349)
                {
                    if (this.type == 159 && (this.velocity.X > 0f && this.direction < 0 || this.velocity.X < 0f && this.direction > 0))
                    {
                        this.velocity.X = this.velocity.X * 0.95f;
                    }
                    if (this.velocity.X < -6f || this.velocity.X > 6f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC9 = this;
                            nPC9.velocity = nPC9.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < 6f && this.direction == 1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = 6f;
                        }
                    }
                    else if (this.velocity.X > -6f && this.direction == -1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = -6f;
                        }
                    }
                }
                else if (this.type == 199)
                {
                    if (this.velocity.X < -4f || this.velocity.X > 4f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC10 = this;
                            nPC10.velocity = nPC10.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < 4f && this.direction == 1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.8f;
                        }
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    else if (this.velocity.X > -4f && this.direction == -1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.8f;
                        }
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                }
                else if (this.type == 120 || this.type == 166 || this.type == 213 || this.type == 258 || this.type == 528 || this.type == 529)
                {
                    if (this.velocity.X < -3f || this.velocity.X > 3f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC11 = this;
                            nPC11.velocity = nPC11.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < 3f && this.direction == 1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > 3f)
                        {
                            this.velocity.X = 3f;
                        }
                    }
                    else if (this.velocity.X > -3f && this.direction == -1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -3f)
                        {
                            this.velocity.X = -3f;
                        }
                    }
                }
                else if (this.type == 461 || this.type == 27 || this.type == 77 || this.type == 104 || this.type == 163 || this.type == 162 || this.type == 196 || this.type == 197 || this.type == 212 || this.type == 257 || this.type == 326 || this.type == 343 || this.type == 348 || this.type == 351 || this.type >= 524 && this.type <= 527 || this.type == 530)
                {
                    if (this.velocity.X < -2f || this.velocity.X > 2f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC12 = this;
                            nPC12.velocity = nPC12.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < 2f && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > 2f)
                        {
                            this.velocity.X = 2f;
                        }
                    }
                    else if (this.velocity.X > -2f && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                }
                else if (this.type == 109)
                {
                    if (this.velocity.X < -2f || this.velocity.X > 2f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC13 = this;
                            nPC13.velocity = nPC13.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < 2f && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.04f;
                        if (this.velocity.X > 2f)
                        {
                            this.velocity.X = 2f;
                        }
                    }
                    else if (this.velocity.X > -2f && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.04f;
                        if (this.velocity.X < -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                }
                else if (this.type == 21 || this.type == 26 || this.type == 31 || this.type == 294 || this.type == 295 || this.type == 296 || this.type == 47 || this.type == 73 || this.type == 140 || this.type == 164 || this.type == 239 || this.type == 167 || this.type == 168 || this.type == 185 || this.type == 198 || this.type == 201 || this.type == 202 || this.type == 203 || this.type == 217 || this.type == 218 || this.type == 219 || this.type == 226 || this.type == 181 || this.type == 254 || this.type == 338 || this.type == 339 || this.type == 340 || this.type == 342 || this.type == 385 || this.type == 389 || this.type == 462 || this.type == 463 || this.type == 466 || this.type == 464 || this.type == 469 || this.type == 470 || this.type == 480 || this.type == 482 || this.type == 425 || this.type == 429)
                {
                    float single18 = 1.5f;
                    if (this.type == 294)
                    {
                        single18 = 2f;
                    }
                    else if (this.type == 295)
                    {
                        single18 = 1.75f;
                    }
                    else if (this.type == 296)
                    {
                        single18 = 1.25f;
                    }
                    else if (this.type == 201)
                    {
                        single18 = 1.1f;
                    }
                    else if (this.type == 202)
                    {
                        single18 = 0.9f;
                    }
                    else if (this.type == 203)
                    {
                        single18 = 1.2f;
                    }
                    else if (this.type == 338)
                    {
                        single18 = 1.75f;
                    }
                    else if (this.type == 339)
                    {
                        single18 = 1.25f;
                    }
                    else if (this.type == 340)
                    {
                        single18 = 2f;
                    }
                    else if (this.type == 385)
                    {
                        single18 = 1.8f;
                    }
                    else if (this.type == 389)
                    {
                        single18 = 2.25f;
                    }
                    else if (this.type == 462)
                    {
                        single18 = 4f;
                    }
                    else if (this.type == 463)
                    {
                        single18 = 0.75f;
                    }
                    else if (this.type == 466)
                    {
                        single18 = 3.75f;
                    }
                    else if (this.type == 469)
                    {
                        single18 = 3.25f;
                    }
                    else if (this.type == 480)
                    {
                        single18 = 1.5f + (1f - (float)this.life / (float)this.lifeMax) * 2f;
                    }
                    else if (this.type == 425)
                    {
                        single18 = 6f;
                    }
                    else if (this.type == 429)
                    {
                        single18 = 4f;
                    }
                    if (this.type == 21 || this.type == 201 || this.type == 202 || this.type == 203 || this.type == 342)
                    {
                        single18 = single18 * (1f + (1f - this.scale));
                    }
                    if (this.velocity.X < -single18 || this.velocity.X > single18)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC14 = this;
                            nPC14.velocity = nPC14.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < single18 && this.direction == 1)
                    {
                        if (this.type == 466 && this.velocity.X < -2f)
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                        }
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > single18)
                        {
                            this.velocity.X = single18;
                        }
                    }
                    else if (this.velocity.X > -single18 && this.direction == -1)
                    {
                        if (this.type == 466 && this.velocity.X > 2f)
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                        }
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -single18)
                        {
                            this.velocity.X = -single18;
                        }
                    }
                    if (this.velocity.Y == 0f && this.type == 462 && (this.direction > 0 && this.velocity.X < 0f || this.direction < 0 && this.velocity.X > 0f))
                    {
                        this.velocity.X = this.velocity.X * 0.9f;
                    }
                }
                else if (this.type >= 269 && this.type <= 280)
                {
                    float single19 = 1.5f;
                    if (this.type == 269)
                    {
                        single19 = 2f;
                    }
                    if (this.type == 270)
                    {
                        single19 = 1f;
                    }
                    if (this.type == 271)
                    {
                        single19 = 1.5f;
                    }
                    if (this.type == 272)
                    {
                        single19 = 3f;
                    }
                    if (this.type == 273)
                    {
                        single19 = 1.25f;
                    }
                    if (this.type == 274)
                    {
                        single19 = 3f;
                    }
                    if (this.type == 275)
                    {
                        single19 = 3.25f;
                    }
                    if (this.type == 276)
                    {
                        single19 = 2f;
                    }
                    if (this.type == 277)
                    {
                        single19 = 2.75f;
                    }
                    if (this.type == 278)
                    {
                        single19 = 1.8f;
                    }
                    if (this.type == 279)
                    {
                        single19 = 1.3f;
                    }
                    if (this.type == 280)
                    {
                        single19 = 2.5f;
                    }
                    single19 = single19 * (1f + (1f - this.scale));
                    if (this.velocity.X < -single19 || this.velocity.X > single19)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC15 = this;
                            nPC15.velocity = nPC15.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < single19 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > single19)
                        {
                            this.velocity.X = single19;
                        }
                    }
                    else if (this.velocity.X > -single19 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -single19)
                        {
                            this.velocity.X = -single19;
                        }
                    }
                }
                else if (this.type >= 305 && this.type <= 314)
                {
                    float single20 = 1.5f;
                    if (this.type == 305 || this.type == 310)
                    {
                        single20 = 2f;
                    }
                    if (this.type == 306 || this.type == 311)
                    {
                        single20 = 1.25f;
                    }
                    if (this.type == 307 || this.type == 312)
                    {
                        single20 = 2.25f;
                    }
                    if (this.type == 308 || this.type == 313)
                    {
                        single20 = 1.5f;
                    }
                    if (this.type == 309 || this.type == 314)
                    {
                        single20 = 1f;
                    }
                    if (this.type < 310)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.85f;
                            if ((double)this.velocity.X > -0.3 && (double)this.velocity.X < 0.3)
                            {
                                this.velocity.Y = -7f;
                                this.velocity.X = single20 * (float)this.direction;
                            }
                        }
                        else if (this.spriteDirection == this.direction)
                        {
                            this.velocity.X = (this.velocity.X * 10f + single20 * (float)this.direction) / 11f;
                        }
                    }
                    else if (this.velocity.X < -single20 || this.velocity.X > single20)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC16 = this;
                            nPC16.velocity = nPC16.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < single20 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > single20)
                        {
                            this.velocity.X = single20;
                        }
                    }
                    else if (this.velocity.X > -single20 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -single20)
                        {
                            this.velocity.X = -single20;
                        }
                    }
                }
                else if (this.type == 67 || this.type == 220 || this.type == 428)
                {
                    if (this.velocity.X < -0.5f || this.velocity.X > 0.5f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC17 = this;
                            nPC17.velocity = nPC17.velocity * 0.7f;
                        }
                    }
                    else if (this.velocity.X < 0.5f && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.03f;
                        if (this.velocity.X > 0.5f)
                        {
                            this.velocity.X = 0.5f;
                        }
                    }
                    else if (this.velocity.X > -0.5f && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.03f;
                        if (this.velocity.X < -0.5f)
                        {
                            this.velocity.X = -0.5f;
                        }
                    }
                }
                else if (this.type == 78 || this.type == 79 || this.type == 80)
                {
                    float single21 = 1f;
                    float single22 = 0.05f;
                    if (this.life < this.lifeMax / 2)
                    {
                        single21 = 2f;
                        single22 = 0.1f;
                    }
                    if (this.type == 79)
                    {
                        single21 = single21 * 1.5f;
                    }
                    if (this.velocity.X < -single21 || this.velocity.X > single21)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC18 = this;
                            nPC18.velocity = nPC18.velocity * 0.7f;
                        }
                    }
                    else if (this.velocity.X < single21 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + single22;
                        if (this.velocity.X > single21)
                        {
                            this.velocity.X = single21;
                        }
                    }
                    else if (this.velocity.X > -single21 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - single22;
                        if (this.velocity.X < -single21)
                        {
                            this.velocity.X = -single21;
                        }
                    }
                }
                else if (this.type == 287)
                {
                    float single23 = 5f;
                    float single24 = 0.2f;
                    if (this.velocity.X < -single23 || this.velocity.X > single23)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC19 = this;
                            nPC19.velocity = nPC19.velocity * 0.7f;
                        }
                    }
                    else if (this.velocity.X < single23 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + single24;
                        if (this.velocity.X > single23)
                        {
                            this.velocity.X = single23;
                        }
                    }
                    else if (this.velocity.X > -single23 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - single24;
                        if (this.velocity.X < -single23)
                        {
                            this.velocity.X = -single23;
                        }
                    }
                }
                else if (this.type == 243)
                {
                    float single25 = 1f;
                    float single26 = 0.07f;
                    single25 = single25 + (1f - (float)this.life / (float)this.lifeMax) * 1.5f;
                    single26 = single26 + (1f - (float)this.life / (float)this.lifeMax) * 0.15f;
                    if (this.velocity.X < -single25 || this.velocity.X > single25)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC20 = this;
                            nPC20.velocity = nPC20.velocity * 0.7f;
                        }
                    }
                    else if (this.velocity.X < single25 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + single26;
                        if (this.velocity.X > single25)
                        {
                            this.velocity.X = single25;
                        }
                    }
                    else if (this.velocity.X > -single25 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - single26;
                        if (this.velocity.X < -single25)
                        {
                            this.velocity.X = -single25;
                        }
                    }
                }
                else if (this.type == 251)
                {
                    float single27 = 1f;
                    float single28 = 0.08f;
                    single27 = single27 + (1f - (float)this.life / (float)this.lifeMax) * 2f;
                    single28 = single28 + (1f - (float)this.life / (float)this.lifeMax) * 0.2f;
                    if (this.velocity.X < -single27 || this.velocity.X > single27)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC21 = this;
                            nPC21.velocity = nPC21.velocity * 0.7f;
                        }
                    }
                    else if (this.velocity.X < single27 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + single28;
                        if (this.velocity.X > single27)
                        {
                            this.velocity.X = single27;
                        }
                    }
                    else if (this.velocity.X > -single27 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - single28;
                        if (this.velocity.X < -single27)
                        {
                            this.velocity.X = -single27;
                        }
                    }
                }
                else if (this.type == 386)
                {
                    if (this.ai[2] <= 0f)
                    {
                        float single29 = 0.15f;
                        float single30 = 1.5f;
                        if (this.velocity.X < -single30 || this.velocity.X > single30)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                NPC nPC22 = this;
                                nPC22.velocity = nPC22.velocity * 0.7f;
                            }
                        }
                        else if (this.velocity.X < single30 && this.direction == 1)
                        {
                            this.velocity.X = this.velocity.X + single29;
                            if (this.velocity.X > single30)
                            {
                                this.velocity.X = single30;
                            }
                        }
                        else if (this.velocity.X > -single30 && this.direction == -1)
                        {
                            this.velocity.X = this.velocity.X - single29;
                            if (this.velocity.X < -single30)
                            {
                                this.velocity.X = -single30;
                            }
                        }
                    }
                    else if (this.velocity.Y == 0f)
                    {
                        this.velocity.X = this.velocity.X * 0.8f;
                    }
                }
                else if (this.type == 460)
                {
                    float single31 = 3f;
                    float single32 = 0.1f;
                    if (Math.Abs(this.velocity.X) > 2f)
                    {
                        single32 = single32 * 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 2.5)
                    {
                        single32 = single32 * 0.8f;
                    }
                    if (Math.Abs(this.velocity.X) > 3f)
                    {
                        single32 = single32 * 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 3.5)
                    {
                        single32 = single32 * 0.8f;
                    }
                    if (Math.Abs(this.velocity.X) > 4f)
                    {
                        single32 = single32 * 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 4.5)
                    {
                        single32 = single32 * 0.8f;
                    }
                    if (Math.Abs(this.velocity.X) > 5f)
                    {
                        single32 = single32 * 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 5.5)
                    {
                        single32 = single32 * 0.8f;
                    }
                    single31 = single31 + (1f - (float)this.life / (float)this.lifeMax) * 3f;
                    if (this.velocity.X < -single31 || this.velocity.X > single31)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC23 = this;
                            nPC23.velocity = nPC23.velocity * 0.7f;
                        }
                    }
                    else if (this.velocity.X < single31 && this.direction == 1)
                    {
                        if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.93f;
                        }
                        this.velocity.X = this.velocity.X + single32;
                        if (this.velocity.X > single31)
                        {
                            this.velocity.X = single31;
                        }
                    }
                    else if (this.velocity.X > -single31 && this.direction == -1)
                    {
                        if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.93f;
                        }
                        this.velocity.X = this.velocity.X - single32;
                        if (this.velocity.X < -single31)
                        {
                            this.velocity.X = -single31;
                        }
                    }
                }
                else if (this.type == 508)
                {
                    float single33 = 2.5f;
                    float single34 = 40f;
                    float single35 = Math.Abs(this.velocity.X);
                    if (single35 > 2.75f)
                    {
                        single33 = 3.5f;
                        single34 = single34 + 80f;
                    }
                    else if ((double)single35 > 2.25)
                    {
                        single33 = 3f;
                        single34 = single34 + 60f;
                    }
                    if ((double)Math.Abs(this.velocity.Y) < 0.5)
                    {
                        if (this.velocity.X > 0f && this.direction < 0)
                        {
                            NPC nPC24 = this;
                            nPC24.velocity = nPC24.velocity * 0.9f;
                        }
                        if (this.velocity.X < 0f && this.direction > 0)
                        {
                            NPC nPC25 = this;
                            nPC25.velocity = nPC25.velocity * 0.9f;
                        }
                    }
                    if (Math.Abs(this.velocity.Y) > NPC.gravity)
                    {
                        single34 = single34 * 3f;
                    }
                    if (this.velocity.X <= 0f && this.direction < 0)
                    {
                        this.velocity.X = (this.velocity.X * single34 - single33) / (single34 + 1f);
                    }
                    else if (this.velocity.X >= 0f && this.direction > 0)
                    {
                        this.velocity.X = (this.velocity.X * single34 + single33) / (single34 + 1f);
                    }
                    else if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 20f && Math.Abs(this.velocity.Y) <= NPC.gravity)
                    {
                        this.velocity.X = this.velocity.X * 0.99f;
                        this.velocity.X = this.velocity.X + (float)this.direction * 0.025f;
                    }
                }
                else if (this.type == 391 || this.type == 427 || this.type == 415 || this.type == 419 || this.type == 518 || this.type == 532)
                {
                    float single36 = 5f;
                    float single37 = 0.25f;
                    float single38 = 0.7f;
                    if (this.type == 427)
                    {
                        single36 = 6f;
                        single37 = 0.2f;
                        single38 = 0.8f;
                    }
                    else if (this.type == 415)
                    {
                        single36 = 4f;
                        single37 = 0.1f;
                        single38 = 0.95f;
                    }
                    else if (this.type == 419)
                    {
                        single36 = 6f;
                        single37 = 0.15f;
                        single38 = 0.85f;
                    }
                    else if (this.type == 518)
                    {
                        single36 = 5f;
                        single37 = 0.1f;
                        single38 = 0.95f;
                    }
                    else if (this.type == 532)
                    {
                        single36 = 5f;
                        single37 = 0.15f;
                        single38 = 0.98f;
                    }
                    if (this.velocity.X < -single36 || this.velocity.X > single36)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC26 = this;
                            nPC26.velocity = nPC26.velocity * single38;
                        }
                    }
                    else if (this.velocity.X < single36 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + single37;
                        if (this.velocity.X > single36)
                        {
                            this.velocity.X = single36;
                        }
                    }
                    else if (this.velocity.X > -single36 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - single37;
                        if (this.velocity.X < -single36)
                        {
                            this.velocity.X = -single36;
                        }
                    }
                }
                else if (this.type >= 430 && this.type <= 436 || this.type == 494 || this.type == 495)
                {
                    if (this.ai[2] != 0f)
                    {
                        this.damage = (int)((double)this.defDamage * 1.5);
                        this.ai[3] = 1f;
                        this.velocity.X = this.velocity.X * 0.9f;
                        if ((double)Math.Abs(this.velocity.X) < 0.1)
                        {
                            this.velocity.X = 0f;
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] >= 20f || this.velocity.Y != 0f || Main.dayTime && (double)this.position.Y < Main.worldSurface * 16)
                        {
                            this.ai[2] = 0f;
                        }
                    }
                    else
                    {
                        this.damage = this.defDamage;
                        float single39 = 1f;
                        single39 = single39 * (1f + (1f - this.scale));
                        if (this.velocity.X < -single39 || this.velocity.X > single39)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                NPC nPC27 = this;
                                nPC27.velocity = nPC27.velocity * 0.8f;
                            }
                        }
                        else if (this.velocity.X < single39 && this.direction == 1)
                        {
                            this.velocity.X = this.velocity.X + 0.07f;
                            if (this.velocity.X > single39)
                            {
                                this.velocity.X = single39;
                            }
                        }
                        else if (this.velocity.X > -single39 && this.direction == -1)
                        {
                            this.velocity.X = this.velocity.X - 0.07f;
                            if (this.velocity.X < -single39)
                            {
                                this.velocity.X = -single39;
                            }
                        }
                        if (this.velocity.Y == 0f && (!Main.dayTime || (double)this.position.Y > Main.worldSurface * 16) && !Main.player[this.target].dead)
                        {
                            Vector2 center10 = base.Center - Main.player[this.target].Center;
                            int num70 = 50;
                            if (this.type >= 494 && this.type <= 495)
                            {
                                num70 = 42;
                            }
                            if (center10.Length() < (float)num70 && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                this.velocity.X = this.velocity.X * 0.7f;
                                this.ai[2] = 1f;
                            }
                        }
                    }
                }
                else if (this.type != 110 && this.type != 111 && this.type != 206 && this.type != 214 && this.type != 215 && this.type != 216 && this.type != 290 && this.type != 291 && this.type != 292 && this.type != 293 && this.type != 350 && this.type != 379 && this.type != 380 && this.type != 381 && this.type != 382 && (this.type < 449 || this.type > 452) && this.type != 468 && this.type != 481 && this.type != 411 && this.type != 409 && (this.type < 498 || this.type > 506) && this.type != 424 && this.type != 426 && this.type != 520)
                {
                    float single40 = 1f;
                    if (this.type == 186)
                    {
                        single40 = 1.1f;
                    }
                    if (this.type == 187)
                    {
                        single40 = 0.9f;
                    }
                    if (this.type == 188)
                    {
                        single40 = 1.2f;
                    }
                    if (this.type == 189)
                    {
                        single40 = 0.8f;
                    }
                    if (this.type == 132)
                    {
                        single40 = 0.95f;
                    }
                    if (this.type == 200)
                    {
                        single40 = 0.87f;
                    }
                    if (this.type == 223)
                    {
                        single40 = 1.05f;
                    }
                    if (this.type == 489)
                    {
                        Vector2 center11 = Main.player[this.target].Center - base.Center;
                        float single41 = center11.Length();
                        single41 = single41 * 0.0025f;
                        if ((double)single41 > 1.5)
                        {
                            single41 = 1.5f;
                        }
                        single40 = (!Main.expertMode ? 2.5f - single41 : 3f - single41);
                        single40 = single40 * 0.8f;
                    }
                    if (this.type == 489 || this.type == 3 || this.type == 132 || this.type == 186 || this.type == 187 || this.type == 188 || this.type == 189 || this.type == 200 || this.type == 223 || this.type == 331 || this.type == 332)
                    {
                        single40 = single40 * (1f + (1f - this.scale));
                    }
                    if (this.velocity.X < -single40 || this.velocity.X > single40)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            NPC nPC28 = this;
                            nPC28.velocity = nPC28.velocity * 0.8f;
                        }
                    }
                    else if (this.velocity.X < single40 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > single40)
                        {
                            this.velocity.X = single40;
                        }
                    }
                    else if (this.velocity.X > -single40 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -single40)
                        {
                            this.velocity.X = -single40;
                        }
                    }
                }
                else if (this.type == 415)
                {
                    this.hide = false;
                    int num71 = 0;
                    while (num71 < 200)
                    {
                        if (!Main.npc[num71].active || Main.npc[num71].type != 416 || Main.npc[num71].ai[0] != (float)this.whoAmI)
                        {
                            num71++;
                        }
                        else
                        {
                            this.hide = true;
                            goto Label10;
                        }
                    }
                }
                else if (this.type == 258)
                {
                    if (this.velocity.Y != 0f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = this.direction;
                        if (Main.player[this.target].Center.X < this.position.X && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.95f;
                        }
                        else if (Main.player[this.target].Center.X > this.position.X + (float)this.width && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.95f;
                        }
                        if (Main.player[this.target].Center.X < this.position.X && this.velocity.X > -5f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (Main.player[this.target].Center.X > this.position.X + (float)this.width && this.velocity.X < 5f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 50f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -7f;
                    }
                }
                else if (this.type == 425)
                {
                    if (this.velocity.Y == 0f)
                    {
                        this.ai[2] = 0f;
                    }
                    if (this.velocity.Y != 0f && this.ai[2] == 1f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = -this.direction;
                        if (Collision.CanHit(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            float x14 = Main.player[this.target].Center.X - (float)(this.direction * 400) - base.Center.X;
                            float y12 = Main.player[this.target].Bottom.Y - base.Bottom.Y;
                            if (x14 < 0f && this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            else if (x14 > 0f && this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (x14 < 0f && this.velocity.X > -5f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (x14 > 0f && this.velocity.X < 5f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = 6f;
                            }
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = -6f;
                            }
                            if (y12 < -20f && this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.8f;
                            }
                            else if (y12 > 20f && this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.8f;
                            }
                            if (y12 < -20f && this.velocity.Y > -5f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.3f;
                            }
                            else if (y12 > 20f && this.velocity.Y < 5f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.3f;
                            }
                        }
                        for (int a = 0; a < 200; a++)
                        {
                            if (a != this.whoAmI && Main.npc[a].active && Main.npc[a].type == this.type && Math.Abs(this.position.X - Main.npc[a].position.X) + Math.Abs(this.position.Y - Main.npc[a].position.Y) < (float)this.width)
                            {
                                if (this.position.X >= Main.npc[a].position.X)
                                {
                                    this.velocity.X = this.velocity.X + 0.05f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X - 0.05f;
                                }
                                if (this.position.Y >= Main.npc[a].position.Y)
                                {
                                    this.velocity.Y = this.velocity.Y + 0.05f;
                                }
                                else
                                {
                                    this.velocity.Y = this.velocity.Y - 0.05f;
                                }
                            }
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 100f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -5f;
                        this.ai[2] = 1f;
                    }
                    if (Main.netMode != 1)
                    {
                        this.localAI[2] = this.localAI[2] + 1f;
                        if (this.localAI[2] >= (float)(360 + Main.rand.Next(360)) && base.Distance(Main.player[this.target].Center) < 400f && Math.Abs(base.DirectionTo(Main.player[this.target].Center).Y) < 0.5f && Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            this.localAI[2] = 0f;
                            Vector2 center13 = base.Center + new Vector2((float)(this.direction * 30), 2f);
                            Vector2 vector227 = base.DirectionTo(Main.player[this.target].Center) * 7f;
                            if (vector227.HasNaNs())
                            {
                                vector227 = new Vector2((float)(this.direction * 8), 0f);
                            }
                            int num72 = (Main.expertMode ? 50 : 75);
                            for (int b = 0; b < 4; b++)
                            {
                                Vector2 vector228 = vector227 + Utils.RandomVector2(Main.rand, -0.8f, 0.8f);
                                Projectile.NewProjectile(center13.X, center13.Y, vector228.X, vector228.Y, 577, num72, 1f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                else if (this.type == 427)
                {
                    if (this.velocity.Y != 0f)
                    {
                        this.rotation = this.velocity.X * 0.1f;
                    }
                    else
                    {
                        this.ai[2] = 0f;
                        this.rotation = 0f;
                    }
                    if (this.velocity.Y != 0f && this.ai[2] == 1f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = -this.direction;
                        if (Collision.CanHit(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            float x15 = Main.player[this.target].Center.X - base.Center.X;
                            float y13 = Main.player[this.target].Center.Y - base.Center.Y;
                            if (x15 < 0f && this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            else if (x15 > 0f && this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            if (x15 < -20f && this.velocity.X > -6f)
                            {
                                this.velocity.X = this.velocity.X - 0.015f;
                            }
                            else if (x15 > 20f && this.velocity.X < 6f)
                            {
                                this.velocity.X = this.velocity.X + 0.015f;
                            }
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = 6f;
                            }
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = -6f;
                            }
                            if (y13 < -20f && this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.98f;
                            }
                            else if (y13 > 20f && this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.98f;
                            }
                            if (y13 < -20f && this.velocity.Y > -6f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.15f;
                            }
                            else if (y13 > 20f && this.velocity.Y < 6f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.15f;
                            }
                        }
                        for (int c = 0; c < 200; c++)
                        {
                            if (c != this.whoAmI && Main.npc[c].active && Main.npc[c].type == this.type && Math.Abs(this.position.X - Main.npc[c].position.X) + Math.Abs(this.position.Y - Main.npc[c].position.Y) < (float)this.width)
                            {
                                if (this.position.X >= Main.npc[c].position.X)
                                {
                                    this.velocity.X = this.velocity.X + 0.05f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X - 0.05f;
                                }
                                if (this.position.Y >= Main.npc[c].position.Y)
                                {
                                    this.velocity.Y = this.velocity.Y + 0.05f;
                                }
                                else
                                {
                                    this.velocity.Y = this.velocity.Y - 0.05f;
                                }
                            }
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 100f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -5f;
                        this.ai[2] = 1f;
                    }
                }
                else if (this.type == 426)
                {
                    if (this.ai[1] > 0f && this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.85f;
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.Y = -0.4f;
                        }
                    }
                    if (this.velocity.Y != 0f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = this.direction;
                        if (Collision.CanHit(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            float x16 = Main.player[this.target].Center.X - (float)(this.direction * 300) - base.Center.X;
                            if (x16 < 40f && this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            else if (x16 > 40f && this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            if (x16 < 40f && this.velocity.X > -5f)
                            {
                                this.velocity.X = this.velocity.X - 0.2f;
                            }
                            else if (x16 > 40f && this.velocity.X < 5f)
                            {
                                this.velocity.X = this.velocity.X + 0.2f;
                            }
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = 6f;
                            }
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = -6f;
                            }
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 100f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -6f;
                    }
                    for (int d = 0; d < 200; d++)
                    {
                        if (d != this.whoAmI && Main.npc[d].active && Main.npc[d].type == this.type && Math.Abs(this.position.X - Main.npc[d].position.X) + Math.Abs(this.position.Y - Main.npc[d].position.Y) < (float)this.width)
                        {
                            if (this.position.X >= Main.npc[d].position.X)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            if (this.position.Y >= Main.npc[d].position.Y)
                            {
                                this.velocity.Y = this.velocity.Y + 0.1f;
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y - 0.1f;
                            }
                        }
                    }
                }
                else if (this.type != 185)
                {
                    if (this.type == 428)
                    {
                        if (this.velocity.Y != 0f)
                        {
                            NPC x19 = this;
                            x19.rotation = x19.rotation + this.velocity.X * 0.08f;
                        }
                        else
                        {
                            this.rotation = 0f;
                        }
                    }
                }
                else if (this.velocity.Y == 0f)
                {
                    this.rotation = 0f;
                    this.localAI[0] = 0f;
                }
                else if (this.localAI[0] == 1f)
                {
                    NPC x20 = this;
                    x20.rotation = x20.rotation + this.velocity.X * 0.05f;
                }
            Label10:
                if (this.type == 159 && Main.netMode != 1)
                {
                    Vector2 vector229 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x21 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector229.X;
                    float y16 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector229.Y;
                    if ((float)Math.Sqrt((double)(x21 * x21 + y16 * y16)) > 300f)
                    {
                        this.Transform(158);
                    }
                }
                if (this.type == 164 && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int x22 = (int)base.Center.X / 16;
                    int y17 = (int)base.Center.Y / 16;
                    bool flag15 = false;
                    for (int e = x22 - 1; e <= x22 + 1; e++)
                    {
                        for (int f = y17 - 1; f <= y17 + 1; f++)
                        {
                            if (Main.tile[e, f].wall > 0)
                            {
                                flag15 = true;
                            }
                        }
                    }
                    if (flag15)
                    {
                        this.Transform(165);
                    }
                }
                if (this.type == 239 && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int x23 = (int)base.Center.X / 16;
                    int y18 = (int)base.Center.Y / 16;
                    bool flag16 = false;
                    for (int g = x23 - 1; g <= x23 + 1; g++)
                    {
                        for (int h = y18 - 1; h <= y18 + 1; h++)
                        {
                            if (Main.tile[g, h].wall > 0)
                            {
                                flag16 = true;
                            }
                        }
                    }
                    if (flag16)
                    {
                        this.Transform(240);
                    }
                }
                if (this.type == 530 && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int x24 = (int)base.Center.X / 16;
                    int y19 = (int)base.Center.Y / 16;
                    bool flag17 = false;
                    for (int i1 = x24 - 1; i1 <= x24 + 1; i1++)
                    {
                        for (int j1 = y19 - 1; j1 <= y19 + 1; j1++)
                        {
                            if (Main.tile[i1, j1].wall > 0)
                            {
                                flag17 = true;
                            }
                        }
                    }
                    if (flag17)
                    {
                        this.Transform(531);
                    }
                }
                if (Main.netMode != 1 && Main.expertMode && this.target >= 0 && (this.type == 163 || this.type == 238) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                {
                    this.localAI[0] = this.localAI[0] + 1f;
                    if (this.justHit)
                    {
                        this.localAI[0] = this.localAI[0] - (float)Main.rand.Next(20, 60);
                        if (this.localAI[0] < 0f)
                        {
                            this.localAI[0] = 0f;
                        }
                    }
                    if (this.localAI[0] > (float)Main.rand.Next(180, 900))
                    {
                        this.localAI[0] = 0f;
                        Vector2 center17 = Main.player[this.target].Center - base.Center;
                        center17.Normalize();
                        center17 = center17 * 8f;
                        Projectile.NewProjectile(base.Center.X, base.Center.Y, center17.X, center17.Y, 472, 18, 0f, Main.myPlayer, 0f, 0f);
                    }
                }
                if (this.type == 163 && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int x25 = (int)base.Center.X / 16;
                    int y20 = (int)base.Center.Y / 16;
                    bool flag18 = false;
                    for (int k1 = x25 - 1; k1 <= x25 + 1; k1++)
                    {
                        for (int l1 = y20 - 1; l1 <= y20 + 1; l1++)
                        {
                            if (Main.tile[k1, l1].wall > 0)
                            {
                                flag18 = true;
                            }
                        }
                    }
                    if (flag18)
                    {
                        this.Transform(238);
                    }
                }
                if (this.type == 236 && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int x26 = (int)base.Center.X / 16;
                    int y21 = (int)base.Center.Y / 16;
                    bool flag19 = false;
                    for (int m1 = x26 - 1; m1 <= x26 + 1; m1++)
                    {
                        for (int n1 = y21 - 1; n1 <= y21 + 1; n1++)
                        {
                            if (Main.tile[m1, n1].wall > 0)
                            {
                                flag19 = true;
                            }
                        }
                    }
                    if (flag19)
                    {
                        this.Transform(237);
                    }
                }
                if (this.type == 243)
                {
                    if (this.justHit && Main.rand.Next(3) == 0)
                    {
                        this.ai[2] = this.ai[2] - (float)Main.rand.Next(30);
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.ai[2] = 0f;
                    }
                    if (this.confused)
                    {
                        this.ai[2] = 0f;
                    }
                    this.ai[2] = this.ai[2] + 1f;
                    float single42 = (float)Main.rand.Next(30, 900);
                    single42 = single42 * ((float)this.life / (float)this.lifeMax);
                    single42 = single42 + 30f;
                    if (Main.netMode != 1 && this.ai[2] >= single42 && this.velocity.Y == 0f && !Main.player[this.target].dead && !Main.player[this.target].frozen && (this.direction > 0 && base.Center.X < Main.player[this.target].Center.X || this.direction < 0 && base.Center.X > Main.player[this.target].Center.X) && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        float single43 = 15f;
                        Vector2 y22 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + 20f);
                        float x27 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - y22.X;
                        float y23 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - y22.Y;
                        x27 = x27 + (float)Main.rand.Next(-40, 41);
                        y23 = y23 + (float)Main.rand.Next(-40, 41);
                        float single44 = (float)Math.Sqrt((double)(x27 * x27 + y23 * y23));
                        this.netUpdate = true;
                        single44 = single43 / single44;
                        x27 = x27 * single44;
                        y23 = y23 * single44;
                        int num74 = 32;
                        int num75 = 257;
                        y22.X = y22.X + x27 * 3f;
                        y22.Y = y22.Y + y23 * 3f;
                        Projectile.NewProjectile(y22.X, y22.Y, x27, y23, num75, num74, 0f, Main.myPlayer, 0f, 0f);
                        this.ai[2] = 0f;
                    }
                }
                if (this.type == 251)
                {
                    if (this.justHit)
                    {
                        this.ai[2] = this.ai[2] - (float)Main.rand.Next(30);
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.ai[2] = 0f;
                    }
                    if (this.confused)
                    {
                        this.ai[2] = 0f;
                    }
                    this.ai[2] = this.ai[2] + 1f;
                    float single45 = (float)Main.rand.Next(60, 1800);
                    single45 = single45 * ((float)this.life / (float)this.lifeMax);
                    single45 = single45 + 15f;
                    if (Main.netMode != 1 && this.ai[2] >= single45 && this.velocity.Y == 0f && !Main.player[this.target].dead && !Main.player[this.target].frozen && (this.direction > 0 && base.Center.X < Main.player[this.target].Center.X || this.direction < 0 && base.Center.X > Main.player[this.target].Center.X) && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        float single46 = 15f;
                        Vector2 y24 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + 12f);
                        float x28 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - y24.X;
                        float y25 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - y24.Y;
                        x28 = x28 + (float)Main.rand.Next(-40, 41);
                        y25 = y25 + (float)Main.rand.Next(-30, 0);
                        float single47 = (float)Math.Sqrt((double)(x28 * x28 + y25 * y25));
                        this.netUpdate = true;
                        single47 = single46 / single47;
                        x28 = x28 * single47;
                        y25 = y25 * single47;
                        int num76 = 30;
                        int num77 = 83;
                        y24.X = y24.X + x28 * 3f;
                        y24.Y = y24.Y + y25 * 3f;
                        Projectile.NewProjectile(y24.X, y24.Y, x28, y25, num77, num76, 0f, Main.myPlayer, 0f, 0f);
                        this.ai[2] = 0f;
                    }
                }
                if (this.type == 386)
                {
                    if (!this.confused)
                    {
                        if (this.ai[2] < 60f)
                        {
                            this.ai[2] = this.ai[2] + 1f;
                        }
                        if (this.ai[2] > 0f && NPC.CountNPCS(387) >= 4 * NPC.CountNPCS(386))
                        {
                            this.ai[2] = 0f;
                        }
                        if (this.justHit)
                        {
                            this.ai[2] = -30f;
                        }
                        if (this.ai[2] == 30f)
                        {
                            int x29 = (int)this.position.X / 16;
                            int y26 = (int)this.position.Y / 16;
                            int x30 = (int)this.position.X / 16;
                            int y27 = (int)this.position.Y / 16;
                            int num78 = 5;
                            int num79 = 0;
                            bool flag20 = false;
                            int num80 = 2;
                            int num81 = 0;
                        Label11:
                            while (!flag20 && num79 < 100)
                            {
                                num79++;
                                int num82 = Main.rand.Next(x29 - num78, x29 + num78);
                                int num83 = Main.rand.Next(y26 - num78, y26 + num78);
                                for (int o1 = num83; o1 < y26 + num78; o1++)
                                {
                                    if ((o1 < y26 - num80 || o1 > y26 + num80 || num82 < x29 - num80 || num82 > x29 + num80) && (o1 < y27 - num81 || o1 > y27 + num81 || num82 < x30 - num81 || num82 > x30 + num81) && Main.tile[num82, o1].nactive())
                                    {
                                        bool flag21 = true;
                                        if (Main.tile[num82, o1 - 1].lava())
                                        {
                                            flag21 = false;
                                        }
                                        if (flag21 && Main.tileSolid[Main.tile[num82, o1].type] && !Collision.SolidTiles(num82 - 1, num82 + 1, o1 - 4, o1 - 1))
                                        {
                                            int num84 = NPC.NewNPC(num82 * 16 - this.width / 2, o1 * 16, 387, 0, 0f, 0f, 0f, 0f, 255);
                                            Main.npc[num84].position.Y = (float)(o1 * 16 - Main.npc[num84].height);
                                            flag20 = true;
                                            this.netUpdate = true;
                                            goto Label11;
                                        }
                                    }
                                }
                            }
                        }
                        if (this.ai[2] == 60f)
                        {
                            this.ai[2] = -120f;
                        }
                    }
                    else
                    {
                        this.ai[2] = -60f;
                    }
                }
                if (this.type == 389)
                {
                    if (!this.confused)
                    {
                        if (this.ai[2] < 20f)
                        {
                            this.ai[2] = this.ai[2] + 1f;
                        }
                        if (this.justHit)
                        {
                            this.ai[2] = -30f;
                        }
                        if (this.ai[2] == 20f && Main.netMode != 1)
                        {
                            this.ai[2] = (float)(-10 + Main.rand.Next(3) * -10);
                            Projectile.NewProjectile(base.Center.X, base.Center.Y + 8f, (float)(this.direction * 6), 0f, 437, 25, 1f, Main.myPlayer, 0f, 0f);
                        }
                    }
                    else
                    {
                        this.ai[2] = -60f;
                    }
                }
                if (this.type == 110 || this.type == 111 || this.type == 206 || this.type == 214 || this.type == 215 || this.type == 216 || this.type == 290 || this.type == 291 || this.type == 292 || this.type == 293 || this.type == 350 || this.type == 379 || this.type == 380 || this.type == 381 || this.type == 382 || this.type >= 449 && this.type <= 452 || this.type == 468 || this.type == 481 || this.type == 411 || this.type == 409 || this.type >= 498 && this.type <= 506 || this.type == 424 || this.type == 426 || this.type == 520)
                {
                    bool flag22 = (this.type == 381 || this.type == 382 ? true : this.type == 520);
                    bool flag23 = this.type == 426;
                    bool flag24 = true;
                    int num85 = -1;
                    int num86 = -1;
                    if (this.type == 411)
                    {
                        flag22 = true;
                        num85 = 90;
                        num86 = 90;
                        if (this.ai[1] <= 150f)
                        {
                            flag24 = false;
                        }
                    }
                    if (!this.confused)
                    {
                        if (this.ai[1] > 0f)
                        {
                            this.ai[1] = this.ai[1] - 1f;
                        }
                        if (this.justHit)
                        {
                            this.ai[1] = 30f;
                            this.ai[2] = 0f;
                        }
                        int num87 = 70;
                        if (this.type == 379 || this.type == 380)
                        {
                            num87 = 80;
                        }
                        if (this.type == 381 || this.type == 382)
                        {
                            num87 = 80;
                        }
                        if (this.type == 520)
                        {
                            num87 = 15;
                        }
                        if (this.type == 350)
                        {
                            num87 = 110;
                        }
                        if (this.type == 291)
                        {
                            num87 = 200;
                        }
                        if (this.type == 292)
                        {
                            num87 = 120;
                        }
                        if (this.type == 293)
                        {
                            num87 = 90;
                        }
                        if (this.type == 111)
                        {
                            num87 = 180;
                        }
                        if (this.type == 206)
                        {
                            num87 = 50;
                        }
                        if (this.type == 214)
                        {
                            num87 = 40;
                        }
                        if (this.type == 215)
                        {
                            num87 = 80;
                        }
                        if (this.type == 290)
                        {
                            num87 = 30;
                        }
                        if (this.type == 411)
                        {
                            num87 = 300;
                        }
                        if (this.type == 409)
                        {
                            num87 = 60;
                        }
                        if (this.type == 424)
                        {
                            num87 = 180;
                        }
                        if (this.type == 426)
                        {
                            num87 = 60;
                        }
                        bool flag25 = false;
                        if (this.type == 216)
                        {
                            if (this.localAI[2] >= 20f)
                            {
                                flag25 = true;
                            }
                            num87 = (!flag25 ? 8 : 60);
                        }
                        int num88 = num87 / 2;
                        if (this.type == 424)
                        {
                            num88 = num87 - 1;
                        }
                        if (this.type == 426)
                        {
                            num88 = num87 - 1;
                        }
                        if (this.ai[2] > 0f)
                        {
                            if (flag24)
                            {
                                this.TargetClosest(true);
                            }
                            if (this.ai[1] == (float)num88)
                            {
                                if (this.type == 216)
                                {
                                    this.localAI[2] = this.localAI[2] + 1f;
                                }
                                float single48 = 11f;
                                if (this.type == 111)
                                {
                                    single48 = 9f;
                                }
                                if (this.type == 206)
                                {
                                    single48 = 7f;
                                }
                                if (this.type == 290)
                                {
                                    single48 = 9f;
                                }
                                if (this.type == 293)
                                {
                                    single48 = 4f;
                                }
                                if (this.type == 214)
                                {
                                    single48 = 14f;
                                }
                                if (this.type == 215)
                                {
                                    single48 = 16f;
                                }
                                if (this.type == 382)
                                {
                                    single48 = 7f;
                                }
                                if (this.type == 520)
                                {
                                    single48 = 8f;
                                }
                                if (this.type == 409)
                                {
                                    single48 = 4f;
                                }
                                if (this.type >= 449 && this.type <= 452)
                                {
                                    single48 = 7f;
                                }
                                if (this.type == 481)
                                {
                                    single48 = 9f;
                                }
                                if (this.type == 468)
                                {
                                    single48 = 7.5f;
                                }
                                if (this.type == 411)
                                {
                                    single48 = 1f;
                                }
                                if (this.type >= 498 && this.type <= 506)
                                {
                                    single48 = 7f;
                                }
                                Vector2 y28 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                if (this.type == 481)
                                {
                                    y28.Y = y28.Y - 14f;
                                }
                                if (this.type == 206)
                                {
                                    y28.Y = y28.Y - 10f;
                                }
                                if (this.type == 290)
                                {
                                    y28.Y = y28.Y - 10f;
                                }
                                if (this.type == 381 || this.type == 382)
                                {
                                    y28.Y = y28.Y + 6f;
                                }
                                if (this.type == 520)
                                {
                                    y28.Y = this.position.Y + 20f;
                                }
                                if (this.type >= 498 && this.type <= 506)
                                {
                                    y28.Y = y28.Y - 8f;
                                }
                                if (this.type == 426)
                                {
                                    y28 = y28 + new Vector2((float)(this.spriteDirection * 2), -12f);
                                }
                                float x31 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - y28.X;
                                float single49 = Math.Abs(x31) * 0.1f;
                                if (this.type == 291 || this.type == 292)
                                {
                                    single49 = 0f;
                                }
                                if (this.type == 215)
                                {
                                    single49 = Math.Abs(x31) * 0.08f;
                                }
                                if (this.type == 214 || this.type == 216 && !flag25)
                                {
                                    single49 = 0f;
                                }
                                if (this.type == 381 || this.type == 382 || this.type == 520)
                                {
                                    single49 = 0f;
                                }
                                if (this.type >= 449 && this.type <= 452)
                                {
                                    single49 = Math.Abs(x31) * (float)Main.rand.Next(10, 50) * 0.01f;
                                }
                                if (this.type == 468)
                                {
                                    single49 = Math.Abs(x31) * (float)Main.rand.Next(10, 50) * 0.01f;
                                }
                                if (this.type == 481)
                                {
                                    single49 = Math.Abs(x31) * (float)Main.rand.Next(-10, 11) * 0.0025f;
                                }
                                if (this.type >= 498 && this.type <= 506)
                                {
                                    single49 = Math.Abs(x31) * (float)Main.rand.Next(1, 11) * 0.0025f;
                                }
                                float y29 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - y28.Y - single49;
                                if (this.type == 291)
                                {
                                    x31 = x31 + (float)Main.rand.Next(-40, 41) * 0.2f;
                                    y29 = y29 + (float)Main.rand.Next(-40, 41) * 0.2f;
                                }
                                else if (this.type == 381 || this.type == 382 || this.type == 520)
                                {
                                    x31 = x31 + (float)Main.rand.Next(-100, 101) * 0.4f;
                                    y29 = y29 + (float)Main.rand.Next(-100, 101) * 0.4f;
                                    x31 = x31 * ((float)Main.rand.Next(85, 116) * 0.01f);
                                    y29 = y29 * ((float)Main.rand.Next(85, 116) * 0.01f);
                                    if (this.type == 520)
                                    {
                                        x31 = x31 + (float)Main.rand.Next(-100, 101) * 0.6f;
                                        y29 = y29 + (float)Main.rand.Next(-100, 101) * 0.6f;
                                        x31 = x31 * ((float)Main.rand.Next(85, 116) * 0.015f);
                                        y29 = y29 * ((float)Main.rand.Next(85, 116) * 0.015f);
                                    }
                                }
                                else if (this.type == 481)
                                {
                                    x31 = x31 + (float)Main.rand.Next(-40, 41) * 0.4f;
                                    y29 = y29 + (float)Main.rand.Next(-40, 41) * 0.4f;
                                }
                                else if (this.type >= 498 && this.type <= 506)
                                {
                                    x31 = x31 + (float)Main.rand.Next(-40, 41) * 0.3f;
                                    y29 = y29 + (float)Main.rand.Next(-40, 41) * 0.3f;
                                }
                                else if (this.type != 292)
                                {
                                    x31 = x31 + (float)Main.rand.Next(-40, 41);
                                    y29 = y29 + (float)Main.rand.Next(-40, 41);
                                }
                                float single50 = (float)Math.Sqrt((double)(x31 * x31 + y29 * y29));
                                this.netUpdate = true;
                                single50 = single48 / single50;
                                x31 = x31 * single50;
                                y29 = y29 * single50;
                                int num89 = 35;
                                int num90 = 82;
                                if (this.type == 111)
                                {
                                    num89 = 11;
                                }
                                if (this.type == 206)
                                {
                                    num89 = 37;
                                }
                                if (this.type == 379 || this.type == 380)
                                {
                                    num89 = 40;
                                }
                                if (this.type == 350)
                                {
                                    num89 = 45;
                                }
                                if (this.type == 468)
                                {
                                    num89 = 50;
                                }
                                if (this.type == 111)
                                {
                                    num90 = 81;
                                }
                                if (this.type == 379 || this.type == 380)
                                {
                                    num90 = 81;
                                }
                                if (this.type == 381)
                                {
                                    num90 = 436;
                                    num89 = 24;
                                }
                                if (this.type == 382)
                                {
                                    num90 = 438;
                                    num89 = 30;
                                }
                                if (this.type == 520)
                                {
                                    num90 = 592;
                                    num89 = 35;
                                }
                                if (this.type >= 449 && this.type <= 452)
                                {
                                    num90 = 471;
                                    num89 = 20;
                                }
                                if (this.type >= 498 && this.type <= 506)
                                {
                                    num90 = 572;
                                    num89 = 14;
                                }
                                if (this.type == 481)
                                {
                                    num90 = 508;
                                    num89 = 24;
                                }
                                if (this.type == 206)
                                {
                                    num90 = 177;
                                }
                                if (this.type == 468)
                                {
                                    num90 = 501;
                                }
                                if (this.type == 411)
                                {
                                    num90 = 537;
                                    num89 = (Main.expertMode ? 45 : 60);
                                }
                                if (this.type == 424)
                                {
                                    num90 = 573;
                                    num89 = (Main.expertMode ? 45 : 60);
                                }
                                if (this.type == 426)
                                {
                                    num90 = 581;
                                    num89 = (Main.expertMode ? 45 : 60);
                                }
                                if (this.type == 291)
                                {
                                    num90 = 302;
                                    num89 = 100;
                                }
                                if (this.type == 290)
                                {
                                    num90 = 300;
                                    num89 = 60;
                                }
                                if (this.type == 293)
                                {
                                    num90 = 303;
                                    num89 = 60;
                                }
                                if (this.type == 214)
                                {
                                    num90 = 180;
                                    num89 = 25;
                                }
                                if (this.type == 215)
                                {
                                    num90 = 82;
                                    num89 = 40;
                                }
                                if (this.type == 292)
                                {
                                    num89 = 50;
                                    num90 = 180;
                                }
                                if (this.type == 216)
                                {
                                    num90 = 180;
                                    num89 = 30;
                                    if (flag25)
                                    {
                                        num89 = 100;
                                        num90 = 240;
                                        this.localAI[2] = 0f;
                                    }
                                }
                                y28.X = y28.X + x31;
                                y28.Y = y28.Y + y29;
                                if (Main.expertMode && this.type == 290)
                                {
                                    num89 = (int)((double)num89 * 0.75);
                                }
                                if (Main.expertMode && this.type >= 381 && this.type <= 392)
                                {
                                    num89 = (int)((double)num89 * 0.8);
                                }
                                if (Main.netMode != 1)
                                {
                                    if (this.type == 292)
                                    {
                                        for (int p1 = 0; p1 < 4; p1++)
                                        {
                                            x31 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - y28.X;
                                            y29 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - y28.Y;
                                            single50 = (float)Math.Sqrt((double)(x31 * x31 + y29 * y29));
                                            single50 = 12f / single50;
                                            float single51 = x31 + (float)Main.rand.Next(-40, 41);
                                            x31 = single51;
                                            x31 = single51;
                                            float single52 = y29 + (float)Main.rand.Next(-40, 41);
                                            y29 = single52;
                                            y29 = single52;
                                            x31 = x31 * single50;
                                            y29 = y29 * single50;
                                            Projectile.NewProjectile(y28.X, y28.Y, x31, y29, num90, num89, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                    }
                                    else if (this.type == 411)
                                    {
                                        Projectile.NewProjectile(y28.X, y28.Y, x31, y29, num90, num89, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                    }
                                    else if (this.type == 424)
                                    {
                                        for (int q1 = 0; q1 < 4; q1++)
                                        {
                                            Projectile.NewProjectile(base.Center.X - (float)(this.spriteDirection * 4), base.Center.Y + 6f, (float)(-3 + 2 * q1) * 0.15f, (float)(-Main.rand.Next(0, 3)) * 0.2f - 0.1f, num90, num89, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                        }
                                    }
                                    else if (this.type != 409)
                                    {
                                        Projectile.NewProjectile(y28.X, y28.Y, x31, y29, num90, num89, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                    else
                                    {
                                        int num91 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 410, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                        Main.npc[num91].velocity = new Vector2(x31, -6f + y29);
                                    }
                                }
                                if (Math.Abs(y29) > Math.Abs(x31) * 2f)
                                {
                                    if (y29 <= 0f)
                                    {
                                        this.ai[2] = 5f;
                                    }
                                    else
                                    {
                                        this.ai[2] = 1f;
                                    }
                                }
                                else if (Math.Abs(x31) > Math.Abs(y29) * 2f)
                                {
                                    this.ai[2] = 3f;
                                }
                                else if (y29 <= 0f)
                                {
                                    this.ai[2] = 4f;
                                }
                                else
                                {
                                    this.ai[2] = 2f;
                                }
                            }
                            if (this.velocity.Y != 0f && !flag23 || this.ai[1] <= 0f)
                            {
                                this.ai[2] = 0f;
                                this.ai[1] = 0f;
                            }
                            else if (!flag22 || num85 != -1 && this.ai[1] >= (float)num85 && this.ai[1] < (float)(num85 + num86) && (!flag23 || this.velocity.Y == 0f))
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                this.spriteDirection = this.direction;
                            }
                        }
                        if (this.type == 468 && !Main.eclipse)
                        {
                            flag22 = true;
                        }
                        else if ((this.ai[2] <= 0f || flag22) && (this.velocity.Y == 0f || flag23) && this.ai[1] <= 0f && !Main.player[this.target].dead)
                        {
                            bool flag26 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                            if (this.type == 520)
                            {
                                flag26 = Collision.CanHitLine(base.Top + new Vector2(0f, 20f), 0, 0, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                            }
                            if (Main.player[this.target].stealth == 0f && Main.player[this.target].itemAnimation == 0)
                            {
                                flag26 = false;
                            }
                            if (flag26)
                            {
                                float single53 = 10f;
                                Vector2 vector230 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x32 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector230.X;
                                float single54 = Math.Abs(x32) * 0.1f;
                                float y30 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector230.Y - single54;
                                x32 = x32 + (float)Main.rand.Next(-40, 41);
                                y30 = y30 + (float)Main.rand.Next(-40, 41);
                                float single55 = (float)Math.Sqrt((double)(x32 * x32 + y30 * y30));
                                float single56 = 700f;
                                if (this.type == 214)
                                {
                                    single56 = 550f;
                                }
                                if (this.type == 215)
                                {
                                    single56 = 800f;
                                }
                                if (this.type >= 498 && this.type <= 506)
                                {
                                    single56 = 190f;
                                }
                                if (this.type >= 449 && this.type <= 452)
                                {
                                    single56 = 200f;
                                }
                                if (this.type == 481)
                                {
                                    single56 = 400f;
                                }
                                if (this.type == 468)
                                {
                                    single56 = 400f;
                                }
                                if (single55 < single56)
                                {
                                    this.netUpdate = true;
                                    this.velocity.X = this.velocity.X * 0.5f;
                                    single55 = single53 / single55;
                                    x32 = x32 * single55;
                                    y30 = y30 * single55;
                                    this.ai[2] = 3f;
                                    this.ai[1] = (float)num87;
                                    if (Math.Abs(y30) > Math.Abs(x32) * 2f)
                                    {
                                        if (y30 <= 0f)
                                        {
                                            this.ai[2] = 5f;
                                        }
                                        else
                                        {
                                            this.ai[2] = 1f;
                                        }
                                    }
                                    else if (Math.Abs(x32) > Math.Abs(y30) * 2f)
                                    {
                                        this.ai[2] = 3f;
                                    }
                                    else if (y30 <= 0f)
                                    {
                                        this.ai[2] = 4f;
                                    }
                                    else
                                    {
                                        this.ai[2] = 2f;
                                    }
                                }
                            }
                        }
                        if (this.ai[2] <= 0f || flag22 && (num85 == -1 || this.ai[1] < (float)num85 || this.ai[1] >= (float)(num85 + num86)))
                        {
                            float single57 = 1f;
                            float single58 = 0.07f;
                            float single59 = 0.8f;
                            if (this.type == 214)
                            {
                                single57 = 2f;
                                single58 = 0.09f;
                            }
                            else if (this.type == 215)
                            {
                                single57 = 1.5f;
                                single58 = 0.08f;
                            }
                            else if (this.type == 381 || this.type == 382)
                            {
                                single57 = 2f;
                                single58 = 0.5f;
                            }
                            else if (this.type == 520)
                            {
                                single57 = 4f;
                                single58 = 1f;
                                single59 = 0.7f;
                            }
                            else if (this.type == 411)
                            {
                                single57 = 2f;
                                single58 = 0.5f;
                            }
                            else if (this.type == 409)
                            {
                                single57 = 2f;
                                single58 = 0.5f;
                            }
                            bool flag27 = false;
                            if ((this.type == 381 || this.type == 382) && Vector2.Distance(base.Center, Main.player[this.target].Center) < 300f && Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                            {
                                flag27 = true;
                                this.ai[3] = 0f;
                            }
                            if (this.type == 520 && Vector2.Distance(base.Center, Main.player[this.target].Center) < 400f && Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                            {
                                flag27 = true;
                                this.ai[3] = 0f;
                            }
                            if (this.velocity.X < -single57 || this.velocity.X > single57 || flag27)
                            {
                                if (this.velocity.Y == 0f)
                                {
                                    NPC nPC29 = this;
                                    nPC29.velocity = nPC29.velocity * single59;
                                }
                            }
                            else if (this.velocity.X < single57 && this.direction == 1)
                            {
                                this.velocity.X = this.velocity.X + single58;
                                if (this.velocity.X > single57)
                                {
                                    this.velocity.X = single57;
                                }
                            }
                            else if (this.velocity.X > -single57 && this.direction == -1)
                            {
                                this.velocity.X = this.velocity.X - single58;
                                if (this.velocity.X < -single57)
                                {
                                    this.velocity.X = -single57;
                                }
                            }
                        }
                        if (this.type == 520)
                        {
                            this.localAI[2] = this.localAI[2] + 1f;
                            if (this.localAI[2] >= 6f)
                            {
                                this.localAI[2] = 0f;
                                this.localAI[3] = Main.player[this.target].DirectionFrom(base.Top + new Vector2(0f, 20f)).ToRotation();
                            }
                        }
                    }
                    else
                    {
                        this.ai[2] = 0f;
                    }
                }
                if (this.type == 109 && Main.netMode != 1 && !Main.player[this.target].dead)
                {
                    if (this.justHit)
                    {
                        this.ai[2] = 0f;
                    }
                    this.ai[2] = this.ai[2] + 1f;
                    if (this.ai[2] > 450f)
                    {
                        Vector2 vector231 = new Vector2(this.position.X + (float)this.width * 0.5f - (float)(this.direction * 24), this.position.Y + 4f);
                        int num92 = 3 * this.direction;
                        int num93 = -5;
                        int num94 = Projectile.NewProjectile(vector231.X, vector231.Y, (float)num92, (float)num93, 75, 0, 0f, Main.myPlayer, 0f, 0f);
                        Main.projectile[num94].timeLeft = 300;
                        this.ai[2] = 0f;
                    }
                }
                bool flag28 = false;
                if (this.velocity.Y == 0f)
                {
                    int y31 = (int)(this.position.Y + (float)this.height + 7f) / 16;
                    int x33 = (int)this.position.X / 16;
                    int x34 = (int)(this.position.X + (float)this.width) / 16;
                    int num95 = x33;
                    while (num95 <= x34)
                    {
                        if (Main.tile[num95, y31] == null)
                        {
                            return;
                        }
                        if (!Main.tile[num95, y31].nactive() || !Main.tileSolid[Main.tile[num95, y31].type])
                        {
                            num95++;
                        }
                        else
                        {
                            flag28 = true;
                            break;
                        }
                    }
                }
                if (this.type == 428)
                {
                    flag28 = false;
                }
                if (this.velocity.Y >= 0f)
                {
                    int num96 = 0;
                    if (this.velocity.X < 0f)
                    {
                        num96 = -1;
                    }
                    if (this.velocity.X > 0f)
                    {
                        num96 = 1;
                    }
                    Vector2 vector232 = this.position;
                    vector232.X = vector232.X + this.velocity.X;
                    int x35 = (int)((vector232.X + (float)(this.width / 2) + (float)((this.width / 2 + 1) * num96)) / 16f);
                    int y32 = (int)((vector232.Y + (float)this.height - 1f) / 16f);
                    if (Main.tile[x35, y32] == null)
                    {
                        Main.tile[x35, y32] = new Tile();
                    }
                    if (Main.tile[x35, y32 - 1] == null)
                    {
                        Main.tile[x35, y32 - 1] = new Tile();
                    }
                    if (Main.tile[x35, y32 - 2] == null)
                    {
                        Main.tile[x35, y32 - 2] = new Tile();
                    }
                    if (Main.tile[x35, y32 - 3] == null)
                    {
                        Main.tile[x35, y32 - 3] = new Tile();
                    }
                    if (Main.tile[x35, y32 + 1] == null)
                    {
                        Main.tile[x35, y32 + 1] = new Tile();
                    }
                    if (Main.tile[x35 - num96, y32 - 3] == null)
                    {
                        Main.tile[x35 - num96, y32 - 3] = new Tile();
                    }
                    if ((float)(x35 * 16) < vector232.X + (float)this.width && (float)(x35 * 16 + 16) > vector232.X && (Main.tile[x35, y32].nactive() && !Main.tile[x35, y32].topSlope() && !Main.tile[x35, y32 - 1].topSlope() && Main.tileSolid[Main.tile[x35, y32].type] && !Main.tileSolidTop[Main.tile[x35, y32].type] || Main.tile[x35, y32 - 1].halfBrick() && Main.tile[x35, y32 - 1].nactive()) && (!Main.tile[x35, y32 - 1].nactive() || !Main.tileSolid[Main.tile[x35, y32 - 1].type] || Main.tileSolidTop[Main.tile[x35, y32 - 1].type] || Main.tile[x35, y32 - 1].halfBrick() && (!Main.tile[x35, y32 - 4].nactive() || !Main.tileSolid[Main.tile[x35, y32 - 4].type] || Main.tileSolidTop[Main.tile[x35, y32 - 4].type])) && (!Main.tile[x35, y32 - 2].nactive() || !Main.tileSolid[Main.tile[x35, y32 - 2].type] || Main.tileSolidTop[Main.tile[x35, y32 - 2].type]) && (!Main.tile[x35, y32 - 3].nactive() || !Main.tileSolid[Main.tile[x35, y32 - 3].type] || Main.tileSolidTop[Main.tile[x35, y32 - 3].type]) && (!Main.tile[x35 - num96, y32 - 3].nactive() || !Main.tileSolid[Main.tile[x35 - num96, y32 - 3].type]))
                    {
                        float single60 = (float)(y32 * 16);
                        if (Main.tile[x35, y32].halfBrick())
                        {
                            single60 = single60 + 8f;
                        }
                        if (Main.tile[x35, y32 - 1].halfBrick())
                        {
                            single60 = single60 - 8f;
                        }
                        if (single60 < vector232.Y + (float)this.height)
                        {
                            float y33 = vector232.Y + (float)this.height - single60;
                            float single61 = 16.1f;
                            if (this.type == 163 || this.type == 164 || this.type == 236 || this.type == 239 || this.type == 530)
                            {
                                single61 = single61 + 8f;
                            }
                            if (y33 <= single61)
                            {
                                NPC nPC30 = this;
                                nPC30.gfxOffY = nPC30.gfxOffY + (this.position.Y + (float)this.height - single60);
                                this.position.Y = single60 - (float)this.height;
                                if (y33 >= 9f)
                                {
                                    this.stepSpeed = 2f;
                                }
                                else
                                {
                                    this.stepSpeed = 1f;
                                }
                            }
                        }
                    }
                }
                if (flag28)
                {
                    int x36 = (int)((this.position.X + (float)(this.width / 2) + (float)(15 * this.direction)) / 16f);
                    int y34 = (int)((this.position.Y + (float)this.height - 15f) / 16f);
                    if (this.type == 109 || this.type == 163 || this.type == 164 || this.type == 199 || this.type == 236 || this.type == 239 || this.type == 257 || this.type == 258 || this.type == 290 || this.type == 391 || this.type == 425 || this.type == 427 || this.type == 426 || this.type == 508 || this.type == 415 || this.type == 530 || this.type == 532)
                    {
                        x36 = (int)((this.position.X + (float)(this.width / 2) + (float)((this.width / 2 + 16) * this.direction)) / 16f);
                    }
                    if (Main.tile[x36, y34] == null)
                    {
                        Main.tile[x36, y34] = new Tile();
                    }
                    if (Main.tile[x36, y34 - 1] == null)
                    {
                        Main.tile[x36, y34 - 1] = new Tile();
                    }
                    if (Main.tile[x36, y34 - 2] == null)
                    {
                        Main.tile[x36, y34 - 2] = new Tile();
                    }
                    if (Main.tile[x36, y34 - 3] == null)
                    {
                        Main.tile[x36, y34 - 3] = new Tile();
                    }
                    if (Main.tile[x36, y34 + 1] == null)
                    {
                        Main.tile[x36, y34 + 1] = new Tile();
                    }
                    if (Main.tile[x36 + this.direction, y34 - 1] == null)
                    {
                        Main.tile[x36 + this.direction, y34 - 1] = new Tile();
                    }
                    if (Main.tile[x36 + this.direction, y34 + 1] == null)
                    {
                        Main.tile[x36 + this.direction, y34 + 1] = new Tile();
                    }
                    if (Main.tile[x36 - this.direction, y34 + 1] == null)
                    {
                        Main.tile[x36 - this.direction, y34 + 1] = new Tile();
                    }
                    Main.tile[x36, y34 + 1].halfBrick();
                    if (!Main.tile[x36, y34 - 1].nactive() || Main.tile[x36, y34 - 1].type != 10 && Main.tile[x36, y34 - 1].type != 388 || !flag11)
                    {
                        int num97 = this.spriteDirection;
                        if (this.type == 425)
                        {
                            num97 = num97 * -1;
                        }
                        if (this.velocity.X < 0f && num97 == -1 || this.velocity.X > 0f && num97 == 1)
                        {
                            if (this.height >= 32 && Main.tile[x36, y34 - 2].nactive() && Main.tileSolid[Main.tile[x36, y34 - 2].type])
                            {
                                if (!Main.tile[x36, y34 - 3].nactive() || !Main.tileSolid[Main.tile[x36, y34 - 3].type])
                                {
                                    this.velocity.Y = -7f;
                                    this.netUpdate = true;
                                }
                                else
                                {
                                    this.velocity.Y = -8f;
                                    this.netUpdate = true;
                                }
                            }
                            else if (Main.tile[x36, y34 - 1].nactive() && Main.tileSolid[Main.tile[x36, y34 - 1].type])
                            {
                                this.velocity.Y = -6f;
                                this.netUpdate = true;
                            }
                            else if (this.position.Y + (float)this.height - (float)(y34 * 16) > 20f && Main.tile[x36, y34].nactive() && !Main.tile[x36, y34].topSlope() && Main.tileSolid[Main.tile[x36, y34].type])
                            {
                                this.velocity.Y = -5f;
                                this.netUpdate = true;
                            }
                            else if (this.directionY < 0 && this.type != 67 && (!Main.tile[x36, y34 + 1].nactive() || !Main.tileSolid[Main.tile[x36, y34 + 1].type]) && (!Main.tile[x36 + this.direction, y34 + 1].nactive() || !Main.tileSolid[Main.tile[x36 + this.direction, y34 + 1].type]))
                            {
                                this.velocity.Y = -8f;
                                this.velocity.X = this.velocity.X * 1.5f;
                                this.netUpdate = true;
                            }
                            else if (flag11)
                            {
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                            }
                            if (this.velocity.Y == 0f && flag9 && this.ai[3] == 1f)
                            {
                                this.velocity.Y = -5f;
                            }
                        }
                        if ((this.type == 31 || this.type == 294 || this.type == 295 || this.type == 296 || this.type == 47 || this.type == 77 || this.type == 104 || this.type == 168 || this.type == 196 || this.type == 385 || this.type == 389 || this.type == 464 || this.type == 470 || this.type >= 524 && this.type <= 527) && this.velocity.Y == 0f && Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) < 100f && Math.Abs(this.position.Y + (float)(this.height / 2) - (Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))) < 50f && (this.direction > 0 && this.velocity.X >= 1f || this.direction < 0 && this.velocity.X <= -1f))
                        {
                            this.velocity.X = this.velocity.X * 2f;
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = 3f;
                            }
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = -3f;
                            }
                            this.velocity.Y = -4f;
                            this.netUpdate = true;
                        }
                        if (this.type == 120 && this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 1.1f;
                        }
                        if (this.type == 287 && this.velocity.Y == 0f && Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) < 150f && Math.Abs(this.position.Y + (float)(this.height / 2) - (Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))) < 50f && (this.direction > 0 && this.velocity.X >= 1f || this.direction < 0 && this.velocity.X <= -1f))
                        {
                            this.velocity.X = (float)(8 * this.direction);
                            this.velocity.Y = -4f;
                            this.netUpdate = true;
                        }
                        if (this.type == 287 && this.velocity.Y < 0f)
                        {
                            this.velocity.X = this.velocity.X * 1.2f;
                            this.velocity.Y = this.velocity.Y * 1.1f;
                        }
                        if (this.type == 460 && this.velocity.Y < 0f)
                        {
                            this.velocity.X = this.velocity.X * 1.3f;
                            this.velocity.Y = this.velocity.Y * 1.1f;
                        }
                    }
                    else
                    {
                        this.ai[2] = this.ai[2] + 1f;
                        this.ai[3] = 0f;
                        if (this.ai[2] >= 60f)
                        {
                            if (!Main.bloodMoon && (this.type == 3 || this.type == 331 || this.type == 332 || this.type == 132 || this.type == 161 || this.type == 186 || this.type == 187 || this.type == 188 || this.type == 189 || this.type == 200 || this.type == 223 || this.type == 320 || this.type == 321 || this.type == 319))
                            {
                                this.ai[1] = 0f;
                            }
                            this.velocity.X = 0.5f * (float)(-this.direction);
                            int num98 = 5;
                            if (Main.tile[x36, y34 - 1].type == 388)
                            {
                                num98 = 2;
                            }
                            this.ai[1] = this.ai[1] + (float)num98;
                            if (this.type == 27)
                            {
                                this.ai[1] = this.ai[1] + 1f;
                            }
                            if (this.type == 31 || this.type == 294 || this.type == 295 || this.type == 296)
                            {
                                this.ai[1] = this.ai[1] + 6f;
                            }
                            this.ai[2] = 0f;
                            bool flag29 = false;
                            if (this.ai[1] >= 10f)
                            {
                                flag29 = true;
                                this.ai[1] = 10f;
                            }
                            if (this.type == 460)
                            {
                                flag29 = true;
                            }
                            WorldGen.KillTile(x36, y34 - 1, true, false, false);
                            if ((Main.netMode != 1 || !flag29) && flag29 && Main.netMode != 1)
                            {
                                if (this.type != 26)
                                {
                                    if (Main.tile[x36, y34 - 1].type == 10)
                                    {
                                        bool flag30 = WorldGen.OpenDoor(x36, y34 - 1, this.direction);
                                        if (!flag30)
                                        {
                                            this.ai[3] = (float)num57;
                                            this.netUpdate = true;
                                        }
                                        if (Main.netMode == 2 && flag30)
                                        {
                                            NetMessage.SendData(19, -1, -1, "", 0, (float)x36, (float)(y34 - 1), (float)this.direction, 0, 0, 0);
                                        }
                                    }
                                    if (Main.tile[x36, y34 - 1].type == 388)
                                    {
                                        bool flag31 = WorldGen.ShiftTallGate(x36, y34 - 1, false);
                                        if (!flag31)
                                        {
                                            this.ai[3] = (float)num57;
                                            this.netUpdate = true;
                                        }
                                        if (Main.netMode == 2 && flag31)
                                        {
                                            NetMessage.SendData(19, -1, -1, "", 4, (float)x36, (float)(y34 - 1), 0f, 0, 0, 0);
                                        }
                                    }
                                }
                                else
                                {
                                    WorldGen.KillTile(x36, y34 - 1, false, false, false);
                                    if (Main.netMode == 2)
                                    {
                                        NetMessage.SendData(17, -1, -1, "", 0, (float)x36, (float)(y34 - 1), 0f, 0, 0, 0);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (flag11)
                {
                    this.ai[1] = 0f;
                    this.ai[2] = 0f;
                }
                if (Main.netMode != 1 && this.type == 120 && this.ai[3] >= (float)num57)
                {
                    int x37 = (int)Main.player[this.target].position.X / 16;
                    int y35 = (int)Main.player[this.target].position.Y / 16;
                    int x38 = (int)this.position.X / 16;
                    int y36 = (int)this.position.Y / 16;
                    int num99 = 20;
                    int num100 = 0;
                    bool flag32 = false;
                    if (Math.Abs(this.position.X - Main.player[this.target].position.X) + Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                    {
                        num100 = 100;
                        flag32 = true;
                    }
                    while (!flag32)
                    {
                        if (num100 >= 100)
                        {
                            return;
                        }
                        num100++;
                        int num101 = Main.rand.Next(x37 - num99, x37 + num99);
                        int num102 = Main.rand.Next(y35 - num99, y35 + num99);
                        for (int r1 = num102; r1 < y35 + num99; r1++)
                        {
                            if ((r1 < y35 - 4 || r1 > y35 + 4 || num101 < x37 - 4 || num101 > x37 + 4) && (r1 < y36 - 1 || r1 > y36 + 1 || num101 < x38 - 1 || num101 > x38 + 1) && Main.tile[num101, r1].nactive())
                            {
                                bool flag33 = true;
                                if (this.type == 32 && Main.tile[num101, r1 - 1].wall == 0)
                                {
                                    flag33 = false;
                                }
                                else if (Main.tile[num101, r1 - 1].lava())
                                {
                                    flag33 = false;
                                }
                                if (flag33 && Main.tileSolid[Main.tile[num101, r1].type] && !Collision.SolidTiles(num101 - 1, num101 + 1, r1 - 4, r1 - 1))
                                {
                                    this.position.X = (float)(num101 * 16 - this.width / 2);
                                    this.position.Y = (float)(r1 * 16 - this.height);
                                    this.netUpdate = true;
                                    this.ai[3] = -120f;
                                }
                            }
                        }
                    }
                }
            }
            else if (this.aiStyle == 4)
            {
                bool flag34 = false;
                if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.12)
                {
                    flag34 = true;
                }
                bool flag35 = false;
                if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.04)
                {
                    flag35 = true;
                }
                float single62 = 20f;
                if (flag35)
                {
                    single62 = 10f;
                }
                if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                {
                    this.TargetClosest(true);
                }
                bool flag36 = Main.player[this.target].dead;
                float x39 = this.position.X + (float)(this.width / 2) - Main.player[this.target].position.X - (float)(Main.player[this.target].width / 2);
                float y37 = this.position.Y + (float)this.height - 59f - Main.player[this.target].position.Y - (float)(Main.player[this.target].height / 2);
                float single63 = (float)Math.Atan2((double)y37, (double)x39) + 1.57f;
                if (single63 < 0f)
                {
                    single63 = single63 + 6.283f;
                }
                else if ((double)single63 > 6.283)
                {
                    single63 = single63 - 6.283f;
                }
                float single64 = 0f;
                if (this.ai[0] == 0f && this.ai[1] == 0f)
                {
                    single64 = 0.02f;
                }
                if (this.ai[0] == 0f && this.ai[1] == 2f && this.ai[2] > 40f)
                {
                    single64 = 0.05f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 0f)
                {
                    single64 = 0.05f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 2f && this.ai[2] > 40f)
                {
                    single64 = 0.08f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 4f && this.ai[2] > single62)
                {
                    single64 = 0.15f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 5f)
                {
                    single64 = 0.05f;
                }
                if (Main.expertMode)
                {
                    single64 = single64 * 1.5f;
                }
                if (flag35 && Main.expertMode)
                {
                    single64 = 0f;
                }
                if (this.rotation < single63)
                {
                    if ((double)(single63 - this.rotation) <= 3.1415)
                    {
                        NPC nPC31 = this;
                        nPC31.rotation = nPC31.rotation + single64;
                    }
                    else
                    {
                        NPC nPC32 = this;
                        nPC32.rotation = nPC32.rotation - single64;
                    }
                }
                else if (this.rotation > single63)
                {
                    if ((double)(this.rotation - single63) <= 3.1415)
                    {
                        NPC nPC33 = this;
                        nPC33.rotation = nPC33.rotation - single64;
                    }
                    else
                    {
                        NPC nPC34 = this;
                        nPC34.rotation = nPC34.rotation + single64;
                    }
                }
                if (this.rotation > single63 - single64 && this.rotation < single63 + single64)
                {
                    this.rotation = single63;
                }
                if (this.rotation < 0f)
                {
                    NPC nPC35 = this;
                    nPC35.rotation = nPC35.rotation + 6.283f;
                }
                else if ((double)this.rotation > 6.283)
                {
                    NPC nPC36 = this;
                    nPC36.rotation = nPC36.rotation - 6.283f;
                }
                if (this.rotation > single63 - single64 && this.rotation < single63 + single64)
                {
                    this.rotation = single63;
                }
                if (Main.dayTime || flag36)
                {
                    this.velocity.Y = this.velocity.Y - 0.04f;
                    if (this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                        return;
                    }
                }
                else if (this.ai[0] == 0f)
                {
                    if (this.ai[1] == 0f)
                    {
                        float single65 = 5f;
                        float single66 = 0.04f;
                        if (Main.expertMode)
                        {
                            single66 = 0.15f;
                            single65 = 7f;
                        }
                        Vector2 vector234 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x41 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector234.X;
                        float y38 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 200f - vector234.Y;
                        float single67 = (float)Math.Sqrt((double)(x41 * x41 + y38 * y38));
                        float single68 = single67;
                        single67 = single65 / single67;
                        x41 = x41 * single67;
                        y38 = y38 * single67;
                        if (this.velocity.X < x41)
                        {
                            this.velocity.X = this.velocity.X + single66;
                            if (this.velocity.X < 0f && x41 > 0f)
                            {
                                this.velocity.X = this.velocity.X + single66;
                            }
                        }
                        else if (this.velocity.X > x41)
                        {
                            this.velocity.X = this.velocity.X - single66;
                            if (this.velocity.X > 0f && x41 < 0f)
                            {
                                this.velocity.X = this.velocity.X - single66;
                            }
                        }
                        if (this.velocity.Y < y38)
                        {
                            this.velocity.Y = this.velocity.Y + single66;
                            if (this.velocity.Y < 0f && y38 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + single66;
                            }
                        }
                        else if (this.velocity.Y > y38)
                        {
                            this.velocity.Y = this.velocity.Y - single66;
                            if (this.velocity.Y > 0f && y38 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - single66;
                            }
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        float single69 = 600f;
                        if (Main.expertMode)
                        {
                            single69 = single69 * 0.35f;
                        }
                        if (this.ai[2] >= single69)
                        {
                            this.ai[1] = 1f;
                            this.ai[2] = 0f;
                            this.ai[3] = 0f;
                            this.target = 255;
                            this.netUpdate = true;
                        }
                        else if (this.position.Y + (float)this.height < Main.player[this.target].position.Y && single68 < 500f || Main.expertMode && single68 < 500f)
                        {
                            if (!Main.player[this.target].dead)
                            {
                                this.ai[3] = this.ai[3] + 1f;
                            }
                            float single70 = 110f;
                            if (Main.expertMode)
                            {
                                single70 = single70 * 0.4f;
                            }
                            if (this.ai[3] >= single70)
                            {
                                this.ai[3] = 0f;
                                this.rotation = single63;
                                float single71 = 5f;
                                if (Main.expertMode)
                                {
                                    single71 = 6f;
                                }
                                float x42 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector234.X;
                                float y39 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector234.Y;
                                float single72 = (float)Math.Sqrt((double)(x42 * x42 + y39 * y39));
                                single72 = single71 / single72;
                                Vector2 vector235 = vector234;
                                vector2.X = x42 * single72;
                                vector2.Y = y39 * single72;
                                vector235.X = vector235.X + vector2.X * 10f;
                                vector235.Y = vector235.Y + vector2.Y * 10f;
                                if (Main.netMode != 1)
                                {
                                    int num106 = NPC.NewNPC((int)vector235.X, (int)vector235.Y, 5, 0, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num106].velocity.X = vector2.X;
                                    Main.npc[num106].velocity.Y = vector2.Y;
                                    if (Main.netMode == 2 && num106 < 200)
                                    {
                                        NetMessage.SendData(23, -1, -1, "", num106, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                }
                            }
                        }
                    }
                    else if (this.ai[1] == 1f)
                    {
                        this.rotation = single63;
                        float single73 = 6f;
                        if (Main.expertMode)
                        {
                            single73 = 7f;
                        }
                        Vector2 vector236 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x43 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector236.X;
                        float y40 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector236.Y;
                        float single74 = (float)Math.Sqrt((double)(x43 * x43 + y40 * y40));
                        single74 = single73 / single74;
                        this.velocity.X = x43 * single74;
                        this.velocity.Y = y40 * single74;
                        this.ai[1] = 2f;
                        this.netUpdate = true;
                        if (this.netSpam > 10)
                        {
                            this.netSpam = 10;
                        }
                    }
                    else if (this.ai[1] == 2f)
                    {
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] < 40f)
                        {
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                        }
                        else
                        {
                            NPC nPC37 = this;
                            nPC37.velocity = nPC37.velocity * 0.98f;
                            if (Main.expertMode)
                            {
                                NPC nPC38 = this;
                                nPC38.velocity = nPC38.velocity * 0.985f;
                            }
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                            }
                        }
                        int num107 = 150;
                        if (Main.expertMode)
                        {
                            num107 = 100;
                        }
                        if (this.ai[2] >= (float)num107)
                        {
                            this.ai[3] = this.ai[3] + 1f;
                            this.ai[2] = 0f;
                            this.target = 255;
                            this.rotation = single63;
                            if (this.ai[3] < 3f)
                            {
                                this.ai[1] = 1f;
                            }
                            else
                            {
                                this.ai[1] = 0f;
                                this.ai[3] = 0f;
                            }
                        }
                    }
                    float single75 = 0.5f;
                    if (Main.expertMode)
                    {
                        single75 = 0.65f;
                    }
                    if ((float)this.life < (float)this.lifeMax * single75)
                    {
                        this.ai[0] = 1f;
                        this.ai[1] = 0f;
                        this.ai[2] = 0f;
                        this.ai[3] = 0f;
                        this.netUpdate = true;
                        if (this.netSpam > 10)
                        {
                            this.netSpam = 10;
                            return;
                        }
                    }
                }
                else if (this.ai[0] == 1f || this.ai[0] == 2f)
                {
                    if (this.ai[0] != 1f)
                    {
                        this.ai[2] = this.ai[2] - 0.005f;
                        if (this.ai[2] < 0f)
                        {
                            this.ai[2] = 0f;
                        }
                    }
                    else
                    {
                        this.ai[2] = this.ai[2] + 0.005f;
                        if ((double)this.ai[2] > 0.5)
                        {
                            this.ai[2] = 0.5f;
                        }
                    }
                    NPC nPC39 = this;
                    nPC39.rotation = nPC39.rotation + this.ai[2];
                    this.ai[1] = this.ai[1] + 1f;
                    if (Main.expertMode && this.ai[1] % 20f == 0f)
                    {
                        float single76 = 5f;
                        Vector2 vector237 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float single77 = (float)Main.rand.Next(-200, 200);
                        float single78 = (float)Main.rand.Next(-200, 200);
                        float single79 = (float)Math.Sqrt((double)(single77 * single77 + single78 * single78));
                        single79 = single76 / single79;
                        Vector2 vector238 = vector237;
                        vector21.X = single77 * single79;
                        vector21.Y = single78 * single79;
                        vector238.X = vector238.X + vector21.X * 10f;
                        vector238.Y = vector238.Y + vector21.Y * 10f;
                        if (Main.netMode != 1)
                        {
                            int num108 = NPC.NewNPC((int)vector238.X, (int)vector238.Y, 5, 0, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num108].velocity.X = vector21.X;
                            Main.npc[num108].velocity.Y = vector21.Y;
                            if (Main.netMode == 2 && num108 < 200)
                            {
                                NetMessage.SendData(23, -1, -1, "", num108, 0f, 0f, 0f, 0, 0, 0);
                            }
                        }
                    }
                    if (this.ai[1] == 100f)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                        this.ai[1] = 0f;
                        if (this.ai[0] == 3f)
                        {
                            this.ai[2] = 0f;
                        }
                    }
                    this.velocity.X = this.velocity.X * 0.98f;
                    this.velocity.Y = this.velocity.Y * 0.98f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                    }
                    if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                    {
                        this.velocity.Y = 0f;
                        return;
                    }
                }
                else
                {
                    this.defense = 0;
                    this.damage = (int)(23f * Main.expertDamage);
                    if (Main.expertMode)
                    {
                        if (flag34)
                        {
                            this.defense = -15;
                        }
                        if (!flag35)
                        {
                            this.damage = (int)(18f * Main.expertDamage);
                        }
                        else
                        {
                            this.damage = (int)(20f * Main.expertDamage);
                            this.defense = -30;
                        }
                    }
                    if (this.ai[1] == 0f && flag34)
                    {
                        this.ai[1] = 5f;
                    }
                    if (this.ai[1] == 0f)
                    {
                        float single80 = 6f;
                        float single81 = 0.07f;
                        Vector2 vector241 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x44 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector241.X;
                        float y41 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 120f - vector241.Y;
                        float single82 = (float)Math.Sqrt((double)(x44 * x44 + y41 * y41));
                        if (single82 > 400f && Main.expertMode)
                        {
                            single80 = single80 + 1f;
                            single81 = single81 + 0.05f;
                            if (single82 > 600f)
                            {
                                single80 = single80 + 1f;
                                single81 = single81 + 0.05f;
                                if (single82 > 800f)
                                {
                                    single80 = single80 + 1f;
                                    single81 = single81 + 0.05f;
                                }
                            }
                        }
                        single82 = single80 / single82;
                        x44 = x44 * single82;
                        y41 = y41 * single82;
                        if (this.velocity.X < x44)
                        {
                            this.velocity.X = this.velocity.X + single81;
                            if (this.velocity.X < 0f && x44 > 0f)
                            {
                                this.velocity.X = this.velocity.X + single81;
                            }
                        }
                        else if (this.velocity.X > x44)
                        {
                            this.velocity.X = this.velocity.X - single81;
                            if (this.velocity.X > 0f && x44 < 0f)
                            {
                                this.velocity.X = this.velocity.X - single81;
                            }
                        }
                        if (this.velocity.Y < y41)
                        {
                            this.velocity.Y = this.velocity.Y + single81;
                            if (this.velocity.Y < 0f && y41 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + single81;
                            }
                        }
                        else if (this.velocity.Y > y41)
                        {
                            this.velocity.Y = this.velocity.Y - single81;
                            if (this.velocity.Y > 0f && y41 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - single81;
                            }
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] >= 200f)
                        {
                            this.ai[1] = 1f;
                            this.ai[2] = 0f;
                            this.ai[3] = 0f;
                            if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.35)
                            {
                                this.ai[1] = 3f;
                            }
                            this.target = 255;
                            this.netUpdate = true;
                        }
                        if (Main.expertMode && flag35)
                        {
                            this.TargetClosest(true);
                            this.netUpdate = true;
                            this.ai[1] = 3f;
                            this.ai[2] = 0f;
                            this.ai[3] = this.ai[3] - 1000f;
                        }
                    }
                    else if (this.ai[1] == 1f)
                    {
                        this.rotation = single63;
                        float single83 = 6.8f;
                        if (Main.expertMode && this.ai[3] == 1f)
                        {
                            single83 = single83 * 1.15f;
                        }
                        if (Main.expertMode && this.ai[3] == 2f)
                        {
                            single83 = single83 * 1.3f;
                        }
                        Vector2 vector242 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x45 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector242.X;
                        float y42 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector242.Y;
                        float single84 = (float)Math.Sqrt((double)(x45 * x45 + y42 * y42));
                        single84 = single83 / single84;
                        this.velocity.X = x45 * single84;
                        this.velocity.Y = y42 * single84;
                        this.ai[1] = 2f;
                        this.netUpdate = true;
                        if (this.netSpam > 10)
                        {
                            this.netSpam = 10;
                        }
                    }
                    else if (this.ai[1] == 2f)
                    {
                        float single85 = 40f;
                        this.ai[2] = this.ai[2] + 1f;
                        if (Main.expertMode)
                        {
                            single85 = 50f;
                        }
                        if (this.ai[2] < single85)
                        {
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                        }
                        else
                        {
                            NPC nPC40 = this;
                            nPC40.velocity = nPC40.velocity * 0.97f;
                            if (Main.expertMode)
                            {
                                NPC nPC41 = this;
                                nPC41.velocity = nPC41.velocity * 0.98f;
                            }
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                            }
                        }
                        int num113 = 130;
                        if (Main.expertMode)
                        {
                            num113 = 90;
                        }
                        if (this.ai[2] >= (float)num113)
                        {
                            this.ai[3] = this.ai[3] + 1f;
                            this.ai[2] = 0f;
                            this.target = 255;
                            this.rotation = single63;
                            if (this.ai[3] < 3f)
                            {
                                this.ai[1] = 1f;
                            }
                            else
                            {
                                this.ai[1] = 0f;
                                this.ai[3] = 0f;
                                if (Main.expertMode && Main.netMode != 1 && (double)this.life < (double)this.lifeMax * 0.5)
                                {
                                    this.ai[1] = 3f;
                                    this.ai[3] = this.ai[3] + (float)Main.rand.Next(1, 4);
                                }
                                this.netUpdate = true;
                                if (this.netSpam > 10)
                                {
                                    this.netSpam = 10;
                                }
                            }
                        }
                    }
                    else if (this.ai[1] == 3f)
                    {
                        if (this.ai[3] == 4f && flag34 && base.Center.Y > Main.player[this.target].Center.Y)
                        {
                            this.TargetClosest(true);
                            this.ai[1] = 0f;
                            this.ai[2] = 0f;
                            this.ai[3] = 0f;
                            this.netUpdate = true;
                            if (this.netSpam > 10)
                            {
                                this.netSpam = 10;
                            }
                        }
                        else if (Main.netMode != 1)
                        {
                            this.TargetClosest(true);
                            float single86 = 20f;
                            Vector2 vector243 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x46 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector243.X;
                            float y43 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector243.Y;
                            float single87 = Math.Abs(Main.player[this.target].velocity.X) + Math.Abs(Main.player[this.target].velocity.Y) / 4f;
                            single87 = single87 + (10f - single87);
                            if (single87 < 5f)
                            {
                                single87 = 5f;
                            }
                            if (single87 > 15f)
                            {
                                single87 = 15f;
                            }
                            if (this.ai[2] == -1f && !flag35)
                            {
                                single87 = single87 * 4f;
                                single86 = single86 * 1.3f;
                            }
                            if (flag35)
                            {
                                single87 = single87 * 2f;
                            }
                            x46 = x46 - Main.player[this.target].velocity.X * single87;
                            y43 = y43 - Main.player[this.target].velocity.Y * single87 / 4f;
                            x46 = x46 * (1f + (float)Main.rand.Next(-10, 11) * 0.01f);
                            y43 = y43 * (1f + (float)Main.rand.Next(-10, 11) * 0.01f);
                            if (flag35)
                            {
                                x46 = x46 * (1f + (float)Main.rand.Next(-10, 11) * 0.01f);
                                y43 = y43 * (1f + (float)Main.rand.Next(-10, 11) * 0.01f);
                            }
                            float single88 = (float)Math.Sqrt((double)(x46 * x46 + y43 * y43));
                            float single89 = single88;
                            single88 = single86 / single88;
                            this.velocity.X = x46 * single88;
                            this.velocity.Y = y43 * single88;
                            this.velocity.X = this.velocity.X + (float)Main.rand.Next(-20, 21) * 0.1f;
                            this.velocity.Y = this.velocity.Y + (float)Main.rand.Next(-20, 21) * 0.1f;
                            if (flag35)
                            {
                                this.velocity.X = this.velocity.X + (float)Main.rand.Next(-50, 51) * 0.1f;
                                this.velocity.Y = this.velocity.Y + (float)Main.rand.Next(-50, 51) * 0.1f;
                                float single90 = Math.Abs(this.velocity.X);
                                float single91 = Math.Abs(this.velocity.Y);
                                if (base.Center.X > Main.player[this.target].Center.X)
                                {
                                    single91 = single91 * -1f;
                                }
                                if (base.Center.Y > Main.player[this.target].Center.Y)
                                {
                                    single90 = single90 * -1f;
                                }
                                this.velocity.X = single91 + this.velocity.X;
                                this.velocity.Y = single90 + this.velocity.Y;
                                this.velocity.Normalize();
                                NPC nPC42 = this;
                                nPC42.velocity = nPC42.velocity * single86;
                                this.velocity.X = this.velocity.X + (float)Main.rand.Next(-20, 21) * 0.1f;
                                this.velocity.Y = this.velocity.Y + (float)Main.rand.Next(-20, 21) * 0.1f;
                            }
                            else if (single89 < 100f)
                            {
                                if (Math.Abs(this.velocity.X) > Math.Abs(this.velocity.Y))
                                {
                                    float single92 = Math.Abs(this.velocity.X);
                                    float single93 = Math.Abs(this.velocity.Y);
                                    if (base.Center.X > Main.player[this.target].Center.X)
                                    {
                                        single93 = single93 * -1f;
                                    }
                                    if (base.Center.Y > Main.player[this.target].Center.Y)
                                    {
                                        single92 = single92 * -1f;
                                    }
                                    this.velocity.X = single93;
                                    this.velocity.Y = single92;
                                }
                            }
                            else if (Math.Abs(this.velocity.X) > Math.Abs(this.velocity.Y))
                            {
                                float single94 = (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) / 2f;
                                float single95 = single94;
                                if (base.Center.X > Main.player[this.target].Center.X)
                                {
                                    single95 = single95 * -1f;
                                }
                                if (base.Center.Y > Main.player[this.target].Center.Y)
                                {
                                    single94 = single94 * -1f;
                                }
                                this.velocity.X = single95;
                                this.velocity.Y = single94;
                            }
                            this.ai[1] = 4f;
                            this.netUpdate = true;
                            if (this.netSpam > 10)
                            {
                                this.netSpam = 10;
                            }
                        }
                    }
                    else if (this.ai[1] == 4f)
                    {
                        float single96 = single62;
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] == single96 && Vector2.Distance(this.position, Main.player[this.target].position) < 200f)
                        {
                            this.ai[2] = this.ai[2] - 1f;
                        }
                        if (this.ai[2] < single96)
                        {
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                        }
                        else
                        {
                            NPC nPC43 = this;
                            nPC43.velocity = nPC43.velocity * 0.95f;
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                            }
                        }
                        if (this.ai[2] >= single96 + 13f)
                        {
                            this.netUpdate = true;
                            if (this.netSpam > 10)
                            {
                                this.netSpam = 10;
                            }
                            this.ai[3] = this.ai[3] + 1f;
                            this.ai[2] = 0f;
                            if (this.ai[3] < 5f)
                            {
                                this.ai[1] = 3f;
                            }
                            else
                            {
                                this.ai[1] = 0f;
                                this.ai[3] = 0f;
                            }
                        }
                    }
                    else if (this.ai[1] == 5f)
                    {
                        float single97 = 600f;
                        float single98 = 9f;
                        float single99 = 0.3f;
                        Vector2 vector244 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x47 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector244.X;
                        float y44 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) + single97 - vector244.Y;
                        float single100 = (float)Math.Sqrt((double)(x47 * x47 + y44 * y44));
                        single100 = single98 / single100;
                        x47 = x47 * single100;
                        y44 = y44 * single100;
                        if (this.velocity.X < x47)
                        {
                            this.velocity.X = this.velocity.X + single99;
                            if (this.velocity.X < 0f && x47 > 0f)
                            {
                                this.velocity.X = this.velocity.X + single99;
                            }
                        }
                        else if (this.velocity.X > x47)
                        {
                            this.velocity.X = this.velocity.X - single99;
                            if (this.velocity.X > 0f && x47 < 0f)
                            {
                                this.velocity.X = this.velocity.X - single99;
                            }
                        }
                        if (this.velocity.Y < y44)
                        {
                            this.velocity.Y = this.velocity.Y + single99;
                            if (this.velocity.Y < 0f && y44 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + single99;
                            }
                        }
                        else if (this.velocity.Y > y44)
                        {
                            this.velocity.Y = this.velocity.Y - single99;
                            if (this.velocity.Y > 0f && y44 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - single99;
                            }
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] >= 70f)
                        {
                            this.TargetClosest(true);
                            this.ai[1] = 3f;
                            this.ai[2] = -1f;
                            this.ai[3] = (float)Main.rand.Next(-3, 1);
                            this.netUpdate = true;
                        }
                    }
                    if (flag35 && this.ai[1] == 5f)
                    {
                        this.ai[1] = 3f;
                        return;
                    }
                }
            }
            else if (this.aiStyle == 5)
            {
                if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                {
                    this.TargetClosest(true);
                }
                float single101 = 6f;
                float single102 = 0.05f;
                if (this.type == 6 || this.type == 173)
                {
                    single101 = 4f;
                    single102 = 0.02f;
                    if (this.type == 6 && Main.expertMode)
                    {
                        single102 = 0.035f;
                    }
                }
                else if (this.type == 94)
                {
                    single101 = 4.2f;
                    single102 = 0.022f;
                }
                else if (this.type == 252)
                {
                    if (!Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        single102 = 0.01f;
                        single101 = 2f;
                    }
                    else
                    {
                        single101 = 6f;
                        single102 = 0.1f;
                    }
                }
                else if (this.type == 42 || this.type >= 231 && this.type <= 235)
                {
                    single101 = 3.5f;
                    single102 = 0.021f;
                    if (this.type == 231)
                    {
                        single101 = 3f;
                        single102 = 0.017f;
                    }
                    single101 = single101 * (1f - this.scale);
                    single102 = single102 * (1f - this.scale);
                }
                else if (this.type == 205)
                {
                    single101 = 3.25f;
                    single102 = 0.018f;
                }
                else if (this.type == 176)
                {
                    single101 = 4f;
                    single102 = 0.017f;
                }
                else if (this.type == 23)
                {
                    single101 = 1f;
                    single102 = 0.03f;
                }
                else if (this.type == 5)
                {
                    single101 = 5f;
                    single102 = 0.03f;
                }
                else if (this.type == 210 || this.type == 211)
                {
                    this.localAI[0] = this.localAI[0] + 1f;
                    float single103 = (this.localAI[0] - 60f) / 60f;
                    if (single103 <= 1f)
                    {
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = 6f;
                        }
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = -6f;
                        }
                        if (this.velocity.Y > 6f)
                        {
                            this.velocity.Y = 6f;
                        }
                        if (this.velocity.Y < -6f)
                        {
                            this.velocity.Y = -6f;
                        }
                    }
                    else
                    {
                        single103 = 1f;
                    }
                    single101 = 5f;
                    single102 = 0.1f;
                    single102 = single102 * single103;
                }
                Vector2 vector245 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float x48 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                float y45 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                x48 = (float)((int)(x48 / 8f) * 8);
                y45 = (float)((int)(y45 / 8f) * 8);
                vector245.X = (float)((int)(vector245.X / 8f) * 8);
                vector245.Y = (float)((int)(vector245.Y / 8f) * 8);
                x48 = x48 - vector245.X;
                y45 = y45 - vector245.Y;
                float single104 = (float)Math.Sqrt((double)(x48 * x48 + y45 * y45));
                float single105 = single104;
                bool flag37 = false;
                if (single104 > 600f)
                {
                    flag37 = true;
                }
                if (single104 != 0f)
                {
                    single104 = single101 / single104;
                    x48 = x48 * single104;
                    y45 = y45 * single104;
                }
                else
                {
                    x48 = this.velocity.X;
                    y45 = this.velocity.Y;
                }
                if (this.type == 6 || this.type == 42 || this.type == 94 || this.type == 139 || this.type == 173 || this.type == 176 || this.type == 205 || this.type == 210 || this.type == 211 || this.type >= 231 && this.type <= 235)
                {
                    if (single105 > 100f || this.type == 42 || this.type == 94 || this.type == 176 || this.type == 210 || this.type == 211 || this.type >= 231 && this.type <= 235)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                        if (this.ai[0] <= 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.023f;
                        }
                        else
                        {
                            this.velocity.Y = this.velocity.Y + 0.023f;
                        }
                        if (this.ai[0] < -100f || this.ai[0] > 100f)
                        {
                            this.velocity.X = this.velocity.X + 0.023f;
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X - 0.023f;
                        }
                        if (this.ai[0] > 200f)
                        {
                            this.ai[0] = -200f;
                        }
                    }
                    if (single105 < 150f && (this.type == 6 || this.type == 94 || this.type == 173))
                    {
                        this.velocity.X = this.velocity.X + x48 * 0.007f;
                        this.velocity.Y = this.velocity.Y + y45 * 0.007f;
                    }
                }
                if (Main.player[this.target].dead)
                {
                    x48 = (float)this.direction * single101 / 2f;
                    y45 = -single101 / 2f;
                }
                if (this.velocity.X < x48)
                {
                    this.velocity.X = this.velocity.X + single102;
                    if (this.type != 173 && this.type != 6 && this.type != 42 && (this.type < 231 || this.type > 235) && this.type != 94 && this.type != 139 && this.velocity.X < 0f && x48 > 0f)
                    {
                        this.velocity.X = this.velocity.X + single102;
                    }
                }
                else if (this.velocity.X > x48)
                {
                    this.velocity.X = this.velocity.X - single102;
                    if (this.type != 173 && this.type != 6 && this.type != 42 && (this.type < 231 || this.type > 235) && this.type != 94 && this.type != 139 && this.velocity.X > 0f && x48 < 0f)
                    {
                        this.velocity.X = this.velocity.X - single102;
                    }
                }
                if (this.velocity.Y < y45)
                {
                    this.velocity.Y = this.velocity.Y + single102;
                    if (this.type != 173 && this.type != 6 && this.type != 42 && (this.type < 231 || this.type > 235) && this.type != 94 && this.type != 139 && this.velocity.Y < 0f && y45 > 0f)
                    {
                        this.velocity.Y = this.velocity.Y + single102;
                    }
                }
                else if (this.velocity.Y > y45)
                {
                    this.velocity.Y = this.velocity.Y - single102;
                    if (this.type != 173 && this.type != 6 && this.type != 42 && (this.type < 231 || this.type > 235) && this.type != 94 && this.type != 139 && this.velocity.Y > 0f && y45 < 0f)
                    {
                        this.velocity.Y = this.velocity.Y - single102;
                    }
                }
                if (this.type == 23)
                {
                    if (x48 > 0f)
                    {
                        this.spriteDirection = 1;
                        this.rotation = (float)Math.Atan2((double)y45, (double)x48);
                    }
                    else if (x48 < 0f)
                    {
                        this.spriteDirection = -1;
                        this.rotation = (float)Math.Atan2((double)y45, (double)x48) + 3.14f;
                    }
                }
                else if (this.type == 139)
                {
                    this.localAI[0] = this.localAI[0] + 1f;
                    if (this.justHit)
                    {
                        this.localAI[0] = 0f;
                    }
                    if (Main.netMode != 1 && this.localAI[0] >= 120f)
                    {
                        this.localAI[0] = 0f;
                        if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            int num114 = 25;
                            if (Main.expertMode)
                            {
                                num114 = 22;
                            }
                            int num115 = 84;
                            Projectile.NewProjectile(vector245.X, vector245.Y, x48, y45, num115, num114, 0f, Main.myPlayer, 0f, 0f);
                        }
                    }
                    int x49 = (int)this.position.X + this.width / 2;
                    int y46 = (int)this.position.Y + this.height / 2;
                    if (x48 > 0f)
                    {
                        this.spriteDirection = 1;
                        this.rotation = (float)Math.Atan2((double)y45, (double)x48);
                    }
                    if (x48 < 0f)
                    {
                        this.spriteDirection = -1;
                        this.rotation = (float)Math.Atan2((double)y45, (double)x48) + 3.14f;
                    }
                }
                else if (this.type == 6 || this.type == 94 || this.type == 173)
                {
                    this.rotation = (float)Math.Atan2((double)y45, (double)x48) - 1.57f;
                }
                else if (this.type == 42 || this.type == 176 || this.type == 205 || this.type >= 231 && this.type <= 235)
                {
                    if (this.velocity.X > 0f)
                    {
                        this.spriteDirection = 1;
                    }
                    if (this.velocity.X < 0f)
                    {
                        this.spriteDirection = -1;
                    }
                    this.rotation = this.velocity.X * 0.1f;
                }
                else
                {
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                }
                if (this.type == 6 || this.type == 23 || this.type == 42 || this.type == 94 || this.type == 139 || this.type == 173 || this.type == 176 || this.type == 205 || this.type == 210 || this.type == 211 || this.type >= 231 && this.type <= 235)
                {
                    float single106 = 0.7f;
                    if (this.type == 6 || this.type == 173)
                    {
                        single106 = 0.4f;
                    }
                    if (this.collideX)
                    {
                        this.netUpdate = true;
                        this.velocity.X = this.oldVelocity.X * -single106;
                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                        {
                            this.velocity.X = 2f;
                        }
                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                    if (this.collideY)
                    {
                        this.netUpdate = true;
                        this.velocity.Y = this.oldVelocity.Y * -single106;
                        if (this.velocity.Y > 0f && (double)this.velocity.Y < 1.5)
                        {
                            this.velocity.Y = 2f;
                        }
                        if (this.velocity.Y < 0f && (double)this.velocity.Y > -1.5)
                        {
                            this.velocity.Y = -2f;
                        }
                    }
                }
                if ((this.type == 6 || this.type == 94 || this.type == 173) && this.wet)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.3f;
                    if (this.velocity.Y < -2f)
                    {
                        this.velocity.Y = -2f;
                    }
                }
                if (this.type == 205 && this.wet)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.5f;
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                    this.TargetClosest(true);
                }
                if (this.type == 42 || this.type == 176 || this.type >= 231 && this.type <= 235)
                {
                    if (this.wet)
                    {
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.95f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                        this.TargetClosest(true);
                    }
                    if (this.ai[1] == 101f)
                    {
                        this.ai[1] = 0f;
                    }
                    if (Main.netMode != 1)
                    {
                        this.ai[1] = this.ai[1] + (float)Main.rand.Next(5, 20) * 0.1f * this.scale;
                        if (this.type == 176)
                        {
                            this.ai[1] = this.ai[1] + (float)Main.rand.Next(5, 20) * 0.1f * this.scale;
                        }
                        if (Main.player[this.target].stealth == 0f && Main.player[this.target].itemAnimation == 0)
                        {
                            this.ai[1] = 0f;
                        }
                        if (this.ai[1] >= 130f)
                        {
                            if (!Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                this.ai[1] = 0f;
                            }
                            else
                            {
                                float single107 = 8f;
                                Vector2 vector248 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)(this.height / 2));
                                float x51 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector248.X + (float)Main.rand.Next(-20, 21);
                                float y47 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector248.Y + (float)Main.rand.Next(-20, 21);
                                if ((x51 >= 0f || this.velocity.X >= 0f) && (x51 <= 0f || this.velocity.X <= 0f))
                                {
                                    this.ai[1] = 0f;
                                }
                                else
                                {
                                    float single108 = (float)Math.Sqrt((double)(x51 * x51 + y47 * y47));
                                    single108 = single107 / single108;
                                    x51 = x51 * single108;
                                    y47 = y47 * single108;
                                    int num124 = (int)(10f * this.scale);
                                    if (this.type == 176)
                                    {
                                        num124 = (int)(30f * this.scale);
                                    }
                                    int num125 = 55;
                                    int num126 = Projectile.NewProjectile(vector248.X, vector248.Y, x51, y47, num125, num124, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num126].timeLeft = 300;
                                    this.ai[1] = 101f;
                                    this.netUpdate = true;
                                }
                            }
                        }
                    }
                }
                if (this.type == 139 && flag37)
                {
                    if ((this.velocity.X <= 0f || x48 <= 0f) && (this.velocity.X >= 0f || x48 >= 0f))
                    {
                        this.velocity.X = this.velocity.X * 0.9f;
                    }
                    else if (Math.Abs(this.velocity.X) < 12f)
                    {
                        this.velocity.X = this.velocity.X * 1.05f;
                    }
                }
                if (Main.netMode != 1 && this.type == 94 && !Main.player[this.target].dead)
                {
                    if (this.justHit)
                    {
                        this.localAI[0] = 0f;
                    }
                    this.localAI[0] = this.localAI[0] + 1f;
                    if (this.localAI[0] == 180f)
                    {
                        if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            NPC.NewNPC((int)(this.position.X + (float)(this.width / 2) + this.velocity.X), (int)(this.position.Y + (float)(this.height / 2) + this.velocity.Y), 112, 0, 0f, 0f, 0f, 0f, 255);
                        }
                        this.localAI[0] = 0f;
                    }
                }
                if (Main.dayTime && this.type != 173 && this.type != 6 && this.type != 23 && this.type != 42 && this.type != 94 && this.type != 176 && this.type != 205 && this.type != 210 && this.type != 211 && this.type != 252 && (this.type < 231 || this.type > 235) || Main.player[this.target].dead)
                {
                    this.velocity.Y = this.velocity.Y - single102 * 2f;
                    if (this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                }
                if ((this.velocity.X > 0f && this.oldVelocity.X < 0f || this.velocity.X < 0f && this.oldVelocity.X > 0f || this.velocity.Y > 0f && this.oldVelocity.Y < 0f || this.velocity.Y < 0f && this.oldVelocity.Y > 0f) && !this.justHit)
                {
                    this.netUpdate = true;
                    return;
                }
            }
            else if (this.aiStyle == 6)
            {
                if (this.type == 117 && this.localAI[1] == 0f)
                {
                    this.localAI[1] = 1f;
                    int num127 = 1;
                    if (this.velocity.X < 0f)
                    {
                        num127 = -1;
                    }
                }
                if (this.type == 454 && this.localAI[3] == 0f)
                {
                    this.localAI[3] = 1f;
                }
                if (this.type >= 454 && this.type <= 459)
                {
                    this.dontTakeDamage = this.alpha > 0;
                    if (this.type == 454 || this.type != 454 && Main.npc[(int)this.ai[1]].alpha < 85)
                    {
                        NPC nPC44 = this;
                        nPC44.alpha = nPC44.alpha - 42;
                        if (this.alpha < 0)
                        {
                            this.alpha = 0;
                        }
                    }
                }
                else if (this.type == 402 && this.ai[1] == 0f)
                {
                    this.ai[1] = (float)Main.rand.Next(-2, 0);
                    this.netUpdate = true;
                }
                if (Main.netMode != 1 && Main.expertMode)
                {
                    if (this.type == 14 && (double)(this.position.Y / 16f) < Main.worldSurface)
                    {
                        if (Main.rand.Next(900) == 0)
                        {
                            this.TargetClosest(true);
                            if (Collision.CanHitLine(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                NPC.NewNPC((int)(this.position.X + (float)(this.width / 2) + this.velocity.X), (int)(this.position.Y + (float)(this.height / 2) + this.velocity.Y), 112, 0, 0f, 0f, 0f, 0f, 255);
                            }
                        }
                    }
                    else if (this.type == 13)
                    {
                        int num131 = 90;
                        num131 = num131 + (int)((float)this.life / (float)this.lifeMax * 60f * 5f);
                        if (Main.rand.Next(num131) == 0)
                        {
                            this.TargetClosest(true);
                            if (Collision.CanHitLine(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                NPC.NewNPC((int)(this.position.X + (float)(this.width / 2) + this.velocity.X), (int)(this.position.Y + (float)(this.height / 2) + this.velocity.Y), 112, 0, 0f, 0f, 0f, 0f, 255);
                            }
                        }
                    }
                }
                if (this.type >= 13 && this.type <= 15)
                {
                    this.realLife = -1;
                }
                else if (this.ai[3] > 0f)
                {
                    this.realLife = (int)this.ai[3];
                }
                if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                {
                    this.TargetClosest(true);
                }
                if (Main.player[this.target].dead && this.timeLeft > 300)
                {
                    this.timeLeft = 300;
                }
                if (Main.netMode != 1)
                {
                    if (this.type == 87 && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num132 = 0;
                        int num133 = this.whoAmI;
                        for (int y110 = 0; y110 < 14; y110++)
                        {
                            int num134 = 89;
                            if (y110 == 1 || y110 == 8)
                            {
                                num134 = 88;
                            }
                            else if (y110 == 11)
                            {
                                num134 = 90;
                            }
                            else if (y110 == 12)
                            {
                                num134 = 91;
                            }
                            else if (y110 == 13)
                            {
                                num134 = 92;
                            }
                            num132 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num134, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num132].ai[3] = (float)this.whoAmI;
                            Main.npc[num132].realLife = this.whoAmI;
                            Main.npc[num132].ai[1] = (float)num133;
                            Main.npc[num133].ai[0] = (float)num132;
                            NetMessage.SendData(23, -1, -1, "", num132, 0f, 0f, 0f, 0, 0, 0);
                            num133 = num132;
                        }
                    }
                    if (this.type == 454 && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num135 = 0;
                        int num136 = this.whoAmI;
                        for (int a1 = 0; a1 < 30; a1++)
                        {
                            int num137 = 456;
                            if ((a1 - 2) % 4 == 0 && a1 < 26)
                            {
                                num137 = 455;
                            }
                            else if (a1 == 27)
                            {
                                num137 = 457;
                            }
                            else if (a1 == 28)
                            {
                                num137 = 458;
                            }
                            else if (a1 == 29)
                            {
                                num137 = 459;
                            }
                            num135 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num137, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num135].ai[3] = (float)this.whoAmI;
                            Main.npc[num135].realLife = this.whoAmI;
                            Main.npc[num135].ai[1] = (float)num136;
                            Main.npc[num136].ai[0] = (float)num135;
                            NetMessage.SendData(23, -1, -1, "", num135, 0f, 0f, 0f, 0, 0, 0);
                            num136 = num135;
                        }
                    }
                    if (this.type == 513 && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num138 = 0;
                        int num139 = this.whoAmI;
                        int num140 = Main.rand.Next(6, 10);
                        for (int b1 = 0; b1 < num140; b1++)
                        {
                            int num141 = 514;
                            if (b1 == num140 - 1)
                            {
                                num141 = 515;
                            }
                            num138 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num141, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num138].ai[3] = (float)this.whoAmI;
                            Main.npc[num138].realLife = this.whoAmI;
                            Main.npc[num138].ai[1] = (float)num139;
                            Main.npc[num139].ai[0] = (float)num138;
                            NetMessage.SendData(23, -1, -1, "", num138, 0f, 0f, 0f, 0, 0, 0);
                            num139 = num138;
                        }
                    }
                    if (this.type == 510 && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num142 = 0;
                        int num143 = this.whoAmI;
                        int num144 = Main.rand.Next(12, 21);
                        for (int c1 = 0; c1 < num144; c1++)
                        {
                            int num145 = 511;
                            if (c1 == num144 - 1)
                            {
                                num145 = 512;
                            }
                            num142 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num145, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num142].ai[3] = (float)this.whoAmI;
                            Main.npc[num142].realLife = this.whoAmI;
                            Main.npc[num142].ai[1] = (float)num143;
                            Main.npc[num143].ai[0] = (float)num142;
                            NetMessage.SendData(23, -1, -1, "", num142, 0f, 0f, 0f, 0, 0, 0);
                            num143 = num142;
                        }
                    }
                    else if ((this.type == 7 || this.type == 8 || this.type == 10 || this.type == 11 || this.type == 13 || this.type == 14 || this.type == 39 || this.type == 40 || this.type == 95 || this.type == 96 || this.type == 98 || this.type == 99 || this.type == 117 || this.type == 118) && this.ai[0] == 0f)
                    {
                        if (this.type == 7 || this.type == 10 || this.type == 13 || this.type == 39 || this.type == 95 || this.type == 98 || this.type == 117)
                        {
                            if (this.type < 13 || this.type > 15)
                            {
                                this.ai[3] = (float)this.whoAmI;
                                this.realLife = this.whoAmI;
                            }
                            this.ai[2] = (float)Main.rand.Next(8, 13);
                            if (this.type == 10)
                            {
                                this.ai[2] = (float)Main.rand.Next(4, 7);
                            }
                            if (this.type == 13)
                            {
                                this.ai[2] = (float)Main.rand.Next(45, 56);
                                if (Main.expertMode)
                                {
                                    this.ai[2] = (float)((int)(this.ai[2] * 1.1f));
                                }
                            }
                            if (this.type == 39)
                            {
                                this.ai[2] = (float)Main.rand.Next(12, 19);
                            }
                            if (this.type == 95)
                            {
                                this.ai[2] = (float)Main.rand.Next(6, 12);
                            }
                            if (this.type == 98)
                            {
                                this.ai[2] = (float)Main.rand.Next(20, 26);
                            }
                            if (this.type == 117)
                            {
                                this.ai[2] = (float)Main.rand.Next(3, 6);
                            }
                            this.ai[0] = (float)NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), this.type + 1, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        }
                        else if ((this.type == 8 || this.type == 11 || this.type == 14 || this.type == 40 || this.type == 96 || this.type == 99 || this.type == 118) && this.ai[2] > 0f)
                        {
                            this.ai[0] = (float)NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), this.type, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        }
                        else
                        {
                            this.ai[0] = (float)NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), this.type + 1, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        }
                        if (this.type < 13 || this.type > 15)
                        {
                            Main.npc[(int)this.ai[0]].ai[3] = this.ai[3];
                            Main.npc[(int)this.ai[0]].realLife = this.realLife;
                        }
                        Main.npc[(int)this.ai[0]].ai[1] = (float)this.whoAmI;
                        Main.npc[(int)this.ai[0]].ai[2] = this.ai[2] - 1f;
                        this.netUpdate = true;
                    }
                    if (this.type == 412 && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num146 = 0;
                        int num147 = this.whoAmI;
                        int num148 = 30;
                        for (int d1 = 0; d1 < num148; d1++)
                        {
                            int num149 = 413;
                            if (d1 == num148 - 1)
                            {
                                num149 = 414;
                            }
                            num146 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num149, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num146].ai[3] = (float)this.whoAmI;
                            Main.npc[num146].realLife = this.whoAmI;
                            Main.npc[num146].ai[1] = (float)num147;
                            Main.npc[num147].ai[0] = (float)num146;
                            NetMessage.SendData(23, -1, -1, "", num146, 0f, 0f, 0f, 0, 0, 0);
                            num147 = num146;
                        }
                    }
                    num6 = this.type;
                    if (num6 <= 100)
                    {
                        switch (num6)
                        {
                            case 8:
                            case 9:
                            case 11:
                            case 12:
                            {
                                break;
                            }
                            case 10:
                            {
                                goto Label6;
                            }
                            default:
                            {
                                switch (num6)
                                {
                                    case 40:
                                    case 41:
                                    {
                                        break;
                                    }
                                    default:
                                    {
                                        switch (num6)
                                        {
                                            case 88:
                                            case 89:
                                            case 90:
                                            case 91:
                                            case 92:
                                            case 96:
                                            case 97:
                                            case 99:
                                            case 100:
                                            {
                                                break;
                                            }
                                            default:
                                            {
                                                goto Label6;
                                            }
                                        }
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    else if (num6 > 414)
                    {
                        switch (num6)
                        {
                            case 455:
                            case 456:
                            case 457:
                            case 458:
                            case 459:
                            {
                                break;
                            }
                            default:
                            {
                                switch (num6)
                                {
                                    case 511:
                                    case 512:
                                    case 514:
                                    case 515:
                                    {
                                        break;
                                    }
                                    default:
                                    {
                                        goto Label6;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (num6)
                        {
                            case 118:
                            case 119:
                            {
                                break;
                            }
                            default:
                            {
                                switch (num6)
                                {
                                    case 413:
                                    case 414:
                                    {
                                        break;
                                    }
                                    default:
                                    {
                                        goto Label6;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != this.aiStyle)
                    {
                        this.life = 0;
                        this.HitEffect(0, 10);
                        this.active = false;
                        NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                    }
                Label6:
                    num6 = this.type;
                    if (num6 <= 99)
                    {
                        switch (num6)
                        {
                            case 7:
                            case 8:
                            case 10:
                            case 11:
                            {
                                break;
                            }
                            case 9:
                            {
                                goto Label7;
                            }
                            default:
                            {
                                switch (num6)
                                {
                                    case 39:
                                    case 40:
                                    {
                                        break;
                                    }
                                    default:
                                    {
                                        switch (num6)
                                        {
                                            case 87:
                                            case 88:
                                            case 89:
                                            case 90:
                                            case 91:
                                            case 95:
                                            case 96:
                                            case 98:
                                            case 99:
                                            {
                                                break;
                                            }
                                            default:
                                            {
                                                goto Label7;
                                            }
                                        }
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    else if (num6 > 413)
                    {
                        switch (num6)
                        {
                            case 454:
                            case 455:
                            case 456:
                            case 457:
                            case 458:
                            {
                                break;
                            }
                            default:
                            {
                                switch (num6)
                                {
                                    case 510:
                                    case 511:
                                    case 513:
                                    case 514:
                                    {
                                        break;
                                    }
                                    default:
                                    {
                                        goto Label7;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        switch (num6)
                        {
                            case 117:
                            case 118:
                            {
                                break;
                            }
                            default:
                            {
                                switch (num6)
                                {
                                    case 412:
                                    case 413:
                                    {
                                        break;
                                    }
                                    default:
                                    {
                                        goto Label7;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    if (!Main.npc[(int)this.ai[0]].active || Main.npc[(int)this.ai[0]].aiStyle != this.aiStyle)
                    {
                        this.life = 0;
                        this.HitEffect(0, 10);
                        this.active = false;
                        NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                    }
                Label7:
                    if (this.type == 13 || this.type == 14 || this.type == 15)
                    {
                        if (!Main.npc[(int)this.ai[1]].active && !Main.npc[(int)this.ai[0]].active)
                        {
                            this.life = 0;
                            this.HitEffect(0, 10);
                            this.checkDead();
                            this.active = false;
                            NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                        }
                        if (this.type == 13 && !Main.npc[(int)this.ai[0]].active)
                        {
                            this.life = 0;
                            this.HitEffect(0, 10);
                            this.checkDead();
                            this.active = false;
                            NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                        }
                        if (this.type == 15 && !Main.npc[(int)this.ai[1]].active)
                        {
                            this.life = 0;
                            this.HitEffect(0, 10);
                            this.checkDead();
                            this.active = false;
                            NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                        }
                        if (this.type == 14 && (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != this.aiStyle))
                        {
                            this.type = 13;
                            int num150 = this.whoAmI;
                            float single110 = (float)this.life / (float)this.lifeMax;
                            float single111 = this.ai[0];
                            this.SetDefaultsKeepPlayerInteraction(this.type);
                            this.life = (int)((float)this.lifeMax * single110);
                            this.ai[0] = single111;
                            this.TargetClosest(true);
                            this.netUpdate = true;
                            this.whoAmI = num150;
                        }
                        if (this.type == 14 && (!Main.npc[(int)this.ai[0]].active || Main.npc[(int)this.ai[0]].aiStyle != this.aiStyle))
                        {
                            int num151 = this.whoAmI;
                            float single112 = (float)this.life / (float)this.lifeMax;
                            float single113 = this.ai[1];
                            this.SetDefaultsKeepPlayerInteraction(this.type);
                            this.life = (int)((float)this.lifeMax * single112);
                            this.ai[1] = single113;
                            this.TargetClosest(true);
                            this.netUpdate = true;
                            this.whoAmI = num151;
                        }
                    }
                    if (!this.active && Main.netMode == 2)
                    {
                        NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                    }
                }
                int x52 = (int)(this.position.X / 16f) - 1;
                int x53 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                int y48 = (int)(this.position.Y / 16f) - 1;
                int y49 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                if (x52 < 0)
                {
                    x52 = 0;
                }
                if (x53 > Main.maxTilesX)
                {
                    x53 = Main.maxTilesX;
                }
                if (y48 < 0)
                {
                    y48 = 0;
                }
                if (y49 > Main.maxTilesY)
                {
                    y49 = Main.maxTilesY;
                }
                bool flag38 = false;
                if (this.type >= 87 && this.type <= 92)
                {
                    flag38 = true;
                }
                if (this.type >= 454 && this.type <= 459)
                {
                    flag38 = true;
                }
                if (this.type == 402 && this.ai[1] == -1f)
                {
                    flag38 = true;
                }
                if (this.type >= 412 && this.type <= 414)
                {
                    flag38 = true;
                }
                if (!flag38)
                {
                    for (int e1 = x52; e1 < x53; e1++)
                    {
                        for (int f1 = y48; f1 < y49; f1++)
                        {
                            if (Main.tile[e1, f1] != null && (Main.tile[e1, f1].nactive() && (Main.tileSolid[Main.tile[e1, f1].type] || Main.tileSolidTop[Main.tile[e1, f1].type] && Main.tile[e1, f1].frameY == 0) || Main.tile[e1, f1].liquid > 64))
                            {
                                vector22.X = (float)(e1 * 16);
                                vector22.Y = (float)(f1 * 16);
                                if (this.position.X + (float)this.width > vector22.X && this.position.X < vector22.X + 16f && this.position.Y + (float)this.height > vector22.Y && this.position.Y < vector22.Y + 16f)
                                {
                                    flag38 = true;
                                    if (Main.rand.Next(100) == 0 && this.type != 117 && Main.tile[e1, f1].nactive())
                                    {
                                        WorldGen.KillTile(e1, f1, true, true, false);
                                    }
                                }
                            }
                        }
                    }
                }
                if (!flag38 && (this.type == 7 || this.type == 10 || this.type == 13 || this.type == 39 || this.type == 95 || this.type == 98 || this.type == 117 || this.type == 375 || this.type == 454 || this.type == 510 || this.type == 513))
                {
                    Rectangle rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                    int num152 = 1000;
                    bool flag39 = true;
                    for (int g1 = 0; g1 < 255; g1++)
                    {
                        if (Main.player[g1].active)
                        {
                            Rectangle rectangle1 = new Rectangle((int)Main.player[g1].position.X - num152, (int)Main.player[g1].position.Y - num152, num152 * 2, num152 * 2);
                            if (rectangle.Intersects(rectangle1))
                            {
                                flag39 = false;
                                break;
                            }
                        }
                    }
                    if (flag39)
                    {
                        flag38 = true;
                    }
                }
                if (this.type >= 87 && this.type <= 92 || this.type >= 454 && this.type <= 459)
                {
                    if (this.velocity.X < 0f)
                    {
                        this.spriteDirection = 1;
                    }
                    else if (this.velocity.X > 0f)
                    {
                        this.spriteDirection = -1;
                    }
                }
                if (this.type == 414)
                {
                    if (this.justHit)
                    {
                        this.localAI[3] = 3f;
                    }
                    if (this.localAI[2] > 0f)
                    {
                        this.localAI[2] = this.localAI[2] - 16f;
                        if (this.localAI[2] == 0f)
                        {
                            this.localAI[2] = -128f;
                        }
                    }
                    else if (this.localAI[2] < 0f)
                    {
                        this.localAI[2] = this.localAI[2] + 16f;
                    }
                    else if (this.localAI[3] > 0f)
                    {
                        this.localAI[2] = 128f;
                        this.localAI[3] = this.localAI[3] - 1f;
                    }
                }
                float single114 = 8f;
                float single115 = 0.07f;
                if (this.type == 95)
                {
                    single114 = 5.5f;
                    single115 = 0.045f;
                }
                if (this.type == 10)
                {
                    single114 = 6f;
                    single115 = 0.05f;
                }
                if (this.type == 513)
                {
                    single114 = 7f;
                    single115 = 0.03f;
                }
                if (this.type == 13)
                {
                    single114 = 10f;
                    single115 = 0.07f;
                    if (Main.expertMode)
                    {
                        single114 = 12f;
                        single115 = 0.15f;
                    }
                }
                if (this.type == 510)
                {
                    single114 = 10f;
                    single115 = 0.25f;
                }
                if (this.type == 87)
                {
                    single114 = 11f;
                    single115 = 0.25f;
                }
                if (this.type == 375)
                {
                    single114 = 6f;
                    single115 = 0.15f;
                }
                if (this.type == 454)
                {
                    single114 = 20f;
                    single115 = 0.55f;
                }
                if (this.type == 402)
                {
                    single114 = 6f;
                    single115 = 0.2f;
                }
                if (this.type == 117 && Main.wof >= 0)
                {
                    float single116 = (float)((float)Main.npc[Main.wof].life / (float)Main.npc[Main.wof].lifeMax);
                    if ((double)single116 < 0.5)
                    {
                        single114 = single114 + 1f;
                        single115 = single115 + 0.1f;
                    }
                    if ((double)single116 < 0.25)
                    {
                        single114 = single114 + 1f;
                        single115 = single115 + 0.1f;
                    }
                    if ((double)single116 < 0.1)
                    {
                        single114 = single114 + 2f;
                        single115 = single115 + 0.1f;
                    }
                }
                Vector2 y50 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float x54 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                float y51 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                if (this.type == 412)
                {
                    single114 = 10f;
                    single115 = 0.3f;
                    int num153 = -1;
                    int x55 = (int)(Main.player[this.target].Center.X / 16f);
                    int y52 = (int)(Main.player[this.target].Center.Y / 16f);
                    for (int h1 = x55 - 2; h1 <= x55 + 2; h1++)
                    {
                        int num154 = y52;
                        while (num154 <= y52 + 15)
                        {
                            if (!WorldGen.SolidTile2(h1, num154))
                            {
                                num154++;
                            }
                            else
                            {
                                num153 = num154;
                                break;
                            }
                        }
                        if (num153 > 0)
                        {
                            break;
                        }
                    }
                    if (num153 <= 0)
                    {
                        single114 = 14f;
                        single115 = 0.5f;
                    }
                    else
                    {
                        num153 = num153 * 16;
                        float single117 = (float)(num153 - 800);
                        if (Main.player[this.target].position.Y > single117)
                        {
                            y51 = single117;
                            if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 500f)
                            {
                                x54 = (this.velocity.X <= 0f ? Main.player[this.target].Center.X - 600f : Main.player[this.target].Center.X + 600f);
                            }
                        }
                    }
                    float single118 = single114 * 1.3f;
                    float single119 = single114 * 0.7f;
                    float single120 = this.velocity.Length();
                    if (single120 > 0f)
                    {
                        if (single120 > single118)
                        {
                            this.velocity.Normalize();
                            NPC nPC45 = this;
                            nPC45.velocity = nPC45.velocity * single118;
                        }
                        else if (single120 < single119)
                        {
                            this.velocity.Normalize();
                            NPC nPC46 = this;
                            nPC46.velocity = nPC46.velocity * single119;
                        }
                    }
                    if (num153 <= 0)
                    {
                        for (int i2 = 0; i2 < 200; i2++)
                        {
                            if (Main.npc[i2].active && Main.npc[i2].type == this.type && i2 != this.whoAmI)
                            {
                                Vector2 center19 = Main.npc[i2].Center - base.Center;
                                if (center19.Length() < 60f)
                                {
                                    center19.Normalize();
                                    center19 = center19 * 200f;
                                    x54 = x54 - center19.X;
                                    y51 = y51 - center19.Y;
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int j2 = 0; j2 < 200; j2++)
                        {
                            if (Main.npc[j2].active && Main.npc[j2].type == this.type && j2 != this.whoAmI)
                            {
                                Vector2 center20 = Main.npc[j2].Center - base.Center;
                                if (center20.Length() < 400f)
                                {
                                    center20.Normalize();
                                    center20 = center20 * 1000f;
                                    x54 = x54 - center20.X;
                                    y51 = y51 - center20.Y;
                                }
                            }
                        }
                    }
                }
                x54 = (float)((int)(x54 / 16f) * 16);
                y51 = (float)((int)(y51 / 16f) * 16);
                y50.X = (float)((int)(y50.X / 16f) * 16);
                y50.Y = (float)((int)(y50.Y / 16f) * 16);
                x54 = x54 - y50.X;
                y51 = y51 - y50.Y;
                if (this.type == 375)
                {
                    x54 = x54 * -1f;
                    y51 = y51 * -1f;
                }
                float single121 = (float)Math.Sqrt((double)(x54 * x54 + y51 * y51));
                if (this.ai[1] <= 0f || this.ai[1] >= (float)((int)Main.npc.Length))
                {
                    if (flag38)
                    {
                        single121 = (float)Math.Sqrt((double)(x54 * x54 + y51 * y51));
                        float single123 = Math.Abs(x54);
                        float single124 = Math.Abs(y51);
                        float single125 = single114 / single121;
                        x54 = x54 * single125;
                        y51 = y51 * single125;
                        bool flag40 = false;
                        if ((this.type == 7 || this.type == 13) && !Main.player[this.target].ZoneCorrupt && !Main.player[this.target].ZoneCrimson)
                        {
                            flag40 = true;
                        }
                        if (this.type == 513 && (double)Main.player[this.target].position.Y < Main.worldSurface * 16)
                        {
                            flag40 = true;
                        }
                        if (this.type == 510 && (double)Main.player[this.target].position.Y < Main.worldSurface * 16)
                        {
                            flag40 = true;
                        }
                        if (flag40)
                        {
                            bool flag41 = true;
                            for (int k2 = 0; k2 < 255; k2++)
                            {
                                if (Main.player[k2].active && !Main.player[k2].dead && Main.player[k2].ZoneCorrupt)
                                {
                                    flag41 = false;
                                }
                            }
                            if (flag41)
                            {
                                if (Main.netMode != 1 && (double)(this.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2)
                                {
                                    this.active = false;
                                    for (int l2 = (int)this.ai[0]; l2 > 0 && l2 < 200 && Main.npc[l2].active && Main.npc[l2].aiStyle == this.aiStyle; l2 = num)
                                    {
                                        num = (int)Main.npc[l2].ai[0];
                                        Main.npc[l2].active = false;
                                        this.life = 0;
                                        if (Main.netMode == 2)
                                        {
                                            NetMessage.SendData(23, -1, -1, "", l2, 0f, 0f, 0f, 0, 0, 0);
                                        }
                                    }
                                    if (Main.netMode == 2)
                                    {
                                        NetMessage.SendData(23, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                }
                                x54 = 0f;
                                y51 = single114;
                            }
                        }
                        bool flag42 = false;
                        if (this.type == 87)
                        {
                            if ((this.velocity.X > 0f && x54 < 0f || this.velocity.X < 0f && x54 > 0f || this.velocity.Y > 0f && y51 < 0f || this.velocity.Y < 0f && y51 > 0f) && Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) > single115 / 2f && single121 < 300f)
                            {
                                flag42 = true;
                                if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < single114)
                                {
                                    NPC nPC47 = this;
                                    nPC47.velocity = nPC47.velocity * 1.1f;
                                }
                            }
                            if (this.position.Y > Main.player[this.target].position.Y || (double)(Main.player[this.target].position.Y / 16f) > Main.worldSurface || Main.player[this.target].dead)
                            {
                                flag42 = true;
                                if (Math.Abs(this.velocity.X) < single114 / 2f)
                                {
                                    if (this.velocity.X == 0f)
                                    {
                                        this.velocity.X = this.velocity.X - (float)this.direction;
                                    }
                                    this.velocity.X = this.velocity.X * 1.1f;
                                }
                                else if (this.velocity.Y > -single114)
                                {
                                    this.velocity.Y = this.velocity.Y - single115;
                                }
                            }
                        }
                        if (this.type == 454)
                        {
                            if ((this.velocity.X > 0f && x54 < 0f || this.velocity.X < 0f && x54 > 0f || this.velocity.Y > 0f && y51 < 0f || this.velocity.Y < 0f && y51 > 0f) && Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) > single115 / 2f && single121 < 300f)
                            {
                                flag42 = true;
                                if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < single114)
                                {
                                    NPC nPC48 = this;
                                    nPC48.velocity = nPC48.velocity * 1.1f;
                                }
                            }
                            if (this.position.Y > Main.player[this.target].position.Y || Main.player[this.target].dead)
                            {
                                flag42 = true;
                                if (Math.Abs(this.velocity.X) < single114 / 2f)
                                {
                                    if (this.velocity.X == 0f)
                                    {
                                        this.velocity.X = this.velocity.X - (float)this.direction;
                                    }
                                    this.velocity.X = this.velocity.X * 1.1f;
                                }
                                else if (this.velocity.Y > -single114)
                                {
                                    this.velocity.Y = this.velocity.Y - single115;
                                }
                            }
                        }
                        if (!flag42)
                        {
                            if (this.velocity.X > 0f && x54 > 0f || this.velocity.X < 0f && x54 < 0f || this.velocity.Y > 0f && y51 > 0f || this.velocity.Y < 0f && y51 < 0f)
                            {
                                if (this.velocity.X < x54)
                                {
                                    this.velocity.X = this.velocity.X + single115;
                                }
                                else if (this.velocity.X > x54)
                                {
                                    this.velocity.X = this.velocity.X - single115;
                                }
                                if (this.velocity.Y < y51)
                                {
                                    this.velocity.Y = this.velocity.Y + single115;
                                }
                                else if (this.velocity.Y > y51)
                                {
                                    this.velocity.Y = this.velocity.Y - single115;
                                }
                                if ((double)Math.Abs(y51) < (double)single114 * 0.2 && (this.velocity.X > 0f && x54 < 0f || this.velocity.X < 0f && x54 > 0f))
                                {
                                    if (this.velocity.Y <= 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single115 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + single115 * 2f;
                                    }
                                }
                                if ((double)Math.Abs(x54) < (double)single114 * 0.2 && (this.velocity.Y > 0f && y51 < 0f || this.velocity.Y < 0f && y51 > 0f))
                                {
                                    if (this.velocity.X <= 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single115 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X + single115 * 2f;
                                    }
                                }
                            }
                            else if (single123 <= single124)
                            {
                                if (this.velocity.Y < y51)
                                {
                                    this.velocity.Y = this.velocity.Y + single115 * 1.1f;
                                }
                                else if (this.velocity.Y > y51)
                                {
                                    this.velocity.Y = this.velocity.Y - single115 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)single114 * 0.5)
                                {
                                    if (this.velocity.X <= 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single115;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X + single115;
                                    }
                                }
                            }
                            else
                            {
                                if (this.velocity.X < x54)
                                {
                                    this.velocity.X = this.velocity.X + single115 * 1.1f;
                                }
                                else if (this.velocity.X > x54)
                                {
                                    this.velocity.X = this.velocity.X - single115 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)single114 * 0.5)
                                {
                                    if (this.velocity.Y <= 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single115;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + single115;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.TargetClosest(true);
                        this.velocity.Y = this.velocity.Y + 0.11f;
                        if (this.velocity.Y > single114)
                        {
                            this.velocity.Y = single114;
                        }
                        if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)single114 * 0.4)
                        {
                            if (this.velocity.X >= 0f)
                            {
                                this.velocity.X = this.velocity.X + single115 * 1.1f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X - single115 * 1.1f;
                            }
                        }
                        else if (this.velocity.Y != single114)
                        {
                            if (this.velocity.Y > 4f)
                            {
                                if (this.velocity.X >= 0f)
                                {
                                    this.velocity.X = this.velocity.X - single115 * 0.9f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X + single115 * 0.9f;
                                }
                            }
                        }
                        else if (this.velocity.X < x54)
                        {
                            this.velocity.X = this.velocity.X + single115;
                        }
                        else if (this.velocity.X > x54)
                        {
                            this.velocity.X = this.velocity.X - single115;
                        }
                    }
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    if (this.type == 7 || this.type == 10 || this.type == 13 || this.type == 39 || this.type == 95 || this.type == 98 || this.type == 117 || this.type == 510 || this.type == 513)
                    {
                        if (!flag38)
                        {
                            if (this.localAI[0] != 0f)
                            {
                                this.netUpdate = true;
                            }
                            this.localAI[0] = 0f;
                        }
                        else
                        {
                            if (this.localAI[0] != 1f)
                            {
                                this.netUpdate = true;
                            }
                            this.localAI[0] = 1f;
                        }
                        if ((this.velocity.X > 0f && this.oldVelocity.X < 0f || this.velocity.X < 0f && this.oldVelocity.X > 0f || this.velocity.Y > 0f && this.oldVelocity.Y < 0f || this.velocity.Y < 0f && this.oldVelocity.Y > 0f) && !this.justHit)
                        {
                            this.netUpdate = true;
                        }
                    }
                    if (this.type == 454)
                    {
                        float single126 = Vector2.Distance(Main.player[this.target].Center, base.Center);
                        int num155 = 0;
                        if (Vector2.Normalize(Main.player[this.target].Center - base.Center).ToRotation().AngleTowards(this.velocity.ToRotation(), 1.57079637f) == this.velocity.ToRotation() && single126 < 350f)
                        {
                            num155 = 4;
                        }
                        if ((double)num155 > this.frameCounter)
                        {
                            NPC nPC49 = this;
                            nPC49.frameCounter = nPC49.frameCounter + 1;
                        }
                        if ((double)num155 < this.frameCounter)
                        {
                            NPC nPC50 = this;
                            nPC50.frameCounter = nPC50.frameCounter - 1;
                        }
                        if (this.frameCounter < 0)
                        {
                            this.frameCounter = 0;
                        }
                        if (this.frameCounter > 4)
                        {
                            this.frameCounter = 4;
                            return;
                        }
                    }
                }
                else
                {
                    try
                    {
                        y50 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        x54 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - y50.X;
                        y51 = Main.npc[(int)this.ai[1]].position.Y + (float)(Main.npc[(int)this.ai[1]].height / 2) - y50.Y;
                    }
                    catch (Exception ex)
                    {
            #if DEBUG
                        Console.WriteLine(ex);
                        System.Diagnostics.Debugger.Break();

            #endif
                    }
                    this.rotation = (float)Math.Atan2((double)y51, (double)x54) + 1.57f;
                    single121 = (float)Math.Sqrt((double)(x54 * x54 + y51 * y51));
                    int num156 = this.width;
                    if (this.type >= 87 && this.type <= 92)
                    {
                        num156 = 42;
                    }
                    if (this.type >= 454 && this.type <= 459)
                    {
                        num156 = 36;
                    }
                    if (this.type >= 13 && this.type <= 15)
                    {
                        num156 = (int)((float)num156 * this.scale);
                    }
                    if (this.type >= 412 && this.type <= 414)
                    {
                        num156 = num156 + 6;
                    }
                    single121 = (single121 - (float)num156) / single121;
                    x54 = x54 * single121;
                    y51 = y51 * single121;
                    this.velocity = Vector2.Zero;
                    this.position.X = this.position.X + x54;
                    this.position.Y = this.position.Y + y51;
                    if (this.type >= 87 && this.type <= 92)
                    {
                        if (x54 < 0f)
                        {
                            this.spriteDirection = 1;
                        }
                        else if (x54 > 0f)
                        {
                            this.spriteDirection = -1;
                        }
                    }
                    if (this.type >= 454 && this.type <= 459)
                    {
                        if (x54 < 0f)
                        {
                            this.spriteDirection = 1;
                            return;
                        }
                        if (x54 > 0f)
                        {
                            this.spriteDirection = -1;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 7)
            {
                bool flag43 = Main.raining;
                if (!Main.dayTime)
                {
                    flag43 = true;
                }
                if (Main.eclipse)
                {
                    flag43 = true;
                }
                if (Main.slimeRain)
                {
                    flag43 = true;
                }
                if (!Main.expertMode)
                {
                    this.defense = (this.dryadWard ? this.defDefense : this.defDefense + 6);
                }
                else
                {
                    this.defense = (this.dryadWard ? this.defDefense : this.defDefense + 10);
                }
                float single127 = 1f;
                if (this.townNPC || this.type == 453)
                {
                    if (NPC.downedBoss1)
                    {
                        single127 = single127 + 0.1f;
                        NPC nPC51 = this;
                        nPC51.defense = nPC51.defense + 3;
                    }
                    if (NPC.downedBoss2)
                    {
                        single127 = single127 + 0.1f;
                        NPC nPC52 = this;
                        nPC52.defense = nPC52.defense + 3;
                    }
                    if (NPC.downedBoss3)
                    {
                        single127 = single127 + 0.1f;
                        NPC nPC53 = this;
                        nPC53.defense = nPC53.defense + 3;
                    }
                    if (NPC.downedQueenBee)
                    {
                        single127 = single127 + 0.1f;
                        NPC nPC54 = this;
                        nPC54.defense = nPC54.defense + 3;
                    }
                    if (Main.hardMode)
                    {
                        single127 = single127 + 0.4f;
                        NPC nPC55 = this;
                        nPC55.defense = nPC55.defense + 12;
                    }
                    if (NPC.downedMechBoss1)
                    {
                        single127 = single127 + 0.15f;
                        NPC nPC56 = this;
                        nPC56.defense = nPC56.defense + 6;
                    }
                    if (NPC.downedMechBoss2)
                    {
                        single127 = single127 + 0.15f;
                        NPC nPC57 = this;
                        nPC57.defense = nPC57.defense + 6;
                    }
                    if (NPC.downedMechBoss3)
                    {
                        single127 = single127 + 0.15f;
                        NPC nPC58 = this;
                        nPC58.defense = nPC58.defense + 6;
                    }
                    if (NPC.downedPlantBoss)
                    {
                        single127 = single127 + 0.15f;
                        NPC nPC59 = this;
                        nPC59.defense = nPC59.defense + 8;
                    }
                    if (NPC.downedGolemBoss)
                    {
                        single127 = single127 + 0.15f;
                        NPC nPC60 = this;
                        nPC60.defense = nPC60.defense + 8;
                    }
                    if (NPC.downedAncientCultist)
                    {
                        single127 = single127 + 0.15f;
                        NPC nPC61 = this;
                        nPC61.defense = nPC61.defense + 8;
                    }
                }
                if (this.type == 142 && Main.netMode != 1 && !Main.xMas)
                {
                    this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData(28, -1, -1, "", this.whoAmI, 9999f, 0f, 0f, 0, 0, 0);
                    }
                }
                if ((this.type == 148 || this.type == 149) && this.localAI[0] == 0f)
                {
                    this.localAI[0] = (float)Main.rand.Next(1, 5);
                }
                if (this.type == 124)
                {
                    bool flag44 = false;
                    int num157 = 0;
                    while (num157 < 1000)
                    {
                        if (!Main.projectile[num157].active || Main.projectile[num157].type != 582 || Main.projectile[num157].ai[1] != (float)this.whoAmI)
                        {
                            num157++;
                        }
                        else
                        {
                            flag44 = true;
                            break;
                        }
                    }
                    this.localAI[0] = (float)flag44.ToInt();
                }
                if ((this.type == 362 || this.type == 364) && Main.netMode != 1 && (this.velocity.Y > 4f || this.velocity.Y < -4f || this.wet))
                {
                    int num158 = this.direction;
                    this.Transform(this.type + 1);
                    this.TargetClosest(true);
                    this.direction = num158;
                    this.netUpdate = true;
                    return;
                }
                num6 = this.type;
                if (num6 <= 124)
                {
                    switch (num6)
                    {
                        case 107:
                        {
                            NPC.savedGoblin = true;
                            break;
                        }
                        case 108:
                        {
                            NPC.savedWizard = true;
                            break;
                        }
                        default:
                        {
                            if (num6 == 124)
                            {
                                NPC.savedMech = true;
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
                else if (num6 == 353)
                {
                    NPC.savedStylist = true;
                }
                else if (num6 == 369)
                {
                    NPC.savedAngler = true;
                }
                else if (num6 == 441)
                {
                    NPC.savedTaxCollector = true;
                }
                if (this.type >= 0 && this.type < 540 && NPCID.Sets.TownCritter[this.type] && this.target == 255)
                {
                    this.TargetClosest(true);
                    if (this.position.X < Main.player[this.target].position.X)
                    {
                        this.direction = 1;
                        this.spriteDirection = this.direction;
                    }
                    if (this.position.X > Main.player[this.target].position.X)
                    {
                        this.direction = -1;
                        this.spriteDirection = this.direction;
                    }
                    if (this.homeTileX == -1)
                    {
                        this.homeTileX = (int)((this.position.X + (float)(this.width / 2)) / 16f);
                    }
                }
                else if (this.homeTileX == -1 && this.homeTileY == -1 && this.velocity.Y == 0f)
                {
                    this.homeTileX = (int)base.Center.X / 16;
                    this.homeTileY = (int)(this.position.Y + (float)this.height + 4f) / 16;
                }
                bool flag45 = false;
                int num159 = this.homeTileY;
                if (this.type == 441)
                {
                    NPC.taxCollector = true;
                }
                this.directionY = -1;
                if (this.direction == 0)
                {
                    this.direction = 1;
                }
                for (int m2 = 0; m2 < 255; m2++)
                {
                    if (Main.player[m2].active && Main.player[m2].talkNPC == this.whoAmI)
                    {
                        flag45 = true;
                        if (this.ai[0] != 0f)
                        {
                            this.netUpdate = true;
                        }
                        this.ai[0] = 0f;
                        this.ai[1] = 300f;
                        this.localAI[3] = 100f;
                        if (Main.player[m2].position.X + (float)(Main.player[m2].width / 2) >= this.position.X + (float)(this.width / 2))
                        {
                            this.direction = 1;
                        }
                        else
                        {
                            this.direction = -1;
                        }
                    }
                }
                if (this.ai[3] == 1f)
                {
                    this.life = -1;
                    this.HitEffect(0, 10);
                    this.active = false;
                    this.netUpdate = true;
                    return;
                }
                if (this.type == 37 && Main.netMode != 1)
                {
                    this.homeless = false;
                    this.homeTileX = Main.dungeonX;
                    this.homeTileY = Main.dungeonY;
                    if (NPC.downedBoss3)
                    {
                        this.ai[3] = 1f;
                        this.netUpdate = true;
                    }
                }
                if (Main.netMode != 1 && this.homeTileY > 0)
                {
                    while (!WorldGen.SolidTile(this.homeTileX, num159) && num159 < Main.maxTilesY - 20)
                    {
                        num159++;
                    }
                }
                if (this.type == 368)
                {
                    this.homeless = true;
                    if (!Main.dayTime)
                    {
                        this.homeTileX = (int)(base.Center.X / 16f);
                        this.homeTileY = (int)(this.position.Y + (float)this.height + 2f) / 16;
                        if (!flag45)
                        {
                            this.ai[0] = 1f;
                            this.ai[1] = 200f;
                        }
                        flag43 = false;
                    }
                }
                if (this.type == 369 && this.homeless && this.wet)
                {
                    if (base.Center.X / 16f < 380f || base.Center.X / 16f > (float)(Main.maxTilesX - 380))
                    {
                        this.homeTileX = Main.spawnTileX;
                        this.homeTileY = Main.spawnTileY;
                        this.ai[0] = 1f;
                        this.ai[1] = 200f;
                    }
                    if (this.position.X / 16f < 200f)
                    {
                        this.direction = 1;
                    }
                    else if (this.position.X / 16f > (float)(Main.maxTilesX - 200))
                    {
                        this.direction = -1;
                    }
                }
                int x56 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                int y53 = (int)(this.position.Y + (float)this.height + 1f) / 16;
                if (!WorldGen.InWorld(x56, y53, 0) || Main.tile[x56, y53] == null)
                {
                    return;
                }
                if (!this.homeless && Main.netMode != 1 && this.townNPC && (flag43 || Main.tileDungeon[Main.tile[x56, y53].type]) && (x56 != this.homeTileX || y53 != num159))
                {
                    bool flag46 = true;
                    for (int n2 = 0; n2 < 2; n2++)
                    {
                        Rectangle rectangle2 = new Rectangle((int)(this.position.X + (float)(this.width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(this.position.Y + (float)(this.height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
                        if (n2 == 1)
                        {
                            rectangle2 = new Rectangle(this.homeTileX * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, num159 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
                        }
                        for (int o2 = 0; o2 < 255; o2++)
                        {
                            if (Main.player[o2].active)
                            {
                                Rectangle rectangle3 = new Rectangle((int)Main.player[o2].position.X, (int)Main.player[o2].position.Y, Main.player[o2].width, Main.player[o2].height);
                                if (rectangle3.Intersects(rectangle2))
                                {
                                    flag46 = false;
                                    break;
                                }
                            }
                            if (!flag46)
                            {
                                break;
                            }
                        }
                    }
                    if (flag46)
                    {
                        if (this.type == 37 || !Collision.SolidTiles(this.homeTileX - 1, this.homeTileX + 1, num159 - 3, num159 - 1))
                        {
                            this.velocity.X = 0f;
                            this.velocity.Y = 0f;
                            this.position.X = (float)(this.homeTileX * 16 + 8 - this.width / 2);
                            this.position.Y = (float)(num159 * 16 - this.height) - 0.1f;
                            this.netUpdate = true;
                        }
                        else
                        {
                            this.homeless = true;
                            WorldGen.QuickFindHome(this.whoAmI);
                        }
                    }
                }
                bool flag47 = (this.type == 300 ? true : this.type == 447);
                float dangerDetectRange = 200f;
                if (NPCID.Sets.DangerDetectRange[this.type] != -1)
                {
                    dangerDetectRange = (float)NPCID.Sets.DangerDetectRange[this.type];
                }
                bool flag48 = false;
                bool flag49 = false;
                float single128 = -1f;
                float single129 = -1f;
                int num160 = 0;
                int num161 = -1;
                int num162 = -1;
                if (Main.netMode != 1 && !flag45)
                {
                    for (int p2 = 0; p2 < 200; p2++)
                    {
                        if (Main.npc[p2].active && !Main.npc[p2].friendly && Main.npc[p2].damage > 0 && Main.npc[p2].Distance(base.Center) < dangerDetectRange && (this.type != 453 || !NPCID.Sets.Skeletons.Contains(Main.npc[p2].netID)))
                        {
                            flag48 = true;
                            float x57 = Main.npc[p2].Center.X - base.Center.X;
                            if (x57 < 0f && (single128 == -1f || x57 > single128))
                            {
                                single128 = x57;
                                num161 = p2;
                            }
                            if (x57 > 0f && (single129 == -1f || x57 < single129))
                            {
                                single129 = x57;
                                num162 = p2;
                            }
                        }
                    }
                    if (flag48)
                    {
                        if (single128 != -1f)
                        {
                            num160 = (single129 != -1f ? (single129 < -single128).ToDirectionInt() : -1);
                        }
                        else
                        {
                            num160 = 1;
                        }
                        float single130 = 0f;
                        if (single128 != -1f)
                        {
                            single130 = -single128;
                        }
                        if (single130 == 0f || single129 < single130 && single129 > 0f)
                        {
                            single130 = single129;
                        }
                        if (this.ai[0] == 8f)
                        {
                            if (this.direction == -num160)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = (float)(300 + Main.rand.Next(300));
                                this.ai[2] = 0f;
                                this.localAI[3] = 0f;
                                this.netUpdate = true;
                            }
                        }
                        else if (this.ai[0] != 10f && this.ai[0] != 12f && this.ai[0] != 13f && this.ai[0] != 14f && this.ai[0] != 15f)
                        {
                            if (NPCID.Sets.PrettySafe[this.type] != -1 && (float)NPCID.Sets.PrettySafe[this.type] < single130)
                            {
                                flag48 = false;
                                flag49 = true;
                            }
                            else if (this.ai[0] != 1f)
                            {
                                if ((this.ai[0] == 3f || this.ai[0] == 4f || this.ai[0] == 16f ? true : this.ai[0] == 17f))
                                {
                                    NPC nPC62 = Main.npc[(int)this.ai[2]];
                                    if (nPC62.active)
                                    {
                                        nPC62.ai[0] = 1f;
                                        nPC62.ai[1] = (float)(120 + Main.rand.Next(120));
                                        nPC62.ai[2] = 0f;
                                        nPC62.localAI[3] = 0f;
                                        nPC62.direction = -num160;
                                        nPC62.netUpdate = true;
                                    }
                                }
                                this.ai[0] = 1f;
                                this.ai[1] = (float)(120 + Main.rand.Next(120));
                                this.ai[2] = 0f;
                                this.localAI[3] = 0f;
                                this.direction = -num160;
                                this.netUpdate = true;
                            }
                            else if (this.ai[0] == 1f && this.direction != -num160)
                            {
                                this.direction = -num160;
                                this.netUpdate = true;
                            }
                        }
                    }
                }
                if (this.ai[0] == 0f)
                {
                    if (this.localAI[3] > 0f)
                    {
                        this.localAI[3] = this.localAI[3] - 1f;
                    }
                    if (!flag43 || flag45 || NPCID.Sets.TownCritter[this.type])
                    {
                        if (flag47)
                        {
                            this.velocity.X = this.velocity.X * 0.5f;
                        }
                        if (this.velocity.X > 0.1f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X >= -0.1f)
                        {
                            this.velocity.X = 0f;
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        if (Main.netMode != 1)
                        {
                            if (this.ai[1] > 0f)
                            {
                                this.ai[1] = this.ai[1] - 1f;
                            }
                            if (this.ai[1] <= 0f)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = (float)(200 + Main.rand.Next(300));
                                this.ai[2] = 0f;
                                if (NPCID.Sets.TownCritter[this.type])
                                {
                                    this.ai[1] = this.ai[1] + (float)Main.rand.Next(200, 400);
                                }
                                this.localAI[3] = 0f;
                                this.netUpdate = true;
                            }
                        }
                    }
                    else if (Main.netMode != 1)
                    {
                        if (x56 != this.homeTileX || y53 != num159)
                        {
                            if (x56 <= this.homeTileX)
                            {
                                this.direction = 1;
                            }
                            else
                            {
                                this.direction = -1;
                            }
                            this.ai[0] = 1f;
                            this.ai[1] = (float)(200 + Main.rand.Next(200));
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.netUpdate = true;
                        }
                        else
                        {
                            if (this.velocity.X != 0f)
                            {
                                this.netUpdate = true;
                            }
                            if (this.velocity.X > 0.1f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (this.velocity.X >= -0.1f)
                            {
                                this.velocity.X = 0f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                        }
                    }
                    if (Main.netMode != 1 && (!flag43 || x56 == this.homeTileX && y53 == num159))
                    {
                        if (x56 >= this.homeTileX - 25 && x56 <= this.homeTileX + 25)
                        {
                            if (Main.rand.Next(80) == 0 && this.localAI[3] == 0f)
                            {
                                this.localAI[3] = 200f;
                                NPC nPC63 = this;
                                nPC63.direction = nPC63.direction * -1;
                                this.netUpdate = true;
                            }
                        }
                        else if (this.localAI[3] == 0f)
                        {
                            if (x56 < this.homeTileX - 50 && this.direction == -1)
                            {
                                this.direction = 1;
                                this.netUpdate = true;
                            }
                            else if (x56 > this.homeTileX + 50 && this.direction == 1)
                            {
                                this.direction = -1;
                                this.netUpdate = true;
                            }
                        }
                    }
                }
                else if (this.ai[0] == 1f)
                {
                    if (Main.netMode == 1 || !flag43 || x56 != this.homeTileX || y53 != this.homeTileY || NPCID.Sets.TownCritter[this.type])
                    {
                        bool flag50 = Collision.DrownCollision(this.position, this.width, this.height, 1f);
                        if (!flag50)
                        {
                            if (Main.netMode != 1 && !this.homeless && !Main.tileDungeon[Main.tile[x56, y53].type] && (x56 < this.homeTileX - 35 || x56 > this.homeTileX + 35))
                            {
                                if (this.position.X < (float)(this.homeTileX * 16) && this.direction == -1)
                                {
                                    this.ai[1] = this.ai[1] - 5f;
                                }
                                else if (this.position.X > (float)(this.homeTileX * 16) && this.direction == 1)
                                {
                                    this.ai[1] = this.ai[1] - 5f;
                                }
                            }
                            this.ai[1] = this.ai[1] - 1f;
                        }
                        if (this.ai[1] <= 0f)
                        {
                            this.ai[0] = 0f;
                            this.ai[1] = (float)(300 + Main.rand.Next(300));
                            this.ai[2] = 0f;
                            if (!NPCID.Sets.TownCritter[this.type])
                            {
                                this.ai[1] = this.ai[1] + (float)Main.rand.Next(900);
                            }
                            else
                            {
                                this.ai[1] = this.ai[1] - (float)Main.rand.Next(100);
                            }
                            this.localAI[3] = 60f;
                            this.netUpdate = true;
                        }
                        if (this.closeDoor && ((this.position.X + (float)(this.width / 2)) / 16f > (float)(this.doorX + 2) || (this.position.X + (float)(this.width / 2)) / 16f < (float)(this.doorX - 2)))
                        {
                            Tile tileSafely = Framing.GetTileSafely(this.doorX, this.doorY);
                            if (tileSafely.type == 11)
                            {
                                if (WorldGen.CloseDoor(this.doorX, this.doorY, false))
                                {
                                    this.closeDoor = false;
                                    NetMessage.SendData(19, -1, -1, "", 1, (float)this.doorX, (float)this.doorY, (float)this.direction, 0, 0, 0);
                                }
                                if ((this.position.X + (float)(this.width / 2)) / 16f > (float)(this.doorX + 4) || (this.position.X + (float)(this.width / 2)) / 16f < (float)(this.doorX - 4) || (this.position.Y + (float)(this.height / 2)) / 16f > (float)(this.doorY + 4) || (this.position.Y + (float)(this.height / 2)) / 16f < (float)(this.doorY - 4))
                                {
                                    this.closeDoor = false;
                                }
                            }
                            else if (tileSafely.type != 389)
                            {
                                this.closeDoor = false;
                            }
                            else
                            {
                                if (WorldGen.ShiftTallGate(this.doorX, this.doorY, true))
                                {
                                    this.closeDoor = false;
                                    NetMessage.SendData(19, -1, -1, "", 5, (float)this.doorX, (float)this.doorY, 0f, 0, 0, 0);
                                }
                                if ((this.position.X + (float)(this.width / 2)) / 16f > (float)(this.doorX + 4) || (this.position.X + (float)(this.width / 2)) / 16f < (float)(this.doorX - 4) || (this.position.Y + (float)(this.height / 2)) / 16f > (float)(this.doorY + 4) || (this.position.Y + (float)(this.height / 2)) / 16f < (float)(this.doorY - 4))
                                {
                                    this.closeDoor = false;
                                }
                            }
                        }
                        float single131 = 1f;
                        float single132 = 0.07f;
                        if (this.type == 299 || this.type == 539 || this.type == 538)
                        {
                            single131 = 1.5f;
                        }
                        if (flag47)
                        {
                            single131 = 2f;
                            single132 = 1f;
                        }
                        if (this.friendly && (flag48 || flag50))
                        {
                            single131 = 1.5f;
                            float single133 = 1f - (float)this.life / (float)this.lifeMax;
                            single131 = single131 + single133 * 0.9f;
                            single132 = 0.1f;
                        }
                        if (this.velocity.X < -single131 || this.velocity.X > single131)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                NPC nPC64 = this;
                                nPC64.velocity = nPC64.velocity * 0.8f;
                            }
                        }
                        else if (this.velocity.X < single131 && this.direction == 1)
                        {
                            this.velocity.X = this.velocity.X + single132;
                            if (this.velocity.X > single131)
                            {
                                this.velocity.X = single131;
                            }
                        }
                        else if (this.velocity.X > -single131 && this.direction == -1)
                        {
                            this.velocity.X = this.velocity.X - single132;
                            if (this.velocity.X > single131)
                            {
                                this.velocity.X = single131;
                            }
                        }
                        bool flag51 = true;
                        if ((float)(this.homeTileY * 16 - 32) > this.position.Y)
                        {
                            flag51 = false;
                        }
                        if (this.direction == 1 && this.position.Y + (float)(this.width / 2) > (float)(this.homeTileX * 16) || this.direction == -1 && this.position.Y + (float)(this.width / 2) < (float)(this.homeTileX * 16))
                        {
                            flag51 = true;
                        }
                        if (this.velocity.Y == 0f)
                        {
                            Collision.StepDown(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, 1, false);
                        }
                        if (this.velocity.Y >= 0f)
                        {
                            Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, 1, flag51, 1);
                        }
                        if (this.velocity.Y == 0f)
                        {
                            int x58 = (int)((this.position.X + (float)(this.width / 2) + (float)(15 * this.direction)) / 16f);
                            int y54 = (int)((this.position.Y + (float)this.height - 16f) / 16f);
                            bool flag52 = false;
                            bool flag53 = true;
                            if (this.townNPC && this.ai[1] < 30f)
                            {
                                flag52 = !Utils.PlotTileLine(base.Top, base.Bottom, (float)this.width, new Utils.PerLinePoint(DelegateMethods.SearchAvoidedByNPCs));
                                if (!flag52)
                                {
                                    Rectangle hitbox = base.Hitbox;
                                    hitbox.X = hitbox.X - 20;
                                    hitbox.Width = hitbox.Width + 40;
                                    int num163 = 0;
                                    while (num163 < 200)
                                    {
                                        if (!Main.npc[num163].active || !Main.npc[num163].friendly || num163 == this.whoAmI || Main.npc[num163].velocity.X != 0f || !hitbox.Intersects(Main.npc[num163].Hitbox))
                                        {
                                            num163++;
                                        }
                                        else
                                        {
                                            flag52 = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!flag52 && flag50)
                            {
                                flag52 = true;
                            }
                            if (flag53 && (NPCID.Sets.TownCritter[this.type] || x56 < this.homeTileX - 35 || x56 > this.homeTileX + 35))
                            {
                                flag53 = false;
                            }
                            if (flag53)
                            {
                                int num164 = 0;
                                int num165 = -1;
                                while (num165 <= 4)
                                {
                                    Tile tile = Framing.GetTileSafely(x58 - this.direction * num164, y54 + num165);
                                    if (!tile.lava() || tile.liquid <= 0)
                                    {
                                        if (tile.nactive() && Main.tileSolid[tile.type])
                                        {
                                            flag53 = false;
                                        }
                                        num165++;
                                    }
                                    else
                                    {
                                        flag53 = true;
                                        break;
                                    }
                                }
                            }
                            if (!flag53 && this.wet)
                            {
                                bool flag54 = flag50;
                                bool flag55 = false;
                                if (!flag54)
                                {
                                    flag55 = Collision.DrownCollision(this.position + new Vector2((float)(this.width * this.direction), 0f), this.width, this.height, 1f);
                                }
                                flag55 = (flag55 ? true : Collision.DrownCollision(this.position + new Vector2((float)(this.width * this.direction), (float)(this.height * 2 - 16 - (flag54 ? 16 : 0))), this.width, 16 + (flag54 ? 16 : 0), 1f));
                                if (flag55 && this.localAI[3] <= 0f)
                                {
                                    flag53 = true;
                                    this.localAI[3] = 600f;
                                }
                            }
                            if (this.position.X == this.localAI[3])
                            {
                                NPC nPC65 = this;
                                nPC65.direction = nPC65.direction * -1;
                                this.netUpdate = true;
                                this.localAI[3] = 600f;
                            }
                            if (!flag50)
                            {
                                this.localAI[3] = -1f;
                            }
                            else if (this.localAI[3] > 0f)
                            {
                                this.localAI[3] = this.localAI[3] - 1f;
                            }
                            Tile tileSafely1 = Framing.GetTileSafely(x58, y54);
                            Tile tile1 = Framing.GetTileSafely(x58, y54 - 1);
                            Tile tileSafely2 = Framing.GetTileSafely(x58, y54 - 2);
                            if (!this.townNPC || !tileSafely2.nactive() || tileSafely2.type != 10 && tileSafely2.type != 388 || Main.rand.Next(10) != 0 && !flag43)
                            {
                                if (this.velocity.X < 0f && this.spriteDirection == -1 || this.velocity.X > 0f && this.spriteDirection == 1)
                                {
                                    if (tileSafely2.nactive() && Main.tileSolid[tileSafely2.type] && !Main.tileSolidTop[tileSafely2.type])
                                    {
                                        if (!Collision.SolidTilesVersatile(x58 - this.direction * 2, x58 - this.direction, y54 - 5, y54 - 1) && !Collision.SolidTiles(x58, x58, y54 - 5, y54 - 3))
                                        {
                                            this.velocity.Y = -6f;
                                            this.netUpdate = true;
                                        }
                                        else if (flag47)
                                        {
                                            if (WorldGen.SolidTile((int)(base.Center.X / 16f) + this.direction, (int)(base.Center.Y / 16f)))
                                            {
                                                NPC nPC66 = this;
                                                nPC66.direction = nPC66.direction * -1;
                                                this.velocity.X = this.velocity.X * 0f;
                                                this.netUpdate = true;
                                            }
                                        }
                                        else if (!flag48)
                                        {
                                            NPC nPC67 = this;
                                            nPC67.direction = nPC67.direction * -1;
                                            this.netUpdate = true;
                                        }
                                        else
                                        {
                                            flag52 = false;
                                            this.velocity.X = 0f;
                                            NPC nPC68 = this;
                                            nPC68.direction = nPC68.direction * -1;
                                            this.netUpdate = true;
                                            this.ai[0] = 8f;
                                            this.ai[1] = 240f;
                                        }
                                    }
                                    else if (tile1.nactive() && Main.tileSolid[tile1.type] && !Main.tileSolidTop[tile1.type])
                                    {
                                        if (!Collision.SolidTilesVersatile(x58 - this.direction * 2, x58 - this.direction, y54 - 4, y54 - 1) && !Collision.SolidTiles(x58, x58, y54 - 4, y54 - 2))
                                        {
                                            this.velocity.Y = -5f;
                                            this.netUpdate = true;
                                        }
                                        else if (!flag48)
                                        {
                                            NPC nPC69 = this;
                                            nPC69.direction = nPC69.direction * -1;
                                            this.netUpdate = true;
                                        }
                                        else
                                        {
                                            flag52 = false;
                                            this.velocity.X = 0f;
                                            NPC nPC70 = this;
                                            nPC70.direction = nPC70.direction * -1;
                                            this.netUpdate = true;
                                            this.ai[0] = 8f;
                                            this.ai[1] = 240f;
                                        }
                                    }
                                    else if (this.position.Y + (float)this.height - (float)(y54 * 16) <= 20f || !tileSafely1.nactive() || !Main.tileSolid[tileSafely1.type] || tileSafely1.topSlope())
                                    {
                                        if (flag53)
                                        {
                                            NPC nPC71 = this;
                                            nPC71.direction = nPC71.direction * -1;
                                            this.velocity.X = this.velocity.X * -1f;
                                            this.netUpdate = true;
                                            if (flag48)
                                            {
                                                flag52 = false;
                                                this.velocity.X = 0f;
                                                this.ai[0] = 8f;
                                                this.ai[1] = 240f;
                                            }
                                        }
                                    }
                                    else if (!Collision.SolidTilesVersatile(x58 - this.direction * 2, x58, y54 - 3, y54 - 1))
                                    {
                                        this.velocity.Y = -4.4f;
                                        this.netUpdate = true;
                                    }
                                    else if (!flag48)
                                    {
                                        NPC nPC72 = this;
                                        nPC72.direction = nPC72.direction * -1;
                                        this.netUpdate = true;
                                    }
                                    else
                                    {
                                        flag52 = false;
                                        this.velocity.X = 0f;
                                        NPC nPC73 = this;
                                        nPC73.direction = nPC73.direction * -1;
                                        this.netUpdate = true;
                                        this.ai[0] = 8f;
                                        this.ai[1] = 240f;
                                    }
                                    if (flag52)
                                    {
                                        this.ai[1] = 90f;
                                        this.netUpdate = true;
                                    }
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.localAI[3] = this.position.X;
                                    }
                                }
                                if (this.velocity.Y < 0f && this.wet)
                                {
                                    this.velocity.Y = this.velocity.Y * 1.2f;
                                }
                                if (this.velocity.Y < 0f && NPCID.Sets.TownCritter[this.type] && !flag47)
                                {
                                    this.velocity.Y = this.velocity.Y * 1.2f;
                                }
                            }
                            else if (Main.netMode != 1)
                            {
                                if (WorldGen.OpenDoor(x58, y54 - 2, this.direction))
                                {
                                    this.closeDoor = true;
                                    this.doorX = x58;
                                    this.doorY = y54 - 2;
                                    NetMessage.SendData(19, -1, -1, "", 0, (float)x58, (float)(y54 - 2), (float)this.direction, 0, 0, 0);
                                    this.netUpdate = true;
                                    this.ai[1] = this.ai[1] + 80f;
                                }
                                else if (WorldGen.OpenDoor(x58, y54 - 2, -this.direction))
                                {
                                    this.closeDoor = true;
                                    this.doorX = x58;
                                    this.doorY = y54 - 2;
                                    NetMessage.SendData(19, -1, -1, "", 0, (float)x58, (float)(y54 - 2), (float)(-this.direction), 0, 0, 0);
                                    this.netUpdate = true;
                                    this.ai[1] = this.ai[1] + 80f;
                                }
                                else if (!WorldGen.ShiftTallGate(x58, y54 - 2, false))
                                {
                                    NPC nPC74 = this;
                                    nPC74.direction = nPC74.direction * -1;
                                    this.netUpdate = true;
                                }
                                else
                                {
                                    this.closeDoor = true;
                                    this.doorX = x58;
                                    this.doorY = y54 - 2;
                                    NetMessage.SendData(19, -1, -1, "", 4, (float)x58, (float)(y54 - 2), 0f, 0, 0, 0);
                                    this.netUpdate = true;
                                    this.ai[1] = this.ai[1] + 80f;
                                }
                            }
                        }
                    }
                    else
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(200 + Main.rand.Next(200));
                        this.localAI[3] = 60f;
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 2f || this.ai[0] == 11f)
                {
                    if (Main.netMode != 1)
                    {
                        this.localAI[3] = this.localAI[3] - 1f;
                        if (Main.rand.Next(60) == 0 && this.localAI[3] == 0f)
                        {
                            this.localAI[3] = 60f;
                            NPC nPC75 = this;
                            nPC75.direction = nPC75.direction * -1;
                            this.netUpdate = true;
                        }
                    }
                    this.ai[1] = this.ai[1] - 1f;
                    this.velocity.X = this.velocity.X * 0.8f;
                    if (this.ai[1] <= 0f)
                    {
                        this.localAI[3] = 40f;
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(60 + Main.rand.Next(60));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 3f || this.ai[0] == 4f || this.ai[0] == 5f || this.ai[0] == 8f || this.ai[0] == 9f || this.ai[0] == 16f || this.ai[0] == 17f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] = this.ai[1] - 1f;
                    if (this.ai[0] == 8f && this.ai[1] < 60f && flag48)
                    {
                        this.ai[1] = 180f;
                        this.netUpdate = true;
                    }
                    if (this.ai[0] == 5f)
                    {
                        Point tileCoordinates = base.Center.ToTileCoordinates();
                        if (Main.tile[tileCoordinates.X, tileCoordinates.Y].type != 15)
                        {
                            this.ai[1] = 0f;
                        }
                    }
                    if (this.ai[1] <= 0f)
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(60 + Main.rand.Next(60));
                        this.ai[2] = 0f;
                        this.localAI[3] = (float)(30 + Main.rand.Next(60));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 6f || this.ai[0] == 7f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] = this.ai[1] - 1f;
                    int num166 = (int)this.ai[2];
                    if (num166 < 0 || num166 > 255 || !Main.player[num166].active || Main.player[num166].dead || Main.player[num166].Distance(base.Center) > 200f || !Collision.CanHitLine(base.Top, 0, 0, Main.player[num166].Top, 0, 0))
                    {
                        this.ai[1] = 0f;
                    }
                    if (this.ai[1] <= 0f)
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(60 + Main.rand.Next(60));
                        this.ai[2] = 0f;
                        this.localAI[3] = (float)(30 + Main.rand.Next(60));
                        this.netUpdate = true;
                    }
                    else
                    {
                        int num167 = (base.Center.X < Main.player[num166].Center.X ? 1 : -1);
                        if (num167 != this.direction)
                        {
                            this.netUpdate = true;
                        }
                        this.direction = num167;
                    }
                }
                else if (this.ai[0] == 10f)
                {
                    int num168 = 0;
                    int num169 = 0;
                    float single134 = 0f;
                    float single135 = 0f;
                    int num170 = 0;
                    int num171 = 0;
                    int num172 = 0;
                    float single136 = 0f;
                    float dangerDetectRange1 = (float)NPCID.Sets.DangerDetectRange[this.type];
                    float single137 = 0f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0;
                        this.localAI[3] = 0f;
                    }
                    if (this.type == 38)
                    {
                        num168 = 30;
                        single135 = 6f;
                        num169 = 20;
                        num170 = 10;
                        num171 = 180;
                        num172 = 120;
                        single136 = 16f;
                        single134 = 7f;
                    }
                    else if (this.type == 208)
                    {
                        num168 = 588;
                        single135 = 6f;
                        num169 = 30;
                        num170 = 10;
                        num171 = 60;
                        num172 = 120;
                        single136 = 16f;
                        single134 = 6f;
                    }
                    else if (this.type == 17)
                    {
                        num168 = 48;
                        single135 = 9f;
                        num169 = 12;
                        num170 = 10;
                        num171 = 60;
                        num172 = 60;
                        single136 = 16f;
                        single134 = 1.5f;
                    }
                    else if (this.type == 369)
                    {
                        num168 = 520;
                        single135 = 12f;
                        num169 = 10;
                        num170 = 10;
                        num171 = 0;
                        num172 = 1;
                        single136 = 16f;
                        single134 = 3f;
                    }
                    else if (this.type == 453)
                    {
                        num168 = 21;
                        single135 = 14f;
                        num169 = 14;
                        num170 = 10;
                        num171 = 0;
                        num172 = 1;
                        single136 = 16f;
                        single134 = 3f;
                    }
                    else if (this.type == 107)
                    {
                        num168 = 24;
                        single135 = 5f;
                        num169 = 15;
                        num170 = 10;
                        num171 = 60;
                        num172 = 60;
                        single136 = 16f;
                        single134 = 1f;
                    }
                    else if (this.type == 124)
                    {
                        num168 = 582;
                        single135 = 10f;
                        num169 = 11;
                        num170 = 1;
                        num171 = 30;
                        num172 = 30;
                        single134 = 3.5f;
                    }
                    else if (this.type == 18)
                    {
                        num168 = 583;
                        single135 = 8f;
                        num169 = 8;
                        num170 = 1;
                        num171 = 15;
                        num172 = 10;
                        single134 = 2f;
                        single136 = 10f;
                    }
                    else if (this.type == 142)
                    {
                        num168 = 589;
                        single135 = 7f;
                        num169 = 22;
                        num170 = 1;
                        num171 = 10;
                        num172 = 1;
                        single134 = 2f;
                        single136 = 10f;
                    }
                    if (Main.expertMode)
                    {
                        num169 = (int)((float)num169 * Main.expertNPCDamage);
                    }
                    num169 = (int)((float)num169 * single127);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] = this.ai[1] - 1f;
                    this.localAI[3] = this.localAI[3] + 1f;
                    if (this.localAI[3] == (float)num170 && Main.netMode != 1)
                    {
                        Vector2 unitY = -Vector2.UnitY;
                        if (num160 == 1 && this.spriteDirection == 1 && num162 != -1)
                        {
                            unitY = base.DirectionTo(Main.npc[num162].Center + new Vector2(0f, -single136 * MathHelper.Clamp(base.Distance(Main.npc[num162].Center) / dangerDetectRange1, 0f, 1f)));
                        }
                        if (num160 == -1 && this.spriteDirection == -1 && num161 != -1)
                        {
                            unitY = base.DirectionTo(Main.npc[num161].Center + new Vector2(0f, -single136 * MathHelper.Clamp(base.Distance(Main.npc[num161].Center) / dangerDetectRange1, 0f, 1f)));
                        }
                        if (unitY.HasNaNs() || Math.Sign(unitY.X) != this.spriteDirection)
                        {
                            unitY = new Vector2((float)this.spriteDirection, -1f);
                        }
                        unitY = unitY * single135;
                        unitY = unitY + Utils.RandomVector2(Main.rand, -single137, single137);
                        int num173 = 1000;
                        if (this.type != 124)
                        {
                            num173 = (this.type != 142 ? Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, unitY.X, unitY.Y, num168, num169, single134, Main.myPlayer, 0f, 0f) : Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, unitY.X, unitY.Y, num168, num169, single134, Main.myPlayer, 0f, (float)Main.rand.Next(5)));
                        }
                        else
                        {
                            num173 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, unitY.X, unitY.Y, num168, num169, single134, Main.myPlayer, 0f, (float)this.whoAmI);
                        }
                        Main.projectile[num173].npcProj = true;
                        Main.projectile[num173].noDropItem = true;
                    }
                    if (this.ai[1] <= 0f && !false)
                    {
                        float[] singleArray = this.ai;
                        float ai_0 = 8;
                        if (this.localAI[2] != 8f || !flag48)
                        {
                            ai_0 = 0;
                        }
                        singleArray[0] = ai_0;
                        this.ai[1] = (float)(num171 + Main.rand.Next(num172));
                        this.ai[2] = 0f;
                        float[] singleArray1 = this.localAI;
                        float[] singleArray2 = this.localAI;
                        float single138 = (float)(num171 / 2 + Main.rand.Next(num172));
                        single1 = single138;
                        singleArray2[3] = single138;
                        singleArray1[1] = single1;
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 12f)
                {
                    int num174 = 0;
                    int num175 = 0;
                    float single139 = 0f;
                    int num176 = 0;
                    int num177 = 0;
                    int num178 = 0;
                    float single140 = 0f;
                    int num179 = 0;
                    bool flag56 = false;
                    float single141 = 0f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0;
                        this.localAI[3] = 0f;
                    }
                    int num180 = -1;
                    if (num160 == 1 && this.spriteDirection == 1)
                    {
                        num180 = num162;
                    }
                    if (num160 == -1 && this.spriteDirection == -1)
                    {
                        num180 = num161;
                    }
                    if (this.type == 19)
                    {
                        num174 = 14;
                        single139 = 13f;
                        num175 = 24;
                        num177 = 14;
                        num178 = 4;
                        single140 = 3f;
                        num176 = 1;
                        single141 = 0.5f;
                        if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                        {
                            this.frameCounter = 0;
                            this.localAI[3] = 0f;
                        }
                        if (Main.hardMode)
                        {
                            num175 = 15;
                            if (this.localAI[3] > (float)num176)
                            {
                                num176 = 10;
                                flag56 = true;
                            }
                            if (this.localAI[3] > (float)num176)
                            {
                                num176 = 20;
                                flag56 = true;
                            }
                            if (this.localAI[3] > (float)num176)
                            {
                                num176 = 30;
                                flag56 = true;
                            }
                        }
                    }
                    else if (this.type == 227)
                    {
                        num174 = 587;
                        single139 = 10f;
                        num175 = 8;
                        num177 = 10;
                        num178 = 1;
                        single140 = 1.75f;
                        num176 = 1;
                        single141 = 0.5f;
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 12;
                            flag56 = true;
                        }
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 24;
                            flag56 = true;
                        }
                        if (Main.hardMode)
                        {
                            num175 = num175 + 2;
                        }
                    }
                    else if (this.type == 368)
                    {
                        num174 = 14;
                        single139 = 13f;
                        num175 = 24;
                        num177 = 12;
                        num178 = 5;
                        single140 = 2f;
                        num176 = 1;
                        single141 = 0.2f;
                        if (Main.hardMode)
                        {
                            num175 = 30;
                            num174 = 357;
                        }
                    }
                    else if (this.type == 22)
                    {
                        single139 = 10f;
                        num175 = 8;
                        num176 = 1;
                        if (!Main.hardMode)
                        {
                            num174 = 1;
                            num177 = 30;
                            num178 = 20;
                        }
                        else
                        {
                            num174 = 2;
                            num177 = 15;
                            num178 = 10;
                            num175 = num175 + 6;
                        }
                        single140 = 2.75f;
                        num179 = 4;
                        single141 = 0.7f;
                    }
                    else if (this.type == 228)
                    {
                        num174 = 267;
                        single139 = 14f;
                        num175 = 20;
                        num176 = 1;
                        num177 = 10;
                        num178 = 1;
                        single140 = 3f;
                        num179 = 6;
                        single141 = 0.4f;
                    }
                    else if (this.type == 178)
                    {
                        num174 = 242;
                        single139 = 13f;
                        num175 = 15;
                        num177 = 10;
                        num178 = 1;
                        single140 = 2f;
                        num176 = 1;
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 8;
                            flag56 = true;
                        }
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 16;
                            flag56 = true;
                        }
                        single141 = 0.3f;
                    }
                    else if (this.type == 229)
                    {
                        num174 = 14;
                        single139 = 14f;
                        num175 = 24;
                        num177 = 10;
                        num178 = 1;
                        single140 = 2f;
                        num176 = 1;
                        single141 = 0.7f;
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 16;
                            flag56 = true;
                        }
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 24;
                            flag56 = true;
                        }
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 32;
                            flag56 = true;
                        }
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 40;
                            flag56 = true;
                        }
                        if (this.localAI[3] > (float)num176)
                        {
                            num176 = 48;
                            flag56 = true;
                        }
                        if (this.localAI[3] == 0f && num180 != -1 && base.Distance(Main.npc[num180].Center) < (float)NPCID.Sets.PrettySafe[this.type])
                        {
                            single141 = 0.1f;
                            num174 = 162;
                            num175 = 50;
                            single140 = 10f;
                            single139 = 24f;
                        }
                    }
                    else if (this.type == 209)
                    {
                        Random random1 = Main.rand;
                        numArray = new int[] { 134, 133, 135 };
                        num174 = Utils.SelectRandom<int>(random1, numArray);
                        num176 = 1;
                        if (num174 == 135)
                        {
                            single139 = 12f;
                            num175 = 30;
                            num177 = 30;
                            num178 = 10;
                            single140 = 7f;
                            single141 = 0.2f;
                        }
                        else if (num174 == 133)
                        {
                            single139 = 10f;
                            num175 = 25;
                            num177 = 10;
                            num178 = 1;
                            single140 = 6f;
                            single141 = 0.2f;
                        }
                        else if (num174 == 134)
                        {
                            single139 = 13f;
                            num175 = 20;
                            num177 = 20;
                            num178 = 10;
                            single140 = 4f;
                            single141 = 0.1f;
                        }
                    }
                    if (Main.expertMode)
                    {
                        num175 = (int)((float)num175 * Main.expertNPCDamage);
                    }
                    num175 = (int)((float)num175 * single127);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] = this.ai[1] - 1f;
                    this.localAI[3] = this.localAI[3] + 1f;
                    if (this.localAI[3] == (float)num176 && Main.netMode != 1)
                    {
                        Vector2 zero1 = Vector2.Zero;
                        if (num180 != -1)
                        {
                            zero1 = base.DirectionTo(Main.npc[num180].Center + new Vector2(0f, (float)(-num179)));
                        }
                        if (zero1.HasNaNs() || Math.Sign(zero1.X) != this.spriteDirection)
                        {
                            zero1 = new Vector2((float)this.spriteDirection, 0f);
                        }
                        zero1 = zero1 * single139;
                        zero1 = zero1 + Utils.RandomVector2(Main.rand, -single141, single141);
                        int num181 = 1000;
                        num181 = (this.type != 227 ? Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, zero1.X, zero1.Y, num174, num175, single140, Main.myPlayer, 0f, 0f) : Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, zero1.X, zero1.Y, num174, num175, single140, Main.myPlayer, 0f, (float)Main.rand.Next(12) / 6f));
                        Main.projectile[num181].npcProj = true;
                        Main.projectile[num181].noDropItem = true;
                    }
                    if (this.localAI[3] == (float)num176 && flag56 && num180 != -1)
                    {
                        Vector2 vector251 = base.DirectionTo(Main.npc[num180].Center);
                        if (vector251.Y <= 0.5f && vector251.Y >= -0.5f)
                        {
                            this.ai[2] = vector251.Y;
                        }
                    }
                    if (this.ai[1] <= 0f && !false)
                    {
                        float[] singleArray3 = this.ai;
                        float array3_0 = 8;
                        if (this.localAI[2] != 8f || !flag48)
                        {
                            array3_0 = 0;
                        }
                        singleArray3[0] = (float)array3_0;
                        this.ai[1] = (float)(num177 + Main.rand.Next(num178));
                        this.ai[2] = 0f;
                        float[] singleArray4 = this.localAI;
                        float[] singleArray5 = this.localAI;
                        float single142 = (float)(num177 / 2 + Main.rand.Next(num178));
                        single1 = single142;
                        singleArray5[3] = single142;
                        singleArray4[1] = single1;
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 13f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0;
                    }
                    this.ai[1] = this.ai[1] - 1f;
                    this.localAI[3] = this.localAI[3] + 1f;
                    if (this.localAI[3] == 1f && Main.netMode != 1)
                    {
                        Vector2 vector252 = base.DirectionTo(Main.npc[(int)this.ai[2]].Center + new Vector2(0f, -20f));
                        if (vector252.HasNaNs() || Math.Sign(vector252.X) == -this.spriteDirection)
                        {
                            vector252 = new Vector2((float)this.spriteDirection, -1f);
                        }
                        vector252 = vector252 * 8f;
                        int num182 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector252.X, vector252.Y, 584, 0, 0f, Main.myPlayer, this.ai[2], 0f);
                        Main.projectile[num182].npcProj = true;
                        Main.projectile[num182].noDropItem = true;
                    }
                    if (this.ai[1] <= 0f)
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(10 + Main.rand.Next(10));
                        this.ai[2] = 0f;
                        this.localAI[3] = (float)(5 + Main.rand.Next(10));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 14f)
                {
                    int num183 = 0;
                    int num184 = 0;
                    float single143 = 0f;
                    int num185 = 0;
                    int num186 = 0;
                    int num187 = 0;
                    float single144 = 0f;
                    float single145 = 0f;
                    float dangerDetectRange2 = (float)NPCID.Sets.DangerDetectRange[this.type];
                    float single146 = 1f;
                    float single147 = 0f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0;
                        this.localAI[3] = 0f;
                    }
                    int num188 = -1;
                    if (num160 == 1 && this.spriteDirection == 1)
                    {
                        num188 = num162;
                    }
                    if (num160 == -1 && this.spriteDirection == -1)
                    {
                        num188 = num161;
                    }
                    if (this.type == 54)
                    {
                        num183 = 585;
                        single143 = 10f;
                        num184 = 16;
                        num185 = 30;
                        num186 = 20;
                        num187 = 15;
                        single144 = 2f;
                        single147 = 1f;
                    }
                    else if (this.type == 108)
                    {
                        num183 = 15;
                        single143 = 6f;
                        num184 = 18;
                        num185 = 15;
                        num186 = 15;
                        num187 = 5;
                        single144 = 3f;
                        single145 = 20f;
                    }
                    else if (this.type == 160)
                    {
                        num183 = 590;
                        num184 = 40;
                        num185 = 15;
                        num186 = 10;
                        num187 = 1;
                        single144 = 3f;
                        while (this.localAI[3] > (float)num185)
                        {
                            num185 = num185 + 15;
                        }
                    }
                    else if (this.type == 20)
                    {
                        num183 = 586;
                        num185 = 24;
                        num186 = 10;
                        num187 = 1;
                        single144 = 3f;
                    }
                    if (Main.expertMode)
                    {
                        num184 = (int)((float)num184 * Main.expertNPCDamage);
                    }
                    num184 = (int)((float)num184 * single127);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] = this.ai[1] - 1f;
                    this.localAI[3] = this.localAI[3] + 1f;
                    if (this.localAI[3] == (float)num185 && Main.netMode != 1)
                    {
                        Vector2 zero2 = Vector2.Zero;
                        if (num188 != -1)
                        {
                            zero2 = base.DirectionTo(Main.npc[num188].Center + new Vector2(0f, -single145 * MathHelper.Clamp(base.Distance(Main.npc[num188].Center) / dangerDetectRange2, 0f, 1f)));
                        }
                        if (zero2.HasNaNs() || Math.Sign(zero2.X) != this.spriteDirection)
                        {
                            zero2 = new Vector2((float)this.spriteDirection, 0f);
                        }
                        zero2 = zero2 * single143;
                        zero2 = zero2 + Utils.RandomVector2(Main.rand, -single147, single147);
                        if (this.type == 108)
                        {
                            Random random2 = Main.rand;
                            numArray = new int[] { 1, 1, 1, 1, 2, 2, 3 };
                            int num189 = Utils.SelectRandom<int>(random2, numArray);
                            for (int q2 = 0; q2 < num189; q2++)
                            {
                                Vector2 vector253 = Utils.RandomVector2(Main.rand, -3.4f, 3.4f);
                                int num190 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, zero2.X + vector253.X, zero2.Y + vector253.Y, num183, num184, single144, Main.myPlayer, 0f, 0f);
                                Main.projectile[num190].npcProj = true;
                                Main.projectile[num190].noDropItem = true;
                            }
                        }
                        else if (this.type == 160)
                        {
                            if (num188 != -1)
                            {
                                Vector2 size = (Main.npc[num188].position - (Main.npc[num188].Size * 2f)) + ((Main.npc[num188].Size * Utils.RandomVector2(Main.rand, 0f, 1f)) * 5f);
                                int num191 = 10;
                                while (num191 > 0 && WorldGen.SolidTile(Framing.GetTileSafely((int)size.X / 16, (int)size.Y / 16)))
                                {
                                    num191--;
                                    size = (Main.npc[num188].position - (Main.npc[num188].Size * 2f)) + ((Main.npc[num188].Size * Utils.RandomVector2(Main.rand, 0f, 1f)) * 5f);
                                }
                                int num192 = Projectile.NewProjectile(size.X, size.Y, 0f, 0f, num183, num184, single144, Main.myPlayer, 0f, 0f);
                                Main.projectile[num192].npcProj = true;
                                Main.projectile[num192].noDropItem = true;
                            }
                        }
                        else if (this.type != 20)
                        {
                            int num193 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, zero2.X, zero2.Y, num183, num184, single144, Main.myPlayer, 0f, 0f);
                            Main.projectile[num193].npcProj = true;
                            Main.projectile[num193].noDropItem = true;
                        }
                        else
                        {
                            int num194 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, zero2.X, zero2.Y, num183, num184, single144, Main.myPlayer, 0f, (float)this.whoAmI);
                            Main.projectile[num194].npcProj = true;
                            Main.projectile[num194].noDropItem = true;
                        }
                    }
                    if (this.ai[1] <= 0f && !false)
                    {
                        float[] singleArray6 = this.ai;
                        float ai_0 = 8;
                        if (this.localAI[2] != 8f || !flag48)
                        {
                            ai_0 = 0;
                        }
                        singleArray6[0] = ai_0;
                        this.ai[1] = (float)(num186 + Main.rand.Next(num187));
                        this.ai[2] = 0f;
                        float[] singleArray7 = this.localAI;
                        float[] singleArray8 = this.localAI;
                        float single148 = (float)(num186 / 2 + Main.rand.Next(num187));
                        single1 = single148;
                        singleArray8[3] = single148;
                        singleArray7[1] = single1;
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 15f)
                {
                    int num195 = 0;
                    int num196 = 0;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0;
                        this.localAI[3] = 0f;
                    }
                    int num197 = 0;
                    float single149 = 0f;
                    int num198 = 0;
                    int num199 = 0;
                    if (num160 == 1)
                    {
                        int num200 = this.spriteDirection;
                    }
                    if (num160 == -1)
                    {
                        int num201 = this.spriteDirection;
                    }
                    if (this.type == 207)
                    {
                        num197 = 11;
                        int num202 = 32;
                        num199 = num202;
                        num198 = num202;
                        num195 = 12;
                        num196 = 6;
                        single149 = 4.25f;
                    }
                    else if (this.type == 441)
                    {
                        num197 = 9;
                        int num203 = 28;
                        num199 = num203;
                        num198 = num203;
                        num195 = 9;
                        num196 = 3;
                        single149 = 3.5f;
                    }
                    else if (this.type == 353)
                    {
                        num197 = 10;
                        int num204 = 32;
                        num199 = num204;
                        num198 = num204;
                        num195 = 15;
                        num196 = 8;
                        single149 = 5f;
                    }
                    if (Main.expertMode)
                    {
                        num197 = (int)((float)num197 * Main.expertNPCDamage);
                    }
                    num197 = (int)((float)num197 * single127);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] = this.ai[1] - 1f;
                    if (Main.netMode != 1)
                    {
                        Tuple<Vector2, float> swingStats = this.GetSwingStats(NPCID.Sets.AttackTime[this.type] * 2, (int)this.ai[1], this.spriteDirection, num198, num199);
                        Rectangle rectangle4 = new Rectangle((int)swingStats.Item1.X, (int)swingStats.Item1.Y, num198, num199);
                        if (this.spriteDirection == -1)
                        {
                            rectangle4.X = rectangle4.X - num198;
                        }
                        rectangle4.Y = rectangle4.Y - num199;
                        this.TweakSwingStats(NPCID.Sets.AttackTime[this.type] * 2, (int)this.ai[1], this.spriteDirection, ref rectangle4);
                        int num205 = Main.myPlayer;
                        for (int r2 = 0; r2 < 200; r2++)
                        {
                            NPC nPC76 = Main.npc[r2];
                            if (nPC76.active && nPC76.immune[num205] == 0 && !nPC76.dontTakeDamage && !nPC76.friendly && nPC76.damage > 0 && rectangle4.Intersects(nPC76.Hitbox) && (nPC76.noTileCollide || Collision.CanHit(this.position, this.width, this.height, nPC76.position, nPC76.width, nPC76.height)))
                            {
                                nPC76.StrikeNPCNoInteraction(num197, single149, this.spriteDirection, false, false, false);
                                if (Main.netMode != 0)
                                {
                                    NetMessage.SendData(28, -1, -1, "", r2, (float)num197, single149, (float)this.spriteDirection, 0, 0, 0);
                                }
                                nPC76.netUpdate = true;
                                nPC76.immune[num205] = (int)this.ai[1] + 2;
                            }
                        }
                    }
                    if (this.ai[1] <= 0f)
                    {
                        bool flag57 = false;
                        if (flag48)
                        {
                            if (!Collision.CanHit(base.Center, 0, 0, base.Center + ((Vector2.UnitX * (float)(-num160)) * 32f), 0, 0) || this.localAI[2] == 8f)
                            {
                                flag57 = true;
                            }
                            if (flag57)
                            {
                                int attackTime = NPCID.Sets.AttackTime[this.type];
                                int num206 = (num160 == 1 ? num162 : num161);
                                int num207 = (num160 == 1 ? num161 : num162);
                                if (num206 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num206].Center, 0, 0))
                                {
                                    num206 = (num207 == -1 || !Collision.CanHit(base.Center, 0, 0, Main.npc[num207].Center, 0, 0) ? -1 : num207);
                                }
                                if (num206 == -1)
                                {
                                    flag57 = false;
                                }
                                else
                                {
                                    this.ai[0] = 15f;
                                    this.ai[1] = (float)attackTime;
                                    this.ai[2] = 0f;
                                    this.localAI[3] = 0f;
                                    this.direction = (this.position.X < Main.npc[num206].position.X ? 1 : -1);
                                    this.netUpdate = true;
                                }
                            }
                        }
                        if (!flag57)
                        {
                            float[] singleArray9 = this.ai;
                            float ai_0 = 8;
                            if (this.localAI[2] != 8f || !flag48)
                            {
                                ai_0 = 0;
                            }
                            singleArray9[0] = ai_0;
                            this.ai[1] = (float)(num195 + Main.rand.Next(num196));
                            this.ai[2] = 0f;
                            float[] singleArray10 = this.localAI;
                            float[] singleArray11 = this.localAI;
                            float single150 = (float)(num195 / 2 + Main.rand.Next(num196));
                            single1 = single150;
                            singleArray11[3] = single150;
                            singleArray10[1] = single1;
                            this.netUpdate = true;
                        }
                    }
                }
                if (Main.netMode != 1 && (this.townNPC || this.type == 453) && !flag45)
                {
                    bool flag58 = (this.ai[0] >= 2f ? false : !flag48);
                    if (this.ai[0] < 2f || this.ai[0] == 8f)
                    {
                        flag5 = (flag48 ? true : flag49);
                    }
                    else
                    {
                        flag5 = false;
                    }
                    bool flag59 = flag5;
                    if (this.localAI[1] > 0f)
                    {
                        this.localAI[1] = this.localAI[1] - 1f;
                    }
                    if (this.localAI[1] > 0f)
                    {
                        flag59 = false;
                    }
                    if (flag59 && this.type == 124 && this.localAI[0] == 1f)
                    {
                        flag59 = false;
                    }
                    if (flag59 && this.type == 20)
                    {
                        flag59 = false;
                        int num208 = 0;
                        while (num208 < 200)
                        {
                            NPC nPC77 = Main.npc[num208];
                            if (!nPC77.active || !nPC77.townNPC || base.Distance(nPC77.Center) > 1200f || nPC77.HasBuff(165) != -1)
                            {
                                num208++;
                            }
                            else
                            {
                                flag59 = true;
                                break;
                            }
                        }
                    }
                    if (flag58 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(300) == 0)
                    {
                        int num209 = 420;
                        num209 = (Main.rand.Next(2) != 0 ? num209 * Main.rand.Next(1, 3) : num209 * Main.rand.Next(1, 4));
                        int num210 = 100;
                        int num211 = 20;
                        int num212 = 0;
                        while (num212 < 200)
                        {
                            NPC nPC78 = Main.npc[num212];
                            bool flag60 = ((nPC78.ai[0] != 1f || !nPC78.closeDoor) && (nPC78.ai[0] != 1f || nPC78.ai[1] <= 200f) ? nPC78.ai[0] > 1f : true);
                            if (nPC78 == this || !nPC78.active || !nPC78.CanTalk || flag60 || nPC78.Distance(base.Center) >= (float)num210 || nPC78.Distance(base.Center) <= (float)num211 || !Collision.CanHit(base.Center, 0, 0, nPC78.Center, 0, 0))
                            {
                                num212++;
                            }
                            else
                            {
                                int directionInt = (this.position.X < nPC78.position.X).ToDirectionInt();
                                this.ai[0] = 3f;
                                this.ai[1] = (float)num209;
                                this.ai[2] = (float)num212;
                                this.direction = directionInt;
                                this.netUpdate = true;
                                nPC78.ai[0] = 4f;
                                nPC78.ai[1] = (float)num209;
                                nPC78.ai[2] = (float)this.whoAmI;
                                nPC78.direction = -directionInt;
                                nPC78.netUpdate = true;
                                goto Label5;
                            }
                        }
                    }
                    else if (flag58 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1800) == 0)
                    {
                        int num213 = 420;
                        num213 = (Main.rand.Next(2) != 0 ? num213 * Main.rand.Next(1, 3) : num213 * Main.rand.Next(1, 4));
                        int num214 = 100;
                        int num215 = 20;
                        int num216 = 0;
                        while (num216 < 200)
                        {
                            NPC nPC79 = Main.npc[num216];
                            bool flag61 = ((nPC79.ai[0] != 1f || !nPC79.closeDoor) && (nPC79.ai[0] != 1f || nPC79.ai[1] <= 200f) ? nPC79.ai[0] > 1f : true);
                            if (nPC79 == this || !nPC79.active || !nPC79.CanTalk || flag61 || nPC79.Distance(base.Center) >= (float)num214 || nPC79.Distance(base.Center) <= (float)num215 || !Collision.CanHit(base.Center, 0, 0, nPC79.Center, 0, 0))
                            {
                                num216++;
                            }
                            else
                            {
                                int directionInt1 = (this.position.X < nPC79.position.X).ToDirectionInt();
                                this.ai[0] = 16f;
                                this.ai[1] = (float)num213;
                                this.ai[2] = (float)num216;
                                this.localAI[2] = (float)Main.rand.Next(4);
                                this.localAI[3] = (float)Main.rand.Next(3 - (int)this.localAI[2]);
                                this.direction = directionInt1;
                                this.netUpdate = true;
                                nPC79.ai[0] = 17f;
                                nPC79.ai[1] = (float)num213;
                                nPC79.ai[2] = (float)this.whoAmI;
                                nPC79.localAI[2] = 0f;
                                nPC79.localAI[3] = 0f;
                                nPC79.direction = -directionInt1;
                                nPC79.netUpdate = true;
                                goto Label5;
                            }
                        }
                    }
                    else if (flag58 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1200) == 0 && this.type == 208)
                    {
                        int num217 = 300;
                        int num218 = 150;
                        int num219 = 0;
                        while (num219 < 255)
                        {
                            Player player1 = Main.player[num219];
                            if (!player1.active || player1.dead || player1.Distance(base.Center) >= (float)num218 || !Collision.CanHitLine(base.Top, 0, 0, player1.Top, 0, 0))
                            {
                                num219++;
                            }
                            else
                            {
                                int directionInt2 = (this.position.X < player1.position.X).ToDirectionInt();
                                this.ai[0] = 6f;
                                this.ai[1] = (float)num217;
                                this.ai[2] = (float)num219;
                                this.direction = directionInt2;
                                this.netUpdate = true;
                                goto Label5;
                            }
                        }
                    }
                    else if (flag58 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1800) == 0)
                    {
                        this.ai[0] = 2f;
                        this.ai[1] = (float)(45 * Main.rand.Next(1, 2));
                        this.netUpdate = true;
                    }
                    else if (flag58 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(600) == 0 && this.type == 229 && !flag49)
                    {
                        this.ai[0] = 11f;
                        this.ai[1] = (float)(30 * Main.rand.Next(1, 4));
                        this.netUpdate = true;
                    }
                    else if (flag58 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1200) == 0)
                    {
                        int num220 = 220;
                        int num221 = 150;
                        int num222 = 0;
                        while (num222 < 255)
                        {
                            Player player2 = Main.player[num222];
                            if (!player2.active || player2.dead || player2.Distance(base.Center) >= (float)num221 || !Collision.CanHitLine(base.Top, 0, 0, player2.Top, 0, 0))
                            {
                                num222++;
                            }
                            else
                            {
                                int directionInt3 = (this.position.X < player2.position.X).ToDirectionInt();
                                this.ai[0] = 7f;
                                this.ai[1] = (float)num220;
                                this.ai[2] = (float)num222;
                                this.direction = directionInt3;
                                this.netUpdate = true;
                                goto Label5;
                            }
                        }
                    }
                    else if (flag58 && this.ai[0] == 1f && this.velocity.Y == 0f && Main.rand.Next(300) == 0)
                    {
                        Point point = base.Center.ToTileCoordinates();
                        bool flag62 = WorldGen.InWorld(point.X, point.Y, 1);
                        if (flag62)
                        {
                            int num223 = 0;
                            while (num223 < 200)
                            {
                                if (!Main.npc[num223].active || Main.npc[num223].aiStyle != 7 || !Main.npc[num223].townNPC || Main.npc[num223].ai[0] != 5f || !(Main.npc[num223].Center.ToTileCoordinates() == point))
                                {
                                    num223++;
                                }
                                else
                                {
                                    flag62 = false;
                                    break;
                                }
                            }
                        }
                        if (flag62)
                        {
                            Tile tile2 = Main.tile[point.X, point.Y];
                            flag62 = tile2.type == 15;
                            if (flag62 && tile2.frameY == 1080)
                            {
                                flag62 = false;
                            }
                            if (flag62)
                            {
                                this.ai[0] = 5f;
                                this.ai[1] = (float)(900 + Main.rand.Next(10800));
                                this.direction = (tile2.frameX == 0 ? -1 : 1);
                                base.Bottom = new Vector2((float)(point.X * 16 + 8 + 2 * this.direction), (float)(point.Y * 16 + 32));
                                this.velocity = Vector2.Zero;
                                this.localAI[3] = 0f;
                                this.netUpdate = true;
                            }
                        }
                    }
                    else if (flag58 && this.ai[0] == 1f && this.velocity.Y == 0f && Main.rand.Next(600) == 0 && Utils.PlotTileLine(base.Top, base.Bottom, (float)this.width, new Utils.PerLinePoint(DelegateMethods.SearchAvoidedByNPCs)))
                    {
                        Point tileCoordinates1 = (base.Center + new Vector2((float)(this.direction * 10), 0f)).ToTileCoordinates();
                        bool flag63 = WorldGen.InWorld(tileCoordinates1.X, tileCoordinates1.Y, 1);
                        if (flag63)
                        {
                            Tile tileSafely3 = Framing.GetTileSafely(tileCoordinates1.X, tileCoordinates1.Y);
                            if (!tileSafely3.nactive() || !TileID.Sets.InteractibleByNPCs[tileSafely3.type])
                            {
                                flag63 = false;
                            }
                        }
                        if (flag63)
                        {
                            this.ai[0] = 9f;
                            this.ai[1] = (float)(40 + Main.rand.Next(90));
                            this.velocity = Vector2.Zero;
                            this.localAI[3] = 0f;
                            this.netUpdate = true;
                        }
                    }
                Label5:
                    if (this.ai[0] < 2f && this.velocity.Y == 0f && this.type == 18)
                    {
                        int num224 = -1;
                        for (int s2 = 0; s2 < 200; s2++)
                        {
                            NPC nPC80 = Main.npc[s2];
                            if (nPC80.active && nPC80.townNPC && nPC80.life != nPC80.lifeMax && (num224 == -1 || nPC80.lifeMax - nPC80.life > Main.npc[num224].lifeMax - Main.npc[num224].life) && Collision.CanHitLine(this.position, this.width, this.height, nPC80.position, nPC80.width, nPC80.height) && base.Distance(nPC80.Center) < 500f)
                            {
                                num224 = s2;
                            }
                        }
                        if (num224 != -1)
                        {
                            this.ai[0] = 13f;
                            this.ai[1] = 34f;
                            this.ai[2] = (float)num224;
                            this.localAI[3] = 0f;
                            this.direction = (this.position.X < Main.npc[num224].position.X ? 1 : -1);
                            this.netUpdate = true;
                        }
                    }
                    if (flag59 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 0 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int attackTime1 = NPCID.Sets.AttackTime[this.type];
                        int num225 = (num160 == 1 ? num162 : num161);
                        int num226 = (num160 == 1 ? num161 : num162);
                        if (num225 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num225].Center, 0, 0))
                        {
                            num225 = (num226 == -1 || !Collision.CanHit(base.Center, 0, 0, Main.npc[num226].Center, 0, 0) ? -1 : num226);
                        }
                        if (num225 != -1)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 10f;
                            this.ai[1] = (float)attackTime1;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.direction = (this.position.X < Main.npc[num225].position.X ? 1 : -1);
                            this.netUpdate = true;
                        }
                    }
                    else if (flag59 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 1 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int attackTime2 = NPCID.Sets.AttackTime[this.type];
                        int num227 = (num160 == 1 ? num162 : num161);
                        int num228 = (num160 == 1 ? num161 : num162);
                        if (num227 != -1 && !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num227].Center, 0, 0))
                        {
                            num227 = (num228 == -1 || !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num228].Center, 0, 0) ? -1 : num228);
                        }
                        if (num227 != -1)
                        {
                            Vector2 vector254 = base.DirectionTo(Main.npc[num227].Center);
                            if (vector254.Y <= 0.5f && vector254.Y >= -0.5f)
                            {
                                this.localAI[2] = this.ai[0];
                                this.ai[0] = 12f;
                                this.ai[1] = (float)attackTime2;
                                this.ai[2] = vector254.Y;
                                this.localAI[3] = 0f;
                                this.direction = (this.position.X < Main.npc[num227].position.X ? 1 : -1);
                                this.netUpdate = true;
                            }
                        }
                    }
                    if (flag59 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 2 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int attackTime3 = NPCID.Sets.AttackTime[this.type];
                        int num229 = (num160 == 1 ? num162 : num161);
                        int num230 = (num160 == 1 ? num161 : num162);
                        if (num229 != -1 && !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num229].Center, 0, 0))
                        {
                            num229 = (num230 == -1 || !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num230].Center, 0, 0) ? -1 : num230);
                        }
                        if (num229 != -1)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 14f;
                            this.ai[1] = (float)attackTime3;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.direction = (this.position.X < Main.npc[num229].position.X ? 1 : -1);
                            this.netUpdate = true;
                        }
                        else if (this.type == 20)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 14f;
                            this.ai[1] = (float)attackTime3;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.netUpdate = true;
                        }
                    }
                    if (flag59 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 3 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int attackTime4 = NPCID.Sets.AttackTime[this.type];
                        int num231 = (num160 == 1 ? num162 : num161);
                        int num232 = (num160 == 1 ? num161 : num162);
                        if (num231 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num231].Center, 0, 0))
                        {
                            num231 = (num232 == -1 || !Collision.CanHit(base.Center, 0, 0, Main.npc[num232].Center, 0, 0) ? -1 : num232);
                        }
                        if (num231 != -1)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 15f;
                            this.ai[1] = (float)attackTime4;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.direction = (this.position.X < Main.npc[num231].position.X ? 1 : -1);
                            this.netUpdate = true;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 8)
            {
                this.TargetClosest(true);
                this.velocity.X = this.velocity.X * 0.93f;
                if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                {
                    this.velocity.X = 0f;
                }
                if (this.ai[0] == 0f)
                {
                    this.ai[0] = 500f;
                }
                if (this.type == 172)
                {
                    if (this.alpha < 255)
                    {
                        NPC nPC81 = this;
                        nPC81.alpha = nPC81.alpha + 1;
                    }
                    if (this.justHit)
                    {
                        this.alpha = 0;
                    }
                }
                if (this.ai[2] != 0f && this.ai[3] != 0f)
                {
                    if (this.type == 172)
                    {
                        this.alpha = 255;
                    }
                    this.position.X = this.ai[2] * 16f - (float)(this.width / 2) + 8f;
                    this.position.Y = this.ai[3] * 16f - (float)this.height;
                    this.velocity.X = 0f;
                    this.velocity.Y = 0f;
                    this.ai[2] = 0f;
                    this.ai[3] = 0f;
                }
                this.ai[0] = this.ai[0] + 1f;
                if (this.type == 283 || this.type == 284)
                {
                    if (this.ai[0] == 50f || this.ai[0] == 100f || this.ai[0] == 150f || this.ai[0] == 200f || this.ai[0] == 250f)
                    {
                        this.ai[1] = 30f;
                        this.netUpdate = true;
                    }
                    if (this.ai[0] >= 400f)
                    {
                        this.ai[0] = 700f;
                    }
                }
                else if (this.type == 172)
                {
                    if (this.ai[0] == 75f || this.ai[0] == 150f || this.ai[0] == 225f || this.ai[0] == 300f || this.ai[0] == 375f || this.ai[0] == 450f)
                    {
                        this.ai[1] = 30f;
                        this.netUpdate = true;
                    }
                }
                else if (this.type == 533)
                {
                    if (this.ai[0] == 180f)
                    {
                        this.ai[1] = 181f;
                        this.netUpdate = true;
                    }
                }
                else if (this.type == 281 || this.type == 282)
                {
                    if (this.ai[0] == 20f || this.ai[0] == 40f || this.ai[0] == 60f || this.ai[0] == 120f || this.ai[0] == 140f || this.ai[0] == 160f || this.ai[0] == 220f || this.ai[0] == 240f || this.ai[0] == 260f)
                    {
                        this.ai[1] = 30f;
                        this.netUpdate = true;
                    }
                    if (this.ai[0] >= 460f)
                    {
                        this.ai[0] = 700f;
                    }
                }
                else if (this.ai[0] == 100f || this.ai[0] == 200f || this.ai[0] == 300f)
                {
                    this.ai[1] = 30f;
                    this.netUpdate = true;
                }
                if ((this.type == 285 || this.type == 286) && this.ai[0] > 400f)
                {
                    this.ai[0] = 650f;
                }
                if (this.type == 533 && this.ai[0] >= 360f)
                {
                    this.ai[0] = 650f;
                }
                if (this.ai[0] >= 650f && Main.netMode != 1)
                {
                    this.ai[0] = 1f;
                    int x59 = (int)Main.player[this.target].position.X / 16;
                    int y55 = (int)Main.player[this.target].position.Y / 16;
                    int x60 = (int)this.position.X / 16;
                    int y56 = (int)this.position.Y / 16;
                    int num281 = 20;
                    int num282 = 0;
                    bool flag64 = false;
                    if (Math.Abs(this.position.X - Main.player[this.target].position.X) + Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                    {
                        num282 = 100;
                        flag64 = true;
                    }
                Label2:
                    while (!flag64 && num282 < 100)
                    {
                        num282++;
                        int num283 = Main.rand.Next(x59 - num281, x59 + num281);
                        int num284 = Main.rand.Next(y55 - num281, y55 + num281);
                        for (int v2 = num284; v2 < y55 + num281; v2++)
                        {
                            if ((v2 < y55 - 4 || v2 > y55 + 4 || num283 < x59 - 4 || num283 > x59 + 4) && (v2 < y56 - 1 || v2 > y56 + 1 || num283 < x60 - 1 || num283 > x60 + 1) && Main.tile[num283, v2].nactive())
                            {
                                bool flag65 = true;
                                if ((this.type == 32 || this.type >= 281 && this.type <= 286) && !Main.wallDungeon[Main.tile[num283, v2 - 1].wall])
                                {
                                    flag65 = false;
                                }
                                else if (Main.tile[num283, v2 - 1].lava())
                                {
                                    flag65 = false;
                                }
                                if (flag65 && Main.tileSolid[Main.tile[num283, v2].type] && !Collision.SolidTiles(num283 - 1, num283 + 1, v2 - 4, v2 - 1))
                                {
                                    this.ai[1] = 20f;
                                    this.ai[2] = (float)num283;
                                    this.ai[3] = (float)v2;
                                    flag64 = true;
                                    goto Label2;
                                }
                            }
                        }
                    }
                    this.netUpdate = true;
                }
                if (this.ai[1] > 0f)
                {
                    this.ai[1] = this.ai[1] - 1f;
                    if (this.type == 533)
                    {
                        if (this.ai[1] % 30f == 0f && this.ai[1] / 30f < 5f)
                        {
                            if (Main.netMode != 1)
                            {
                                Point point1 = base.Center.ToTileCoordinates();
                                Point tileCoordinates2 = Main.player[this.target].Center.ToTileCoordinates();
                                Vector2 center21 = Main.player[this.target].Center - base.Center;
                                int num285 = 6;
                                int num286 = 6;
                                int num287 = 0;
                                int num288 = 2;
                                int num289 = 0;
                                bool flag66 = false;
                                if (center21.Length() > 2000f)
                                {
                                    flag66 = true;
                                }
                                do
                                {
                                Label4:
                                    if (flag66)
                                    {
                                        break;
                                    }
                                    if (num289 < 50)
                                    {
                                        num289++;
                                        num1 = Main.rand.Next(tileCoordinates2.X - num285, tileCoordinates2.X + num285 + 1);
                                        num2 = Main.rand.Next(tileCoordinates2.Y - num285, tileCoordinates2.Y + num285 + 1);
                                        if ((num2 < tileCoordinates2.Y - num287 || num2 > tileCoordinates2.Y + num287 || num1 < tileCoordinates2.X - num287 || num1 > tileCoordinates2.X + num287) && (num2 < point1.Y - num286 || num2 > point1.Y + num286 || num1 < point1.X - num286 || num1 > point1.X + num286) && !Main.tile[num1, num2].nactive())
                                        {
                                            flag = true;
                                            if (flag && Main.tile[num1, num2].lava())
                                            {
                                                flag = false;
                                            }
                                            if (!flag || !Collision.SolidTiles(num1 - num288, num1 + num288, num2 - num288, num2 + num288))
                                            {
                                                continue;
                                            }
                                            flag = false;
                                        }
                                        else
                                        {
                                            goto Label4;
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                while (!flag);
                                Projectile.NewProjectile((float)(num1 * 16 + 8), (float)(num2 * 16 + 8), 0f, 0f, 596, 0, 1f, Main.myPlayer, (float)this.target, 0f);
                                flag66 = true;
                            }
                        }
                    }
                    else if (this.ai[1] == 25f)
                    {
                        if (this.type < 281 || this.type > 286)
                        {
                            if (Main.netMode != 1)
                            {
                                if (this.type == 29 || this.type == 45)
                                {
                                    NPC.NewNPC((int)this.position.X + this.width / 2, (int)this.position.Y - 8, 30, 0, 0f, 0f, 0f, 0f, 255);
                                }
                                else if (this.type == 32)
                                {
                                    NPC.NewNPC((int)this.position.X + this.width / 2, (int)this.position.Y - 8, 33, 0, 0f, 0f, 0f, 0f, 255);
                                }
                                else if (this.type != 172)
                                {
                                    NPC.NewNPC((int)this.position.X + this.width / 2 + this.direction * 8, (int)this.position.Y + 20, 25, 0, 0f, 0f, 0f, 0f, 255);
                                }
                                else
                                {
                                    float single151 = 10f;
                                    Vector2 vector271 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float x61 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector271.X + (float)Main.rand.Next(-10, 11);
                                    float y57 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector271.Y + (float)Main.rand.Next(-10, 11);
                                    float single152 = (float)Math.Sqrt((double)(x61 * x61 + y57 * y57));
                                    single152 = single151 / single152;
                                    x61 = x61 * single152;
                                    y57 = y57 * single152;
                                    int num290 = 40;
                                    int num291 = 129;
                                    int num292 = Projectile.NewProjectile(vector271.X, vector271.Y, x61, y57, num291, num290, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num292].timeLeft = 300;
                                    this.localAI[0] = 0f;
                                }
                            }
                        }
                        else if (Main.netMode != 1)
                        {
                            float single153 = 6f;
                            if (this.type == 285 || this.type == 286)
                            {
                                single153 = 8f;
                            }
                            if (this.type == 281 || this.type == 282)
                            {
                                single153 = 4f;
                            }
                            Vector2 vector272 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y);
                            float x62 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector272.X;
                            float y58 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector272.Y;
                            if (this.type == 283 || this.type == 284)
                            {
                                x62 = x62 + (float)Main.rand.Next(-30, 31);
                                y58 = y58 + (float)Main.rand.Next(-30, 31);
                                x62 = x62 - Main.player[this.target].velocity.X * 10f;
                                y58 = y58 - Main.player[this.target].velocity.Y * 10f;
                            }
                            float single154 = (float)Math.Sqrt((double)(x62 * x62 + y58 * y58));
                            single154 = single153 / single154;
                            x62 = x62 * single154;
                            y58 = y58 * single154;
                            int num293 = 30;
                            int num294 = 290;
                            if (this.type == 285 || this.type == 286)
                            {
                                num294 = 291;
                                num293 = 40;
                            }
                            if (this.type == 281 || this.type == 282)
                            {
                                num294 = 293;
                                num293 = 40;
                            }
                            if (Main.expertMode)
                            {
                                num293 = (int)((double)num293 * 0.8);
                            }
                            int num295 = Projectile.NewProjectile(vector272.X, vector272.Y, x62, y58, num294, num293, 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num295].timeLeft = 300;
                            if (num294 == 291)
                            {
                                Main.projectile[num295].ai[0] = Main.player[this.target].Center.X;
                                Main.projectile[num295].ai[1] = Main.player[this.target].Center.Y;
                                Main.projectile[num295].netUpdate = true;
                            }
                            this.localAI[0] = 0f;
                        }
                    }
                }
                if (this.type == 29 || this.type == 45)
                {
                    if (Main.rand.Next(5) == 0)
                    {
                        return;
                    }
                }
                else if (this.type != 32)
                {
                    if (this.type == 172)
                    {
                        int num299 = 1;
                        if (this.alpha == 255)
                        {
                            num299 = 2;
                        }
                        return;
                    }
                    if (this.type == 283 || this.type == 284)
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            return;
                        }
                    }
                    else if (this.type == 285 || this.type == 286)
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            return;
                        }
                    }
                    else if (this.type != 281 && this.type != 282)
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            return;
                        }
                    }
                    else if (Main.rand.Next(2) == 0)
                    {
                        return;
                    }
                }
                else if (Main.rand.Next(3) != 0)
                {
                    return;
                }
            }
            else if (this.aiStyle == 9)
            {
                if (this.type == 516)
                {
                    if (this.alpha < 220)
                    {
                        NPC nPC82 = this;
                        nPC82.alpha = nPC82.alpha + 40;
                    }
                    if (this.ai[0] == 0f)
                    {
                        this.ai[0] = 1f;
                        Vector2 unitY1 = Main.player[this.target].Center - base.Center;
                        unitY1.Normalize();
                        if (unitY1.HasNaNs())
                        {
                            unitY1 = -Vector2.UnitY;
                        }
                        Vector2 vector280 = unitY1.RotatedByRandom(1.57079637050629);
                        vector24 = new Vector2();
                        unitY1 = vector280.RotatedBy(-0.785398185253143, vector24);
                        if (unitY1.Y > 0.2f)
                        {
                            unitY1.Y = 0.2f;
                        }
                        this.velocity = unitY1 * (6f + Main.rand.NextFloat() * 4f);
                    }
                    if (this.collideX || this.collideY || base.Distance(Main.player[this.target].Center) < 20f)
                    {
                        this.StrikeNPCNoInteraction(9999, 0f, this.direction, false, false, false);
                    }
                }
                if (this.target == 255)
                {
                    this.TargetClosest(true);
                    float single155 = 6f;
                    if (this.type == 25)
                    {
                        single155 = 5f;
                    }
                    if (this.type == 112)
                    {
                        single155 = 7f;
                    }
                    Vector2 vector281 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x63 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector281.X;
                    float y59 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector281.Y;
                    float single156 = (float)Math.Sqrt((double)(x63 * x63 + y59 * y59));
                    single156 = single155 / single156;
                    this.velocity.X = x63 * single156;
                    this.velocity.Y = y59 * single156;
                }
                if (this.type == 112)
                {
                    this.ai[0] = this.ai[0] + 1f;
                    if (this.ai[0] > 3f)
                    {
                        this.ai[0] = 3f;
                    }
                    if (this.ai[0] == 2f)
                    {
                        NPC nPC83 = this;
                        nPC83.position = nPC83.position + this.velocity;
                    }
                }
                if (this.type == 112 && Collision.SolidCollision(this.position, this.width, this.height))
                {
                    int num321 = Main.netMode;
                    this.StrikeNPCNoInteraction(999, 0f, 0, false, false, false);
                }
                if (this.timeLeft > 100)
                {
                    this.timeLeft = 100;
                }
                if (this.type != 516)
                {
                    for (int y210 = 0; y210 < 2; y210++)
                    {
                        if (this.type == 30)
                        {
                            this.alpha = 255;
                        }

                        else if (this.type != 112)
                        {
                        }

                    }
                    NPC nPC84 = this;
                    nPC84.rotation = nPC84.rotation + 0.4f * (float)this.direction;
                    return;
                }
                NPC nPC85 = this;
                nPC85.rotation = nPC85.rotation + 0.1f * (float)this.direction;
                float single157 = 15f;
                float single158 = 0.0833333358f;
                Vector2 center22 = base.Center;
                Vector2 center23 = Main.player[this.target].Center;
                Vector2 vector288 = center23 - center22;
                vector288.Normalize();
                if (vector288.HasNaNs())
                {
                    vector288 = new Vector2((float)this.direction, 0f);
                }
                this.velocity = ((this.velocity * (single157 - 1f)) + (vector288 * (this.velocity.Length() + single158))) / single157;
                if (this.velocity.Length() < 6f)
                {
                    NPC nPC86 = this;
                    nPC86.velocity = nPC86.velocity * 1.05f;
                    return;
                }
            }
            else if (this.aiStyle == 10)
            {
                float single159 = 1f;
                float single160 = 0.011f;
                this.TargetClosest(true);
                Vector2 vector289 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float x65 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector289.X;
                float y61 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector289.Y;
                float single161 = (float)Math.Sqrt((double)(x65 * x65 + y61 * y61));
                float single162 = single161;
                this.ai[1] = this.ai[1] + 1f;
                if (this.ai[1] > 600f)
                {
                    single160 = single160 * 8f;
                    single159 = 4f;
                    if (this.ai[1] > 650f)
                    {
                        this.ai[1] = 0f;
                    }
                }
                else if (single162 < 250f)
                {
                    this.ai[0] = this.ai[0] + 0.9f;
                    if (this.ai[0] <= 0f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.019f;
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y + 0.019f;
                    }
                    if (this.ai[0] < -100f || this.ai[0] > 100f)
                    {
                        this.velocity.X = this.velocity.X + 0.019f;
                    }
                    else
                    {
                        this.velocity.X = this.velocity.X - 0.019f;
                    }
                    if (this.ai[0] > 200f)
                    {
                        this.ai[0] = -200f;
                    }
                }
                if (single162 > 350f)
                {
                    single159 = 5f;
                    single160 = 0.3f;
                }
                else if (single162 > 300f)
                {
                    single159 = 3f;
                    single160 = 0.2f;
                }
                else if (single162 > 250f)
                {
                    single159 = 1.5f;
                    single160 = 0.1f;
                }
                single161 = single159 / single161;
                x65 = x65 * single161;
                y61 = y61 * single161;
                if (Main.player[this.target].dead)
                {
                    x65 = (float)this.direction * single159 / 2f;
                    y61 = -single159 / 2f;
                }
                if (this.velocity.X < x65)
                {
                    this.velocity.X = this.velocity.X + single160;
                }
                else if (this.velocity.X > x65)
                {
                    this.velocity.X = this.velocity.X - single160;
                }
                if (this.velocity.Y < y61)
                {
                    this.velocity.Y = this.velocity.Y + single160;
                }
                else if (this.velocity.Y > y61)
                {
                    this.velocity.Y = this.velocity.Y - single160;
                }
                if (x65 > 0f)
                {
                    this.spriteDirection = -1;
                    this.rotation = (float)Math.Atan2((double)y61, (double)x65);
                }
                if (x65 < 0f)
                {
                    this.spriteDirection = 1;
                    this.rotation = (float)Math.Atan2((double)y61, (double)x65) + 3.14f;
                }
                if (this.type == 289)
                {
                    if (this.justHit)
                    {
                        this.ai[2] = 0f;
                        this.ai[3] = 0f;
                    }
                    vector289 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    x65 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector289.X;
                    y61 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector289.Y;
                    single161 = (float)Math.Sqrt((double)(x65 * x65 + y61 * y61));
                    if (single161 > 500f)
                    {
                        this.ai[2] = 0f;
                        this.ai[3] = 0f;
                        return;
                    }
                    this.ai[2] = this.ai[2] + 1f;
                    if (this.ai[3] != 0f)
                    {
                        if (this.ai[2] > 40f)
                        {
                            this.ai[3] = 0f;
                        }
                        if (Main.netMode != 1 && this.ai[2] == 20f)
                        {
                            float single163 = 6f;
                            int num335 = 25;
                            int num336 = 299;
                            single161 = single163 / single161;
                            x65 = x65 * single161;
                            y61 = y61 * single161;
                            Projectile.NewProjectile(vector289.X, vector289.Y, x65, y61, num336, num335, 0f, Main.myPlayer, 0f, 0f);
                            return;
                        }
                    }
                    else if (this.ai[2] > 120f)
                    {
                        this.ai[2] = 0f;
                        this.ai[3] = 1f;
                        this.netUpdate = true;
                        return;
                    }
                }
            }
            else if (this.aiStyle == 11)
            {
                this.defense = this.defDefense;
                if (this.ai[0] == 0f && Main.netMode != 1)
                {
                    this.TargetClosest(true);
                    this.ai[0] = 1f;
                    if (this.type != 68)
                    {
                        int num337 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 36, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        Main.npc[num337].ai[0] = -1f;
                        Main.npc[num337].ai[1] = (float)this.whoAmI;
                        Main.npc[num337].target = this.target;
                        Main.npc[num337].netUpdate = true;
                        num337 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 36, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        Main.npc[num337].ai[0] = 1f;
                        Main.npc[num337].ai[1] = (float)this.whoAmI;
                        Main.npc[num337].ai[3] = 150f;
                        Main.npc[num337].target = this.target;
                        Main.npc[num337].netUpdate = true;
                    }
                }
                if (this.type == 68 && this.ai[1] != 3f && this.ai[1] != 2f)
                {
                    this.ai[1] = 2f;
                }
                if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                {
                    this.TargetClosest(true);
                    if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                    {
                        this.ai[1] = 3f;
                    }
                }
                if (Main.dayTime && this.ai[1] != 3f && this.ai[1] != 2f)
                {
                    this.ai[1] = 2f;
                }
                int num338 = 0;
                if (Main.expertMode)
                {
                    for (int c2 = 0; c2 < 200; c2++)
                    {
                        if (Main.npc[c2].active && Main.npc[c2].type == this.type + 1)
                        {
                            num338++;
                        }
                    }
                    NPC nPC87 = this;
                    nPC87.defense = nPC87.defense + num338 * 25;
                    if ((num338 < 2 || (double)this.life < (double)this.lifeMax * 0.75) && this.ai[1] == 0f)
                    {
                        float single164 = 80f;
                        if (num338 == 0)
                        {
                            single164 = single164 / 2f;
                        }
                        if (Main.netMode != 1 && this.ai[2] % single164 == 0f)
                        {
                            Vector2 center24 = base.Center;
                            float x66 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - center24.X;
                            float y62 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - center24.Y;
                            Math.Sqrt((double)(x66 * x66 + y62 * y62));
                            if (Collision.CanHit(center24, 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float single165 = 3f;
                                if (num338 == 0)
                                {
                                    single165 = single165 + 2f;
                                }
                                float x67 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - center24.X + (float)Main.rand.Next(-20, 21);
                                float y63 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - center24.Y + (float)Main.rand.Next(-20, 21);
                                float single166 = (float)Math.Sqrt((double)(x67 * x67 + y63 * y63));
                                single166 = single165 / single166;
                                x67 = x67 * single166;
                                y63 = y63 * single166;
                                Vector2 vector290 = new Vector2(x67 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f, y63 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f);
                                vector290.Normalize();
                                vector290 = vector290 * single165;
                                vector290 = vector290 + this.velocity;
                                x67 = vector290.X;
                                y63 = vector290.Y;
                                int num339 = 17;
                                int num340 = 270;
                                center24 = center24 + (vector290 * 5f);
                                int num341 = Projectile.NewProjectile(center24.X, center24.Y, x67, y63, num340, num339, 0f, Main.myPlayer, -1f, 0f);
                                Main.projectile[num341].timeLeft = 300;
                            }
                        }
                    }
                }
                if (this.ai[1] == 0f)
                {
                    this.damage = this.defDamage;
                    this.ai[2] = this.ai[2] + 1f;
                    if (this.ai[2] >= 800f)
                    {
                        this.ai[2] = 0f;
                        this.ai[1] = 1f;
                        this.TargetClosest(true);
                        this.netUpdate = true;
                    }
                    this.rotation = this.velocity.X / 15f;
                    float single167 = 0.02f;
                    float single168 = 2f;
                    float single169 = 0.05f;
                    float single170 = 8f;
                    if (Main.expertMode)
                    {
                        single167 = 0.03f;
                        single168 = 4f;
                        single169 = 0.07f;
                        single170 = 9.5f;
                    }
                    if (this.position.Y > Main.player[this.target].position.Y - 250f)
                    {
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.98f;
                        }
                        this.velocity.Y = this.velocity.Y - single167;
                        if (this.velocity.Y > single168)
                        {
                            this.velocity.Y = single168;
                        }
                    }
                    else if (this.position.Y < Main.player[this.target].position.Y - 250f)
                    {
                        if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.98f;
                        }
                        this.velocity.Y = this.velocity.Y + single167;
                        if (this.velocity.Y < -single168)
                        {
                            this.velocity.Y = -single168;
                        }
                    }
                    if (this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))
                    {
                        if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.98f;
                        }
                        this.velocity.X = this.velocity.X - single169;
                        if (this.velocity.X > single170)
                        {
                            this.velocity.X = single170;
                        }
                    }
                    if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))
                    {
                        if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.98f;
                        }
                        this.velocity.X = this.velocity.X + single169;
                        if (this.velocity.X < -single170)
                        {
                            this.velocity.X = -single170;
                        }
                    }
                }
                else if (this.ai[1] == 1f)
                {
                    NPC nPC88 = this;
                    nPC88.defense = nPC88.defense - 10;
                    this.ai[2] = this.ai[2] + 1f;
                    if (this.ai[2] >= 400f)
                    {
                        this.ai[2] = 0f;
                        this.ai[1] = 0f;
                    }
                    NPC nPC89 = this;
                    nPC89.rotation = nPC89.rotation + (float)this.direction * 0.3f;
                    Vector2 vector291 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x68 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector291.X;
                    float y64 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector291.Y;
                    float single171 = (float)Math.Sqrt((double)(x68 * x68 + y64 * y64));
                    float single172 = 1.5f;
                    if (Main.expertMode)
                    {
                        this.damage = (int)((double)this.defDamage * 1.3);
                        single172 = 4f;
                        if (single171 > 150f)
                        {
                            single172 = single172 * 1.05f;
                        }
                        if (single171 > 200f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 250f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 300f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 350f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 400f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 450f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 500f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 550f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (single171 > 600f)
                        {
                            single172 = single172 * 1.1f;
                        }
                        if (num338 == 0)
                        {
                            single172 = single172 * 1.2f;
                        }
                        else if (num338 == 1)
                        {
                            single172 = single172 * 1.1f;
                        }
                    }
                    single171 = single172 / single171;
                    this.velocity.X = x68 * single171;
                    this.velocity.Y = y64 * single171;
                }
                else if (this.ai[1] == 2f)
                {
                    this.damage = 1000;
                    this.defense = 9999;
                    NPC nPC90 = this;
                    nPC90.rotation = nPC90.rotation + (float)this.direction * 0.3f;
                    Vector2 vector292 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x69 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector292.X;
                    float y65 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector292.Y;
                    float single173 = (float)Math.Sqrt((double)(x69 * x69 + y65 * y65));
                    single173 = 8f / single173;
                    this.velocity.X = x69 * single173;
                    this.velocity.Y = y65 * single173;
                }
                else if (this.ai[1] == 3f)
                {
                    this.velocity.Y = this.velocity.Y + 0.1f;
                    if (this.velocity.Y < 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.X = this.velocity.X * 0.95f;
                    if (this.timeLeft > 50)
                    {
                        this.timeLeft = 50;
                    }
                }
                if (this.ai[1] != 2f && this.ai[1] != 3f && this.type != 68)
                {
                    if (num338 == 0 && Main.expertMode)
                    {
                        return;
                    }
                    return;
                }
            }
            else if (this.aiStyle == 12)
            {
                this.spriteDirection = -(int)this.ai[0];
                if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 11)
                {
                    this.ai[2] = this.ai[2] + 10f;
                    if (this.ai[2] > 50f || Main.netMode != 2)
                    {
                        this.life = -1;
                        this.HitEffect(0, 10);
                        this.active = false;
                    }
                }
                if (this.ai[2] == 0f || this.ai[2] == 3f)
                {
                    if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                    if (Main.npc[(int)this.ai[1]].ai[1] == 0f)
                    {
                        this.ai[3] = this.ai[3] + 1f;
                        if (Main.expertMode)
                        {
                            this.ai[3] = this.ai[3] + 0.5f;
                        }
                        if (this.ai[3] >= 300f)
                        {
                            this.ai[2] = this.ai[2] + 1f;
                            this.ai[3] = 0f;
                            this.netUpdate = true;
                        }
                        if (Main.expertMode)
                        {
                            if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 230f)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.04f;
                                if (this.velocity.Y > 3f)
                                {
                                    this.velocity.Y = 3f;
                                }
                            }
                            else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 230f)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.04f;
                                if (this.velocity.Y < -3f)
                                {
                                    this.velocity.Y = -3f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X - 0.07f;
                                if (this.velocity.X > 8f)
                                {
                                    this.velocity.X = 8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X + 0.07f;
                                if (this.velocity.X < -8f)
                                {
                                    this.velocity.X = -8f;
                                }
                            }
                        }
                        if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 230f)
                        {
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if (this.velocity.Y > 3f)
                            {
                                this.velocity.Y = 3f;
                            }
                        }
                        else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 230f)
                        {
                            if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if (this.velocity.Y < -3f)
                            {
                                this.velocity.Y = -3f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                        {
                            if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X - 0.07f;
                            if (this.velocity.X > 8f)
                            {
                                this.velocity.X = 8f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X + 0.07f;
                            if (this.velocity.X < -8f)
                            {
                                this.velocity.X = -8f;
                            }
                        }
                    }
                    else
                    {
                        if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                        {
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y - 0.07f;
                            if (this.velocity.Y > 6f)
                            {
                                this.velocity.Y = 6f;
                            }
                        }
                        else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                        {
                            if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y + 0.07f;
                            if (this.velocity.Y < -6f)
                            {
                                this.velocity.Y = -6f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                        {
                            if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 8f)
                            {
                                this.velocity.X = 8f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -8f)
                            {
                                this.velocity.X = -8f;
                            }
                        }
                    }
                    Vector2 vector295 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x71 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector295.X;
                    float y67 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector295.Y;
                    Math.Sqrt((double)(x71 * x71 + y67 * y67));
                    this.rotation = (float)Math.Atan2((double)y67, (double)x71) + 1.57f;
                    return;
                }
                if (this.ai[2] == 1f)
                {
                    Vector2 vector296 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x72 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector296.X;
                    float y68 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector296.Y;
                    float single174 = (float)Math.Sqrt((double)(x72 * x72 + y68 * y68));
                    this.rotation = (float)Math.Atan2((double)y68, (double)x72) + 1.57f;
                    this.velocity.X = this.velocity.X * 0.95f;
                    this.velocity.Y = this.velocity.Y - 0.1f;
                    if (Main.expertMode)
                    {
                        this.velocity.Y = this.velocity.Y - 0.06f;
                        if (this.velocity.Y < -13f)
                        {
                            this.velocity.Y = -13f;
                        }
                    }
                    else if (this.velocity.Y < -8f)
                    {
                        this.velocity.Y = -8f;
                    }
                    if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 200f)
                    {
                        this.TargetClosest(true);
                        this.ai[2] = 2f;
                        vector296 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        x72 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector296.X;
                        y68 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector296.Y;
                        single174 = (float)Math.Sqrt((double)(x72 * x72 + y68 * y68));
                        single174 = (!Main.expertMode ? 18f / single174 : 21f / single174);
                        this.velocity.X = x72 * single174;
                        this.velocity.Y = y68 * single174;
                        this.netUpdate = true;
                        return;
                    }
                }
                else if (this.ai[2] == 2f)
                {
                    if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f)
                    {
                        this.ai[2] = 3f;
                        return;
                    }
                }
                else if (this.ai[2] == 4f)
                {
                    Vector2 vector297 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x73 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector297.X;
                    float y69 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector297.Y;
                    float single175 = (float)Math.Sqrt((double)(x73 * x73 + y69 * y69));
                    this.rotation = (float)Math.Atan2((double)y69, (double)x73) + 1.57f;
                    this.velocity.Y = this.velocity.Y * 0.95f;
                    this.velocity.X = this.velocity.X + 0.1f * -this.ai[0];
                    if (Main.expertMode)
                    {
                        this.velocity.X = this.velocity.X + 0.07f * -this.ai[0];
                        if (this.velocity.X < -12f)
                        {
                            this.velocity.X = -12f;
                        }
                        else if (this.velocity.X > 12f)
                        {
                            this.velocity.X = 12f;
                        }
                    }
                    else if (this.velocity.X < -8f)
                    {
                        this.velocity.X = -8f;
                    }
                    else if (this.velocity.X > 8f)
                    {
                        this.velocity.X = 8f;
                    }
                    if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 500f || this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 500f)
                    {
                        this.TargetClosest(true);
                        this.ai[2] = 5f;
                        vector297 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        x73 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector297.X;
                        y69 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector297.Y;
                        single175 = (float)Math.Sqrt((double)(x73 * x73 + y69 * y69));
                        single175 = (!Main.expertMode ? 17f / single175 : 22f / single175);
                        this.velocity.X = x73 * single175;
                        this.velocity.Y = y69 * single175;
                        this.netUpdate = true;
                        return;
                    }
                }
                else if (this.ai[2] == 5f && (this.velocity.X > 0f && this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) || this.velocity.X < 0f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)))
                {
                    this.ai[2] = 0f;
                    return;
                }
            }
            else if (this.aiStyle == 13)
            {
                if (this.ai[0] < 0f || this.ai[0] >= (float)Main.maxTilesX || this.ai[1] < 0f || this.ai[1] >= (float)Main.maxTilesX)
                {
                    return;
                }
                if (Main.tile[(int)this.ai[0], (int)this.ai[1]] == null)
                {
                    Main.tile[(int)this.ai[0], (int)this.ai[1]] = new Tile();
                }
                if (!Main.tile[(int)this.ai[0], (int)this.ai[1]].active())
                {
                    this.life = -1;
                    this.HitEffect(0, 10);
                    this.active = false;
                    return;
                }
                this.TargetClosest(true);
                float single176 = 0.035f;
                float single177 = 150f;
                if (this.type == 43)
                {
                    single177 = 250f;
                }
                if (this.type == 101)
                {
                    single177 = 175f;
                }
                if (this.type == 259)
                {
                    single177 = 100f;
                }
                if (this.type == 175)
                {
                    single177 = 500f;
                    single176 = 0.05f;
                }
                if (this.type == 260)
                {
                    single177 = 350f;
                    single176 = 0.15f;
                }
                this.ai[2] = this.ai[2] + 1f;
                if (this.ai[2] > 300f)
                {
                    single177 = (float)((int)((double)single177 * 1.3));
                    if (this.ai[2] > 450f)
                    {
                        this.ai[2] = 0f;
                    }
                }
                Vector2 vector298 = new Vector2(this.ai[0] * 16f + 8f, this.ai[1] * 16f + 8f);
                float x74 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - (float)(this.width / 2) - vector298.X;
                float y70 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - (float)(this.height / 2) - vector298.Y;
                float single178 = (float)Math.Sqrt((double)(x74 * x74 + y70 * y70));
                if (single178 > single177)
                {
                    single178 = single177 / single178;
                    x74 = x74 * single178;
                    y70 = y70 * single178;
                }
                if (this.position.X < this.ai[0] * 16f + 8f + x74)
                {
                    this.velocity.X = this.velocity.X + single176;
                    if (this.velocity.X < 0f && x74 > 0f)
                    {
                        this.velocity.X = this.velocity.X + single176 * 1.5f;
                    }
                }
                else if (this.position.X > this.ai[0] * 16f + 8f + x74)
                {
                    this.velocity.X = this.velocity.X - single176;
                    if (this.velocity.X > 0f && x74 < 0f)
                    {
                        this.velocity.X = this.velocity.X - single176 * 1.5f;
                    }
                }
                if (this.position.Y < this.ai[1] * 16f + 8f + y70)
                {
                    this.velocity.Y = this.velocity.Y + single176;
                    if (this.velocity.Y < 0f && y70 > 0f)
                    {
                        this.velocity.Y = this.velocity.Y + single176 * 1.5f;
                    }
                }
                else if (this.position.Y > this.ai[1] * 16f + 8f + y70)
                {
                    this.velocity.Y = this.velocity.Y - single176;
                    if (this.velocity.Y > 0f && y70 < 0f)
                    {
                        this.velocity.Y = this.velocity.Y - single176 * 1.5f;
                    }
                }
                if (this.type == 43)
                {
                    if (this.velocity.X > 3f)
                    {
                        this.velocity.X = 3f;
                    }
                    if (this.velocity.X < -3f)
                    {
                        this.velocity.X = -3f;
                    }
                    if (this.velocity.Y > 3f)
                    {
                        this.velocity.Y = 3f;
                    }
                    if (this.velocity.Y < -3f)
                    {
                        this.velocity.Y = -3f;
                    }
                }
                else if (this.type != 175)
                {
                    if (this.velocity.X > 2f)
                    {
                        this.velocity.X = 2f;
                    }
                    if (this.velocity.X < -2f)
                    {
                        this.velocity.X = -2f;
                    }
                    if (this.velocity.Y > 2f)
                    {
                        this.velocity.Y = 2f;
                    }
                    if (this.velocity.Y < -2f)
                    {
                        this.velocity.Y = -2f;
                    }
                }
                else
                {
                    if (this.velocity.X > 4f)
                    {
                        this.velocity.X = 4f;
                    }
                    if (this.velocity.X < -4f)
                    {
                        this.velocity.X = -4f;
                    }
                    if (this.velocity.Y > 4f)
                    {
                        this.velocity.Y = 4f;
                    }
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                }
                if (this.type == 259 || this.type == 260)
                {
                    this.rotation = (float)Math.Atan2((double)y70, (double)x74) + 1.57f;
                }
                else
                {
                    if (x74 > 0f)
                    {
                        this.spriteDirection = 1;
                        this.rotation = (float)Math.Atan2((double)y70, (double)x74);
                    }
                    if (x74 < 0f)
                    {
                        this.spriteDirection = -1;
                        this.rotation = (float)Math.Atan2((double)y70, (double)x74) + 3.14f;
                    }
                }
                if (this.collideX)
                {
                    this.netUpdate = true;
                    this.velocity.X = this.oldVelocity.X * -0.7f;
                    if (this.velocity.X > 0f && this.velocity.X < 2f)
                    {
                        this.velocity.X = 2f;
                    }
                    if (this.velocity.X < 0f && this.velocity.X > -2f)
                    {
                        this.velocity.X = -2f;
                    }
                }
                if (this.collideY)
                {
                    this.netUpdate = true;
                    this.velocity.Y = this.oldVelocity.Y * -0.7f;
                    if (this.velocity.Y > 0f && this.velocity.Y < 2f)
                    {
                        this.velocity.Y = 2f;
                    }
                    if (this.velocity.Y < 0f && this.velocity.Y > -2f)
                    {
                        this.velocity.Y = -2f;
                    }
                }
                if (Main.netMode != 1)
                {
                    if (this.type == 101 && !Main.player[this.target].dead)
                    {
                        if (this.justHit)
                        {
                            this.localAI[0] = 0f;
                        }
                        this.localAI[0] = this.localAI[0] + 1f;
                        if (this.localAI[0] >= 120f)
                        {
                            if (Collision.SolidCollision(this.position, this.width, this.height) || !Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                this.localAI[0] = 100f;
                            }
                            else
                            {
                                float single179 = 10f;
                                vector298 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                x74 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector298.X + (float)Main.rand.Next(-10, 11);
                                y70 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector298.Y + (float)Main.rand.Next(-10, 11);
                                single178 = (float)Math.Sqrt((double)(x74 * x74 + y70 * y70));
                                single178 = single179 / single178;
                                x74 = x74 * single178;
                                y70 = y70 * single178;
                                int num344 = 22;
                                if (Main.expertMode)
                                {
                                    num344 = (int)((double)num344 * 0.8);
                                }
                                int num345 = 96;
                                int num346 = Projectile.NewProjectile(vector298.X, vector298.Y, x74, y70, num345, num344, 0f, Main.myPlayer, 0f, 0f);
                                Main.projectile[num346].timeLeft = 300;
                                this.localAI[0] = 0f;
                            }
                        }
                    }
                    if (this.type == 260 && !Main.player[this.target].dead)
                    {
                        if (this.justHit)
                        {
                            this.localAI[0] = 0f;
                        }
                        this.localAI[0] = this.localAI[0] + 1f;
                        if (this.localAI[0] >= 150f)
                        {
                            if (Collision.SolidCollision(this.position, this.width, this.height))
                            {
                                this.localAI[0] = 250f;
                                return;
                            }
                            float single180 = 14f;
                            vector298 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            x74 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector298.X + (float)Main.rand.Next(-10, 11);
                            float single181 = Math.Abs(x74 * 0.1f);
                            if (y70 > 0f)
                            {
                                single181 = 0f;
                            }
                            y70 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector298.Y + (float)Main.rand.Next(-10, 11) - single181;
                            single178 = (float)Math.Sqrt((double)(x74 * x74 + y70 * y70));
                            single178 = single180 / single178;
                            x74 = x74 * single178;
                            y70 = y70 * single178;
                            int num347 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 261, 0, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num347].velocity.X = x74;
                            Main.npc[num347].velocity.Y = y70;
                            Main.npc[num347].netUpdate = true;
                            this.localAI[0] = 0f;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 14)
            {
                this.noGravity = true;
                if (this.collideX)
                {
                    this.velocity.X = this.oldVelocity.X * -0.5f;
                    if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                    {
                        this.velocity.X = 2f;
                    }
                    if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                    {
                        this.velocity.X = -2f;
                    }
                }
                if (this.collideY)
                {
                    this.velocity.Y = this.oldVelocity.Y * -0.5f;
                    if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                    {
                        this.velocity.Y = 1f;
                    }
                    if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                    {
                        this.velocity.Y = -1f;
                    }
                }
                if (this.type != 226)
                {
                    this.TargetClosest(true);
                }
                else
                {
                    int num354 = 1;
                    int num355 = 1;
                    if (this.velocity.X < 0f)
                    {
                        num354 = -1;
                    }
                    if (this.velocity.Y < 0f)
                    {
                        num355 = -1;
                    }
                    this.TargetClosest(true);
                    if (!Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.direction = num354;
                        this.directionY = num355;
                    }
                }
                if (this.type == 158)
                {
                    if ((double)this.position.Y < Main.worldSurface * 16 && Main.dayTime && !Main.eclipse)
                    {
                        this.directionY = -1;
                        NPC nPC91 = this;
                        nPC91.direction = nPC91.direction * -1;
                    }
                    if (this.direction == -1 && this.velocity.X > -7f)
                    {
                        this.velocity.X = this.velocity.X - 0.2f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -7f)
                        {
                            this.velocity.X = -7f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 7f)
                    {
                        this.velocity.X = this.velocity.X + 0.2f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 7f)
                        {
                            this.velocity.X = 7f;
                        }
                    }
                    if (this.directionY == -1 && this.velocity.Y > -7f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.2f;
                        if (this.velocity.Y > 4f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.1f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        if (this.velocity.Y < -7f)
                        {
                            this.velocity.Y = -7f;
                        }
                    }
                    else if (this.directionY == 1 && this.velocity.Y < 7f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.2f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.1f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        if (this.velocity.Y > 7f)
                        {
                            this.velocity.Y = 7f;
                        }
                    }
                }
                else if (this.type != 226)
                {
                    if (this.direction == -1 && this.velocity.X > -4f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 4f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if ((double)this.velocity.Y > 1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if ((double)this.velocity.Y < -1.5)
                        {
                            this.velocity.Y = -1.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if ((double)this.velocity.Y < -1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if ((double)this.velocity.Y > 1.5)
                        {
                            this.velocity.Y = 1.5f;
                        }
                    }
                }
                else
                {
                    if (this.direction == -1 && this.velocity.X > -4f)
                    {
                        this.velocity.X = this.velocity.X - 0.2f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 4f)
                    {
                        this.velocity.X = this.velocity.X + 0.2f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -2.5)
                    {
                        this.velocity.Y = this.velocity.Y - 0.1f;
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = -2.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 2.5)
                    {
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = 2.5f;
                        }
                    }
                }
                if (this.type == 49 || this.type == 51 || this.type == 60 || this.type == 62 || this.type == 66 || this.type == 93 || this.type == 137 || this.type == 150 || this.type == 151 || this.type == 152)
                {
                    if (this.wet)
                    {
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.95f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                        this.TargetClosest(true);
                    }
                    if (this.type != 60)
                    {
                        if (this.direction == -1 && this.velocity.X > -4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.05f;
                            }
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = -4f;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < 4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.05f;
                            }
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = 4f;
                            }
                        }
                        if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = this.velocity.Y - 0.05f;
                            }
                            else if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = -1.5f;
                            }
                        }
                        else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = this.velocity.Y + 0.05f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = 1.5f;
                            }
                        }
                    }
                    else
                    {
                        if (this.direction == -1 && this.velocity.X > -4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = this.velocity.X - 0.07f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.03f;
                            }
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = -4f;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < 4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = this.velocity.X + 0.07f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.03f;
                            }
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = 4f;
                            }
                        }
                        if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            else if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.02f;
                            }
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = -1.5f;
                            }
                        }
                        else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.02f;
                            }
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = 1.5f;
                            }
                        }
                    }
                }
                if (this.type == 158 && Main.netMode != 1)
                {
                    Vector2 vector2101 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x75 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2101.X;
                    float y71 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2101.Y;
                    if ((float)Math.Sqrt((double)(x75 * x75 + y71 * y71)) < 200f && this.position.Y + (float)this.height < Main.player[this.target].position.Y + (float)Main.player[this.target].height && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.Transform(159);
                    }
                }
                this.ai[1] = this.ai[1] + 1f;
                if (this.type == 158)
                {
                    this.ai[1] = this.ai[1] + 1f;
                }
                if (this.ai[1] > 200f)
                {
                    if (!Main.player[this.target].wet && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.ai[1] = 0f;
                    }
                    float single182 = 0.2f;
                    float single183 = 0.1f;
                    float single184 = 4f;
                    float single185 = 1.5f;
                    if (this.type == 48 || this.type == 62 || this.type == 66)
                    {
                        single182 = 0.12f;
                        single183 = 0.07f;
                        single184 = 3f;
                        single185 = 1.25f;
                    }
                    if (this.ai[1] > 1000f)
                    {
                        this.ai[1] = 0f;
                    }
                    this.ai[2] = this.ai[2] + 1f;
                    if (this.ai[2] > 0f)
                    {
                        if (this.velocity.Y < single185)
                        {
                            this.velocity.Y = this.velocity.Y + single183;
                        }
                    }
                    else if (this.velocity.Y > -single185)
                    {
                        this.velocity.Y = this.velocity.Y - single183;
                    }
                    if (this.ai[2] >= -150f && this.ai[2] <= 150f)
                    {
                        if (this.velocity.X > -single184)
                        {
                            this.velocity.X = this.velocity.X - single182;
                        }
                    }
                    else if (this.velocity.X < single184)
                    {
                        this.velocity.X = this.velocity.X + single182;
                    }
                    if (this.ai[2] > 300f)
                    {
                        this.ai[2] = -300f;
                    }
                }
                if (Main.netMode != 1)
                {
                    if (this.type == 48)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                        if (this.ai[0] != 30f && this.ai[0] != 60f && this.ai[0] != 90f)
                        {
                            if (this.ai[0] >= (float)(400 + Main.rand.Next(400)))
                            {
                                this.ai[0] = 0f;
                            }
                        }
                        else if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            float single186 = 6f;
                            Vector2 vector2102 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x76 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2102.X + (float)Main.rand.Next(-100, 101);
                            float y72 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2102.Y + (float)Main.rand.Next(-100, 101);
                            float single187 = (float)Math.Sqrt((double)(x76 * x76 + y72 * y72));
                            single187 = single186 / single187;
                            x76 = x76 * single187;
                            y72 = y72 * single187;
                            int num356 = 15;
                            int num357 = 38;
                            int num358 = Projectile.NewProjectile(vector2102.X, vector2102.Y, x76, y72, num357, num356, 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num358].timeLeft = 300;
                        }
                    }
                    if (this.type == 62 || this.type == 66)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                        if (this.ai[0] != 20f && this.ai[0] != 40f && this.ai[0] != 60f && this.ai[0] != 80f)
                        {
                            if (this.ai[0] >= (float)(300 + Main.rand.Next(300)))
                            {
                                this.ai[0] = 0f;
                            }
                        }
                        else if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            float single188 = 0.2f;
                            Vector2 vector2103 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x77 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2103.X + (float)Main.rand.Next(-100, 101);
                            float y73 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2103.Y + (float)Main.rand.Next(-100, 101);
                            float single189 = (float)Math.Sqrt((double)(x77 * x77 + y73 * y73));
                            single189 = single188 / single189;
                            x77 = x77 * single189;
                            y73 = y73 * single189;
                            int num359 = 21;
                            int num360 = 44;
                            int num361 = Projectile.NewProjectile(vector2103.X, vector2103.Y, x77, y73, num360, num359, 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num361].timeLeft = 300;
                        }
                    }
                    if (this.type == 156)
                    {
                        this.ai[0] = this.ai[0] + 1f;
                        if (this.ai[0] != 20f && this.ai[0] != 40f && this.ai[0] != 60f && this.ai[0] != 80f && this.ai[0] != 100f)
                        {
                            if (this.ai[0] >= (float)(250 + Main.rand.Next(250)))
                            {
                                this.ai[0] = 0f;
                                return;
                            }
                        }
                        else if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            float single190 = 0.2f;
                            Vector2 vector2104 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x78 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2104.X + (float)Main.rand.Next(-50, 51);
                            float y74 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2104.Y + (float)Main.rand.Next(-50, 51);
                            float single191 = (float)Math.Sqrt((double)(x78 * x78 + y74 * y74));
                            single191 = single190 / single191;
                            x78 = x78 * single191;
                            y74 = y74 * single191;
                            int num362 = 80;
                            int num363 = 115;
                            vector2104 = vector2104 + (this.velocity * 5f);
                            int num364 = Projectile.NewProjectile(vector2104.X + x78 * 100f, vector2104.Y + y74 * 100f, x78, y74, num363, num362, 0f, Main.myPlayer, 0f, 0f);
                            Main.projectile[num364].timeLeft = 300;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 15)
            {
                float single192 = 1f;
                bool flag67 = false;
                bool flag68 = false;
                this.aiAction = 0;
                if (this.ai[3] == 0f && this.life > 0)
                {
                    this.ai[3] = (float)this.lifeMax;
                }
                if (this.localAI[3] == 0f && Main.netMode != 1)
                {
                    this.ai[0] = -100f;
                    this.localAI[3] = 1f;
                    this.TargetClosest(true);
                    this.netUpdate = true;
                }
                if (Main.player[this.target].dead)
                {
                    this.TargetClosest(true);
                    if (Main.player[this.target].dead)
                    {
                        this.timeLeft = 0;
                        if (Main.player[this.target].Center.X >= base.Center.X)
                        {
                            this.direction = -1;
                        }
                        else
                        {
                            this.direction = 1;
                        }
                    }
                }
                if (!Main.player[this.target].dead && this.ai[2] >= 300f && this.ai[1] < 5f && this.velocity.Y == 0f)
                {
                    this.ai[2] = 0f;
                    this.ai[0] = 0f;
                    this.ai[1] = 5f;
                    if (Main.netMode != 1)
                    {
                        this.TargetClosest(false);
                        Point point2 = base.Center.ToTileCoordinates();
                        Point tileCoordinates3 = Main.player[this.target].Center.ToTileCoordinates();
                        Vector2 center25 = Main.player[this.target].Center - base.Center;
                        int num365 = 10;
                        int num366 = 0;
                        int num367 = 7;
                        int num368 = 0;
                        bool flag69 = false;
                        if (center25.Length() > 2000f)
                        {
                            flag69 = true;
                            num368 = 100;
                        }
                        while (!flag69 && num368 < 100)
                        {
                            num368++;
                            int num369 = Main.rand.Next(tileCoordinates3.X - num365, tileCoordinates3.X + num365 + 1);
                            int num370 = Main.rand.Next(tileCoordinates3.Y - num365, tileCoordinates3.Y + 1);
                            if (num370 >= tileCoordinates3.Y - num367 && num370 <= tileCoordinates3.Y + num367 && num369 >= tileCoordinates3.X - num367 && num369 <= tileCoordinates3.X + num367 || num370 >= point2.Y - num366 && num370 <= point2.Y + num366 && num369 >= point2.X - num366 && num369 <= point2.X + num366 || Main.tile[num369, num370].nactive())
                            {
                                continue;
                            }
                            int num371 = num370;
                            int num372 = 0;
                            if ((!Main.tile[num369, num371].nactive() || !Main.tileSolid[Main.tile[num369, num371].type] ? true : Main.tileSolidTop[Main.tile[num369, num371].type]))
                            {
                                while (num372 < 150 && num371 + num372 < Main.maxTilesY)
                                {
                                    int num373 = num371 + num372;
                                    if ((!Main.tile[num369, num373].nactive() || !Main.tileSolid[Main.tile[num369, num373].type] ? true : Main.tileSolidTop[Main.tile[num369, num373].type]))
                                    {
                                        num372++;
                                    }
                                    else
                                    {
                                        num372--;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                num372 = 1;
                            }
                            num370 = num370 + num372;
                            bool flag70 = true;
                            if (flag70 && Main.tile[num369, num370].lava())
                            {
                                flag70 = false;
                            }
                            if (flag70 && !Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                            {
                                flag70 = false;
                            }
                            if (!flag70)
                            {
                                continue;
                            }
                            this.localAI[1] = (float)(num369 * 16 + 8);
                            this.localAI[2] = (float)(num370 * 16 + 16);
                            flag69 = true;
                            break;
                        }
                        if (num368 >= 100)
                        {
                            Vector2 bottom = Main.player[Player.FindClosest(this.position, this.width, this.height)].Bottom;
                            this.localAI[1] = bottom.X;
                            this.localAI[2] = bottom.Y;
                        }
                    }
                }
                if (!Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                {
                    this.ai[2] = this.ai[2] + 1f;
                }
                if (Math.Abs(base.Top.Y - Main.player[this.target].Bottom.Y) > 320f)
                {
                    this.ai[2] = this.ai[2] + 1f;
                }
                if (this.ai[1] == 5f)
                {
                    flag67 = true;
                    this.aiAction = 1;
                    this.ai[0] = this.ai[0] + 1f;
                    single192 = MathHelper.Clamp((60f - this.ai[0]) / 60f, 0f, 1f);
                    single192 = 0.5f + single192 * 0.5f;
                    if (this.ai[0] >= 60f)
                    {
                        flag68 = true;
                    }
                    if (this.ai[0] == 60f)
                    {
                    }
                    if (this.ai[0] >= 60f && Main.netMode != 1)
                    {
                        base.Bottom = new Vector2(this.localAI[1], this.localAI[2]);
                        this.ai[1] = 6f;
                        this.ai[0] = 0f;
                        this.netUpdate = true;
                    }
                    if (Main.netMode == 1 && this.ai[0] >= 120f)
                    {
                        this.ai[1] = 6f;
                        this.ai[0] = 0f;
                    }
                    if (!flag68)
                    {
                    }
                }
                else if (this.ai[1] == 6f)
                {
                    flag67 = true;
                    this.aiAction = 0;
                    this.ai[0] = this.ai[0] + 1f;
                    single192 = MathHelper.Clamp(this.ai[0] / 30f, 0f, 1f);
                    single192 = 0.5f + single192 * 0.5f;
                    if (this.ai[0] >= 30f && Main.netMode != 1)
                    {
                        this.ai[1] = 0f;
                        this.ai[0] = 0f;
                        this.netUpdate = true;
                        this.TargetClosest(true);
                    }
                    if (Main.netMode == 1 && this.ai[0] >= 60f)
                    {
                        this.ai[1] = 0f;
                        this.ai[0] = 0f;
                        this.TargetClosest(true);
                    }
                }
                bool flag71 = flag68;
                bool flag72 = flag71;
                this.hide = flag71;
                this.dontTakeDamage = flag72;
                if (this.velocity.Y == 0f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                    }
                    if (!flag67)
                    {
                        this.ai[0] = this.ai[0] + 2f;
                        if ((double)this.life < (double)this.lifeMax * 0.8)
                        {
                            this.ai[0] = this.ai[0] + 1f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.6)
                        {
                            this.ai[0] = this.ai[0] + 1f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.4)
                        {
                            this.ai[0] = this.ai[0] + 2f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.2)
                        {
                            this.ai[0] = this.ai[0] + 3f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.1)
                        {
                            this.ai[0] = this.ai[0] + 4f;
                        }
                        if (this.ai[0] >= 0f)
                        {
                            this.netUpdate = true;
                            this.TargetClosest(true);
                            if (this.ai[1] == 3f)
                            {
                                this.velocity.Y = -13f;
                                this.velocity.X = this.velocity.X + 3.5f * (float)this.direction;
                                this.ai[0] = -200f;
                                this.ai[1] = 0f;
                            }
                            else if (this.ai[1] != 2f)
                            {
                                this.velocity.Y = -8f;
                                this.velocity.X = this.velocity.X + 4f * (float)this.direction;
                                this.ai[0] = -120f;
                                this.ai[1] = this.ai[1] + 1f;
                            }
                            else
                            {
                                this.velocity.Y = -6f;
                                this.velocity.X = this.velocity.X + 4.5f * (float)this.direction;
                                this.ai[0] = -120f;
                                this.ai[1] = this.ai[1] + 1f;
                            }
                        }
                        else if (this.ai[0] >= -30f)
                        {
                            this.aiAction = 1;
                        }
                    }
                }
                else if (this.target < 255 && (this.direction == 1 && this.velocity.X < 3f || this.direction == -1 && this.velocity.X > -3f))
                {
                    if ((this.direction != -1 || (double)this.velocity.X >= 0.1) && (this.direction != 1 || (double)this.velocity.X <= -0.1))
                    {
                        this.velocity.X = this.velocity.X * 0.93f;
                    }
                    else
                    {
                        this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                    }
                }
                if (this.life > 0)
                {
                    float single193 = (float)this.life / (float)this.lifeMax;
                    single193 = single193 * 0.5f + 0.75f;
                    single193 = single193 * single192;
                    if (single193 != this.scale)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)this.height;
                        this.scale = single193;
                        this.width = (int)(98f * this.scale);
                        this.height = (int)(92f * this.scale);
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)this.height;
                    }
                    if (Main.netMode != 1)
                    {
                        int num377 = (int)((double)this.lifeMax * 0.05);
                        if ((float)(this.life + num377) < this.ai[3])
                        {
                            this.ai[3] = (float)this.life;
                            int num378 = Main.rand.Next(1, 4);
                            for (int g2 = 0; g2 < num378; g2++)
                            {
                                int x79 = (int)(this.position.X + (float)Main.rand.Next(this.width - 32));
                                int y75 = (int)(this.position.Y + (float)Main.rand.Next(this.height - 32));
                                int num379 = 1;
                                if (Main.expertMode && Main.rand.Next(4) == 0)
                                {
                                    num379 = 535;
                                }
                                int num380 = NPC.NewNPC(x79, y75, num379, 0, 0f, 0f, 0f, 0f, 255);
                                Main.npc[num380].SetDefaults(num379, -1f);
                                Main.npc[num380].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f;
                                Main.npc[num380].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f;
                                Main.npc[num380].ai[0] = (float)(-1000 * Main.rand.Next(3));
                                Main.npc[num380].ai[1] = 0f;
                                if (Main.netMode == 2 && num380 < 200)
                                {
                                    NetMessage.SendData(23, -1, -1, "", num380, 0f, 0f, 0f, 0, 0, 0);
                                }
                            }
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 16)
            {
                if (this.direction == 0)
                {
                    this.TargetClosest(true);
                }
                if (!this.wet)
                {
                    if (this.velocity.Y == 0f)
                    {
                        if (this.type == 65)
                        {
                            this.velocity.X = this.velocity.X * 0.94f;
                            if ((double)this.velocity.X > -0.2 && (double)this.velocity.X < 0.2)
                            {
                                this.velocity.X = 0f;
                            }
                        }
                        else if (Main.netMode != 1)
                        {
                            this.velocity.Y = (float)Main.rand.Next(-50, -20) * 0.1f;
                            this.velocity.X = (float)Main.rand.Next(-20, 20) * 0.1f;
                            this.netUpdate = true;
                        }
                    }
                    this.velocity.Y = this.velocity.Y + 0.3f;
                    if (this.velocity.Y > 10f)
                    {
                        this.velocity.Y = 10f;
                    }
                    this.ai[0] = 1f;
                }
                else
                {
                    bool flag73 = false;
                    if (this.type != 55)
                    {
                        this.TargetClosest(false);
                        if (Main.player[this.target].wet && !Main.player[this.target].dead)
                        {
                            flag73 = true;
                        }
                    }
                    if (!flag73)
                    {
                        if (this.collideX)
                        {
                            this.velocity.X = this.velocity.X * -1f;
                            NPC nPC92 = this;
                            nPC92.direction = nPC92.direction * -1;
                            this.netUpdate = true;
                        }
                        if (this.collideY)
                        {
                            this.netUpdate = true;
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = Math.Abs(this.velocity.Y) * -1f;
                                this.directionY = -1;
                                this.ai[0] = -1f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = Math.Abs(this.velocity.Y);
                                this.directionY = 1;
                                this.ai[0] = 1f;
                            }
                        }
                    }
                    if (!flag73)
                    {
                        if (this.type != 157)
                        {
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.1f;
                            if (this.velocity.X < -1f || this.velocity.X > 1f)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.ai[0] != -1f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.01f;
                                if ((double)this.velocity.Y > 0.3)
                                {
                                    this.ai[0] = -1f;
                                }
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y - 0.01f;
                                if ((double)this.velocity.Y < -0.3)
                                {
                                    this.ai[0] = 1f;
                                }
                            }
                        }
                        else
                        {
                            if (Main.player[this.target].position.Y <= this.position.Y)
                            {
                                this.directionY = -1;
                            }
                            else
                            {
                                this.directionY = 1;
                            }
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.2f;
                            if (this.velocity.X < -2f || this.velocity.X > 2f)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.ai[0] != -1f)
                            {
                                float single194 = 0.6f;
                                if (this.directionY < 0)
                                {
                                    single194 = 0.2f;
                                }
                                if (this.directionY > 0)
                                {
                                    single194 = 1f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.02f;
                                if (this.velocity.Y > single194)
                                {
                                    this.ai[0] = -1f;
                                }
                            }
                            else
                            {
                                float single195 = -0.6f;
                                if (this.directionY < 0)
                                {
                                    single195 = -1f;
                                }
                                if (this.directionY > 0)
                                {
                                    single195 = -0.2f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.02f;
                                if (this.velocity.Y < single195)
                                {
                                    this.ai[0] = 1f;
                                }
                            }
                        }
                        int x80 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                        int y76 = (int)(this.position.Y + (float)(this.height / 2)) / 16;
                        if (Main.tile[x80, y76 - 1] == null)
                        {
                            Main.tile[x80, y76 - 1] = new Tile();
                        }
                        if (Main.tile[x80, y76 + 1] == null)
                        {
                            Main.tile[x80, y76 + 1] = new Tile();
                        }
                        if (Main.tile[x80, y76 + 2] == null)
                        {
                            Main.tile[x80, y76 + 2] = new Tile();
                        }
                        if (Main.tile[x80, y76 - 1].liquid > 128)
                        {
                            if (Main.tile[x80, y76 + 1].active())
                            {
                                this.ai[0] = -1f;
                            }
                            else if (Main.tile[x80, y76 + 2].active())
                            {
                                this.ai[0] = -1f;
                            }
                        }
                        if (this.type != 157 && ((double)this.velocity.Y > 0.4 || (double)this.velocity.Y < -0.4))
                        {
                            this.velocity.Y = this.velocity.Y * 0.95f;
                        }
                    }
                    else
                    {
                        this.TargetClosest(true);
                        if (this.type == 157)
                        {
                            if (this.velocity.X > 0f && this.direction < 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.velocity.X < 0f && this.direction > 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.25f;
                            this.velocity.Y = this.velocity.Y + (float)this.directionY * 0.2f;
                            if (this.velocity.X > 8f)
                            {
                                this.velocity.X = 7f;
                            }
                            if (this.velocity.X < -8f)
                            {
                                this.velocity.X = -7f;
                            }
                            if (this.velocity.Y > 5f)
                            {
                                this.velocity.Y = 4f;
                            }
                            if (this.velocity.Y < -5f)
                            {
                                this.velocity.Y = -4f;
                            }
                        }
                        else if (this.type == 65 || this.type == 102)
                        {
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.15f;
                            this.velocity.Y = this.velocity.Y + (float)this.directionY * 0.15f;
                            if (this.velocity.X > 5f)
                            {
                                this.velocity.X = 5f;
                            }
                            if (this.velocity.X < -5f)
                            {
                                this.velocity.X = -5f;
                            }
                            if (this.velocity.Y > 3f)
                            {
                                this.velocity.Y = 3f;
                            }
                            if (this.velocity.Y < -3f)
                            {
                                this.velocity.Y = -3f;
                            }
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.1f;
                            this.velocity.Y = this.velocity.Y + (float)this.directionY * 0.1f;
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = 3f;
                            }
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = -3f;
                            }
                            if (this.velocity.Y > 2f)
                            {
                                this.velocity.Y = 2f;
                            }
                            if (this.velocity.Y < -2f)
                            {
                                this.velocity.Y = -2f;
                            }
                        }
                    }
                }
                this.rotation = this.velocity.Y * (float)this.direction * 0.1f;
                if ((double)this.rotation < -0.2)
                {
                    this.rotation = -0.2f;
                }
                if ((double)this.rotation > 0.2)
                {
                    this.rotation = 0.2f;
                    return;
                }
            }
            else if (this.aiStyle == 17)
            {
                this.noGravity = true;
                if (this.ai[0] == 0f)
                {
                    this.noGravity = false;
                    this.TargetClosest(true);
                    if (Main.netMode != 1)
                    {
                        if (this.velocity.X != 0f || this.velocity.Y < 0f || (double)this.velocity.Y > 0.3)
                        {
                            this.ai[0] = 1f;
                            this.netUpdate = true;
                        }
                        else
                        {
                            Rectangle rectangle5 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                            Rectangle rectangle6 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                            if (rectangle6.Intersects(rectangle5) || this.life < this.lifeMax)
                            {
                                this.ai[0] = 1f;
                                this.velocity.Y = this.velocity.Y - 6f;
                                this.netUpdate = true;
                            }
                        }
                    }
                }
                else if (!Main.player[this.target].dead)
                {
                    if (this.collideX)
                    {
                        this.velocity.X = this.oldVelocity.X * -0.5f;
                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                        {
                            this.velocity.X = 2f;
                        }
                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                    if (this.collideY)
                    {
                        this.velocity.Y = this.oldVelocity.Y * -0.5f;
                        if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                        {
                            this.velocity.Y = 1f;
                        }
                        if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                        {
                            this.velocity.Y = -1f;
                        }
                    }
                    this.TargetClosest(true);
                    if (this.direction == -1 && this.velocity.X > -3f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 3f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X < -3f)
                        {
                            this.velocity.X = -3f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 3f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -3f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X > 3f)
                        {
                            this.velocity.X = 3f;
                        }
                    }
                    float single196 = Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)));
                    float y77 = Main.player[this.target].position.Y - (float)(this.height / 2);
                    if (single196 > 50f)
                    {
                        y77 = y77 - 100f;
                    }
                    if (this.position.Y >= y77)
                    {
                        this.velocity.Y = this.velocity.Y - 0.05f;
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.01f;
                        }
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y + 0.05f;
                        if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.01f;
                        }
                    }
                    if (this.velocity.Y < -3f)
                    {
                        this.velocity.Y = -3f;
                    }
                    if (this.velocity.Y > 3f)
                    {
                        this.velocity.Y = 3f;
                    }
                }
                if (this.wet)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.5f;
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                    this.TargetClosest(true);
                    return;
                }
            }
            else if (this.aiStyle == 18)
            {
                bool flag74 = false;
                if (!this.wet || this.ai[1] != 1f)
                {
                    this.dontTakeDamage = false;
                }
                else
                {
                    flag74 = true;
                }
                if (Main.expertMode && (this.type == 63 || this.type == 64 || this.type == 103 || this.type == 242))
                {
                    if (!this.wet)
                    {
                        this.ai[1] = 0f;
                        this.ai[2] = 0f;
                    }
                    else
                    {
                        if (this.target >= 0 && Main.player[this.target].wet && !Main.player[this.target].dead && (Main.player[this.target].Center - base.Center).Length() < 150f)
                        {
                            if (this.ai[1] != 0f)
                            {
                                this.ai[2] = this.ai[2] - 0.25f;
                            }
                            else
                            {
                                this.ai[2] = this.ai[2] + 2f;
                            }
                        }
                        if (!flag74)
                        {
                            this.ai[2] = this.ai[2] + 1f;
                            if (this.ai[2] >= 420f)
                            {
                                this.ai[1] = 1f;
                                this.ai[2] = 0f;
                            }
                        }
                        else
                        {
                            this.dontTakeDamage = true;
                            this.ai[2] = this.ai[2] + 1f;
                            if (this.ai[2] >= 120f)
                            {
                                this.ai[1] = 0f;
                            }
                        }
                    }
                }
                float single197 = 1f;
                if (flag74)
                {
                    single197 = single197 + 0.5f;
                }
                if (this.direction == 0)
                {
                    this.TargetClosest(true);
                }
                if (flag74)
                {
                    return;
                }
                if (!this.wet)
                {
                    NPC x81 = this;
                    x81.rotation = x81.rotation + this.velocity.X * 0.1f;
                    if (this.velocity.Y == 0f)
                    {
                        this.velocity.X = this.velocity.X * 0.98f;
                        if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                        {
                            this.velocity.X = 0f;
                        }
                    }
                    this.velocity.Y = this.velocity.Y + 0.2f;
                    if (this.velocity.Y > 10f)
                    {
                        this.velocity.Y = 10f;
                    }
                    this.ai[0] = 1f;
                    return;
                }
                if (this.collideX)
                {
                    this.velocity.X = this.velocity.X * -1f;
                    NPC nPC93 = this;
                    nPC93.direction = nPC93.direction * -1;
                }
                if (this.collideY)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = Math.Abs(this.velocity.Y) * -1f;
                        this.directionY = -1;
                        this.ai[0] = -1f;
                    }
                    else if (this.velocity.Y < 0f)
                    {
                        this.velocity.Y = Math.Abs(this.velocity.Y);
                        this.directionY = 1;
                        this.ai[0] = 1f;
                    }
                }
                bool flag75 = false;
                if (!this.friendly)
                {
                    this.TargetClosest(false);
                    if (Main.player[this.target].wet && !Main.player[this.target].dead)
                    {
                        flag75 = true;
                    }
                }
                if (!flag75)
                {
                    this.localAI[2] = 0f;
                    this.velocity.X = this.velocity.X + (float)this.direction * 0.02f;
                    this.rotation = this.velocity.X * 0.4f;
                    if (this.velocity.X < -1f || this.velocity.X > 1f)
                    {
                        this.velocity.X = this.velocity.X * 0.95f;
                    }
                    if (this.ai[0] != -1f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.01f;
                        if (this.velocity.Y > 1f)
                        {
                            this.ai[0] = -1f;
                        }
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y - 0.01f;
                        if (this.velocity.Y < -1f)
                        {
                            this.ai[0] = 1f;
                        }
                    }
                    int x82 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                    int y78 = (int)(this.position.Y + (float)(this.height / 2)) / 16;
                    if (Main.tile[x82, y78 - 1] == null)
                    {
                        Main.tile[x82, y78 - 1] = new Tile();
                    }
                    if (Main.tile[x82, y78 + 1] == null)
                    {
                        Main.tile[x82, y78 + 1] = new Tile();
                    }
                    if (Main.tile[x82, y78 + 2] == null)
                    {
                        Main.tile[x82, y78 + 2] = new Tile();
                    }
                    if (Main.tile[x82, y78 - 1].liquid <= 128)
                    {
                        this.ai[0] = 1f;
                    }
                    else if (Main.tile[x82, y78 + 1].active())
                    {
                        this.ai[0] = -1f;
                    }
                    else if (Main.tile[x82, y78 + 2].active())
                    {
                        this.ai[0] = -1f;
                    }
                    if ((double)this.velocity.Y > 1.2 || (double)this.velocity.Y < -1.2)
                    {
                        this.velocity.Y = this.velocity.Y * 0.99f;
                        return;
                    }
                }
                else
                {
                    this.localAI[2] = 1f;
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    NPC nPC94 = this;
                    nPC94.velocity = nPC94.velocity * 0.98f;
                    float single198 = 0.2f;
                    if (this.type == 103)
                    {
                        NPC nPC95 = this;
                        nPC95.velocity = nPC95.velocity * 0.98f;
                        single198 = 0.6f;
                    }
                    if (this.type == 221)
                    {
                        NPC nPC96 = this;
                        nPC96.velocity = nPC96.velocity * 0.99f;
                        single198 = 1f;
                    }
                    if (this.type == 242)
                    {
                        NPC nPC97 = this;
                        nPC97.velocity = nPC97.velocity * 0.995f;
                        single198 = 3f;
                    }
                    if (this.velocity.X > -single198 && this.velocity.X < single198 && this.velocity.Y > -single198 && this.velocity.Y < single198)
                    {
                        if (this.type == 221)
                        {
                            this.localAI[0] = 1f;
                        }
                        this.TargetClosest(true);
                        float single199 = 7f;
                        if (this.type == 103)
                        {
                            single199 = 9f;
                        }
                        Vector2 vector2105 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x83 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2105.X;
                        float y79 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2105.Y;
                        float single200 = (float)Math.Sqrt((double)(x83 * x83 + y79 * y79));
                        single200 = single199 / single200;
                        x83 = x83 * single200;
                        y79 = y79 * single200;
                        this.velocity.X = x83;
                        this.velocity.Y = y79;
                        return;
                    }
                }
            }
            else if (this.aiStyle != 19)
            {
                if (this.aiStyle == 20)
                {
                    if (this.ai[0] == 0f)
                    {
                        if (Main.netMode == 1)
                        {
                            this.ai[1] = this.position.X + (float)(this.width / 2);
                            this.ai[2] = this.position.Y + (float)(this.height / 2);
                            return;
                        }
                        this.TargetClosest(true);
                        NPC nPC98 = this;
                        nPC98.direction = nPC98.direction * -1;
                        NPC nPC99 = this;
                        nPC99.directionY = nPC99.directionY * -1;
                        this.position.Y = this.position.Y + (float)(this.height / 2 + 8);
                        this.ai[1] = this.position.X + (float)(this.width / 2);
                        this.ai[2] = this.position.Y + (float)(this.height / 2);
                        if (this.direction == 0)
                        {
                            this.direction = 1;
                        }
                        if (this.directionY == 0)
                        {
                            this.directionY = 1;
                        }
                        this.ai[3] = 1f + (float)Main.rand.Next(15) * 0.1f;
                        this.velocity.Y = (float)(this.directionY * 6) * this.ai[3];
                        this.ai[0] = this.ai[0] + 1f;
                        this.netUpdate = true;
                        return;
                    }
                    float single201 = 6f * this.ai[3];
                    float single202 = 0.2f * this.ai[3];
                    float single203 = single201 / single202 / 2f;
                    if (this.ai[0] >= 1f && this.ai[0] < (float)((int)single203))
                    {
                        this.velocity.Y = (float)this.directionY * single201;
                        this.ai[0] = this.ai[0] + 1f;
                        return;
                    }
                    if (this.ai[0] >= (float)((int)single203))
                    {
                        this.velocity.Y = 0f;
                        NPC nPC100 = this;
                        nPC100.directionY = nPC100.directionY * -1;
                        this.velocity.X = single201 * (float)this.direction;
                        this.ai[0] = -1f;
                        return;
                    }
                    if (this.directionY > 0)
                    {
                        if (this.velocity.Y >= single201)
                        {
                            NPC nPC101 = this;
                            nPC101.directionY = nPC101.directionY * -1;
                            this.velocity.Y = single201;
                        }
                    }
                    else if (this.directionY < 0 && this.velocity.Y <= -single201)
                    {
                        NPC nPC102 = this;
                        nPC102.directionY = nPC102.directionY * -1;
                        this.velocity.Y = -single201;
                    }
                    if (this.direction > 0)
                    {
                        if (this.velocity.X >= single201)
                        {
                            NPC nPC103 = this;
                            nPC103.direction = nPC103.direction * -1;
                            this.velocity.X = single201;
                        }
                    }
                    else if (this.direction < 0 && this.velocity.X <= -single201)
                    {
                        NPC nPC104 = this;
                        nPC104.direction = nPC104.direction * -1;
                        this.velocity.X = -single201;
                    }
                    this.velocity.X = this.velocity.X + single202 * (float)this.direction;
                    this.velocity.Y = this.velocity.Y + single202 * (float)this.directionY;
                    return;
                }
                if (this.aiStyle == 21)
                {
                    if (this.ai[0] == 0f)
                    {
                        this.TargetClosest(true);
                        this.directionY = 1;
                        this.ai[0] = 1f;
                    }
                    int num381 = 6;
                    if (this.ai[1] != 0f)
                    {
                        NPC nPC105 = this;
                        nPC105.rotation = nPC105.rotation - (float)(this.direction * this.directionY) * 0.13f;
                        if (this.collideX)
                        {
                            this.ai[0] = 2f;
                        }
                        if (!this.collideX && this.ai[0] == 2f)
                        {
                            this.directionY = -this.directionY;
                            this.ai[1] = 0f;
                            this.ai[0] = 1f;
                        }
                        if (this.collideY)
                        {
                            this.direction = -this.direction;
                            this.ai[1] = 0f;
                        }
                    }
                    else
                    {
                        NPC nPC106 = this;
                        nPC106.rotation = nPC106.rotation + (float)(this.direction * this.directionY) * 0.13f;
                        if (this.collideY)
                        {
                            this.ai[0] = 2f;
                        }
                        if (!this.collideY && this.ai[0] == 2f)
                        {
                            this.direction = -this.direction;
                            this.ai[1] = 1f;
                            this.ai[0] = 1f;
                        }
                        if (this.collideX)
                        {
                            this.directionY = -this.directionY;
                            this.ai[1] = 1f;
                        }
                    }
                    this.velocity.X = (float)(num381 * this.direction);
                    this.velocity.Y = (float)(num381 * this.directionY);
                    return;
                }
                if (this.aiStyle == 22)
                {
                    bool flag76 = false;
                    bool flag77 = (this.type != 330 ? false : !Main.pumpkinMoon);
                    if (this.type == 253 && !Main.eclipse)
                    {
                        flag77 = true;
                    }
                    if (this.type == 490 && Main.dayTime)
                    {
                        flag77 = true;
                    }
                    if (this.justHit)
                    {
                        this.ai[2] = 0f;
                    }
                    if (!flag77)
                    {
                        if (this.ai[2] >= 0f)
                        {
                            int num382 = 16;
                            bool flag78 = false;
                            bool flag79 = false;
                            if (this.position.X > this.ai[0] - (float)num382 && this.position.X < this.ai[0] + (float)num382)
                            {
                                flag78 = true;
                            }
                            else if (this.velocity.X < 0f && this.direction > 0 || this.velocity.X > 0f && this.direction < 0)
                            {
                                flag78 = true;
                            }
                            num382 = num382 + 24;
                            if (this.position.Y > this.ai[1] - (float)num382 && this.position.Y < this.ai[1] + (float)num382)
                            {
                                flag79 = true;
                            }
                            if (!flag78 || !flag79)
                            {
                                this.ai[0] = this.position.X;
                                this.ai[1] = this.position.Y;
                                this.ai[2] = 0f;
                            }
                            else
                            {
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] >= 30f && num382 == 16)
                                {
                                    flag76 = true;
                                }
                                if (this.ai[2] >= 60f)
                                {
                                    this.ai[2] = -200f;
                                    NPC nPC107 = this;
                                    nPC107.direction = nPC107.direction * -1;
                                    this.velocity.X = this.velocity.X * -1f;
                                    this.collideX = false;
                                }
                            }
                            this.TargetClosest(true);
                        }
                        else if (this.type != 253)
                        {
                            if (this.type != 330)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            else
                            {
                                this.ai[2] = this.ai[2] + 0.1f;
                            }
                            if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) <= this.position.X + (float)(this.width / 2))
                            {
                                this.direction = 1;
                            }
                            else
                            {
                                this.direction = -1;
                            }
                        }
                        else
                        {
                            this.TargetClosest(true);
                            this.ai[2] = this.ai[2] + 2f;
                        }
                    }
                    int x84 = (int)((this.position.X + (float)(this.width / 2)) / 16f) + this.direction * 2;
                    int y80 = (int)((this.position.Y + (float)this.height) / 16f);
                    bool flag80 = true;
                    bool flag81 = false;
                    int num383 = 3;
                    if (this.type == 122)
                    {
                        if (this.justHit)
                        {
                            this.ai[3] = 0f;
                            this.localAI[1] = 0f;
                        }
                        float single205 = 7f;
                        Vector2 vector2106 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x85 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2106.X;
                        float y81 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2106.Y;
                        float single206 = (float)Math.Sqrt((double)(x85 * x85 + y81 * y81));
                        single206 = single205 / single206;
                        x85 = x85 * single206;
                        y81 = y81 * single206;
                        if (Main.netMode != 1 && this.ai[3] == 32f && !Main.player[this.target].npcTypeNoAggro[this.type])
                        {
                            int num384 = 25;
                            int num385 = 84;
                            Projectile.NewProjectile(vector2106.X, vector2106.Y, x85, y81, num385, num384, 0f, Main.myPlayer, 0f, 0f);
                        }
                        num383 = 8;
                        if (this.ai[3] > 0f)
                        {
                            this.ai[3] = this.ai[3] + 1f;
                            if (this.ai[3] >= 64f)
                            {
                                this.ai[3] = 0f;
                            }
                        }
                        if (Main.netMode != 1 && this.ai[3] == 0f)
                        {
                            this.localAI[1] = this.localAI[1] + 1f;
                            if (this.localAI[1] > 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && !Main.player[this.target].npcTypeNoAggro[this.type])
                            {
                                this.localAI[1] = 0f;
                                this.ai[3] = 1f;
                                this.netUpdate = true;
                            }
                        }
                    }
                    else if (this.type == 75)
                    {
                        num383 = 4;
                    }
                    else if (this.type == 169)
                    {
                        this.alpha = 30;
                        if (this.justHit)
                        {
                            this.ai[3] = 0f;
                            this.localAI[1] = 0f;
                        }
                        float single207 = 5f;
                        Vector2 vector2108 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x86 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2108.X;
                        float y82 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2108.Y;
                        float single208 = (float)Math.Sqrt((double)(x86 * x86 + y82 * y82));
                        single208 = single207 / single208;
                        x86 = x86 * single208;
                        y82 = y82 * single208;
                        if (x86 <= 0f)
                        {
                            this.direction = -1;
                        }
                        else
                        {
                            this.direction = 1;
                        }
                        this.spriteDirection = this.direction;
                        if (this.direction >= 0)
                        {
                            this.rotation = (float)Math.Atan2((double)y82, (double)x86);
                        }
                        else
                        {
                            this.rotation = (float)Math.Atan2((double)(-y82), (double)(-x86));
                        }
                        if (Main.netMode != 1 && this.ai[3] == 16f)
                        {
                            int num390 = 45;
                            int num391 = 128;
                            Projectile.NewProjectile(vector2108.X, vector2108.Y, x86, y82, num391, num390, 0f, Main.myPlayer, 0f, 0f);
                        }
                        num383 = 10;
                        if (this.ai[3] > 0f)
                        {
                            this.ai[3] = this.ai[3] + 1f;
                            if (this.ai[3] >= 64f)
                            {
                                this.ai[3] = 0f;
                            }
                        }
                        if (Main.netMode != 1 && this.ai[3] == 0f)
                        {
                            this.localAI[1] = this.localAI[1] + 1f;
                            if (this.localAI[1] > 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                this.localAI[1] = 0f;
                                this.ai[3] = 1f;
                                this.netUpdate = true;
                            }
                        }
                    }
                    else if (this.type == 268)
                    {
                        this.rotation = this.velocity.X * 0.1f;
                        num383 = (Main.player[this.target].Center.Y >= base.Center.Y ? 6 : 12);
                        if (Main.netMode != 1 && !this.confused)
                        {
                            this.ai[3] = this.ai[3] + 1f;
                            if (this.justHit)
                            {
                                this.ai[3] = -45f;
                                this.localAI[1] = 0f;
                            }
                            if (Main.netMode != 1 && this.ai[3] >= (float)(60 + Main.rand.Next(60)))
                            {
                                this.ai[3] = 0f;
                                if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].head))
                                {
                                    float single209 = 10f;
                                    Vector2 vector2109 = new Vector2(this.position.X + (float)this.width * 0.5f - 4f, this.position.Y + (float)this.height * 0.7f);
                                    float x87 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2109.X;
                                    float single210 = Math.Abs(x87) * 0.1f;
                                    float y83 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2109.Y - single210;
                                    x87 = x87 + (float)Main.rand.Next(-10, 11);
                                    y83 = y83 + (float)Main.rand.Next(-30, 21);
                                    float single211 = (float)Math.Sqrt((double)(x87 * x87 + y83 * y83));
                                    single211 = single209 / single211;
                                    x87 = x87 * single211;
                                    y83 = y83 * single211;
                                    int num392 = 40;
                                    int num393 = 288;
                                    Projectile.NewProjectile(vector2109.X, vector2109.Y, x87, y83, num393, num392, 0f, Main.myPlayer, 0f, 0f);
                                }
                            }
                        }
                    }
                    if (this.type == 490)
                    {
                        num383 = 4;
                        if (this.target >= 0)
                        {
                            Vector2 center26 = Main.player[this.target].Center - base.Center;
                            float single212 = center26.Length();
                            single212 = single212 / 70f;
                            if (single212 > 8f)
                            {
                                single212 = 8f;
                            }
                            num383 = num383 + (int)single212;
                        }
                    }
                    int num394 = y80;
                    while (num394 < y80 + num383)
                    {
                        if (Main.tile[x84, num394] == null)
                        {
                            Main.tile[x84, num394] = new Tile();
                        }
                        if ((!Main.tile[x84, num394].nactive() || !Main.tileSolid[Main.tile[x84, num394].type]) && Main.tile[x84, num394].liquid <= 0)
                        {
                            num394++;
                        }
                        else
                        {
                            if (num394 <= y80 + 1)
                            {
                                flag81 = true;
                            }
                            flag80 = false;
                            break;
                        }
                    }
                    if (Main.player[this.target].npcTypeNoAggro[this.type])
                    {
                        bool flag82 = false;
                        int num395 = y80;
                        while (num395 < y80 + num383 - 2)
                        {
                            if (Main.tile[x84, num395] == null)
                            {
                                Main.tile[x84, num395] = new Tile();
                            }
                            if ((!Main.tile[x84, num395].nactive() || !Main.tileSolid[Main.tile[x84, num395].type]) && Main.tile[x84, num395].liquid <= 0)
                            {
                                num395++;
                            }
                            else
                            {
                                flag82 = true;
                                break;
                            }
                        }
                        this.directionY = (!flag82).ToDirectionInt();
                    }
                    if (this.type == 169 || this.type == 268)
                    {
                        int num396 = y80 - 3;
                        while (num396 < y80)
                        {
                            if (Main.tile[x84, num396] == null)
                            {
                                Main.tile[x84, num396] = new Tile();
                            }
                            if ((!Main.tile[x84, num396].nactive() || !Main.tileSolid[Main.tile[x84, num396].type]) && Main.tile[x84, num396].liquid <= 0)
                            {
                                num396++;
                            }
                            else
                            {
                                flag81 = false;
                                flag76 = true;
                                break;
                            }
                        }
                    }
                    if (flag76)
                    {
                        flag81 = false;
                        flag80 = true;
                        if (this.type == 268)
                        {
                            this.velocity.Y = this.velocity.Y + 2f;
                        }
                    }
                    if (!flag80)
                    {
                        if (this.type == 75 || this.type == 169)
                        {
                            if (this.directionY < 0 && this.velocity.Y > 0f || flag81)
                            {
                                this.velocity.Y = this.velocity.Y - 0.2f;
                            }
                        }
                        else if (this.type == 490)
                        {
                            if (this.directionY < 0 && this.velocity.Y > 0f || flag81)
                            {
                                this.velocity.Y = this.velocity.Y - 0.075f;
                            }
                            if (this.velocity.Y < -0.75f)
                            {
                                this.velocity.Y = -0.75f;
                            }
                        }
                        else if (this.directionY < 0 && this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.1f;
                        }
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                    }
                    else if (this.type == 75 || this.type == 169)
                    {
                        this.velocity.Y = this.velocity.Y + 0.2f;
                        if (this.velocity.Y > 2f)
                        {
                            this.velocity.Y = 2f;
                        }
                    }
                    else if (this.type != 490)
                    {
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        if (this.velocity.Y > 3f)
                        {
                            this.velocity.Y = 3f;
                        }
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y + 0.03f;
                        if ((double)this.velocity.Y > 0.75)
                        {
                            this.velocity.Y = 0.75f;
                        }
                    }
                    if (this.type == 75 && this.wet)
                    {
                        this.velocity.Y = this.velocity.Y - 0.2f;
                        if (this.velocity.Y < -2f)
                        {
                            this.velocity.Y = -2f;
                        }
                    }
                    if (this.collideX)
                    {
                        this.velocity.X = this.oldVelocity.X * -0.4f;
                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 1f)
                        {
                            this.velocity.X = 1f;
                        }
                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -1f)
                        {
                            this.velocity.X = -1f;
                        }
                    }
                    if (this.collideY)
                    {
                        this.velocity.Y = this.oldVelocity.Y * -0.25f;
                        if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                        {
                            this.velocity.Y = 1f;
                        }
                        if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                        {
                            this.velocity.Y = -1f;
                        }
                    }
                    float single213 = 2f;
                    if (this.type == 75)
                    {
                        single213 = 3f;
                    }
                    if (this.type == 253)
                    {
                        single213 = 4f;
                    }
                    if (this.type == 490)
                    {
                        single213 = 1.5f;
                    }
                    if (this.type == 330)
                    {
                        this.alpha = 0;
                        single213 = 4f;
                        if (!flag77)
                        {
                            this.TargetClosest(true);
                        }
                        else if (this.timeLeft > 10)
                        {
                            this.timeLeft = 10;
                        }
                        if (this.direction < 0 && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                        }
                        if (this.direction > 0 && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                        }
                    }
                    if (this.direction == -1 && this.velocity.X > -single213)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > single213)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -single213)
                        {
                            this.velocity.X = -single213;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < single213)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -single213)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > single213)
                        {
                            this.velocity.X = single213;
                        }
                    }
                    single213 = (this.type != 490 ? 1.5f : 1f);
                    if (this.directionY == -1 && this.velocity.Y > -single213)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if (this.velocity.Y > single213)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if (this.velocity.Y < -single213)
                        {
                            this.velocity.Y = -single213;
                        }
                    }
                    else if (this.directionY == 1 && this.velocity.Y < single213)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if (this.velocity.Y < -single213)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if (this.velocity.Y > single213)
                        {
                            this.velocity.Y = single213;
                        }
                    }
                }
                else if (this.aiStyle == 23)
                {
                    this.noGravity = true;
                    this.noTileCollide = true;
                    if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                    {
                        this.TargetClosest(true);
                    }
                    if (this.ai[0] == 0f)
                    {
                        float single214 = 9f;
                        Vector2 vector2110 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x88 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2110.X;
                        float y84 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2110.Y;
                        float single215 = (float)Math.Sqrt((double)(x88 * x88 + y84 * y84));
                        single215 = single214 / single215;
                        x88 = x88 * single215;
                        y84 = y84 * single215;
                        this.velocity.X = x88;
                        this.velocity.Y = y84;
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 0.785f;
                        this.ai[0] = 1f;
                        this.ai[1] = 0f;
                        this.netUpdate = true;
                        return;
                    }
                    if (this.ai[0] != 1f)
                    {
                        if (this.justHit)
                        {
                            this.ai[0] = 2f;
                            this.ai[1] = 0f;
                        }
                        NPC nPC108 = this;
                        nPC108.velocity = nPC108.velocity * 0.96f;
                        this.ai[1] = this.ai[1] + 1f;
                        float single216 = this.ai[1] / 120f;
                        single216 = 0.1f + single216 * 0.4f;
                        NPC nPC109 = this;
                        nPC109.rotation = nPC109.rotation + single216 * (float)this.direction;
                        if (this.ai[1] >= 120f)
                        {
                            this.netUpdate = true;
                            this.ai[0] = 0f;
                            this.ai[1] = 0f;
                            return;
                        }
                    }
                    else
                    {
                        if (this.justHit)
                        {
                            this.ai[0] = 2f;
                            this.ai[1] = 0f;
                        }
                        NPC nPC110 = this;
                        nPC110.velocity = nPC110.velocity * 0.99f;
                        this.ai[1] = this.ai[1] + 1f;
                        if (this.ai[1] >= 100f)
                        {
                            this.netUpdate = true;
                            this.ai[0] = 2f;
                            this.ai[1] = 0f;
                            this.velocity.X = 0f;
                            this.velocity.Y = 0f;
                            return;
                        }
                    }
                }
                else if (this.aiStyle == 24)
                {
                    this.noGravity = true;
                    if (this.ai[0] == 0f)
                    {
                        this.noGravity = false;
                        this.TargetClosest(true);
                        if (Main.netMode != 1)
                        {
                            if (this.velocity.X != 0f || this.velocity.Y < 0f || (double)this.velocity.Y > 0.3)
                            {
                                this.ai[0] = 1f;
                                this.netUpdate = true;
                                this.direction = -this.direction;
                            }
                            else
                            {
                                Rectangle rectangle7 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                                Rectangle rectangle8 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                                if (rectangle8.Intersects(rectangle7) || this.life < this.lifeMax)
                                {
                                    this.ai[0] = 1f;
                                    this.velocity.Y = this.velocity.Y - 6f;
                                    this.netUpdate = true;
                                    this.direction = -this.direction;
                                }
                            }
                        }
                    }
                    else if (!Main.player[this.target].dead)
                    {
                        if (this.collideX)
                        {
                            NPC nPC111 = this;
                            nPC111.direction = nPC111.direction * -1;
                            this.velocity.X = this.oldVelocity.X * -0.5f;
                            if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                            {
                                this.velocity.X = 2f;
                            }
                            if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                            {
                                this.velocity.X = -2f;
                            }
                        }
                        if (this.collideY)
                        {
                            this.velocity.Y = this.oldVelocity.Y * -0.5f;
                            if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                            {
                                this.velocity.Y = 1f;
                            }
                            if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                            {
                                this.velocity.Y = -1f;
                            }
                        }
                        if (this.direction == -1 && this.velocity.X > -3f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.05f;
                            }
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = -3f;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < 3f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.05f;
                            }
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = 3f;
                            }
                        }
                        int x89 = (int)((this.position.X + (float)(this.width / 2)) / 16f) + this.direction;
                        int y85 = (int)((this.position.Y + (float)this.height) / 16f);
                        bool flag83 = true;
                        int num397 = 15;
                        bool flag84 = false;
                        int num398 = y85;
                        while (num398 < y85 + num397)
                        {
                            if (Main.tile[x89, num398] == null)
                            {
                                Main.tile[x89, num398] = new Tile();
                            }
                            if ((!Main.tile[x89, num398].nactive() || !Main.tileSolid[Main.tile[x89, num398].type]) && Main.tile[x89, num398].liquid <= 0)
                            {
                                num398++;
                            }
                            else
                            {
                                if (num398 < y85 + 5)
                                {
                                    flag84 = true;
                                }
                                flag83 = false;
                                break;
                            }
                        }
                        if (!flag83)
                        {
                            this.velocity.Y = this.velocity.Y - 0.1f;
                        }
                        else
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        if (flag84)
                        {
                            this.velocity.Y = this.velocity.Y - 0.2f;
                        }
                        if (this.velocity.Y > 2f)
                        {
                            this.velocity.Y = 2f;
                        }
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                    }
                    if (this.wet)
                    {
                        this.ai[1] = 0f;
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.95f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                        this.TargetClosest(true);
                        return;
                    }
                }
                else if (this.aiStyle == 25)
                {
                    bool flag85 = (this.type != 341 ? false : !Main.snowMoon);
                    if (this.ai[3] == 0f)
                    {
                        this.position.X = this.position.X + 8f;
                        if (this.position.Y / 16f > (float)(Main.maxTilesY - 200))
                        {
                            this.ai[3] = 3f;
                        }
                        else if ((double)(this.position.Y / 16f) <= Main.worldSurface)
                        {
                            this.ai[3] = 1f;
                        }
                        else
                        {
                            this.TargetClosest(true);
                            if (!Main.player[this.target].ZoneSnow)
                            {
                                this.ai[3] = 2f;
                            }
                            else
                            {
                                this.ai[3] = 4f;
                            }
                        }
                    }
                    if (this.type == 341)
                    {
                        this.ai[3] = 1f;
                    }
                    if (this.ai[0] != 0f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.ai[2] = this.ai[2] + 1f;
                            int num399 = 20;
                            if (this.ai[1] == 0f)
                            {
                                num399 = 12;
                            }
                            if (this.ai[2] < (float)num399)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                return;
                            }
                            this.ai[2] = 0f;
                            if (!flag85)
                            {
                                this.TargetClosest(true);
                            }
                            if (this.direction == 0)
                            {
                                this.direction = -1;
                            }
                            this.spriteDirection = this.direction;
                            this.ai[1] = this.ai[1] + 1f;
                            if (this.ai[1] != 2f)
                            {
                                this.velocity.X = (float)this.direction * 3.5f;
                                this.velocity.Y = -4f;
                            }
                            else
                            {
                                this.velocity.X = (float)this.direction * 2.5f;
                                this.velocity.Y = -8f;
                                this.ai[1] = 0f;
                            }
                            this.netUpdate = true;
                            return;
                        }
                        if (this.direction == 1 && this.velocity.X < 1f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            return;
                        }
                        if (this.direction == -1 && this.velocity.X > -1f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            return;
                        }
                    }
                    else
                    {
                        if (!flag85)
                        {
                            this.TargetClosest(true);
                        }
                        if (Main.netMode != 1)
                        {
                            if (this.velocity.X != 0f || this.velocity.Y < 0f || (double)this.velocity.Y > 0.3)
                            {
                                this.ai[0] = 1f;
                                this.netUpdate = true;
                                return;
                            }
                            Rectangle rectangle9 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                            Rectangle rectangle10 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                            if (rectangle10.Intersects(rectangle9) || this.life < this.lifeMax)
                            {
                                this.ai[0] = 1f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                    }
                }
                else if (this.aiStyle == 26)
                {
                    int num400 = 30;
                    int num401 = 10;
                    bool flag86 = false;
                    bool flag87 = false;
                    bool flag88 = false;
                    if (this.velocity.Y == 0f && (this.velocity.X > 0f && this.direction < 0 || this.velocity.X < 0f && this.direction > 0))
                    {
                        flag87 = true;
                        this.ai[3] = this.ai[3] + 1f;
                    }
                    if (this.position.X == this.oldPosition.X || this.ai[3] >= (float)num400 || flag87)
                    {
                        this.ai[3] = this.ai[3] + 1f;
                        flag88 = true;
                    }
                    else if (this.ai[3] > 0f)
                    {
                        this.ai[3] = this.ai[3] - 1f;
                    }
                    if (this.ai[3] > (float)(num400 * num401))
                    {
                        this.ai[3] = 0f;
                    }
                    if (this.justHit)
                    {
                        this.ai[3] = 0f;
                    }
                    if (this.ai[3] == (float)num400)
                    {
                        this.netUpdate = true;
                    }
                    Vector2 vector2111 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x90 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2111.X;
                    float y86 = Main.player[this.target].position.Y - vector2111.Y;
                    float single217 = (float)Math.Sqrt((double)(x90 * x90 + y86 * y86));
                    if (single217 < 200f && !flag88)
                    {
                        this.ai[3] = 0f;
                    }
                    if (this.type == 410)
                    {
                        this.ai[1] = this.ai[1] + 1f;
                        bool flag89 = this.ai[1] >= 240f;
                        if (!flag89 && this.velocity.Y == 0f)
                        {
                            int num402 = 0;
                            while (num402 < 255)
                            {
                                if (!Main.player[num402].active || Main.player[num402].dead || Main.player[num402].Distance(base.Center) >= 800f || Main.player[num402].Center.Y >= base.Center.Y || Math.Abs(Main.player[num402].Center.X - base.Center.X) >= 20f)
                                {
                                    num402++;
                                }
                                else
                                {
                                    flag89 = true;
                                    break;
                                }
                            }
                        }
                        if (flag89 && Main.netMode != 1)
                        {
                            for (int h2 = 0; h2 < 3; h2++)
                            {
                                Projectile.NewProjectile(base.Center.X, base.Center.Y, (Main.rand.NextFloat() - 0.5f) * 2f, -4f - 10f * Main.rand.NextFloat(), 538, 50, 0f, Main.myPlayer, 0f, 0f);
                            }
                            this.HitEffect(9999, 10);
                            this.active = false;
                            return;
                        }
                    }
                    else if (this.type == 423)
                    {
                        if (this.ai[2] != 1f)
                        {
                            this.ai[1] = this.ai[1] + 1f;
                            if (this.ai[1] >= 180f && single217 < 500f && this.velocity.Y == 0f)
                            {
                                flag86 = true;
                                this.ai[1] = 0f;
                                this.ai[2] = 1f;
                                this.netUpdate = true;
                            }
                            else if (this.velocity.Y == 0f && single217 < 100f && Math.Abs(this.velocity.X) > 3f && (base.Center.X < Main.player[this.target].Center.X && this.velocity.X > 0f || base.Center.X > Main.player[this.target].Center.X && this.velocity.X < 0f))
                            {
                                this.velocity.Y = this.velocity.Y - 4f;
                            }
                        }
                        else
                        {
                            this.ai[1] = this.ai[1] + 1f;
                            this.velocity.X = this.velocity.X * 0.7f;
                            if (this.velocity.X > -0.5f && this.velocity.X < 0.5f)
                            {
                                this.velocity.X = 0f;
                            }
                            if (this.ai[1] == 30f && Main.netMode != 1)
                            {
                                int num403 = (Main.expertMode ? 35 : 50);
                                Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * -20), base.Center.Y, (float)(this.spriteDirection * -7), 0f, 575, num403, 0f, Main.myPlayer, (float)this.target, 0f);
                            }
                            if (this.ai[1] >= 60f)
                            {
                                this.ai[1] = (float)(-Main.rand.Next(320, 601));
                                this.ai[2] = 0f;
                            }
                        }
                    }
                    else if ((this.type == 155 || this.type == 329) && this.velocity.Y == 0f && single217 < 100f && Math.Abs(this.velocity.X) > 3f && (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) && this.velocity.X > 0f || this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) && this.velocity.X < 0f))
                    {
                        this.velocity.Y = this.velocity.Y - 4f;
                    }
                    if (this.ai[3] >= (float)num400)
                    {
                        if (this.velocity.X != 0f)
                        {
                            this.ai[0] = 0f;
                        }
                        else if (this.velocity.Y == 0f)
                        {
                            this.ai[0] = this.ai[0] + 1f;
                            if (this.ai[0] >= 2f)
                            {
                                NPC nPC112 = this;
                                nPC112.direction = nPC112.direction * -1;
                                this.spriteDirection = this.direction;
                                this.ai[0] = 0f;
                            }
                        }
                        this.directionY = -1;
                        if (this.direction == 0)
                        {
                            this.direction = 1;
                        }
                    }
                    else if (this.type != 329 && this.type != 315 || Main.pumpkinMoon)
                    {
                        this.TargetClosest(true);
                    }
                    else if (this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                    float single218 = 6f;
                    float single219 = 0.07f;
                    if (!flag86 && (this.velocity.Y == 0f || this.wet || this.velocity.X <= 0f && this.direction < 0 || this.velocity.X >= 0f && this.direction > 0))
                    {
                        if (this.type == 155)
                        {
                            if (this.velocity.X > 0f && this.direction < 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.velocity.X < 0f && this.direction > 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                        }
                        else if (this.type == 329)
                        {
                            if (this.velocity.X > 0f && this.direction < 0)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (this.velocity.X < 0f && this.direction > 0)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (this.direction > 0 && this.velocity.X < 3f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            if (this.direction < 0 && this.velocity.X > -3f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                        }
                        else if (this.type == 315)
                        {
                            if (this.velocity.X > 0f && this.direction < 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.velocity.X < 0f && this.direction > 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.velocity.X < -single218 || this.velocity.X > single218)
                            {
                                if (this.velocity.Y == 0f)
                                {
                                    NPC nPC113 = this;
                                    nPC113.velocity = nPC113.velocity * 0.8f;
                                }
                            }
                            else if (this.velocity.X < single218 && this.direction == 1)
                            {
                                this.velocity.X = this.velocity.X + 0.07f;
                                if (this.velocity.X > single218)
                                {
                                    this.velocity.X = single218;
                                }
                            }
                            else if (this.velocity.X > -single218 && this.direction == -1)
                            {
                                this.velocity.X = this.velocity.X - 0.07f;
                                if (this.velocity.X < -single218)
                                {
                                    this.velocity.X = -single218;
                                }
                            }
                        }
                        else if (this.type == 410)
                        {
                            if (Math.Sign(this.velocity.X) != this.direction)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            single218 = 6f;
                            single219 = 0.2f;
                        }
                        else if (this.type == 423)
                        {
                            if (Math.Sign(this.velocity.X) != this.direction)
                            {
                                this.velocity.X = this.velocity.X * 0.85f;
                            }
                            single218 = 10f;
                            single219 = 0.2f;
                        }
                        if (this.velocity.X < -single218 || this.velocity.X > single218)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                NPC nPC114 = this;
                                nPC114.velocity = nPC114.velocity * 0.8f;
                            }
                        }
                        else if (this.velocity.X < single218 && this.direction == 1)
                        {
                            this.velocity.X = this.velocity.X + single219;
                            if (this.velocity.X > single218)
                            {
                                this.velocity.X = single218;
                            }
                        }
                        else if (this.velocity.X > -single218 && this.direction == -1)
                        {
                            this.velocity.X = this.velocity.X - single219;
                            if (this.velocity.X < -single218)
                            {
                                this.velocity.X = -single218;
                            }
                        }
                    }
                    if (this.velocity.Y >= 0f)
                    {
                        int num404 = 0;
                        if (this.velocity.X < 0f)
                        {
                            num404 = -1;
                        }
                        if (this.velocity.X > 0f)
                        {
                            num404 = 1;
                        }
                        Vector2 x91 = this.position;
                        x91.X = x91.X + this.velocity.X;
                        int x92 = (int)((x91.X + (float)(this.width / 2) + (float)((this.width / 2 + 1) * num404)) / 16f);
                        int y87 = (int)((x91.Y + (float)this.height - 1f) / 16f);
                        if (Main.tile[x92, y87] == null)
                        {
                            Main.tile[x92, y87] = new Tile();
                        }
                        if (Main.tile[x92, y87 - 1] == null)
                        {
                            Main.tile[x92, y87 - 1] = new Tile();
                        }
                        if (Main.tile[x92, y87 - 2] == null)
                        {
                            Main.tile[x92, y87 - 2] = new Tile();
                        }
                        if (Main.tile[x92, y87 - 3] == null)
                        {
                            Main.tile[x92, y87 - 3] = new Tile();
                        }
                        if (Main.tile[x92, y87 + 1] == null)
                        {
                            Main.tile[x92, y87 + 1] = new Tile();
                        }
                        if ((float)(x92 * 16) < x91.X + (float)this.width && (float)(x92 * 16 + 16) > x91.X && (Main.tile[x92, y87].nactive() && !Main.tile[x92, y87].topSlope() && !Main.tile[x92, y87 - 1].topSlope() && Main.tileSolid[Main.tile[x92, y87].type] && !Main.tileSolidTop[Main.tile[x92, y87].type] || Main.tile[x92, y87 - 1].halfBrick() && Main.tile[x92, y87 - 1].nactive()) && (!Main.tile[x92, y87 - 1].nactive() || !Main.tileSolid[Main.tile[x92, y87 - 1].type] || Main.tileSolidTop[Main.tile[x92, y87 - 1].type] || Main.tile[x92, y87 - 1].halfBrick() && (!Main.tile[x92, y87 - 4].nactive() || !Main.tileSolid[Main.tile[x92, y87 - 4].type] || Main.tileSolidTop[Main.tile[x92, y87 - 4].type])) && (!Main.tile[x92, y87 - 2].nactive() || !Main.tileSolid[Main.tile[x92, y87 - 2].type] || Main.tileSolidTop[Main.tile[x92, y87 - 2].type]) && (!Main.tile[x92, y87 - 3].nactive() || !Main.tileSolid[Main.tile[x92, y87 - 3].type] || Main.tileSolidTop[Main.tile[x92, y87 - 3].type]) && (!Main.tile[x92 - num404, y87 - 3].nactive() || !Main.tileSolid[Main.tile[x92 - num404, y87 - 3].type]))
                        {
                            float single220 = (float)(y87 * 16);
                            if (Main.tile[x92, y87].halfBrick())
                            {
                                single220 = single220 + 8f;
                            }
                            if (Main.tile[x92, y87 - 1].halfBrick())
                            {
                                single220 = single220 - 8f;
                            }
                            if (single220 < x91.Y + (float)this.height)
                            {
                                float y88 = x91.Y + (float)this.height - single220;
                                if ((double)y88 <= 16.1)
                                {
                                    NPC y89 = this;
                                    y89.gfxOffY = y89.gfxOffY + (this.position.Y + (float)this.height - single220);
                                    this.position.Y = single220 - (float)this.height;
                                    if (y88 >= 9f)
                                    {
                                        this.stepSpeed = 2f;
                                    }
                                    else
                                    {
                                        this.stepSpeed = 1f;
                                    }
                                }
                            }
                        }
                    }
                    if (this.velocity.Y == 0f)
                    {
                        int x93 = (int)((this.position.X + (float)(this.width / 2) + (float)((this.width / 2 + 2) * this.direction) + this.velocity.X * 5f) / 16f);
                        int y90 = (int)((this.position.Y + (float)this.height - 15f) / 16f);
                        if (Main.tile[x93, y90] == null)
                        {
                            Main.tile[x93, y90] = new Tile();
                        }
                        if (Main.tile[x93, y90 - 1] == null)
                        {
                            Main.tile[x93, y90 - 1] = new Tile();
                        }
                        if (Main.tile[x93, y90 - 2] == null)
                        {
                            Main.tile[x93, y90 - 2] = new Tile();
                        }
                        if (Main.tile[x93, y90 - 3] == null)
                        {
                            Main.tile[x93, y90 - 3] = new Tile();
                        }
                        if (Main.tile[x93, y90 + 1] == null)
                        {
                            Main.tile[x93, y90 + 1] = new Tile();
                        }
                        if (Main.tile[x93 + this.direction, y90 - 1] == null)
                        {
                            Main.tile[x93 + this.direction, y90 - 1] = new Tile();
                        }
                        if (Main.tile[x93 + this.direction, y90 + 1] == null)
                        {
                            Main.tile[x93 + this.direction, y90 + 1] = new Tile();
                        }
                        if (Main.tile[x93 - this.direction, y90 + 1] == null)
                        {
                            Main.tile[x93 - this.direction, y90 + 1] = new Tile();
                        }
                        int num405 = this.spriteDirection;
                        if (this.type == 423 || this.type == 410)
                        {
                            num405 = num405 * -1;
                        }
                        if (this.velocity.X < 0f && num405 == -1 || this.velocity.X > 0f && num405 == 1)
                        {
                            bool flag90 = (this.type == 410 ? true : this.type == 423);
                            float single221 = 3f;
                            if (Main.tile[x93, y90 - 2].nactive() && Main.tileSolid[Main.tile[x93, y90 - 2].type])
                            {
                                if (!Main.tile[x93, y90 - 3].nactive() || !Main.tileSolid[Main.tile[x93, y90 - 3].type])
                                {
                                    this.velocity.Y = -7.5f;
                                    this.netUpdate = true;
                                }
                                else
                                {
                                    this.velocity.Y = -8.5f;
                                    this.netUpdate = true;
                                }
                            }
                            else if (Main.tile[x93, y90 - 1].nactive() && !Main.tile[x93, y90 - 1].topSlope() && Main.tileSolid[Main.tile[x93, y90 - 1].type])
                            {
                                this.velocity.Y = -7f;
                                this.netUpdate = true;
                            }
                            else if (this.position.Y + (float)this.height - (float)(y90 * 16) > 20f && Main.tile[x93, y90].nactive() && !Main.tile[x93, y90].topSlope() && Main.tileSolid[Main.tile[x93, y90].type])
                            {
                                this.velocity.Y = -6f;
                                this.netUpdate = true;
                            }
                            else if ((this.directionY < 0 || Math.Abs(this.velocity.X) > single221) && (!flag90 || !Main.tile[x93, y90 + 1].nactive() || !Main.tileSolid[Main.tile[x93, y90 + 1].type]) && (!Main.tile[x93, y90 + 2].nactive() || !Main.tileSolid[Main.tile[x93, y90 + 2].type]) && (!Main.tile[x93 + this.direction, y90 + 3].nactive() || !Main.tileSolid[Main.tile[x93 + this.direction, y90 + 3].type]))
                            {
                                this.velocity.Y = -8f;
                                this.netUpdate = true;
                            }
                        }
                    }
                }
                else if (this.aiStyle == 27)
                {
                    if (this.position.X < 160f || this.position.X > (float)((Main.maxTilesX - 10) * 16))
                    {
                        this.active = false;
                    }
                    if (this.localAI[0] == 0f)
                    {
                        this.localAI[0] = 1f;
                        Main.wofB = -1;
                        Main.wofT = -1;
                    }
                    this.ai[1] = this.ai[1] + 1f;
                    if (this.ai[2] == 0f)
                    {
                        if ((double)this.life < (double)this.lifeMax * 0.5)
                        {
                            this.ai[1] = this.ai[1] + 1f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.2)
                        {
                            this.ai[1] = this.ai[1] + 1f;
                        }
                        if (this.ai[1] > 2700f)
                        {
                            this.ai[2] = 1f;
                        }
                    }
                    if (this.ai[2] > 0f && this.ai[1] > 60f)
                    {
                        int num406 = 3;
                        if ((double)this.life < (double)this.lifeMax * 0.3)
                        {
                            num406++;
                        }
                        this.ai[2] = this.ai[2] + 1f;
                        this.ai[1] = 0f;
                        if (this.ai[2] > (float)num406)
                        {
                            this.ai[2] = 0f;
                        }
                        if (Main.netMode != 1)
                        {
                            int num407 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)(this.height / 2) + 20f), 117, 1, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num407].velocity.X = (float)(this.direction * 8);
                        }
                    }
                    this.localAI[3] = this.localAI[3] + 1f;
                    if (this.localAI[3] >= (float)(600 + Main.rand.Next(1000)))
                    {
                        this.localAI[3] = (float)(-Main.rand.Next(200));
                    }
                    Main.wof = this.whoAmI;
                    int x94 = (int)(this.position.X / 16f);
                    int x95 = (int)((this.position.X + (float)this.width) / 16f);
                    int y91 = (int)((this.position.Y + (float)(this.height / 2)) / 16f);
                    int num408 = 0;
                    int num409 = y91 + 7;
                    while (num408 < 15 && num409 > Main.maxTilesY - 200)
                    {
                        num409++;
                        for (int k3 = x94; k3 <= x95; k3++)
                        {
                            try
                            {
                                if (WorldGen.SolidTile(k3, num409) || Main.tile[k3, num409].liquid > 0)
                                {
                                    num408++;
                                }
                            }
                            catch
                            {
                                num408 = num408 + 15;
                            }
                        }
                    }
                    num409 = num409 + 4;
                    if (Main.wofB == -1)
                    {
                        Main.wofB = num409 * 16;
                    }
                    else if (Main.wofB > num409 * 16)
                    {
                        Main.wofB = Main.wofB - 1;
                        if (Main.wofB < num409 * 16)
                        {
                            Main.wofB = num409 * 16;
                        }
                    }
                    else if (Main.wofB < num409 * 16)
                    {
                        Main.wofB = Main.wofB + 1;
                        if (Main.wofB > num409 * 16)
                        {
                            Main.wofB = num409 * 16;
                        }
                    }
                    num408 = 0;
                    num409 = y91 - 7;
                    while (num408 < 15 && num409 < Main.maxTilesY - 10)
                    {
                        num409--;
                        for (int l3 = x94; l3 <= x95; l3++)
                        {
                            try
                            {
                                if (WorldGen.SolidTile(l3, num409) || Main.tile[l3, num409].liquid > 0)
                                {
                                    num408++;
                                }
                            }
                            catch
                            {
                                num408 = num408 + 15;
                            }
                        }
                    }
                    num409 = num409 - 4;
                    if (Main.wofT == -1)
                    {
                        Main.wofT = num409 * 16;
                    }
                    else if (Main.wofT > num409 * 16)
                    {
                        Main.wofT = Main.wofT - 1;
                        if (Main.wofT < num409 * 16)
                        {
                            Main.wofT = num409 * 16;
                        }
                    }
                    else if (Main.wofT < num409 * 16)
                    {
                        Main.wofT = Main.wofT + 1;
                        if (Main.wofT > num409 * 16)
                        {
                            Main.wofT = num409 * 16;
                        }
                    }
                    float single222 = (float)((Main.wofB + Main.wofT) / 2 - this.height / 2);
                    if (this.position.Y > single222 + 1f)
                    {
                        this.velocity.Y = -1f;
                    }
                    else if (this.position.Y < single222 - 1f)
                    {
                        this.velocity.Y = 1f;
                    }
                    this.velocity.Y = 0f;
                    this.position.Y = single222;
                    float single223 = 1.5f;
                    if ((double)this.life < (double)this.lifeMax * 0.75)
                    {
                        single223 = single223 + 0.25f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.5)
                    {
                        single223 = single223 + 0.4f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.25)
                    {
                        single223 = single223 + 0.5f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.1)
                    {
                        single223 = single223 + 0.6f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.66 && Main.expertMode)
                    {
                        single223 = single223 + 0.3f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.33 && Main.expertMode)
                    {
                        single223 = single223 + 0.3f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.05 && Main.expertMode)
                    {
                        single223 = single223 + 0.6f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.035 && Main.expertMode)
                    {
                        single223 = single223 + 0.6f;
                    }
                    if ((double)this.life < (double)this.lifeMax * 0.025 && Main.expertMode)
                    {
                        single223 = single223 + 0.6f;
                    }
                    if (Main.expertMode)
                    {
                        single223 = single223 * 1.35f;
                        single223 = single223 + 0.35f;
                    }
                    if (this.velocity.X == 0f)
                    {
                        this.TargetClosest(true);
                        this.velocity.X = (float)this.direction;
                    }
                    if (this.velocity.X >= 0f)
                    {
                        this.velocity.X = single223;
                        this.direction = 1;
                    }
                    else
                    {
                        this.velocity.X = -single223;
                        this.direction = -1;
                    }
                    this.spriteDirection = this.direction;
                    Vector2 vector2115 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x96 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2115.X;
                    float y92 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2115.Y;
                    float single224 = (float)Math.Sqrt((double)(x96 * x96 + y92 * y92));
                    x96 = x96 * single224;
                    y92 = y92 * single224;
                    if (this.direction > 0)
                    {
                        if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) <= this.position.X + (float)(this.width / 2))
                        {
                            this.rotation = 0f;
                        }
                        else
                        {
                            this.rotation = (float)Math.Atan2((double)(-y92), (double)(-x96)) + 3.14f;
                        }
                    }
                    else if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) >= this.position.X + (float)(this.width / 2))
                    {
                        this.rotation = 0f;
                    }
                    else
                    {
                        this.rotation = (float)Math.Atan2((double)y92, (double)x96) + 3.14f;
                    }
                    if (Main.expertMode && Main.netMode != 1)
                    {
                        int num410 = (int)(1f + (float)this.life / (float)this.lifeMax * 10f);
                        num410 = num410 * num410;
                        if (num410 < 400)
                        {
                            num410 = (num410 * 19 + 400) / 20;
                        }
                        if (num410 < 60)
                        {
                            num410 = (num410 * 3 + 60) / 4;
                        }
                        if (num410 < 20)
                        {
                            num410 = (num410 + 20) / 2;
                        }
                        num410 = (int)((double)num410 * 0.7);
                        if (Main.rand.Next(num410) == 0)
                        {
                            int num411 = 0;
                            float[] singleArray12 = new float[10];
                            for (int m3 = 0; m3 < 200; m3++)
                            {
                                if (num411 < 10 && Main.npc[m3].active && Main.npc[m3].type == 115)
                                {
                                    singleArray12[num411] = Main.npc[m3].ai[0];
                                    num411++;
                                }
                            }
                            int num412 = 1 + num411 * 2;
                            if (num411 < 10 && Main.rand.Next(num412) <= 1)
                            {
                                int num413 = -1;
                                int num414 = 0;
                                while (num414 < 1000)
                                {
                                    int num415 = Main.rand.Next(10);
                                    float single225 = (float)num415 * 0.1f - 0.05f;
                                    bool flag91 = true;
                                    int num416 = 0;
                                    while (num416 < num411)
                                    {
                                        if (single225 != singleArray12[num416])
                                        {
                                            num416++;
                                        }
                                        else
                                        {
                                            flag91 = false;
                                            break;
                                        }
                                    }
                                    if (!flag91)
                                    {
                                        num414++;
                                    }
                                    else
                                    {
                                        num413 = num415;
                                        break;
                                    }
                                }
                                if (num413 >= 0)
                                {
                                    int num417 = NPC.NewNPC((int)this.position.X, (int)single222, 115, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num417].ai[0] = (float)num413 * 0.1f - 0.05f;
                                }
                            }
                        }
                    }
                    if (this.localAI[0] == 1f && Main.netMode != 1)
                    {
                        this.localAI[0] = 2f;
                        single222 = (float)((Main.wofB + Main.wofT) / 2);
                        single222 = (single222 + (float)Main.wofT) / 2f;
                        int num418 = NPC.NewNPC((int)this.position.X, (int)single222, 114, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        Main.npc[num418].ai[0] = 1f;
                        single222 = (float)((Main.wofB + Main.wofT) / 2);
                        single222 = (single222 + (float)Main.wofB) / 2f;
                        num418 = NPC.NewNPC((int)this.position.X, (int)single222, 114, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        Main.npc[num418].ai[0] = -1f;
                        single222 = (float)((Main.wofB + Main.wofT) / 2);
                        single222 = (single222 + (float)Main.wofB) / 2f;
                        for (int n3 = 0; n3 < 11; n3++)
                        {
                            num418 = NPC.NewNPC((int)this.position.X, (int)single222, 115, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num418].ai[0] = (float)n3 * 0.1f - 0.05f;
                        }
                        return;
                    }
                }
                else if (this.aiStyle != 28)
                {
                    if (this.aiStyle == 29)
                    {
                        if (this.justHit)
                        {
                            this.ai[1] = 10f;
                        }
                        if (Main.wof < 0)
                        {
                            this.active = false;
                            return;
                        }
                        this.TargetClosest(true);
                        float single226 = 0.1f;
                        float single227 = 300f;
                        if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.25)
                        {
                            this.damage = (int)(75f * Main.damageMultiplier);
                            this.defense = 40;
                            if (Main.expertMode)
                            {
                                single226 = single226 + 0.1f;
                            }
                            else
                            {
                                single227 = 900f;
                            }
                        }
                        else if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.5)
                        {
                            this.damage = (int)(60f * Main.damageMultiplier);
                            this.defense = 30;
                            if (Main.expertMode)
                            {
                                single226 = single226 + 0.066f;
                            }
                            else
                            {
                                single227 = 700f;
                            }
                        }
                        else if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.75)
                        {
                            this.damage = (int)(45f * Main.damageMultiplier);
                            this.defense = 20;
                            if (Main.expertMode)
                            {
                                single226 = single226 + 0.033f;
                            }
                            else
                            {
                                single227 = 500f;
                            }
                        }
                        if (Main.expertMode)
                        {
                            this.defense = this.defDefense;
                            if (this.whoAmI % 4 == 0)
                            {
                                single227 = single227 * 1.75f;
                            }
                            if (this.whoAmI % 4 == 1)
                            {
                                single227 = single227 * 1.5f;
                            }
                            if (this.whoAmI % 4 == 2)
                            {
                                single227 = single227 * 1.25f;
                            }
                            if (this.whoAmI % 3 == 0)
                            {
                                single227 = single227 * 1.5f;
                            }
                            if (this.whoAmI % 3 == 1)
                            {
                                single227 = single227 * 1.25f;
                            }
                            single227 = single227 * 0.75f;
                        }
                        float x97 = Main.npc[Main.wof].position.X + (float)(Main.npc[Main.wof].width / 2);
                        float y93 = Main.npc[Main.wof].position.Y;
                        float single228 = (float)(Main.wofB - Main.wofT);
                        y93 = (float)Main.wofT + single228 * this.ai[0];
                        this.ai[2] = this.ai[2] + 1f;
                        if (this.ai[2] > 100f)
                        {
                            single227 = (float)((int)(single227 * 1.3f));
                            if (this.ai[2] > 200f)
                            {
                                this.ai[2] = 0f;
                            }
                        }
                        Vector2 vector2116 = new Vector2(x97, y93);
                        float x98 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - (float)(this.width / 2) - vector2116.X;
                        float y94 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - (float)(this.height / 2) - vector2116.Y;
                        float single229 = (float)Math.Sqrt((double)(x98 * x98 + y94 * y94));
                        if (this.ai[1] == 0f)
                        {
                            if (single229 > single227)
                            {
                                single229 = single227 / single229;
                                x98 = x98 * single229;
                                y94 = y94 * single229;
                            }
                            if (this.position.X < x97 + x98)
                            {
                                this.velocity.X = this.velocity.X + single226;
                                if (this.velocity.X < 0f && x98 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + single226 * 2.5f;
                                }
                            }
                            else if (this.position.X > x97 + x98)
                            {
                                this.velocity.X = this.velocity.X - single226;
                                if (this.velocity.X > 0f && x98 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - single226 * 2.5f;
                                }
                            }
                            if (this.position.Y < y93 + y94)
                            {
                                this.velocity.Y = this.velocity.Y + single226;
                                if (this.velocity.Y < 0f && y94 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + single226 * 2.5f;
                                }
                            }
                            else if (this.position.Y > y93 + y94)
                            {
                                this.velocity.Y = this.velocity.Y - single226;
                                if (this.velocity.Y > 0f && y94 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - single226 * 2.5f;
                                }
                            }
                            float single230 = 4f;
                            if (Main.expertMode && Main.wof >= 0)
                            {
                                float single231 = 1.5f;
                                float single232 = (float)(Main.npc[Main.wof].life / Main.npc[Main.wof].lifeMax);
                                if ((double)single232 < 0.75)
                                {
                                    single231 = single231 + 0.7f;
                                }
                                if ((double)single232 < 0.5)
                                {
                                    single231 = single231 + 0.7f;
                                }
                                if ((double)single232 < 0.25)
                                {
                                    single231 = single231 + 0.9f;
                                }
                                if ((double)single232 < 0.1)
                                {
                                    single231 = single231 + 0.9f;
                                }
                                single231 = single231 * 1.25f;
                                single231 = single231 + 0.3f;
                                single230 = single230 + single231 * 0.35f;
                                if (base.Center.X < Main.npc[Main.wof].Center.X && Main.npc[Main.wof].velocity.X > 0f)
                                {
                                    single230 = single230 + 6f;
                                }
                                if (base.Center.X > Main.npc[Main.wof].Center.X && Main.npc[Main.wof].velocity.X < 0f)
                                {
                                    single230 = single230 + 6f;
                                }
                            }
                            if (this.velocity.X > single230)
                            {
                                this.velocity.X = single230;
                            }
                            if (this.velocity.X < -single230)
                            {
                                this.velocity.X = -single230;
                            }
                            if (this.velocity.Y > single230)
                            {
                                this.velocity.Y = single230;
                            }
                            if (this.velocity.Y < -single230)
                            {
                                this.velocity.Y = -single230;
                            }
                        }
                        else if (this.ai[1] <= 0f)
                        {
                            this.ai[1] = 0f;
                        }
                        else
                        {
                            this.ai[1] = this.ai[1] - 1f;
                        }
                        if (x98 > 0f)
                        {
                            this.spriteDirection = 1;
                            this.rotation = (float)Math.Atan2((double)y94, (double)x98);
                        }
                        if (x98 < 0f)
                        {
                            this.spriteDirection = -1;
                            this.rotation = (float)Math.Atan2((double)y94, (double)x98) + 3.14f;
                        }
                        return;
                    }
                    if (this.aiStyle == 30)
                    {
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                        {
                            this.TargetClosest(true);
                        }
                        bool flag92 = Main.player[this.target].dead;
                        float x99 = this.position.X + (float)(this.width / 2) - Main.player[this.target].position.X - (float)(Main.player[this.target].width / 2);
                        float y95 = this.position.Y + (float)this.height - 59f - Main.player[this.target].position.Y - (float)(Main.player[this.target].height / 2);
                        float single233 = (float)Math.Atan2((double)y95, (double)x99) + 1.57f;
                        if (single233 < 0f)
                        {
                            single233 = single233 + 6.283f;
                        }
                        else if ((double)single233 > 6.283)
                        {
                            single233 = single233 - 6.283f;
                        }
                        float single234 = 0.1f;
                        if (this.rotation < single233)
                        {
                            if ((double)(single233 - this.rotation) <= 3.1415)
                            {
                                NPC nPC115 = this;
                                nPC115.rotation = nPC115.rotation + single234;
                            }
                            else
                            {
                                NPC nPC116 = this;
                                nPC116.rotation = nPC116.rotation - single234;
                            }
                        }
                        else if (this.rotation > single233)
                        {
                            if ((double)(this.rotation - single233) <= 3.1415)
                            {
                                NPC nPC117 = this;
                                nPC117.rotation = nPC117.rotation - single234;
                            }
                            else
                            {
                                NPC nPC118 = this;
                                nPC118.rotation = nPC118.rotation + single234;
                            }
                        }
                        if (this.rotation > single233 - single234 && this.rotation < single233 + single234)
                        {
                            this.rotation = single233;
                        }
                        if (this.rotation < 0f)
                        {
                            NPC nPC119 = this;
                            nPC119.rotation = nPC119.rotation + 6.283f;
                        }
                        else if ((double)this.rotation > 6.283)
                        {
                            NPC nPC120 = this;
                            nPC120.rotation = nPC120.rotation - 6.283f;
                        }
                        if (this.rotation > single233 - single234 && this.rotation < single233 + single234)
                        {
                            this.rotation = single233;
                        }
                        if (Main.netMode != 1 && !Main.dayTime && !flag92 && this.timeLeft < 10)
                        {
                            for (int o3 = 0; o3 < 200; o3++)
                            {
                                if (o3 != this.whoAmI && Main.npc[o3].active && (Main.npc[o3].type == 125 || Main.npc[o3].type == 126) && Main.npc[o3].timeLeft - 1 > this.timeLeft)
                                {
                                    this.timeLeft = Main.npc[o3].timeLeft - 1;
                                }
                            }
                        }
                        if (Main.dayTime || flag92)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if (this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                                return;
                            }
                        }
                        else if (this.ai[0] == 0f)
                        {
                            if (this.ai[1] == 0f)
                            {
                                float single235 = 7f;
                                float single236 = 0.1f;
                                if (Main.expertMode)
                                {
                                    single235 = 8.25f;
                                    single236 = 0.115f;
                                }
                                int num422 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num422 = -1;
                                }
                                Vector2 y96 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x101 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num422 * 300) - y96.X;
                                float y97 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 300f - y96.Y;
                                float single237 = (float)Math.Sqrt((double)(x101 * x101 + y97 * y97));
                                float single238 = single237;
                                single237 = single235 / single237;
                                x101 = x101 * single237;
                                y97 = y97 * single237;
                                if (this.velocity.X < x101)
                                {
                                    this.velocity.X = this.velocity.X + single236;
                                    if (this.velocity.X < 0f && x101 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single236;
                                    }
                                }
                                else if (this.velocity.X > x101)
                                {
                                    this.velocity.X = this.velocity.X - single236;
                                    if (this.velocity.X > 0f && x101 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single236;
                                    }
                                }
                                if (this.velocity.Y < y97)
                                {
                                    this.velocity.Y = this.velocity.Y + single236;
                                    if (this.velocity.Y < 0f && y97 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single236;
                                    }
                                }
                                else if (this.velocity.Y > y97)
                                {
                                    this.velocity.Y = this.velocity.Y - single236;
                                    if (this.velocity.Y > 0f && y97 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single236;
                                    }
                                }
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] >= 600f)
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.target = 255;
                                    this.netUpdate = true;
                                }
                                else if (this.position.Y + (float)this.height < Main.player[this.target].position.Y && single238 < 400f)
                                {
                                    if (!Main.player[this.target].dead)
                                    {
                                        this.ai[3] = this.ai[3] + 1f;
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.9)
                                        {
                                            this.ai[3] = this.ai[3] + 0.3f;
                                        }
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.8)
                                        {
                                            this.ai[3] = this.ai[3] + 0.3f;
                                        }
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.7)
                                        {
                                            this.ai[3] = this.ai[3] + 0.3f;
                                        }
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.6)
                                        {
                                            this.ai[3] = this.ai[3] + 0.3f;
                                        }
                                    }
                                    if (this.ai[3] >= 60f)
                                    {
                                        this.ai[3] = 0f;
                                        y96 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        x101 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y96.X;
                                        y97 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y96.Y;
                                        if (Main.netMode != 1)
                                        {
                                            float single239 = 9f;
                                            int num423 = 20;
                                            int num424 = 83;
                                            if (Main.expertMode)
                                            {
                                                single239 = 10.5f;
                                                num423 = 18;
                                            }
                                            single237 = (float)Math.Sqrt((double)(x101 * x101 + y97 * y97));
                                            single237 = single239 / single237;
                                            x101 = x101 * single237;
                                            y97 = y97 * single237;
                                            x101 = x101 + (float)Main.rand.Next(-40, 41) * 0.08f;
                                            y97 = y97 + (float)Main.rand.Next(-40, 41) * 0.08f;
                                            y96.X = y96.X + x101 * 15f;
                                            y96.Y = y96.Y + y97 * 15f;
                                            Projectile.NewProjectile(y96.X, y96.Y, x101, y97, num424, num423, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                    }
                                }
                            }
                            else if (this.ai[1] == 1f)
                            {
                                this.rotation = single233;
                                float single240 = 12f;
                                if (Main.expertMode)
                                {
                                    single240 = 15f;
                                }
                                Vector2 vector2118 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x102 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2118.X;
                                float y98 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2118.Y;
                                float single241 = (float)Math.Sqrt((double)(x102 * x102 + y98 * y98));
                                single241 = single240 / single241;
                                this.velocity.X = x102 * single241;
                                this.velocity.Y = y98 * single241;
                                this.ai[1] = 2f;
                            }
                            else if (this.ai[1] == 2f)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] < 25f)
                                {
                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                    {
                                        this.velocity.X = 0f;
                                    }
                                    if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                                    {
                                        this.velocity.Y = 0f;
                                    }
                                }
                                if (this.ai[2] >= 70f)
                                {
                                    this.ai[3] = this.ai[3] + 1f;
                                    this.ai[2] = 0f;
                                    this.target = 255;
                                    this.rotation = single233;
                                    if (this.ai[3] < 4f)
                                    {
                                        this.ai[1] = 1f;
                                    }
                                    else
                                    {
                                        this.ai[1] = 0f;
                                        this.ai[3] = 0f;
                                    }
                                }
                            }
                            if ((double)this.life < (double)this.lifeMax * 0.4)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.ai[0] == 1f || this.ai[0] == 2f)
                        {
                            if (this.ai[0] != 1f)
                            {
                                this.ai[2] = this.ai[2] - 0.005f;
                                if (this.ai[2] < 0f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            else
                            {
                                this.ai[2] = this.ai[2] + 0.005f;
                                if ((double)this.ai[2] > 0.5)
                                {
                                    this.ai[2] = 0.5f;
                                }
                            }
                            NPC nPC121 = this;
                            nPC121.rotation = nPC121.rotation + this.ai[2];
                            this.ai[1] = this.ai[1] + 1f;
                            if (this.ai[1] == 100f)
                            {
                                this.ai[0] = this.ai[0] + 1f;
                                this.ai[1] = 0f;
                                if (this.ai[0] == 3f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                                return;
                            }
                        }
                        else
                        {
                            this.damage = (int)((double)this.defDamage * 1.5);
                            this.defense = this.defDefense + 10;
                            this.soundHit = 4;
                            if (this.ai[1] != 0f)
                            {
                                int num429 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num429 = -1;
                                }
                                float single242 = 8f;
                                float single243 = 0.2f;
                                if (Main.expertMode)
                                {
                                    single242 = 9.5f;
                                    single243 = 0.25f;
                                }
                                Vector2 y99 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x103 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num429 * 340) - y99.X;
                                float y100 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y99.Y;
                                float single244 = (float)Math.Sqrt((double)(x103 * x103 + y100 * y100));
                                single244 = single242 / single244;
                                x103 = x103 * single244;
                                y100 = y100 * single244;
                                if (this.velocity.X < x103)
                                {
                                    this.velocity.X = this.velocity.X + single243;
                                    if (this.velocity.X < 0f && x103 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single243;
                                    }
                                }
                                else if (this.velocity.X > x103)
                                {
                                    this.velocity.X = this.velocity.X - single243;
                                    if (this.velocity.X > 0f && x103 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single243;
                                    }
                                }
                                if (this.velocity.Y < y100)
                                {
                                    this.velocity.Y = this.velocity.Y + single243;
                                    if (this.velocity.Y < 0f && y100 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single243;
                                    }
                                }
                                else if (this.velocity.Y > y100)
                                {
                                    this.velocity.Y = this.velocity.Y - single243;
                                    if (this.velocity.Y > 0f && y100 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single243;
                                    }
                                }
                                y99 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                x103 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y99.X;
                                y100 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y99.Y;
                                this.rotation = (float)Math.Atan2((double)y100, (double)x103) - 1.57f;
                                if (Main.netMode != 1)
                                {
                                    this.localAI[1] = this.localAI[1] + 1f;
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        this.localAI[1] = this.localAI[1] + 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        this.localAI[1] = this.localAI[1] + 0.75f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1.5f;
                                    }
                                    if (Main.expertMode)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if (this.localAI[1] > 60f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                    {
                                        this.localAI[1] = 0f;
                                        float single245 = 9f;
                                        int num430 = 18;
                                        int num431 = 100;
                                        if (Main.expertMode)
                                        {
                                            num430 = 16;
                                        }
                                        single244 = (float)Math.Sqrt((double)(x103 * x103 + y100 * y100));
                                        single244 = single245 / single244;
                                        x103 = x103 * single244;
                                        y100 = y100 * single244;
                                        y99.X = y99.X + x103 * 15f;
                                        y99.Y = y99.Y + y100 * 15f;
                                        Projectile.NewProjectile(y99.X, y99.Y, x103, y100, num431, num430, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                }
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] >= 180f)
                                {
                                    this.ai[1] = 0f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.TargetClosest(true);
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else
                            {
                                float single246 = 8f;
                                float single247 = 0.15f;
                                if (Main.expertMode)
                                {
                                    single246 = 9.5f;
                                    single247 = 0.175f;
                                }
                                Vector2 y101 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x104 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y101.X;
                                float y102 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 300f - y101.Y;
                                float single248 = (float)Math.Sqrt((double)(x104 * x104 + y102 * y102));
                                single248 = single246 / single248;
                                x104 = x104 * single248;
                                y102 = y102 * single248;
                                if (this.velocity.X < x104)
                                {
                                    this.velocity.X = this.velocity.X + single247;
                                    if (this.velocity.X < 0f && x104 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single247;
                                    }
                                }
                                else if (this.velocity.X > x104)
                                {
                                    this.velocity.X = this.velocity.X - single247;
                                    if (this.velocity.X > 0f && x104 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single247;
                                    }
                                }
                                if (this.velocity.Y < y102)
                                {
                                    this.velocity.Y = this.velocity.Y + single247;
                                    if (this.velocity.Y < 0f && y102 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single247;
                                    }
                                }
                                else if (this.velocity.Y > y102)
                                {
                                    this.velocity.Y = this.velocity.Y - single247;
                                    if (this.velocity.Y > 0f && y102 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single247;
                                    }
                                }
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] >= 300f)
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.TargetClosest(true);
                                    this.netUpdate = true;
                                }
                                y101 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                x104 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y101.X;
                                y102 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y101.Y;
                                this.rotation = (float)Math.Atan2((double)y102, (double)x104) - 1.57f;
                                if (Main.netMode != 1)
                                {
                                    this.localAI[1] = this.localAI[1] + 1f;
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        this.localAI[1] = this.localAI[1] + 2f;
                                    }
                                    if (this.localAI[1] > 180f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                    {
                                        this.localAI[1] = 0f;
                                        float single249 = 8.5f;
                                        int num432 = 25;
                                        int num433 = 100;
                                        if (Main.expertMode)
                                        {
                                            single249 = 10f;
                                            num432 = 21;
                                        }
                                        single248 = (float)Math.Sqrt((double)(x104 * x104 + y102 * y102));
                                        single248 = single249 / single248;
                                        x104 = x104 * single248;
                                        y102 = y102 * single248;
                                        y101.X = y101.X + x104 * 15f;
                                        y101.Y = y101.Y + y102 * 15f;
                                        Projectile.NewProjectile(y101.X, y101.Y, x104, y102, num433, num432, 0f, Main.myPlayer, 0f, 0f);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 31)
                    {
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                        {
                            this.TargetClosest(true);
                        }
                        bool flag93 = Main.player[this.target].dead;
                        float x105 = this.position.X + (float)(this.width / 2) - Main.player[this.target].position.X - (float)(Main.player[this.target].width / 2);
                        float y103 = this.position.Y + (float)this.height - 59f - Main.player[this.target].position.Y - (float)(Main.player[this.target].height / 2);
                        float single250 = (float)Math.Atan2((double)y103, (double)x105) + 1.57f;
                        if (single250 < 0f)
                        {
                            single250 = single250 + 6.283f;
                        }
                        else if ((double)single250 > 6.283)
                        {
                            single250 = single250 - 6.283f;
                        }
                        float single251 = 0.15f;
                        if (this.rotation < single250)
                        {
                            if ((double)(single250 - this.rotation) <= 3.1415)
                            {
                                NPC nPC122 = this;
                                nPC122.rotation = nPC122.rotation + single251;
                            }
                            else
                            {
                                NPC nPC123 = this;
                                nPC123.rotation = nPC123.rotation - single251;
                            }
                        }
                        else if (this.rotation > single250)
                        {
                            if ((double)(this.rotation - single250) <= 3.1415)
                            {
                                NPC nPC124 = this;
                                nPC124.rotation = nPC124.rotation - single251;
                            }
                            else
                            {
                                NPC nPC125 = this;
                                nPC125.rotation = nPC125.rotation + single251;
                            }
                        }
                        if (this.rotation > single250 - single251 && this.rotation < single250 + single251)
                        {
                            this.rotation = single250;
                        }
                        if (this.rotation < 0f)
                        {
                            NPC nPC126 = this;
                            nPC126.rotation = nPC126.rotation + 6.283f;
                        }
                        else if ((double)this.rotation > 6.283)
                        {
                            NPC nPC127 = this;
                            nPC127.rotation = nPC127.rotation - 6.283f;
                        }
                        if (this.rotation > single250 - single251 && this.rotation < single250 + single251)
                        {
                            this.rotation = single250;
                        }
                        if (Main.netMode != 1 && !Main.dayTime && !flag93 && this.timeLeft < 10)
                        {
                            for (int r3 = 0; r3 < 200; r3++)
                            {
                                if (r3 != this.whoAmI && Main.npc[r3].active && (Main.npc[r3].type == 125 || Main.npc[r3].type == 126) && Main.npc[r3].timeLeft - 1 > this.timeLeft)
                                {
                                    this.timeLeft = Main.npc[r3].timeLeft - 1;
                                }
                            }
                        }
                        if (Main.dayTime || flag93)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if (this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                                return;
                            }
                        }
                        else if (this.ai[0] == 0f)
                        {
                            if (this.ai[1] == 0f)
                            {
                                this.TargetClosest(true);
                                float single252 = 12f;
                                float single253 = 0.4f;
                                int num437 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num437 = -1;
                                }
                                Vector2 y104 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x107 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num437 * 400) - y104.X;
                                float y105 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y104.Y;
                                float single254 = (float)Math.Sqrt((double)(x107 * x107 + y105 * y105));
                                single254 = single252 / single254;
                                x107 = x107 * single254;
                                y105 = y105 * single254;
                                if (this.velocity.X < x107)
                                {
                                    this.velocity.X = this.velocity.X + single253;
                                    if (this.velocity.X < 0f && x107 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single253;
                                    }
                                }
                                else if (this.velocity.X > x107)
                                {
                                    this.velocity.X = this.velocity.X - single253;
                                    if (this.velocity.X > 0f && x107 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single253;
                                    }
                                }
                                if (this.velocity.Y < y105)
                                {
                                    this.velocity.Y = this.velocity.Y + single253;
                                    if (this.velocity.Y < 0f && y105 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single253;
                                    }
                                }
                                else if (this.velocity.Y > y105)
                                {
                                    this.velocity.Y = this.velocity.Y - single253;
                                    if (this.velocity.Y > 0f && y105 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single253;
                                    }
                                }
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] < 600f)
                                {
                                    if (!Main.player[this.target].dead)
                                    {
                                        this.ai[3] = this.ai[3] + 1f;
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.8)
                                        {
                                            this.ai[3] = this.ai[3] + 0.5f;
                                        }
                                    }
                                    if (this.ai[3] >= 60f)
                                    {
                                        this.ai[3] = 0f;
                                        y104 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        x107 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y104.X;
                                        y105 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y104.Y;
                                        if (Main.netMode != 1)
                                        {
                                            float single255 = 12f;
                                            int num438 = 25;
                                            int num439 = 96;
                                            if (Main.expertMode)
                                            {
                                                single255 = 13.5f;
                                                num438 = 21;
                                            }
                                            single254 = (float)Math.Sqrt((double)(x107 * x107 + y105 * y105));
                                            single254 = single255 / single254;
                                            x107 = x107 * single254;
                                            y105 = y105 * single254;
                                            x107 = x107 + (float)Main.rand.Next(-40, 41) * 0.05f;
                                            y105 = y105 + (float)Main.rand.Next(-40, 41) * 0.05f;
                                            y104.X = y104.X + x107 * 4f;
                                            y104.Y = y104.Y + y105 * 4f;
                                            Projectile.NewProjectile(y104.X, y104.Y, x107, y105, num439, num438, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                    }
                                }
                                else
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.target = 255;
                                    this.netUpdate = true;
                                }
                            }
                            else if (this.ai[1] == 1f)
                            {
                                this.rotation = single250;
                                float single256 = 13f;
                                if (Main.expertMode)
                                {
                                    if ((double)this.life < (double)this.lifeMax * 0.9)
                                    {
                                        single256 = single256 + 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.8)
                                    {
                                        single256 = single256 + 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.7)
                                    {
                                        single256 = single256 + 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.6)
                                    {
                                        single256 = single256 + 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        single256 = single256 + 0.5f;
                                    }
                                }
                                Vector2 vector2122 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x108 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2122.X;
                                float y106 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2122.Y;
                                float single257 = (float)Math.Sqrt((double)(x108 * x108 + y106 * y106));
                                single257 = single256 / single257;
                                this.velocity.X = x108 * single257;
                                this.velocity.Y = y106 * single257;
                                this.ai[1] = 2f;
                            }
                            else if (this.ai[1] == 2f)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] < 8f)
                                {
                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                    {
                                        this.velocity.X = 0f;
                                    }
                                    if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                                    {
                                        this.velocity.Y = 0f;
                                    }
                                }
                                if (this.ai[2] >= 42f)
                                {
                                    this.ai[3] = this.ai[3] + 1f;
                                    this.ai[2] = 0f;
                                    this.target = 255;
                                    this.rotation = single250;
                                    if (this.ai[3] < 10f)
                                    {
                                        this.ai[1] = 1f;
                                    }
                                    else
                                    {
                                        this.ai[1] = 0f;
                                        this.ai[3] = 0f;
                                    }
                                }
                            }
                            if ((double)this.life < (double)this.lifeMax * 0.4)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.ai[0] == 1f || this.ai[0] == 2f)
                        {
                            if (this.ai[0] != 1f)
                            {
                                this.ai[2] = this.ai[2] - 0.005f;
                                if (this.ai[2] < 0f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            else
                            {
                                this.ai[2] = this.ai[2] + 0.005f;
                                if ((double)this.ai[2] > 0.5)
                                {
                                    this.ai[2] = 0.5f;
                                }
                            }
                            NPC nPC128 = this;
                            nPC128.rotation = nPC128.rotation + this.ai[2];
                            this.ai[1] = this.ai[1] + 1f;
                            if (this.ai[1] == 100f)
                            {
                                this.ai[0] = this.ai[0] + 1f;
                                this.ai[1] = 0f;
                                if (this.ai[0] == 3f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                                return;
                            }
                        }
                        else
                        {
                            this.soundHit = 4;
                            this.damage = (int)((double)this.defDamage * 1.5);
                            this.defense = this.defDefense + 18;
                            if (this.ai[1] != 0f)
                            {
                                if (this.ai[1] == 1f)
                                {
                                    this.rotation = single250;
                                    float single258 = 14f;
                                    if (Main.expertMode)
                                    {
                                        single258 = single258 + 2f;
                                    }
                                    Vector2 vector2125 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float x109 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2125.X;
                                    float y107 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2125.Y;
                                    float single259 = (float)Math.Sqrt((double)(x109 * x109 + y107 * y107));
                                    single259 = single258 / single259;
                                    this.velocity.X = x109 * single259;
                                    this.velocity.Y = y107 * single259;
                                    this.ai[1] = 2f;
                                    return;
                                }
                                if (this.ai[1] == 2f)
                                {
                                    this.ai[2] = this.ai[2] + 1f;
                                    if (Main.expertMode)
                                    {
                                        this.ai[2] = this.ai[2] + 0.5f;
                                    }
                                    if (this.ai[2] < 50f)
                                    {
                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X * 0.93f;
                                        this.velocity.Y = this.velocity.Y * 0.93f;
                                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                        {
                                            this.velocity.X = 0f;
                                        }
                                        if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                                        {
                                            this.velocity.Y = 0f;
                                        }
                                    }
                                    if (this.ai[2] >= 80f)
                                    {
                                        this.ai[3] = this.ai[3] + 1f;
                                        this.ai[2] = 0f;
                                        this.target = 255;
                                        this.rotation = single250;
                                        if (this.ai[3] < 6f)
                                        {
                                            this.ai[1] = 1f;
                                            return;
                                        }
                                        this.ai[1] = 0f;
                                        this.ai[3] = 0f;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                float single260 = 4f;
                                float single261 = 0.1f;
                                int num444 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num444 = -1;
                                }
                                Vector2 y108 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x111 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num444 * 180) - y108.X;
                                float y109 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y108.Y;
                                float single262 = (float)Math.Sqrt((double)(x111 * x111 + y109 * y109));
                                if (Main.expertMode)
                                {
                                    if (single262 > 300f)
                                    {
                                        single260 = single260 + 0.5f;
                                    }
                                    if (single262 > 400f)
                                    {
                                        single260 = single260 + 0.5f;
                                    }
                                    if (single262 > 500f)
                                    {
                                        single260 = single260 + 0.5f;
                                    }
                                    if (single262 > 600f)
                                    {
                                        single260 = single260 + 0.5f;
                                    }
                                    if (single262 > 700f)
                                    {
                                        single260 = single260 + 0.5f;
                                    }
                                    if (single262 > 800f)
                                    {
                                        single260 = single260 + 0.5f;
                                    }
                                }
                                single262 = single260 / single262;
                                x111 = x111 * single262;
                                y109 = y109 * single262;
                                if (this.velocity.X < x111)
                                {
                                    this.velocity.X = this.velocity.X + single261;
                                    if (this.velocity.X < 0f && x111 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single261;
                                    }
                                }
                                else if (this.velocity.X > x111)
                                {
                                    this.velocity.X = this.velocity.X - single261;
                                    if (this.velocity.X > 0f && x111 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single261;
                                    }
                                }
                                if (this.velocity.Y < y109)
                                {
                                    this.velocity.Y = this.velocity.Y + single261;
                                    if (this.velocity.Y < 0f && y109 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single261;
                                    }
                                }
                                else if (this.velocity.Y > y109)
                                {
                                    this.velocity.Y = this.velocity.Y - single261;
                                    if (this.velocity.Y > 0f && y109 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single261;
                                    }
                                }
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] >= 400f)
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.target = 255;
                                    this.netUpdate = true;
                                }
                                if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                {
                                    this.localAI[2] = this.localAI[2] + 1f;
                                    if (this.localAI[2] > 22f)
                                    {
                                        this.localAI[2] = 0f;
                                    }
                                    if (Main.netMode != 1)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.1)
                                        {
                                            this.localAI[1] = this.localAI[1] + 2f;
                                        }
                                        if (this.localAI[1] > 8f)
                                        {
                                            this.localAI[1] = 0f;
                                            float single263 = 6f;
                                            int num445 = 30;
                                            if (Main.expertMode)
                                            {
                                                num445 = 26;
                                            }
                                            int num446 = 101;
                                            y108 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            x111 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y108.X;
                                            y109 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y108.Y;
                                            single262 = (float)Math.Sqrt((double)(x111 * x111 + y109 * y109));
                                            single262 = single263 / single262;
                                            x111 = x111 * single262;
                                            y109 = y109 * single262;
                                            y109 = y109 + (float)Main.rand.Next(-40, 41) * 0.01f;
                                            x111 = x111 + (float)Main.rand.Next(-40, 41) * 0.01f;
                                            y109 = y109 + this.velocity.Y * 0.5f;
                                            x111 = x111 + this.velocity.X * 0.5f;
                                            y108.X = y108.X - x111 * 1f;
                                            y108.Y = y108.Y - y109 * 1f;
                                            Projectile.NewProjectile(y108.X, y108.Y, x111, y109, num446, num445, 0f, Main.myPlayer, 0f, 0f);
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 32)
                    {
                        this.damage = this.defDamage;
                        this.defense = this.defDefense;
                        if (this.ai[0] == 0f && Main.netMode != 1)
                        {
                            this.TargetClosest(true);
                            this.ai[0] = 1f;
                            int num447 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 128, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num447].ai[0] = -1f;
                            Main.npc[num447].ai[1] = (float)this.whoAmI;
                            Main.npc[num447].target = this.target;
                            Main.npc[num447].netUpdate = true;
                            num447 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 129, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num447].ai[0] = 1f;
                            Main.npc[num447].ai[1] = (float)this.whoAmI;
                            Main.npc[num447].target = this.target;
                            Main.npc[num447].netUpdate = true;
                            num447 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 130, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num447].ai[0] = -1f;
                            Main.npc[num447].ai[1] = (float)this.whoAmI;
                            Main.npc[num447].target = this.target;
                            Main.npc[num447].ai[3] = 150f;
                            Main.npc[num447].netUpdate = true;
                            num447 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 131, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num447].ai[0] = 1f;
                            Main.npc[num447].ai[1] = (float)this.whoAmI;
                            Main.npc[num447].target = this.target;
                            Main.npc[num447].netUpdate = true;
                            Main.npc[num447].ai[3] = 150f;
                        }
                        if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 6000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 6000f)
                        {
                            this.TargetClosest(true);
                            if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 6000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 6000f)
                            {
                                this.ai[1] = 3f;
                            }
                        }
                        if (Main.dayTime && this.ai[1] != 3f && this.ai[1] != 2f)
                        {
                            this.ai[1] = 2f;
                        }
                        if (this.ai[1] != 0f)
                        {
                            if (this.ai[1] == 1f)
                            {
                                NPC nPC129 = this;
                                nPC129.defense = nPC129.defense * 2;
                                NPC nPC130 = this;
                                nPC130.damage = nPC130.damage * 2;
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.ai[2] >= 400f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                }
                                NPC nPC131 = this;
                                nPC131.rotation = nPC131.rotation + (float)this.direction * 0.3f;
                                Vector2 vector2126 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x112 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2126.X;
                                float y111 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2126.Y;
                                float single264 = (float)Math.Sqrt((double)(x112 * x112 + y111 * y111));
                                single264 = 2f / single264;
                                this.velocity.X = x112 * single264;
                                this.velocity.Y = y111 * single264;
                                return;
                            }
                            if (this.ai[1] == 2f)
                            {
                                this.damage = 1000;
                                this.defense = 9999;
                                NPC nPC132 = this;
                                nPC132.rotation = nPC132.rotation + (float)this.direction * 0.3f;
                                Vector2 vector2127 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x113 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2127.X;
                                float y112 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2127.Y;
                                float single265 = (float)Math.Sqrt((double)(x113 * x113 + y112 * y112));
                                float single266 = 10f;
                                single266 = single266 + single265 / 100f;
                                if (single266 < 8f)
                                {
                                    single266 = 8f;
                                }
                                if (single266 > 32f)
                                {
                                    single266 = 32f;
                                }
                                single265 = single266 / single265;
                                this.velocity.X = x113 * single265;
                                this.velocity.Y = y112 * single265;
                                return;
                            }
                            if (this.ai[1] == 3f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.95f;
                                }
                                this.velocity.X = this.velocity.X * 0.95f;
                                if (this.timeLeft > 500)
                                {
                                    this.timeLeft = 500;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            this.ai[2] = this.ai[2] + 1f;
                            if (this.ai[2] >= 600f)
                            {
                                this.ai[2] = 0f;
                                this.ai[1] = 1f;
                                this.TargetClosest(true);
                                this.netUpdate = true;
                            }
                            this.rotation = this.velocity.X / 15f;
                            if (this.position.Y > Main.player[this.target].position.Y - 200f)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.98f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y > 2f)
                                {
                                    this.velocity.Y = 2f;
                                }
                            }
                            else if (this.position.Y < Main.player[this.target].position.Y - 500f)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.98f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < -2f)
                                {
                                    this.velocity.Y = -2f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + 100f)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                this.velocity.X = this.velocity.X - 0.1f;
                                if (this.velocity.X > 8f)
                                {
                                    this.velocity.X = 8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - 100f)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                this.velocity.X = this.velocity.X + 0.1f;
                                if (this.velocity.X < -8f)
                                {
                                    this.velocity.X = -8f;
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 33)
                    {
                        Vector2 vector2128 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x114 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2128.X;
                        float y113 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2128.Y;
                        float single267 = (float)Math.Sqrt((double)(x114 * x114 + y113 * y113));
                        if (this.ai[2] != 99f)
                        {
                            if (single267 > 800f)
                            {
                                this.ai[2] = 99f;
                            }
                        }
                        else if (single267 < 400f)
                        {
                            this.ai[2] = 0f;
                        }
                        this.spriteDirection = -(int)this.ai[0];
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] = this.ai[2] + 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] != 99f)
                        {
                            if (this.ai[2] == 0f || this.ai[2] == 3f)
                            {
                                if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                                {
                                    this.timeLeft = 10;
                                }
                                if (Main.npc[(int)this.ai[1]].ai[1] == 0f)
                                {
                                    this.ai[3] = this.ai[3] + 1f;
                                    if (this.ai[3] >= 300f)
                                    {
                                        this.ai[2] = this.ai[2] + 1f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                    if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 320f)
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y - 0.04f;
                                        if (this.velocity.Y > 3f)
                                        {
                                            this.velocity.Y = 3f;
                                        }
                                    }
                                    else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 260f)
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y + 0.04f;
                                        if (this.velocity.Y < -3f)
                                        {
                                            this.velocity.Y = -3f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.96f;
                                        }
                                        this.velocity.X = this.velocity.X - 0.3f;
                                        if (this.velocity.X > 12f)
                                        {
                                            this.velocity.X = 12f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 250f)
                                    {
                                        if (this.velocity.X < 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.96f;
                                        }
                                        this.velocity.X = this.velocity.X + 0.3f;
                                        if (this.velocity.X < -12f)
                                        {
                                            this.velocity.X = -12f;
                                        }
                                    }
                                }
                                else
                                {
                                    this.TargetClosest(true);
                                    if (!Main.player[this.target].dead)
                                    {
                                        Vector2 vector2129 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float x115 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2129.X;
                                        float y114 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2129.Y;
                                        float single268 = (float)Math.Sqrt((double)(x115 * x115 + y114 * y114));
                                        single268 = 7f / single268;
                                        x115 = x115 * single268;
                                        y114 = y114 * single268;
                                        this.rotation = (float)Math.Atan2((double)y114, (double)x115) - 1.57f;
                                        if (this.velocity.X > x115)
                                        {
                                            if (this.velocity.X > 0f)
                                            {
                                                this.velocity.X = this.velocity.X * 0.97f;
                                            }
                                            this.velocity.X = this.velocity.X - 0.05f;
                                        }
                                        if (this.velocity.X < x115)
                                        {
                                            if (this.velocity.X < 0f)
                                            {
                                                this.velocity.X = this.velocity.X * 0.97f;
                                            }
                                            this.velocity.X = this.velocity.X + 0.05f;
                                        }
                                        if (this.velocity.Y > y114)
                                        {
                                            if (this.velocity.Y > 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y * 0.97f;
                                            }
                                            this.velocity.Y = this.velocity.Y - 0.05f;
                                        }
                                        if (this.velocity.Y < y114)
                                        {
                                            if (this.velocity.Y < 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y * 0.97f;
                                            }
                                            this.velocity.Y = this.velocity.Y + 0.05f;
                                        }
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                        if (this.velocity.Y > 16f)
                                        {
                                            this.velocity.Y = 16f;
                                        }
                                    }
                                    this.ai[3] = this.ai[3] + 1f;
                                    if (this.ai[3] >= 600f)
                                    {
                                        this.ai[2] = 0f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                }
                                Vector2 vector2130 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x116 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2130.X;
                                float y115 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2130.Y;
                                Math.Sqrt((double)(x116 * x116 + y115 * y115));
                                this.rotation = (float)Math.Atan2((double)y115, (double)x116) + 1.57f;
                                return;
                            }
                            if (this.ai[2] == 1f)
                            {
                                Vector2 vector2131 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x117 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2131.X;
                                float y116 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2131.Y;
                                float single269 = (float)Math.Sqrt((double)(x117 * x117 + y116 * y116));
                                this.rotation = (float)Math.Atan2((double)y116, (double)x117) + 1.57f;
                                this.velocity.X = this.velocity.X * 0.95f;
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y < -8f)
                                {
                                    this.velocity.Y = -8f;
                                }
                                if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 200f)
                                {
                                    this.TargetClosest(true);
                                    this.ai[2] = 2f;
                                    vector2131 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    x117 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2131.X;
                                    y116 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2131.Y;
                                    single269 = (float)Math.Sqrt((double)(x117 * x117 + y116 * y116));
                                    single269 = 22f / single269;
                                    this.velocity.X = x117 * single269;
                                    this.velocity.Y = y116 * single269;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else if (this.ai[2] != 2f)
                            {
                                if (this.ai[2] == 4f)
                                {
                                    this.TargetClosest(true);
                                    Vector2 vector2132 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float x118 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2132.X;
                                    float y117 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2132.Y;
                                    float single270 = (float)Math.Sqrt((double)(x118 * x118 + y117 * y117));
                                    single270 = 7f / single270;
                                    x118 = x118 * single270;
                                    y117 = y117 * single270;
                                    if (this.velocity.X > x118)
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.97f;
                                        }
                                        this.velocity.X = this.velocity.X - 0.05f;
                                    }
                                    if (this.velocity.X < x118)
                                    {
                                        if (this.velocity.X < 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.97f;
                                        }
                                        this.velocity.X = this.velocity.X + 0.05f;
                                    }
                                    if (this.velocity.Y > y117)
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.97f;
                                        }
                                        this.velocity.Y = this.velocity.Y - 0.05f;
                                    }
                                    if (this.velocity.Y < y117)
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.97f;
                                        }
                                        this.velocity.Y = this.velocity.Y + 0.05f;
                                    }
                                    this.ai[3] = this.ai[3] + 1f;
                                    if (this.ai[3] >= 600f)
                                    {
                                        this.ai[2] = 0f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                    vector2132 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    x118 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2132.X;
                                    y117 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2132.Y;
                                    single270 = (float)Math.Sqrt((double)(x118 * x118 + y117 * y117));
                                    this.rotation = (float)Math.Atan2((double)y117, (double)x118) + 1.57f;
                                    return;
                                }
                                if (this.ai[2] == 5f && (this.velocity.X > 0f && this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) || this.velocity.X < 0f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)))
                                {
                                    this.ai[2] = 0f;
                                    return;
                                }
                            }
                            else if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f)
                            {
                                this.ai[2] = 3f;
                                return;
                            }
                        }
                        else
                        {
                            if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y > 8f)
                                {
                                    this.velocity.Y = 8f;
                                }
                            }
                            else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < -8f)
                                {
                                    this.velocity.Y = -8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X - 0.5f;
                                if (this.velocity.X > 12f)
                                {
                                    this.velocity.X = 12f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X + 0.5f;
                                if (this.velocity.X < -12f)
                                {
                                    this.velocity.X = -12f;
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 34)
                    {
                        this.spriteDirection = -(int)this.ai[0];
                        Vector2 vector2133 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x119 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2133.X;
                        float y118 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2133.Y;
                        float single271 = (float)Math.Sqrt((double)(x119 * x119 + y118 * y118));
                        if (this.ai[2] != 99f)
                        {
                            if (single271 > 800f)
                            {
                                this.ai[2] = 99f;
                            }
                        }
                        else if (single271 < 400f)
                        {
                            this.ai[2] = 0f;
                        }
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] = this.ai[2] + 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] != 99f)
                        {
                            if (this.ai[2] == 0f || this.ai[2] == 3f)
                            {
                                if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                                {
                                    this.timeLeft = 10;
                                }
                                if (Main.npc[(int)this.ai[1]].ai[1] == 0f)
                                {
                                    this.ai[3] = this.ai[3] + 1f;
                                    if (this.ai[3] >= 600f)
                                    {
                                        this.ai[2] = this.ai[2] + 1f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                    if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 300f)
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y - 0.1f;
                                        if (this.velocity.Y > 3f)
                                        {
                                            this.velocity.Y = 3f;
                                        }
                                    }
                                    else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 230f)
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                        if (this.velocity.Y < -3f)
                                        {
                                            this.velocity.Y = -3f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 250f)
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.94f;
                                        }
                                        this.velocity.X = this.velocity.X - 0.3f;
                                        if (this.velocity.X > 9f)
                                        {
                                            this.velocity.X = 9f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                                    {
                                        if (this.velocity.X < 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.94f;
                                        }
                                        this.velocity.X = this.velocity.X + 0.2f;
                                        if (this.velocity.X < -8f)
                                        {
                                            this.velocity.X = -8f;
                                        }
                                    }
                                }
                                else
                                {
                                    this.TargetClosest(true);
                                    this.TargetClosest(true);
                                    if (!Main.player[this.target].dead)
                                    {
                                        Vector2 vector2134 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float x120 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2134.X;
                                        float y119 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2134.Y;
                                        float single272 = (float)Math.Sqrt((double)(x120 * x120 + y119 * y119));
                                        single272 = 12f / single272;
                                        x120 = x120 * single272;
                                        y119 = y119 * single272;
                                        this.rotation = (float)Math.Atan2((double)y119, (double)x120) - 1.57f;
                                        if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) >= 2f)
                                        {
                                            NPC nPC133 = this;
                                            nPC133.velocity = nPC133.velocity * 0.97f;
                                        }
                                        else
                                        {
                                            this.rotation = (float)Math.Atan2((double)y119, (double)x120) - 1.57f;
                                            this.velocity.X = x120;
                                            this.velocity.Y = y119;
                                            this.netUpdate = true;
                                        }
                                        this.ai[3] = this.ai[3] + 1f;
                                        if (this.ai[3] >= 600f)
                                        {
                                            this.ai[2] = 0f;
                                            this.ai[3] = 0f;
                                            this.netUpdate = true;
                                        }
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                        if (this.velocity.Y > 16f)
                                        {
                                            this.velocity.Y = 16f;
                                        }
                                    }
                                }
                                Vector2 vector2135 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x121 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2135.X;
                                float y120 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2135.Y;
                                Math.Sqrt((double)(x121 * x121 + y120 * y120));
                                this.rotation = (float)Math.Atan2((double)y120, (double)x121) + 1.57f;
                                return;
                            }
                            if (this.ai[2] == 1f)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                Vector2 vector2136 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x122 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 280f * this.ai[0] - vector2136.X;
                                float y121 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2136.Y;
                                float single273 = (float)Math.Sqrt((double)(x122 * x122 + y121 * y121));
                                this.rotation = (float)Math.Atan2((double)y121, (double)x122) + 1.57f;
                                this.velocity.X = (this.velocity.X * 5f + Main.npc[(int)this.ai[1]].velocity.X) / 6f;
                                this.velocity.X = this.velocity.X + 0.5f;
                                this.velocity.Y = this.velocity.Y - 0.5f;
                                if (this.velocity.Y < -9f)
                                {
                                    this.velocity.Y = -9f;
                                }
                                if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 280f)
                                {
                                    this.TargetClosest(true);
                                    this.ai[2] = 2f;
                                    vector2136 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    x122 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2136.X;
                                    y121 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2136.Y;
                                    single273 = (float)Math.Sqrt((double)(x122 * x122 + y121 * y121));
                                    single273 = 20f / single273;
                                    this.velocity.X = x122 * single273;
                                    this.velocity.Y = y121 * single273;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else if (this.ai[2] == 2f)
                            {
                                if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f)
                                {
                                    if (this.ai[3] >= 4f)
                                    {
                                        this.ai[2] = 3f;
                                        this.ai[3] = 0f;
                                        return;
                                    }
                                    this.ai[2] = 1f;
                                    this.ai[3] = this.ai[3] + 1f;
                                    return;
                                }
                            }
                            else if (this.ai[2] == 4f)
                            {
                                Vector2 vector2137 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x123 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2137.X;
                                float y122 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2137.Y;
                                float single274 = (float)Math.Sqrt((double)(x123 * x123 + y122 * y122));
                                this.rotation = (float)Math.Atan2((double)y122, (double)x123) + 1.57f;
                                this.velocity.Y = (this.velocity.Y * 5f + Main.npc[(int)this.ai[1]].velocity.Y) / 6f;
                                this.velocity.X = this.velocity.X + 0.5f;
                                if (this.velocity.X > 12f)
                                {
                                    this.velocity.X = 12f;
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 500f || this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 500f)
                                {
                                    this.TargetClosest(true);
                                    this.ai[2] = 5f;
                                    vector2137 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    x123 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2137.X;
                                    y122 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2137.Y;
                                    single274 = (float)Math.Sqrt((double)(x123 * x123 + y122 * y122));
                                    single274 = 17f / single274;
                                    this.velocity.X = x123 * single274;
                                    this.velocity.Y = y122 * single274;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else if (this.ai[2] == 5f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - 100f)
                            {
                                if (this.ai[3] >= 4f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    return;
                                }
                                this.ai[2] = 4f;
                                this.ai[3] = this.ai[3] + 1f;
                                return;
                            }
                        }
                        else
                        {
                            if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y > 8f)
                                {
                                    this.velocity.Y = 8f;
                                }
                            }
                            else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < -8f)
                                {
                                    this.velocity.Y = -8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X - 0.5f;
                                if (this.velocity.X > 12f)
                                {
                                    this.velocity.X = 12f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X + 0.5f;
                                if (this.velocity.X < -12f)
                                {
                                    this.velocity.X = -12f;
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 35)
                    {
                        this.spriteDirection = -(int)this.ai[0];
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] = this.ai[2] + 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] == 0f)
                        {
                            if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                            }
                            if (Main.npc[(int)this.ai[1]].ai[1] == 0f)
                            {
                                this.ai[3] = this.ai[3] + 1f;
                                if (this.ai[3] >= 1100f)
                                {
                                    this.localAI[0] = 0f;
                                    this.ai[2] = 1f;
                                    this.ai[3] = 0f;
                                    this.netUpdate = true;
                                }
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 150f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.04f;
                                    if (this.velocity.Y > 3f)
                                    {
                                        this.velocity.Y = 3f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 150f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.04f;
                                    if (this.velocity.Y < -3f)
                                    {
                                        this.velocity.Y = -3f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 200f)
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.2f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 160f)
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.2f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            else
                            {
                                this.localAI[0] = this.localAI[0] + 2f;
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.07f;
                                    if (this.velocity.Y > 6f)
                                    {
                                        this.velocity.Y = 6f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.07f;
                                    if (this.velocity.Y < -6f)
                                    {
                                        this.velocity.Y = -6f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.1f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.1f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            Vector2 y123 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x124 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - y123.X;
                            float y124 = Main.npc[(int)this.ai[1]].position.Y + 230f - y123.Y;
                            float single275 = (float)Math.Sqrt((double)(x124 * x124 + y124 * y124));
                            this.rotation = (float)Math.Atan2((double)y124, (double)x124) + 1.57f;
                            if (Main.netMode != 1)
                            {
                                this.localAI[0] = this.localAI[0] + 1f;
                                if (this.localAI[0] > 140f)
                                {
                                    this.localAI[0] = 0f;
                                    float single276 = 12f;
                                    int num448 = 0;
                                    int num449 = 102;
                                    single275 = single276 / single275;
                                    x124 = -x124 * single275;
                                    y124 = -y124 * single275;
                                    x124 = x124 + (float)Main.rand.Next(-40, 41) * 0.01f;
                                    y124 = y124 + (float)Main.rand.Next(-40, 41) * 0.01f;
                                    y123.X = y123.X + x124 * 4f;
                                    y123.Y = y123.Y + y124 * 4f;
                                    Projectile.NewProjectile(y123.X, y123.Y, x124, y124, num449, num448, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                        else if (this.ai[2] == 1f)
                        {
                            this.ai[3] = this.ai[3] + 1f;
                            if (this.ai[3] >= 300f)
                            {
                                this.localAI[0] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                            }
                            Vector2 x125 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x126 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - x125.X;
                            float y125 = Main.npc[(int)this.ai[1]].position.Y - x125.Y;
                            y125 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 80f - x125.Y;
                            float single277 = (float)Math.Sqrt((double)(x126 * x126 + y125 * y125));
                            single277 = 6f / single277;
                            x126 = x126 * single277;
                            y125 = y125 * single277;
                            if (this.velocity.X > x126)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X - 0.04f;
                            }
                            if (this.velocity.X < x126)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X + 0.04f;
                            }
                            if (this.velocity.Y > y125)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.08f;
                            }
                            if (this.velocity.Y < y125)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.08f;
                            }
                            this.TargetClosest(true);
                            x125 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            x126 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - x125.X;
                            y125 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - x125.Y;
                            single277 = (float)Math.Sqrt((double)(x126 * x126 + y125 * y125));
                            this.rotation = (float)Math.Atan2((double)y125, (double)x126) - 1.57f;
                            if (Main.netMode != 1)
                            {
                                this.localAI[0] = this.localAI[0] + 1f;
                                if (this.localAI[0] > 40f)
                                {
                                    this.localAI[0] = 0f;
                                    float single278 = 10f;
                                    int num450 = 0;
                                    int num451 = 102;
                                    single277 = single278 / single277;
                                    x126 = x126 * single277;
                                    y125 = y125 * single277;
                                    x126 = x126 + (float)Main.rand.Next(-40, 41) * 0.01f;
                                    y125 = y125 + (float)Main.rand.Next(-40, 41) * 0.01f;
                                    x125.X = x125.X + x126 * 4f;
                                    x125.Y = x125.Y + y125 * 4f;
                                    Projectile.NewProjectile(x125.X, x125.Y, x126, y125, num451, num450, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 36)
                    {
                        this.spriteDirection = -(int)this.ai[0];
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] = this.ai[2] + 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] == 0f || this.ai[2] == 3f)
                        {
                            if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                            }
                            if (Main.npc[(int)this.ai[1]].ai[1] == 0f)
                            {
                                this.ai[3] = this.ai[3] + 1f;
                                if (this.ai[3] >= 800f)
                                {
                                    this.ai[2] = this.ai[2] + 1f;
                                    this.ai[3] = 0f;
                                    this.netUpdate = true;
                                }
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.1f;
                                    if (this.velocity.Y > 3f)
                                    {
                                        this.velocity.Y = 3f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.1f;
                                    if (this.velocity.Y < -3f)
                                    {
                                        this.velocity.Y = -3f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 180f * this.ai[0])
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.14f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 180f * this.ai[0])
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.14f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            else
                            {
                                this.localAI[0] = this.localAI[0] + 3f;
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.07f;
                                    if (this.velocity.Y > 6f)
                                    {
                                        this.velocity.Y = 6f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.07f;
                                    if (this.velocity.Y < -6f)
                                    {
                                        this.velocity.Y = -6f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.1f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.1f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            this.TargetClosest(true);
                            Vector2 y126 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x127 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y126.X;
                            float y127 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y126.Y;
                            float single279 = (float)Math.Sqrt((double)(x127 * x127 + y127 * y127));
                            this.rotation = (float)Math.Atan2((double)y127, (double)x127) - 1.57f;
                            if (Main.netMode != 1)
                            {
                                this.localAI[0] = this.localAI[0] + 1f;
                                if (this.localAI[0] > 200f)
                                {
                                    this.localAI[0] = 0f;
                                    float single280 = 8f;
                                    int num452 = 25;
                                    int num453 = 100;
                                    single279 = single280 / single279;
                                    x127 = x127 * single279;
                                    y127 = y127 * single279;
                                    x127 = x127 + (float)Main.rand.Next(-40, 41) * 0.05f;
                                    y127 = y127 + (float)Main.rand.Next(-40, 41) * 0.05f;
                                    y126.X = y126.X + x127 * 8f;
                                    y126.Y = y126.Y + y127 * 8f;
                                    Projectile.NewProjectile(y126.X, y126.Y, x127, y127, num453, num452, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                        else if (this.ai[2] == 1f)
                        {
                            this.ai[3] = this.ai[3] + 1f;
                            if (this.ai[3] >= 200f)
                            {
                                this.localAI[0] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                            }
                            Vector2 x128 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x129 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - 350f - x128.X;
                            float y128 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 20f - x128.Y;
                            float single281 = (float)Math.Sqrt((double)(x129 * x129 + y128 * y128));
                            single281 = 7f / single281;
                            x129 = x129 * single281;
                            y128 = y128 * single281;
                            if (this.velocity.X > x129)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            if (this.velocity.X < x129)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            if (this.velocity.Y > y128)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            if (this.velocity.Y < y128)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            this.TargetClosest(true);
                            x128 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            x129 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - x128.X;
                            y128 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - x128.Y;
                            single281 = (float)Math.Sqrt((double)(x129 * x129 + y128 * y128));
                            this.rotation = (float)Math.Atan2((double)y128, (double)x129) - 1.57f;
                            if (Main.netMode == 1)
                            {
                                this.localAI[0] = this.localAI[0] + 1f;
                                if (this.localAI[0] > 80f)
                                {
                                    this.localAI[0] = 0f;
                                    float single282 = 10f;
                                    int num454 = 25;
                                    int num455 = 100;
                                    single281 = single282 / single281;
                                    x129 = x129 * single281;
                                    y128 = y128 * single281;
                                    x129 = x129 + (float)Main.rand.Next(-40, 41) * 0.05f;
                                    y128 = y128 + (float)Main.rand.Next(-40, 41) * 0.05f;
                                    x128.X = x128.X + x129 * 8f;
                                    x128.Y = x128.Y + y128 * 8f;
                                    Projectile.NewProjectile(x128.X, x128.Y, x129, y128, num455, num454, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 37)
                    {
                        if (this.ai[3] > 0f)
                        {
                            this.realLife = (int)this.ai[3];
                        }
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                        }
                        if (this.type >= 134 && this.type <= 136)
                        {
                            this.velocity.Length();
                            if (this.type == 134 || this.type != 134 && Main.npc[(int)this.ai[1]].alpha < 128)
                            {
                                NPC nPC134 = this;
                                nPC134.alpha = nPC134.alpha - 42;
                                if (this.alpha < 0)
                                {
                                    this.alpha = 0;
                                }
                            }
                        }
                        if (this.type > 134)
                        {
                            bool flag94 = false;
                            if (this.ai[1] <= 0f)
                            {
                                flag94 = true;
                            }
                            else if (Main.npc[(int)this.ai[1]].life <= 0)
                            {
                                flag94 = true;
                            }
                            if (flag94)
                            {
                                this.life = 0;
                                this.HitEffect(0, 10);
                                this.checkDead();
                            }
                        }
                        if (Main.netMode != 1)
                        {
                            if (this.ai[0] == 0f && this.type == 134)
                            {
                                this.ai[3] = (float)this.whoAmI;
                                this.realLife = this.whoAmI;
                                int num459 = 0;
                                int num460 = this.whoAmI;
                                int num461 = 80;
                                for (int v3 = 0; v3 <= num461; v3++)
                                {
                                    int num462 = 135;
                                    if (v3 == num461)
                                    {
                                        num462 = 136;
                                    }
                                    num459 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num462, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num459].ai[3] = (float)this.whoAmI;
                                    Main.npc[num459].realLife = this.whoAmI;
                                    Main.npc[num459].ai[1] = (float)num460;
                                    Main.npc[num460].ai[0] = (float)num459;
                                    NetMessage.SendData(23, -1, -1, "", num459, 0f, 0f, 0f, 0, 0, 0);
                                    num460 = num459;
                                }
                            }
                            if (this.type == 135)
                            {
                                this.localAI[0] = this.localAI[0] + (float)Main.rand.Next(4);
                                if (this.localAI[0] >= (float)Main.rand.Next(1400, 26000))
                                {
                                    this.localAI[0] = 0f;
                                    this.TargetClosest(true);
                                    if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                    {
                                        float single283 = 8f;
                                        Vector2 y129 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)(this.height / 2));
                                        float x130 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - y129.X + (float)Main.rand.Next(-20, 21);
                                        float y130 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - y129.Y + (float)Main.rand.Next(-20, 21);
                                        float single284 = (float)Math.Sqrt((double)(x130 * x130 + y130 * y130));
                                        single284 = single283 / single284;
                                        x130 = x130 * single284;
                                        y130 = y130 * single284;
                                        x130 = x130 + (float)Main.rand.Next(-20, 21) * 0.05f;
                                        y130 = y130 + (float)Main.rand.Next(-20, 21) * 0.05f;
                                        int num463 = 22;
                                        if (Main.expertMode)
                                        {
                                            num463 = 18;
                                        }
                                        int num464 = 100;
                                        y129.X = y129.X + x130 * 5f;
                                        y129.Y = y129.Y + y130 * 5f;
                                        int num465 = Projectile.NewProjectile(y129.X, y129.Y, x130, y130, num464, num463, 0f, Main.myPlayer, 0f, 0f);
                                        Main.projectile[num465].timeLeft = 300;
                                        this.netUpdate = true;
                                    }
                                }
                            }
                        }
                        int x131 = (int)(this.position.X / 16f) - 1;
                        int x132 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                        int y131 = (int)(this.position.Y / 16f) - 1;
                        int y132 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                        if (x131 < 0)
                        {
                            x131 = 0;
                        }
                        if (x132 > Main.maxTilesX)
                        {
                            x132 = Main.maxTilesX;
                        }
                        if (y131 < 0)
                        {
                            y131 = 0;
                        }
                        if (y132 > Main.maxTilesY)
                        {
                            y132 = Main.maxTilesY;
                        }
                        bool flag95 = false;
                        if (!flag95)
                        {
                            for (int w3 = x131; w3 < x132; w3++)
                            {
                                for (int x310 = y131; x310 < y132; x310++)
                                {
                                    if (Main.tile[w3, x310] != null && (Main.tile[w3, x310].nactive() && (Main.tileSolid[Main.tile[w3, x310].type] || Main.tileSolidTop[Main.tile[w3, x310].type] && Main.tile[w3, x310].frameY == 0) || Main.tile[w3, x310].liquid > 64))
                                    {
                                        vector23.X = (float)(w3 * 16);
                                        vector23.Y = (float)(x310 * 16);
                                        if (this.position.X + (float)this.width > vector23.X && this.position.X < vector23.X + 16f && this.position.Y + (float)this.height > vector23.Y && this.position.Y < vector23.Y + 16f)
                                        {
                                            flag95 = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if (flag95)
                        {
                            this.localAI[1] = 0f;
                        }
                        else
                        {
                            this.localAI[1] = 1f;
                            if (this.type == 134)
                            {
                                Rectangle rectangle11 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                                int num466 = 1000;
                                bool flag96 = true;
                                if (this.position.Y > Main.player[this.target].position.Y)
                                {
                                    for (int y310 = 0; y310 < 255; y310++)
                                    {
                                        if (Main.player[y310].active)
                                        {
                                            Rectangle rectangle12 = new Rectangle((int)Main.player[y310].position.X - num466, (int)Main.player[y310].position.Y - num466, num466 * 2, num466 * 2);
                                            if (rectangle11.Intersects(rectangle12))
                                            {
                                                flag96 = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (flag96)
                                    {
                                        flag95 = true;
                                    }
                                }
                            }
                        }
                        float single285 = 16f;
                        if (Main.dayTime || Main.player[this.target].dead)
                        {
                            flag95 = false;
                            this.velocity.Y = this.velocity.Y + 1f;
                            if ((double)this.position.Y > Main.worldSurface * 16)
                            {
                                this.velocity.Y = this.velocity.Y + 1f;
                                single285 = 32f;
                            }
                            if ((double)this.position.Y > Main.rockLayer * 16)
                            {
                                for (int a3 = 0; a3 < 200; a3++)
                                {
                                    if (Main.npc[a3].aiStyle == this.aiStyle)
                                    {
                                        Main.npc[a3].active = false;
                                    }
                                }
                            }
                        }
                        float single286 = 0.1f;
                        float single287 = 0.15f;
                        Vector2 x133 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x134 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                        float y133 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                        x134 = (float)((int)(x134 / 16f) * 16);
                        y133 = (float)((int)(y133 / 16f) * 16);
                        x133.X = (float)((int)(x133.X / 16f) * 16);
                        x133.Y = (float)((int)(x133.Y / 16f) * 16);
                        x134 = x134 - x133.X;
                        y133 = y133 - x133.Y;
                        float single288 = (float)Math.Sqrt((double)(x134 * x134 + y133 * y133));
                        if (this.ai[1] > 0f && this.ai[1] < (float)((int)Main.npc.Length))
                        {
                            try
                            {
                                x133 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                x134 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - x133.X;
                                y133 = Main.npc[(int)this.ai[1]].position.Y + (float)(Main.npc[(int)this.ai[1]].height / 2) - x133.Y;
                            }
                            catch (Exception ex)
                            {
            #if DEBUG
                                Console.WriteLine(ex);
                                System.Diagnostics.Debugger.Break();

            #endif
                            }
                            this.rotation = (float)Math.Atan2((double)y133, (double)x134) + 1.57f;
                            single288 = (float)Math.Sqrt((double)(x134 * x134 + y133 * y133));
                            int num467 = (int)(44f * this.scale);
                            single288 = (single288 - (float)num467) / single288;
                            x134 = x134 * single288;
                            y133 = y133 * single288;
                            this.velocity = Vector2.Zero;
                            this.position.X = this.position.X + x134;
                            this.position.Y = this.position.Y + y133;
                            return;
                        }
                        if (flag95)
                        {
                            if (this.soundDelay == 0)
                            {
                                float single289 = single288 / 40f;
                                if (single289 < 10f)
                                {
                                    single289 = 10f;
                                }
                                if (single289 > 20f)
                                {
                                    single289 = 20f;
                                }
                                this.soundDelay = (int)single289;
                            }
                            single288 = (float)Math.Sqrt((double)(x134 * x134 + y133 * y133));
                            float single290 = Math.Abs(x134);
                            float single291 = Math.Abs(y133);
                            float single292 = single285 / single288;
                            x134 = x134 * single292;
                            y133 = y133 * single292;
                            if ((this.velocity.X > 0f && x134 > 0f || this.velocity.X < 0f && x134 < 0f) && (this.velocity.Y > 0f && y133 > 0f || this.velocity.Y < 0f && y133 < 0f))
                            {
                                if (this.velocity.X < x134)
                                {
                                    this.velocity.X = this.velocity.X + single287;
                                }
                                else if (this.velocity.X > x134)
                                {
                                    this.velocity.X = this.velocity.X - single287;
                                }
                                if (this.velocity.Y < y133)
                                {
                                    this.velocity.Y = this.velocity.Y + single287;
                                }
                                else if (this.velocity.Y > y133)
                                {
                                    this.velocity.Y = this.velocity.Y - single287;
                                }
                            }
                            if (this.velocity.X > 0f && x134 > 0f || this.velocity.X < 0f && x134 < 0f || this.velocity.Y > 0f && y133 > 0f || this.velocity.Y < 0f && y133 < 0f)
                            {
                                if (this.velocity.X < x134)
                                {
                                    this.velocity.X = this.velocity.X + single286;
                                }
                                else if (this.velocity.X > x134)
                                {
                                    this.velocity.X = this.velocity.X - single286;
                                }
                                if (this.velocity.Y < y133)
                                {
                                    this.velocity.Y = this.velocity.Y + single286;
                                }
                                else if (this.velocity.Y > y133)
                                {
                                    this.velocity.Y = this.velocity.Y - single286;
                                }
                                if ((double)Math.Abs(y133) < (double)single285 * 0.2 && (this.velocity.X > 0f && x134 < 0f || this.velocity.X < 0f && x134 > 0f))
                                {
                                    if (this.velocity.Y <= 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single286 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + single286 * 2f;
                                    }
                                }
                                if ((double)Math.Abs(x134) < (double)single285 * 0.2 && (this.velocity.Y > 0f && y133 < 0f || this.velocity.Y < 0f && y133 > 0f))
                                {
                                    if (this.velocity.X <= 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single286 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X + single286 * 2f;
                                    }
                                }
                            }
                            else if (single290 <= single291)
                            {
                                if (this.velocity.Y < y133)
                                {
                                    this.velocity.Y = this.velocity.Y + single286 * 1.1f;
                                }
                                else if (this.velocity.Y > y133)
                                {
                                    this.velocity.Y = this.velocity.Y - single286 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)single285 * 0.5)
                                {
                                    if (this.velocity.X <= 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single286;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X + single286;
                                    }
                                }
                            }
                            else
                            {
                                if (this.velocity.X < x134)
                                {
                                    this.velocity.X = this.velocity.X + single286 * 1.1f;
                                }
                                else if (this.velocity.X > x134)
                                {
                                    this.velocity.X = this.velocity.X - single286 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)single285 * 0.5)
                                {
                                    if (this.velocity.Y <= 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single286;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + single286;
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.TargetClosest(true);
                            this.velocity.Y = this.velocity.Y + 0.15f;
                            if (this.velocity.Y > single285)
                            {
                                this.velocity.Y = single285;
                            }
                            if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)single285 * 0.4)
                            {
                                if (this.velocity.X >= 0f)
                                {
                                    this.velocity.X = this.velocity.X + single286 * 1.1f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X - single286 * 1.1f;
                                }
                            }
                            else if (this.velocity.Y != single285)
                            {
                                if (this.velocity.Y > 4f)
                                {
                                    if (this.velocity.X >= 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single286 * 0.9f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X + single286 * 0.9f;
                                    }
                                }
                            }
                            else if (this.velocity.X < x134)
                            {
                                this.velocity.X = this.velocity.X + single286;
                            }
                            else if (this.velocity.X > x134)
                            {
                                this.velocity.X = this.velocity.X - single286;
                            }
                        }
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                        if (this.type == 134)
                        {
                            if (!flag95)
                            {
                                if (this.localAI[0] != 0f)
                                {
                                    this.netUpdate = true;
                                }
                                this.localAI[0] = 0f;
                            }
                            else
                            {
                                if (this.localAI[0] != 1f)
                                {
                                    this.netUpdate = true;
                                }
                                this.localAI[0] = 1f;
                            }
                            if ((this.velocity.X > 0f && this.oldVelocity.X < 0f || this.velocity.X < 0f && this.oldVelocity.X > 0f || this.velocity.Y > 0f && this.oldVelocity.Y < 0f || this.velocity.Y < 0f && this.oldVelocity.Y > 0f) && !this.justHit)
                            {
                                this.netUpdate = true;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 38)
                    {
                        float single293 = 4f;
                        float single294 = 1f;
                        if (this.type == 143)
                        {
                            single293 = 3f;
                            single294 = 0.7f;
                        }
                        if (this.type == 145)
                        {
                            single293 = 3.5f;
                            single294 = 0.8f;
                        }
                        if (this.type == 143)
                        {
                            this.ai[2] = this.ai[2] + 1f;
                            if (this.ai[2] >= 120f)
                            {
                                this.ai[2] = 0f;
                                if (Main.netMode != 1)
                                {
                                    Vector2 vector2139 = new Vector2(this.position.X + (float)this.width * 0.5f - (float)(this.direction * 12), this.position.Y + (float)this.height * 0.5f);
                                    float single295 = (float)(12 * this.spriteDirection);
                                    float single296 = 0f;
                                    if (Main.netMode != 1)
                                    {
                                        int num468 = 25;
                                        int num469 = 110;
                                        int num470 = Projectile.NewProjectile(vector2139.X, vector2139.Y, single295, single296, num469, num468, 0f, Main.myPlayer, 0f, 0f);
                                        Main.projectile[num470].ai[0] = 2f;
                                        Main.projectile[num470].timeLeft = 300;
                                        Main.projectile[num470].friendly = false;
                                        NetMessage.SendData(27, -1, -1, "", num470, 0f, 0f, 0f, 0, 0, 0);
                                        this.netUpdate = true;
                                    }
                                }
                            }
                        }
                        if (this.type == 144 && this.ai[1] >= 3f)
                        {
                            this.TargetClosest(true);
                            this.spriteDirection = this.direction;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                this.ai[2] = this.ai[2] + 1f;
                                if ((double)this.velocity.X > -0.3 && (double)this.velocity.X < 0.3)
                                {
                                    this.velocity.X = 0f;
                                }
                                if (this.ai[2] >= 200f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                }
                            }
                        }
                        else if (this.type != 145 || this.ai[1] < 3f)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                if (this.localAI[2] == this.position.X)
                                {
                                    NPC nPC135 = this;
                                    nPC135.direction = nPC135.direction * -1;
                                    this.ai[3] = 60f;
                                }
                                this.localAI[2] = this.position.X;
                                if (this.ai[3] == 0f)
                                {
                                    this.TargetClosest(true);
                                }
                                this.ai[0] = this.ai[0] + 1f;
                                if (this.ai[0] <= 2f)
                                {
                                    this.velocity.Y = -6f;
                                    this.velocity.X = this.velocity.X + (float)this.direction * single294 * 0.9f;
                                }
                                else
                                {
                                    this.ai[0] = 0f;
                                    this.ai[1] = this.ai[1] + 1f;
                                    this.velocity.Y = -8.2f;
                                    this.velocity.X = this.velocity.X + (float)this.direction * single294 * 1.1f;
                                }
                                this.spriteDirection = this.direction;
                            }
                            this.velocity.X = this.velocity.X + (float)this.direction * single294 * 0.01f;
                        }
                        else
                        {
                            this.TargetClosest(true);
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                this.ai[2] = this.ai[2] + 1f;
                                if ((double)this.velocity.X > -0.3 && (double)this.velocity.X < 0.3)
                                {
                                    this.velocity.X = 0f;
                                }
                                if (this.ai[2] >= 16f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                }
                            }
                            if (this.velocity.X == 0f && this.velocity.Y == 0f && this.ai[2] == 8f)
                            {
                                float single297 = 10f;
                                Vector2 vector2140 = new Vector2(this.position.X + (float)this.width * 0.5f - (float)(this.direction * 12), this.position.Y + (float)this.height * 0.25f);
                                float x135 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2140.X;
                                float y134 = Main.player[this.target].position.Y - vector2140.Y;
                                float single298 = (float)Math.Sqrt((double)(x135 * x135 + y134 * y134));
                                single298 = single297 / single298;
                                x135 = x135 * single298;
                                y134 = y134 * single298;
                                if (Main.netMode != 1)
                                {
                                    int num471 = 35;
                                    int num472 = 109;
                                    int num473 = Projectile.NewProjectile(vector2140.X, vector2140.Y, x135, y134, num472, num471, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num473].ai[0] = 2f;
                                    Main.projectile[num473].timeLeft = 300;
                                    Main.projectile[num473].friendly = false;
                                    NetMessage.SendData(27, -1, -1, "", num473, 0f, 0f, 0f, 0, 0, 0);
                                    this.netUpdate = true;
                                }
                            }
                        }
                        if (this.ai[3] > 0f)
                        {
                            this.ai[3] = this.ai[3] - 1f;
                        }
                        if (this.velocity.X > single293 && this.direction > 0)
                        {
                            this.velocity.X = 4f;
                        }
                        if (this.velocity.X < -single293 && this.direction < 0)
                        {
                            this.velocity.X = -4f;
                            return;
                        }
                    }
                    else if (this.aiStyle == 39)
                    {
                        if (this.target < 0 || Main.player[this.target].dead || this.direction == 0)
                        {
                            this.TargetClosest(true);
                        }
                        bool flag97 = true;
                        int num474 = 0;
                        if (this.velocity.X < 0f)
                        {
                            num474 = -1;
                        }
                        if (this.velocity.X > 0f)
                        {
                            num474 = 1;
                        }
                        Vector2 x136 = this.position;
                        x136.X = x136.X + this.velocity.X;
                        int x137 = (int)((x136.X + (float)(this.width / 2) + (float)((this.width / 2 + 1) * num474)) / 16f);
                        int y135 = (int)((x136.Y + (float)this.height - 1f) / 16f);
                        if ((float)(x137 * 16) < x136.X + (float)this.width && (float)(x137 * 16 + 16) > x136.X && (Main.tile[x137, y135].nactive() && !Main.tile[x137, y135].topSlope() && !Main.tile[x137, y135 - 1].topSlope() && (Main.tileSolid[Main.tile[x137, y135].type] && !Main.tileSolidTop[Main.tile[x137, y135].type] || flag97 && Main.tileSolidTop[Main.tile[x137, y135].type] && (!Main.tileSolid[Main.tile[x137, y135 - 1].type] || !Main.tile[x137, y135 - 1].nactive()) && Main.tile[x137, y135].type != 16 && Main.tile[x137, y135].type != 18 && Main.tile[x137, y135].type != 134) || Main.tile[x137, y135 - 1].halfBrick() && Main.tile[x137, y135 - 1].nactive()) && (!Main.tile[x137, y135 - 1].nactive() || !Main.tileSolid[Main.tile[x137, y135 - 1].type] || Main.tileSolidTop[Main.tile[x137, y135 - 1].type] || Main.tile[x137, y135 - 1].halfBrick() && (!Main.tile[x137, y135 - 4].nactive() || !Main.tileSolid[Main.tile[x137, y135 - 4].type] || Main.tileSolidTop[Main.tile[x137, y135 - 4].type])) && (!Main.tile[x137, y135 - 2].nactive() || !Main.tileSolid[Main.tile[x137, y135 - 2].type] || Main.tileSolidTop[Main.tile[x137, y135 - 2].type]) && (!Main.tile[x137, y135 - 3].nactive() || !Main.tileSolid[Main.tile[x137, y135 - 3].type] || Main.tileSolidTop[Main.tile[x137, y135 - 3].type]) && (!Main.tile[x137 - num474, y135 - 3].nactive() || !Main.tileSolid[Main.tile[x137 - num474, y135 - 3].type] || Main.tileSolidTop[Main.tile[x137 - num474, y135 - 3].type]))
                        {
                            float single299 = (float)(y135 * 16);
                            if (Main.tile[x137, y135].halfBrick())
                            {
                                single299 = single299 + 8f;
                            }
                            if (Main.tile[x137, y135 - 1].halfBrick())
                            {
                                single299 = single299 - 8f;
                            }
                            if (single299 < x136.Y + (float)this.height)
                            {
                                float y136 = x136.Y + (float)this.height - single299;
                                if ((double)y136 <= 16.1)
                                {
                                    NPC nPC136 = this;
                                    nPC136.gfxOffY = nPC136.gfxOffY + (this.position.Y + (float)this.height - single299);
                                    this.position.Y = single299 - (float)this.height;
                                    if (y136 >= 9f)
                                    {
                                        this.stepSpeed = 1.5f;
                                    }
                                    else
                                    {
                                        this.stepSpeed = 0.75f;
                                    }
                                }
                            }
                        }
                        if (this.justHit && this.type != 417)
                        {
                            this.ai[0] = 0f;
                            this.ai[1] = 0f;
                            this.TargetClosest(true);
                        }
                        if (this.ai[0] == 0f)
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.direction = -1;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.direction = 1;
                            }
                            this.spriteDirection = this.direction;
                            Vector2 vector2142 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x138 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2142.X;
                            float y137 = Main.player[this.target].position.Y - vector2142.Y;
                            float single300 = (float)Math.Sqrt((double)(x138 * x138 + y137 * y137));
                            bool flag98 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                            if (this.type < 496 || this.type > 497)
                            {
                                if (single300 > 200f && flag98)
                                {
                                    this.ai[1] = this.ai[1] + 4f;
                                }
                                if (single300 > 600f && (flag98 || this.position.Y + (float)this.height > Main.player[this.target].position.Y - 200f))
                                {
                                    this.ai[1] = this.ai[1] + 10f;
                                }
                                if (this.wet)
                                {
                                    this.ai[1] = 1000f;
                                }
                            }
                            else
                            {
                                if (single300 > 200f && flag98)
                                {
                                    this.ai[1] = this.ai[1] + 2f;
                                }
                                if (single300 > 600f && (flag98 || this.position.Y + (float)this.height > Main.player[this.target].position.Y - 200f))
                                {
                                    this.ai[1] = this.ai[1] + 4f;
                                }
                            }
                            this.defense = this.defDefense;
                            this.damage = this.defDamage;
                            if (this.type < 496 || this.type > 497)
                            {
                                this.knockBackResist = 0.3f * Main.knockBackMultiplier;
                            }
                            else
                            {
                                this.knockBackResist = 0.75f * Main.knockBackMultiplier;
                            }
                            this.ai[1] = this.ai[1] + 1f;
                            if (this.ai[1] >= 400f)
                            {
                                this.ai[1] = 0f;
                                this.ai[0] = 1f;
                            }
                            if (!this.justHit && this.velocity.X != this.oldVelocity.X)
                            {
                                NPC nPC137 = this;
                                nPC137.direction = nPC137.direction * -1;
                            }
                            if (this.velocity.Y == 0f && Main.player[this.target].position.Y < this.position.Y + (float)this.height)
                            {
                                if (this.direction <= 0)
                                {
                                    x1 = (int)(((double)this.position.X + (double)this.width * 0.5) / 16);
                                    x = x1 - 3;
                                }
                                else
                                {
                                    x = (int)(((double)this.position.X + (double)this.width * 0.5) / 16);
                                    x1 = x + 3;
                                }
                                int y138 = (int)((this.position.Y + (float)this.height + 2f) / 16f) - 1;
                                int num478 = y138 + 4;
                                bool flag99 = false;
                                for (int b3 = x; b3 <= x1; b3++)
                                {
                                    for (int c3 = y138; c3 <= num478; c3++)
                                    {
                                        if (Main.tile[b3, c3] != null && Main.tile[b3, c3].nactive() && Main.tileSolid[Main.tile[b3, c3].type])
                                        {
                                            flag99 = true;
                                        }
                                    }
                                }
                                if (!flag99)
                                {
                                    NPC nPC138 = this;
                                    nPC138.direction = nPC138.direction * -1;
                                    this.velocity.X = 0.1f * (float)this.direction;
                                }
                            }
                            if (this.type < 496 || this.type > 497)
                            {
                                float single301 = 1f;
                                if (single300 < 400f)
                                {
                                    if (this.velocity.X < -single301 || this.velocity.X > single301)
                                    {
                                        if (this.velocity.Y == 0f)
                                        {
                                            NPC nPC139 = this;
                                            nPC139.velocity = nPC139.velocity * 0.8f;
                                            return;
                                        }
                                    }
                                    else if (this.velocity.X < single301 && this.direction == 1)
                                    {
                                        this.velocity.X = this.velocity.X + 0.07f;
                                        if (this.velocity.X > single301)
                                        {
                                            this.velocity.X = single301;
                                            return;
                                        }
                                    }
                                    else if (this.velocity.X > -single301 && this.direction == -1)
                                    {
                                        this.velocity.X = this.velocity.X - 0.07f;
                                        if (this.velocity.X < -single301)
                                        {
                                            this.velocity.X = -single301;
                                            return;
                                        }
                                    }
                                }
                                else if (this.velocity.X < -1.5f || this.velocity.X > 1.5f)
                                {
                                    if (this.velocity.Y == 0f)
                                    {
                                        NPC nPC140 = this;
                                        nPC140.velocity = nPC140.velocity * 0.8f;
                                        return;
                                    }
                                }
                                else if (this.velocity.X < 1.5f && this.direction == 1)
                                {
                                    this.velocity.X = this.velocity.X + 0.07f;
                                    if (this.velocity.X > 1.5f)
                                    {
                                        this.velocity.X = 1.5f;
                                        return;
                                    }
                                }
                                else if (this.velocity.X > -1.5f && this.direction == -1)
                                {
                                    this.velocity.X = this.velocity.X - 0.07f;
                                    if (this.velocity.X < -1.5f)
                                    {
                                        this.velocity.X = -1.5f;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                float single302 = 0.5f;
                                if (this.velocity.X < -single302 || this.velocity.X > single302)
                                {
                                    if (this.velocity.Y == 0f)
                                    {
                                        NPC nPC141 = this;
                                        nPC141.velocity = nPC141.velocity * 0.8f;
                                        return;
                                    }
                                }
                                else if (this.velocity.X < single302 && this.direction == 1)
                                {
                                    this.velocity.X = this.velocity.X + 0.07f;
                                    if (this.velocity.X > single302)
                                    {
                                        this.velocity.X = single302;
                                        return;
                                    }
                                }
                                else if (this.velocity.X > -single302 && this.direction == -1)
                                {
                                    this.velocity.X = this.velocity.X - 0.07f;
                                    if (this.velocity.X < -single302)
                                    {
                                        this.velocity.X = -single302;
                                        return;
                                    }
                                }
                            }
                        }
                        else if (this.ai[0] != 1f)
                        {
                            if (this.ai[0] == 3f)
                            {
                                if (Main.expertMode)
                                {
                                    if (this.type < 496 || this.type > 497)
                                    {
                                        this.damage = (int)((double)(this.defDamage * 2) * 0.9);
                                    }
                                    else
                                    {
                                        this.damage = (int)((double)this.defDamage * 1.5 * 0.9);
                                    }
                                }
                                else if (this.type < 496 || this.type > 497)
                                {
                                    this.damage = this.defDamage * 2;
                                }
                                else
                                {
                                    this.damage = (int)((double)this.defDamage * 1.5);
                                }
                                this.defense = this.defDefense * 2;
                                this.ai[1] = this.ai[1] + 1f;
                                if (this.ai[1] != 1f)
                                {
                                    if (this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y < Main.player[this.target].position.Y + (float)Main.player[this.target].height)
                                    {
                                        this.velocity.X = this.velocity.X * 0.8f;
                                        this.ai[3] = 0f;
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.2f;
                                        }
                                    }
                                    if (this.ai[3] != 0f)
                                    {
                                        this.velocity.X = this.ai[3];
                                        this.velocity.Y = this.velocity.Y - 0.22f;
                                    }
                                    if (this.ai[1] >= 90f)
                                    {
                                        this.noGravity = false;
                                        this.ai[1] = 0f;
                                        this.ai[0] = 4f;
                                    }
                                }
                                else
                                {
                                    this.netUpdate = true;
                                    this.TargetClosest(true);
                                    this.ai[2] = this.ai[2] + 0.3f;
                                    NPC nPC142 = this;
                                    nPC142.rotation = nPC142.rotation + this.ai[2] * (float)this.direction;
                                    this.ai[1] = this.ai[1] + 1f;
                                    bool flag100 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                                    float single303 = 10f;
                                    if (!flag100)
                                    {
                                        single303 = 6f;
                                    }
                                    if (this.type >= 496 && this.type <= 497)
                                    {
                                        single303 = single303 * 0.75f;
                                    }
                                    Vector2 vector2144 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float x139 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2144.X;
                                    float single304 = Math.Abs(x139) * 0.2f;
                                    if (this.directionY > 0)
                                    {
                                        single304 = 0f;
                                    }
                                    float y139 = Main.player[this.target].position.Y - vector2144.Y - single304;
                                    float single305 = (float)Math.Sqrt((double)(x139 * x139 + y139 * y139));
                                    this.netUpdate = true;
                                    single305 = single303 / single305;
                                    x139 = x139 * single305;
                                    y139 = y139 * single305;
                                    if (!flag100)
                                    {
                                        y139 = -10f;
                                    }
                                    this.velocity.X = x139;
                                    this.velocity.Y = y139;
                                    this.ai[3] = this.velocity.X;
                                }
                                if (this.wet && this.directionY < 0)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.3f;
                                }
                                NPC nPC143 = this;
                                nPC143.rotation = nPC143.rotation + this.ai[2] * (float)this.direction;
                                return;
                            }
                            if (this.ai[0] != 4f)
                            {
                                if (this.ai[0] == 6f)
                                {
                                    this.damage = (int)((float)(this.defDamage * 2) * Main.damageMultiplier);
                                    this.defense = this.defDefense * 2;
                                    this.knockBackResist = 0f;
                                    this.ai[1] = this.ai[1] + 1f;
                                    if (this.ai[3] > 0f)
                                    {
                                        if (this.ai[3] == 1f)
                                        {
                                        }
                                        this.ai[3] = this.ai[3] + 1f;
                                        if (this.ai[3] >= 10f)
                                        {
                                            this.ai[3] = 0f;
                                        }
                                    }
                                    if (this.ai[1] != 1f)
                                    {
                                        if (this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y < Main.player[this.target].position.Y + (float)Main.player[this.target].height)
                                        {
                                            this.velocity.X = this.velocity.X * 0.9f;
                                            if (this.velocity.Y < 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.2f;
                                            }
                                        }
                                        if (this.ai[2] == 0f || this.ai[1] >= 1200f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 5f;
                                        }
                                    }
                                    else
                                    {
                                        this.netUpdate = true;
                                        this.TargetClosest(true);
                                        bool flag101 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                                        float single306 = 16f;
                                        if (!flag101)
                                        {
                                            single306 = 10f;
                                        }
                                        Vector2 vector2147 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float x140 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2147.X;
                                        float single307 = Math.Abs(x140) * 0.2f;
                                        if (this.directionY > 0)
                                        {
                                            single307 = 0f;
                                        }
                                        float y140 = Main.player[this.target].position.Y - vector2147.Y - single307;
                                        float single308 = (float)Math.Sqrt((double)(x140 * x140 + y140 * y140));
                                        this.netUpdate = true;
                                        single308 = single306 / single308;
                                        x140 = x140 * single308;
                                        y140 = y140 * single308;
                                        if (!flag101)
                                        {
                                            y140 = -12f;
                                        }
                                        this.velocity.X = x140;
                                        this.velocity.Y = y140;
                                    }
                                    if (this.wet && this.directionY < 0)
                                    {
                                        this.velocity.Y = this.velocity.Y - 0.3f;
                                    }
                                    NPC nPC144 = this;
                                    nPC144.rotation = nPC144.rotation + MathHelper.Clamp(this.velocity.X / 10f * (float)this.direction, -0.314159274f, 0.314159274f);
                                    return;
                                }
                                if (this.ai[0] == 5f)
                                {
                                    this.rotation = 0f;
                                    this.velocity.X = 0f;
                                    if (this.type < 496 || this.type > 497)
                                    {
                                        this.ai[1] = this.ai[1] + 1f;
                                    }
                                    else
                                    {
                                        this.ai[1] = this.ai[1] + 0.5f;
                                    }
                                    if (this.ai[1] >= 30f)
                                    {
                                        this.TargetClosest(true);
                                        this.netUpdate = true;
                                        this.ai[1] = 0f;
                                        this.ai[0] = 0f;
                                    }
                                    if (this.wet)
                                    {
                                        this.ai[0] = 3f;
                                        this.ai[1] = 0f;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                if (this.wet && this.directionY < 0)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.3f;
                                }
                                this.velocity.X = this.velocity.X * 0.96f;
                                if (this.ai[2] > 0f)
                                {
                                    this.ai[2] = this.ai[2] - 0.01f;
                                    NPC nPC145 = this;
                                    nPC145.rotation = nPC145.rotation + this.ai[2] * (float)this.direction;
                                }
                                else if (this.velocity.Y >= 0f)
                                {
                                    this.rotation = 0f;
                                }
                                if (this.ai[2] <= 0f && (this.velocity.Y == 0f || this.wet))
                                {
                                    this.netUpdate = true;
                                    this.rotation = 0f;
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                    this.ai[0] = 5f;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X * 0.5f;
                            if (this.type < 496 || this.type > 497)
                            {
                                this.ai[1] = this.ai[1] + 1f;
                            }
                            else
                            {
                                this.ai[1] = this.ai[1] + 0.5f;
                            }
                            if (this.ai[1] >= 30f)
                            {
                                this.netUpdate = true;
                                this.TargetClosest(true);
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.ai[0] = 3f;
                                if (this.type == 417)
                                {
                                    this.ai[0] = 6f;
                                    this.ai[2] = (float)Main.rand.Next(2, 5);
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 40)
                    {
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                        }
                        float single309 = 2f;
                        float single310 = 0.08f;
                        if (this.type == 531)
                        {
                            single309 = 4f;
                            single310 = 0.16f;
                        }
                        Vector2 x141 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float x142 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                        float y141 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                        x142 = (float)((int)(x142 / 8f) * 8);
                        y141 = (float)((int)(y141 / 8f) * 8);
                        x141.X = (float)((int)(x141.X / 8f) * 8);
                        x141.Y = (float)((int)(x141.Y / 8f) * 8);
                        x142 = x142 - x141.X;
                        y141 = y141 - x141.Y;
                        float single311 = (float)Math.Sqrt((double)(x142 * x142 + y141 * y141));
                        if (single311 != 0f)
                        {
                            single311 = single309 / single311;
                            x142 = x142 * single311;
                            y141 = y141 * single311;
                        }
                        else
                        {
                            x142 = this.velocity.X;
                            y141 = this.velocity.Y;
                        }
                        if (Main.player[this.target].dead)
                        {
                            x142 = (float)this.direction * single309 / 2f;
                            y141 = -single309 / 2f;
                        }
                        this.spriteDirection = -1;
                        if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            if (this.velocity.X < x142)
                            {
                                this.velocity.X = this.velocity.X + single310;
                                if (this.velocity.X < 0f && x142 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + single310;
                                }
                            }
                            else if (this.velocity.X > x142)
                            {
                                this.velocity.X = this.velocity.X - single310;
                                if (this.velocity.X > 0f && x142 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - single310;
                                }
                            }
                            if (this.velocity.Y < y141)
                            {
                                this.velocity.Y = this.velocity.Y + single310;
                                if (this.velocity.Y < 0f && y141 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + single310;
                                }
                            }
                            else if (this.velocity.Y > y141)
                            {
                                this.velocity.Y = this.velocity.Y - single310;
                                if (this.velocity.Y > 0f && y141 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - single310;
                                }
                            }
                            this.rotation = (float)Math.Atan2((double)y141, (double)x142);
                        }
                        else
                        {
                            this.ai[0] = this.ai[0] + 1f;
                            if (this.ai[0] <= 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.023f;
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y + 0.023f;
                            }
                            if (this.ai[0] < -100f || this.ai[0] > 100f)
                            {
                                this.velocity.X = this.velocity.X + 0.023f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X - 0.023f;
                            }
                            if (this.ai[0] > 200f)
                            {
                                this.ai[0] = -200f;
                            }
                            this.velocity.X = this.velocity.X + x142 * 0.007f;
                            this.velocity.Y = this.velocity.Y + y141 * 0.007f;
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                            if ((double)this.velocity.X > 1.5)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if ((double)this.velocity.X < -1.5)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = this.velocity.Y * 0.9f;
                            }
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = this.velocity.Y * 0.9f;
                            }
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = 3f;
                            }
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = -3f;
                            }
                            if (this.velocity.Y > 3f)
                            {
                                this.velocity.Y = 3f;
                            }
                            if (this.velocity.Y < -3f)
                            {
                                this.velocity.Y = -3f;
                            }
                        }
                        if (this.type == 531)
                        {
                            NPC nPC146 = this;
                            nPC146.rotation = nPC146.rotation + 1.57079637f;
                        }
                        float single312 = 0.5f;
                        if (this.collideX)
                        {
                            this.netUpdate = true;
                            this.velocity.X = this.oldVelocity.X * -single312;
                            if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                            {
                                this.velocity.X = 2f;
                            }
                            if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                            {
                                this.velocity.X = -2f;
                            }
                        }
                        if (this.collideY)
                        {
                            this.netUpdate = true;
                            this.velocity.Y = this.oldVelocity.Y * -single312;
                            if (this.velocity.Y > 0f && (double)this.velocity.Y < 1.5)
                            {
                                this.velocity.Y = 2f;
                            }
                            if (this.velocity.Y < 0f && (double)this.velocity.Y > -1.5)
                            {
                                this.velocity.Y = -2f;
                            }
                        }
                        if ((this.velocity.X > 0f && this.oldVelocity.X < 0f || this.velocity.X < 0f && this.oldVelocity.X > 0f || this.velocity.Y > 0f && this.oldVelocity.Y < 0f || this.velocity.Y < 0f && this.oldVelocity.Y > 0f) && !this.justHit)
                        {
                            this.netUpdate = true;
                        }
                        if (Main.netMode != 1)
                        {
                            if (Main.netMode != 1 && Main.expertMode && this.target >= 0 && (this.type == 163 || this.type == 238) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                this.localAI[0] = this.localAI[0] + 1f;
                                if (this.justHit)
                                {
                                    this.localAI[0] = this.localAI[0] - (float)Main.rand.Next(20, 60);
                                    if (this.localAI[0] < 0f)
                                    {
                                        this.localAI[0] = 0f;
                                    }
                                }
                                if (this.localAI[0] > (float)Main.rand.Next(180, 900))
                                {
                                    this.localAI[0] = 0f;
                                    Vector2 center31 = Main.player[this.target].Center - base.Center;
                                    center31.Normalize();
                                    center31 = center31 * 8f;
                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, center31.X, center31.Y, 472, 18, 0f, Main.myPlayer, 0f, 0f);
                                }
                            }
                            int x143 = (int)base.Center.X / 16;
                            int y142 = (int)base.Center.Y / 16;
                            bool flag102 = false;
                            for (int g3 = x143 - 1; g3 <= x143 + 1; g3++)
                            {
                                for (int h3 = y142 - 1; h3 <= y142 + 1; h3++)
                                {
                                    if (Main.tile[g3, h3] == null)
                                    {
                                        return;
                                    }
                                    if (Main.tile[g3, h3].wall > 0)
                                    {
                                        flag102 = true;
                                    }
                                }
                            }
                            if (!flag102)
                            {
                                if (this.type == 237)
                                {
                                    this.Transform(236);
                                    return;
                                }
                                if (this.type == 238)
                                {
                                    this.Transform(163);
                                    return;
                                }
                                if (this.type == 240)
                                {
                                    this.Transform(239);
                                    return;
                                }
                                if (this.type == 531)
                                {
                                    this.Transform(530);
                                    return;
                                }
                                this.Transform(164);
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 41)
                    {
                        if (this.ai[2] > 1f)
                        {
                            this.ai[2] = this.ai[2] - 1f;
                        }
                        if (this.ai[2] == 0f)
                        {
                            this.ai[0] = -100f;
                            this.ai[2] = 1f;
                            this.TargetClosest(true);
                            this.spriteDirection = this.direction;
                        }
                        if (this.type == 378)
                        {
                            Vector2 vector2148 = new Vector2(-6f, -10f);
                            if (this.ai[1] == 5f)
                            {
                                this.velocity = Vector2.Zero;
                                this.position.X = this.position.X + (float)(this.width / 2);
                                this.position.Y = this.position.Y + (float)(this.height / 2);
                                this.width = 160;
                                this.height = 160;
                                this.position.X = this.position.X - (float)(this.width / 2);
                                this.position.Y = this.position.Y - (float)(this.height / 2);
                                this.dontTakeDamage = true;
                                if (this.ai[2] == 1f)
                                {
                                    this.life = -1;
                                    this.HitEffect(0, 10);
                                    this.active = false;
                                }
                                return;
                            }
                        }
                        if (this.type == 378 && this.ai[1] != 5f)
                        {
                            if (this.wet || Vector2.Distance(base.Center, Main.player[this.target].Center) < 64f)
                            {
                                this.ai[1] = 5f;
                                this.ai[2] = 3f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.wet && this.type != 177)
                        {
                            if (this.collideX)
                            {
                                NPC nPC147 = this;
                                nPC147.direction = nPC147.direction * -this.direction;
                                this.spriteDirection = this.direction;
                            }
                            if (this.collideY)
                            {
                                this.TargetClosest(true);
                                if (this.oldVelocity.Y >= 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - 2f;
                                }
                                else
                                {
                                    this.velocity.Y = 5f;
                                }
                                this.spriteDirection = this.direction;
                            }
                            if (this.velocity.Y > 4f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.95f;
                            }
                            this.velocity.Y = this.velocity.Y - 0.3f;
                            if (this.velocity.Y < -4f)
                            {
                                this.velocity.Y = -4f;
                            }
                        }
                        if (this.velocity.Y == 0f)
                        {
                            if (this.ai[3] == this.position.X)
                            {
                                NPC nPC148 = this;
                                nPC148.direction = nPC148.direction * -1;
                                this.ai[2] = 300f;
                            }
                            this.ai[3] = 0f;
                            this.velocity.X = this.velocity.X * 0.8f;
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if (this.type != 177)
                            {
                                this.ai[0] = this.ai[0] + 5f;
                            }
                            else
                            {
                                this.ai[0] = this.ai[0] + 2f;
                            }
                            Vector2 vector2154 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x144 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2154.X;
                            float y143 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2154.Y;
                            float single313 = (float)Math.Sqrt((double)(x144 * x144 + y143 * y143));
                            float single314 = 400f / single313;
                            single314 = (this.type != 177 ? single314 * 10f : single314 * 5f);
                            if (single314 > 30f)
                            {
                                single314 = 30f;
                            }
                            this.ai[0] = this.ai[0] + (float)((int)single314);
                            if (this.ai[0] >= 0f)
                            {
                                this.netUpdate = true;
                                if (this.ai[2] == 1f)
                                {
                                    this.TargetClosest(true);
                                }
                                if (this.type == 177)
                                {
                                    if (this.ai[1] != 2f)
                                    {
                                        this.velocity.Y = -7.5f;
                                        this.velocity.X = this.velocity.X + (float)(4 * this.direction);
                                        if (single313 < 350f && single313 > 200f)
                                        {
                                            this.velocity.X = this.velocity.X + (float)this.direction;
                                        }
                                        this.ai[0] = -120f;
                                        this.ai[1] = this.ai[1] + 1f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = -11.5f;
                                        this.velocity.X = this.velocity.X + 2f * (float)this.direction;
                                        if (single313 < 350f && single313 > 200f)
                                        {
                                            this.velocity.X = this.velocity.X + (float)this.direction;
                                        }
                                        this.ai[0] = -200f;
                                        this.ai[1] = 0f;
                                        this.ai[3] = this.position.X;
                                    }
                                }
                                else if (this.ai[1] != 3f)
                                {
                                    this.velocity.Y = -5f;
                                    this.velocity.X = this.velocity.X + (float)(5 * this.direction);
                                    if (single313 < 350f && single313 > 200f)
                                    {
                                        this.velocity.X = this.velocity.X + (float)this.direction;
                                    }
                                    this.ai[0] = -120f;
                                    this.ai[1] = this.ai[1] + 1f;
                                }
                                else
                                {
                                    this.velocity.Y = -9f;
                                    this.velocity.X = this.velocity.X + (float)(3 * this.direction);
                                    if (single313 < 350f && single313 > 200f)
                                    {
                                        this.velocity.X = this.velocity.X + (float)this.direction;
                                    }
                                    this.ai[0] = -200f;
                                    this.ai[1] = 0f;
                                    this.ai[3] = this.position.X;
                                }
                            }
                            else if (this.ai[0] >= -30f)
                            {
                                this.aiAction = 1;
                            }
                            this.spriteDirection = this.direction;
                            return;
                        }
                        if (this.target < 255)
                        {
                            if (this.type == 177)
                            {
                                bool flag103 = false;
                                if (this.position.Y + (float)this.height < Main.player[this.target].position.Y && this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    flag103 = true;
                                    this.velocity.X = this.velocity.X * 0.92f;
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                    }
                                }
                                if (!flag103 && (this.direction == 1 && this.velocity.X < 4f || this.direction == -1 && this.velocity.X > -4f))
                                {
                                    if ((this.direction != -1 || (double)this.velocity.X >= 0.1) && (this.direction != 1 || (double)this.velocity.X <= -0.1))
                                    {
                                        this.velocity.X = this.velocity.X * 0.93f;
                                        return;
                                    }
                                    this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                                    return;
                                }
                            }
                            else if (this.direction == 1 && this.velocity.X < 3f || this.direction == -1 && this.velocity.X > -3f)
                            {
                                if ((this.direction != -1 || (double)this.velocity.X >= 0.1) && (this.direction != 1 || (double)this.velocity.X <= -0.1))
                                {
                                    this.velocity.X = this.velocity.X * 0.93f;
                                    return;
                                }
                                this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 42)
                    {
                        this.TargetClosest(true);
                        if (this.ai[0] != 0f)
                        {
                            this.ai[0] = this.ai[0] + 1f;
                            if (this.ai[0] >= 21f)
                            {
                                this.ai[0] = 21f;
                                this.Transform(196);
                                return;
                            }
                        }
                        else
                        {
                            if (this.target >= 0)
                            {
                                Vector2 vector2155 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float x145 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2155.X;
                                float y144 = Main.player[this.target].position.Y - vector2155.Y;
                                if ((float)Math.Sqrt((double)(x145 * x145 + y144 * y144)) < 200f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                {
                                    this.ai[0] = 1f;
                                }
                            }
                            if (this.velocity.X != 0f || this.velocity.Y < 0f || this.velocity.Y > 2f || this.life != this.lifeMax)
                            {
                                this.ai[0] = 1f;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 43)
                    {
                        int num498 = 0;
                        for (int l4 = 0; l4 < 255; l4++)
                        {
                            if (Main.player[l4].active && !Main.player[l4].dead && (base.Center - Main.player[l4].Center).Length() < 1000f)
                            {
                                num498++;
                            }
                        }
                        if (Main.expertMode)
                        {
                            int num499 = (int)(20f * (1f - (float)this.life / (float)this.lifeMax));
                            this.defense = this.defDefense + num499;
                        }
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                        {
                            this.TargetClosest(true);
                        }
                        if (Main.player[this.target].dead && Main.expertMode)
                        {
                            if ((double)this.position.Y < Main.worldSurface * 16 + 2000)
                            {
                                this.velocity.Y = this.velocity.Y + 0.04f;
                            }
                            if (this.position.X >= (float)(Main.maxTilesX * 8))
                            {
                                this.velocity.X = this.velocity.X + 0.04f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X - 0.04f;
                            }
                            if (this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                                return;
                            }
                        }
                        else if (this.ai[0] == -1f)
                        {
                            if (Main.netMode != 1)
                            {
                                float single315 = this.ai[1];
                                do
                                {
                                    num3 = Main.rand.Next(3);
                                    if (num3 != 1)
                                    {
                                        if (num3 != 2)
                                        {
                                            continue;
                                        }
                                        num3 = 3;
                                    }
                                    else
                                    {
                                        num3 = 2;
                                    }
                                }
                                while ((float)num3 == single315);
                                this.ai[0] = (float)num3;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                return;
                            }
                        }
                        else if (this.ai[0] == 0f)
                        {
                            int num500 = 2;
                            if (Main.expertMode)
                            {
                                if (this.life < this.lifeMax / 2)
                                {
                                    num500++;
                                }
                                if (this.life < this.lifeMax / 3)
                                {
                                    num500++;
                                }
                                if (this.life < this.lifeMax / 5)
                                {
                                    num500++;
                                }
                            }
                            if (this.ai[1] > (float)(2 * num500) && this.ai[1] % 2f == 0f)
                            {
                                this.ai[0] = -1f;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                            if (this.ai[1] % 2f == 0f)
                            {
                                this.TargetClosest(true);
                                if (Math.Abs(this.position.Y + (float)(this.height / 2) - (Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))) < 20f)
                                {
                                    this.localAI[0] = 1f;
                                    this.ai[1] = this.ai[1] + 1f;
                                    this.ai[2] = 0f;
                                    float single316 = 12f;
                                    if (Main.expertMode)
                                    {
                                        single316 = 16f;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            single316 = single316 + 2f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            single316 = single316 + 2f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            single316 = single316 + 2f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.1)
                                        {
                                            single316 = single316 + 2f;
                                        }
                                    }
                                    Vector2 vector2156 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float x146 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2156.X;
                                    float y145 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2156.Y;
                                    float single317 = (float)Math.Sqrt((double)(x146 * x146 + y145 * y145));
                                    single317 = single316 / single317;
                                    this.velocity.X = x146 * single317;
                                    this.velocity.Y = y145 * single317;
                                    this.spriteDirection = this.direction;
                                    return;
                                }
                                this.localAI[0] = 0f;
                                float single318 = 12f;
                                float single319 = 0.15f;
                                if (Main.expertMode)
                                {
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        single318 = single318 + 1f;
                                        single319 = single319 + 0.05f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        single318 = single318 + 1f;
                                        single319 = single319 + 0.05f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        single318 = single318 + 2f;
                                        single319 = single319 + 0.05f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        single318 = single318 + 2f;
                                        single319 = single319 + 0.1f;
                                    }
                                }
                                if (this.position.Y + (float)(this.height / 2) >= Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))
                                {
                                    this.velocity.Y = this.velocity.Y - single319;
                                }
                                else
                                {
                                    this.velocity.Y = this.velocity.Y + single319;
                                }
                                if (this.velocity.Y < -12f)
                                {
                                    this.velocity.Y = -single318;
                                }
                                if (this.velocity.Y > 12f)
                                {
                                    this.velocity.Y = single318;
                                }
                                if (Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) > 600f)
                                {
                                    this.velocity.X = this.velocity.X + 0.15f * (float)this.direction;
                                }
                                else if (Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) >= 300f)
                                {
                                    this.velocity.X = this.velocity.X * 0.8f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X - 0.15f * (float)this.direction;
                                }
                                if (this.velocity.X < -16f)
                                {
                                    this.velocity.X = -16f;
                                }
                                if (this.velocity.X > 16f)
                                {
                                    this.velocity.X = 16f;
                                }
                                this.spriteDirection = this.direction;
                                return;
                            }
                            if (this.velocity.X >= 0f)
                            {
                                this.direction = 1;
                            }
                            else
                            {
                                this.direction = -1;
                            }
                            this.spriteDirection = this.direction;
                            int num501 = 600;
                            if (Main.expertMode)
                            {
                                if ((double)this.life < (double)this.lifeMax * 0.1)
                                {
                                    num501 = 300;
                                }
                                else if ((double)this.life < (double)this.lifeMax * 0.25)
                                {
                                    num501 = 450;
                                }
                                else if ((double)this.life < (double)this.lifeMax * 0.5)
                                {
                                    num501 = 500;
                                }
                                else if ((double)this.life < (double)this.lifeMax * 0.75)
                                {
                                    num501 = 550;
                                }
                            }
                            int num502 = 1;
                            if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))
                            {
                                num502 = -1;
                            }
                            if (this.direction == num502 && Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) > (float)num501)
                            {
                                this.ai[2] = 1f;
                            }
                            if (this.ai[2] != 1f)
                            {
                                this.localAI[0] = 1f;
                                return;
                            }
                            this.TargetClosest(true);
                            this.spriteDirection = this.direction;
                            this.localAI[0] = 0f;
                            NPC nPC149 = this;
                            nPC149.velocity = nPC149.velocity * 0.9f;
                            float single320 = 0.1f;
                            if (Main.expertMode)
                            {
                                if (this.life < this.lifeMax / 2)
                                {
                                    NPC nPC150 = this;
                                    nPC150.velocity = nPC150.velocity * 0.9f;
                                    single320 = single320 + 0.05f;
                                }
                                if (this.life < this.lifeMax / 3)
                                {
                                    NPC nPC151 = this;
                                    nPC151.velocity = nPC151.velocity * 0.9f;
                                    single320 = single320 + 0.05f;
                                }
                                if (this.life < this.lifeMax / 5)
                                {
                                    NPC nPC152 = this;
                                    nPC152.velocity = nPC152.velocity * 0.9f;
                                    single320 = single320 + 0.05f;
                                }
                            }
                            if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < single320)
                            {
                                this.ai[2] = 0f;
                                this.ai[1] = this.ai[1] + 1f;
                                return;
                            }
                        }
                        else if (this.ai[0] == 2f)
                        {
                            this.TargetClosest(true);
                            this.spriteDirection = this.direction;
                            float single321 = 12f;
                            float single322 = 0.07f;
                            if (Main.expertMode)
                            {
                                single322 = 0.1f;
                            }
                            Vector2 vector2157 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x147 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2157.X;
                            float y146 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 200f - vector2157.Y;
                            float single323 = (float)Math.Sqrt((double)(x147 * x147 + y146 * y146));
                            if (single323 < 200f)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                            single323 = single321 / single323;
                            if (this.velocity.X < x147)
                            {
                                this.velocity.X = this.velocity.X + single322;
                                if (this.velocity.X < 0f && x147 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + single322;
                                }
                            }
                            else if (this.velocity.X > x147)
                            {
                                this.velocity.X = this.velocity.X - single322;
                                if (this.velocity.X > 0f && x147 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - single322;
                                }
                            }
                            if (this.velocity.Y < y146)
                            {
                                this.velocity.Y = this.velocity.Y + single322;
                                if (this.velocity.Y < 0f && y146 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + single322;
                                    return;
                                }
                            }
                            else if (this.velocity.Y > y146)
                            {
                                this.velocity.Y = this.velocity.Y - single322;
                                if (this.velocity.Y > 0f && y146 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - single322;
                                    return;
                                }
                            }
                        }
                        else if (this.ai[0] == 1f)
                        {
                            this.localAI[0] = 0f;
                            this.TargetClosest(true);
                            Vector2 vector2158 = new Vector2(this.position.X + (float)(this.width / 2) + (float)(Main.rand.Next(20) * this.direction), this.position.Y + (float)this.height * 0.8f);
                            Vector2 vector2159 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x148 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2159.X;
                            float y147 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2159.Y;
                            float single324 = (float)Math.Sqrt((double)(x148 * x148 + y147 * y147));
                            this.ai[1] = this.ai[1] + 1f;
                            if (Main.expertMode)
                            {
                                this.ai[1] = this.ai[1] + (float)(num498 / 2);
                                if ((double)this.life < (double)this.lifeMax * 0.75)
                                {
                                    this.ai[1] = this.ai[1] + 0.25f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.5)
                                {
                                    this.ai[1] = this.ai[1] + 0.25f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.25)
                                {
                                    this.ai[1] = this.ai[1] + 0.25f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.1)
                                {
                                    this.ai[1] = this.ai[1] + 0.25f;
                                }
                            }
                            bool flag104 = false;
                            if (this.ai[1] > 40f)
                            {
                                this.ai[1] = 0f;
                                this.ai[2] = this.ai[2] + 1f;
                                flag104 = true;
                            }
                            if (Collision.CanHit(vector2158, 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && flag104)
                            {
                                if (Main.netMode != 1)
                                {
                                    int num503 = Main.rand.Next(210, 212);
                                    int num504 = NPC.NewNPC((int)vector2158.X, (int)vector2158.Y, num503, 0, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num504].velocity.X = (float)Main.rand.Next(-200, 201) * 0.002f;
                                    Main.npc[num504].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.002f;
                                    Main.npc[num504].localAI[0] = 60f;
                                    Main.npc[num504].netUpdate = true;
                                }
                            }
                            if (single324 > 400f || !Collision.CanHit(new Vector2(vector2158.X, vector2158.Y - 30f), 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float single325 = 14f;
                                float single326 = 0.1f;
                                vector2159 = vector2158;
                                x148 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2159.X;
                                y147 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2159.Y;
                                single324 = (float)Math.Sqrt((double)(x148 * x148 + y147 * y147));
                                single324 = single325 / single324;
                                if (this.velocity.X < x148)
                                {
                                    this.velocity.X = this.velocity.X + single326;
                                    if (this.velocity.X < 0f && x148 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single326;
                                    }
                                }
                                else if (this.velocity.X > x148)
                                {
                                    this.velocity.X = this.velocity.X - single326;
                                    if (this.velocity.X > 0f && x148 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single326;
                                    }
                                }
                                if (this.velocity.Y < y147)
                                {
                                    this.velocity.Y = this.velocity.Y + single326;
                                    if (this.velocity.Y < 0f && y147 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single326;
                                    }
                                }
                                else if (this.velocity.Y > y147)
                                {
                                    this.velocity.Y = this.velocity.Y - single326;
                                    if (this.velocity.Y > 0f && y147 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single326;
                                    }
                                }
                            }
                            else
                            {
                                NPC nPC153 = this;
                                nPC153.velocity = nPC153.velocity * 0.9f;
                            }
                            this.spriteDirection = this.direction;
                            if (this.ai[2] > 5f)
                            {
                                this.ai[0] = -1f;
                                this.ai[1] = 1f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.ai[0] == 3f)
                        {
                            float single327 = 4f;
                            float single328 = 0.05f;
                            if (Main.expertMode)
                            {
                                single328 = 0.075f;
                                single327 = 6f;
                            }
                            Vector2 vector2160 = new Vector2(this.position.X + (float)(this.width / 2) + (float)(Main.rand.Next(20) * this.direction), this.position.Y + (float)this.height * 0.8f);
                            Vector2 vector2161 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float x149 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2161.X;
                            float y148 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 300f - vector2161.Y;
                            float single329 = (float)Math.Sqrt((double)(x149 * x149 + y148 * y148));
                            this.ai[1] = this.ai[1] + 1f;
                            bool flag105 = false;
                            if (!Main.expertMode)
                            {
                                if (this.ai[1] % 40f == 39f)
                                {
                                    flag105 = true;
                                }
                            }
                            else if ((double)this.life < (double)this.lifeMax * 0.1)
                            {
                                if (this.ai[1] % 15f == 14f)
                                {
                                    flag105 = true;
                                }
                            }
                            else if (this.life < this.lifeMax / 3)
                            {
                                if (this.ai[1] % 25f == 24f)
                                {
                                    flag105 = true;
                                }
                            }
                            else if (this.life < this.lifeMax / 2)
                            {
                                if (this.ai[1] % 30f == 29f)
                                {
                                    flag105 = true;
                                }
                            }
                            else if (this.ai[1] % 35f == 34f)
                            {
                                flag105 = true;
                            }
                            if (flag105 && this.position.Y + (float)this.height < Main.player[this.target].position.Y && Collision.CanHit(vector2160, 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                if (Main.netMode != 1)
                                {
                                    float single330 = 8f;
                                    if (Main.expertMode)
                                    {
                                        single330 = single330 + 2f;
                                    }
                                    if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        single330 = single330 + 3f;
                                    }
                                    float x150 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2160.X + (float)Main.rand.Next(-80, 81);
                                    float y149 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2160.Y + (float)Main.rand.Next(-40, 41);
                                    float single331 = (float)Math.Sqrt((double)(x150 * x150 + y149 * y149));
                                    single331 = single330 / single331;
                                    x150 = x150 * single331;
                                    y149 = y149 * single331;
                                    int num505 = 11;
                                    int num506 = 55;
                                    int num507 = Projectile.NewProjectile(vector2160.X, vector2160.Y, x150, y149, num506, num505, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num507].timeLeft = 300;
                                }
                            }
                            if (!Collision.CanHit(new Vector2(vector2160.X, vector2160.Y - 30f), 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                single327 = 14f;
                                single328 = 0.1f;
                                vector2161 = vector2160;
                                x149 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2161.X;
                                y148 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2161.Y;
                                single329 = (float)Math.Sqrt((double)(x149 * x149 + y148 * y148));
                                single329 = single327 / single329;
                                if (this.velocity.X < x149)
                                {
                                    this.velocity.X = this.velocity.X + single328;
                                    if (this.velocity.X < 0f && x149 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single328;
                                    }
                                }
                                else if (this.velocity.X > x149)
                                {
                                    this.velocity.X = this.velocity.X - single328;
                                    if (this.velocity.X > 0f && x149 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single328;
                                    }
                                }
                                if (this.velocity.Y < y148)
                                {
                                    this.velocity.Y = this.velocity.Y + single328;
                                    if (this.velocity.Y < 0f && y148 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single328;
                                    }
                                }
                                else if (this.velocity.Y > y148)
                                {
                                    this.velocity.Y = this.velocity.Y - single328;
                                    if (this.velocity.Y > 0f && y148 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single328;
                                    }
                                }
                            }
                            else if (single329 > 100f)
                            {
                                this.TargetClosest(true);
                                this.spriteDirection = this.direction;
                                single329 = single327 / single329;
                                if (this.velocity.X < x149)
                                {
                                    this.velocity.X = this.velocity.X + single328;
                                    if (this.velocity.X < 0f && x149 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single328 * 2f;
                                    }
                                }
                                else if (this.velocity.X > x149)
                                {
                                    this.velocity.X = this.velocity.X - single328;
                                    if (this.velocity.X > 0f && x149 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single328 * 2f;
                                    }
                                }
                                if (this.velocity.Y < y148)
                                {
                                    this.velocity.Y = this.velocity.Y + single328;
                                    if (this.velocity.Y < 0f && y148 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single328 * 2f;
                                    }
                                }
                                else if (this.velocity.Y > y148)
                                {
                                    this.velocity.Y = this.velocity.Y - single328;
                                    if (this.velocity.Y > 0f && y148 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single328 * 2f;
                                    }
                                }
                            }
                            if (this.ai[1] > 800f)
                            {
                                this.ai[0] = -1f;
                                this.ai[1] = 3f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 44)
                    {
                        this.noGravity = true;
                        if (this.collideX)
                        {
                            if (this.oldVelocity.X <= 0f)
                            {
                                this.direction = 1;
                            }
                            else
                            {
                                this.direction = -1;
                            }
                            this.velocity.X = (float)this.direction;
                        }
                        if (this.collideY)
                        {
                            if (this.oldVelocity.Y <= 0f)
                            {
                                this.directionY = 1;
                            }
                            else
                            {
                                this.directionY = -1;
                            }
                            this.velocity.Y = (float)this.directionY;
                        }
                        int num508 = this.target;
                        int num509 = this.direction;
                        if (this.target == 255 || Main.player[this.target].dead || Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[0] = 90f;
                            this.TargetClosest(true);
                        }
                        else if (this.ai[0] > 0f)
                        {
                            this.ai[0] = this.ai[0] - 1f;
                            this.TargetClosest(true);
                        }
                        if (this.netUpdate && num508 == this.target && num509 == this.direction)
                        {
                            this.netUpdate = false;
                        }
                        float single332 = 0.05f;
                        float single333 = 0.01f;
                        float single334 = 3f;
                        float single335 = 1f;
                        float single336 = 30f;
                        float single337 = 100f;
                        float single338 = Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)));
                        float y150 = Main.player[this.target].position.Y - (float)(this.height / 2);
                        if (this.type == 509)
                        {
                            single332 = 0.09f;
                            single333 = 0.03f;
                            single334 = 5f;
                            single335 = 2f;
                            single336 = 40f;
                            single337 = 150f;
                            y150 = Main.player[this.target].Center.Y - (float)(this.height / 2);
                            this.rotation = this.velocity.X * 0.1f;
                            for (int m4 = 0; m4 < 200; m4++)
                            {
                                if (m4 != this.whoAmI && Main.npc[m4].active && Main.npc[m4].type == this.type && Math.Abs(this.position.X - Main.npc[m4].position.X) + Math.Abs(this.position.Y - Main.npc[m4].position.Y) < (float)this.width)
                                {
                                    if (this.position.X >= Main.npc[m4].position.X)
                                    {
                                        this.velocity.X = this.velocity.X + 0.05f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X - 0.05f;
                                    }
                                    if (this.position.Y >= Main.npc[m4].position.Y)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.05f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y - 0.05f;
                                    }
                                }
                            }
                        }
                        if (this.ai[0] <= 0f)
                        {
                            single334 = single334 * 0.8f;
                            single332 = single332 * 0.7f;
                            y150 = base.Center.Y + (float)(this.directionY * 1000);
                            if (this.velocity.X < 0f)
                            {
                                this.direction = -1;
                            }
                            else if (this.velocity.X > 0f || this.direction == 0)
                            {
                                this.direction = 1;
                            }
                        }
                        if (single338 > single336)
                        {
                            if (this.direction == -1 && this.velocity.X > -single334)
                            {
                                this.velocity.X = this.velocity.X - single332;
                                if (this.velocity.X > single334)
                                {
                                    this.velocity.X = this.velocity.X - single332;
                                }
                                else if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X - single332 / 2f;
                                }
                                if (this.velocity.X < -single334)
                                {
                                    this.velocity.X = -single334;
                                }
                            }
                            else if (this.direction == 1 && this.velocity.X < single334)
                            {
                                this.velocity.X = this.velocity.X + single332;
                                if (this.velocity.X < -single334)
                                {
                                    this.velocity.X = this.velocity.X + single332;
                                }
                                else if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X + single332 / 2f;
                                }
                                if (this.velocity.X > single334)
                                {
                                    this.velocity.X = single334;
                                }
                            }
                        }
                        if (single338 > single337)
                        {
                            y150 = y150 - single337 / 2f;
                        }
                        if (this.position.Y >= y150)
                        {
                            this.velocity.Y = this.velocity.Y - single333;
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y - single333;
                            }
                        }
                        else
                        {
                            this.velocity.Y = this.velocity.Y + single333;
                            if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y + single333;
                            }
                        }
                        if (this.velocity.Y < -single335)
                        {
                            this.velocity.Y = -single335;
                        }
                        if (this.velocity.Y > single335)
                        {
                            this.velocity.Y = single335;
                            return;
                        }
                    }
                    else if (this.aiStyle != 45)
                    {
                        if (this.aiStyle == 46)
                        {
                            this.noTileCollide = true;
                            if (NPC.golemBoss < 0)
                            {
                                this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                                return;
                            }
                            float single339 = 12f;
                            Vector2 vector2162 = new Vector2(base.Center.X, base.Center.Y);
                            float x151 = Main.npc[NPC.golemBoss].Center.X - vector2162.X;
                            float y151 = Main.npc[NPC.golemBoss].Center.Y - vector2162.Y;
                            y151 = y151 - 57f;
                            x151 = x151 - 3f;
                            float single340 = (float)Math.Sqrt((double)(x151 * x151 + y151 * y151));
                            if (single340 >= 20f)
                            {
                                single340 = single339 / single340;
                                this.velocity.X = x151 * single340;
                                this.velocity.Y = y151 * single340;
                                this.rotation = (float)this.velocity.X * 0.1f;
                            }
                            else
                            {
                                this.rotation = 0f;
                                this.velocity.X = x151;
                                this.velocity.Y = y151;
                            }
                            if (this.alpha > 0)
                            {
                                NPC nPC154 = this;
                                nPC154.alpha = nPC154.alpha - 10;
                                if (this.alpha < 0)
                                {
                                    this.alpha = 0;
                                }
                                this.ai[1] = 30f;
                            }
                            if (this.ai[0] == 0f)
                            {
                                this.ai[1] = this.ai[1] + 1f;
                                int num510 = 300;
                                if (this.ai[1] < 20f || this.ai[1] > (float)(num510 - 20))
                                {
                                    this.localAI[0] = 1f;
                                }
                                else
                                {
                                    this.localAI[0] = 0f;
                                }
                                if (this.ai[1] >= (float)num510)
                                {
                                    this.TargetClosest(true);
                                    this.ai[1] = 0f;
                                    Vector2 vector2163 = new Vector2(base.Center.X, base.Center.Y + 10f);
                                    float single341 = 8f;
                                    float x152 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2163.X;
                                    float y152 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2163.Y;
                                    float single342 = (float)Math.Sqrt((double)(x152 * x152 + y152 * y152));
                                    single342 = single341 / single342;
                                    x152 = x152 * single342;
                                    y152 = y152 * single342;
                                    int num511 = 18;
                                    int num512 = 258;
                                    if (Main.netMode != 1)
                                    {
                                        Projectile.NewProjectile(vector2163.X, vector2163.Y, x152, y152, num512, num511, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                }
                            }
                            else if (this.ai[0] == 1f)
                            {
                                this.TargetClosest(true);
                                Vector2 x153 = new Vector2(base.Center.X, base.Center.Y + 10f);
                                if (Main.player[this.target].Center.X < base.Center.X - (float)this.width)
                                {
                                    this.localAI[1] = -1f;
                                    x153.X = x153.X - 40f;
                                }
                                else if (Main.player[this.target].Center.X <= base.Center.X + (float)this.width)
                                {
                                    this.localAI[1] = 0f;
                                }
                                else
                                {
                                    this.localAI[1] = 1f;
                                    x153.X = x153.X + 40f;
                                }
                                this.ai[1] = this.ai[1] + 1f;
                                if ((double)this.life < (double)this.lifeMax * 0.4)
                                {
                                    this.ai[1] = this.ai[1] + 1f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.2)
                                {
                                    this.ai[1] = this.ai[1] + 1f;
                                }
                                int num513 = 300;
                                if (this.ai[1] < 20f || this.ai[1] > (float)(num513 - 20))
                                {
                                    this.localAI[0] = 1f;
                                }
                                else
                                {
                                    this.localAI[0] = 0f;
                                }
                                if (this.ai[1] >= (float)num513)
                                {
                                    this.TargetClosest(true);
                                    this.ai[1] = 0f;
                                    float single343 = 8f;
                                    float x154 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - x153.X;
                                    float y153 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - x153.Y;
                                    float single344 = (float)Math.Sqrt((double)(x154 * x154 + y153 * y153));
                                    single344 = single343 / single344;
                                    x154 = x154 * single344;
                                    y153 = y153 * single344;
                                    int num514 = 24;
                                    int num515 = 258;
                                    if (Main.netMode != 1)
                                    {
                                        Projectile.NewProjectile(x153.X, x153.Y, x154, y153, num515, num514, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                }
                                this.ai[2] = this.ai[2] + 1f;
                                if (this.life < this.lifeMax / 3)
                                {
                                    this.ai[2] = this.ai[2] + 1f;
                                }
                                if (this.life < this.lifeMax / 4)
                                {
                                    this.ai[2] = this.ai[2] + 1f;
                                }
                                if (this.life < this.lifeMax / 5)
                                {
                                    this.ai[2] = this.ai[2] + 1f;
                                }
                                if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                {
                                    this.ai[2] = this.ai[2] + 4f;
                                }
                                if (this.ai[2] > (float)(60 + Main.rand.Next(600)))
                                {
                                    this.ai[2] = 0f;
                                    int num516 = 28;
                                    int num517 = 259;
                                    if (this.localAI[1] == 0f)
                                    {
                                        for (int n4 = 0; n4 < 2; n4++)
                                        {
                                            x153 = new Vector2(base.Center.X, base.Center.Y - 22f);
                                            if (n4 != 0)
                                            {
                                                x153.X = x153.X + 18f;
                                            }
                                            else
                                            {
                                                x153.X = x153.X - 18f;
                                            }
                                            float single345 = 11f;
                                            float x155 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - x153.X;
                                            float y154 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - x153.Y;
                                            float single346 = (float)Math.Sqrt((double)(x155 * x155 + y154 * y154));
                                            single346 = single345 / single346;
                                            x155 = x155 * single346;
                                            y154 = y154 * single346;
                                            x153.X = x153.X + x155 * 3f;
                                            x153.Y = x153.Y + y154 * 3f;
                                            if (Main.netMode != 1)
                                            {
                                                int num518 = Projectile.NewProjectile(x153.X, x153.Y, x155, y154, num517, num516, 0f, Main.myPlayer, 0f, 0f);
                                                Main.projectile[num518].timeLeft = 300;
                                            }
                                        }
                                    }
                                    else if (this.localAI[1] != 0f)
                                    {
                                        x153 = new Vector2(base.Center.X, base.Center.Y - 22f);
                                        if (this.localAI[1] == -1f)
                                        {
                                            x153.X = x153.X - 30f;
                                        }
                                        else if (this.localAI[1] == 1f)
                                        {
                                            x153.X = x153.X + 30f;
                                        }
                                        float single347 = 12f;
                                        float x156 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - x153.X;
                                        float y155 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - x153.Y;
                                        float single348 = (float)Math.Sqrt((double)(x156 * x156 + y155 * y155));
                                        single348 = single347 / single348;
                                        x156 = x156 * single348;
                                        y155 = y155 * single348;
                                        x153.X = x153.X + x156 * 3f;
                                        x153.Y = x153.Y + y155 * 3f;
                                        if (Main.netMode != 1)
                                        {
                                            int num519 = Projectile.NewProjectile(x153.X, x153.Y, x156, y155, num517, num516, 0f, Main.myPlayer, 0f, 0f);
                                            Main.projectile[num519].timeLeft = 300;
                                        }
                                    }
                                }
                            }
                            if (this.life < this.lifeMax / 2)
                            {
                                this.ai[0] = 1f;
                                return;
                            }
                            this.ai[0] = 0f;
                            return;
                        }
                        if (this.aiStyle == 47)
                        {
                            if (NPC.golemBoss < 0)
                            {
                                this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                                return;
                            }
                            if (this.alpha > 0)
                            {
                                NPC nPC155 = this;
                                nPC155.alpha = nPC155.alpha - 10;
                                if (this.alpha < 0)
                                {
                                    this.alpha = 0;
                                }
                                this.ai[1] = 0f;
                            }
                            if (this.ai[0] == 0f)
                            {
                                this.noTileCollide = true;
                                float single349 = 14f;
                                if (this.life < this.lifeMax / 2)
                                {
                                    single349 = single349 + 3f;
                                }
                                if (this.life < this.lifeMax / 4)
                                {
                                    single349 = single349 + 3f;
                                }
                                if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax)
                                {
                                    single349 = single349 + 8f;
                                }
                                Vector2 vector2164 = new Vector2(base.Center.X, base.Center.Y);
                                float x157 = Main.npc[NPC.golemBoss].Center.X - vector2164.X;
                                float y156 = Main.npc[NPC.golemBoss].Center.Y - vector2164.Y;
                                y156 = y156 - 9f;
                                x157 = (this.type != 247 ? x157 + 78f : x157 - 84f);
                                float single350 = (float)Math.Sqrt((double)(x157 * x157 + y156 * y156));
                                if (single350 >= 12f + single349)
                                {
                                    single350 = single349 / single350;
                                    this.velocity.X = x157 * single350;
                                    this.velocity.Y = y156 * single350;
                                    this.rotation = (float)Math.Atan2((double)(-this.velocity.Y), (double)(-this.velocity.X));
                                    if (this.type == 247)
                                    {
                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                        return;
                                    }
                                }
                                else
                                {
                                    this.rotation = 0f;
                                    this.velocity.X = x157;
                                    this.velocity.Y = y156;
                                    this.ai[1] = this.ai[1] + 1f;
                                    if (this.life < this.lifeMax / 2)
                                    {
                                        this.ai[1] = this.ai[1] + 1f;
                                    }
                                    if (this.life < this.lifeMax / 4)
                                    {
                                        this.ai[1] = this.ai[1] + 1f;
                                    }
                                    if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax)
                                    {
                                        this.ai[1] = this.ai[1] + 10f;
                                    }
                                    if (this.ai[1] >= 60f)
                                    {
                                        this.TargetClosest(true);
                                        if ((this.type != 247 || base.Center.X + 100f <= Main.player[this.target].Center.X) && (this.type != 248 || base.Center.X - 100f >= Main.player[this.target].Center.X))
                                        {
                                            this.ai[1] = 0f;
                                            return;
                                        }
                                        this.ai[1] = 0f;
                                        this.ai[0] = 1f;
                                        return;
                                    }
                                }
                            }
                            else if (this.ai[0] == 1f)
                            {
                                this.noTileCollide = true;
                                this.collideX = false;
                                this.collideY = false;
                                float single351 = 12f;
                                if (this.life < this.lifeMax / 2)
                                {
                                    single351 = single351 + 4f;
                                }
                                if (this.life < this.lifeMax / 4)
                                {
                                    single351 = single351 + 4f;
                                }
                                if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax)
                                {
                                    single351 = single351 + 10f;
                                }
                                Vector2 vector2165 = new Vector2(base.Center.X, base.Center.Y);
                                float x158 = Main.player[this.target].Center.X - vector2165.X;
                                float y157 = Main.player[this.target].Center.Y - vector2165.Y;
                                float single352 = (float)Math.Sqrt((double)(x158 * x158 + y157 * y157));
                                single352 = single351 / single352;
                                this.velocity.X = x158 * single352;
                                this.velocity.Y = y157 * single352;
                                this.ai[0] = 2f;
                                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                if (this.type == 247)
                                {
                                    this.rotation = (float)Math.Atan2((double)(-this.velocity.Y), (double)(-this.velocity.X));
                                    return;
                                }
                            }
                            else if (this.ai[0] == 2f)
                            {
                                if (Math.Abs(this.velocity.X) <= Math.Abs(this.velocity.Y))
                                {
                                    if (this.velocity.Y > 0f && base.Center.Y > Main.player[this.target].Center.Y)
                                    {
                                        this.noTileCollide = false;
                                    }
                                    if (this.velocity.Y < 0f && base.Center.Y < Main.player[this.target].Center.Y)
                                    {
                                        this.noTileCollide = false;
                                    }
                                }
                                else
                                {
                                    if (this.velocity.X > 0f && base.Center.X > Main.player[this.target].Center.X)
                                    {
                                        this.noTileCollide = false;
                                    }
                                    if (this.velocity.X < 0f && base.Center.X < Main.player[this.target].Center.X)
                                    {
                                        this.noTileCollide = false;
                                    }
                                }
                                Vector2 vector2166 = new Vector2(base.Center.X, base.Center.Y);
                                float x159 = Main.npc[NPC.golemBoss].Center.X - vector2166.X;
                                float y158 = Main.npc[NPC.golemBoss].Center.Y - vector2166.Y;
                                x159 = x159 + Main.npc[NPC.golemBoss].velocity.X;
                                y158 = y158 + Main.npc[NPC.golemBoss].velocity.Y;
                                y158 = y158 - 9f;
                                x159 = (this.type != 247 ? x159 + 78f : x159 - 84f);
                                float single353 = (float)Math.Sqrt((double)(x159 * x159 + y158 * y158));
                                if (Main.npc[NPC.golemBoss].life >= Main.npc[NPC.golemBoss].lifeMax)
                                {
                                    bool flag106 = this.justHit;
                                    if (flag106)
                                    {
                                        int num520 = 0;
                                        while (num520 < 200)
                                        {
                                            if (!Main.npc[num520].active || Main.npc[num520].type != 246)
                                            {
                                                num520++;
                                            }
                                            else
                                            {
                                                if (Main.npc[num520].life >= Main.npc[num520].lifeMax / 2)
                                                {
                                                    break;
                                                }
                                                if (this.knockBackResist == 0f)
                                                {
                                                    flag106 = false;
                                                }
                                                this.knockBackResist = 0f;
                                                break;
                                            }
                                        }
                                    }
                                    if (single353 > 600f || this.collideX || this.collideY || flag106)
                                    {
                                        this.noTileCollide = true;
                                        this.ai[0] = 0f;
                                        return;
                                    }
                                }
                                else
                                {
                                    this.knockBackResist = 0f;
                                    if (single353 > 700f || this.collideX || this.collideY)
                                    {
                                        this.noTileCollide = true;
                                        this.ai[0] = 0f;
                                        return;
                                    }
                                }
                            }
                            else if (this.ai[0] == 3f)
                            {
                                this.noTileCollide = true;
                                float single354 = 12f;
                                float single355 = 0.4f;
                                Vector2 vector2167 = new Vector2(base.Center.X, base.Center.Y);
                                float x160 = Main.player[this.target].Center.X - vector2167.X;
                                float y159 = Main.player[this.target].Center.Y - vector2167.Y;
                                float single356 = (float)Math.Sqrt((double)(x160 * x160 + y159 * y159));
                                single356 = single354 / single356;
                                x160 = x160 * single356;
                                y159 = y159 * single356;
                                if (this.velocity.X < x160)
                                {
                                    this.velocity.X = this.velocity.X + single355;
                                    if (this.velocity.X < 0f && x160 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single355 * 2f;
                                    }
                                }
                                else if (this.velocity.X > x160)
                                {
                                    this.velocity.X = this.velocity.X - single355;
                                    if (this.velocity.X > 0f && x160 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single355 * 2f;
                                    }
                                }
                                if (this.velocity.Y < y159)
                                {
                                    this.velocity.Y = this.velocity.Y + single355;
                                    if (this.velocity.Y < 0f && y159 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single355 * 2f;
                                    }
                                }
                                else if (this.velocity.Y > y159)
                                {
                                    this.velocity.Y = this.velocity.Y - single355;
                                    if (this.velocity.Y > 0f && y159 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single355 * 2f;
                                    }
                                }
                                this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                if (this.type == 247)
                                {
                                    this.rotation = (float)Math.Atan2((double)(-this.velocity.Y), (double)(-this.velocity.X));
                                    return;
                                }
                            }
                        }
                        else if (this.aiStyle == 48)
                        {
                            bool flag107 = false;
                            if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                this.noTileCollide = false;
                            }
                            else
                            {
                                this.noTileCollide = true;
                                flag107 = true;
                            }
                            if (NPC.golemBoss < 0)
                            {
                                this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                                return;
                            }
                            this.TargetClosest(true);
                            float single357 = 7f;
                            float single358 = 0.05f;
                            Vector2 vector2168 = new Vector2(base.Center.X, base.Center.Y);
                            float x161 = Main.player[this.target].Center.X - vector2168.X;
                            float y160 = Main.player[this.target].Center.Y - vector2168.Y - 300f;
                            float single359 = (float)Math.Sqrt((double)(x161 * x161 + y160 * y160));
                            single359 = single357 / single359;
                            x161 = x161 * single359;
                            y160 = y160 * single359;
                            if (this.velocity.X < x161)
                            {
                                this.velocity.X = this.velocity.X + single358;
                                if (this.velocity.X < 0f && x161 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + single358;
                                }
                            }
                            else if (this.velocity.X > x161)
                            {
                                this.velocity.X = this.velocity.X - single358;
                                if (this.velocity.X > 0f && x161 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - single358;
                                }
                            }
                            if (this.velocity.Y < y160)
                            {
                                this.velocity.Y = this.velocity.Y + single358;
                                if (this.velocity.Y < 0f && y160 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + single358;
                                }
                            }
                            else if (this.velocity.Y > y160)
                            {
                                this.velocity.Y = this.velocity.Y - single358;
                                if (this.velocity.Y > 0f && y160 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - single358;
                                }
                            }
                            this.ai[1] = this.ai[1] + 1f;
                            if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.8)
                            {
                                this.ai[1] = this.ai[1] + 1f;
                            }
                            if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.6)
                            {
                                this.ai[1] = this.ai[1] + 1f;
                            }
                            if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.2)
                            {
                                this.ai[1] = this.ai[1] + 1f;
                            }
                            if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.1)
                            {
                                this.ai[1] = this.ai[1] + 1f;
                            }
                            int num521 = 360;
                            if (this.ai[1] < 20f || this.ai[1] > (float)(num521 - 20))
                            {
                                this.localAI[0] = 1f;
                            }
                            else
                            {
                                this.localAI[0] = 0f;
                            }
                            if (flag107)
                            {
                                this.ai[1] = 20f;
                            }
                            if (this.ai[1] >= (float)num521)
                            {
                                this.TargetClosest(true);
                                this.ai[1] = 0f;
                                Vector2 vector2169 = new Vector2(base.Center.X, base.Center.Y - 10f);
                                float single360 = 8f;
                                int num522 = 20;
                                int num523 = 258;
                                float x162 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2169.X;
                                float y161 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2169.Y;
                                float single361 = (float)Math.Sqrt((double)(x162 * x162 + y161 * y161));
                                single361 = single360 / single361;
                                x162 = x162 * single361;
                                y161 = y161 * single361;
                                if (Main.netMode != 1)
                                {
                                    Projectile.NewProjectile(vector2169.X, vector2169.Y, x162, y161, num523, num522, 0f, Main.myPlayer, 0f, 0f);
                                }
                            }
                            this.ai[2] = this.ai[2] + 1f;
                            if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax / 1.25)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax / 1.5)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 2)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 3)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 4)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 5)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 6)
                            {
                                this.ai[2] = this.ai[2] + 1f;
                            }
                            if (!Collision.CanHit(Main.npc[NPC.golemBoss].Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                this.ai[2] = this.ai[2] + 4f;
                            }
                            if (this.ai[2] > (float)(100 + Main.rand.Next(4800)))
                            {
                                this.ai[2] = 0f;
                                for (int o4 = 0; o4 < 2; o4++)
                                {
                                    Vector2 y162 = new Vector2(base.Center.X, base.Center.Y - 50f);
                                    if (o4 == 0)
                                    {
                                        y162.X = y162.X - 14f;
                                    }
                                    else if (o4 == 1)
                                    {
                                        y162.X = y162.X + 14f;
                                    }
                                    float single362 = 11f;
                                    int num524 = 24;
                                    int num525 = 259;
                                    if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.5)
                                    {
                                        num524++;
                                        single362 = single362 + 0.25f;
                                    }
                                    if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.4)
                                    {
                                        num524++;
                                        single362 = single362 + 0.25f;
                                    }
                                    if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.3)
                                    {
                                        num524++;
                                        single362 = single362 + 0.25f;
                                    }
                                    if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.2)
                                    {
                                        num524++;
                                        single362 = single362 + 0.25f;
                                    }
                                    if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.1)
                                    {
                                        num524++;
                                        single362 = single362 + 0.25f;
                                    }
                                    float x163 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - y162.X;
                                    float y163 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - y162.Y;
                                    float single363 = (float)Math.Sqrt((double)(x163 * x163 + y163 * y163));
                                    single363 = single362 / single363;
                                    x163 = x163 * single363;
                                    y163 = y163 * single363;
                                    y162.X = y162.X + x163 * 3f;
                                    y162.Y = y162.Y + y163 * 3f;
                                    if (Main.netMode != 1)
                                    {
                                        int num526 = Projectile.NewProjectile(y162.X, y162.Y, x163, y163, num525, num524, 0f, Main.myPlayer, 0f, 0f);
                                        Main.projectile[num526].timeLeft = 300;
                                    }
                                }
                                return;
                            }
                        }
                        else if (this.aiStyle != 49)
                        {
                            if (this.aiStyle == 50)
                            {
                                if (this.timeLeft > 5)
                                {
                                    this.timeLeft = 5;
                                }
                                this.noTileCollide = true;
                                this.velocity.Y = this.velocity.Y + 0.02f;
                                if (this.velocity.Y < 0f && !Main.expertMode)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.99f;
                                }
                                if (this.velocity.Y > 1f)
                                {
                                    this.velocity.Y = 1f;
                                }
                                this.TargetClosest(true);
                                if (this.position.X + (float)this.width < Main.player[this.target].position.X)
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.98f;
                                    }
                                    if (Main.expertMode && this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.98f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.1f;
                                    if (Main.expertMode)
                                    {
                                        this.velocity.X = this.velocity.X + 0.1f;
                                    }
                                }
                                else if (this.position.X > Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.98f;
                                    }
                                    if (Main.expertMode && this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.98f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.1f;
                                    if (Main.expertMode)
                                    {
                                        this.velocity.X = this.velocity.X + 0.1f;
                                    }
                                }
                                if (this.velocity.X > 5f || this.velocity.X < -5f)
                                {
                                    this.velocity.X = this.velocity.X * 0.97f;
                                }
                                this.rotation = this.velocity.X * 0.2f;
                                return;
                            }
                            if (this.aiStyle == 51)
                            {
                                bool flag108 = false;
                                bool flag109 = false;
                                this.TargetClosest(true);
                                if (Main.player[this.target].dead)
                                {
                                    flag109 = true;
                                    flag108 = true;
                                }
                                if (Main.netMode != 1 && Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)6000)
                                {
                                    this.active = false;
                                    this.life = 0;
                                    if (Main.netMode == 2)
                                    {
                                        NetMessage.SendData(23, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                }
                                NPC.plantBoss = this.whoAmI;
                                if (this.localAI[0] == 0f && Main.netMode != 1)
                                {
                                    this.localAI[0] = 1f;
                                    NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 263, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                    NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 263, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                    NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 263, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                }
                                int[] numArray2 = new int[3];
                                float x164 = 0f;
                                float y164 = 0f;
                                int num527 = 0;
                                for (int p4 = 0; p4 < 200; p4++)
                                {
                                    if (Main.npc[p4].active && Main.npc[p4].aiStyle == 52)
                                    {
                                        x164 = x164 + Main.npc[p4].Center.X;
                                        y164 = y164 + Main.npc[p4].Center.Y;
                                        numArray2[num527] = p4;
                                        num527++;
                                        if (num527 > 2)
                                        {
                                            break;
                                        }
                                    }
                                }
                                x164 = x164 / (float)num527;
                                y164 = y164 / (float)num527;
                                float single364 = 2.5f;
                                float single365 = 0.025f;
                                if (this.life < this.lifeMax / 2)
                                {
                                    single364 = 5f;
                                    single365 = 0.05f;
                                }
                                if (this.life < this.lifeMax / 4)
                                {
                                    single364 = 7f;
                                }
                                if (!Main.player[this.target].ZoneJungle || (double)Main.player[this.target].position.Y < Main.worldSurface * 16 || Main.player[this.target].position.Y > (float)((Main.maxTilesY - 200) * 16))
                                {
                                    flag108 = true;
                                    single364 = single364 + 8f;
                                    single365 = 0.15f;
                                }
                                if (Main.expertMode)
                                {
                                    single364 = single364 + 1f;
                                    single364 = single364 * 1.1f;
                                    single365 = single365 + 0.01f;
                                    single365 = single365 * 1.1f;
                                }
                                Vector2 vector2170 = new Vector2(x164, y164);
                                float x165 = Main.player[this.target].Center.X - vector2170.X;
                                float y165 = Main.player[this.target].Center.Y - vector2170.Y;
                                if (flag109)
                                {
                                    y165 = y165 * -1f;
                                    x165 = x165 * -1f;
                                    single364 = single364 + 8f;
                                }
                                float single366 = (float)Math.Sqrt((double)(x165 * x165 + y165 * y165));
                                int num528 = 500;
                                if (flag108)
                                {
                                    num528 = num528 + 350;
                                }
                                if (Main.expertMode)
                                {
                                    num528 = num528 + 150;
                                }
                                if (single366 >= (float)num528)
                                {
                                    single366 = (float)num528 / single366;
                                    x165 = x165 * single366;
                                    y165 = y165 * single366;
                                }
                                x164 = x164 + x165;
                                y164 = y164 + y165;
                                vector2170 = new Vector2(base.Center.X, base.Center.Y);
                                x165 = x164 - vector2170.X;
                                y165 = y164 - vector2170.Y;
                                single366 = (float)Math.Sqrt((double)(x165 * x165 + y165 * y165));
                                if (single366 >= single364)
                                {
                                    single366 = single364 / single366;
                                    x165 = x165 * single366;
                                    y165 = y165 * single366;
                                }
                                else
                                {
                                    x165 = this.velocity.X;
                                    y165 = this.velocity.Y;
                                }
                                if (this.velocity.X < x165)
                                {
                                    this.velocity.X = this.velocity.X + single365;
                                    if (this.velocity.X < 0f && x165 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + single365 * 2f;
                                    }
                                }
                                else if (this.velocity.X > x165)
                                {
                                    this.velocity.X = this.velocity.X - single365;
                                    if (this.velocity.X > 0f && x165 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - single365 * 2f;
                                    }
                                }
                                if (this.velocity.Y < y165)
                                {
                                    this.velocity.Y = this.velocity.Y + single365;
                                    if (this.velocity.Y < 0f && y165 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + single365 * 2f;
                                    }
                                }
                                else if (this.velocity.Y > y165)
                                {
                                    this.velocity.Y = this.velocity.Y - single365;
                                    if (this.velocity.Y > 0f && y165 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - single365 * 2f;
                                    }
                                }
                                Vector2 vector2171 = new Vector2(base.Center.X, base.Center.Y);
                                float x166 = Main.player[this.target].Center.X - vector2171.X;
                                float y166 = Main.player[this.target].Center.Y - vector2171.Y;
                                this.rotation = (float)Math.Atan2((double)y166, (double)x166) + 1.57f;
                                if (this.life <= this.lifeMax / 2)
                                {
                                    this.defense = 10;
                                    this.damage = (int)(70f * Main.damageMultiplier);
                                    if (flag108)
                                    {
                                        NPC nPC156 = this;
                                        nPC156.defense = nPC156.defense * 4;
                                        NPC nPC157 = this;
                                        nPC157.damage = nPC157.damage * 2;
                                    }
                                    if (Main.netMode != 1)
                                    {
                                        if (this.localAI[0] == 1f)
                                        {
                                            this.localAI[0] = 2f;
                                            for (int q4 = 0; q4 < 8; q4++)
                                            {
                                                NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 264, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                            }
                                            if (Main.expertMode)
                                            {
                                                for (int r4 = 0; r4 < 200; r4++)
                                                {
                                                    if (Main.npc[r4].active && Main.npc[r4].aiStyle == 52)
                                                    {
                                                        for (int s4 = 0; s4 < 3; s4++)
                                                        {
                                                            int num529 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 264, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                            Main.npc[num529].ai[3] = (float)(r4 + 1);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else if (Main.expertMode && Main.rand.Next(60) == 0)
                                        {
                                            int num530 = 0;
                                            for (int t4 = 0; t4 < 200; t4++)
                                            {
                                                if (Main.npc[t4].active && Main.npc[t4].type == 264 && Main.npc[t4].ai[3] == 0f)
                                                {
                                                    num530++;
                                                }
                                            }
                                            if (num530 < 8 && Main.rand.Next((num530 + 1) * 10) <= 1)
                                            {
                                                NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 264, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                            }
                                        }
                                    }
                                    if (this.localAI[2] == 0f)
                                    {
                                        this.localAI[2] = 1f;
                                    }
                                    this.localAI[1] = this.localAI[1] + 1f;
                                    if ((double)this.life < (double)this.lifeMax * 0.4)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.3)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.2)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                    }
                                    if (this.localAI[1] >= 350f)
                                    {
                                        float single367 = 8f;
                                        Vector2 vector2172 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float x167 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2172.X + (float)Main.rand.Next(-10, 11);
                                        float single368 = Math.Abs(x167 * 0.2f);
                                        float y167 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector2172.Y + (float)Main.rand.Next(-10, 11);
                                        if (y167 > 0f)
                                        {
                                            single368 = 0f;
                                        }
                                        y167 = y167 - single368;
                                        float single369 = (float)Math.Sqrt((double)(x167 * x167 + y167 * y167));
                                        single369 = single367 / single369;
                                        x167 = x167 * single369;
                                        y167 = y167 * single369;
                                        int num531 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 265, 0, 0f, 0f, 0f, 0f, 255);
                                        Main.npc[num531].velocity.X = x167;
                                        Main.npc[num531].velocity.Y = y167;
                                        Main.npc[num531].netUpdate = true;
                                        this.localAI[1] = 0f;
                                        return;
                                    }
                                }
                                else
                                {
                                    this.defense = 36;
                                    this.damage = (int)(50f * Main.damageMultiplier);
                                    if (flag108)
                                    {
                                        NPC nPC158 = this;
                                        nPC158.defense = nPC158.defense * 2;
                                        NPC nPC159 = this;
                                        nPC159.damage = nPC159.damage * 2;
                                    }
                                    if (Main.netMode != 1)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                        if ((double)this.life < (double)this.lifeMax * 0.9)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.8)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.7)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.6)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if (flag108)
                                        {
                                            this.localAI[1] = this.localAI[1] + 3f;
                                        }
                                        if (Main.expertMode)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                        }
                                        if (Main.expertMode && this.justHit && Main.rand.Next(2) == 0)
                                        {
                                            this.localAI[3] = 1f;
                                        }
                                        if (this.localAI[1] > 80f)
                                        {
                                            this.localAI[1] = 0f;
                                            bool flag110 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                                            if (this.localAI[3] > 0f)
                                            {
                                                flag110 = true;
                                                this.localAI[3] = 0f;
                                            }
                                            if (flag110)
                                            {
                                                Vector2 x168 = new Vector2(base.Center.X, base.Center.Y);
                                                float single370 = 15f;
                                                if (Main.expertMode)
                                                {
                                                    single370 = 17f;
                                                }
                                                float x169 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - x168.X;
                                                float y168 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - x168.Y;
                                                float single371 = (float)Math.Sqrt((double)(x169 * x169 + y168 * y168));
                                                single371 = single370 / single371;
                                                x169 = x169 * single371;
                                                y168 = y168 * single371;
                                                int num532 = 22;
                                                int num533 = 275;
                                                int num534 = 4;
                                                int num535 = 8;
                                                if (Main.expertMode)
                                                {
                                                    num534 = 2;
                                                    num535 = 6;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.8 && Main.rand.Next(num534) == 0)
                                                {
                                                    num532 = 27;
                                                    this.localAI[1] = -30f;
                                                    num533 = 276;
                                                }
                                                else if ((double)this.life < (double)this.lifeMax * 0.8 && Main.rand.Next(num535) == 0)
                                                {
                                                    num532 = 31;
                                                    this.localAI[1] = -120f;
                                                    num533 = 277;
                                                }
                                                if (flag108)
                                                {
                                                    num532 = num532 * 2;
                                                }
                                                if (Main.expertMode)
                                                {
                                                    num532 = (int)((double)num532 * 0.9);
                                                }
                                                x168.X = x168.X + x169 * 3f;
                                                x168.Y = x168.Y + y168 * 3f;
                                                int num536 = Projectile.NewProjectile(x168.X, x168.Y, x169, y168, num533, num532, 0f, Main.myPlayer, 0f, 0f);
                                                if (num533 != 277)
                                                {
                                                    Main.projectile[num536].timeLeft = 300;
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else if (this.aiStyle == 52)
                            {
                                bool flag111 = false;
                                bool flag112 = false;
                                if (NPC.plantBoss < 0)
                                {
                                    this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                                    this.netUpdate = true;
                                    return;
                                }
                                if (Main.player[Main.npc[NPC.plantBoss].target].dead)
                                {
                                    flag112 = true;
                                }
                                if (NPC.plantBoss != -1 && !Main.player[Main.npc[NPC.plantBoss].target].ZoneJungle || (double)Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > (float)((Main.maxTilesY - 200) * 16) || flag112)
                                {
                                    this.localAI[0] = this.localAI[0] - 4f;
                                    flag111 = true;
                                }
                                if (Main.netMode == 1)
                                {
                                    if (this.ai[0] == 0f)
                                    {
                                        this.ai[0] = (float)((int)(base.Center.X / 16f));
                                    }
                                    if (this.ai[1] == 0f)
                                    {
                                        this.ai[1] = (float)((int)(base.Center.X / 16f));
                                    }
                                }
                                if (Main.netMode != 1)
                                {
                                    if (this.ai[0] == 0f || this.ai[1] == 0f)
                                    {
                                        this.localAI[0] = 0f;
                                    }
                                    this.localAI[0] = this.localAI[0] - 1f;
                                    if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2)
                                    {
                                        this.localAI[0] = this.localAI[0] - 2f;
                                    }
                                    if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 4)
                                    {
                                        this.localAI[0] = this.localAI[0] - 2f;
                                    }
                                    if (flag111)
                                    {
                                        this.localAI[0] = this.localAI[0] - 6f;
                                    }
                                    if (!flag112 && this.localAI[0] <= 0f && this.ai[0] != 0f)
                                    {
                                        for (int u4 = 0; u4 < 200; u4++)
                                        {
                                            if (u4 != this.whoAmI && Main.npc[u4].active && Main.npc[u4].type == this.type && (Main.npc[u4].velocity.X != 0f || Main.npc[u4].velocity.Y != 0f))
                                            {
                                                this.localAI[0] = (float)Main.rand.Next(60, 300);
                                            }
                                        }
                                    }
                                    if (this.localAI[0] <= 0f)
                                    {
                                        this.localAI[0] = (float)Main.rand.Next(300, 600);
                                        bool flag113 = false;
                                        int num537 = 0;
                                        while (!flag113 && num537 <= 1000)
                                        {
                                            num537++;
                                            int x170 = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.X / 16f);
                                            int y169 = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.Y / 16f);
                                            if (this.ai[0] == 0f)
                                            {
                                                x170 = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.X + Main.npc[NPC.plantBoss].Center.X) / 32f);
                                                y169 = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.Y + Main.npc[NPC.plantBoss].Center.Y) / 32f);
                                            }
                                            if (flag112)
                                            {
                                                x170 = (int)Main.npc[NPC.plantBoss].position.X / 16;
                                                y169 = (int)(Main.npc[NPC.plantBoss].position.Y + 400f) / 16;
                                            }
                                            int num538 = 20;
                                            num538 = num538 + (int)(100f * ((float)num537 / 1000f));
                                            int num539 = x170 + Main.rand.Next(-num538, num538 + 1);
                                            int num540 = y169 + Main.rand.Next(-num538, num538 + 1);
                                            if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2 && Main.rand.Next(6) == 0)
                                            {
                                                this.TargetClosest(true);
                                                int x171 = (int)(Main.player[this.target].Center.X / 16f);
                                                int y170 = (int)(Main.player[this.target].Center.Y / 16f);
                                                if (Main.tile[x171, y170].wall > 0)
                                                {
                                                    num539 = x171;
                                                    num540 = y170;
                                                }
                                            }
                                            try
                                            {
                                                if (WorldGen.SolidTile(num539, num540) || Main.tile[num539, num540].wall > 0 && (num537 > 500 || Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2))
                                                {
                                                    flag113 = true;
                                                    this.ai[0] = (float)num539;
                                                    this.ai[1] = (float)num540;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            catch (Exception ex)
                                            {
            #if DEBUG
                                                Console.WriteLine(ex);
                                                System.Diagnostics.Debugger.Break();

            #endif
                                            }
                                        }
                                    }
                                }
                                if (this.ai[0] > 0f && this.ai[1] > 0f)
                                {
                                    float single372 = 6f;
                                    if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2)
                                    {
                                        single372 = 8f;
                                    }
                                    if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 4)
                                    {
                                        single372 = 10f;
                                    }
                                    if (Main.expertMode)
                                    {
                                        single372 = single372 + 1f;
                                    }
                                    if (Main.expertMode && Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2)
                                    {
                                        single372 = single372 + 1f;
                                    }
                                    if (flag111)
                                    {
                                        single372 = single372 * 2f;
                                    }
                                    if (flag112)
                                    {
                                        single372 = single372 * 2f;
                                    }
                                    Vector2 vector2173 = new Vector2(base.Center.X, base.Center.Y);
                                    float x172 = this.ai[0] * 16f - 8f - vector2173.X;
                                    float y171 = this.ai[1] * 16f - 8f - vector2173.Y;
                                    float single373 = (float)Math.Sqrt((double)(x172 * x172 + y171 * y171));
                                    if (single373 >= 12f + single372)
                                    {
                                        single373 = single372 / single373;
                                        this.velocity.X = x172 * single373;
                                        this.velocity.Y = y171 * single373;
                                    }
                                    else
                                    {
                                        this.velocity.X = x172;
                                        this.velocity.Y = y171;
                                    }
                                    Vector2 vector2174 = new Vector2(base.Center.X, base.Center.Y);
                                    float x173 = Main.npc[NPC.plantBoss].Center.X - vector2174.X;
                                    float y172 = Main.npc[NPC.plantBoss].Center.Y - vector2174.Y;
                                    this.rotation = (float)Math.Atan2((double)y172, (double)x173) - 1.57f;
                                    return;
                                }
                            }
                            else if (this.aiStyle == 53)
                            {
                                if (NPC.plantBoss < 0)
                                {
                                    this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                                    this.netUpdate = true;
                                    return;
                                }
                                int num541 = NPC.plantBoss;
                                if (this.ai[3] > 0f)
                                {
                                    num541 = (int)this.ai[3] - 1;
                                }
                                if (Main.netMode != 1)
                                {
                                    this.localAI[0] = this.localAI[0] - 1f;
                                    if (this.localAI[0] <= 0f)
                                    {
                                        this.localAI[0] = (float)Main.rand.Next(120, 480);
                                        this.ai[0] = (float)Main.rand.Next(-100, 101);
                                        this.ai[1] = (float)Main.rand.Next(-100, 101);
                                        this.netUpdate = true;
                                    }
                                }
                                this.TargetClosest(true);
                                float single374 = 0.2f;
                                float single375 = 200f;
                                if ((double)Main.npc[NPC.plantBoss].life < (double)Main.npc[NPC.plantBoss].lifeMax * 0.25)
                                {
                                    single375 = single375 + 100f;
                                }
                                if ((double)Main.npc[NPC.plantBoss].life < (double)Main.npc[NPC.plantBoss].lifeMax * 0.1)
                                {
                                    single375 = single375 + 100f;
                                }
                                if (Main.expertMode)
                                {
                                    float single376 = 1f - (float)this.life / (float)this.lifeMax;
                                    single375 = single375 + single376 * 300f;
                                    single374 = single374 + 0.3f;
                                }
                                if (!Main.npc[num541].active || NPC.plantBoss < 0)
                                {
                                    this.active = false;
                                    return;
                                }
                                float x174 = Main.npc[num541].position.X + (float)(Main.npc[num541].width / 2);
                                float y173 = Main.npc[num541].position.Y + (float)(Main.npc[num541].height / 2);
                                Vector2 vector2175 = new Vector2(x174, y173);
                                float single377 = x174 + this.ai[0];
                                float single378 = y173 + this.ai[1];
                                float x175 = single377 - vector2175.X;
                                float y174 = single378 - vector2175.Y;
                                float single379 = (float)Math.Sqrt((double)(x175 * x175 + y174 * y174));
                                single379 = single375 / single379;
                                x175 = x175 * single379;
                                y174 = y174 * single379;
                                if (this.position.X < x174 + x175)
                                {
                                    this.velocity.X = this.velocity.X + single374;
                                    if (this.velocity.X < 0f && x175 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.9f;
                                    }
                                }
                                else if (this.position.X > x174 + x175)
                                {
                                    this.velocity.X = this.velocity.X - single374;
                                    if (this.velocity.X > 0f && x175 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.9f;
                                    }
                                }
                                if (this.position.Y < y173 + y174)
                                {
                                    this.velocity.Y = this.velocity.Y + single374;
                                    if (this.velocity.Y < 0f && y174 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                    }
                                }
                                else if (this.position.Y > y173 + y174)
                                {
                                    this.velocity.Y = this.velocity.Y - single374;
                                    if (this.velocity.Y > 0f && y174 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                    }
                                }
                                if (this.velocity.X > 8f)
                                {
                                    this.velocity.X = 8f;
                                }
                                if (this.velocity.X < -8f)
                                {
                                    this.velocity.X = -8f;
                                }
                                if (this.velocity.Y > 8f)
                                {
                                    this.velocity.Y = 8f;
                                }
                                if (this.velocity.Y < -8f)
                                {
                                    this.velocity.Y = -8f;
                                }
                                if (x175 > 0f)
                                {
                                    this.spriteDirection = 1;
                                    this.rotation = (float)Math.Atan2((double)y174, (double)x175);
                                }
                                if (x175 < 0f)
                                {
                                    this.spriteDirection = -1;
                                    this.rotation = (float)Math.Atan2((double)y174, (double)x175) + 3.14f;
                                    return;
                                }
                            }
                            else if (this.aiStyle == 54)
                            {
                                NPC.crimsonBoss = this.whoAmI;
                                if (Main.netMode != 1 && this.localAI[0] == 0f)
                                {
                                    this.localAI[0] = 1f;
                                    for (int v4 = 0; v4 < 20; v4++)
                                    {
                                        float x176 = base.Center.X;
                                        float y175 = base.Center.Y;
                                        x176 = x176 + (float)Main.rand.Next(-this.width, this.width);
                                        y175 = y175 + (float)Main.rand.Next(-this.height, this.height);
                                        int num542 = NPC.NewNPC((int)x176, (int)y175, 267, 0, 0f, 0f, 0f, 0f, 255);
                                        Main.npc[num542].velocity = new Vector2((float)Main.rand.Next(-30, 31) * 0.1f, (float)Main.rand.Next(-30, 31) * 0.1f);
                                        Main.npc[num542].netUpdate = true;
                                    }
                                }
                                if (Main.netMode != 1)
                                {
                                    this.TargetClosest(true);
                                    if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)6000)
                                    {
                                        this.active = false;
                                        this.life = 0;
                                        if (Main.netMode == 2)
                                        {
                                            NetMessage.SendData(23, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                        }
                                    }
                                }
                                if (this.ai[0] >= 0f)
                                {
                                    this.TargetClosest(true);
                                    Vector2 vector2176 = new Vector2(base.Center.X, base.Center.Y);
                                    float x177 = Main.player[this.target].Center.X - vector2176.X;
                                    float y176 = Main.player[this.target].Center.Y - vector2176.Y;
                                    float single380 = (float)Math.Sqrt((double)(x177 * x177 + y176 * y176));
                                    float single381 = 1f;
                                    if (single380 >= single381)
                                    {
                                        single380 = single381 / single380;
                                        this.velocity.X = x177 * single380;
                                        this.velocity.Y = y176 * single380;
                                    }
                                    else
                                    {
                                        this.velocity.X = x177;
                                        this.velocity.Y = y176;
                                    }
                                    if (this.ai[0] == 0f)
                                    {
                                        if (Main.netMode != 1)
                                        {
                                            int num543 = 0;
                                            for (int w4 = 0; w4 < 200; w4++)
                                            {
                                                if (Main.npc[w4].active && Main.npc[w4].type == 267)
                                                {
                                                    num543++;
                                                }
                                            }
                                            if (num543 == 0)
                                            {
                                                this.ai[0] = -1f;
                                                this.localAI[1] = 0f;
                                                this.alpha = 0;
                                                this.netUpdate = true;
                                            }
                                            this.localAI[1] = this.localAI[1] + 1f;
                                            if (this.localAI[1] >= (float)(120 + Main.rand.Next(300)))
                                            {
                                                this.localAI[1] = 0f;
                                                this.TargetClosest(true);
                                                int num544 = 0;
                                                do
                                                {
                                                    num544++;
                                                    int x178 = (int)Main.player[this.target].Center.X / 16;
                                                    int y177 = (int)Main.player[this.target].Center.Y / 16;
                                                    x178 = x178 + Main.rand.Next(-50, 51);
                                                    y177 = y177 + Main.rand.Next(-50, 51);
                                                    if (WorldGen.SolidTile(x178, y177) || !Collision.CanHit(new Vector2((float)(x178 * 16), (float)(y177 * 16)), 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                                    {
                                                        continue;
                                                    }
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = (float)x178;
                                                    this.ai[2] = (float)y177;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                                while (num544 <= 100);
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.ai[0] == 1f)
                                    {
                                        NPC nPC160 = this;
                                        nPC160.alpha = nPC160.alpha + 5;
                                        if (this.alpha >= 255)
                                        {
                                            this.alpha = 255;
                                            this.position.X = this.ai[1] * 16f - (float)(this.width / 2);
                                            this.position.Y = this.ai[2] * 16f - (float)(this.height / 2);
                                            this.ai[0] = 2f;
                                            return;
                                        }
                                    }
                                    else if (this.ai[0] == 2f)
                                    {
                                        NPC nPC161 = this;
                                        nPC161.alpha = nPC161.alpha - 5;
                                        if (this.alpha <= 0)
                                        {
                                            this.alpha = 0;
                                            this.ai[0] = 0f;
                                            return;
                                        }
                                    }
                                }
                                else
                                {
                                    if (this.localAI[2] == 0f)
                                    {
                                        this.localAI[2] = 1f;
                                    }
                                    this.dontTakeDamage = false;
                                    this.knockBackResist = 0.5f;
                                    if (Main.expertMode)
                                    {
                                        NPC nPC162 = this;
                                        nPC162.knockBackResist = nPC162.knockBackResist * Main.expertKnockBack;
                                    }
                                    this.TargetClosest(true);
                                    Vector2 vector2178 = new Vector2(base.Center.X, base.Center.Y);
                                    float x179 = Main.player[this.target].Center.X - vector2178.X;
                                    float y178 = Main.player[this.target].Center.Y - vector2178.Y;
                                    float single382 = (float)Math.Sqrt((double)(x179 * x179 + y178 * y178));
                                    single382 = 8f / single382;
                                    x179 = x179 * single382;
                                    y178 = y178 * single382;
                                    this.velocity.X = (this.velocity.X * 50f + x179) / 51f;
                                    this.velocity.Y = (this.velocity.Y * 50f + y178) / 51f;
                                    if (this.ai[0] != -1f)
                                    {
                                        if (this.ai[0] == -2f)
                                        {
                                            NPC nPC163 = this;
                                            nPC163.velocity = nPC163.velocity * 0.9f;
                                            if (Main.netMode == 0)
                                            {
                                                this.ai[3] = this.ai[3] + 25f;
                                            }
                                            else
                                            {
                                                this.ai[3] = this.ai[3] + 15f;
                                            }
                                            if (this.ai[3] >= 255f)
                                            {
                                                this.ai[3] = 255f;
                                                this.position.X = this.ai[1] * 16f - (float)(this.width / 2);
                                                this.position.Y = this.ai[2] * 16f - (float)(this.height / 2);
                                                this.ai[0] = -3f;
                                                this.netUpdate = true;
                                                this.netSpam = 0;
                                            }
                                            this.alpha = (int)this.ai[3];
                                            return;
                                        }
                                        if (this.ai[0] == -3f)
                                        {
                                            if (Main.netMode == 0)
                                            {
                                                this.ai[3] = this.ai[3] - 25f;
                                            }
                                            else
                                            {
                                                this.ai[3] = this.ai[3] - 15f;
                                            }
                                            if (this.ai[3] <= 0f)
                                            {
                                                this.ai[3] = 0f;
                                                this.ai[0] = -1f;
                                                this.netUpdate = true;
                                                this.netSpam = 0;
                                            }
                                            this.alpha = (int)this.ai[3];
                                            return;
                                        }
                                    }
                                    else if (Main.netMode != 1)
                                    {
                                        this.localAI[1] = this.localAI[1] + 1f;
                                        if (this.justHit)
                                        {
                                            this.localAI[1] = this.localAI[1] - (float)Main.rand.Next(5);
                                        }
                                        int num547 = 60 + Main.rand.Next(120);
                                        if (Main.netMode != 0)
                                        {
                                            num547 = num547 + Main.rand.Next(30, 90);
                                        }
                                        if (this.localAI[1] >= (float)num547)
                                        {
                                            this.localAI[1] = 0f;
                                            this.TargetClosest(true);
                                            int num548 = 0;
                                            do
                                            {
                                                num548++;
                                                int x180 = (int)Main.player[this.target].Center.X / 16;
                                                int y179 = (int)Main.player[this.target].Center.Y / 16;
                                                x180 = (Main.rand.Next(2) != 0 ? x180 - Main.rand.Next(7, 13) : x180 + Main.rand.Next(7, 13));
                                                y179 = (Main.rand.Next(2) != 0 ? y179 - Main.rand.Next(7, 13) : y179 + Main.rand.Next(7, 13));
                                                if (WorldGen.SolidTile(x180, y179))
                                                {
                                                    continue;
                                                }
                                                this.ai[3] = 0f;
                                                this.ai[0] = -2f;
                                                this.ai[1] = (float)x180;
                                                this.ai[2] = (float)y179;
                                                this.netUpdate = true;
                                                this.netSpam = 0;
                                                return;
                                            }
                                            while (num548 <= 100);
                                            return;
                                        }
                                    }
                                }
                            }
                            else if (this.aiStyle != 55)
                            {
                                if (this.aiStyle == 56)
                                {
                                    this.TargetClosest(true);
                                    Vector2 vector2179 = new Vector2(base.Center.X, base.Center.Y);
                                    float x181 = Main.player[this.target].Center.X - vector2179.X;
                                    float y180 = Main.player[this.target].Center.Y - vector2179.Y;
                                    float single383 = (float)Math.Sqrt((double)(x181 * x181 + y180 * y180));
                                    single383 = 12f / single383;
                                    x181 = x181 * single383;
                                    y180 = y180 * single383;
                                    this.velocity.X = (this.velocity.X * 100f + x181) / 101f;
                                    this.velocity.Y = (this.velocity.Y * 100f + y180) / 101f;
                                    this.rotation = (float)Math.Atan2((double)y180, (double)x181) - 1.57f;
                                    return;
                                }
                                if (this.aiStyle != 57)
                                {
                                    if (this.aiStyle == 58)
                                    {
                                        this.localAI[0] = this.localAI[0] + 1f;
                                        if (this.localAI[0] > 6f)
                                        {
                                            this.localAI[0] = 0f;
                                            this.localAI[1] = this.localAI[1] + 1f;
                                            if (this.localAI[1] > 4f)
                                            {
                                                this.localAI[1] = 0f;
                                            }
                                        }
                                        if (Main.netMode != 1)
                                        {
                                            this.localAI[2] = this.localAI[2] + 1f;
                                            if (this.localAI[2] > 300f)
                                            {
                                                this.ai[3] = (float)Main.rand.Next(3);
                                                this.localAI[2] = 0f;
                                            }
                                            else if (this.ai[3] == 0f && this.localAI[2] % 30f == 0f && this.localAI[2] > 30f)
                                            {
                                                float single384 = 5f;
                                                Vector2 vector2181 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                                if (!WorldGen.SolidTile((int)vector2181.X / 16, (int)vector2181.Y / 16))
                                                {
                                                    float x182 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2181.X;
                                                    float y181 = Main.player[this.target].position.Y - vector2181.Y;
                                                    x182 = x182 + (float)Main.rand.Next(-50, 51);
                                                    y181 = y181 + (float)Main.rand.Next(50, 201);
                                                    y181 = y181 * 0.2f;
                                                    float single385 = (float)Math.Sqrt((double)(x182 * x182 + y181 * y181));
                                                    single385 = single384 / single385;
                                                    x182 = x182 * single385;
                                                    y181 = y181 * single385;
                                                    x182 = x182 * (1f + (float)Main.rand.Next(-30, 31) * 0.01f);
                                                    y181 = y181 * (1f + (float)Main.rand.Next(-30, 31) * 0.01f);
                                                    Projectile.NewProjectile(vector2181.X, vector2181.Y, x182, y181, Main.rand.Next(326, 329), 40, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                            }
                                        }
                                        if (this.ai[0] == 0f && Main.netMode != 1)
                                        {
                                            this.TargetClosest(true);
                                            this.ai[0] = 1f;
                                            int num552 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 328, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                            Main.npc[num552].ai[0] = -1f;
                                            Main.npc[num552].ai[1] = (float)this.whoAmI;
                                            Main.npc[num552].target = this.target;
                                            Main.npc[num552].netUpdate = true;
                                            num552 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 328, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                            Main.npc[num552].ai[0] = 1f;
                                            Main.npc[num552].ai[1] = (float)this.whoAmI;
                                            Main.npc[num552].ai[3] = 150f;
                                            Main.npc[num552].target = this.target;
                                            Main.npc[num552].netUpdate = true;
                                        }
                                        if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                                        {
                                            this.TargetClosest(true);
                                            if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                                            {
                                                this.ai[1] = 2f;
                                            }
                                        }
                                        if (Main.dayTime)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.3f;
                                            this.velocity.X = this.velocity.X * 0.9f;
                                        }
                                        else if (this.ai[1] == 0f)
                                        {
                                            this.ai[2] = this.ai[2] + 1f;
                                            if (this.ai[2] >= 300f)
                                            {
                                                if (this.ai[3] == 1f)
                                                {
                                                    this.ai[2] = 0f;
                                                    this.ai[1] = 1f;
                                                    this.TargetClosest(true);
                                                    this.netUpdate = true;
                                                }
                                                else
                                                {
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                            }
                                            Vector2 vector2182 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float x183 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2182.X;
                                            float y182 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 200f - vector2182.Y;
                                            float single386 = (float)Math.Sqrt((double)(x183 * x183 + y182 * y182));
                                            float single387 = 6f;
                                            if (this.ai[3] == 1f)
                                            {
                                                if (single386 > 900f)
                                                {
                                                    single387 = 12f;
                                                }
                                                else if (single386 > 600f)
                                                {
                                                    single387 = 10f;
                                                }
                                                else if (single386 > 300f)
                                                {
                                                    single387 = 8f;
                                                }
                                            }
                                            if (single386 > 50f)
                                            {
                                                single386 = single387 / single386;
                                                this.velocity.X = (this.velocity.X * 14f + x183 * single386) / 15f;
                                                this.velocity.Y = (this.velocity.Y * 14f + y182 * single386) / 15f;
                                            }
                                        }
                                        else if (this.ai[1] == 1f)
                                        {
                                            this.ai[2] = this.ai[2] + 1f;
                                            if (this.ai[2] >= 600f || this.ai[3] != 1f)
                                            {
                                                this.ai[2] = 0f;
                                                this.ai[1] = 0f;
                                            }
                                            Vector2 vector2183 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float x184 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2183.X;
                                            float y183 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2183.Y;
                                            float single388 = (float)Math.Sqrt((double)(x184 * x184 + y183 * y183));
                                            single388 = 16f / single388;
                                            this.velocity.X = (this.velocity.X * 49f + x184 * single388) / 50f;
                                            this.velocity.Y = (this.velocity.Y * 49f + y183 * single388) / 50f;
                                        }
                                        else if (this.ai[1] == 2f)
                                        {
                                            this.ai[1] = 3f;
                                            this.velocity.Y = this.velocity.Y + 0.1f;
                                            if (this.velocity.Y < 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y * 0.95f;
                                            }
                                            this.velocity.X = this.velocity.X * 0.95f;
                                            if (this.timeLeft > 500)
                                            {
                                                this.timeLeft = 500;
                                            }
                                        }
                                        this.rotation = this.velocity.X * -0.02f;
                                        return;
                                    }
                                    if (this.aiStyle == 59)
                                    {
                                        this.spriteDirection = -(int)this.ai[0];
                                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 58)
                                        {
                                            this.ai[2] = this.ai[2] + 10f;
                                            if (this.ai[2] > 50f || Main.netMode != 2)
                                            {
                                                this.life = -1;
                                                this.HitEffect(0, 10);
                                                this.active = false;
                                            }
                                        }
                                        if (Main.netMode != 1 && Main.npc[(int)this.ai[1]].ai[3] == 2f)
                                        {
                                            this.localAI[1] = this.localAI[1] + 1f;
                                            if (this.localAI[1] > 90f)
                                            {
                                                this.localAI[1] = 0f;
                                                float single389 = 0.01f;
                                                Vector2 vector2184 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                                float x185 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2184.X;
                                                float y184 = Main.player[this.target].position.Y - vector2184.Y;
                                                float single390 = (float)Math.Sqrt((double)(x185 * x185 + y184 * y184));
                                                single390 = single389 / single390;
                                                x185 = x185 * single390;
                                                y184 = y184 * single390;
                                                Projectile.NewProjectile(base.Center.X, base.Center.Y, x185, y184, 329, 60, 0f, Main.myPlayer, this.rotation, (float)this.spriteDirection);
                                            }
                                        }
                                        if (Main.dayTime)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.3f;
                                            this.velocity.X = this.velocity.X * 0.9f;
                                            return;
                                        }
                                        if (this.ai[2] == 0f || this.ai[2] == 3f)
                                        {
                                            if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                                            {
                                                this.timeLeft = 10;
                                            }
                                            this.ai[3] = this.ai[3] + 1f;
                                            if (this.ai[3] >= 180f)
                                            {
                                                this.ai[2] = this.ai[2] + 1f;
                                                this.ai[3] = 0f;
                                                this.netUpdate = true;
                                            }
                                            Vector2 vector2185 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float x186 = (Main.player[this.target].Center.X + Main.npc[(int)this.ai[1]].Center.X) / 2f;
                                            float y185 = (Main.player[this.target].Center.Y + Main.npc[(int)this.ai[1]].Center.Y) / 2f;
                                            x186 = x186 + (-170f * this.ai[0] - vector2185.X);
                                            y185 = y185 + (90f - vector2185.Y);
                                            if (Math.Abs(Main.player[this.target].Center.X - Main.npc[(int)this.ai[1]].Center.X) + Math.Abs(Main.player[this.target].Center.Y - Main.npc[(int)this.ai[1]].Center.Y) > 700f)
                                            {
                                                x186 = Main.npc[(int)this.ai[1]].Center.X - 170f * this.ai[0] - vector2185.X;
                                                y185 = Main.npc[(int)this.ai[1]].Center.Y + 90f - vector2185.Y;
                                            }
                                            float single391 = (float)Math.Sqrt((double)(x186 * x186 + y185 * y185));
                                            float single392 = 6f;
                                            if (single391 > 1000f)
                                            {
                                                single392 = 21f;
                                            }
                                            else if (single391 > 800f)
                                            {
                                                single392 = 18f;
                                            }
                                            else if (single391 > 600f)
                                            {
                                                single392 = 15f;
                                            }
                                            else if (single391 > 400f)
                                            {
                                                single392 = 12f;
                                            }
                                            else if (single391 > 200f)
                                            {
                                                single392 = 9f;
                                            }
                                            if (this.ai[0] < 0f && base.Center.X > Main.npc[(int)this.ai[1]].Center.X)
                                            {
                                                x186 = x186 - 4f;
                                            }
                                            if (this.ai[0] > 0f && base.Center.X < Main.npc[(int)this.ai[1]].Center.X)
                                            {
                                                x186 = x186 + 4f;
                                            }
                                            single391 = single392 / single391;
                                            this.velocity.X = (this.velocity.X * 14f + x186 * single391) / 15f;
                                            this.velocity.Y = (this.velocity.Y * 14f + y185 * single391) / 15f;
                                            single391 = (float)Math.Sqrt((double)(x186 * x186 + y185 * y185));
                                            if (single391 > 20f)
                                            {
                                                this.rotation = (float)Math.Atan2((double)y185, (double)x186) + 1.57f;
                                                return;
                                            }
                                        }
                                        else if (this.ai[2] == 1f)
                                        {
                                            Vector2 vector2186 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float x187 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2186.X;
                                            float y186 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2186.Y;
                                            float single393 = (float)Math.Sqrt((double)(x187 * x187 + y186 * y186));
                                            this.rotation = (float)Math.Atan2((double)y186, (double)x187) + 1.57f;
                                            this.velocity.X = this.velocity.X * 0.95f;
                                            this.velocity.Y = this.velocity.Y - 0.3f;
                                            if (this.velocity.Y < -14f)
                                            {
                                                this.velocity.Y = -14f;
                                            }
                                            if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 200f)
                                            {
                                                this.TargetClosest(true);
                                                this.ai[2] = 2f;
                                                vector2186 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                x187 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2186.X;
                                                y186 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2186.Y;
                                                single393 = (float)Math.Sqrt((double)(x187 * x187 + y186 * y186));
                                                single393 = 18f / single393;
                                                this.velocity.X = x187 * single393;
                                                this.velocity.Y = y186 * single393;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[2] == 2f)
                                        {
                                            float single394 = Math.Abs(base.Center.X - Main.npc[(int)this.ai[1]].Center.X) + Math.Abs(base.Center.Y - Main.npc[(int)this.ai[1]].Center.Y);
                                            if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f || single394 > 800f)
                                            {
                                                this.ai[2] = 3f;
                                                return;
                                            }
                                        }
                                        else if (this.ai[2] == 4f)
                                        {
                                            Vector2 vector2187 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            float x188 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector2187.X;
                                            float y187 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector2187.Y;
                                            float single395 = (float)Math.Sqrt((double)(x188 * x188 + y187 * y187));
                                            this.rotation = (float)Math.Atan2((double)y187, (double)x188) + 1.57f;
                                            this.velocity.Y = this.velocity.Y * 0.95f;
                                            this.velocity.X = this.velocity.X + 0.3f * -this.ai[0];
                                            if (this.velocity.X < -14f)
                                            {
                                                this.velocity.X = -14f;
                                            }
                                            if (this.velocity.X > 14f)
                                            {
                                                this.velocity.X = 14f;
                                            }
                                            if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 500f || this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 500f)
                                            {
                                                this.TargetClosest(true);
                                                this.ai[2] = 5f;
                                                vector2187 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                                x188 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2187.X;
                                                y187 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector2187.Y;
                                                single395 = (float)Math.Sqrt((double)(x188 * x188 + y187 * y187));
                                                single395 = 17f / single395;
                                                this.velocity.X = x188 * single395;
                                                this.velocity.Y = y187 * single395;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[2] == 5f)
                                        {
                                            float single396 = Math.Abs(base.Center.X - Main.npc[(int)this.ai[1]].Center.X) + Math.Abs(base.Center.Y - Main.npc[(int)this.ai[1]].Center.Y);
                                            if (this.velocity.X > 0f && this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) || this.velocity.X < 0f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) || single396 > 800f)
                                            {
                                                this.ai[2] = 0f;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 60)
                                    {
                                        if (Main.dayTime)
                                        {
                                            if (this.velocity.X <= 0f)
                                            {
                                                this.velocity.X = this.velocity.X - 0.25f;
                                            }
                                            else
                                            {
                                                this.velocity.X = this.velocity.X + 0.25f;
                                            }
                                            this.velocity.Y = this.velocity.Y - 0.1f;
                                            this.rotation = this.velocity.X * 0.05f;
                                        }
                                        else if (this.ai[0] == 0f)
                                        {
                                            if (this.ai[2] == 0f)
                                            {
                                                this.TargetClosest(true);
                                                if (base.Center.X >= Main.player[this.target].Center.X)
                                                {
                                                    this.ai[2] = -1f;
                                                }
                                                else
                                                {
                                                    this.ai[2] = 1f;
                                                }
                                            }
                                            this.TargetClosest(true);
                                            int num553 = 800;
                                            float single397 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                            if (base.Center.X < Main.player[this.target].Center.X && this.ai[2] < 0f && single397 > (float)num553)
                                            {
                                                this.ai[2] = 0f;
                                            }
                                            if (base.Center.X > Main.player[this.target].Center.X && this.ai[2] > 0f && single397 > (float)num553)
                                            {
                                                this.ai[2] = 0f;
                                            }
                                            float single398 = 0.45f;
                                            float single399 = 7f;
                                            if ((double)this.life < (double)this.lifeMax * 0.75)
                                            {
                                                single398 = 0.55f;
                                                single399 = 8f;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.5)
                                            {
                                                single398 = 0.7f;
                                                single399 = 10f;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.25)
                                            {
                                                single398 = 0.8f;
                                                single399 = 11f;
                                            }
                                            this.velocity.X = this.velocity.X + this.ai[2] * single398;
                                            if (this.velocity.X > single399)
                                            {
                                                this.velocity.X = single399;
                                            }
                                            if (this.velocity.X < -single399)
                                            {
                                                this.velocity.X = -single399;
                                            }
                                            float y188 = Main.player[this.target].position.Y - (this.position.Y + (float)this.height);
                                            if (y188 < 150f)
                                            {
                                                this.velocity.Y = this.velocity.Y - 0.2f;
                                            }
                                            if (y188 > 200f)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.2f;
                                            }
                                            if (this.velocity.Y > 8f)
                                            {
                                                this.velocity.Y = 8f;
                                            }
                                            if (this.velocity.Y < -8f)
                                            {
                                                this.velocity.Y = -8f;
                                            }
                                            this.rotation = this.velocity.X * 0.05f;
                                            if ((single397 < 500f || this.ai[3] < 0f) && this.position.Y < Main.player[this.target].position.Y)
                                            {
                                                this.ai[3] = this.ai[3] + 1f;
                                                int num554 = 13;
                                                if ((double)this.life < (double)this.lifeMax * 0.75)
                                                {
                                                    num554 = 12;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.5)
                                                {
                                                    num554 = 11;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.25)
                                                {
                                                    num554 = 10;
                                                }
                                                num554++;
                                                if (this.ai[3] > (float)num554)
                                                {
                                                    this.ai[3] = (float)(-num554);
                                                }
                                                if (this.ai[3] == 0f && Main.netMode != 1)
                                                {
                                                    Vector2 vector2188 = new Vector2(base.Center.X, base.Center.Y);
                                                    float x189 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2188.X;
                                                    float y189 = Main.player[this.target].Center.Y - vector2188.Y;
                                                    float single400 = (float)Math.Sqrt((double)(x189 * x189 + y189 * y189));
                                                    float single401 = 6f;
                                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                                    {
                                                        single401 = 7f;
                                                    }
                                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                                    {
                                                        single401 = 8f;
                                                    }
                                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                                    {
                                                        single401 = 9f;
                                                    }
                                                    single400 = single401 / single400;
                                                    x189 = x189 * single400;
                                                    y189 = y189 * single400;
                                                    Projectile.NewProjectile(vector2188.X, vector2188.Y, x189, y189, 348, 42, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                            }
                                            else if (this.ai[3] < 0f)
                                            {
                                                this.ai[3] = this.ai[3] + 1f;
                                            }
                                            if (Main.netMode != 1)
                                            {
                                                this.ai[1] = this.ai[1] + (float)Main.rand.Next(1, 4);
                                                if (this.ai[1] > 800f && single397 < 600f)
                                                {
                                                    this.ai[0] = -1f;
                                                }
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            this.TargetClosest(true);
                                            float single402 = 0.15f;
                                            float single403 = 7f;
                                            if ((double)this.life < (double)this.lifeMax * 0.75)
                                            {
                                                single402 = 0.17f;
                                                single403 = 8f;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.5)
                                            {
                                                single402 = 0.2f;
                                                single403 = 9f;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.25)
                                            {
                                                single402 = 0.25f;
                                                single403 = 10f;
                                            }
                                            single402 = single402 - 0.05f;
                                            single403 = single403 - 1f;
                                            if (base.Center.X < Main.player[this.target].Center.X)
                                            {
                                                this.velocity.X = this.velocity.X + single402;
                                                if (this.velocity.X < 0f)
                                                {
                                                    this.velocity.X = this.velocity.X * 0.98f;
                                                }
                                            }
                                            if (base.Center.X > Main.player[this.target].Center.X)
                                            {
                                                this.velocity.X = this.velocity.X - single402;
                                                if (this.velocity.X > 0f)
                                                {
                                                    this.velocity.X = this.velocity.X * 0.98f;
                                                }
                                            }
                                            if (this.velocity.X > single403 || this.velocity.X < -single403)
                                            {
                                                this.velocity.X = this.velocity.X * 0.95f;
                                            }
                                            float y190 = Main.player[this.target].position.Y - (this.position.Y + (float)this.height);
                                            if (y190 < 180f)
                                            {
                                                this.velocity.Y = this.velocity.Y - 0.1f;
                                            }
                                            if (y190 > 200f)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.1f;
                                            }
                                            if (this.velocity.Y > 6f)
                                            {
                                                this.velocity.Y = 6f;
                                            }
                                            if (this.velocity.Y < -6f)
                                            {
                                                this.velocity.Y = -6f;
                                            }
                                            this.rotation = this.velocity.X * 0.01f;
                                            if (Main.netMode != 1)
                                            {
                                                this.ai[3] = this.ai[3] + 1f;
                                                int num555 = 15;
                                                if ((double)this.life < (double)this.lifeMax * 0.75)
                                                {
                                                    num555 = 14;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.5)
                                                {
                                                    num555 = 12;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.25)
                                                {
                                                    num555 = 10;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.1)
                                                {
                                                    num555 = 8;
                                                }
                                                num555 = num555 + 3;
                                                if (this.ai[3] >= (float)num555)
                                                {
                                                    this.ai[3] = 0f;
                                                    Vector2 vector2189 = new Vector2(base.Center.X, this.position.Y + (float)this.height - 14f);
                                                    if (!WorldGen.SolidTile((int)(vector2189.X / 16f), (int)(vector2189.Y / 16f)))
                                                    {
                                                        float y191 = this.velocity.Y;
                                                        if (y191 < 0f)
                                                        {
                                                            y191 = 0f;
                                                        }
                                                        y191 = y191 + 3f;
                                                        float x190 = this.velocity.X * 0.25f;
                                                        Projectile.NewProjectile(vector2189.X, vector2189.Y, x190, y191, 349, 37, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f);
                                                    }
                                                }
                                            }
                                            if (Main.netMode != 1)
                                            {
                                                this.ai[1] = this.ai[1] + (float)Main.rand.Next(1, 4);
                                                if (this.ai[1] > 600f)
                                                {
                                                    this.ai[0] = -1f;
                                                }
                                            }
                                        }
                                        else if (this.ai[0] == 2f)
                                        {
                                            this.TargetClosest(true);
                                            Vector2 vector2190 = new Vector2(base.Center.X, base.Center.Y - 20f);
                                            float single404 = (float)Main.rand.Next(-1000, 1001);
                                            float single405 = (float)Main.rand.Next(-1000, 1001);
                                            float single406 = (float)Math.Sqrt((double)(single404 * single404 + single405 * single405));
                                            float single407 = 15f;
                                            NPC nPC164 = this;
                                            nPC164.velocity = nPC164.velocity * 0.95f;
                                            single406 = single407 / single406;
                                            single404 = single404 * single406;
                                            single405 = single405 * single406;
                                            NPC nPC165 = this;
                                            nPC165.rotation = nPC165.rotation + 0.2f;
                                            vector2190.X = vector2190.X + single404 * 4f;
                                            vector2190.Y = vector2190.Y + single405 * 4f;
                                            this.ai[3] = this.ai[3] + 1f;
                                            int num556 = 7;
                                            if ((double)this.life < (double)this.lifeMax * 0.75)
                                            {
                                                num556--;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.5)
                                            {
                                                num556 = num556 - 2;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.25)
                                            {
                                                num556 = num556 - 3;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.1)
                                            {
                                                num556 = num556 - 4;
                                            }
                                            if (this.ai[3] > (float)num556)
                                            {
                                                this.ai[3] = 0f;
                                                Projectile.NewProjectile(vector2190.X, vector2190.Y, single404, single405, 349, 35, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (Main.netMode != 1)
                                            {
                                                this.ai[1] = this.ai[1] + (float)Main.rand.Next(1, 4);
                                                if (this.ai[1] > 500f)
                                                {
                                                    this.ai[0] = -1f;
                                                }
                                            }
                                        }
                                        if (this.ai[0] == -1f)
                                        {
                                            int num557 = Main.rand.Next(3);
                                            this.TargetClosest(true);
                                            if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 1000f)
                                            {
                                                num557 = 0;
                                            }
                                            this.ai[0] = (float)num557;
                                            this.ai[1] = 0f;
                                            this.ai[2] = 0f;
                                            this.ai[3] = 0f;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 61)
                                    {
                                        float single408 = 2f;
                                        this.noGravity = true;
                                        this.noTileCollide = true;
                                        if (!Main.dayTime)
                                        {
                                            this.TargetClosest(true);
                                        }
                                        bool flag114 = false;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            single408 = 3f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            single408 = 4f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            single408 = 5f;
                                        }
                                        if (Main.dayTime)
                                        {
                                            if (this.timeLeft > 10)
                                            {
                                                this.timeLeft = 10;
                                            }
                                            single408 = 8f;
                                            if (this.velocity.X == 0f)
                                            {
                                                this.velocity.X = 0.1f;
                                            }
                                        }
                                        else if (this.ai[0] == 0f)
                                        {
                                            this.ai[1] = this.ai[1] + 1f;
                                            if (this.ai[1] >= 300f && Main.netMode != 1)
                                            {
                                                this.TargetClosest(true);
                                                this.ai[1] = 0f;
                                                this.ai[0] = 1f;
                                                this.netUpdate = true;
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            this.ai[1] = this.ai[1] + 1f;
                                            flag114 = true;
                                            int num558 = 16;
                                            if ((double)this.life < (double)this.lifeMax * 0.25)
                                            {
                                                num558 = 8;
                                            }
                                            else if ((double)this.life < (double)this.lifeMax * 0.5)
                                            {
                                                num558 = 11;
                                            }
                                            else if ((double)this.life < (double)this.lifeMax * 0.75)
                                            {
                                                num558 = 14;
                                            }
                                            if (this.ai[1] % (float)num558 == 0f)
                                            {
                                                Vector2 vector2191 = new Vector2(base.Center.X + (float)(this.direction * 50), base.Center.Y + (float)Main.rand.Next(15, 36));
                                                float x191 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2191.X;
                                                float y192 = Main.player[this.target].Center.Y - vector2191.Y;
                                                x191 = x191 + (float)Main.rand.Next(-40, 41);
                                                y192 = y192 + (float)Main.rand.Next(-40, 41);
                                                float single409 = (float)Math.Sqrt((double)(x191 * x191 + y192 * y192));
                                                single409 = 15f / single409;
                                                x191 = x191 * single409;
                                                y192 = y192 * single409;
                                                x191 = x191 * (1f + (float)Main.rand.Next(-20, 21) * 0.015f);
                                                y192 = y192 * (1f + (float)Main.rand.Next(-20, 21) * 0.015f);
                                                Projectile.NewProjectile(vector2191.X, vector2191.Y, x191, y192, 180, 36, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (this.ai[1] > 240f)
                                            {
                                                this.ai[0] = 0f;
                                                this.ai[1] = 0f;
                                            }
                                        }
                                        if (Main.netMode != 1)
                                        {
                                            int num559 = 600;
                                            int num560 = 1200;
                                            int num561 = 2700;
                                            if ((double)this.life < (double)this.lifeMax * 0.25)
                                            {
                                                num559 = (int)((double)num559 * 0.5);
                                                num560 = (int)((double)num560 * 0.5);
                                                num561 = (int)((double)num561 * 0.5);
                                            }
                                            else if ((double)this.life < (double)this.lifeMax * 0.5)
                                            {
                                                num559 = (int)((double)num559 * 0.75);
                                                num560 = (int)((double)num560 * 0.75);
                                                num561 = (int)((double)num561 * 0.75);
                                            }
                                            else if ((double)this.life < (double)this.lifeMax * 0.75)
                                            {
                                                num559 = (int)((double)num559 * 0.9);
                                                num560 = (int)((double)num560 * 0.9);
                                                num561 = (int)((double)num561 * 0.9);
                                            }
                                            if (Main.rand.Next(num559) == 0)
                                            {
                                                Vector2 vector2192 = new Vector2(base.Center.X - (float)(this.direction * 24), base.Center.Y - 64f);
                                                float single410 = (float)(Main.rand.Next(1, 100) * this.direction);
                                                float single411 = 1f;
                                                float single412 = (float)Math.Sqrt((double)(single410 * single410 + single411 * single411));
                                                single412 = 1f / single412;
                                                single410 = single410 * single412;
                                                single411 = single411 * single412;
                                                Projectile.NewProjectile(vector2192.X, vector2192.Y, single410, single411, 352, 80, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (Main.rand.Next(num560) == 0)
                                            {
                                                this.localAI[1] = 1f;
                                            }
                                            if (this.localAI[1] >= 1f)
                                            {
                                                this.localAI[1] = this.localAI[1] + 1f;
                                                if (this.localAI[1] % (float)12 == 0f)
                                                {
                                                    Vector2 vector2193 = new Vector2(base.Center.X - (float)(this.direction * 24), base.Center.Y - 64f);
                                                    float x192 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2193.X;
                                                    float y193 = Main.player[this.target].Center.Y - vector2193.Y;
                                                    x192 = x192 + (float)Main.rand.Next(-50, 51);
                                                    y193 = y193 + (float)Main.rand.Next(-50, 51);
                                                    float single413 = (float)Math.Sqrt((double)(x192 * x192 + y193 * y193));
                                                    single413 = 12.5f / single413;
                                                    x192 = x192 * single413;
                                                    y193 = y193 * single413;
                                                    x192 = x192 * (1f + (float)Main.rand.Next(-20, 21) * 0.015f);
                                                    y193 = y193 * (1f + (float)Main.rand.Next(-20, 21) * 0.015f);
                                                    Projectile.NewProjectile(vector2193.X, vector2193.Y, x192, y193, 350, 42, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                                if (this.localAI[1] >= 100f)
                                                {
                                                    this.localAI[1] = 0f;
                                                }
                                            }
                                            if (Main.rand.Next(num561) == 0)
                                            {
                                                this.localAI[2] = 2f;
                                            }
                                            if (this.localAI[2] > 0f)
                                            {
                                                this.localAI[2] = this.localAI[2] + 1f;
                                                if (this.localAI[2] % (float)9 == 0f)
                                                {
                                                    Vector2 vector2194 = new Vector2(base.Center.X - (float)(this.direction * 24), base.Center.Y - 64f);
                                                    float single414 = (float)Main.rand.Next(-100, 101);
                                                    float single415 = -300f;
                                                    float single416 = (float)Math.Sqrt((double)(single414 * single414 + single415 * single415));
                                                    single416 = 11f / single416;
                                                    single414 = single414 * single416;
                                                    single415 = single415 * single416;
                                                    single414 = single414 * (1f + (float)Main.rand.Next(-20, 21) * 0.01f);
                                                    single415 = single415 * (1f + (float)Main.rand.Next(-20, 21) * 0.01f);
                                                    Projectile.NewProjectile(vector2194.X, vector2194.Y, single414, single415, 351, 50, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                                if (this.localAI[2] >= 100f)
                                                {
                                                    this.localAI[2] = 0f;
                                                }
                                            }
                                        }
                                        if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 50f)
                                        {
                                            flag114 = true;
                                        }
                                        if (!flag114)
                                        {
                                            if (this.direction > 0)
                                            {
                                                this.velocity.X = (this.velocity.X * 20f + single408) / 21f;
                                            }
                                            if (this.direction < 0)
                                            {
                                                this.velocity.X = (this.velocity.X * 20f - single408) / 21f;
                                            }
                                        }
                                        else
                                        {
                                            this.velocity.X = this.velocity.X * 0.9f;
                                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                            {
                                                this.velocity.X = 0f;
                                            }
                                        }
                                        int num562 = 80;
                                        int num563 = 20;
                                        Vector2 vector2195 = new Vector2(base.Center.X - (float)(num562 / 2), this.position.Y + (float)this.height - (float)num563);
                                        bool flag115 = false;
                                        if (this.position.X < Main.player[this.target].position.X && this.position.X + (float)this.width > Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y + (float)this.height < Main.player[this.target].position.Y + (float)Main.player[this.target].height - 16f)
                                        {
                                            flag115 = true;
                                        }
                                        if (flag115)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.5f;
                                        }
                                        else if (!Collision.SolidCollision(vector2195, num562, num563))
                                        {
                                            if (this.velocity.Y < 0f)
                                            {
                                                this.velocity.Y = 0f;
                                            }
                                            if ((double)this.velocity.Y >= 0.1)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.5f;
                                            }
                                            else
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.025f;
                                            }
                                        }
                                        else
                                        {
                                            if (this.velocity.Y > 0f)
                                            {
                                                this.velocity.Y = 0f;
                                            }
                                            if ((double)this.velocity.Y <= -0.2)
                                            {
                                                this.velocity.Y = this.velocity.Y - 0.2f;
                                            }
                                            else
                                            {
                                                this.velocity.Y = this.velocity.Y - 0.025f;
                                            }
                                            if (this.velocity.Y < -4f)
                                            {
                                                this.velocity.Y = -4f;
                                            }
                                        }
                                        if (this.velocity.Y > 10f)
                                        {
                                            this.velocity.Y = 10f;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle != 62)
                                    {
                                        if (this.aiStyle == 63)
                                        {
                                            this.TargetClosest(true);
                                            float single417 = 11f;
                                            Vector2 vector2196 = new Vector2(base.Center.X + (float)(this.direction * 20), base.Center.Y + 6f);
                                            float x193 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2196.X;
                                            float y194 = Main.player[this.target].Center.Y - vector2196.Y;
                                            float single418 = (float)Math.Sqrt((double)(x193 * x193 + y194 * y194));
                                            float single419 = single417 / single418;
                                            x193 = x193 * single419;
                                            y194 = y194 * single419;
                                            if (Main.dayTime)
                                            {
                                                x193 = -x193;
                                                y194 = -y194;
                                            }
                                            this.ai[0] = this.ai[0] - 1f;
                                            if (single418 < 200f || this.ai[0] > 0f)
                                            {
                                                if (single418 < 200f)
                                                {
                                                    this.ai[0] = 20f;
                                                }
                                                if (this.velocity.X >= 0f)
                                                {
                                                    this.direction = 1;
                                                }
                                                else
                                                {
                                                    this.direction = -1;
                                                }
                                                NPC nPC166 = this;
                                                nPC166.rotation = nPC166.rotation + (float)this.direction * 0.3f;
                                                return;
                                            }
                                            this.velocity.X = (this.velocity.X * 50f + x193) / 51f;
                                            this.velocity.Y = (this.velocity.Y * 50f + y194) / 51f;
                                            if (single418 < 350f)
                                            {
                                                this.velocity.X = (this.velocity.X * 10f + x193) / 11f;
                                                this.velocity.Y = (this.velocity.Y * 10f + y194) / 11f;
                                            }
                                            if (single418 < 300f)
                                            {
                                                this.velocity.X = (this.velocity.X * 7f + x193) / 8f;
                                                this.velocity.Y = (this.velocity.Y * 7f + y194) / 8f;
                                            }
                                            this.rotation = this.velocity.X * 0.15f;
                                            return;
                                        }
                                        if (this.aiStyle == 64)
                                        {
                                            float single420 = this.ai[0];
                                            float single421 = this.ai[1];
                                            if (Main.netMode != 1)
                                            {
                                                this.localAI[0] = this.localAI[0] - 1f;
                                                if (this.ai[3] == 0f)
                                                {
                                                    this.ai[3] = (float)Main.rand.Next(75, 111) * 0.01f;
                                                }
                                                if (this.localAI[0] <= 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    this.localAI[0] = (float)Main.rand.Next(60, 180);
                                                    float single422 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                                    if (single422 <= 700f || this.localAI[3] != 0f)
                                                    {
                                                        this.localAI[3] = 1f;
                                                        float single423 = (float)Main.rand.Next(5, 151) * 0.01f;
                                                        int num564 = Main.rand.Next(-100, 101);
                                                        int num565 = Main.rand.Next(-100, 101);
                                                        float single424 = single423 / (float)Math.Sqrt((double)(num564 * num564 + num565 * num565));
                                                        single420 = (float)num564 * single424;
                                                        single421 = (float)num565 * single424;
                                                    }
                                                    else
                                                    {
                                                        float single425 = (float)Main.rand.Next(50, 151) * 0.01f;
                                                        if (single422 > 1000f)
                                                        {
                                                            single425 = (float)Main.rand.Next(150, 201) * 0.01f;
                                                        }
                                                        else if (single422 > 850f)
                                                        {
                                                            single425 = (float)Main.rand.Next(100, 151) * 0.01f;
                                                        }
                                                        int num566 = this.direction * Main.rand.Next(100, 251);
                                                        int num567 = Main.rand.Next(-50, 51);
                                                        if (this.position.Y > Main.player[this.target].position.Y - 100f)
                                                        {
                                                            num567 = num567 - Main.rand.Next(100, 251);
                                                        }
                                                        float single426 = single425 / (float)Math.Sqrt((double)(num566 * num566 + num567 * num567));
                                                        single420 = (float)num566 * single426;
                                                        single421 = (float)num567 * single426;
                                                    }
                                                    this.netUpdate = true;
                                                }
                                            }
                                            this.scale = this.ai[3];
                                            if (this.localAI[2] > 0f)
                                            {
                                                int x194 = (int)base.Center.X / 16;
                                                int y195 = (int)base.Center.Y / 16;
                                                this.localAI[2] = this.localAI[2] - 1f;
                                            }
                                            else if (this.localAI[1] <= 0f)
                                            {
                                                this.localAI[1] = (float)Main.rand.Next(30, 180);
                                                if (!Main.dayTime || (double)(this.position.Y / 16f) > Main.worldSurface + 10)
                                                {
                                                    this.localAI[2] = (float)Main.rand.Next(10, 30);
                                                }
                                            }
                                            else
                                            {
                                                this.localAI[1] = this.localAI[1] - 1f;
                                            }
                                            int num568 = 80;
                                            this.velocity.X = (this.velocity.X * (float)(num568 - 1) + single420) / (float)num568;
                                            this.velocity.Y = (this.velocity.Y * (float)(num568 - 1) + single421) / (float)num568;
                                            if (this.velocity.Y > 0f)
                                            {
                                                int num569 = 4;
                                                int x195 = (int)base.Center.X / 16;
                                                int y196 = (int)base.Center.Y / 16;
                                                for (int y410 = y196; y410 < y196 + num569; y410++)
                                                {
                                                    if (Main.tile[x195, y410] != null && (Main.tile[x195, y410].nactive() && Main.tileSolid[Main.tile[x195, y410].type] || Main.tile[x195, y410].liquid > 0))
                                                    {
                                                        single421 = single421 * -1f;
                                                        if (this.velocity.Y > 0f)
                                                        {
                                                            this.velocity.Y = this.velocity.Y * 0.9f;
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.velocity.Y < 0f)
                                            {
                                                int num570 = 30;
                                                bool flag116 = false;
                                                int x196 = (int)base.Center.X / 16;
                                                int y197 = (int)base.Center.Y / 16;
                                                for (int a4 = y197; a4 < y197 + num570; a4++)
                                                {
                                                    if (Main.tile[x196, a4] != null && Main.tile[x196, a4].nactive() && Main.tileSolid[Main.tile[x196, a4].type])
                                                    {
                                                        flag116 = true;
                                                    }
                                                }
                                                if (!flag116)
                                                {
                                                    single421 = single421 * -1f;
                                                    if (this.velocity.Y < 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                                    }
                                                }
                                            }
                                            if (this.collideX)
                                            {
                                                single420 = (this.velocity.X >= 0f ? -Math.Abs(single420) : Math.Abs(single420));
                                                this.velocity.X = this.velocity.X * -0.2f;
                                            }
                                            if (this.velocity.X < 0f)
                                            {
                                                this.direction = -1;
                                            }
                                            if (this.velocity.X > 0f)
                                            {
                                                this.direction = 1;
                                            }
                                            this.ai[0] = single420;
                                            this.ai[1] = single421;
                                            return;
                                        }
                                        if (this.aiStyle == 65)
                                        {
                                            float single427 = this.ai[0];
                                            float single428 = this.ai[1];
                                            if (Main.netMode != 1)
                                            {
                                                if (this.ai[2] == 0f)
                                                {
                                                    int num571 = 0;
                                                    int num572 = 4;
                                                    int num573 = 6;
                                                    int num574 = 3;
                                                    int num575 = 7;
                                                    int num576 = 2;
                                                    int num577 = 1;
                                                    int num578 = 5;
                                                    int num579 = Main.rand.Next(100);
                                                    if (num579 == 0)
                                                    {
                                                        num579 = num578;
                                                    }
                                                    else if (num579 < 3)
                                                    {
                                                        num579 = num577;
                                                    }
                                                    else if (num579 < 9)
                                                    {
                                                        num579 = num576;
                                                    }
                                                    else if (num579 < 19)
                                                    {
                                                        num579 = num575;
                                                    }
                                                    else if (num579 < 34)
                                                    {
                                                        num579 = num574;
                                                    }
                                                    else if (num579 >= 53)
                                                    {
                                                        num579 = (num579 >= 75 ? num571 : num572);
                                                    }
                                                    else
                                                    {
                                                        num579 = num573;
                                                    }
                                                    this.ai[2] = (float)(1 + num579);
                                                }
                                                if (this.ai[3] == 0f)
                                                {
                                                    this.ai[3] = (float)Main.rand.Next(75, 111) * 0.01f;
                                                }
                                                this.localAI[0] = this.localAI[0] - 1f;
                                                if (this.localAI[0] <= 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    this.localAI[0] = (float)Main.rand.Next(90, 240);
                                                    float single429 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                                    if (single429 <= 700f || this.localAI[3] != 0f)
                                                    {
                                                        this.localAI[3] = 1f;
                                                        float single430 = (float)Main.rand.Next(26, 301) * 0.01f;
                                                        int num580 = Main.rand.Next(-100, 101);
                                                        int num581 = Main.rand.Next(-100, 101);
                                                        float single431 = single430 / (float)Math.Sqrt((double)(num580 * num580 + num581 * num581));
                                                        single427 = (float)num580 * single431;
                                                        single428 = (float)num581 * single431;
                                                    }
                                                    else
                                                    {
                                                        float single432 = (float)Main.rand.Next(50, 151) * 0.01f;
                                                        if (single429 > 1000f)
                                                        {
                                                            single432 = (float)Main.rand.Next(150, 201) * 0.01f;
                                                        }
                                                        else if (single429 > 850f)
                                                        {
                                                            single432 = (float)Main.rand.Next(100, 151) * 0.01f;
                                                        }
                                                        int num582 = this.direction * Main.rand.Next(100, 251);
                                                        int num583 = Main.rand.Next(-50, 51);
                                                        if (this.position.Y > Main.player[this.target].position.Y - 100f)
                                                        {
                                                            num583 = num583 - Main.rand.Next(100, 251);
                                                        }
                                                        float single433 = single432 / (float)Math.Sqrt((double)(num582 * num582 + num583 * num583));
                                                        single427 = (float)num582 * single433;
                                                        single428 = (float)num583 * single433;
                                                    }
                                                    this.netUpdate = true;
                                                }
                                            }
                                            this.scale = this.ai[3];
                                            int num584 = 60;
                                            this.velocity.X = (this.velocity.X * (float)(num584 - 1) + single427) / (float)num584;
                                            this.velocity.Y = (this.velocity.Y * (float)(num584 - 1) + single428) / (float)num584;
                                            if (this.velocity.Y > 0f)
                                            {
                                                int num585 = 3;
                                                int x197 = (int)base.Center.X / 16;
                                                int y198 = (int)base.Center.Y / 16;
                                                for (int b4 = y198; b4 < y198 + num585; b4++)
                                                {
                                                    if (Main.tile[x197, b4] != null && (Main.tile[x197, b4].nactive() && Main.tileSolid[Main.tile[x197, b4].type] || Main.tile[x197, b4].liquid > 0))
                                                    {
                                                        single428 = single428 * -1f;
                                                        if (this.velocity.Y > 0f)
                                                        {
                                                            this.velocity.Y = this.velocity.Y * 0.9f;
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.velocity.Y < 0f)
                                            {
                                                int num586 = 30;
                                                bool flag117 = false;
                                                int x198 = (int)base.Center.X / 16;
                                                int y199 = (int)base.Center.Y / 16;
                                                for (int c4 = y199; c4 < y199 + num586; c4++)
                                                {
                                                    if (Main.tile[x198, c4] != null && Main.tile[x198, c4].nactive() && Main.tileSolid[Main.tile[x198, c4].type])
                                                    {
                                                        flag117 = true;
                                                    }
                                                }
                                                if (!flag117)
                                                {
                                                    single428 = single428 * -1f;
                                                    if (this.velocity.Y < 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                                    }
                                                }
                                            }
                                            if (this.collideX)
                                            {
                                                single427 = (this.velocity.X >= 0f ? -Math.Abs(single427) : Math.Abs(single427));
                                                this.velocity.X = this.velocity.X * -0.2f;
                                            }
                                            if (this.velocity.X < 0f)
                                            {
                                                this.direction = -1;
                                            }
                                            if (this.velocity.X > 0f)
                                            {
                                                this.direction = 1;
                                            }
                                            this.ai[0] = single427;
                                            this.ai[1] = single428;
                                            if (this.type == 356)
                                            {
                                                this.catchItem = (short)(1994f + this.ai[2] - 1f);
                                                return;
                                            }
                                        }
                                        else if (this.aiStyle == 66)
                                        {
                                            if (this.type == 357 || this.type == 448 || this.type >= 484 && this.type <= 487)
                                            {
                                                if (this.localAI[2] >= 90f)
                                                {
                                                    this.friendly = false;
                                                }
                                                else
                                                {
                                                    this.localAI[2] = this.localAI[2] + 1f;
                                                }
                                            }
                                            if (this.velocity.Y == 0f)
                                            {
                                                if (this.ai[0] != 1f)
                                                {
                                                    this.velocity.X = 0f;
                                                }
                                                else
                                                {
                                                    if (this.direction == 0)
                                                    {
                                                        this.TargetClosest(true);
                                                    }
                                                    if (this.collideX)
                                                    {
                                                        NPC nPC167 = this;
                                                        nPC167.direction = nPC167.direction * -1;
                                                    }
                                                    float single435 = 0.2f;
                                                    if (this.type == 485)
                                                    {
                                                        single435 = 0.25f;
                                                    }
                                                    if (this.type == 486)
                                                    {
                                                        single435 = 0.325f;
                                                    }
                                                    if (this.type == 487)
                                                    {
                                                        single435 = 0.4f;
                                                    }
                                                    this.velocity.X = single435 * (float)this.direction;
                                                    if (this.type == 374)
                                                    {
                                                        this.velocity.X = this.velocity.X * 3f;
                                                    }
                                                }
                                                if (Main.netMode != 1)
                                                {
                                                    this.localAI[1] = this.localAI[1] - 1f;
                                                    if (this.localAI[1] <= 0f)
                                                    {
                                                        if (this.ai[0] != 1f)
                                                        {
                                                            this.ai[0] = 1f;
                                                            this.localAI[1] = (float)Main.rand.Next(600, 1800);
                                                        }
                                                        else
                                                        {
                                                            this.ai[0] = 0f;
                                                            this.localAI[1] = (float)Main.rand.Next(300, 900);
                                                        }
                                                        this.netUpdate = true;
                                                    }
                                                }
                                            }
                                            if (this.type == 374)
                                            {
                                                this.spriteDirection = this.direction;
                                                bool flag118 = false;
                                                int num587 = 0;
                                                while (num587 < 255)
                                                {
                                                    Player player3 = Main.player[num587];
                                                    if (!player3.active || player3.dead || Vector2.Distance(player3.Center, base.Center) > 160f)
                                                    {
                                                        num587++;
                                                    }
                                                    else
                                                    {
                                                        flag118 = true;
                                                        break;
                                                    }
                                                }
                                                int num588 = 90;
                                                if (flag118 && this.ai[1] < (float)num588)
                                                {
                                                    this.ai[1] = this.ai[1] + 1f;
                                                }
                                                if (this.ai[1] == (float)num588 && Main.netMode != 1)
                                                {
                                                    this.position.Y = this.position.Y + 16f;
                                                    this.Transform(375);
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 67)
                                        {
                                            if (this.type == 359)
                                            {
                                                if (this.ai[3] != 0f)
                                                {
                                                    this.scale = this.ai[3];
                                                    int num589 = (int)(12f * this.scale);
                                                    int num590 = (int)(12f * this.scale);
                                                    if (num589 != this.width)
                                                    {
                                                        this.position.X = this.position.X + (float)(this.width / 2) - (float)num589 - 2f;
                                                        this.width = num589;
                                                    }
                                                    if (num590 != this.height)
                                                    {
                                                        this.position.Y = this.position.Y + (float)this.height - (float)num590;
                                                        this.height = num590;
                                                    }
                                                }
                                                if (this.ai[3] == 0f && Main.netMode != 1)
                                                {
                                                    this.ai[3] = (float)Main.rand.Next(80, 111) * 0.01f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            float single436 = 0.3f;
                                            if (this.type == 360)
                                            {
                                                single436 = 0.6f;
                                            }
                                            if (this.ai[0] == 0f)
                                            {
                                                this.TargetClosest(true);
                                                this.directionY = 1;
                                                this.ai[0] = 1f;
                                                if (this.direction > 0)
                                                {
                                                    this.spriteDirection = 1;
                                                }
                                            }
                                            bool flag119 = false;
                                            if (Main.netMode != 1)
                                            {
                                                if (this.ai[2] == 0f && Main.rand.Next(7200) == 0)
                                                {
                                                    this.ai[2] = 2f;
                                                    this.netUpdate = true;
                                                }
                                                if (this.collideX || this.collideY)
                                                {
                                                    this.localAI[3] = 0f;
                                                }
                                                else
                                                {
                                                    this.localAI[3] = this.localAI[3] + 1f;
                                                    if (this.localAI[3] > 5f)
                                                    {
                                                        this.ai[2] = 2f;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                            }
                                            if (this.ai[2] > 0f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[0] = 1f;
                                                this.directionY = 1;
                                                if (this.velocity.Y <= single436)
                                                {
                                                    this.rotation = 0f;
                                                }
                                                else
                                                {
                                                    NPC nPC168 = this;
                                                    nPC168.rotation = nPC168.rotation + (float)this.direction * 0.1f;
                                                }
                                                this.spriteDirection = this.direction;
                                                this.velocity.X = single436 * (float)this.direction;
                                                this.noGravity = false;
                                                int x199 = (int)(base.Center.X + (float)(this.width / 2 * -this.direction)) / 16;
                                                int y200 = (int)(this.position.Y + (float)this.height + 8f) / 16;
                                                if (Main.tile[x199, y200] != null && !Main.tile[x199, y200].topSlope() && this.collideY)
                                                {
                                                    this.ai[2] = this.ai[2] - 1f;
                                                }
                                                y200 = (int)(this.position.Y + (float)this.height - 4f) / 16;
                                                x199 = (int)(base.Center.X + (float)(this.width / 2 * this.direction)) / 16;
                                                if (Main.tile[x199, y200] != null && Main.tile[x199, y200].bottomSlope())
                                                {
                                                    NPC nPC169 = this;
                                                    nPC169.direction = nPC169.direction * -1;
                                                }
                                                if (this.collideX && this.velocity.Y == 0f)
                                                {
                                                    flag119 = true;
                                                    this.ai[2] = 0f;
                                                    this.directionY = -1;
                                                    this.ai[1] = 1f;
                                                }
                                                if (this.velocity.Y == 0f)
                                                {
                                                    if (this.localAI[1] != this.position.X)
                                                    {
                                                        this.localAI[2] = 0f;
                                                        this.localAI[1] = this.position.X;
                                                    }
                                                    else
                                                    {
                                                        this.localAI[2] = this.localAI[2] + 1f;
                                                        if (this.localAI[2] > 10f)
                                                        {
                                                            this.direction = 1;
                                                            this.velocity.X = (float)this.direction * single436;
                                                            this.localAI[2] = 0f;
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.ai[2] == 0f)
                                            {
                                                this.noGravity = true;
                                                if (this.ai[1] != 0f)
                                                {
                                                    if (this.collideX)
                                                    {
                                                        this.ai[0] = 2f;
                                                    }
                                                    if (!this.collideX && this.ai[0] == 2f)
                                                    {
                                                        this.directionY = -this.directionY;
                                                        this.ai[1] = 0f;
                                                        this.ai[0] = 1f;
                                                    }
                                                    if (this.collideY)
                                                    {
                                                        this.direction = -this.direction;
                                                        this.ai[1] = 0f;
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.collideY)
                                                    {
                                                        this.ai[0] = 2f;
                                                    }
                                                    if (!this.collideY && this.ai[0] == 2f)
                                                    {
                                                        this.direction = -this.direction;
                                                        this.ai[1] = 1f;
                                                        this.ai[0] = 1f;
                                                    }
                                                    if (this.collideX)
                                                    {
                                                        this.directionY = -this.directionY;
                                                        this.ai[1] = 1f;
                                                    }
                                                }
                                                if (!flag119)
                                                {
                                                    float single437 = this.rotation;
                                                    if (this.directionY < 0)
                                                    {
                                                        if (this.direction < 0)
                                                        {
                                                            if (this.collideX)
                                                            {
                                                                this.rotation = 1.57f;
                                                                this.spriteDirection = -1;
                                                            }
                                                            else if (this.collideY)
                                                            {
                                                                this.rotation = 3.14f;
                                                                this.spriteDirection = 1;
                                                            }
                                                        }
                                                        else if (this.collideY)
                                                        {
                                                            this.rotation = 3.14f;
                                                            this.spriteDirection = -1;
                                                        }
                                                        else if (this.collideX)
                                                        {
                                                            this.rotation = 4.71f;
                                                            this.spriteDirection = 1;
                                                        }
                                                    }
                                                    else if (this.direction < 0)
                                                    {
                                                        if (this.collideY)
                                                        {
                                                            this.rotation = 0f;
                                                            this.spriteDirection = -1;
                                                        }
                                                        else if (this.collideX)
                                                        {
                                                            this.rotation = 1.57f;
                                                            this.spriteDirection = 1;
                                                        }
                                                    }
                                                    else if (this.collideX)
                                                    {
                                                        this.rotation = 4.71f;
                                                        this.spriteDirection = -1;
                                                    }
                                                    else if (this.collideY)
                                                    {
                                                        this.rotation = 0f;
                                                        this.spriteDirection = 1;
                                                    }
                                                    float single438 = this.rotation;
                                                    this.rotation = single437;
                                                    if ((double)this.rotation > 6.28)
                                                    {
                                                        NPC nPC170 = this;
                                                        nPC170.rotation = nPC170.rotation - 6.28f;
                                                    }
                                                    if (this.rotation < 0f)
                                                    {
                                                        NPC nPC171 = this;
                                                        nPC171.rotation = nPC171.rotation + 6.28f;
                                                    }
                                                    float single439 = Math.Abs(this.rotation - single438);
                                                    float single440 = 0.1f;
                                                    if (this.rotation > single438)
                                                    {
                                                        if ((double)single439 <= 3.14)
                                                        {
                                                            NPC nPC172 = this;
                                                            nPC172.rotation = nPC172.rotation - single440;
                                                            if (this.rotation < single438)
                                                            {
                                                                this.rotation = single438;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            NPC nPC173 = this;
                                                            nPC173.rotation = nPC173.rotation + single440;
                                                        }
                                                    }
                                                    if (this.rotation < single438)
                                                    {
                                                        if ((double)single439 <= 3.14)
                                                        {
                                                            NPC nPC174 = this;
                                                            nPC174.rotation = nPC174.rotation + single440;
                                                            if (this.rotation > single438)
                                                            {
                                                                this.rotation = single438;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            NPC nPC175 = this;
                                                            nPC175.rotation = nPC175.rotation - single440;
                                                        }
                                                    }
                                                }
                                                this.velocity.X = single436 * (float)this.direction;
                                                this.velocity.Y = single436 * (float)this.directionY;
                                                return;
                                            }
                                        }
                                        else if (this.aiStyle == 68)
                                        {
                                            this.noGravity = true;
                                            if (this.ai[0] == 0f)
                                            {
                                                this.noGravity = false;
                                                int num591 = this.direction;
                                                int num592 = this.target;
                                                this.TargetClosest(true);
                                                if (num592 >= 0 && num591 != 0)
                                                {
                                                    this.direction = num591;
                                                }
                                                if (this.wet)
                                                {
                                                    float single441 = 2f;
                                                    this.velocity.X = (this.velocity.X * 19f + single441 * (float)this.direction) / 20f;
                                                    int x200 = (int)(base.Center.X + (float)((this.width / 2 + 8) * this.direction)) / 16;
                                                    int y201 = (int)(base.Center.Y / 16f);
                                                    int y202 = (int)(this.position.Y / 16f);
                                                    int y203 = (int)((this.position.Y + (float)this.height) / 16f);
                                                    if (Main.tile[x200, y201] == null)
                                                    {
                                                        Main.tile[x200, y201] = new Tile();
                                                    }
                                                    if (Main.tile[x200, y203] == null)
                                                    {
                                                        Main.tile[x200, y203] = new Tile();
                                                    }
                                                    if (WorldGen.SolidTile(x200, y201) || WorldGen.SolidTile(x200, y202) || WorldGen.SolidTile(x200, y203) || Main.tile[x200, y203].liquid == 0)
                                                    {
                                                        NPC nPC176 = this;
                                                        nPC176.direction = nPC176.direction * -1;
                                                    }
                                                    this.spriteDirection = this.direction;
                                                    if (this.velocity.Y > 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.5f;
                                                    }
                                                    this.noGravity = true;
                                                    x200 = (int)(base.Center.X / 16f);
                                                    y201 = (int)(base.Center.Y / 16f);
                                                    float y204 = this.position.Y + (float)this.height;
                                                    if (Main.tile[x200, y201 - 1] == null)
                                                    {
                                                        Main.tile[x200, y201 - 1] = new Tile();
                                                    }
                                                    if (Main.tile[x200, y201] == null)
                                                    {
                                                        Main.tile[x200, y201] = new Tile();
                                                    }
                                                    if (Main.tile[x200, y201 + 1] == null)
                                                    {
                                                        Main.tile[x200, y201 + 1] = new Tile();
                                                    }
                                                    if (Main.tile[x200, y201 - 1].liquid > 0)
                                                    {
                                                        y204 = (float)(y201 * 16);
                                                        y204 = y204 - (float)(Main.tile[x200, y201 - 1].liquid / 16);
                                                    }
                                                    else if (Main.tile[x200, y201].liquid > 0)
                                                    {
                                                        y204 = (float)((y201 + 1) * 16);
                                                        y204 = y204 - (float)(Main.tile[x200, y201].liquid / 16);
                                                    }
                                                    else if (Main.tile[x200, y201 + 1].liquid > 0)
                                                    {
                                                        y204 = (float)((y201 + 2) * 16);
                                                        y204 = y204 - (float)(Main.tile[x200, y201 + 1].liquid / 16);
                                                    }
                                                    y204 = y204 - 6f;
                                                    if (base.Center.Y <= y204)
                                                    {
                                                        this.velocity.Y = y204 - base.Center.Y;
                                                    }
                                                    else
                                                    {
                                                        this.velocity.Y = this.velocity.Y - 0.1f;
                                                        if (this.velocity.Y < -8f)
                                                        {
                                                            this.velocity.Y = -8f;
                                                        }
                                                        if (base.Center.Y + this.velocity.Y < y204)
                                                        {
                                                            this.velocity.Y = y204 - base.Center.Y;
                                                        }
                                                    }
                                                }
                                                if (Main.netMode != 1)
                                                {
                                                    if (!this.wet)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.netUpdate = true;
                                                        this.direction = -this.direction;
                                                        return;
                                                    }
                                                    Rectangle rectangle13 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                                                    Rectangle rectangle14 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                                                    if (rectangle14.Intersects(rectangle13) || this.life < this.lifeMax)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.velocity.Y = this.velocity.Y - 6f;
                                                        this.netUpdate = true;
                                                        this.direction = -this.direction;
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (!Main.player[this.target].dead)
                                            {
                                                bool flag120 = false;
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 300f)
                                                {
                                                    flag120 = true;
                                                }
                                                if (!flag120)
                                                {
                                                    if (this.collideX)
                                                    {
                                                        NPC nPC177 = this;
                                                        nPC177.direction = nPC177.direction * -1;
                                                        this.velocity.X = this.oldVelocity.X * -0.5f;
                                                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                                                        {
                                                            this.velocity.X = 2f;
                                                        }
                                                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                                                        {
                                                            this.velocity.X = -2f;
                                                        }
                                                    }
                                                    if (this.collideY)
                                                    {
                                                        this.velocity.Y = this.oldVelocity.Y * -0.5f;
                                                        if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                                                        {
                                                            this.velocity.Y = 1f;
                                                        }
                                                        if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                                                        {
                                                            this.velocity.Y = -1f;
                                                        }
                                                    }
                                                    if (this.direction == -1 && this.velocity.X > -3f)
                                                    {
                                                        this.velocity.X = this.velocity.X - 0.1f;
                                                        if (this.velocity.X > 3f)
                                                        {
                                                            this.velocity.X = this.velocity.X - 0.1f;
                                                        }
                                                        else if (this.velocity.X > 0f)
                                                        {
                                                            this.velocity.X = this.velocity.X - 0.05f;
                                                        }
                                                        if (this.velocity.X < -3f)
                                                        {
                                                            this.velocity.X = -3f;
                                                        }
                                                    }
                                                    else if (this.direction == 1 && this.velocity.X < 3f)
                                                    {
                                                        this.velocity.X = this.velocity.X + 0.1f;
                                                        if (this.velocity.X < -3f)
                                                        {
                                                            this.velocity.X = this.velocity.X + 0.1f;
                                                        }
                                                        else if (this.velocity.X < 0f)
                                                        {
                                                            this.velocity.X = this.velocity.X + 0.05f;
                                                        }
                                                        if (this.velocity.X > 3f)
                                                        {
                                                            this.velocity.X = 3f;
                                                        }
                                                    }
                                                    int x201 = (int)((this.position.X + (float)(this.width / 2)) / 16f) + this.direction;
                                                    int y205 = (int)((this.position.Y + (float)this.height) / 16f);
                                                    bool flag121 = true;
                                                    int num593 = 15;
                                                    bool flag122 = false;
                                                    int num594 = y205;
                                                    while (num594 < y205 + num593)
                                                    {
                                                        if (Main.tile[x201, num594] == null)
                                                        {
                                                            Main.tile[x201, num594] = new Tile();
                                                        }
                                                        if ((!Main.tile[x201, num594].nactive() || !Main.tileSolid[Main.tile[x201, num594].type]) && Main.tile[x201, num594].liquid <= 0)
                                                        {
                                                            num594++;
                                                        }
                                                        else
                                                        {
                                                            if (num594 < y205 + 5)
                                                            {
                                                                flag122 = true;
                                                            }
                                                            flag121 = false;
                                                            break;
                                                        }
                                                    }
                                                    if (!flag121)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - 0.1f;
                                                    }
                                                    else
                                                    {
                                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                                    }
                                                    if (flag122)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - 0.2f;
                                                    }
                                                    if (this.velocity.Y > 3f)
                                                    {
                                                        this.velocity.Y = 3f;
                                                    }
                                                    if (this.velocity.Y < -4f)
                                                    {
                                                        this.velocity.Y = -4f;
                                                        return;
                                                    }
                                                }
                                                else if (this.velocity.Y == 0f || this.collideY || this.wet)
                                                {
                                                    this.velocity.X = 0f;
                                                    this.velocity.Y = 0f;
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    if (Main.netMode != 1)
                                                    {
                                                        if ((this.type == 363 || this.type == 365) && !this.wet)
                                                        {
                                                            int num595 = this.direction;
                                                            this.Transform(this.type - 1);
                                                            this.TargetClosest(true);
                                                            this.direction = num595;
                                                            this.ai[0] = 0f;
                                                            this.ai[1] = (float)(200 + Main.rand.Next(200));
                                                        }
                                                        this.netUpdate = true;
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    this.velocity.X = this.velocity.X * 0.98f;
                                                    this.velocity.Y = this.velocity.Y + 0.1f;
                                                    if (this.velocity.Y > 2f)
                                                    {
                                                        this.velocity.Y = 2f;
                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 69)
                                        {
                                            bool flag123 = Main.expertMode;
                                            float single442 = (flag123 ? 0.6f * Main.damageMultiplier : 1f);
                                            bool flag124 = (double)this.life <= (double)this.lifeMax * 0.5;
                                            bool flag125 = (!flag123 ? false : (double)this.life <= (double)this.lifeMax * 0.15);
                                            bool flag126 = this.ai[0] > 4f;
                                            bool flag127 = this.ai[0] > 9f;
                                            bool flag128 = this.ai[3] < 10f;
                                            if (flag127)
                                            {
                                                this.damage = (int)((float)this.defDamage * 1.1f * single442);
                                                this.defense = 0;
                                            }
                                            else if (!flag126)
                                            {
                                                this.damage = this.defDamage;
                                                this.defense = this.defDefense;
                                            }
                                            else
                                            {
                                                this.damage = (int)((float)this.defDamage * 1.2f * single442);
                                                this.defense = (int)((float)this.defDefense * 0.8f);
                                            }
                                            int num596 = (flag123 ? 40 : 60);
                                            float single443 = (flag123 ? 0.55f : 0.45f);
                                            float single444 = (flag123 ? 8.5f : 7.5f);
                                            if (flag127)
                                            {
                                                single443 = 0.7f;
                                                single444 = 12f;
                                                num596 = 30;
                                            }
                                            else if (flag126 && flag128)
                                            {
                                                single443 = (flag123 ? 0.6f : 0.5f);
                                                single444 = (flag123 ? 10f : 8f);
                                                num596 = (flag123 ? 40 : 20);
                                            }
                                            else if (flag128 && !flag126 && !flag127)
                                            {
                                                num596 = 30;
                                            }
                                            int num597 = (flag123 ? 28 : 30);
                                            float single445 = (flag123 ? 17f : 16f);
                                            if (flag127)
                                            {
                                                num597 = 25;
                                                single445 = 27f;
                                            }
                                            else if (flag128 && flag126)
                                            {
                                                num597 = (flag123 ? 27 : 30);
                                                if (flag123)
                                                {
                                                    single445 = 21f;
                                                }
                                            }
                                            int num598 = 80;
                                            int num599 = 4;
                                            float single446 = 0.3f;
                                            float single447 = 5f;
                                            int num600 = 90;
                                            int num601 = 180;
                                            int num602 = 180;
                                            int num603 = 30;
                                            int num604 = 120;
                                            int num605 = 4;
                                            float single448 = 6f;
                                            float single449 = 20f;
                                            float single450 = 6.28318548f / (float)(num604 / 2);
                                            int num606 = 75;
                                            Vector2 center33 = base.Center;
                                            Player player4 = Main.player[this.target];
                                            if (this.target < 0 || this.target == 255 || player4.dead || !player4.active)
                                            {
                                                this.TargetClosest(true);
                                                player4 = Main.player[this.target];
                                                this.netUpdate = true;
                                            }
                                            if (player4.dead || Vector2.Distance(player4.Center, center33) > 2400f)
                                            {
                                                this.velocity.Y = this.velocity.Y - 0.4f;
                                                if (this.timeLeft > 10)
                                                {
                                                    this.timeLeft = 10;
                                                }
                                                if (this.ai[0] <= 4f)
                                                {
                                                    this.ai[0] = 0f;
                                                }
                                                else
                                                {
                                                    this.ai[0] = 5f;
                                                }
                                                this.ai[2] = 0f;
                                            }
                                            if (player4.position.Y < 800f || (double)player4.position.Y > Main.worldSurface * 16)
                                            {
                                                flag4 = true;
                                            }
                                            else
                                            {
                                                flag4 = (player4.position.X <= 6400f ? false : player4.position.X < (float)(Main.maxTilesX * 16 - 6400));
                                            }
                                            if (flag4)
                                            {
                                                num596 = 20;
                                                this.damage = this.defDamage * 2;
                                                this.defense = this.defDefense * 2;
                                                this.ai[3] = 0f;
                                                single445 = single445 + 6f;
                                            }
                                            if (this.localAI[0] == 0f)
                                            {
                                                this.localAI[0] = 1f;
                                                this.alpha = 255;
                                                this.rotation = 0f;
                                                if (Main.netMode != 1)
                                                {
                                                    this.ai[0] = -1f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            float single451 = (float)Math.Atan2((double)(player4.Center.Y - center33.Y), (double)(player4.Center.X - center33.X));
                                            if (this.spriteDirection == 1)
                                            {
                                                single451 = single451 + 3.14159274f;
                                            }
                                            if (single451 < 0f)
                                            {
                                                single451 = single451 + 6.28318548f;
                                            }
                                            if (single451 > 6.28318548f)
                                            {
                                                single451 = single451 - 6.28318548f;
                                            }
                                            if (this.ai[0] == -1f)
                                            {
                                                single451 = 0f;
                                            }
                                            if (this.ai[0] == 3f)
                                            {
                                                single451 = 0f;
                                            }
                                            if (this.ai[0] == 4f)
                                            {
                                                single451 = 0f;
                                            }
                                            if (this.ai[0] == 8f)
                                            {
                                                single451 = 0f;
                                            }
                                            float single452 = 0.04f;
                                            if (this.ai[0] == 1f || this.ai[0] == 6f)
                                            {
                                                single452 = 0f;
                                            }
                                            if (this.ai[0] == 7f)
                                            {
                                                single452 = 0f;
                                            }
                                            if (this.ai[0] == 3f)
                                            {
                                                single452 = 0.01f;
                                            }
                                            if (this.ai[0] == 4f)
                                            {
                                                single452 = 0.01f;
                                            }
                                            if (this.ai[0] == 8f)
                                            {
                                                single452 = 0.01f;
                                            }
                                            if (this.rotation < single451)
                                            {
                                                if ((double)(single451 - this.rotation) <= 3.14159265358979)
                                                {
                                                    NPC nPC178 = this;
                                                    nPC178.rotation = nPC178.rotation + single452;
                                                }
                                                else
                                                {
                                                    NPC nPC179 = this;
                                                    nPC179.rotation = nPC179.rotation - single452;
                                                }
                                            }
                                            if (this.rotation > single451)
                                            {
                                                if ((double)(this.rotation - single451) <= 3.14159265358979)
                                                {
                                                    NPC nPC180 = this;
                                                    nPC180.rotation = nPC180.rotation - single452;
                                                }
                                                else
                                                {
                                                    NPC nPC181 = this;
                                                    nPC181.rotation = nPC181.rotation + single452;
                                                }
                                            }
                                            if (this.rotation > single451 - single452 && this.rotation < single451 + single452)
                                            {
                                                this.rotation = single451;
                                            }
                                            if (this.rotation < 0f)
                                            {
                                                NPC nPC182 = this;
                                                nPC182.rotation = nPC182.rotation + 6.28318548f;
                                            }
                                            if (this.rotation > 6.28318548f)
                                            {
                                                NPC nPC183 = this;
                                                nPC183.rotation = nPC183.rotation - 6.28318548f;
                                            }
                                            if (this.rotation > single451 - single452 && this.rotation < single451 + single452)
                                            {
                                                this.rotation = single451;
                                            }
                                            if (this.ai[0] != -1f && this.ai[0] < 9f)
                                            {
                                                if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                {
                                                    NPC nPC184 = this;
                                                    nPC184.alpha = nPC184.alpha - 15;
                                                }
                                                else
                                                {
                                                    NPC nPC185 = this;
                                                    nPC185.alpha = nPC185.alpha + 15;
                                                }
                                                if (this.alpha < 0)
                                                {
                                                    this.alpha = 0;
                                                }
                                                if (this.alpha > 150)
                                                {
                                                    this.alpha = 150;
                                                }
                                            }
                                            if (this.ai[0] == -1f)
                                            {
                                                NPC nPC186 = this;
                                                nPC186.velocity = nPC186.velocity * 0.98f;
                                                int num607 = Math.Sign(player4.Center.X - center33.X);
                                                if (num607 != 0)
                                                {
                                                    this.direction = num607;
                                                    this.spriteDirection = -this.direction;
                                                }
                                                if (this.ai[2] > 20f)
                                                {
                                                    this.velocity.Y = -2f;
                                                    NPC nPC187 = this;
                                                    nPC187.alpha = nPC187.alpha - 5;
                                                    if (Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        NPC nPC188 = this;
                                                        nPC188.alpha = nPC188.alpha + 15;
                                                    }
                                                    if (this.alpha < 0)
                                                    {
                                                        this.alpha = 0;
                                                    }
                                                    if (this.alpha > 150)
                                                    {
                                                        this.alpha = 150;
                                                    }
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num606)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 0f && !player4.dead)
                                            {
                                                if (this.ai[1] == 0f)
                                                {
                                                    this.ai[1] = (float)(300 * Math.Sign((center33 - player4.Center).X));
                                                }
                                                Vector2 center35 = (player4.Center + new Vector2(this.ai[1], -200f)) - center33;
                                                Vector2 vector2199 = Vector2.Normalize(center35 - this.velocity) * single444;
                                                if (this.velocity.X < vector2199.X)
                                                {
                                                    this.velocity.X = this.velocity.X + single443;
                                                    if (this.velocity.X < 0f && vector2199.X > 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X + single443;
                                                    }
                                                }
                                                else if (this.velocity.X > vector2199.X)
                                                {
                                                    this.velocity.X = this.velocity.X - single443;
                                                    if (this.velocity.X > 0f && vector2199.X < 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X - single443;
                                                    }
                                                }
                                                if (this.velocity.Y < vector2199.Y)
                                                {
                                                    this.velocity.Y = this.velocity.Y + single443;
                                                    if (this.velocity.Y < 0f && vector2199.Y > 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y + single443;
                                                    }
                                                }
                                                else if (this.velocity.Y > vector2199.Y)
                                                {
                                                    this.velocity.Y = this.velocity.Y - single443;
                                                    if (this.velocity.Y > 0f && vector2199.Y < 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - single443;
                                                    }
                                                }
                                                int num611 = Math.Sign(player4.Center.X - center33.X);
                                                if (num611 != 0)
                                                {
                                                    if (this.ai[2] == 0f && num611 != this.direction)
                                                    {
                                                        NPC nPC189 = this;
                                                        nPC189.rotation = nPC189.rotation + 3.14159274f;
                                                    }
                                                    this.direction = num611;
                                                    if (this.spriteDirection != -this.direction)
                                                    {
                                                        NPC nPC190 = this;
                                                        nPC190.rotation = nPC190.rotation + 3.14159274f;
                                                    }
                                                    this.spriteDirection = -this.direction;
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num596)
                                                {
                                                    int num612 = 0;
                                                    num6 = (int)this.ai[3];
                                                    switch (num6)
                                                    {
                                                        case 0:
                                                        case 1:
                                                        case 2:
                                                        case 3:
                                                        case 4:
                                                        case 5:
                                                        case 6:
                                                        case 7:
                                                        case 8:
                                                        case 9:
                                                        {
                                                            num612 = 1;
                                                            break;
                                                        }
                                                        case 10:
                                                        {
                                                            this.ai[3] = 1f;
                                                            num612 = 2;
                                                            break;
                                                        }
                                                        case 11:
                                                        {
                                                            this.ai[3] = 0f;
                                                            num612 = 3;
                                                            break;
                                                        }
                                                    }
                                                    if (flag124)
                                                    {
                                                        num612 = 4;
                                                    }
                                                    if (num612 == 1)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.velocity = Vector2.Normalize(player4.Center - center33) * single445;
                                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                        if (num611 != 0)
                                                        {
                                                            this.direction = num611;
                                                            if (this.spriteDirection == 1)
                                                            {
                                                                NPC nPC191 = this;
                                                                nPC191.rotation = nPC191.rotation + 3.14159274f;
                                                            }
                                                            this.spriteDirection = -this.direction;
                                                        }
                                                    }
                                                    else if (num612 == 2)
                                                    {
                                                        this.ai[0] = 2f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    else if (num612 == 3)
                                                    {
                                                        this.ai[0] = 3f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    else if (num612 == 4)
                                                    {
                                                        this.ai[0] = 4f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 1f)
                                            {
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num597)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = this.ai[3] + 2f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 2f)
                                            {
                                                if (this.ai[1] == 0f)
                                                {
                                                    this.ai[1] = (float)(300 * Math.Sign((center33 - player4.Center).X));
                                                }
                                                Vector2 center36 = (player4.Center + new Vector2(this.ai[1], -200f)) - center33;
                                                Vector2 vector2202 = Vector2.Normalize(center36 - this.velocity) * single447;
                                                if (this.velocity.X < vector2202.X)
                                                {
                                                    this.velocity.X = this.velocity.X + single446;
                                                    if (this.velocity.X < 0f && vector2202.X > 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X + single446;
                                                    }
                                                }
                                                else if (this.velocity.X > vector2202.X)
                                                {
                                                    this.velocity.X = this.velocity.X - single446;
                                                    if (this.velocity.X > 0f && vector2202.X < 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X - single446;
                                                    }
                                                }
                                                if (this.velocity.Y < vector2202.Y)
                                                {
                                                    this.velocity.Y = this.velocity.Y + single446;
                                                    if (this.velocity.Y < 0f && vector2202.Y > 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y + single446;
                                                    }
                                                }
                                                else if (this.velocity.Y > vector2202.Y)
                                                {
                                                    this.velocity.Y = this.velocity.Y - single446;
                                                    if (this.velocity.Y > 0f && vector2202.Y < 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - single446;
                                                    }
                                                }
                                                if (this.ai[2] % (float)num599 == 0f)
                                                {
                                                    if (Main.netMode != 1)
                                                    {
                                                        Vector2 vector2203 = ((Vector2.Normalize(player4.Center - center33) * (float)(this.width + 20)) / 2f) + center33;
                                                        NPC.NewNPC((int)vector2203.X, (int)vector2203.Y + 45, 371, 0, 0f, 0f, 0f, 0f, 255);
                                                    }
                                                }
                                                int num616 = Math.Sign(player4.Center.X - center33.X);
                                                if (num616 != 0)
                                                {
                                                    this.direction = num616;
                                                    if (this.spriteDirection != -this.direction)
                                                    {
                                                        NPC nPC192 = this;
                                                        nPC192.rotation = nPC192.rotation + 3.14159274f;
                                                    }
                                                    this.spriteDirection = -this.direction;
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num598)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 3f)
                                            {
                                                NPC nPC193 = this;
                                                nPC193.velocity = nPC193.velocity * 0.98f;
                                                this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                                if (Main.netMode != 1 && this.ai[2] == (float)(num600 - 30))
                                                {
                                                    Vector2 rotationVector22 = (((this.rotation.ToRotationVector2() * Vector2.UnitX * (float)this.direction) * (float)(this.width + 20)) / 2f) + center33;
                                                    Projectile.NewProjectile(rotationVector22.X, rotationVector22.Y, (float)(this.direction * 2), 8f, 385, 0, 0f, Main.myPlayer, 0f, 0f);
                                                    Projectile.NewProjectile(rotationVector22.X, rotationVector22.Y, (float)(-this.direction * 2), 8f, 385, 0, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num600)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 4f)
                                            {
                                                NPC nPC194 = this;
                                                nPC194.velocity = nPC194.velocity * 0.98f;
                                                this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num601)
                                                {
                                                    this.ai[0] = 5f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 5f && !player4.dead)
                                            {
                                                if (this.ai[1] == 0f)
                                                {
                                                    this.ai[1] = (float)(300 * Math.Sign((center33 - player4.Center).X));
                                                }
                                                Vector2 center37 = (player4.Center + new Vector2(this.ai[1], -200f)) - center33;
                                                Vector2 vector2204 = Vector2.Normalize(center37 - this.velocity) * single444;
                                                if (this.velocity.X < vector2204.X)
                                                {
                                                    this.velocity.X = this.velocity.X + single443;
                                                    if (this.velocity.X < 0f && vector2204.X > 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X + single443;
                                                    }
                                                }
                                                else if (this.velocity.X > vector2204.X)
                                                {
                                                    this.velocity.X = this.velocity.X - single443;
                                                    if (this.velocity.X > 0f && vector2204.X < 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X - single443;
                                                    }
                                                }
                                                if (this.velocity.Y < vector2204.Y)
                                                {
                                                    this.velocity.Y = this.velocity.Y + single443;
                                                    if (this.velocity.Y < 0f && vector2204.Y > 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y + single443;
                                                    }
                                                }
                                                else if (this.velocity.Y > vector2204.Y)
                                                {
                                                    this.velocity.Y = this.velocity.Y - single443;
                                                    if (this.velocity.Y > 0f && vector2204.Y < 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - single443;
                                                    }
                                                }
                                                int num617 = Math.Sign(player4.Center.X - center33.X);
                                                if (num617 != 0)
                                                {
                                                    if (this.ai[2] == 0f && num617 != this.direction)
                                                    {
                                                        NPC nPC195 = this;
                                                        nPC195.rotation = nPC195.rotation + 3.14159274f;
                                                    }
                                                    this.direction = num617;
                                                    if (this.spriteDirection != -this.direction)
                                                    {
                                                        NPC nPC196 = this;
                                                        nPC196.rotation = nPC196.rotation + 3.14159274f;
                                                    }
                                                    this.spriteDirection = -this.direction;
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num596)
                                                {
                                                    int num618 = 0;
                                                    num6 = (int)this.ai[3];
                                                    switch (num6)
                                                    {
                                                        case 0:
                                                        case 1:
                                                        case 2:
                                                        case 3:
                                                        case 4:
                                                        case 5:
                                                        {
                                                            num618 = 1;
                                                            break;
                                                        }
                                                        case 6:
                                                        {
                                                            this.ai[3] = 1f;
                                                            num618 = 2;
                                                            break;
                                                        }
                                                        case 7:
                                                        {
                                                            this.ai[3] = 0f;
                                                            num618 = 3;
                                                            break;
                                                        }
                                                    }
                                                    if (flag125)
                                                    {
                                                        num618 = 4;
                                                    }
                                                    if (num618 == 1)
                                                    {
                                                        this.ai[0] = 6f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.velocity = Vector2.Normalize(player4.Center - center33) * single445;
                                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                        if (num617 != 0)
                                                        {
                                                            this.direction = num617;
                                                            if (this.spriteDirection == 1)
                                                            {
                                                                NPC nPC197 = this;
                                                                nPC197.rotation = nPC197.rotation + 3.14159274f;
                                                            }
                                                            this.spriteDirection = -this.direction;
                                                        }
                                                    }
                                                    else if (num618 == 2)
                                                    {
                                                        this.velocity = Vector2.Normalize(player4.Center - center33) * single449;
                                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                        if (num617 != 0)
                                                        {
                                                            this.direction = num617;
                                                            if (this.spriteDirection == 1)
                                                            {
                                                                NPC nPC198 = this;
                                                                nPC198.rotation = nPC198.rotation + 3.14159274f;
                                                            }
                                                            this.spriteDirection = -this.direction;
                                                        }
                                                        this.ai[0] = 7f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    else if (num618 == 3)
                                                    {
                                                        this.ai[0] = 8f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    else if (num618 == 4)
                                                    {
                                                        this.ai[0] = 9f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 6f)
                                            {
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num597)
                                                {
                                                    this.ai[0] = 5f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = this.ai[3] + 2f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 7f)
                                            {
                                                if (this.ai[2] % (float)num605 == 0f)
                                                {
                                                    if (Main.netMode != 1)
                                                    {
                                                        Vector2 vector2207 = ((Vector2.Normalize(this.velocity) * (float)(this.width + 20)) / 2f) + center33;
                                                        int num622 = NPC.NewNPC((int)vector2207.X, (int)vector2207.Y + 45, 371, 0, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num622].target = this.target;
                                                        NPC nPC199 = Main.npc[num622];
                                                        Vector2 vector2208 = Vector2.Normalize(this.velocity);
                                                        double num623 = (double)(1.57079637f * (float)this.direction);
                                                        vector24 = new Vector2();
                                                        nPC199.velocity = vector2208.RotatedBy(num623, vector24) * single448;
                                                        Main.npc[num622].netUpdate = true;
                                                        Main.npc[num622].ai[3] = (float)Main.rand.Next(80, 121) / 100f;
                                                    }
                                                }
                                                Vector2 vector2209 = this.velocity;
                                                double num624 = (double)(-single450 * (float)this.direction);
                                                vector24 = new Vector2();
                                                this.velocity = vector2209.RotatedBy(num624, vector24);
                                                NPC nPC200 = this;
                                                nPC200.rotation = nPC200.rotation - single450 * (float)this.direction;
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num604)
                                                {
                                                    this.ai[0] = 5f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 8f)
                                            {
                                                NPC nPC201 = this;
                                                nPC201.velocity = nPC201.velocity * 0.98f;
                                                this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                                if (Main.netMode != 1 && this.ai[2] == (float)(num600 - 30))
                                                {
                                                    Projectile.NewProjectile(center33.X, center33.Y, 0f, 0f, 385, 0, 0f, Main.myPlayer, 1f, (float)(this.target + 1));
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num600)
                                                {
                                                    this.ai[0] = 5f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 9f)
                                            {
                                                if (this.ai[2] < (float)(num602 - 90))
                                                {
                                                    if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        NPC nPC202 = this;
                                                        nPC202.alpha = nPC202.alpha - 15;
                                                    }
                                                    else
                                                    {
                                                        NPC nPC203 = this;
                                                        nPC203.alpha = nPC203.alpha + 15;
                                                    }
                                                    if (this.alpha < 0)
                                                    {
                                                        this.alpha = 0;
                                                    }
                                                    if (this.alpha > 150)
                                                    {
                                                        this.alpha = 150;
                                                    }
                                                }
                                                else if (this.alpha < 255)
                                                {
                                                    NPC nPC204 = this;
                                                    nPC204.alpha = nPC204.alpha + 4;
                                                    if (this.alpha > 255)
                                                    {
                                                        this.alpha = 255;
                                                    }
                                                }
                                                NPC nPC205 = this;
                                                nPC205.velocity = nPC205.velocity * 0.98f;
                                                this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num602)
                                                {
                                                    this.ai[0] = 10f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 10f && !player4.dead)
                                            {
                                                this.dontTakeDamage = false;
                                                this.chaseable = false;
                                                if (this.alpha < 255)
                                                {
                                                    NPC nPC206 = this;
                                                    nPC206.alpha = nPC206.alpha + 25;
                                                    if (this.alpha > 255)
                                                    {
                                                        this.alpha = 255;
                                                    }
                                                }
                                                if (this.ai[1] == 0f)
                                                {
                                                    this.ai[1] = (float)(360 * Math.Sign((center33 - player4.Center).X));
                                                }
                                                Vector2 center38 = (player4.Center + new Vector2(this.ai[1], -200f)) - center33;
                                                Vector2 vector2210 = Vector2.Normalize(center38 - this.velocity) * single444;
                                                this.SimpleFlyMovement(vector2210, single443);
                                                int num625 = Math.Sign(player4.Center.X - center33.X);
                                                if (num625 != 0)
                                                {
                                                    if (this.ai[2] == 0f && num625 != this.direction)
                                                    {
                                                        NPC nPC207 = this;
                                                        nPC207.rotation = nPC207.rotation + 3.14159274f;
                                                        for (int g4 = 0; g4 < (int)this.oldPos.Length; g4++)
                                                        {
                                                            this.oldPos[g4] = Vector2.Zero;
                                                        }
                                                    }
                                                    this.direction = num625;
                                                    if (this.spriteDirection != -this.direction)
                                                    {
                                                        NPC nPC208 = this;
                                                        nPC208.rotation = nPC208.rotation + 3.14159274f;
                                                    }
                                                    this.spriteDirection = -this.direction;
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num596)
                                                {
                                                    int num626 = 0;
                                                    num6 = (int)this.ai[3];
                                                    switch (num6)
                                                    {
                                                        case 0:
                                                        case 2:
                                                        case 3:
                                                        case 5:
                                                        case 6:
                                                        case 7:
                                                        {
                                                            num626 = 1;
                                                            break;
                                                        }
                                                        case 1:
                                                        case 4:
                                                        case 8:
                                                        {
                                                            num626 = 2;
                                                            break;
                                                        }
                                                    }
                                                    if (num626 == 1)
                                                    {
                                                        this.ai[0] = 11f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.velocity = Vector2.Normalize(player4.Center - center33) * single445;
                                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                        if (num625 != 0)
                                                        {
                                                            this.direction = num625;
                                                            if (this.spriteDirection == 1)
                                                            {
                                                                NPC nPC209 = this;
                                                                nPC209.rotation = nPC209.rotation + 3.14159274f;
                                                            }
                                                            this.spriteDirection = -this.direction;
                                                        }
                                                    }
                                                    else if (num626 == 2)
                                                    {
                                                        this.ai[0] = 12f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    else if (num626 == 3)
                                                    {
                                                        this.ai[0] = 13f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                    }
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 11f)
                                            {
                                                this.dontTakeDamage = false;
                                                this.chaseable = true;
                                                NPC nPC210 = this;
                                                nPC210.alpha = nPC210.alpha - 25;
                                                if (this.alpha < 0)
                                                {
                                                    this.alpha = 0;
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num597)
                                                {
                                                    this.ai[0] = 10f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = this.ai[3] + 1f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 12f)
                                            {
                                                this.dontTakeDamage = true;
                                                this.chaseable = false;
                                                if (this.alpha < 255)
                                                {
                                                    NPC nPC211 = this;
                                                    nPC211.alpha = nPC211.alpha + 17;
                                                    if (this.alpha > 255)
                                                    {
                                                        this.alpha = 255;
                                                    }
                                                }
                                                NPC nPC212 = this;
                                                nPC212.velocity = nPC212.velocity * 0.98f;
                                                this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                                if (Main.netMode != 1 && this.ai[2] == (float)(num603 / 2))
                                                {
                                                    if (this.ai[1] == 0f)
                                                    {
                                                        this.ai[1] = (float)(300 * Math.Sign((center33 - player4.Center).X));
                                                    }
                                                    Vector2 center39 = player4.Center + new Vector2(-this.ai[1], -200f);
                                                    Vector2 vector2213 = center39;
                                                    vector24 = vector2213;
                                                    base.Center = vector2213;
                                                    center33 = vector24;
                                                    int num630 = Math.Sign(player4.Center.X - center33.X);
                                                    if (num630 != 0)
                                                    {
                                                        if (this.ai[2] == 0f && num630 != this.direction)
                                                        {
                                                            NPC nPC213 = this;
                                                            nPC213.rotation = nPC213.rotation + 3.14159274f;
                                                            for (int i5 = 0; i5 < (int)this.oldPos.Length; i5++)
                                                            {
                                                                this.oldPos[i5] = Vector2.Zero;
                                                            }
                                                        }
                                                        this.direction = num630;
                                                        if (this.spriteDirection != -this.direction)
                                                        {
                                                            NPC nPC214 = this;
                                                            nPC214.rotation = nPC214.rotation + 3.14159274f;
                                                        }
                                                        this.spriteDirection = -this.direction;
                                                    }
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num603)
                                                {
                                                    this.ai[0] = 10f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = this.ai[3] + 1f;
                                                    if (this.ai[3] >= 9f)
                                                    {
                                                        this.ai[3] = 0f;
                                                    }
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 13f)
                                            {
                                                Vector2 vector2214 = this.velocity;
                                                double num631 = (double)(-single450 * (float)this.direction);
                                                vector24 = new Vector2();
                                                this.velocity = vector2214.RotatedBy(num631, vector24);
                                                NPC nPC215 = this;
                                                nPC215.rotation = nPC215.rotation - single450 * (float)this.direction;
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= (float)num604)
                                                {
                                                    this.ai[0] = 10f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = this.ai[3] + 1f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 70)
                                        {
                                            if (this.target == 255)
                                            {
                                                this.TargetClosest(true);
                                                this.ai[3] = (float)Main.rand.Next(80, 121) / 100f;
                                                float single453 = (float)Main.rand.Next(165, 265) / 15f;
                                                this.velocity = Vector2.Normalize((Main.player[this.target].Center - base.Center) + new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101))) * single453;
                                                this.netUpdate = true;
                                            }
                                            Vector2 vector2215 = Vector2.Normalize(Main.player[this.target].Center - base.Center);
                                            this.velocity = ((this.velocity * 40f) + (vector2215 * 20f)) / 41f;
                                            this.scale = this.ai[3];
                                            NPC nPC216 = this;
                                            nPC216.alpha = nPC216.alpha - 30;
                                            if (this.alpha < 50)
                                            {
                                                this.alpha = 50;
                                            }
                                            this.alpha = 50;
                                            this.velocity.X = (this.velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f;
                                            this.velocity.Y = (this.velocity.Y * 50f + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f;
                                            if (this.velocity.Y > 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y - 0.04f;
                                            }
                                            if (this.ai[0] == 0f)
                                            {
                                                int num632 = 40;
                                                Rectangle rect = this.getRect();
                                                rect.X = rect.X - (num632 + this.width / 2);
                                                rect.Y = rect.Y - (num632 + this.height / 2);
                                                rect.Width = rect.Width + num632 * 2;
                                                rect.Height = rect.Height + num632 * 2;
                                                int num633 = 0;
                                                while (num633 < 255)
                                                {
                                                    Player player5 = Main.player[num633];
                                                    if (!player5.active || player5.dead || !rect.Intersects(player5.getRect()))
                                                    {
                                                        num633++;
                                                    }
                                                    else
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.ai[1] = 4f;
                                                        this.netUpdate = true;
                                                        break;
                                                    }
                                                }
                                            }
                                            if (this.ai[0] == 0f)
                                            {
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 150f)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = 4f;
                                                }
                                            }
                                            if (this.ai[0] == 1f)
                                            {
                                                this.ai[1] = this.ai[1] - 1f;
                                                if (this.ai[1] <= 0f)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10);
                                                    this.active = false;
                                                    return;
                                                }
                                            }
                                            if (this.justHit || this.ai[0] == 1f)
                                            {
                                                this.dontTakeDamage = true;
                                                this.position = base.Center;
                                                int num634 = 100;
                                                num6 = num634;
                                                this.height = num634;
                                                this.width = num6;
                                                this.position = new Vector2(this.position.X - (float)(this.width / 2), this.position.Y - (float)(this.height / 2));
                                                if (this.timeLeft > 3)
                                                {
                                                    this.timeLeft = 3;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 71)
                                        {
                                            this.noTileCollide = true;
                                            int num635 = 90;
                                            if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                                            {
                                                this.TargetClosest(false);
                                                this.direction = 1;
                                                this.netUpdate = true;
                                            }
                                            if (this.ai[0] == 0f)
                                            {
                                                this.ai[1] = this.ai[1] + 1f;
                                                int num636 = this.type;
                                                this.noGravity = true;
                                                this.dontTakeDamage = true;
                                                this.velocity.Y = this.ai[3];
                                                if (this.type == 373)
                                                {
                                                    float single454 = 0.104719758f;
                                                    float single455 = this.ai[2];
                                                    float single456 = (float)(Math.Cos((double)(single454 * this.localAI[1])) - 0.5) * single455;
                                                    this.position.X = this.position.X - single456 * (float)(-this.direction);
                                                    this.localAI[1] = this.localAI[1] + 1f;
                                                    single456 = (float)(Math.Cos((double)(single454 * this.localAI[1])) - 0.5) * single455;
                                                    this.position.X = this.position.X + single456 * (float)(-this.direction);
                                                    if (Math.Abs(Math.Cos((double)(single454 * this.localAI[1])) - 0.5) > 0.25)
                                                    {
                                                        this.spriteDirection = (Math.Cos((double)(single454 * this.localAI[1])) - 0.5 >= 0 ? -1 : 1);
                                                    }
                                                    this.rotation = this.velocity.Y * (float)this.spriteDirection * 0.1f;
                                                    if ((double)this.rotation < -0.2)
                                                    {
                                                        this.rotation = -0.2f;
                                                    }
                                                    if ((double)this.rotation > 0.2)
                                                    {
                                                        this.rotation = 0.2f;
                                                    }
                                                    NPC nPC217 = this;
                                                    nPC217.alpha = nPC217.alpha - 6;
                                                    if (this.alpha < 0)
                                                    {
                                                        this.alpha = 0;
                                                    }
                                                }
                                                if (this.ai[1] >= (float)num635)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = 0f;
                                                    if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        this.ai[1] = 1f;
                                                    }
                                                    this.TargetClosest(true);
                                                    this.spriteDirection = this.direction;
                                                    Vector2 center40 = Main.player[this.target].Center - base.Center;
                                                    center40.Normalize();
                                                    this.velocity = center40 * 16f;
                                                    this.rotation = this.velocity.ToRotation();
                                                    if (this.direction == -1)
                                                    {
                                                        this.rotation = this.rotation + 3.14159274f;
                                                    }
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 1f)
                                            {
                                                this.noGravity = true;
                                                if (Collision.SolidCollision(this.position, this.width, this.height))
                                                {
                                                    NPC nPC218 = this;
                                                    nPC218.alpha = nPC218.alpha - 15;
                                                    if (this.alpha < 150)
                                                    {
                                                        this.alpha = 150;
                                                    }
                                                }
                                                else if (this.ai[1] < 1f)
                                                {
                                                    this.ai[1] = 1f;
                                                }
                                                if (this.ai[1] >= 1f)
                                                {
                                                    NPC nPC219 = this;
                                                    nPC219.alpha = nPC219.alpha - 60;
                                                    if (this.alpha < 0)
                                                    {
                                                        this.alpha = 0;
                                                    }
                                                    this.dontTakeDamage = false;
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    if (Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 10);
                                                        this.active = false;
                                                        return;
                                                    }
                                                }
                                                if (this.ai[1] >= 60f)
                                                {
                                                    this.noGravity = false;
                                                }
                                                this.rotation = this.velocity.ToRotation();
                                                if (this.direction == -1)
                                                {
                                                    this.rotation = this.rotation + 3.14159274f;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 72)
                                        {
                                            if (this.type == 384)
                                            {
                                                int num637 = (int)this.ai[0];
                                                if (!Main.npc[num637].active || Main.npc[num637].type != 383)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10);
                                                    this.active = false;
                                                    return;
                                                }
                                                this.velocity = Vector2.Zero;
                                                this.position = Main.npc[num637].Center;
                                                this.position.X = this.position.X - (float)(this.width / 2);
                                                this.position.Y = this.position.Y - (float)(this.height / 2);
                                                this.gfxOffY = Main.npc[num637].gfxOffY;
                                                return;
                                            }
                                        }
                                        else if (this.aiStyle == 73)
                                        {
                                            this.TargetClosest(false);
                                            this.spriteDirection = this.direction;
                                            this.velocity.X = this.velocity.X * 0.93f;
                                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                            {
                                                this.velocity.X = 0f;
                                            }
                                            if (this.type == 387)
                                            {
                                                float single457 = 120f;
                                                float single458 = 60f;
                                                if (this.ai[1] < single457)
                                                {
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    if (this.ai[1] <= 60f)
                                                    {
                                                        this.alpha = 255;
                                                    }
                                                    else
                                                    {
                                                        float single459 = (this.ai[1] - single458) / (single457 - single458);
                                                        this.alpha = (int)((1f - single459) * 255f);
                                                    }
                                                    this.dontTakeDamage = true;
                                                    this.frameCounter = 0;
                                                    this.frame.Y = 0;
                                                    return;
                                                }
                                                this.dontTakeDamage = false;
                                            }
                                            if (this.ai[0] < 60f)
                                            {
                                                this.ai[0] = this.ai[0] + 1f;
                                            }
                                            if (this.justHit)
                                            {
                                                this.ai[0] = -30f;
                                            }
                                            if (this.ai[0] == 60f)
                                            {
                                                this.ai[0] = -120f;
                                                Vector2 center43 = Main.player[this.target].Center;
                                                Vector2 center44 = base.Center - (Vector2.UnitY * 10f);
                                                Vector2 unitY3 = center43 - center44;
                                                unitY3.X = unitY3.X + (float)Main.rand.Next(-100, 101);
                                                unitY3.Y = unitY3.Y + (float)Main.rand.Next(-100, 101);
                                                unitY3.X = unitY3.X * ((float)Main.rand.Next(70, 131) * 0.01f);
                                                unitY3.Y = unitY3.Y * ((float)Main.rand.Next(70, 131) * 0.01f);
                                                unitY3.Normalize();
                                                if (float.IsNaN(unitY3.X) || float.IsNaN(unitY3.Y))
                                                {
                                                    unitY3 = -Vector2.UnitY;
                                                }
                                                unitY3 = unitY3 * 14f;
                                                int num640 = 35;
                                                if (Main.expertMode && this.type >= 381 && this.type <= 392)
                                                {
                                                    num640 = (int)((double)num640 * 0.8);
                                                }
                                                Projectile.NewProjectile(center44.X, center44.Y, unitY3.X, unitY3.Y, 435, num640, 0f, Main.myPlayer, 0f, 0f);
                                                return;
                                            }
                                        }
                                        else if (this.aiStyle == 74)
                                        {
                                            this.TargetClosest(false);
                                            this.rotation = this.velocity.ToRotation();
                                            if (Math.Sign(this.velocity.X) != 0)
                                            {
                                                this.spriteDirection = -Math.Sign(this.velocity.X);
                                            }
                                            if (this.rotation < -1.57079637f)
                                            {
                                                NPC nPC220 = this;
                                                nPC220.rotation = nPC220.rotation + 3.14159274f;
                                            }
                                            if (this.rotation > 1.57079637f)
                                            {
                                                NPC nPC221 = this;
                                                nPC221.rotation = nPC221.rotation - 3.14159274f;
                                            }
                                            if (this.type == 418)
                                            {
                                                this.spriteDirection = Math.Sign(this.velocity.X);
                                            }
                                            float single462 = 0.4f;
                                            float single463 = 10f;
                                            float single464 = 200f;
                                            float single465 = 750f;
                                            float single466 = 30f;
                                            float single467 = 30f;
                                            float single468 = 0.95f;
                                            int num641 = 50;
                                            float single469 = 14f;
                                            float single470 = 30f;
                                            float single471 = 100f;
                                            float single472 = 20f;
                                            float single473 = 0f;
                                            float single474 = 7f;
                                            bool flag129 = true;
                                            if (this.type == 418)
                                            {
                                                single462 = 0.3f;
                                                single463 = 8f;
                                                single464 = 300f;
                                                single465 = 800f;
                                                single466 = 60f;
                                                single467 = 5f;
                                                single468 = 0.8f;
                                                num641 = 0;
                                                single469 = 10f;
                                                single470 = 30f;
                                                single471 = 150f;
                                                single472 = 60f;
                                                single473 = 0.333333343f;
                                                single474 = 8f;
                                                flag129 = false;
                                            }
                                            single473 = single473 * single472;
                                            if (Main.expertMode)
                                            {
                                                single462 = single462 * Main.expertKnockBack;
                                            }
                                            if (this.type == 418)
                                            {
                                            }
                                            if (this.ai[0] == 0f)
                                            {
                                                this.knockBackResist = single462;
                                                float single475 = single463;
                                                Vector2 center46 = base.Center;
                                                Vector2 center47 = Main.player[this.target].Center;
                                                Vector2 vector2218 = center47 - center46;
                                                Vector2 unitY4 = vector2218 - (Vector2.UnitY * single464);
                                                float single476 = vector2218.Length();
                                                vector2218 = Vector2.Normalize(vector2218) * single475;
                                                unitY4 = Vector2.Normalize(unitY4) * single475;
                                                bool flag130 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1);
                                                float single477 = 8f;
                                                flag130 = (!flag130 || vector2218.ToRotation() <= 3.14159274f / single477 ? false : vector2218.ToRotation() < 3.14159274f - 3.14159274f / single477);
                                                if (single476 > single465 || !flag130)
                                                {
                                                    this.velocity.X = (this.velocity.X * (single466 - 1f) + unitY4.X) / single466;
                                                    this.velocity.Y = (this.velocity.Y * (single466 - 1f) + unitY4.Y) / single466;
                                                }
                                                else
                                                {
                                                    this.ai[0] = 1f;
                                                    this.ai[2] = vector2218.X;
                                                    this.ai[3] = vector2218.Y;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            else if (this.ai[0] == 1f)
                                            {
                                                this.knockBackResist = 0f;
                                                NPC nPC222 = this;
                                                nPC222.velocity = nPC222.velocity * single468;
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= single467)
                                                {
                                                    this.ai[0] = 2f;
                                                    this.ai[1] = 0f;
                                                    this.netUpdate = true;
                                                    Vector2 vector2219 = new Vector2(this.ai[2], this.ai[3]) + (new Vector2((float)Main.rand.Next(-num641, num641 + 1), (float)Main.rand.Next(-num641, num641 + 1)) * 0.04f);
                                                    vector2219.Normalize();
                                                    vector2219 = vector2219 * single469;
                                                    this.velocity = vector2219;
                                                }
                                            }
                                            else if (this.ai[0] == 2f)
                                            {
                                                this.knockBackResist = 0f;
                                                float single478 = single470;
                                                this.ai[1] = this.ai[1] + 1f;
                                                bool flag131 = (Vector2.Distance(base.Center, Main.player[this.target].Center) <= single471 ? false : base.Center.Y > Main.player[this.target].Center.Y);
                                                if ((this.ai[1] < single478 || !flag131) && this.velocity.Length() >= single474)
                                                {
                                                    Vector2 center48 = base.Center;
                                                    Vector2 center49 = Main.player[this.target].Center;
                                                    Vector2 vector2221 = center49 - center48;
                                                    vector2221.Normalize();
                                                    if (vector2221.HasNaNs())
                                                    {
                                                        vector2221 = new Vector2((float)this.direction, 0f);
                                                    }
                                                    this.velocity = ((this.velocity * (single472 - 1f)) + (vector2221 * (this.velocity.Length() + single473))) / single472;
                                                }
                                                else
                                                {
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = 0f;
                                                    NPC nPC223 = this;
                                                    nPC223.velocity = nPC223.velocity / 2f;
                                                    this.netUpdate = true;
                                                    if (this.type == 418)
                                                    {
                                                        this.ai[1] = 45f;
                                                        this.ai[0] = 4f;
                                                    }
                                                }
                                                if (flag129 && Collision.SolidCollision(this.position, this.width, this.height))
                                                {
                                                    this.ai[0] = 3f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = 0f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            else if (this.ai[0] == 4f)
                                            {
                                                this.ai[1] = this.ai[1] - 3f;
                                                if (this.ai[1] <= 0f)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    this.netUpdate = true;
                                                }
                                                NPC nPC224 = this;
                                                nPC224.velocity = nPC224.velocity * 0.95f;
                                            }
                                            if (flag129 && this.ai[0] != 3f && Vector2.Distance(base.Center, Main.player[this.target].Center) < 64f)
                                            {
                                                this.ai[0] = 3f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] = 0f;
                                                this.netUpdate = true;
                                            }
                                            if (this.ai[0] == 3f)
                                            {
                                                this.position = base.Center;
                                                int num652 = 192;
                                                num6 = num652;
                                                this.height = num652;
                                                this.width = num6;
                                                this.position.X = this.position.X - (float)(this.width / 2);
                                                this.position.Y = this.position.Y - (float)(this.height / 2);
                                                this.velocity = Vector2.Zero;
                                                this.damage = (int)(80f * Main.damageMultiplier);
                                                this.alpha = 255;
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 3f)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10);
                                                    this.active = false;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 75)
                                        {
                                            int num663 = -1;
                                            Vector2 zero4 = Vector2.Zero;
                                            int num664 = 0;
                                            if (this.type == 390)
                                            {
                                                if (this.localAI[0] == 0f && Main.netMode != 1)
                                                {
                                                    this.localAI[0] = 1f;
                                                    int num665 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 391, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                    this.ai[0] = (float)num665;
                                                    this.netUpdate = true;
                                                }
                                                int num666 = (int)this.ai[0];
                                                if (Main.npc[num666].active && Main.npc[num666].type == 391)
                                                {
                                                    if (this.timeLeft < 60)
                                                    {
                                                        this.timeLeft = 60;
                                                    }
                                                    num663 = num666;
                                                    zero4 = Vector2.UnitY * -14f;
                                                }
                                            }
                                            if (this.type == 416)
                                            {
                                                if (this.localAI[0] == 0f && Main.netMode != 1)
                                                {
                                                    this.localAI[0] = 1f;
                                                    int num667 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 415, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                    this.ai[0] = (float)num667;
                                                    this.netUpdate = true;
                                                }
                                                int num668 = (int)this.ai[0];
                                                if (Main.npc[num668].active && Main.npc[num668].type == 415)
                                                {
                                                    if (this.timeLeft < 60)
                                                    {
                                                        this.timeLeft = 60;
                                                    }
                                                    num663 = num668;
                                                    zero4 = new Vector2((float)(-Main.npc[num668].spriteDirection * 10), -30f);
                                                }
                                            }
                                            else if (this.type == 392)
                                            {
                                                int num669 = (int)this.ai[0];
                                                if (Main.npc[num669].active && Main.npc[num669].type == 395)
                                                {
                                                    if (this.timeLeft < 60)
                                                    {
                                                        this.timeLeft = 60;
                                                    }
                                                    num663 = num669;
                                                    zero4 = Vector2.UnitY * 2f;
                                                    zero4 = zero4 * Main.npc[num669].scale;
                                                    float single479 = Main.npc[num669].rotation;
                                                    double num670 = (double)single479;
                                                    vector24 = new Vector2();
                                                    zero4 = zero4.RotatedBy(num670, vector24);
                                                    this.rotation = single479;
                                                    if (Main.netMode != 1)
                                                    {
                                                        bool flag132 = true;
                                                        if (Main.npc[num669].ai[0] >= 1f || Main.npc[num669].ai[0] < 0f)
                                                        {
                                                            flag132 = false;
                                                        }
                                                        if (flag132)
                                                        {
                                                            for (int n5 = 0; n5 < 2; n5++)
                                                            {
                                                                if (Main.npc[(int)this.localAI[n5]].active && Main.npc[(int)this.localAI[n5]].type == 393)
                                                                {
                                                                    flag132 = false;
                                                                }
                                                            }
                                                            for (int o5 = 2; o5 < 4; o5++)
                                                            {
                                                                if (Main.npc[(int)this.localAI[o5]].active && Main.npc[(int)this.localAI[o5]].type == 394)
                                                                {
                                                                    flag132 = false;
                                                                }
                                                            }
                                                        }
                                                        if (flag132)
                                                        {
                                                            Main.npc[num669].ai[0] = 1f;
                                                            Main.npc[num669].ai[1] = 0f;
                                                            Main.npc[num669].ai[2] = 0f;
                                                            Main.npc[num669].ai[3] = 0f;
                                                            Main.npc[num669].netUpdate = true;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (this.type == 393)
                                            {
                                                int num671 = (int)this.ai[0];
                                                if (Main.npc[num671].active && Main.npc[num671].type == 395)
                                                {
                                                    if (this.timeLeft < 60)
                                                    {
                                                        this.timeLeft = 60;
                                                    }
                                                    num663 = num671;
                                                    zero4 = (Vector2.UnitY * 29f) + ((this.ai[1] == 1f ? Vector2.UnitX : -Vector2.UnitX) * 60f);
                                                    zero4 = zero4 * Main.npc[num671].scale;
                                                    float single480 = Main.npc[num671].rotation;
                                                    double num672 = (double)single480;
                                                    vector24 = new Vector2();
                                                    zero4 = zero4.RotatedBy(num672, vector24);
                                                    this.rotation = single480;
                                                }
                                            }
                                            else if (this.type == 394)
                                            {
                                                int num673 = (int)this.ai[0];
                                                if (Main.npc[num673].active && Main.npc[num673].type == 395)
                                                {
                                                    if (this.timeLeft < 60)
                                                    {
                                                        this.timeLeft = 60;
                                                    }
                                                    num663 = num673;
                                                    zero4 = (Vector2.UnitY * -13f) + ((this.ai[1] == 1f ? Vector2.UnitX : -Vector2.UnitX) * 49f);
                                                    zero4 = zero4 * Main.npc[num673].scale;
                                                    float single481 = Main.npc[num673].rotation;
                                                    double num674 = (double)single481;
                                                    vector24 = new Vector2();
                                                    zero4 = zero4.RotatedBy(num674, vector24);
                                                    this.rotation = single481;
                                                    num664 = (this.ai[1] == 1f ? 1 : -1);
                                                }
                                            }
                                            else if (this.type == 492)
                                            {
                                                int num675 = (int)this.ai[0];
                                                if (Main.npc[num675].active && Main.npc[num675].type == 491)
                                                {
                                                    if (this.timeLeft < 60)
                                                    {
                                                        this.timeLeft = 60;
                                                    }
                                                    num663 = num675;
                                                    zero4 = new Vector2((-122f + 68f * this.ai[1]) * (float)((Main.npc[num675].spriteDirection == 1 ? -1 : 1)), -6f);
                                                    zero4 = zero4 * Main.npc[num675].scale;
                                                    float single482 = Main.npc[num675].rotation;
                                                    double num676 = (double)single482;
                                                    vector24 = new Vector2();
                                                    zero4 = zero4.RotatedBy(num676, vector24);
                                                    this.rotation = single482;
                                                }
                                            }
                                            if (num663 == -1)
                                            {
                                                if (this.type == 390)
                                                {
                                                    this.Transform(382);
                                                    return;
                                                }
                                                if (this.type == 416)
                                                {
                                                    this.Transform(518);
                                                    return;
                                                }
                                                this.life = 0;
                                                this.HitEffect(0, 10);
                                                this.active = false;
                                                return;
                                            }
                                            NPC nPC225 = Main.npc[num663];
                                            this.velocity = Vector2.Zero;
                                            this.position = nPC225.Center;
                                            this.position.X = this.position.X - (float)(this.width / 2);
                                            this.position.Y = this.position.Y - (float)(this.height / 2);
                                            NPC nPC226 = this;
                                            nPC226.position = nPC226.position + zero4;
                                            this.gfxOffY = nPC225.gfxOffY;
                                            this.direction = nPC225.direction;
                                            if (num664 != 0)
                                            {
                                                this.spriteDirection = num664;
                                            }
                                            else
                                            {
                                                this.spriteDirection = nPC225.spriteDirection;
                                            }
                                            if (this.type == 390)
                                            {
                                                this.timeLeft = nPC225.timeLeft;
                                                this.velocity = nPC225.velocity;
                                                this.target = nPC225.target;
                                                if (this.ai[1] < 60f)
                                                {
                                                    this.ai[1] = this.ai[1] + 1f;
                                                }
                                                if (this.justHit)
                                                {
                                                    this.ai[1] = -30f;
                                                }
                                                int num677 = 438;
                                                int num678 = 30;
                                                float single483 = 7f;
                                                if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                                {
                                                    Vector2 center50 = Main.player[this.target].Center - base.Center;
                                                    Vector2 vector2226 = Vector2.Normalize(center50);
                                                    float single484 = center50.Length();
                                                    float single485 = 700f;
                                                    if (this.type == 214)
                                                    {
                                                        single485 = 550f;
                                                    }
                                                    if (this.type == 215)
                                                    {
                                                        single485 = 800f;
                                                    }
                                                    if (single484 < single485)
                                                    {
                                                        if (this.ai[1] != 60f || Math.Sign(center50.X) != this.direction)
                                                        {
                                                            float single486 = this.ai[2];
                                                            this.velocity.X = this.velocity.X * 0.5f;
                                                            this.ai[2] = 3f;
                                                            if (Math.Abs(vector2226.Y) > Math.Abs(vector2226.X) * 2f)
                                                            {
                                                                if (vector2226.Y <= 0f)
                                                                {
                                                                    this.ai[2] = 5f;
                                                                }
                                                                else
                                                                {
                                                                    this.ai[2] = 1f;
                                                                }
                                                            }
                                                            else if (Math.Abs(vector2226.X) > Math.Abs(vector2226.Y) * 2f)
                                                            {
                                                                this.ai[2] = 3f;
                                                            }
                                                            else if (vector2226.Y <= 0f)
                                                            {
                                                                this.ai[2] = 4f;
                                                            }
                                                            else
                                                            {
                                                                this.ai[2] = 2f;
                                                            }
                                                            if (this.ai[2] != single486)
                                                            {
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            this.ai[1] = -60f;
                                                            Vector2 center51 = Main.player[this.target].Center;
                                                            Vector2 center52 = base.Center - (Vector2.UnitY * 4f);
                                                            Vector2 unitY5 = center51 - center52;
                                                            unitY5.X = unitY5.X + (float)Main.rand.Next(-50, 51);
                                                            unitY5.Y = unitY5.Y + (float)Main.rand.Next(-50, 51);
                                                            unitY5.X = unitY5.X * ((float)Main.rand.Next(80, 121) * 0.01f);
                                                            unitY5.Y = unitY5.Y * ((float)Main.rand.Next(80, 121) * 0.01f);
                                                            unitY5.Normalize();
                                                            if (float.IsNaN(unitY5.X) || float.IsNaN(unitY5.Y))
                                                            {
                                                                unitY5 = -Vector2.UnitY;
                                                            }
                                                            unitY5 = unitY5 * single483;
                                                            Projectile.NewProjectile(center52.X, center52.Y, unitY5.X, unitY5.Y, num677, num678, 0f, Main.myPlayer, 0f, 0f);
                                                            this.netUpdate = true;
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.type == 492)
                                            {
                                                this.timeLeft = nPC225.timeLeft;
                                                this.velocity = nPC225.velocity;
                                                if (this.ai[3] < 240f)
                                                {
                                                    this.ai[3] = this.ai[3] + 1f;
                                                }
                                                if (this.ai[3] == 2f)
                                                {
                                                    this.TargetClosest(false);
                                                }
                                                if (!Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                                {
                                                    if (this.ai[2] != 0f)
                                                    {
                                                        this.netUpdate = true;
                                                    }
                                                    this.ai[2] = 0f;
                                                }
                                                else
                                                {
                                                    Vector2 center53 = Main.player[this.target].Center - base.Center;
                                                    Vector2.Normalize(center53);
                                                    if (this.ai[3] < 240f)
                                                    {
                                                        float single487 = this.ai[2];
                                                        float[] singleArray13 = new float[8];
                                                        for (int p5 = 0; p5 < (int)singleArray13.Length; p5++)
                                                        {
                                                            Vector2 center54 = base.Center;
                                                            Vector2 unitY6 = Vector2.UnitY;
                                                            double num679 = (double)((float)p5 * -0.7853982f);
                                                            vector24 = new Vector2();
                                                            singleArray13[p5] = Vector2.Distance(center54 + (unitY6.RotatedBy(num679, vector24) * 50f), Main.player[this.target].Center);
                                                        }
                                                        int num680 = 0;
                                                        for (int q5 = 1; q5 < (int)singleArray13.Length; q5++)
                                                        {
                                                            if (singleArray13[num680] > singleArray13[q5])
                                                            {
                                                                num680 = q5;
                                                            }
                                                        }
                                                        this.ai[2] = (float)(num680 + 1);
                                                        if (this.spriteDirection == 1)
                                                        {
                                                            this.ai[2] = 9f - this.ai[2];
                                                        }
                                                        if (this.ai[2] != single487)
                                                        {
                                                            this.netUpdate = true;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.ai[3] = 0f;
                                                        Vector2 center55 = Main.player[this.target].Center;
                                                        Vector2 center56 = base.Center;
                                                        Vector2 unitY7 = Vector2.Normalize(center55 - center56);
                                                        if (float.IsNaN(unitY7.X) || float.IsNaN(unitY7.Y))
                                                        {
                                                            unitY7 = Vector2.UnitY;
                                                        }
                                                        unitY7 = unitY7 * 14f;
                                                        unitY7 = unitY7 + (Vector2.UnitY * -5f);
                                                        if (Main.netMode != 1)
                                                        {
                                                            Projectile.NewProjectile(center56.X, center56.Y, unitY7.X, unitY7.Y, 240, 30, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                        this.netUpdate = true;
                                                    }
                                                }
                                            }
                                            if (this.type == 394)
                                            {
                                                this.timeLeft = nPC225.timeLeft;
                                                int num681 = 50;
                                                if (Main.expertMode)
                                                {
                                                    num681 = 37;
                                                }
                                                this.ai[3] = nPC225.ai[3];
                                                float single488 = 440f;
                                                float single489 = 140f;
                                                if (this.ai[3] >= single488 && this.ai[3] < single488 + single489 && (this.ai[3] - single488) % 20f == 0f)
                                                {
                                                    if (Main.netMode != 1)
                                                    {
                                                        Vector2 unitX2 = (float)num664 * Vector2.UnitX;
                                                        vector24 = new Vector2();
                                                        unitX2 = unitX2.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.785398185253143, vector24);
                                                        unitX2 = unitX2 * 8f;
                                                        Vector2 unitX3 = ((((float)num664 * Vector2.UnitX) * 36f) + base.Center) + (Vector2.UnitY * 8f);
                                                        Projectile.NewProjectile(unitX3.X, unitX3.Y, unitX2.X, unitX2.Y, 448, num681, 0f, Main.myPlayer, 0f, 20f);
                                                    }
                                                }
                                            }
                                            if (this.type == 393)
                                            {
                                                this.timeLeft = nPC225.timeLeft;
                                                int num682 = 35;
                                                if (Main.expertMode)
                                                {
                                                    num682 = 30;
                                                }
                                                this.ai[3] = nPC225.ai[3];
                                                float single490 = 280f;
                                                float single491 = 140f;
                                                bool flag133 = (this.ai[3] < single490 ? false : this.ai[3] < single490 + single491);
                                                if (!flag133)
                                                {
                                                    this.TargetClosest(false);
                                                    Player player6 = Main.player[this.target];
                                                    Vector2 unitY8 = player6.Center - base.Center;
                                                    if (unitY8.Y < 0f)
                                                    {
                                                        unitY8.Y = 0f;
                                                    }
                                                    unitY8.Normalize();
                                                    if (float.IsNaN(unitY8.X) || float.IsNaN(unitY8.Y))
                                                    {
                                                        unitY8 = Vector2.UnitY;
                                                    }
                                                    this.ai[2] = unitY8.ToRotation();
                                                }
                                                if (flag133 && (this.ai[3] - single490) % 6f == 0f)
                                                {
                                                    if (Main.netMode != 1)
                                                    {
                                                        Vector2 rotationVector25 = this.ai[2].ToRotationVector2();
                                                        double num683 = (Main.rand.NextDouble() - 0.5) * 0.785398185253143 / 3;
                                                        vector24 = new Vector2();
                                                        rotationVector25 = rotationVector25.RotatedBy(num683, vector24);
                                                        rotationVector25 = rotationVector25 * 16f;
                                                        Vector2 center57 = base.Center + (rotationVector25 * 1f);
                                                        Projectile.NewProjectile(center57.X, center57.Y, rotationVector25.X, rotationVector25.Y, 449, num682, 0f, Main.myPlayer, 0f, 0f);
                                                    }
                                                }
                                            }
                                            if (this.type == 392)
                                            {
                                                this.timeLeft = nPC225.timeLeft;
                                                int num684 = 70;
                                                if (Main.expertMode)
                                                {
                                                    num684 = 50;
                                                }
                                                this.ai[3] = nPC225.ai[3];
                                                float single492 = 20f;
                                                float single493 = 240f;
                                                bool flag134 = (this.ai[3] < single492 || this.ai[3] >= single492 + single493 ? false : nPC225.ai[0] == 0f);
                                                if (flag134 && this.ai[3] - single492 == 0f)
                                                {
                                                    if (Main.netMode != 1)
                                                    {
                                                        Vector2 center58 = base.Center;
                                                        Projectile.NewProjectile(center58.X, center58.Y, 0f, 0f, 447, num684, 0f, Main.myPlayer, (float)(this.whoAmI + 1), 0f);
                                                    }
                                                }
                                                flag134 = false;
                                                int num685 = 1000;
                                                int num686 = 1000;
                                                int num687 = 450;
                                                int num688 = 30;
                                                if (Main.expertMode)
                                                {
                                                    num688 = 25;
                                                }
                                                if (nPC225.ai[0] == 2f)
                                                {
                                                    flag134 = true;
                                                    num686 = 120;
                                                    num685 = 120;
                                                }
                                                if (!flag134)
                                                {
                                                    single492 = 280f;
                                                    single493 = 120f;
                                                    if (flag134)
                                                    {
                                                        flag3 = true;
                                                    }
                                                    else
                                                    {
                                                        flag3 = (this.ai[3] < single492 ? false : this.ai[3] < single492 + single493);
                                                    }
                                                    flag134 = flag3;
                                                    if (flag134)
                                                    {
                                                        num686 = 90;
                                                        num685 = 60;
                                                    }
                                                }
                                                if (!flag134)
                                                {
                                                    single492 = 440f;
                                                    single493 = 140f;
                                                    if (flag134)
                                                    {
                                                        flag2 = true;
                                                    }
                                                    else
                                                    {
                                                        flag2 = (this.ai[3] < single492 ? false : this.ai[3] < single492 + single493);
                                                    }
                                                    flag134 = flag2;
                                                    if (flag134)
                                                    {
                                                        num686 = 60;
                                                        num685 = 90;
                                                    }
                                                }
                                                bool flag135 = true;
                                                bool flag136 = true;
                                                bool flag137 = true;
                                                bool flag138 = true;
                                                if (Main.npc[(int)this.localAI[0]].active && Main.npc[(int)this.localAI[0]].type == 393)
                                                {
                                                    flag135 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[1]].active && Main.npc[(int)this.localAI[1]].type == 393)
                                                {
                                                    flag136 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[2]].active && Main.npc[(int)this.localAI[2]].type == 394)
                                                {
                                                    flag137 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[3]].active && Main.npc[(int)this.localAI[3]].type == 394)
                                                {
                                                    flag138 = false;
                                                }
                                                if (flag134)
                                                {
                                                    if (flag135 && Main.rand.Next(num685) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 vector2227 = new Vector2(-1f * (float)Main.rand.NextDouble() * 3f, 1f);
                                                            vector24 = new Vector2();
                                                            vector2227 = vector2227.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.785398185253143, vector24);
                                                            vector2227 = vector2227 * 3f;
                                                            Vector2 unitX4 = (((-1f * Vector2.UnitX) * (float)Main.rand.Next(50, 70)) + base.Center) + (Vector2.UnitY * (float)Main.rand.Next(30, 45));
                                                            Projectile.NewProjectile(unitX4.X, unitX4.Y, vector2227.X, vector2227.Y, num687, num688, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                    if (flag136 && Main.rand.Next(num685) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 vector2228 = new Vector2(1f * (float)Main.rand.NextDouble() * 3f, 1f);
                                                            vector24 = new Vector2();
                                                            vector2228 = vector2228.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.785398185253143, vector24);
                                                            vector2228 = vector2228 * 3f;
                                                            Vector2 unitX5 = (((1f * Vector2.UnitX) * (float)Main.rand.Next(50, 70)) + base.Center) + (Vector2.UnitY * (float)Main.rand.Next(30, 45));
                                                            Projectile.NewProjectile(unitX5.X, unitX5.Y, vector2228.X, vector2228.Y, num687, num688, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                }
                                                if (flag134)
                                                {
                                                    if (flag137 && Main.rand.Next(num686) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 vector2229 = new Vector2(-1f * (float)Main.rand.NextDouble() * 2f, -1f);
                                                            vector24 = new Vector2();
                                                            vector2229 = vector2229.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.785398185253143, vector24);
                                                            vector2229 = vector2229 * 3f;
                                                            Vector2 unitX6 = (((-1f * Vector2.UnitX) * (float)Main.rand.Next(30, 60)) + base.Center) + (Vector2.UnitY * (float)Main.rand.Next(-30, -10));
                                                            Projectile.NewProjectile(unitX6.X, unitX6.Y, vector2229.X, vector2229.Y, num687, num688, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                    if (flag138 && Main.rand.Next(num686) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 vector2230 = new Vector2(1f * (float)Main.rand.NextDouble() * 2f, -1f);
                                                            vector24 = new Vector2();
                                                            vector2230 = vector2230.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.785398185253143, vector24);
                                                            vector2230 = vector2230 * 3f;
                                                            Vector2 unitX7 = (((1f * Vector2.UnitX) * (float)Main.rand.Next(30, 60)) + base.Center) + (Vector2.UnitY * (float)Main.rand.Next(-30, -10));
                                                            Projectile.NewProjectile(unitX7.X, unitX7.Y, vector2230.X, vector2230.Y, num687, num688, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                }
                                                if (flag138 && Main.rand.Next(8) == 0)
                                                {
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 76)
                                        {
                                            if (this.localAI[3] == 0f && Main.netMode != 1 && this.type == 395)
                                            {
                                                this.localAI[3] = 1f;
                                                int[] numArray3 = new int[4];
                                                int num693 = 0;
                                                for (int r5 = 0; r5 < 2; r5++)
                                                {
                                                    int num694 = NPC.NewNPC((int)base.Center.X + r5 * 300 - 150, (int)base.Center.Y, 393, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                    Main.npc[num694].ai[1] = (float)r5;
                                                    Main.npc[num694].netUpdate = true;
                                                    int num695 = num693;
                                                    num693 = num695 + 1;
                                                    numArray3[num695] = num694;
                                                }
                                                for (int s5 = 0; s5 < 2; s5++)
                                                {
                                                    int num696 = NPC.NewNPC((int)base.Center.X + s5 * 300 - 150, (int)base.Center.Y, 394, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                    Main.npc[num696].ai[1] = (float)s5;
                                                    Main.npc[num696].netUpdate = true;
                                                    int num697 = num693;
                                                    num693 = num697 + 1;
                                                    numArray3[num697] = num696;
                                                }
                                                int num698 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 392, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                Main.npc[num698].ai[0] = (float)this.whoAmI;
                                                Main.npc[num698].netUpdate = true;
                                                for (int t5 = 0; t5 < 4; t5++)
                                                {
                                                    Main.npc[numArray3[t5]].ai[0] = (float)this.whoAmI;
                                                }
                                                for (int u5 = 0; u5 < 4; u5++)
                                                {
                                                    Main.npc[num698].localAI[u5] = (float)numArray3[u5];
                                                }
                                            }
                                            Vector2 center59 = base.Center;
                                            Player player7 = Main.player[this.target];
                                            if (this.target < 0 || this.target == 255 || player7.dead || !player7.active)
                                            {
                                                this.TargetClosest(true);
                                                player7 = Main.player[this.target];
                                                this.netUpdate = true;
                                            }
                                            if ((player7.dead || Vector2.Distance(player7.Center, center59) > 3200f) && this.ai[0] != 1f)
                                            {
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.ai[0] = -1f;
                                                }
                                                if (this.ai[0] == 2f)
                                                {
                                                    this.ai[0] = -2f;
                                                }
                                                this.netUpdate = true;
                                            }
                                            if (this.ai[0] == -1f || this.ai[0] == -2f)
                                            {
                                                this.velocity.Y = this.velocity.Y - 0.4f;
                                                if (this.timeLeft > 10)
                                                {
                                                    this.timeLeft = 10;
                                                }
                                                if (!player7.dead)
                                                {
                                                    this.timeLeft = 300;
                                                    if (this.ai[0] == -2f)
                                                    {
                                                        this.ai[0] = 2f;
                                                    }
                                                    if (this.ai[0] == 0f)
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] != 0f)
                                            {
                                                if (this.ai[0] == 1f)
                                                {
                                                    this.dontTakeDamage = false;
                                                    NPC nPC227 = this;
                                                    nPC227.velocity = nPC227.velocity * 0.96f;
                                                    float single494 = 150f;
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    if (this.ai[1] >= single494)
                                                    {
                                                        this.ai[0] = 2f;
                                                        this.ai[1] = 0f;
                                                        this.rotation = 0f;
                                                        this.netUpdate = true;
                                                        return;
                                                    }
                                                    if (this.ai[1] < 40f)
                                                    {
                                                        Vector2 unitY9 = Vector2.UnitY;
                                                        double num699 = (double)(this.ai[1] / 40f * 6.28318548f);
                                                        vector24 = new Vector2();
                                                        this.rotation = unitY9.RotatedBy(num699, vector24).Y * 0.2f;
                                                        return;
                                                    }
                                                    if (this.ai[1] < 80f)
                                                    {
                                                        Vector2 unitY10 = Vector2.UnitY;
                                                        double num700 = (double)(this.ai[1] / 20f * 6.28318548f);
                                                        vector24 = new Vector2();
                                                        this.rotation = unitY10.RotatedBy(num700, vector24).Y * 0.3f;
                                                        return;
                                                    }
                                                    if (this.ai[1] >= 120f)
                                                    {
                                                        this.rotation = (this.ai[1] - 120f) / 30f * 6.28318548f;
                                                        return;
                                                    }
                                                    Vector2 unitY11 = Vector2.UnitY;
                                                    double num701 = (double)(this.ai[1] / 10f * 6.28318548f);
                                                    vector24 = new Vector2();
                                                    this.rotation = unitY11.RotatedBy(num701, vector24).Y * 0.4f;
                                                    return;
                                                }
                                                if (this.ai[0] == 2f)
                                                {
                                                    int num702 = 100;
                                                    float single495 = 3600f;
                                                    float single496 = 120f;
                                                    float single497 = 60f;
                                                    int num703 = 0;
                                                    if (this.ai[3] % single496 >= single497)
                                                    {
                                                        num703 = 1;
                                                    }
                                                    int num704 = num703;
                                                    num703 = 0;
                                                    this.ai[3] = this.ai[3] + 1f;
                                                    if (this.ai[3] % single496 >= single497)
                                                    {
                                                        num703 = 1;
                                                    }
                                                    if (num703 != num704)
                                                    {
                                                        if (num703 == 1)
                                                        {
                                                            this.ai[2] = (float)((Math.Sign((player7.Center - center59).X) == 1 ? 1 : -1));
                                                            if (Main.netMode != 1)
                                                            {
                                                                Vector2 center60 = base.Center;
                                                                Projectile.NewProjectile(center60.X, center60.Y, 0f, 0f, 447, num702, 0f, Main.myPlayer, (float)(this.whoAmI + 1), 0f);
                                                            }
                                                        }
                                                        this.netUpdate = true;
                                                    }
                                                    if (this.ai[3] >= single495)
                                                    {
                                                        this.ai[0] = 2f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                        this.netUpdate = true;
                                                    }
                                                    else if (num703 != 0)
                                                    {
                                                        int x203 = (int)base.Center.X / 16;
                                                        int y206 = (int)(this.position.Y + (float)this.height) / 16;
                                                        int num705 = 0;
                                                        if ((!Main.tile[x203, y206].nactive() || !Main.tileSolid[Main.tile[x203, y206].type] ? true : Main.tileSolidTop[Main.tile[x203, y206].type]))
                                                        {
                                                            while (num705 < 150 && y206 + num705 < Main.maxTilesY)
                                                            {
                                                                int num706 = y206 + num705;
                                                                if ((!Main.tile[x203, num706].nactive() || !Main.tileSolid[Main.tile[x203, num706].type] ? true : Main.tileSolidTop[Main.tile[x203, num706].type]))
                                                                {
                                                                    num705++;
                                                                }
                                                                else
                                                                {
                                                                    num705--;
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            num705 = 1;
                                                        }
                                                        float single498 = (float)(num705 * 16);
                                                        if (single498 >= 250f)
                                                        {
                                                            this.velocity.Y = this.velocity.Y * 0.95f;
                                                        }
                                                        else
                                                        {
                                                            float single499 = -4f;
                                                            if (-single499 > single498)
                                                            {
                                                                single499 = -single498;
                                                            }
                                                            this.velocity.Y = MathHelper.Lerp(this.velocity.Y, single499, 0.05f);
                                                        }
                                                        this.velocity.X = 8f * this.ai[2];
                                                    }
                                                    else
                                                    {
                                                        Vector2 center61 = (player7.Center + new Vector2(this.ai[2] * 350f, -250f)) - center59;
                                                        center61.Normalize();
                                                        this.velocity = Vector2.Lerp(this.velocity, center61 * 16f, 0.1f);
                                                    }
                                                    this.rotation = 0f;
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                int num707 = 0;
                                                int num708 = 0;
                                                if (this.ai[3] >= 580f)
                                                {
                                                    num707 = 0;
                                                }
                                                else if (this.ai[3] >= 440f)
                                                {
                                                    num707 = 5;
                                                }
                                                else if (this.ai[3] >= 420f)
                                                {
                                                    num707 = 4;
                                                }
                                                else if (this.ai[3] >= 280f)
                                                {
                                                    num707 = 3;
                                                }
                                                else if (this.ai[3] >= 260f)
                                                {
                                                    num707 = 2;
                                                }
                                                else if (this.ai[3] >= 20f)
                                                {
                                                    num707 = 1;
                                                }
                                                this.ai[3] = this.ai[3] + 1f;
                                                if (this.ai[3] >= 600f)
                                                {
                                                    this.ai[3] = 0f;
                                                }
                                                num708 = num707;
                                                if (this.ai[3] >= 580f)
                                                {
                                                    num707 = 0;
                                                }
                                                else if (this.ai[3] >= 440f)
                                                {
                                                    num707 = 5;
                                                }
                                                else if (this.ai[3] >= 420f)
                                                {
                                                    num707 = 4;
                                                }
                                                else if (this.ai[3] >= 280f)
                                                {
                                                    num707 = 3;
                                                }
                                                else if (this.ai[3] >= 260f)
                                                {
                                                    num707 = 2;
                                                }
                                                else if (this.ai[3] >= 20f)
                                                {
                                                    num707 = 1;
                                                }
                                                if (num707 != num708)
                                                {
                                                    if (num707 == 0)
                                                    {
                                                        this.ai[2] = 0f;
                                                    }
                                                    if (num707 == 1)
                                                    {
                                                        this.ai[2] = (float)((Math.Sign((player7.Center - center59).X) == 1 ? 1 : -1));
                                                    }
                                                    if (num707 == 2)
                                                    {
                                                        this.ai[2] = 0f;
                                                    }
                                                    this.netUpdate = true;
                                                }
                                                if (num707 == 0)
                                                {
                                                    if (this.ai[2] == 0f)
                                                    {
                                                        this.ai[2] = (float)(-600 * Math.Sign((center59 - player7.Center).X));
                                                    }
                                                    Vector2 center62 = (player7.Center + new Vector2(this.ai[2], -250f)) - center59;
                                                    if (center62.Length() >= 50f)
                                                    {
                                                        center62.Normalize();
                                                        this.velocity = Vector2.Lerp(this.velocity, center62 * 16f, 0.1f);
                                                    }
                                                    else
                                                    {
                                                        this.ai[3] = 19f;
                                                    }
                                                }
                                                if (num707 == 1)
                                                {
                                                    int x204 = (int)base.Center.X / 16;
                                                    int y207 = (int)(this.position.Y + (float)this.height) / 16;
                                                    int num709 = 0;
                                                    if ((!Main.tile[x204, y207].nactive() || !Main.tileSolid[Main.tile[x204, y207].type] ? true : Main.tileSolidTop[Main.tile[x204, y207].type]))
                                                    {
                                                        while (num709 < 150 && y207 + num709 < Main.maxTilesY)
                                                        {
                                                            int num710 = y207 + num709;
                                                            if ((!Main.tile[x204, num710].nactive() || !Main.tileSolid[Main.tile[x204, num710].type] ? true : Main.tileSolidTop[Main.tile[x204, num710].type]))
                                                            {
                                                                num709++;
                                                            }
                                                            else
                                                            {
                                                                num709--;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        num709 = 1;
                                                    }
                                                    float single500 = (float)(num709 * 16);
                                                    if (single500 >= 250f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.95f;
                                                    }
                                                    else
                                                    {
                                                        float single501 = -4f;
                                                        if (-single501 > single500)
                                                        {
                                                            single501 = -single500;
                                                        }
                                                        this.velocity.Y = MathHelper.Lerp(this.velocity.Y, single501, 0.05f);
                                                    }
                                                    this.velocity.X = 3.5f * this.ai[2];
                                                }
                                                if (num707 == 2)
                                                {
                                                    if (this.ai[2] == 0f)
                                                    {
                                                        this.ai[2] = (float)(300 * Math.Sign((center59 - player7.Center).X));
                                                    }
                                                    Vector2 center63 = (player7.Center + new Vector2(this.ai[2], -170f)) - center59;
                                                    int x205 = (int)base.Center.X / 16;
                                                    int y208 = (int)(this.position.Y + (float)this.height) / 16;
                                                    int num711 = 0;
                                                    if ((!Main.tile[x205, y208].nactive() || !Main.tileSolid[Main.tile[x205, y208].type] ? true : Main.tileSolidTop[Main.tile[x205, y208].type]))
                                                    {
                                                        while (num711 < 150 && y208 + num711 < Main.maxTilesY)
                                                        {
                                                            int num712 = y208 + num711;
                                                            if ((!Main.tile[x205, num712].nactive() || !Main.tileSolid[Main.tile[x205, num712].type] ? true : Main.tileSolidTop[Main.tile[x205, num712].type]))
                                                            {
                                                                num711++;
                                                            }
                                                            else
                                                            {
                                                                num711--;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        num711 = 1;
                                                    }
                                                    float single502 = (float)(num711 * 16);
                                                    float single503 = 170f;
                                                    if (single502 < single503)
                                                    {
                                                        center63.Y = center63.Y - (single503 - single502);
                                                    }
                                                    if (center63.Length() >= 70f)
                                                    {
                                                        center63.Normalize();
                                                        this.velocity = Vector2.Lerp(this.velocity, center63 * 20f, 0.1f);
                                                    }
                                                    else
                                                    {
                                                        this.ai[3] = 279f;
                                                    }
                                                }
                                                else if (num707 == 3)
                                                {
                                                    float single504 = 0.85f;
                                                    int x206 = (int)base.Center.X / 16;
                                                    int y209 = (int)(this.position.Y + (float)this.height) / 16;
                                                    int num713 = 0;
                                                    if ((!Main.tile[x206, y209].nactive() || !Main.tileSolid[Main.tile[x206, y209].type] ? true : Main.tileSolidTop[Main.tile[x206, y209].type]))
                                                    {
                                                        while (num713 < 150 && y209 + num713 < Main.maxTilesY)
                                                        {
                                                            int num714 = y209 + num713;
                                                            if ((!Main.tile[x206, num714].nactive() || !Main.tileSolid[Main.tile[x206, num714].type] ? true : Main.tileSolidTop[Main.tile[x206, num714].type]))
                                                            {
                                                                num713++;
                                                            }
                                                            else
                                                            {
                                                                num713--;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        num713 = 1;
                                                    }
                                                    float single505 = (float)(num713 * 16);
                                                    if (single505 >= 170f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * single504;
                                                    }
                                                    else
                                                    {
                                                        float single506 = -4f;
                                                        if (-single506 > single505)
                                                        {
                                                            single506 = -single505;
                                                        }
                                                        this.velocity.Y = MathHelper.Lerp(this.velocity.Y, single506, 0.05f);
                                                    }
                                                    this.velocity.X = this.velocity.X * single504;
                                                }
                                                if (num707 == 4)
                                                {
                                                    Vector2 center64 = (player7.Center + new Vector2(0f, -250f)) - center59;
                                                    if (center64.Length() < 50f)
                                                    {
                                                        this.ai[3] = 439f;
                                                        return;
                                                    }
                                                    center64.Normalize();
                                                    this.velocity = Vector2.Lerp(this.velocity, center64 * 16f, 0.1f);
                                                    return;
                                                }
                                                if (num707 == 5)
                                                {
                                                    NPC nPC228 = this;
                                                    nPC228.velocity = nPC228.velocity * 0.85f;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 77)
                                        {
                                            if (this.localAI[3] == 0f)
                                            {
                                                this.netUpdate = true;
                                                this.localAI[3] = 1f;
                                                this.ai[0] = -1f;
                                            }
                                            if (this.ai[0] == -1f)
                                            {
                                                this.dontTakeDamage = true;
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] < 60f)
                                                {
                                                    MoonlordDeathDrama.RequestLight(this.ai[1] / 30f, base.Center);
                                                }
                                                if (this.ai[1] == 60f)
                                                {
                                                    this.ai[1] = 0f;
                                                    this.ai[0] = 0f;
                                                    if (Main.netMode != 1 && this.type == 398)
                                                    {
                                                        this.ai[2] = (float)Main.rand.Next(3);
                                                        this.ai[2] = 0f;
                                                        this.netUpdate = true;
                                                        int[] numArray4 = new int[3];
                                                        int num715 = 0;
                                                        for (int v5 = 0; v5 < 2; v5++)
                                                        {
                                                            int num716 = NPC.NewNPC((int)base.Center.X + v5 * 800 - 400, (int)base.Center.Y - 100, 397, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                            Main.npc[num716].ai[2] = (float)v5;
                                                            Main.npc[num716].netUpdate = true;
                                                            int num717 = num715;
                                                            num715 = num717 + 1;
                                                            numArray4[num717] = num716;
                                                        }
                                                        int num718 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y - 400, 396, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num718].netUpdate = true;
                                                        int num719 = num715;
                                                        num715 = num719 + 1;
                                                        numArray4[num719] = num718;
                                                        for (int w5 = 0; w5 < 3; w5++)
                                                        {
                                                            Main.npc[numArray4[w5]].ai[3] = (float)this.whoAmI;
                                                        }
                                                        for (int x510 = 0; x510 < 3; x510++)
                                                        {
                                                            this.localAI[x510] = (float)numArray4[x510];
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.ai[0] == 0f)
                                            {
                                                this.dontTakeDamage = true;
                                                this.TargetClosest(false);
                                                Vector2 center65 = (Main.player[this.target].Center - base.Center) + new Vector2(0f, 130f);
                                                if (center65.Length() > 20f)
                                                {
                                                    Vector2 vector2235 = Vector2.Normalize(center65 - this.velocity) * 8f;
                                                    Vector2 vector2236 = this.velocity;
                                                    this.SimpleFlyMovement(vector2235, 0.5f);
                                                    this.velocity = Vector2.Lerp(this.velocity, vector2236, 0.5f);
                                                }
                                                if (Main.netMode != 1)
                                                {
                                                    bool flag139 = false;
                                                    if (this.localAI[0] < 0f || this.localAI[1] < 0f || this.localAI[2] < 0f)
                                                    {
                                                        flag139 = true;
                                                    }
                                                    else if (!Main.npc[(int)this.localAI[0]].active || Main.npc[(int)this.localAI[0]].type != 397)
                                                    {
                                                        flag139 = true;
                                                    }
                                                    else if (!Main.npc[(int)this.localAI[1]].active || Main.npc[(int)this.localAI[1]].type != 397)
                                                    {
                                                        flag139 = true;
                                                    }
                                                    else if (!Main.npc[(int)this.localAI[2]].active || Main.npc[(int)this.localAI[2]].type != 396)
                                                    {
                                                        flag139 = true;
                                                    }
                                                    if (flag139)
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 10);
                                                        this.active = false;
                                                    }
                                                    bool flag140 = true;
                                                    if (Main.npc[(int)this.localAI[0]].ai[0] != -2f)
                                                    {
                                                        flag140 = false;
                                                    }
                                                    if (Main.npc[(int)this.localAI[1]].ai[0] != -2f)
                                                    {
                                                        flag140 = false;
                                                    }
                                                    if (Main.npc[(int)this.localAI[2]].ai[0] != -2f)
                                                    {
                                                        flag140 = false;
                                                    }
                                                    if (flag140)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.dontTakeDamage = false;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                            }
                                            else if (this.ai[0] == 1f)
                                            {
                                                this.dontTakeDamage = false;
                                                this.TargetClosest(false);
                                                Vector2 center66 = (Main.player[this.target].Center - base.Center) + new Vector2(0f, 130f);
                                                if (center66.Length() > 20f)
                                                {
                                                    Vector2 vector2237 = Vector2.Normalize(center66 - this.velocity) * 8f;
                                                    Vector2 vector2238 = this.velocity;
                                                    this.SimpleFlyMovement(vector2237, 0.5f);
                                                    this.velocity = Vector2.Lerp(this.velocity, vector2238, 0.5f);
                                                }
                                            }
                                            else if (this.ai[0] == 2f)
                                            {
                                                this.dontTakeDamage = true;
                                                Vector2 vector2239 = new Vector2((float)this.direction, -0.5f);
                                                this.velocity = Vector2.Lerp(this.velocity, vector2239, 0.98f);
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] < 60f)
                                                {
                                                    MoonlordDeathDrama.RequestLight(this.ai[1] / 60f, base.Center);
                                                }
                                                if (this.ai[1] == 60f)
                                                {
                                                    for (int y510 = 0; y510 < 1000; y510++)
                                                    {
                                                        Projectile projectile = Main.projectile[y510];
                                                        if (projectile.active && (projectile.type == 456 || projectile.type == 462 || projectile.type == 455 || projectile.type == 452 || projectile.type == 454))
                                                        {
                                                            projectile.Kill();
                                                        }
                                                    }
                                                    for (int a5 = 0; a5 < 200; a5++)
                                                    {
                                                        NPC nPC229 = Main.npc[a5];
                                                        if (nPC229.active && nPC229.type == 400)
                                                        {
                                                            nPC229.HitEffect(0, 9999);
                                                            nPC229.active = false;
                                                        }
                                                    }
                                                }
                                                if (this.ai[1] % 3f == 0f && this.ai[1] < 580f && this.ai[1] > 60f)
                                                {
                                                    Vector2 vector2240 = Utils.RandomVector2(Main.rand, -1f, 1f);
                                                    if (vector2240 != Vector2.Zero)
                                                    {
                                                        vector2240.Normalize();
                                                    }
                                                    vector2240 = vector2240 * (20f + Main.rand.NextFloat() * 400f);
                                                    bool flag141 = true;
                                                    Point point3 = (base.Center + vector2240).ToTileCoordinates();
                                                    if (!WorldGen.InWorld(point3.X, point3.Y, 0))
                                                    {
                                                        flag141 = false;
                                                    }
                                                    if (flag141 && WorldGen.SolidTile(point3.X, point3.Y))
                                                    {
                                                        flag141 = false;
                                                    }
                                                    float single507 = (float)Main.rand.Next(6, 19);
                                                    float single508 = 6.28318548f / single507;
                                                    float single509 = 6.28318548f * Main.rand.NextFloat();
                                                    float single510 = 1f + Main.rand.NextFloat() * 2f;
                                                    float single511 = 1f + Main.rand.NextFloat();
                                                    float single512 = 0.4f + Main.rand.NextFloat();
                                                    Random random3 = Main.rand;
                                                    numArray = new int[] { 31, 229 };
                                                    int num720 = Utils.SelectRandom<int>(random3, numArray);
                                                    for (float b5 = 0f; b5 < this.ai[1] / 60f; b5 = b5 + 1f)
                                                    {
                                                        Vector2 vector2241 = Utils.RandomVector2(Main.rand, -1f, 1f);
                                                        if (vector2241 != Vector2.Zero)
                                                        {
                                                            vector2241.Normalize();
                                                        }
                                                        vector2241 = vector2241 * (20f + Main.rand.NextFloat() * 800f);
                                                        Vector2 center67 = base.Center + vector2241;
                                                        Point tileCoordinates4 = center67.ToTileCoordinates();
                                                        bool flag142 = true;
                                                        if (!WorldGen.InWorld(tileCoordinates4.X, tileCoordinates4.Y, 0))
                                                        {
                                                            flag142 = false;
                                                        }
                                                        if (flag142 && WorldGen.SolidTile(tileCoordinates4.X, tileCoordinates4.Y))
                                                        {
                                                            flag142 = false;
                                                        }
                                                    }
                                                }
                                                if (this.ai[1] % 15f == 0f && this.ai[1] < 480f && this.ai[1] >= 90f && Main.netMode != 1)
                                                {
                                                    Vector2 vector2242 = Utils.RandomVector2(Main.rand, -1f, 1f);
                                                    if (vector2242 != Vector2.Zero)
                                                    {
                                                        vector2242.Normalize();
                                                    }
                                                    vector2242 = vector2242 * (20f + Main.rand.NextFloat() * 400f);
                                                    bool flag143 = true;
                                                    Vector2 center68 = base.Center + vector2242;
                                                    Point point4 = center68.ToTileCoordinates();
                                                    if (!WorldGen.InWorld(point4.X, point4.Y, 0))
                                                    {
                                                        flag143 = false;
                                                    }
                                                    if (flag143 && WorldGen.SolidTile(point4.X, point4.Y))
                                                    {
                                                        flag143 = false;
                                                    }
                                                    if (flag143)
                                                    {
                                                        float directionInt4 = (float)(Main.rand.Next(4) < 2).ToDirectionInt() * (0.3926991f + 0.7853982f * Main.rand.NextFloat());
                                                        Vector2 vector2243 = new Vector2(0f, -Main.rand.NextFloat() * 0.5f - 0.5f);
                                                        double num721 = (double)directionInt4;
                                                        vector24 = new Vector2();
                                                        Vector2 vector2244 = vector2243.RotatedBy(num721, vector24) * 6f;
                                                        Projectile.NewProjectile(center68.X, center68.Y, vector2244.X, vector2244.Y, 622, 0, 0f, Main.myPlayer, 0f, 0f);
                                                    }
                                                }
                                                if (this.ai[1] >= 480f)
                                                {
                                                    MoonlordDeathDrama.RequestLight((this.ai[1] - 480f) / 120f, base.Center);
                                                }
                                                if (this.ai[1] >= 600f)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 1337);
                                                    this.checkDead();
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 3f)
                                            {
                                                this.dontTakeDamage = true;
                                                Vector2 vector2245 = new Vector2((float)this.direction, -0.5f);
                                                this.velocity = Vector2.Lerp(this.velocity, vector2245, 0.98f);
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] < 60f)
                                                {
                                                    MoonlordDeathDrama.RequestLight(this.ai[1] / 40f, base.Center);
                                                }
                                                if (this.ai[1] == 40f)
                                                {
                                                    for (int c5 = 0; c5 < 1000; c5++)
                                                    {
                                                        Projectile projectile1 = Main.projectile[c5];
                                                        if (projectile1.active && (projectile1.type == 456 || projectile1.type == 462 || projectile1.type == 455 || projectile1.type == 452 || projectile1.type == 454))
                                                        {
                                                            projectile1.active = false;
                                                            NetMessage.SendData(27, -1, -1, "", c5, 0f, 0f, 0f, 0, 0, 0);
                                                        }
                                                    }
                                                    for (int d5 = 0; d5 < 200; d5++)
                                                    {
                                                        NPC nPC230 = Main.npc[d5];
                                                        if (nPC230.active && nPC230.type == 400)
                                                        {
                                                            nPC230.active = false;
                                                            if (Main.netMode != 1)
                                                            {
                                                                NetMessage.SendData(23, -1, -1, "", nPC230.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                            }
                                                        }
                                                    }
                                                }
                                                if (this.ai[1] == 60f)
                                                {
                                                    for (int f5 = 0; f5 < 200; f5++)
                                                    {
                                                        NPC nPC231 = Main.npc[f5];
                                                        if (nPC231.active && (nPC231.type == 400 || nPC231.type == 397 || nPC231.type == 396))
                                                        {
                                                            nPC231.active = false;
                                                            if (Main.netMode != 1)
                                                            {
                                                                NetMessage.SendData(23, -1, -1, "", nPC231.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                            }
                                                        }
                                                    }
                                                    this.active = false;
                                                    NetMessage.SendData(23, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                    NPC.LunarApocalypseIsUp = false;
                                                    if (Main.netMode == 2)
                                                    {
                                                        NetMessage.SendData(7, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0);
                                                    }
                                                    return;
                                                }
                                            }
                                            bool flag144 = false;
                                            if (Main.player[this.target].active && !Main.player[this.target].dead)
                                            {
                                                flag144 = true;
                                            }
                                            if (!flag144)
                                            {
                                                int num722 = 0;
                                                while (num722 < 255)
                                                {
                                                    if (!Main.player[num722].active || Main.player[num722].dead)
                                                    {
                                                        num722++;
                                                    }
                                                    else
                                                    {
                                                        flag144 = true;
                                                        break;
                                                    }
                                                }
                                            }
                                            if (!flag144)
                                            {
                                                this.ai[0] = 3f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.aiStyle == 78)
                                        {
                                            NPC.InitializeMoonLordAttacks();
                                            if (!Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 398)
                                            {
                                                this.life = 0;
                                                this.HitEffect(0, 10);
                                                this.active = false;
                                            }
                                            bool flag145 = this.ai[2] == 0f;
                                            float directionInt5 = (float)(-flag145.ToDirectionInt());
                                            this.spriteDirection = (int)directionInt5;
                                            this.dontTakeDamage = this.frameCounter >= 21;
                                            Vector2 vector2246 = new Vector2(30f, 66f);
                                            float single513 = 0f;
                                            float moonLordAttacksArray = 0f;
                                            bool flag146 = true;
                                            int num723 = 0;
                                            if (this.ai[0] != -2f)
                                            {
                                                float single514 = this.ai[0];
                                                this.ai[1] = this.ai[1] + 1f;
                                                int num724 = (int)Main.npc[(int)this.ai[3]].ai[2];
                                                int num725 = (flag145 ? 0 : 1);
                                                int num726 = 0;
                                                int num727 = 0;
                                                while (num726 < 5)
                                                {
                                                    moonLordAttacksArray = (float)NPC.MoonLordAttacksArray[num724, num725, 1, num726];
                                                    if (moonLordAttacksArray + (float)num727 > this.ai[1])
                                                    {
                                                        break;
                                                    }
                                                    num727 = num727 + (int)moonLordAttacksArray;
                                                    num726++;
                                                }
                                                if (num726 == 5)
                                                {
                                                    num726 = 0;
                                                    this.ai[1] = 0f;
                                                    moonLordAttacksArray = (float)NPC.MoonLordAttacksArray[num724, num725, 1, num726];
                                                    num727 = 0;
                                                }
                                                this.ai[0] = (float)NPC.MoonLordAttacksArray[num724, num725, 0, num726];
                                                single513 = (float)((int)this.ai[1] - num727);
                                                if (this.ai[0] != single514)
                                                {
                                                    this.netUpdate = true;
                                                }
                                            }
                                            if (this.ai[0] == -2f)
                                            {
                                                this.damage = 80;
                                                num723 = 0;
                                                this.dontTakeDamage = true;
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 32f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                                if (this.ai[1] < 0f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                                Vector2 center69 = Main.npc[(int)this.ai[3]].Center;
                                                Vector2 vector2247 = center69 + new Vector2(350f * directionInt5, -100f);
                                                Vector2 center70 = vector2247 - base.Center;
                                                if (center70.Length() > 20f)
                                                {
                                                    center70.Normalize();
                                                    center70 = center70 * 6f;
                                                    Vector2 vector2248 = this.velocity;
                                                    if (center70 != Vector2.Zero)
                                                    {
                                                        this.SimpleFlyMovement(center70, 0.3f);
                                                    }
                                                    this.velocity = Vector2.Lerp(vector2248, this.velocity, 0.5f);
                                                }
                                            }
                                            else if (this.ai[0] == 0f)
                                            {
                                                num723 = 3;
                                                this.localAI[1] = this.localAI[1] - 0.05f;
                                                if (this.localAI[1] < 0f)
                                                {
                                                    this.localAI[1] = 0f;
                                                }
                                                Vector2 center71 = Main.npc[(int)this.ai[3]].Center;
                                                Vector2 vector2249 = center71 + new Vector2(350f * directionInt5, -100f);
                                                Vector2 center72 = vector2249 - base.Center;
                                                if (center72.Length() > 20f)
                                                {
                                                    center72.Normalize();
                                                    center72 = center72 * 6f;
                                                    Vector2 vector2250 = this.velocity;
                                                    if (center72 != Vector2.Zero)
                                                    {
                                                        this.SimpleFlyMovement(center72, 0.3f);
                                                    }
                                                    this.velocity = Vector2.Lerp(vector2250, this.velocity, 0.5f);
                                                }
                                            }
                                            else if (this.ai[0] == 1f)
                                            {
                                                num723 = 0;
                                                int num728 = 7;
                                                int num729 = 4;
                                                if (single513 >= (float)(num728 * num729 * 2))
                                                {
                                                    this.localAI[1] = this.localAI[1] - 0.07f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                }
                                                else if (single513 < (float)(num728 * num729))
                                                {
                                                    this.localAI[1] = this.localAI[1] + 0.02f;
                                                    if (this.localAI[1] > 0.75f)
                                                    {
                                                        this.localAI[1] = 0.75f;
                                                    }
                                                    float single515 = 6.28318548f * (single513 % (float)(num728 * num729)) / (float)(num728 * num729) - 1.57079637f;
                                                    this.localAI[0] = (new Vector2((float)Math.Cos((double)single515) * vector2246.X, (float)Math.Sin((double)single515) * vector2246.Y)).ToRotation();
                                                }
                                                else
                                                {
                                                    this.localAI[1] = this.localAI[1] + 0.05f;
                                                    if (this.localAI[1] > 0.75f)
                                                    {
                                                        this.localAI[1] = 0.75f;
                                                    }
                                                    float single516 = 6.28318548f * (single513 % (float)(num728 * num729)) / (float)(num728 * num729) - 1.57079637f;
                                                    this.localAI[0] = (new Vector2((float)Math.Cos((double)single516) * vector2246.X, (float)Math.Sin((double)single516) * vector2246.Y)).ToRotation();
                                                    if (single513 % (float)num729 == 0f)
                                                    {
                                                        Vector2 vector2251 = new Vector2(1f * -directionInt5, 3f);
                                                        Vector2 vector2252 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector2246 * this.localAI[1]);
                                                        Vector2 center73 = (base.Center + ((Vector2.Normalize(vector2252) * vector2246.Length()) * 0.4f)) + vector2251;
                                                        Vector2 vector2253 = Vector2.Normalize(vector2252) * 8f;
                                                        float single517 = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * directionInt5;
                                                        Projectile.NewProjectile(center73.X, center73.Y, vector2253.X, vector2253.Y, 452, 30, 0f, Main.myPlayer, 0f, single517);
                                                    }
                                                }
                                            }
                                            else if (this.ai[0] == 2f)
                                            {
                                                this.localAI[1] = this.localAI[1] - 0.05f;
                                                if (this.localAI[1] < 0f)
                                                {
                                                    this.localAI[1] = 0f;
                                                }
                                                Vector2 center74 = Main.npc[(int)this.ai[3]].Center;
                                                Vector2 vector2254 = new Vector2(220f * directionInt5, -60f) + center74;
                                                vector2254 = vector2254 + new Vector2(directionInt5 * 100f, -50f);
                                                Vector2 vector2255 = new Vector2(400f * directionInt5, -60f);
                                                if (single513 < 30f)
                                                {
                                                    Vector2 center75 = vector2254 - base.Center;
                                                    if (center75 != Vector2.Zero)
                                                    {
                                                        Vector2 vector2256 = center75;
                                                        vector2256.Normalize();
                                                        this.velocity = Vector2.SmoothStep(this.velocity, vector2256 * Math.Min(8f, center75.Length()), 0.2f);
                                                    }
                                                }
                                                else if (single513 < 210f)
                                                {
                                                    num723 = 1;
                                                    int num730 = (int)single513 - 30;
                                                    if (num730 % 30 == 0 && Main.netMode != 1)
                                                    {
                                                        Vector2 x207 = new Vector2(5f * directionInt5, -8f);
                                                        int num731 = num730 / 30;
                                                        x207.X = x207.X + ((float)num731 - 3.5f) * directionInt5 * 3f;
                                                        x207.Y = x207.Y + ((float)num731 - 4.5f) * 1f;
                                                        x207 = x207 * 1.2f;
                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, x207.X, x207.Y, 454, 50, 1f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                    }
                                                    Vector2 vector2257 = Vector2.SmoothStep(vector2254, vector2254 + vector2255, (single513 - 30f) / 180f) - base.Center;
                                                    if (vector2257 != Vector2.Zero)
                                                    {
                                                        Vector2 vector2258 = vector2257;
                                                        vector2258.Normalize();
                                                        this.velocity = Vector2.Lerp(this.velocity, vector2258 * Math.Min(20f, vector2257.Length()), 0.5f);
                                                    }
                                                }
                                                else if (single513 < 282f)
                                                {
                                                    num723 = 0;
                                                    NPC nPC232 = this;
                                                    nPC232.velocity = nPC232.velocity * 0.9f;
                                                }
                                                else if (single513 < 287f)
                                                {
                                                    num723 = 1;
                                                    NPC nPC233 = this;
                                                    nPC233.velocity = nPC233.velocity * 0.9f;
                                                }
                                                else if (single513 < 292f)
                                                {
                                                    num723 = 2;
                                                    NPC nPC234 = this;
                                                    nPC234.velocity = nPC234.velocity * 0.9f;
                                                }
                                                else if (single513 >= 300f)
                                                {
                                                    num723 = 3;
                                                    Vector2 center76 = vector2254 - base.Center;
                                                    if (center76 != Vector2.Zero)
                                                    {
                                                        Vector2 vector2259 = center76;
                                                        vector2259.Normalize();
                                                        this.velocity = Vector2.SmoothStep(this.velocity, vector2259 * Math.Min(8f, center76.Length()), 0.2f);
                                                    }
                                                }
                                                else
                                                {
                                                    num723 = 3;
                                                    if (single513 == 292f && Main.netMode != 1)
                                                    {
                                                        int num732 = Player.FindClosest(this.position, this.width, this.height);
                                                        Vector2 unitY13 = Vector2.Normalize(Main.player[num732].Center - (base.Center + (Vector2.UnitY * -350f)));
                                                        if (float.IsNaN(unitY13.X) || float.IsNaN(unitY13.Y))
                                                        {
                                                            unitY13 = Vector2.UnitY;
                                                        }
                                                        unitY13 = unitY13 * 12f;
                                                        for (int g5 = 0; g5 < 1000; g5++)
                                                        {
                                                            Projectile projectile2 = Main.projectile[g5];
                                                            if (projectile2.active && projectile2.type == 454 && projectile2.ai[1] == (float)this.whoAmI && projectile2.ai[0] != -1f)
                                                            {
                                                                projectile2.ai[0] = -1f;
                                                                projectile2.velocity = unitY13;
                                                                projectile2.netUpdate = true;
                                                            }
                                                        }
                                                    }
                                                    Vector2 vector2260 = Vector2.SmoothStep(vector2254, vector2254 + vector2255, 1f - (single513 - 270f) / 30f) - base.Center;
                                                    if (vector2260 != Vector2.Zero)
                                                    {
                                                        Vector2 vector2261 = vector2260;
                                                        vector2261.Normalize();
                                                        this.velocity = Vector2.Lerp(this.velocity, vector2261 * Math.Min(14f, vector2260.Length()), 0.1f);
                                                    }
                                                }
                                            }
                                            else if (this.ai[0] == 3f)
                                            {
                                                if (single513 == 0f)
                                                {
                                                    this.TargetClosest(false);
                                                    this.netUpdate = true;
                                                }
                                                Vector2 center77 = (Main.player[this.target].Center + (Main.player[this.target].velocity * 20f)) - base.Center;
                                                this.localAI[0] = this.localAI[0].AngleLerp(center77.ToRotation(), 0.5f);
                                                this.localAI[1] = this.localAI[1] + 0.05f;
                                                if (this.localAI[1] > 1f)
                                                {
                                                    this.localAI[1] = 1f;
                                                }
                                                if ((single513 == moonLordAttacksArray - 14f || single513 == moonLordAttacksArray - 7f || single513 == moonLordAttacksArray) && Main.netMode != 1)
                                                {
                                                    Vector2 vector2262 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector2246 * this.localAI[1]);
                                                    Vector2 vector2263 = Vector2.Normalize(center77) * 8f;
                                                    Projectile.NewProjectile(base.Center.X + vector2262.X, base.Center.Y + vector2262.Y, vector2263.X, vector2263.Y, 462, 30, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                            }
                                            if (flag146)
                                            {
                                                Vector2 center78 = Main.npc[(int)this.ai[3]].Center;
                                                Vector2 vector2264 = new Vector2(220f * directionInt5, -60f) + center78;
                                                Vector2 vector2265 = vector2264 + new Vector2(directionInt5 * 110f, -150f);
                                                Vector2 vector2266 = vector2265 + new Vector2(directionInt5 * 370f, 150f);
                                                if (vector2265.X > vector2266.X)
                                                {
                                                    Utils.Swap<float>(ref vector2265.X, ref vector2266.X);
                                                }
                                                if (vector2265.Y > vector2266.Y)
                                                {
                                                    Utils.Swap<float>(ref vector2265.Y, ref vector2266.Y);
                                                }
                                                Vector2 vector2267 = Vector2.Clamp(base.Center + this.velocity, vector2265, vector2266);
                                                if (vector2267 != (base.Center + this.velocity))
                                                {
                                                    base.Center = vector2267 - this.velocity;
                                                }
                                            }
                                            int num733 = num723 * 7;
                                            if ((double)num733 > this.frameCounter)
                                            {
                                                NPC nPC235 = this;
                                                nPC235.frameCounter = nPC235.frameCounter + 1;
                                            }
                                            if ((double)num733 < this.frameCounter)
                                            {
                                                NPC nPC236 = this;
                                                nPC236.frameCounter = nPC236.frameCounter - 1;
                                            }
                                            if (this.frameCounter < 0)
                                            {
                                                this.frameCounter = 0;
                                            }
                                            if (this.frameCounter > 21)
                                            {
                                                this.frameCounter = 21;
                                            }
                                            int num734 = 0;
                                            if (flag145)
                                            {
                                                num734 = 0;
                                            }
                                            if (num734 == 0)
                                            {
                                                return;
                                            }
                                            if (num734 != 1)
                                            {
                                                if (num734 == 2)
                                                {
                                                    Vector2 vector2268 = new Vector2(30f, 66f);
                                                    this.TargetClosest(false);
                                                    Vector2 vector2269 = (Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY)) - base.Center;
                                                    float single518 = vector2269.Length() / 200f;
                                                    if (single518 > 1f)
                                                    {
                                                        single518 = 1f;
                                                    }
                                                    single518 = 1f - single518;
                                                    single518 = single518 * 2f;
                                                    if (single518 > 1f)
                                                    {
                                                        single518 = 1f;
                                                    }
                                                    this.localAI[0] = vector2269.ToRotation();
                                                    this.localAI[1] = single518;
                                                    this.localAI[1] = 1f;
                                                    return;
                                                }
                                                if (num734 == 3)
                                                {
                                                    int num735 = 7;
                                                    int num736 = 4;
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    if (this.ai[1] >= (float)(num735 * num736 * 10))
                                                    {
                                                        this.ai[1] = 0f;
                                                        return;
                                                    }
                                                    if (this.ai[1] < (float)(num735 * num736))
                                                    {
                                                        this.localAI[1] = this.localAI[1] + 0.05f;
                                                        if (this.localAI[1] > 0.75f)
                                                        {
                                                            this.localAI[1] = 0.75f;
                                                        }
                                                        float single519 = 6.28318548f * (this.ai[1] % (float)(num735 * num736)) / (float)(num735 * num736) - 1.57079637f;
                                                        this.localAI[0] = (new Vector2((float)Math.Cos((double)single519) * vector2246.X, (float)Math.Sin((double)single519) * vector2246.Y)).ToRotation();
                                                        if (this.ai[1] % (float)num736 == 0f)
                                                        {
                                                            Vector2 vector2270 = new Vector2(1f * -directionInt5, 3f);
                                                            Vector2 vector2271 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector2246 * this.localAI[1]);
                                                            Vector2 center79 = (base.Center + ((Vector2.Normalize(vector2271) * vector2246.Length()) * 0.4f)) + vector2270;
                                                            Vector2 vector2272 = Vector2.Normalize(vector2271) * 8f;
                                                            float single520 = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * directionInt5;
                                                            Projectile.NewProjectile(center79.X, center79.Y, vector2272.X, vector2272.Y, 452, 5, 0f, Main.myPlayer, 0f, single520);
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.localAI[1] = this.localAI[1] - 0.07f;
                                                        if (this.localAI[1] < 0f)
                                                        {
                                                            this.localAI[1] = 0f;
                                                            return;
                                                        }
                                                    }
                                                }
                                                else if (num734 == 4)
                                                {
                                                    Vector2 center80 = Main.npc[(int)this.ai[3]].Center;
                                                    Vector2 vector2273 = new Vector2(220f * directionInt5, -60f) + center80;
                                                    vector2273 = vector2273 + new Vector2(directionInt5 * 100f, -50f);
                                                    Vector2 vector2274 = new Vector2(400f * directionInt5, -60f);
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    if (this.ai[1] < 30f)
                                                    {
                                                        Vector2 center81 = vector2273 - base.Center;
                                                        if (center81 != Vector2.Zero)
                                                        {
                                                            Vector2 vector2275 = center81;
                                                            vector2275.Normalize();
                                                            this.velocity = Vector2.SmoothStep(this.velocity, vector2275 * Math.Min(8f, center81.Length()), 0.2f);
                                                            return;
                                                        }
                                                    }
                                                    else if (this.ai[1] >= 210f)
                                                    {
                                                        if (this.ai[1] < 270f)
                                                        {
                                                            NPC nPC237 = this;
                                                            nPC237.velocity = nPC237.velocity * 0.9f;
                                                            return;
                                                        }
                                                        if (this.ai[1] >= 300f)
                                                        {
                                                            this.ai[1] = 0f;
                                                            return;
                                                        }
                                                        if (this.ai[1] == 270f && Main.netMode != 1)
                                                        {
                                                            int num737 = Player.FindClosest(this.position, this.width, this.height);
                                                            Vector2 unitY14 = Vector2.Normalize(Main.player[num737].Center - (base.Center + (Vector2.UnitY * -350f)));
                                                            if (float.IsNaN(unitY14.X) || float.IsNaN(unitY14.Y))
                                                            {
                                                                unitY14 = Vector2.UnitY;
                                                            }
                                                            unitY14 = unitY14 * 12f;
                                                            for (int h5 = 0; h5 < 1000; h5++)
                                                            {
                                                                Projectile projectile3 = Main.projectile[h5];
                                                                if (projectile3.active && projectile3.type == 454 && projectile3.ai[1] == (float)this.whoAmI && projectile3.ai[0] != -1f)
                                                                {
                                                                    projectile3.ai[0] = -1f;
                                                                    projectile3.velocity = unitY14;
                                                                    projectile3.netUpdate = true;
                                                                }
                                                            }
                                                        }
                                                        Vector2 vector2276 = Vector2.SmoothStep(vector2273, vector2273 + vector2274, 1f - (this.ai[1] - 270f) / 30f) - base.Center;
                                                        if (vector2276 != Vector2.Zero)
                                                        {
                                                            Vector2 vector2277 = vector2276;
                                                            vector2277.Normalize();
                                                            this.velocity = Vector2.Lerp(this.velocity, vector2277 * Math.Min(14f, vector2276.Length()), 0.1f);
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        int num738 = (int)this.ai[1] - 30;
                                                        if (num738 % 30 == 0 && Main.netMode != 1)
                                                        {
                                                            Vector2 x208 = new Vector2(5f * directionInt5, -8f);
                                                            int num739 = num738 / 30;
                                                            x208.X = x208.X + ((float)num739 - 3.5f) * directionInt5 * 3f;
                                                            x208.Y = x208.Y + ((float)num739 - 4.5f) * 1f;
                                                            x208 = x208 * 1.2f;
                                                            Projectile.NewProjectile(base.Center.X, base.Center.Y, x208.X, x208.Y, 454, 1, 1f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                        }
                                                        Vector2 vector2278 = Vector2.SmoothStep(vector2273, vector2273 + vector2274, (this.ai[1] - 30f) / 180f) - base.Center;
                                                        if (vector2278 != Vector2.Zero)
                                                        {
                                                            Vector2 vector2279 = vector2278;
                                                            vector2279.Normalize();
                                                            this.velocity = Vector2.Lerp(this.velocity, vector2279 * Math.Min(4f, vector2278.Length()), 0.1f);
                                                            return;
                                                        }
                                                    }
                                                }
                                                else if (num734 == 5)
                                                {
                                                    this.dontTakeDamage = true;
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    if (this.ai[1] >= 40f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        return;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (this.ai[0] == 0f)
                                                {
                                                    float single521 = this.ai[1] + 1f;
                                                    single1 = single521;
                                                    this.ai[1] = single521;
                                                    if (single1 >= 20f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        this.ai[0] = 1f;
                                                        this.netUpdate = true;
                                                    }
                                                    this.velocity = Vector2.UnitX * 4f;
                                                    return;
                                                }
                                                if (this.ai[0] == 1f)
                                                {
                                                    float single522 = this.ai[1] + 1f;
                                                    single1 = single522;
                                                    this.ai[1] = single522;
                                                    if (single1 >= 20f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        this.ai[0] = 2f;
                                                        this.netUpdate = true;
                                                    }
                                                    this.velocity = Vector2.UnitX * -4f;
                                                    return;
                                                }
                                                if (this.ai[0] == 2f || this.ai[0] == 4f)
                                                {
                                                    float single523 = this.ai[1] + 1f;
                                                    single1 = single523;
                                                    this.ai[1] = single523;
                                                    if (single1 >= 20f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        this.ai[0] = this.ai[0] + 1f;
                                                        this.netUpdate = true;
                                                    }
                                                    this.velocity = (Vector2.UnitY * -4f) * (float)((flag145 ? 1 : -1));
                                                    return;
                                                }
                                                if (this.ai[0] == 3f || this.ai[0] == 5f)
                                                {
                                                    float single524 = this.ai[1] + 1f;
                                                    single1 = single524;
                                                    this.ai[1] = single524;
                                                    if (single1 >= 20f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        this.ai[0] = this.ai[0] + 1f;
                                                        if (this.ai[0] == 6f)
                                                        {
                                                            this.ai[0] = 0f;
                                                        }
                                                        this.netUpdate = true;
                                                    }
                                                    this.velocity = (Vector2.UnitY * 4f) * (float)((flag145 ? 1 : -1));
                                                    return;
                                                }
                                            }
                                        }
                                        else if (this.aiStyle != 79)
                                        {
                                            if (this.aiStyle == 80)
                                            {
                                                if (this.ai[0] == 0f)
                                                {
                                                    if (this.collideX)
                                                    {
                                                        this.direction = 1 - this.direction;
                                                    }
                                                    this.velocity.X = 3f * (float)((this.direction == 0 ? -1 : 1));
                                                    Point tileCoordinates5 = base.Center.ToTileCoordinates();
                                                    int num740 = 30;
                                                    int num741 = 0;
                                                    while (num741 < 30)
                                                    {
                                                        if (!WorldGen.SolidTile(tileCoordinates5.X, tileCoordinates5.Y + num741))
                                                        {
                                                            num741++;
                                                        }
                                                        else
                                                        {
                                                            num740 = num741;
                                                            break;
                                                        }
                                                    }
                                                    if (num740 < 15)
                                                    {
                                                        this.velocity.Y = Math.Max(this.velocity.Y - 0.05f, -3.5f);
                                                    }
                                                    else if (num740 >= 20)
                                                    {
                                                        this.velocity.Y = Math.Min(this.velocity.Y + 0.05f, 1.5f);
                                                    }
                                                    else
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.95f;
                                                    }
                                                    if (this.FindClosestPlayer(out single) == -1)
                                                    {
                                                        return;
                                                    }
                                                    if (single < 352f)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.ai[1] = 0f;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 1f)
                                                {
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    NPC nPC238 = this;
                                                    nPC238.velocity = nPC238.velocity * 0.95f;
                                                    if (this.ai[1] >= 60f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        this.ai[0] = 2f;
                                                        int num742 = this.FindClosestPlayer();
                                                        if (num742 == -1)
                                                        {
                                                            this.ai[3] = 1f;
                                                        }
                                                        else
                                                        {
                                                            this.ai[3] = (Main.player[num742].Center.X > base.Center.X ? -1f : 1f);
                                                        }
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    this.noTileCollide = true;
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    this.velocity.Y = Math.Max(this.velocity.Y - 0.1f, -10f);
                                                    this.velocity.X = Math.Min(this.velocity.X + this.ai[3] * 0.05f, 4f);
                                                    if (this.position.Y < (float)(-this.height) || this.ai[1] >= 180f)
                                                    {
                                                        Main.StartInvasion(4);
                                                        this.active = false;
                                                        this.ai[0] = 3f;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                skyBlue = Color.SkyBlue;
                                                Vector3 vector34 = skyBlue.ToVector3();
                                                if (this.ai[0] == 2f)
                                                {
                                                    skyBlue = Color.Red;
                                                    vector34 = skyBlue.ToVector3();
                                                }
                                                vector34 = vector34 * 0.65f;
                                                return;
                                            }
                                            if (this.aiStyle != 81)
                                            {
                                                if (this.aiStyle == 82)
                                                {
                                                    float single525 = 90f;
                                                    Vector2 vector2280 = new Vector2(0f, 216f);
                                                    int num743 = (int)Math.Abs(this.ai[0]) - 1;
                                                    int num744 = (int)this.ai[1];
                                                    if (!Main.npc[num743].active || Main.npc[num743].type != 396)
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 10);
                                                        this.active = false;
                                                        return;
                                                    }
                                                    this.ai[2] = this.ai[2] + 1f;
                                                    if (this.ai[2] < single525)
                                                    {
                                                        this.velocity = Vector2.Zero;
                                                        base.Center = Vector2.Lerp(Main.projectile[num744].Center, Main.npc[(int)Math.Abs(this.ai[0]) - 1].Center + vector2280, this.ai[2] / single525);
                                                        return;
                                                    }
                                                    if (Main.netMode != 1)
                                                    {
                                                        int num749 = (int)Main.npc[num743].ai[3];
                                                        int num750 = -1;
                                                        int num751 = -1;
                                                        int num752 = num743;
                                                        for (int k6 = 0; k6 < 200; k6++)
                                                        {
                                                            if (Main.npc[k6].active && Main.npc[k6].ai[3] == (float)num749)
                                                            {
                                                                if (num750 == -1 && Main.npc[k6].type == 397 && Main.npc[k6].ai[2] == 0f)
                                                                {
                                                                    num750 = k6;
                                                                }
                                                                if (num751 == -1 && Main.npc[k6].type == 397 && Main.npc[k6].ai[2] == 1f)
                                                                {
                                                                    num751 = k6;
                                                                }
                                                                if (num750 != -1 && num751 != -1 && num752 != -1)
                                                                {
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                        int num753 = 1000;
                                                        int num754 = Main.npc[num749].lifeMax - Main.npc[num749].life;
                                                        int num755 = Main.npc[num750].lifeMax - Main.npc[num750].life;
                                                        int num756 = Main.npc[num751].lifeMax - Main.npc[num751].life;
                                                        int num757 = Main.npc[num752].lifeMax - Main.npc[num752].life;
                                                        if (num757 > 0 && num753 > 0)
                                                        {
                                                            int num758 = num757 - num753;
                                                            if (num758 > 0)
                                                            {
                                                                num758 = 0;
                                                            }
                                                            int num759 = num753 + num758;
                                                            num753 = num753 - num759;
                                                            NPC nPC239 = Main.npc[num752];
                                                            nPC239.life = nPC239.life + num759;
                                                            NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num752].Center, new Vector2(50f)), num759, true);
                                                        }
                                                        if (num754 > 0 && num753 > 0)
                                                        {
                                                            int num760 = num754 - num753;
                                                            if (num760 > 0)
                                                            {
                                                                num760 = 0;
                                                            }
                                                            int num761 = num753 + num760;
                                                            num753 = num753 - num761;
                                                            NPC nPC240 = Main.npc[num749];
                                                            nPC240.life = nPC240.life + num761;
                                                            NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num749].Center, new Vector2(50f)), num761, true);
                                                        }
                                                        if (num755 > 0 && num753 > 0)
                                                        {
                                                            int num762 = num755 - num753;
                                                            if (num762 > 0)
                                                            {
                                                                num762 = 0;
                                                            }
                                                            int num763 = num753 + num762;
                                                            num753 = num753 - num763;
                                                            NPC nPC241 = Main.npc[num750];
                                                            nPC241.life = nPC241.life + num763;
                                                            NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num750].Center, new Vector2(50f)), num763, true);
                                                        }
                                                        if (num756 > 0 && num753 > 0)
                                                        {
                                                            int num764 = num756 - num753;
                                                            if (num764 > 0)
                                                            {
                                                                num764 = 0;
                                                            }
                                                            int num765 = num753 + num764;
                                                            num753 = num753 - num765;
                                                            NPC nPC242 = Main.npc[num751];
                                                            nPC242.life = nPC242.life + num765;
                                                            NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num751].Center, new Vector2(50f)), num765, true);
                                                        }
                                                    }
                                                    this.life = 0;
                                                    this.HitEffect(0, 10);
                                                    this.active = false;
                                                    return;
                                                }
                                                if (this.aiStyle != 83)
                                                {
                                                    if (this.aiStyle == 84)
                                                    {
                                                        bool flag147 = Main.expertMode;
                                                        bool flag148 = this.life <= this.lifeMax / 2;
                                                        int num766 = 120;
                                                        int num767 = 35;
                                                        if (flag147)
                                                        {
                                                            num766 = 90;
                                                            num767 = 25;
                                                        }
                                                        int num768 = 18;
                                                        int num769 = 3;
                                                        int num770 = 30;
                                                        if (flag147)
                                                        {
                                                            num768 = 12;
                                                            num769 = 4;
                                                            num770 = 20;
                                                        }
                                                        int num771 = 80;
                                                        int num772 = 45;
                                                        if (flag147)
                                                        {
                                                            num771 = 40;
                                                            num772 = 30;
                                                        }
                                                        int num773 = 20;
                                                        int num774 = 2;
                                                        if (flag147)
                                                        {
                                                            num773 = 30;
                                                            num774 = 2;
                                                        }
                                                        int num775 = 20;
                                                        int num776 = 3;
                                                        bool flag149 = this.type == 439;
                                                        bool flag150 = false;
                                                        bool flag151 = false;
                                                        if (flag148)
                                                        {
                                                            this.defense = (int)((float)this.defDefense * 0.65f);
                                                        }
                                                        if (!flag149)
                                                        {
                                                            if ((this.ai[3] < 0f || !Main.npc[(int)this.ai[3]].active ? true : Main.npc[(int)this.ai[3]].type != 439))
                                                            {
                                                                this.life = 0;
                                                                this.HitEffect(0, 10);
                                                                this.active = false;
                                                                return;
                                                            }
                                                            this.ai[0] = Main.npc[(int)this.ai[3]].ai[0];
                                                            this.ai[1] = Main.npc[(int)this.ai[3]].ai[1];
                                                            if (this.ai[0] != 5f)
                                                            {
                                                                flag150 = true;
                                                                flag151 = true;
                                                            }
                                                            else if (this.justHit)
                                                            {
                                                                this.life = 0;
                                                                this.HitEffect(0, 10);
                                                                this.active = false;
                                                                NetMessage.SendData(23, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                                NPC nPC243 = Main.npc[(int)this.ai[3]];
                                                                nPC243.ai[0] = 6f;
                                                                nPC243.ai[1] = 0f;
                                                                nPC243.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 5f && this.ai[1] >= 120f && this.ai[1] < 420f && this.justHit)
                                                        {
                                                            this.ai[0] = 0f;
                                                            this.ai[1] = 0f;
                                                            this.ai[3] = this.ai[3] + 1f;
                                                            this.velocity = Vector2.Zero;
                                                            this.netUpdate = true;
                                                            List<int> nums = new List<int>();
                                                            for (int l6 = 0; l6 < 200; l6++)
                                                            {
                                                                if (Main.npc[l6].active && Main.npc[l6].type == 440 && Main.npc[l6].ai[3] == (float)this.whoAmI)
                                                                {
                                                                    nums.Add(l6);
                                                                }
                                                            }
                                                            int num777 = 10;
                                                            if (Main.expertMode)
                                                            {
                                                                num777 = 3;
                                                            }
                                                            foreach (int num778 in nums)
                                                            {
                                                                NPC nPC244 = Main.npc[num778];
                                                                if (nPC244.localAI[1] != this.localAI[1] || num777 <= 0)
                                                                {
                                                                    if (num777 <= 0)
                                                                    {
                                                                        continue;
                                                                    }
                                                                    num777--;
                                                                    nPC244.life = 0;
                                                                    nPC244.HitEffect(0, 10);
                                                                    nPC244.active = false;
                                                                }
                                                                else
                                                                {
                                                                    num777--;
                                                                    nPC244.life = 0;
                                                                    nPC244.HitEffect(0, 10);
                                                                    nPC244.active = false;
                                                                    NetMessage.SendData(23, -1, -1, "", num778, 0f, 0f, 0f, 0, 0, 0);
                                                                }
                                                            }
                                                            Main.projectile[(int)this.ai[2]].ai[1] = -1f;
                                                            Main.projectile[(int)this.ai[2]].netUpdate = true;
                                                        }
                                                        Vector2 center84 = base.Center;
                                                        Player player8 = Main.player[this.target];
                                                        if (this.target < 0 || this.target == 255 || player8.dead || !player8.active)
                                                        {
                                                            this.TargetClosest(false);
                                                            player8 = Main.player[this.target];
                                                            this.netUpdate = true;
                                                        }
                                                        if (player8.dead || Vector2.Distance(player8.Center, center84) > 5600f)
                                                        {
                                                            this.life = 0;
                                                            this.HitEffect(0, 10);
                                                            this.active = false;
                                                            NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                                                            (new List<int>()).Add(this.whoAmI);
                                                            for (int m6 = 0; m6 < 200; m6++)
                                                            {
                                                                if (Main.npc[m6].active && Main.npc[m6].type == 440 && Main.npc[m6].ai[3] == (float)this.whoAmI)
                                                                {
                                                                    Main.npc[m6].life = 0;
                                                                    Main.npc[m6].HitEffect(0, 10);
                                                                    Main.npc[m6].active = false;
                                                                    NetMessage.SendData(28, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                                                                }
                                                            }
                                                        }
                                                        float single526 = this.ai[3];
                                                        if (this.localAI[0] == 0f)
                                                        {
                                                            this.localAI[0] = 1f;
                                                            this.alpha = 255;
                                                            this.rotation = 0f;
                                                            if (Main.netMode != 1)
                                                            {
                                                                this.ai[0] = -1f;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        if (this.ai[0] == -1f)
                                                        {
                                                            NPC nPC245 = this;
                                                            nPC245.alpha = nPC245.alpha - 5;
                                                            if (this.alpha < 0)
                                                            {
                                                                this.alpha = 0;
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= 420f)
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.netUpdate = true;
                                                            }
                                                            else if (this.ai[1] > 360f)
                                                            {
                                                                NPC nPC246 = this;
                                                                nPC246.velocity = nPC246.velocity * 0.95f;
                                                                this.localAI[2] = 13f;
                                                            }
                                                            else if (this.ai[1] > 300f)
                                                            {
                                                                this.velocity = -Vector2.UnitY;
                                                                this.localAI[2] = 10f;
                                                            }
                                                            else if (this.ai[1] <= 120f)
                                                            {
                                                                this.localAI[2] = 0f;
                                                            }
                                                            else
                                                            {
                                                                this.localAI[2] = 1f;
                                                            }
                                                            flag150 = true;
                                                            flag151 = true;
                                                        }
                                                        if (this.ai[0] == 0f)
                                                        {
                                                            if (this.ai[1] == 0f)
                                                            {
                                                                this.TargetClosest(false);
                                                            }
                                                            this.localAI[2] = 10f;
                                                            int num779 = Math.Sign(player8.Center.X - center84.X);
                                                            if (num779 != 0)
                                                            {
                                                                int num780 = num779;
                                                                num6 = num780;
                                                                this.spriteDirection = num780;
                                                                this.direction = num6;
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= 40f && flag149)
                                                            {
                                                                int num781 = 0;
                                                                if (!flag148)
                                                                {
                                                                    num6 = (int)this.ai[3];
                                                                    switch (num6)
                                                                    {
                                                                        case 0:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 1:
                                                                        {
                                                                            num781 = 1;
                                                                            break;
                                                                        }
                                                                        case 2:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 3:
                                                                        {
                                                                            num781 = 2;
                                                                            break;
                                                                        }
                                                                        case 4:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 5:
                                                                        {
                                                                            num781 = 3;
                                                                            break;
                                                                        }
                                                                        case 6:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 7:
                                                                        {
                                                                            num781 = 1;
                                                                            break;
                                                                        }
                                                                        case 8:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 9:
                                                                        {
                                                                            num781 = 2;
                                                                            break;
                                                                        }
                                                                        case 10:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 11:
                                                                        {
                                                                            num781 = 4;
                                                                            this.ai[3] = -1f;
                                                                            break;
                                                                        }
                                                                        default:
                                                                        {
                                                                            this.ai[3] = -1f;
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    num6 = (int)this.ai[3];
                                                                    switch (num6)
                                                                    {
                                                                        case 0:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 1:
                                                                        {
                                                                            num781 = 1;
                                                                            break;
                                                                        }
                                                                        case 2:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 3:
                                                                        {
                                                                            num781 = 5;
                                                                            break;
                                                                        }
                                                                        case 4:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 5:
                                                                        {
                                                                            num781 = 3;
                                                                            break;
                                                                        }
                                                                        case 6:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 7:
                                                                        {
                                                                            num781 = 5;
                                                                            break;
                                                                        }
                                                                        case 8:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 9:
                                                                        {
                                                                            num781 = 2;
                                                                            break;
                                                                        }
                                                                        case 10:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 11:
                                                                        {
                                                                            num781 = 3;
                                                                            break;
                                                                        }
                                                                        case 12:
                                                                        {
                                                                            num781 = 0;
                                                                            break;
                                                                        }
                                                                        case 13:
                                                                        {
                                                                            num781 = 4;
                                                                            this.ai[3] = -1f;
                                                                            break;
                                                                        }
                                                                        default:
                                                                        {
                                                                            this.ai[3] = -1f;
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                                int num782 = 6;
                                                                if (this.life < this.lifeMax / 3)
                                                                {
                                                                    num782 = 4;
                                                                }
                                                                if (this.life < this.lifeMax / 4)
                                                                {
                                                                    num782 = 3;
                                                                }
                                                                if (flag147 && flag148 && Main.rand.Next(num782) == 0 && num781 != 0 && num781 != 4 && num781 != 5 && NPC.CountNPCS(523) < 10)
                                                                {
                                                                    num781 = 6;
                                                                }
                                                                if (num781 == 0)
                                                                {
                                                                    Vector2 center85 = (player8.Center + new Vector2(0f, -100f)) - center84;
                                                                    float single527 = (float)Math.Ceiling((double)(center85.Length() / 50f));
                                                                    if (single527 == 0f)
                                                                    {
                                                                        single527 = 1f;
                                                                    }
                                                                    List<int> nums1 = new List<int>();
                                                                    int num783 = 0;
                                                                    nums1.Add(this.whoAmI);
                                                                    for (int n6 = 0; n6 < 200; n6++)
                                                                    {
                                                                        if (Main.npc[n6].active && Main.npc[n6].type == 440 && Main.npc[n6].ai[3] == (float)this.whoAmI)
                                                                        {
                                                                            nums1.Add(n6);
                                                                        }
                                                                    }
                                                                    bool count = nums1.Count % 2 == 0;
                                                                    foreach (int num784 in nums1)
                                                                    {
                                                                        NPC nPC247 = Main.npc[num784];
                                                                        Vector2 center86 = nPC247.Center;
                                                                        float single528 = (float)((num783 + count.ToInt() + 1) / 2) * 6.28318548f * 0.4f / (float)nums1.Count;
                                                                        if (num783 % 2 == 1)
                                                                        {
                                                                            single528 = single528 * -1f;
                                                                        }
                                                                        if (nums1.Count == 1)
                                                                        {
                                                                            single528 = 0f;
                                                                        }
                                                                        Vector2 vector2283 = new Vector2(0f, -1f);
                                                                        double num785 = (double)single528;
                                                                        vector24 = new Vector2();
                                                                        Vector2 vector2284 = vector2283.RotatedBy(num785, vector24) * new Vector2(300f, 200f);
                                                                        Vector2 center87 = (player8.Center + vector2284) - center86;
                                                                        nPC247.ai[0] = 1f;
                                                                        nPC247.ai[1] = single527 * 2f;
                                                                        nPC247.velocity = center87 / single527;
                                                                        if (this.whoAmI >= nPC247.whoAmI)
                                                                        {
                                                                            NPC nPC248 = nPC247;
                                                                            nPC248.position = nPC248.position - nPC247.velocity;
                                                                        }
                                                                        nPC247.netUpdate = true;
                                                                        num783++;
                                                                    }
                                                                }
                                                                if (num781 == 1)
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = 0f;
                                                                }
                                                                else if (num781 == 2)
                                                                {
                                                                    this.ai[0] = 2f;
                                                                    this.ai[1] = 0f;
                                                                }
                                                                else if (num781 == 3)
                                                                {
                                                                    this.ai[0] = 4f;
                                                                    this.ai[1] = 0f;
                                                                }
                                                                else if (num781 == 4)
                                                                {
                                                                    this.ai[0] = 5f;
                                                                    this.ai[1] = 0f;
                                                                }
                                                                if (num781 == 5)
                                                                {
                                                                    this.ai[0] = 7f;
                                                                    this.ai[1] = 0f;
                                                                }
                                                                if (num781 == 6)
                                                                {
                                                                    this.ai[0] = 8f;
                                                                    this.ai[1] = 0f;
                                                                }
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 1f)
                                                        {
                                                            flag150 = true;
                                                            this.localAI[2] = 10f;
                                                            if ((float)((int)this.ai[1]) % 2f != 0f && this.ai[1] != 1f)
                                                            {
                                                                NPC nPC249 = this;
                                                                nPC249.position = nPC249.position - this.velocity;
                                                            }
                                                            this.ai[1] = this.ai[1] - 1f;
                                                            if (this.ai[1] <= 0f)
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 2f)
                                                        {
                                                            this.localAI[2] = 11f;
                                                            Vector2 vector2285 = Vector2.Normalize(player8.Center - center84);
                                                            if (vector2285.HasNaNs())
                                                            {
                                                                vector2285 = new Vector2((float)this.direction, 0f);
                                                            }
                                                            if (this.ai[1] >= 4f && flag149 && (int)(this.ai[1] - 4f) % num766 == 0)
                                                            {
                                                                List<int> nums2 = new List<int>();
                                                                for (int o6 = 0; o6 < 200; o6++)
                                                                {
                                                                    if (Main.npc[o6].active && Main.npc[o6].type == 440 && Main.npc[o6].ai[3] == (float)this.whoAmI)
                                                                    {
                                                                        nums2.Add(o6);
                                                                    }
                                                                }
                                                                foreach (int num786 in nums2)
                                                                {
                                                                    NPC nPC250 = Main.npc[num786];
                                                                    Vector2 center88 = nPC250.Center;
                                                                    int num787 = Math.Sign(player8.Center.X - center88.X);
                                                                    if (num787 != 0)
                                                                    {
                                                                        int num788 = num787;
                                                                        num6 = num788;
                                                                        nPC250.spriteDirection = num788;
                                                                        nPC250.direction = num6;
                                                                    }
                                                                    if (Main.netMode == 1)
                                                                    {
                                                                        continue;
                                                                    }
                                                                    vector2285 = Vector2.Normalize((player8.Center - center88) + (player8.velocity * 20f));
                                                                    if (vector2285.HasNaNs())
                                                                    {
                                                                        vector2285 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    Vector2 vector2286 = center88 + new Vector2((float)(this.direction * 30), 12f);
                                                                    for (int p6 = 0; p6 < 1; p6++)
                                                                    {
                                                                        Vector2 vector2287 = vector2285 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                        vector2287 = vector2287.RotatedByRandom(0.523598790168762);
                                                                        Projectile.NewProjectile(vector2286.X, vector2286.Y, vector2287.X, vector2287.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                    }
                                                                }
                                                                if (Main.netMode != 1)
                                                                {
                                                                    vector2285 = Vector2.Normalize((player8.Center - center84) + (player8.velocity * 20f));
                                                                    if (vector2285.HasNaNs())
                                                                    {
                                                                        vector2285 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    Vector2 center89 = base.Center + new Vector2((float)(this.direction * 30), 12f);
                                                                    for (int q6 = 0; q6 < 1; q6++)
                                                                    {
                                                                        Vector2 vector2288 = vector2285 * 4f;
                                                                        Projectile.NewProjectile(center89.X, center89.Y, vector2288.X, vector2288.Y, 464, num767, 0f, Main.myPlayer, 0f, 1f);
                                                                    }
                                                                }
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= (float)(4 + num766))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 3f)
                                                        {
                                                            this.localAI[2] = 11f;
                                                            Vector2 vector2289 = Vector2.Normalize(player8.Center - center84);
                                                            if (vector2289.HasNaNs())
                                                            {
                                                                vector2289 = new Vector2((float)this.direction, 0f);
                                                            }
                                                            if (this.ai[1] >= 4f && flag149 && (int)(this.ai[1] - 4f) % num768 == 0)
                                                            {
                                                                if ((int)(this.ai[1] - 4f) / num768 == 2)
                                                                {
                                                                    List<int> nums3 = new List<int>();
                                                                    for (int r6 = 0; r6 < 200; r6++)
                                                                    {
                                                                        if (Main.npc[r6].active && Main.npc[r6].type == 440 && Main.npc[r6].ai[3] == (float)this.whoAmI)
                                                                        {
                                                                            nums3.Add(r6);
                                                                        }
                                                                    }
                                                                    foreach (int num789 in nums3)
                                                                    {
                                                                        NPC nPC251 = Main.npc[num789];
                                                                        Vector2 center90 = nPC251.Center;
                                                                        int num790 = Math.Sign(player8.Center.X - center90.X);
                                                                        if (num790 != 0)
                                                                        {
                                                                            int num791 = num790;
                                                                            num6 = num791;
                                                                            nPC251.spriteDirection = num791;
                                                                            nPC251.direction = num6;
                                                                        }
                                                                        if (Main.netMode == 1)
                                                                        {
                                                                            continue;
                                                                        }
                                                                        vector2289 = Vector2.Normalize((player8.Center - center90) + (player8.velocity * 20f));
                                                                        if (vector2289.HasNaNs())
                                                                        {
                                                                            vector2289 = new Vector2((float)this.direction, 0f);
                                                                        }
                                                                        Vector2 vector2290 = center90 + new Vector2((float)(this.direction * 30), 12f);
                                                                        for (int s6 = 0; s6 < 1; s6++)
                                                                        {
                                                                            Vector2 vector2291 = vector2289 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                            vector2291 = vector2291.RotatedByRandom(0.523598790168762);
                                                                            Projectile.NewProjectile(vector2290.X, vector2290.Y, vector2291.X, vector2291.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                        }
                                                                    }
                                                                }
                                                                int num792 = Math.Sign(player8.Center.X - center84.X);
                                                                if (num792 != 0)
                                                                {
                                                                    int num793 = num792;
                                                                    num6 = num793;
                                                                    this.spriteDirection = num793;
                                                                    this.direction = num6;
                                                                }
                                                                if (Main.netMode != 1)
                                                                {
                                                                    vector2289 = Vector2.Normalize((player8.Center - center84) + (player8.velocity * 20f));
                                                                    if (vector2289.HasNaNs())
                                                                    {
                                                                        vector2289 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    Vector2 center91 = base.Center + new Vector2((float)(this.direction * 30), 12f);
                                                                    for (int t6 = 0; t6 < 1; t6++)
                                                                    {
                                                                        Vector2 vector2292 = vector2289 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                        vector2292 = vector2292.RotatedByRandom(0.523598790168762);
                                                                        Projectile.NewProjectile(center91.X, center91.Y, vector2292.X, vector2292.Y, 467, num770, 0f, Main.myPlayer, 0f, 0f);
                                                                    }
                                                                }
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= (float)(4 + num768 * num769))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 4f)
                                                        {
                                                            if (!flag149)
                                                            {
                                                                this.localAI[2] = 11f;
                                                            }
                                                            else
                                                            {
                                                                this.localAI[2] = 12f;
                                                            }
                                                            if (this.ai[1] == 20f && flag149)
                                                            {
                                                                List<int> nums4 = new List<int>();
                                                                for (int u6 = 0; u6 < 200; u6++)
                                                                {
                                                                    if (Main.npc[u6].active && Main.npc[u6].type == 440 && Main.npc[u6].ai[3] == (float)this.whoAmI)
                                                                    {
                                                                        nums4.Add(u6);
                                                                    }
                                                                }
                                                                foreach (int num794 in nums4)
                                                                {
                                                                    NPC nPC252 = Main.npc[num794];
                                                                    Vector2 center92 = nPC252.Center;
                                                                    int num795 = Math.Sign(player8.Center.X - center92.X);
                                                                    if (num795 != 0)
                                                                    {
                                                                        int num796 = num795;
                                                                        num6 = num796;
                                                                        nPC252.spriteDirection = num796;
                                                                        nPC252.direction = num6;
                                                                    }
                                                                    if (Main.netMode == 1)
                                                                    {
                                                                        continue;
                                                                    }
                                                                    Vector2 vector2293 = Vector2.Normalize((player8.Center - center92) + (player8.velocity * 20f));
                                                                    if (vector2293.HasNaNs())
                                                                    {
                                                                        vector2293 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    Vector2 vector2294 = center92 + new Vector2((float)(this.direction * 30), 12f);
                                                                    for (int v6 = 0; v6 < 1; v6++)
                                                                    {
                                                                        Vector2 vector2295 = vector2293 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                        vector2295 = vector2295.RotatedByRandom(0.523598790168762);
                                                                        Projectile.NewProjectile(vector2294.X, vector2294.Y, vector2295.X, vector2295.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                    }
                                                                }
                                                                if ((int)(this.ai[1] - 20f) % num771 == 0)
                                                                {
                                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y - 100f, 0f, 0f, 465, num772, 0f, Main.myPlayer, 0f, 0f);
                                                                }
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= (float)(20 + num771))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 5f)
                                                        {
                                                            this.localAI[2] = 10f;
                                                            Vector2 vector2296 = Vector2.Normalize(player8.Center - center84);
                                                            if (vector2296.HasNaNs())
                                                            {
                                                                vector2296 = new Vector2((float)this.direction, 0f);
                                                            }
                                                            if (this.ai[1] >= 0f && this.ai[1] < 30f)
                                                            {
                                                                flag150 = true;
                                                                flag151 = true;
                                                                float single529 = (this.ai[1] - 0f) / 30f;
                                                                this.alpha = (int)(single529 * 255f);
                                                            }
                                                            else if (this.ai[1] >= 30f && this.ai[1] < 90f)
                                                            {
                                                                if (this.ai[1] == 30f && Main.netMode != 1 && flag149)
                                                                {
                                                                    this.localAI[1] = this.localAI[1] + 1f;
                                                                    Vector2 vector2297 = new Vector2(180f, 0f);
                                                                    List<int> nums5 = new List<int>();
                                                                    for (int w6 = 0; w6 < 200; w6++)
                                                                    {
                                                                        if (Main.npc[w6].active && Main.npc[w6].type == 440 && Main.npc[w6].ai[3] == (float)this.whoAmI)
                                                                        {
                                                                            nums5.Add(w6);
                                                                        }
                                                                    }
                                                                    int count1 = 6 - nums5.Count;
                                                                    if (count1 > 2)
                                                                    {
                                                                        count1 = 2;
                                                                    }
                                                                    int count2 = nums5.Count + count1 + 1;
                                                                    float[] singleArray14 = new float[count2];
                                                                    for (int x610 = 0; x610 < (int)singleArray14.Length; x610++)
                                                                    {
                                                                        Vector2 center93 = base.Center;
                                                                        double num797 = (double)((float)x610 * 6.28318548f / (float)count2 - 1.57079637f);
                                                                        vector24 = new Vector2();
                                                                        singleArray14[x610] = Vector2.Distance(center93 + vector2297.RotatedBy(num797, vector24), player8.Center);
                                                                    }
                                                                    int num798 = 0;
                                                                    for (int y610 = 1; y610 < (int)singleArray14.Length; y610++)
                                                                    {
                                                                        if (singleArray14[num798] > singleArray14[y610])
                                                                        {
                                                                            num798 = y610;
                                                                        }
                                                                    }
                                                                    num798 = (num798 >= count2 / 2 ? num798 - count2 / 2 : num798 + count2 / 2);
                                                                    int num799 = count1;
                                                                    for (int a6 = 0; a6 < (int)singleArray14.Length; a6++)
                                                                    {
                                                                        if (num798 != a6)
                                                                        {
                                                                            Vector2 center94 = base.Center;
                                                                            double num800 = (double)((float)a6 * 6.28318548f / (float)count2 - 1.57079637f);
                                                                            vector24 = new Vector2();
                                                                            Vector2 vector2298 = center94 + vector2297.RotatedBy(num800, vector24);
                                                                            int num801 = num799;
                                                                            num799 = num801 - 1;
                                                                            if (num801 <= 0)
                                                                            {
                                                                                int item = nums5[-num799 - 1];
                                                                                Main.npc[item].Center = vector2298;
                                                                                NetMessage.SendData(23, -1, -1, "", item, 0f, 0f, 0f, 0, 0, 0);
                                                                            }
                                                                            else
                                                                            {
                                                                                int num802 = NPC.NewNPC((int)vector2298.X, (int)vector2298.Y + this.height / 2, 440, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                                                Main.npc[num802].ai[3] = (float)this.whoAmI;
                                                                                Main.npc[num802].netUpdate = true;
                                                                                Main.npc[num802].localAI[1] = this.localAI[1];
                                                                            }
                                                                        }
                                                                    }
                                                                    this.ai[2] = (float)Projectile.NewProjectile(base.Center.X, base.Center.Y, 0f, 0f, 490, 0, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                                    NPC nPC253 = this;
                                                                    Vector2 center95 = nPC253.Center;
                                                                    double num803 = (double)((float)num798 * 6.28318548f / (float)count2 - 1.57079637f);
                                                                    vector24 = new Vector2();
                                                                    nPC253.Center = center95 + vector2297.RotatedBy(num803, vector24);
                                                                    this.netUpdate = true;
                                                                    nums5.Clear();
                                                                }
                                                                flag150 = true;
                                                                flag151 = true;
                                                                this.alpha = 255;
                                                                if (!flag149)
                                                                {
                                                                    Vector2 unitY16 = Main.projectile[(int)Main.npc[(int)this.ai[3]].ai[2]].Center;
                                                                    unitY16 = unitY16 - base.Center;
                                                                    if (unitY16 == Vector2.Zero)
                                                                    {
                                                                        unitY16 = -Vector2.UnitY;
                                                                    }
                                                                    unitY16.Normalize();
                                                                    if (Math.Abs(unitY16.Y) < 0.77f)
                                                                    {
                                                                        this.localAI[2] = 11f;
                                                                    }
                                                                    else if (unitY16.Y >= 0f)
                                                                    {
                                                                        this.localAI[2] = 10f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.localAI[2] = 12f;
                                                                    }
                                                                    int num804 = Math.Sign(unitY16.X);
                                                                    if (num804 != 0)
                                                                    {
                                                                        int num805 = num804;
                                                                        num6 = num805;
                                                                        this.spriteDirection = num805;
                                                                        this.direction = num6;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    Vector2 unitY17 = Main.projectile[(int)this.ai[2]].Center;
                                                                    unitY17 = unitY17 - base.Center;
                                                                    if (unitY17 == Vector2.Zero)
                                                                    {
                                                                        unitY17 = -Vector2.UnitY;
                                                                    }
                                                                    unitY17.Normalize();
                                                                    if (Math.Abs(unitY17.Y) < 0.77f)
                                                                    {
                                                                        this.localAI[2] = 11f;
                                                                    }
                                                                    else if (unitY17.Y >= 0f)
                                                                    {
                                                                        this.localAI[2] = 10f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.localAI[2] = 12f;
                                                                    }
                                                                    int num806 = Math.Sign(unitY17.X);
                                                                    if (num806 != 0)
                                                                    {
                                                                        int num807 = num806;
                                                                        num6 = num807;
                                                                        this.spriteDirection = num807;
                                                                        this.direction = num6;
                                                                    }
                                                                }
                                                            }
                                                            else if (this.ai[1] >= 90f && this.ai[1] < 120f)
                                                            {
                                                                flag150 = true;
                                                                flag151 = true;
                                                                float single530 = (this.ai[1] - 90f) / 30f;
                                                                this.alpha = 255 - (int)(single530 * 255f);
                                                            }
                                                            else if (this.ai[1] >= 120f && this.ai[1] < 420f)
                                                            {
                                                                flag151 = true;
                                                                this.alpha = 0;
                                                                if (!flag149)
                                                                {
                                                                    Vector2 unitY18 = Main.projectile[(int)Main.npc[(int)this.ai[3]].ai[2]].Center;
                                                                    unitY18 = unitY18 - base.Center;
                                                                    if (unitY18 == Vector2.Zero)
                                                                    {
                                                                        unitY18 = -Vector2.UnitY;
                                                                    }
                                                                    unitY18.Normalize();
                                                                    if (Math.Abs(unitY18.Y) < 0.77f)
                                                                    {
                                                                        this.localAI[2] = 11f;
                                                                    }
                                                                    else if (unitY18.Y >= 0f)
                                                                    {
                                                                        this.localAI[2] = 10f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.localAI[2] = 12f;
                                                                    }
                                                                    int num808 = Math.Sign(unitY18.X);
                                                                    if (num808 != 0)
                                                                    {
                                                                        int num809 = num808;
                                                                        num6 = num809;
                                                                        this.spriteDirection = num809;
                                                                        this.direction = num6;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    Vector2 unitY19 = Main.projectile[(int)this.ai[2]].Center;
                                                                    unitY19 = unitY19 - base.Center;
                                                                    if (unitY19 == Vector2.Zero)
                                                                    {
                                                                        unitY19 = -Vector2.UnitY;
                                                                    }
                                                                    unitY19.Normalize();
                                                                    if (Math.Abs(unitY19.Y) < 0.77f)
                                                                    {
                                                                        this.localAI[2] = 11f;
                                                                    }
                                                                    else if (unitY19.Y >= 0f)
                                                                    {
                                                                        this.localAI[2] = 10f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.localAI[2] = 12f;
                                                                    }
                                                                    int num810 = Math.Sign(unitY19.X);
                                                                    if (num810 != 0)
                                                                    {
                                                                        int num811 = num810;
                                                                        num6 = num811;
                                                                        this.spriteDirection = num811;
                                                                        this.direction = num6;
                                                                    }
                                                                }
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= 420f)
                                                            {
                                                                flag151 = true;
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 6f)
                                                        {
                                                            this.localAI[2] = 13f;
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= 120f)
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 7f)
                                                        {
                                                            this.localAI[2] = 11f;
                                                            Vector2 vector2299 = Vector2.Normalize(player8.Center - center84);
                                                            if (vector2299.HasNaNs())
                                                            {
                                                                vector2299 = new Vector2((float)this.direction, 0f);
                                                            }
                                                            if (this.ai[1] >= 4f && flag149 && (int)(this.ai[1] - 4f) % num773 == 0)
                                                            {
                                                                if ((int)(this.ai[1] - 4f) / num773 == 2)
                                                                {
                                                                    List<int> nums6 = new List<int>();
                                                                    for (int b6 = 0; b6 < 200; b6++)
                                                                    {
                                                                        if (Main.npc[b6].active && Main.npc[b6].type == 440 && Main.npc[b6].ai[3] == (float)this.whoAmI)
                                                                        {
                                                                            nums6.Add(b6);
                                                                        }
                                                                    }
                                                                    foreach (int num812 in nums6)
                                                                    {
                                                                        NPC nPC254 = Main.npc[num812];
                                                                        Vector2 center96 = nPC254.Center;
                                                                        int num813 = Math.Sign(player8.Center.X - center96.X);
                                                                        if (num813 != 0)
                                                                        {
                                                                            int num814 = num813;
                                                                            num6 = num814;
                                                                            nPC254.spriteDirection = num814;
                                                                            nPC254.direction = num6;
                                                                        }
                                                                        if (Main.netMode == 1)
                                                                        {
                                                                            continue;
                                                                        }
                                                                        vector2299 = Vector2.Normalize((player8.Center - center96) + (player8.velocity * 20f));
                                                                        if (vector2299.HasNaNs())
                                                                        {
                                                                            vector2299 = new Vector2((float)this.direction, 0f);
                                                                        }
                                                                        Vector2 vector2300 = center96 + new Vector2((float)(this.direction * 30), 12f);
                                                                        for (int c6 = 0; (float)c6 < 5f; c6++)
                                                                        {
                                                                            Vector2 vector2301 = vector2299 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                            vector2301 = vector2301.RotatedByRandom(1.25663709640503);
                                                                            Projectile.NewProjectile(vector2300.X, vector2300.Y, vector2301.X, vector2301.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                        }
                                                                    }
                                                                }
                                                                int num815 = Math.Sign(player8.Center.X - center84.X);
                                                                if (num815 != 0)
                                                                {
                                                                    int num816 = num815;
                                                                    num6 = num816;
                                                                    this.spriteDirection = num816;
                                                                    this.direction = num6;
                                                                }
                                                                if (Main.netMode != 1)
                                                                {
                                                                    vector2299 = Vector2.Normalize((player8.Center - center84) + (player8.velocity * 20f));
                                                                    if (vector2299.HasNaNs())
                                                                    {
                                                                        vector2299 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    Vector2 center97 = base.Center + new Vector2((float)(this.direction * 30), 12f);
                                                                    float single531 = 8f;
                                                                    float single532 = 0.251327425f;
                                                                    for (int d6 = 0; (float)d6 < 5f; d6++)
                                                                    {
                                                                        Vector2 vector2302 = vector2299 * single531;
                                                                        double num817 = (double)(single532 * (float)d6 - (1.2566371f - single532) / 2f);
                                                                        vector24 = new Vector2();
                                                                        vector2302 = vector2302.RotatedBy(num817, vector24);
                                                                        float single533 = (Main.rand.NextFloat() - 0.5f) * 0.3f * 6.28318548f / 60f;
                                                                        int num818 = NPC.NewNPC((int)center97.X, (int)center97.Y + 7, 522, 0, 0f, single533, vector2302.X, vector2302.Y, 255);
                                                                        Main.npc[num818].velocity = vector2302;
                                                                    }
                                                                }
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= (float)(4 + num773 * num774))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 8f)
                                                        {
                                                            this.localAI[2] = 13f;
                                                            if (this.ai[1] >= 4f && flag149 && (int)(this.ai[1] - 4f) % num775 == 0)
                                                            {
                                                                List<int> nums7 = new List<int>();
                                                                for (int e6 = 0; e6 < 200; e6++)
                                                                {
                                                                    if (Main.npc[e6].active && Main.npc[e6].type == 440 && Main.npc[e6].ai[3] == (float)this.whoAmI)
                                                                    {
                                                                        nums7.Add(e6);
                                                                    }
                                                                }
                                                                int count3 = nums7.Count + 1;
                                                                if (count3 > 3)
                                                                {
                                                                    count3 = 3;
                                                                }
                                                                int num819 = Math.Sign(player8.Center.X - center84.X);
                                                                if (num819 != 0)
                                                                {
                                                                    int num820 = num819;
                                                                    num6 = num820;
                                                                    this.spriteDirection = num820;
                                                                    this.direction = num6;
                                                                }
                                                                if (Main.netMode != 1)
                                                                {
                                                                    for (int f6 = 0; f6 < count3; f6++)
                                                                    {
                                                                        Point point5 = base.Center.ToTileCoordinates();
                                                                        Point tileCoordinates6 = Main.player[this.target].Center.ToTileCoordinates();
                                                                        Vector2 center98 = Main.player[this.target].Center - base.Center;
                                                                        int num821 = 20;
                                                                        int num822 = 3;
                                                                        int num823 = 7;
                                                                        int num824 = 2;
                                                                        int num825 = 0;
                                                                        bool flag152 = false;
                                                                        if (center98.Length() > 2000f)
                                                                        {
                                                                            flag152 = true;
                                                                        }
                                                                        while (!flag152 && num825 < 100)
                                                                        {
                                                                            num825++;
                                                                            int num826 = Main.rand.Next(tileCoordinates6.X - num821, tileCoordinates6.X + num821 + 1);
                                                                            int num827 = Main.rand.Next(tileCoordinates6.Y - num821, tileCoordinates6.Y + num821 + 1);
                                                                            if (num827 >= tileCoordinates6.Y - num823 && num827 <= tileCoordinates6.Y + num823 && num826 >= tileCoordinates6.X - num823 && num826 <= tileCoordinates6.X + num823 || num827 >= point5.Y - num822 && num827 <= point5.Y + num822 && num826 >= point5.X - num822 && num826 <= point5.X + num822 || Main.tile[num826, num827].nactive())
                                                                            {
                                                                                continue;
                                                                            }
                                                                            bool flag153 = true;
                                                                            if (flag153 && Collision.SolidTiles(num826 - num824, num826 + num824, num827 - num824, num827 + num824))
                                                                            {
                                                                                flag153 = false;
                                                                            }
                                                                            if (!flag153)
                                                                            {
                                                                                continue;
                                                                            }
                                                                            NPC.NewNPC(num826 * 16 + 8, num827 * 16 + 8, 523, 0, (float)this.whoAmI, 0f, 0f, 0f, 255);
                                                                            flag152 = true;
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= (float)(4 + num775 * num776))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                this.velocity = Vector2.Zero;
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                        if (!flag149)
                                                        {
                                                            this.ai[3] = single526;
                                                        }
                                                        this.dontTakeDamage = flag150;
                                                        this.chaseable = !flag151;
                                                        return;
                                                    }
                                                    if (this.aiStyle == 85)
                                                    {
                                                        this.noTileCollide = false;
                                                        if (this.ai[0] == 0f)
                                                        {
                                                            this.TargetClosest(true);
                                                            if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                Vector2 center99 = Main.player[this.target].Center - base.Center;
                                                                center99.Y = center99.Y - (float)(Main.player[this.target].height / 4);
                                                                if (center99.Length() <= 800f)
                                                                {
                                                                    Vector2 center100 = base.Center;
                                                                    center100.X = Main.player[this.target].Center.X;
                                                                    Vector2 center101 = center100 - base.Center;
                                                                    if (center101.Length() <= 8f || !Collision.CanHit(base.Center, 1, 1, center100, 1, 1))
                                                                    {
                                                                        center100 = base.Center;
                                                                        center100.Y = Main.player[this.target].Center.Y;
                                                                        center101 = center100 - base.Center;
                                                                        if (center101.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center100, 1, 1))
                                                                        {
                                                                            this.ai[0] = 3f;
                                                                            this.ai[1] = center100.X;
                                                                            this.ai[2] = center100.Y;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        this.ai[0] = 3f;
                                                                        this.ai[1] = center100.X;
                                                                        this.ai[2] = center100.Y;
                                                                        Vector2 center102 = base.Center;
                                                                        center102.Y = Main.player[this.target].Center.Y;
                                                                        if (center101.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center102, 1, 1) && Collision.CanHit(center102, 1, 1, Main.player[this.target].position, 1, 1))
                                                                        {
                                                                            this.ai[0] = 3f;
                                                                            this.ai[1] = center102.X;
                                                                            this.ai[2] = center102.Y;
                                                                        }
                                                                    }
                                                                    if (this.ai[0] == 0f)
                                                                    {
                                                                        this.localAI[0] = 0f;
                                                                        center99.Normalize();
                                                                        center99 = center99 * 0.5f;
                                                                        NPC nPC255 = this;
                                                                        nPC255.velocity = nPC255.velocity + center99;
                                                                        this.ai[0] = 4f;
                                                                        this.ai[1] = 0f;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    this.ai[0] = 2f;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                this.ai[0] = 1f;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 1f)
                                                        {
                                                            NPC nPC256 = this;
                                                            nPC256.rotation = nPC256.rotation + (float)this.direction * 0.3f;
                                                            Vector2 top = Main.player[this.target].Center - base.Center;
                                                            if (this.type == 421)
                                                            {
                                                                top = Main.player[this.target].Top - base.Center;
                                                            }
                                                            float single534 = top.Length();
                                                            float single535 = 5.5f + single534 / 100f;
                                                            int num828 = 50;
                                                            top.Normalize();
                                                            top = top * single535;
                                                            this.velocity = ((this.velocity * (float)(num828 - 1)) + top) / (float)num828;
                                                            if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                            }
                                                            if (this.type == 421 && single534 < 40f && Main.player[this.target].active && !Main.player[this.target].dead)
                                                            {
                                                                bool flag154 = true;
                                                                int num829 = 0;
                                                                while (num829 < 200)
                                                                {
                                                                    NPC nPC257 = Main.npc[num829];
                                                                    if (!nPC257.active || nPC257.type != this.type || nPC257.ai[0] != 5f || nPC257.target != this.target)
                                                                    {
                                                                        num829++;
                                                                    }
                                                                    else
                                                                    {
                                                                        flag154 = false;
                                                                        break;
                                                                    }
                                                                }
                                                                if (flag154)
                                                                {
                                                                    base.Center = Main.player[this.target].Top;
                                                                    this.velocity = Vector2.Zero;
                                                                    this.ai[0] = 5f;
                                                                    this.ai[1] = 0f;
                                                                    this.netUpdate = true;
                                                                }
                                                            }
                                                        }
                                                        else if (this.ai[0] == 2f)
                                                        {
                                                            this.rotation = this.velocity.X * 0.1f;
                                                            this.noTileCollide = true;
                                                            Vector2 center103 = Main.player[this.target].Center - base.Center;
                                                            float single536 = center103.Length();
                                                            float single537 = 3f;
                                                            int num830 = 3;
                                                            center103.Normalize();
                                                            center103 = center103 * single537;
                                                            this.velocity = ((this.velocity * (float)(num830 - 1)) + center103) / (float)num830;
                                                            if (single536 < 600f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                            {
                                                                this.ai[0] = 0f;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 3f)
                                                        {
                                                            this.rotation = this.velocity.X * 0.1f;
                                                            Vector2 vector2303 = new Vector2(this.ai[1], this.ai[2]);
                                                            Vector2 center104 = vector2303 - base.Center;
                                                            float single538 = center104.Length();
                                                            float single539 = 2f;
                                                            float single540 = 3f;
                                                            center104.Normalize();
                                                            center104 = center104 * single539;
                                                            this.velocity = ((this.velocity * (single540 - 1f)) + center104) / single540;
                                                            if (this.collideX || this.collideY)
                                                            {
                                                                this.ai[0] = 4f;
                                                                this.ai[1] = 0f;
                                                            }
                                                            if (single538 < single539 || single538 > 800f || Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 0f;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 4f)
                                                        {
                                                            this.rotation = this.velocity.X * 0.1f;
                                                            if (this.collideX)
                                                            {
                                                                this.velocity.X = this.velocity.X * -0.8f;
                                                            }
                                                            if (this.collideY)
                                                            {
                                                                this.velocity.Y = this.velocity.Y * -0.8f;
                                                            }
                                                            if (this.velocity.X == 0f && this.velocity.Y == 0f)
                                                            {
                                                                center = Main.player[this.target].Center - base.Center;
                                                                center.Y = center.Y - (float)(Main.player[this.target].height / 4);
                                                                center.Normalize();
                                                                this.velocity = center * 0.1f;
                                                            }
                                                            float single541 = 2f;
                                                            float single542 = 20f;
                                                            center = this.velocity;
                                                            center.Normalize();
                                                            center = center * single541;
                                                            this.velocity = ((this.velocity * (single542 - 1f)) + center) / single542;
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] > 180f)
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                            }
                                                            if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 0f;
                                                            }
                                                            this.localAI[0] = this.localAI[0] + 1f;
                                                            if (this.localAI[0] >= 5f && !Collision.SolidCollision(this.position - new Vector2(10f, 10f), this.width + 20, this.height + 20))
                                                            {
                                                                this.localAI[0] = 0f;
                                                                Vector2 center105 = base.Center;
                                                                center105.X = Main.player[this.target].Center.X;
                                                                if (!Collision.CanHit(base.Center, 1, 1, center105, 1, 1) || !Collision.CanHit(base.Center, 1, 1, center105, 1, 1) || !Collision.CanHit(Main.player[this.target].Center, 1, 1, center105, 1, 1))
                                                                {
                                                                    center105 = base.Center;
                                                                    center105.Y = Main.player[this.target].Center.Y;
                                                                    if (Collision.CanHit(base.Center, 1, 1, center105, 1, 1) && Collision.CanHit(Main.player[this.target].Center, 1, 1, center105, 1, 1))
                                                                    {
                                                                        this.ai[0] = 3f;
                                                                        this.ai[1] = center105.X;
                                                                        this.ai[2] = center105.Y;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = center105.X;
                                                                    this.ai[2] = center105.Y;
                                                                }
                                                            }
                                                        }
                                                        else if (this.ai[0] == 5f)
                                                        {
                                                            Player player9 = Main.player[this.target];
                                                            if (!player9.active || player9.dead)
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.netUpdate = true;
                                                            }
                                                            else
                                                            {
                                                                base.Center = (player9.gravDir == 1f ? player9.Top : player9.Bottom) + new Vector2((float)(player9.direction * 4), 0f);
                                                                this.gfxOffY = player9.gfxOffY;
                                                                this.velocity = Vector2.Zero;
                                                                player9.AddBuff(163, 59, true);
                                                            }
                                                        }
                                                        if (this.type == 405)
                                                        {
                                                            this.rotation = 0f;
                                                            for (int g6 = 0; g6 < 200; g6++)
                                                            {
                                                                if (g6 != this.whoAmI && Main.npc[g6].active && Main.npc[g6].type == this.type && Math.Abs(this.position.X - Main.npc[g6].position.X) + Math.Abs(this.position.Y - Main.npc[g6].position.Y) < (float)this.width)
                                                                {
                                                                    if (this.position.X >= Main.npc[g6].position.X)
                                                                    {
                                                                        this.velocity.X = this.velocity.X + 0.05f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.X = this.velocity.X - 0.05f;
                                                                    }
                                                                    if (this.position.Y >= Main.npc[g6].position.Y)
                                                                    {
                                                                        this.velocity.Y = this.velocity.Y + 0.05f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.Y = this.velocity.Y - 0.05f;
                                                                    }
                                                                }
                                                            }
                                                            return;
                                                        }
                                                        if (this.type == 421)
                                                        {
                                                            this.hide = this.ai[0] == 5f;
                                                            this.rotation = this.velocity.X * 0.1f;
                                                            for (int h6 = 0; h6 < 200; h6++)
                                                            {
                                                                if (h6 != this.whoAmI && Main.npc[h6].active && Main.npc[h6].type == this.type && Math.Abs(this.position.X - Main.npc[h6].position.X) + Math.Abs(this.position.Y - Main.npc[h6].position.Y) < (float)this.width)
                                                                {
                                                                    if (this.position.X >= Main.npc[h6].position.X)
                                                                    {
                                                                        this.velocity.X = this.velocity.X + 0.05f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.X = this.velocity.X - 0.05f;
                                                                    }
                                                                    if (this.position.Y >= Main.npc[h6].position.Y)
                                                                    {
                                                                        this.velocity.Y = this.velocity.Y + 0.05f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.Y = this.velocity.Y - 0.05f;
                                                                    }
                                                                }
                                                            }
                                                            return;
                                                        }
                                                    }
                                                    else if (this.aiStyle == 86)
                                                    {
                                                        if (this.alpha > 0)
                                                        {
                                                            NPC nPC258 = this;
                                                            nPC258.alpha = nPC258.alpha - 30;
                                                            if (this.alpha < 0)
                                                            {
                                                                this.alpha = 0;
                                                            }
                                                        }
                                                        this.noGravity = true;
                                                        this.noTileCollide = true;
                                                        this.knockBackResist = 0f;
                                                        for (int i7 = 0; i7 < 200; i7++)
                                                        {
                                                            if (i7 != this.whoAmI && Main.npc[i7].active && Main.npc[i7].type == this.type)
                                                            {
                                                                Vector2 center106 = Main.npc[i7].Center - base.Center;
                                                                if (center106.Length() < 50f)
                                                                {
                                                                    center106.Normalize();
                                                                    if (center106.X == 0f && center106.Y == 0f)
                                                                    {
                                                                        if (i7 <= this.whoAmI)
                                                                        {
                                                                            center106.X = -1f;
                                                                        }
                                                                        else
                                                                        {
                                                                            center106.X = 1f;
                                                                        }
                                                                    }
                                                                    center106 = center106 * 0.4f;
                                                                    NPC nPC259 = this;
                                                                    nPC259.velocity = nPC259.velocity - center106;
                                                                    NPC nPC260 = Main.npc[i7];
                                                                    nPC260.velocity = nPC260.velocity + center106;
                                                                }
                                                            }
                                                        }
                                                        if (this.type == 472)
                                                        {
                                                            float single543 = 120f;
                                                            if (this.localAI[0] < single543)
                                                            {
                                                                if (this.localAI[0] == 0f)
                                                                {
                                                                    this.TargetClosest(true);
                                                                    if (this.direction <= 0)
                                                                    {
                                                                        this.velocity.X = this.velocity.X - 2f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.X = this.velocity.X + 2f;
                                                                    }
                                                                }
                                                                this.localAI[0] = this.localAI[0] + 1f;
                                                            }
                                                        }
                                                        if (this.type == 521 && this.localAI[0] < 120f)
                                                        {
                                                            if (this.localAI[0] == 0f)
                                                            {
                                                                this.TargetClosest(true);
                                                                if (this.direction <= 0)
                                                                {
                                                                    this.velocity.X = this.velocity.X - 2f;
                                                                }
                                                                else
                                                                {
                                                                    this.velocity.X = this.velocity.X + 2f;
                                                                }
                                                            }
                                                            this.localAI[0] = this.localAI[0] + 1f;
                                                            int num835 = 10;
                                                        }
                                                        if (this.ai[0] == 0f)
                                                        {
                                                            this.TargetClosest(true);
                                                            this.ai[0] = 1f;
                                                            this.ai[1] = (float)this.direction;
                                                        }
                                                        else if (this.ai[0] == 1f)
                                                        {
                                                            this.TargetClosest(true);
                                                            float single546 = 0.3f;
                                                            float single547 = 7f;
                                                            float single548 = 4f;
                                                            float single549 = 660f;
                                                            float single550 = 4f;
                                                            if (this.type == 521)
                                                            {
                                                                single546 = 0.7f;
                                                                single547 = 14f;
                                                                single549 = 500f;
                                                                single548 = 6f;
                                                                single550 = 3f;
                                                            }
                                                            this.velocity.X = this.velocity.X + this.ai[1] * single546;
                                                            if (this.velocity.X > single547)
                                                            {
                                                                this.velocity.X = single547;
                                                            }
                                                            if (this.velocity.X < -single547)
                                                            {
                                                                this.velocity.X = -single547;
                                                            }
                                                            float y211 = Main.player[this.target].Center.Y - base.Center.Y;
                                                            if (Math.Abs(y211) > single548)
                                                            {
                                                                single550 = 15f;
                                                            }
                                                            if (y211 > single548)
                                                            {
                                                                y211 = single548;
                                                            }
                                                            else if (y211 < -single548)
                                                            {
                                                                y211 = -single548;
                                                            }
                                                            this.velocity.Y = (this.velocity.Y * (single550 - 1f) + y211) / single550;
                                                            if (this.ai[1] > 0f && Main.player[this.target].Center.X - base.Center.X < -single549 || this.ai[1] < 0f && Main.player[this.target].Center.X - base.Center.X > single549)
                                                            {
                                                                this.ai[0] = 2f;
                                                                this.ai[1] = 0f;
                                                                if (base.Center.Y + 20f <= Main.player[this.target].Center.Y)
                                                                {
                                                                    this.ai[1] = 1f;
                                                                }
                                                                else
                                                                {
                                                                    this.ai[1] = -1f;
                                                                }
                                                            }
                                                        }
                                                        else if (this.ai[0] == 2f)
                                                        {
                                                            float single551 = 0.4f;
                                                            float single552 = 0.95f;
                                                            float single553 = 5f;
                                                            if (this.type == 521)
                                                            {
                                                                single551 = 0.3f;
                                                                single553 = 7f;
                                                                single552 = 0.9f;
                                                            }
                                                            this.velocity.Y = this.velocity.Y + this.ai[1] * single551;
                                                            if (this.velocity.Length() > single553)
                                                            {
                                                                NPC nPC261 = this;
                                                                nPC261.velocity = nPC261.velocity * single552;
                                                            }
                                                            if (this.velocity.X > -1f && this.velocity.X < 1f)
                                                            {
                                                                this.TargetClosest(true);
                                                                this.ai[0] = 3f;
                                                                this.ai[1] = (float)this.direction;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 3f)
                                                        {
                                                            float single554 = 0.4f;
                                                            float single555 = 0.2f;
                                                            float single556 = 5f;
                                                            float single557 = 0.95f;
                                                            if (this.type == 521)
                                                            {
                                                                single554 = 0.6f;
                                                                single555 = 0.3f;
                                                                single556 = 7f;
                                                                single557 = 0.9f;
                                                            }
                                                            this.velocity.X = this.velocity.X + this.ai[1] * single554;
                                                            if (base.Center.Y <= Main.player[this.target].Center.Y)
                                                            {
                                                                this.velocity.Y = this.velocity.Y + single555;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.Y = this.velocity.Y - single555;
                                                            }
                                                            if (this.velocity.Length() > single556)
                                                            {
                                                                NPC nPC262 = this;
                                                                nPC262.velocity = nPC262.velocity * single557;
                                                            }
                                                            if (this.velocity.Y > -1f && this.velocity.Y < 1f)
                                                            {
                                                                this.TargetClosest(true);
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = (float)this.direction;
                                                            }
                                                        }
                                                        if (this.type == 521)
                                                        {
                                                            int num837 = 10;
                                                            return;
                                                        }
                                                    }
                                                    else if (this.aiStyle == 87)
                                                    {
                                                        this.knockBackResist = 0.2f * Main.knockBackMultiplier;
                                                        this.dontTakeDamage = false;
                                                        this.noTileCollide = false;
                                                        this.noGravity = false;
                                                        this.reflectingProjectiles = false;
                                                        if (this.ai[0] != 7f && Main.player[this.target].dead)
                                                        {
                                                            this.TargetClosest(true);
                                                            if (Main.player[this.target].dead)
                                                            {
                                                                this.ai[0] = 7f;
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                            }
                                                        }
                                                        if (this.ai[0] == 0f)
                                                        {
                                                            this.TargetClosest(true);
                                                            Vector2 center108 = Main.player[this.target].Center - base.Center;
                                                            if (this.velocity.X != 0f || this.velocity.Y > 100f || this.justHit || center108.Length() < 80f)
                                                            {
                                                                this.ai[0] = 1f;
                                                                this.ai[1] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 1f)
                                                        {
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] > 36f)
                                                            {
                                                                this.ai[0] = 2f;
                                                                this.ai[1] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 2f)
                                                        {
                                                            if ((Main.player[this.target].Center - base.Center).Length() > 600f)
                                                            {
                                                                this.ai[0] = 5f;
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                            }
                                                            if (this.velocity.Y != 0f)
                                                            {
                                                                this.knockBackResist = 0f;
                                                                this.velocity.X = this.velocity.X * 0.99f;
                                                                if (this.direction < 0 && this.velocity.X > -1f)
                                                                {
                                                                    this.velocity.X = -1f;
                                                                }
                                                                if (this.direction > 0 && this.velocity.X < 1f)
                                                                {
                                                                    this.velocity.X = 1f;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                this.TargetClosest(true);
                                                                this.velocity.X = this.velocity.X * 0.85f;
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                float single558 = 15f + 30f * ((float)this.life / (float)this.lifeMax);
                                                                float single559 = 3f + 4f * (1f - (float)this.life / (float)this.lifeMax);
                                                                float single560 = 4f;
                                                                if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                                {
                                                                    single560 = single560 + 2f;
                                                                }
                                                                if (this.ai[1] > single558)
                                                                {
                                                                    this.ai[3] = this.ai[3] + 1f;
                                                                    if (this.ai[3] >= 3f)
                                                                    {
                                                                        this.ai[3] = 0f;
                                                                        single560 = single560 * 2f;
                                                                        single559 = single559 / 2f;
                                                                    }
                                                                    this.ai[1] = 0f;
                                                                    this.velocity.Y = this.velocity.Y - single560;
                                                                    this.velocity.X = single559 * (float)this.direction;
                                                                }
                                                            }
                                                            this.ai[2] = this.ai[2] + 1f;
                                                            if ((double)this.ai[2] > 210 && this.velocity.Y == 0f && Main.netMode != 1)
                                                            {
                                                                int num839 = Main.rand.Next(3);
                                                                if (num839 == 0)
                                                                {
                                                                    this.ai[0] = 3f;
                                                                }
                                                                else if (num839 == 1)
                                                                {
                                                                    this.ai[0] = 4f;
                                                                    this.noTileCollide = true;
                                                                    this.velocity.Y = -8f;
                                                                }
                                                                else if (num839 != 2)
                                                                {
                                                                    this.ai[0] = 2f;
                                                                }
                                                                else
                                                                {
                                                                    this.ai[0] = 6f;
                                                                }
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 3f)
                                                        {
                                                            this.velocity.X = this.velocity.X * 0.85f;
                                                            this.dontTakeDamage = true;
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= 180f)
                                                            {
                                                                this.ai[0] = 2f;
                                                                this.ai[1] = 0f;
                                                            }
                                                            if (Main.expertMode)
                                                            {
                                                                this.ReflectProjectiles(base.Hitbox);
                                                                this.reflectingProjectiles = true;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 4f)
                                                        {
                                                            this.noTileCollide = true;
                                                            this.noGravity = true;
                                                            this.knockBackResist = 0f;
                                                            if (this.velocity.X >= 0f)
                                                            {
                                                                this.direction = 1;
                                                            }
                                                            else
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            this.spriteDirection = this.direction;
                                                            this.TargetClosest(true);
                                                            Vector2 center109 = Main.player[this.target].Center;
                                                            center109.Y = center109.Y - 350f;
                                                            Vector2 center110 = center109 - base.Center;
                                                            if (this.ai[2] != 1f)
                                                            {
                                                                if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 40f && base.Center.Y < Main.player[this.target].Center.Y - 300f)
                                                                {
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 1f;
                                                                    return;
                                                                }
                                                                center110.Normalize();
                                                                center110 = center110 * 12f;
                                                                this.velocity = ((this.velocity * 5f) + center110) / 6f;
                                                                return;
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            center110 = Main.player[this.target].Center - base.Center;
                                                            center110.Normalize();
                                                            center110 = center110 * 8f;
                                                            this.velocity = ((this.velocity * 4f) + center110) / 5f;
                                                            if (this.ai[1] > 6f)
                                                            {
                                                                this.ai[1] = 0f;
                                                                this.ai[0] = 4.1f;
                                                                this.ai[2] = 0f;
                                                                this.velocity = center110;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] != 4.1f)
                                                        {
                                                            if (this.ai[0] == 5f)
                                                            {
                                                                if (this.velocity.X <= 0f)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                this.noTileCollide = true;
                                                                this.noGravity = true;
                                                                this.knockBackResist = 0f;
                                                                Vector2 center111 = Main.player[this.target].Center - base.Center;
                                                                center111.Y = center111.Y - 4f;
                                                                if (center111.Length() < 200f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                                {
                                                                    this.ai[0] = 2f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                }
                                                                if (center111.Length() > 10f)
                                                                {
                                                                    center111.Normalize();
                                                                    center111 = center111 * 10f;
                                                                }
                                                                this.velocity = ((this.velocity * 4f) + center111) / 5f;
                                                                return;
                                                            }
                                                            if (this.ai[0] == 6f)
                                                            {
                                                                this.knockBackResist = 0f;
                                                                if (this.velocity.Y != 0f)
                                                                {
                                                                    this.velocity.X = this.velocity.X * 0.98f;
                                                                    if (this.direction < 0 && this.velocity.X > -8f)
                                                                    {
                                                                        this.velocity.X = -8f;
                                                                    }
                                                                    if (this.direction > 0 && this.velocity.X < 8f)
                                                                    {
                                                                        this.velocity.X = 8f;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    this.TargetClosest(true);
                                                                    this.velocity.X = this.velocity.X * 0.8f;
                                                                    this.ai[1] = this.ai[1] + 1f;
                                                                    if (this.ai[1] > 5f)
                                                                    {
                                                                        this.ai[1] = 0f;
                                                                        this.velocity.Y = this.velocity.Y - 4f;
                                                                        if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y)
                                                                        {
                                                                            this.velocity.Y = this.velocity.Y - 1.25f;
                                                                        }
                                                                        if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 40f)
                                                                        {
                                                                            this.velocity.Y = this.velocity.Y - 1.5f;
                                                                        }
                                                                        if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 80f)
                                                                        {
                                                                            this.velocity.Y = this.velocity.Y - 1.75f;
                                                                        }
                                                                        if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 120f)
                                                                        {
                                                                            this.velocity.Y = this.velocity.Y - 2f;
                                                                        }
                                                                        if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 160f)
                                                                        {
                                                                            this.velocity.Y = this.velocity.Y - 2.25f;
                                                                        }
                                                                        if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 200f)
                                                                        {
                                                                            this.velocity.Y = this.velocity.Y - 2.5f;
                                                                        }
                                                                        if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                                        {
                                                                            this.velocity.Y = this.velocity.Y - 2f;
                                                                        }
                                                                        this.velocity.X = (float)(12 * this.direction);
                                                                        this.ai[2] = this.ai[2] + 1f;
                                                                    }
                                                                }
                                                                if (this.ai[2] >= 3f && this.velocity.Y == 0f)
                                                                {
                                                                    this.ai[0] = 2f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                    return;
                                                                }
                                                            }
                                                            else if (this.ai[0] == 7f)
                                                            {
                                                                this.damage = 0;
                                                                this.life = this.lifeMax;
                                                                this.defense = 9999;
                                                                this.noTileCollide = true;
                                                                NPC nPC263 = this;
                                                                nPC263.alpha = nPC263.alpha + 7;
                                                                if (this.alpha > 255)
                                                                {
                                                                    this.alpha = 255;
                                                                }
                                                                this.velocity.X = this.velocity.X * 0.98f;
                                                                return;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            this.knockBackResist = 0f;
                                                            if (this.ai[2] == 0f && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1) && !Collision.SolidCollision(this.position, this.width, this.height))
                                                            {
                                                                this.ai[2] = 1f;
                                                            }
                                                            if (this.position.Y + (float)this.height >= Main.player[this.target].position.Y || this.velocity.Y <= 0f)
                                                            {
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                if (this.ai[1] > 10f)
                                                                {
                                                                    this.ai[0] = 2f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                    if (Collision.SolidCollision(this.position, this.width, this.height))
                                                                    {
                                                                        this.ai[0] = 5f;
                                                                    }
                                                                }
                                                            }
                                                            else if (this.ai[2] == 0f)
                                                            {
                                                                this.noTileCollide = true;
                                                                this.noGravity = true;
                                                                this.knockBackResist = 0f;
                                                            }
                                                            this.velocity.Y = this.velocity.Y + 0.2f;
                                                            if (this.velocity.Y > 16f)
                                                            {
                                                                this.velocity.Y = 16f;
                                                                return;
                                                            }
                                                        }
                                                    }
                                                    else if (this.aiStyle == 88)
                                                    {
                                                        int num840 = 7;
                                                        this.noTileCollide = false;
                                                        this.noGravity = true;
                                                        this.knockBackResist = 0.2f * Main.expertKnockBack;
                                                        this.damage = this.defDamage;
                                                        if (!Main.eclipse)
                                                        {
                                                            this.ai[0] = -1f;
                                                        }
                                                        else if (this.target < 0 || Main.player[this.target].dead || !Main.player[this.target].active)
                                                        {
                                                            this.TargetClosest(true);
                                                            Vector2 center112 = Main.player[this.target].Center - base.Center;
                                                            if (Main.player[this.target].dead || center112.Length() > 3000f)
                                                            {
                                                                this.ai[0] = -1f;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Vector2 center113 = Main.player[this.target].Center - base.Center;
                                                            if (this.ai[0] > 1f && center113.Length() > 1000f)
                                                            {
                                                                this.ai[0] = 1f;
                                                            }
                                                        }
                                                        if (this.ai[0] == -1f)
                                                        {
                                                            Vector2 vector2308 = new Vector2(0f, -8f);
                                                            this.velocity = ((this.velocity * 9f) + vector2308) / 10f;
                                                            this.noTileCollide = true;
                                                            this.dontTakeDamage = true;
                                                            return;
                                                        }
                                                        if (this.ai[0] != 0f)
                                                        {
                                                            if (this.ai[0] == 1f)
                                                            {
                                                                this.collideX = false;
                                                                this.collideY = false;
                                                                this.noTileCollide = true;
                                                                this.knockBackResist = 0f;
                                                                if (this.target < 0 || !Main.player[this.target].active || Main.player[this.target].dead)
                                                                {
                                                                    this.TargetClosest(true);
                                                                }
                                                                if (this.velocity.X < 0f)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else if (this.velocity.X > 0f)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                this.rotation = (this.rotation * 9f + this.velocity.X * 0.08f) / 10f;
                                                                Vector2 center114 = Main.player[this.target].Center - base.Center;
                                                                if (center114.Length() < 300f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                                {
                                                                    this.ai[0] = 0f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                }
                                                                float single561 = 7f + center114.Length() / 100f;
                                                                float single562 = 25f;
                                                                center114.Normalize();
                                                                center114 = center114 * single561;
                                                                this.velocity = ((this.velocity * (single562 - 1f)) + center114) / single562;
                                                                return;
                                                            }
                                                            if (this.ai[0] != 2f)
                                                            {
                                                                if (this.ai[0] == 3f)
                                                                {
                                                                    this.knockBackResist = 0f;
                                                                    this.noTileCollide = true;
                                                                    if (this.velocity.X >= 0f)
                                                                    {
                                                                        this.direction = 1;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.direction = -1;
                                                                    }
                                                                    this.spriteDirection = this.direction;
                                                                    this.rotation = (this.rotation * 4f + this.velocity.X * 0.07f) / 5f;
                                                                    Vector2 center115 = Main.player[this.target].Center - base.Center;
                                                                    center115.Y = center115.Y - 12f;
                                                                    if (base.Center.X <= Main.player[this.target].Center.X)
                                                                    {
                                                                        center115.X = center115.X - 400f;
                                                                    }
                                                                    else
                                                                    {
                                                                        center115.X = center115.X + 400f;
                                                                    }
                                                                    if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 350f && Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) < 20f)
                                                                    {
                                                                        this.ai[0] = 3.1f;
                                                                        this.ai[1] = 0f;
                                                                    }
                                                                    this.ai[1] = this.ai[1] + 0.0333333351f;
                                                                    float single563 = 8f + this.ai[1];
                                                                    float single564 = 4f;
                                                                    center115.Normalize();
                                                                    center115 = center115 * single563;
                                                                    this.velocity = ((this.velocity * (single564 - 1f)) + center115) / single564;
                                                                    return;
                                                                }
                                                                if (this.ai[0] != 3.1f)
                                                                {
                                                                    if (this.ai[0] == 3.2f)
                                                                    {
                                                                        this.damage = (int)((double)this.defDamage * 1.3);
                                                                        this.collideX = false;
                                                                        this.collideY = false;
                                                                        this.knockBackResist = 0f;
                                                                        this.noTileCollide = true;
                                                                        this.ai[2] = this.ai[2] + 0.0333333351f;
                                                                        this.velocity.X = (16f + this.ai[2]) * this.ai[1];
                                                                        if (this.ai[1] > 0f && base.Center.X > Main.player[this.target].Center.X + 260f || this.ai[1] < 0f && base.Center.X < Main.player[this.target].Center.X - 260f)
                                                                        {
                                                                            if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                                            {
                                                                                this.ai[0] = 0f;
                                                                                this.ai[1] = 0f;
                                                                                this.ai[2] = 0f;
                                                                                this.ai[3] = 0f;
                                                                            }
                                                                            else if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 800f)
                                                                            {
                                                                                this.ai[0] = 1f;
                                                                                this.ai[1] = 0f;
                                                                                this.ai[2] = 0f;
                                                                                this.ai[3] = 0f;
                                                                            }
                                                                        }
                                                                        this.rotation = (this.rotation * 4f + this.velocity.X * 0.07f) / 5f;
                                                                        return;
                                                                    }
                                                                    if (this.ai[0] == 4f)
                                                                    {
                                                                        this.ai[0] = 0f;
                                                                        this.TargetClosest(true);
                                                                        if (Main.netMode != 1)
                                                                        {
                                                                            this.ai[1] = -1f;
                                                                            this.ai[2] = -1f;
                                                                            for (int n7 = 0; n7 < 1000; n7++)
                                                                            {
                                                                                int x209 = (int)Main.player[this.target].Center.X / 16;
                                                                                int y212 = (int)Main.player[this.target].Center.Y / 16;
                                                                                int num841 = 30 + n7 / 50;
                                                                                int num842 = 20 + n7 / 75;
                                                                                x209 = x209 + Main.rand.Next(-num841, num841 + 1);
                                                                                y212 = y212 + Main.rand.Next(-num842, num842 + 1);
                                                                                if (!WorldGen.SolidTile(x209, y212))
                                                                                {
                                                                                    while (!WorldGen.SolidTile(x209, y212) && (double)y212 < Main.worldSurface)
                                                                                    {
                                                                                        y212++;
                                                                                    }
                                                                                    if ((new Vector2((float)(x209 * 16 + 8), (float)(y212 * 16 + 8)) - Main.player[this.target].Center).Length() < 600f)
                                                                                    {
                                                                                        this.ai[0] = 4.1f;
                                                                                        this.ai[1] = (float)x209;
                                                                                        this.ai[2] = (float)y212;
                                                                                        break;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        this.netUpdate = true;
                                                                        return;
                                                                    }
                                                                    if (this.ai[0] == 4.1f)
                                                                    {
                                                                        if (this.velocity.X < -2f)
                                                                        {
                                                                            this.direction = -1;
                                                                        }
                                                                        else if (this.velocity.X > 2f)
                                                                        {
                                                                            this.direction = 1;
                                                                        }
                                                                        this.spriteDirection = this.direction;
                                                                        this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                                        this.noTileCollide = true;
                                                                        int num843 = (int)this.ai[1];
                                                                        int num844 = (int)this.ai[2];
                                                                        float single565 = (float)(num843 * 16 + 8);
                                                                        float single566 = (float)(num844 * 16 - 20);
                                                                        Vector2 center116 = new Vector2(single565, single566);
                                                                        center116 = center116 - base.Center;
                                                                        float single567 = 6f + center116.Length() / 150f;
                                                                        if (single567 > 10f)
                                                                        {
                                                                            single567 = 10f;
                                                                        }
                                                                        float single568 = 10f;
                                                                        if (center116.Length() < 10f)
                                                                        {
                                                                            this.ai[0] = 4.2f;
                                                                        }
                                                                        center116.Normalize();
                                                                        center116 = center116 * single567;
                                                                        this.velocity = ((this.velocity * (single568 - 1f)) + center116) / single568;
                                                                        return;
                                                                    }
                                                                    if (this.ai[0] == 4.2f)
                                                                    {
                                                                        this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                                        this.knockBackResist = 0f;
                                                                        this.noTileCollide = true;
                                                                        int num845 = (int)this.ai[1];
                                                                        int num846 = (int)this.ai[2];
                                                                        float single569 = (float)(num845 * 16 + 8);
                                                                        float single570 = (float)(num846 * 16 - 20);
                                                                        Vector2 center117 = new Vector2(single569, single570);
                                                                        center117 = center117 - base.Center;
                                                                        float single571 = 4f;
                                                                        float single572 = 2f;
                                                                        if (Main.netMode != 1 && center117.Length() < 4f)
                                                                        {
                                                                            int num847 = 70;
                                                                            if (Main.expertMode)
                                                                            {
                                                                                num847 = (int)((double)num847 * 0.75);
                                                                            }
                                                                            this.ai[3] = this.ai[3] + 1f;
                                                                            if (this.ai[3] == (float)num847)
                                                                            {
                                                                                NPC.NewNPC(num845 * 16 + 8, num846 * 16, 478, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                                            }
                                                                            else if (this.ai[3] == (float)(num847 * 2))
                                                                            {
                                                                                this.ai[0] = 0f;
                                                                                this.ai[1] = 0f;
                                                                                this.ai[2] = 0f;
                                                                                this.ai[3] = 0f;
                                                                                if (NPC.CountNPCS(478) + NPC.CountNPCS(479) < num840 && Main.rand.Next(3) != 0)
                                                                                {
                                                                                    this.ai[0] = 4f;
                                                                                }
                                                                                else if (Collision.SolidCollision(this.position, this.width, this.height))
                                                                                {
                                                                                    this.ai[0] = 1f;
                                                                                }
                                                                            }
                                                                        }
                                                                        if (center117.Length() > single571)
                                                                        {
                                                                            center117.Normalize();
                                                                            center117 = center117 * single571;
                                                                        }
                                                                        this.velocity = ((this.velocity * (single572 - 1f)) + center117) / single572;
                                                                        return;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    this.knockBackResist = 0f;
                                                                    this.noTileCollide = true;
                                                                    this.rotation = (this.rotation * 4f + this.velocity.X * 0.07f) / 5f;
                                                                    Vector2 center118 = Main.player[this.target].Center - base.Center;
                                                                    center118.Y = center118.Y - 12f;
                                                                    float single573 = 16f;
                                                                    float single574 = 8f;
                                                                    center118.Normalize();
                                                                    center118 = center118 * single573;
                                                                    this.velocity = ((this.velocity * (single574 - 1f)) + center118) / single574;
                                                                    if (this.velocity.X >= 0f)
                                                                    {
                                                                        this.direction = 1;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.direction = -1;
                                                                    }
                                                                    this.spriteDirection = this.direction;
                                                                    this.ai[1] = this.ai[1] + 1f;
                                                                    if (this.ai[1] > 10f)
                                                                    {
                                                                        this.velocity = center118;
                                                                        if (this.velocity.X >= 0f)
                                                                        {
                                                                            this.direction = 1;
                                                                        }
                                                                        else
                                                                        {
                                                                            this.direction = -1;
                                                                        }
                                                                        this.ai[0] = 3.2f;
                                                                        this.ai[1] = 0f;
                                                                        this.ai[1] = (float)this.direction;
                                                                        return;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                this.damage = (int)((double)this.defDamage * 0.5);
                                                                this.knockBackResist = 0f;
                                                                if (this.target < 0 || !Main.player[this.target].active || Main.player[this.target].dead)
                                                                {
                                                                    this.TargetClosest(true);
                                                                    this.ai[0] = 0f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                }
                                                                if (Main.player[this.target].Center.X - 10f < base.Center.X)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else if (Main.player[this.target].Center.X + 10f > base.Center.X)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                this.rotation = (this.rotation * 4f + this.velocity.X * 0.1f) / 5f;
                                                                if (this.collideX)
                                                                {
                                                                    this.velocity.X = this.velocity.X * (-this.oldVelocity.X * 0.5f);
                                                                    if (this.velocity.X > 4f)
                                                                    {
                                                                        this.velocity.X = 4f;
                                                                    }
                                                                    if (this.velocity.X < -4f)
                                                                    {
                                                                        this.velocity.X = -4f;
                                                                    }
                                                                }
                                                                if (this.collideY)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y * (-this.oldVelocity.Y * 0.5f);
                                                                    if (this.velocity.Y > 4f)
                                                                    {
                                                                        this.velocity.Y = 4f;
                                                                    }
                                                                    if (this.velocity.Y < -4f)
                                                                    {
                                                                        this.velocity.Y = -4f;
                                                                    }
                                                                }
                                                                Vector2 center119 = Main.player[this.target].Center - base.Center;
                                                                center119.Y = center119.Y - 20f;
                                                                this.ai[2] = this.ai[2] + 0.0222222228f;
                                                                if (Main.expertMode)
                                                                {
                                                                    this.ai[2] = this.ai[2] + 0.0166666675f;
                                                                }
                                                                float single575 = 4f + this.ai[2] + center119.Length() / 120f;
                                                                float single576 = 20f;
                                                                center119.Normalize();
                                                                center119 = center119 * single575;
                                                                this.velocity = ((this.velocity * (single576 - 1f)) + center119) / single576;
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                if (this.ai[1] > 240f || !Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                                {
                                                                    this.ai[0] = 0f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            this.TargetClosest(true);
                                                            if (base.Center.X < Main.player[this.target].Center.X - 2f)
                                                            {
                                                                this.direction = 1;
                                                            }
                                                            if (base.Center.X > Main.player[this.target].Center.X + 2f)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            this.spriteDirection = this.direction;
                                                            this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                            if (this.collideX)
                                                            {
                                                                this.velocity.X = this.velocity.X * (-this.oldVelocity.X * 0.5f);
                                                                if (this.velocity.X > 4f)
                                                                {
                                                                    this.velocity.X = 4f;
                                                                }
                                                                if (this.velocity.X < -4f)
                                                                {
                                                                    this.velocity.X = -4f;
                                                                }
                                                            }
                                                            if (this.collideY)
                                                            {
                                                                this.velocity.Y = this.velocity.Y * (-this.oldVelocity.Y * 0.5f);
                                                                if (this.velocity.Y > 4f)
                                                                {
                                                                    this.velocity.Y = 4f;
                                                                }
                                                                if (this.velocity.Y < -4f)
                                                                {
                                                                    this.velocity.Y = -4f;
                                                                }
                                                            }
                                                            Vector2 center120 = Main.player[this.target].Center - base.Center;
                                                            center120.Y = center120.Y - 200f;
                                                            if (center120.Length() > 800f)
                                                            {
                                                                this.ai[0] = 1f;
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                            }
                                                            else if (center120.Length() > 80f)
                                                            {
                                                                float single577 = 6f;
                                                                float single578 = 30f;
                                                                center120.Normalize();
                                                                center120 = center120 * single577;
                                                                this.velocity = ((this.velocity * (single578 - 1f)) + center120) / single578;
                                                            }
                                                            else if (this.velocity.Length() > 2f)
                                                            {
                                                                NPC nPC264 = this;
                                                                nPC264.velocity = nPC264.velocity * 0.95f;
                                                            }
                                                            else if (this.velocity.Length() < 1f)
                                                            {
                                                                NPC nPC265 = this;
                                                                nPC265.velocity = nPC265.velocity * 1.05f;
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.justHit)
                                                            {
                                                                this.ai[1] = this.ai[1] + (float)Main.rand.Next(10, 30);
                                                            }
                                                            if (this.ai[1] >= 180f && Main.netMode != 1)
                                                            {
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                                this.netUpdate = true;
                                                                while (this.ai[0] == 0f)
                                                                {
                                                                    int num848 = Main.rand.Next(3);
                                                                    if (num848 == 0 && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                                    {
                                                                        this.ai[0] = 2f;
                                                                    }
                                                                    else if (num848 != 1)
                                                                    {
                                                                        if (num848 != 2 || NPC.CountNPCS(478) + NPC.CountNPCS(479) >= num840)
                                                                        {
                                                                            continue;
                                                                        }
                                                                        this.ai[0] = 4f;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.ai[0] = 3f;
                                                                    }
                                                                }
                                                                return;
                                                            }
                                                        }
                                                    }
                                                    else if (this.aiStyle == 89)
                                                    {
                                                        if (this.velocity.Y != 0f)
                                                        {
                                                            this.velocity.X = this.velocity.X * 0.99f;
                                                            NPC x211 = this;
                                                            x211.rotation = x211.rotation + this.velocity.X * 0.04f;
                                                        }
                                                        else
                                                        {
                                                            this.velocity.X = this.velocity.X * 0.9f;
                                                            NPC x212 = this;
                                                            x212.rotation = x212.rotation + this.velocity.X * 0.02f;
                                                        }
                                                        int num849 = 900;
                                                        if (Main.expertMode)
                                                        {
                                                            num849 = 600;
                                                        }
                                                        if (this.justHit)
                                                        {
                                                            this.ai[0] = this.ai[0] - (float)Main.rand.Next(10, 21);
                                                            if (!Main.expertMode)
                                                            {
                                                                this.ai[0] = this.ai[0] - (float)Main.rand.Next(10, 21);
                                                            }
                                                        }
                                                        this.ai[0] = this.ai[0] + 1f;
                                                        if (this.ai[0] >= (float)num849)
                                                        {
                                                            this.Transform(479);
                                                        }
                                                        if (Main.netMode != 1 && this.velocity.Y == 0f && (double)Math.Abs(this.velocity.X) < 0.2 && (double)this.ai[0] >= (double)num849 * 0.75)
                                                        {
                                                            float single579 = this.ai[0] - (float)num849 * 0.75f;
                                                            single579 = single579 / ((float)num849 * 0.25f);
                                                            if ((float)Main.rand.Next(-10, 120) < single579 * 100f)
                                                            {
                                                                this.velocity.Y = this.velocity.Y - (float)Main.rand.Next(20, 40) * 0.025f;
                                                                this.velocity.X = this.velocity.X + (float)Main.rand.Next(-20, 20) * 0.025f;
                                                                NPC nPC266 = this;
                                                                nPC266.velocity = nPC266.velocity * (1f + single579 * 2f);
                                                                this.netUpdate = true;
                                                                return;
                                                            }
                                                        }
                                                    }
                                                    else if (this.aiStyle == 90)
                                                    {
                                                        this.noTileCollide = false;
                                                        this.knockBackResist = 0.4f * Main.knockBackMultiplier;
                                                        this.noGravity = true;
                                                        this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                        if (!Main.eclipse)
                                                        {
                                                            if (this.timeLeft > 5)
                                                            {
                                                                this.timeLeft = 5;
                                                            }
                                                            this.velocity.Y = this.velocity.Y - 0.2f;
                                                            if (this.velocity.Y < -8f)
                                                            {
                                                                this.velocity.Y = -8f;
                                                            }
                                                            this.noTileCollide = true;
                                                            return;
                                                        }
                                                        if (this.ai[0] == 0f || this.ai[0] == 1f)
                                                        {
                                                            for (int o7 = 0; o7 < 200; o7++)
                                                            {
                                                                if (o7 != this.whoAmI && Main.npc[o7].active && Main.npc[o7].type == this.type)
                                                                {
                                                                    Vector2 center121 = Main.npc[o7].Center - base.Center;
                                                                    if (center121.Length() < (float)(this.width + this.height))
                                                                    {
                                                                        center121.Normalize();
                                                                        center121 = center121 * -0.1f;
                                                                        NPC nPC267 = this;
                                                                        nPC267.velocity = nPC267.velocity + center121;
                                                                        NPC nPC268 = Main.npc[o7];
                                                                        nPC268.velocity = nPC268.velocity - center121;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        if (this.target < 0 || Main.player[this.target].dead || !Main.player[this.target].active)
                                                        {
                                                            this.TargetClosest(true);
                                                            Vector2 center122 = Main.player[this.target].Center - base.Center;
                                                            if (Main.player[this.target].dead || center122.Length() > 3000f)
                                                            {
                                                                this.ai[0] = -1f;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Vector2 center123 = Main.player[this.target].Center - base.Center;
                                                            if (this.ai[0] > 1f && center123.Length() > 1000f)
                                                            {
                                                                this.ai[0] = 1f;
                                                            }
                                                        }
                                                        if (this.ai[0] == -1f)
                                                        {
                                                            Vector2 vector2309 = new Vector2(0f, -8f);
                                                            this.velocity = ((this.velocity * 9f) + vector2309) / 10f;
                                                            this.noTileCollide = true;
                                                            this.dontTakeDamage = true;
                                                            return;
                                                        }
                                                        if (this.ai[0] != 0f)
                                                        {
                                                            if (this.ai[0] == 1f)
                                                            {
                                                                this.collideX = false;
                                                                this.collideY = false;
                                                                this.noTileCollide = true;
                                                                this.knockBackResist = 0f;
                                                                if (this.target < 0 || !Main.player[this.target].active || Main.player[this.target].dead)
                                                                {
                                                                    this.TargetClosest(true);
                                                                }
                                                                if (this.velocity.X < 0f)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else if (this.velocity.X > 0f)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                this.rotation = (this.rotation * 9f + this.velocity.X * 0.08f) / 10f;
                                                                Vector2 center124 = Main.player[this.target].Center - base.Center;
                                                                if (center124.Length() < 300f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                                {
                                                                    this.ai[0] = 0f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                }
                                                                this.ai[2] = this.ai[2] + 0.0166666675f;
                                                                float single580 = 5.5f + this.ai[2] + center124.Length() / 150f;
                                                                float single581 = 35f;
                                                                center124.Normalize();
                                                                center124 = center124 * single580;
                                                                this.velocity = ((this.velocity * (single581 - 1f)) + center124) / single581;
                                                                return;
                                                            }
                                                            if (this.ai[0] == 2f)
                                                            {
                                                                if (this.velocity.X < 0f)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else if (this.velocity.X > 0f)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                this.rotation = (this.rotation * 7f + this.velocity.X * 0.1f) / 8f;
                                                                this.knockBackResist = 0f;
                                                                this.noTileCollide = true;
                                                                Vector2 center125 = Main.player[this.target].Center - base.Center;
                                                                center125.Y = center125.Y - 8f;
                                                                float single582 = 9f;
                                                                float single583 = 8f;
                                                                center125.Normalize();
                                                                center125 = center125 * single582;
                                                                this.velocity = ((this.velocity * (single583 - 1f)) + center125) / single583;
                                                                if (this.velocity.X >= 0f)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                else
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                if (this.ai[1] > 10f)
                                                                {
                                                                    this.velocity = center125;
                                                                    if (this.velocity.X >= 0f)
                                                                    {
                                                                        this.direction = 1;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.direction = -1;
                                                                    }
                                                                    this.ai[0] = 2.1f;
                                                                    this.ai[1] = 0f;
                                                                    return;
                                                                }
                                                            }
                                                            else if (this.ai[0] == 2.1f)
                                                            {
                                                                if (this.velocity.X < 0f)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else if (this.velocity.X > 0f)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                NPC nPC269 = this;
                                                                nPC269.velocity = nPC269.velocity * 1.01f;
                                                                this.knockBackResist = 0f;
                                                                this.noTileCollide = true;
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                int num850 = 45;
                                                                if (this.ai[1] > (float)num850)
                                                                {
                                                                    if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                                    {
                                                                        this.ai[0] = 0f;
                                                                        this.ai[1] = 0f;
                                                                        this.ai[2] = 0f;
                                                                        return;
                                                                    }
                                                                    if (this.ai[1] > (float)(num850 * 2))
                                                                    {
                                                                        this.ai[0] = 1f;
                                                                        this.ai[1] = 0f;
                                                                        this.ai[2] = 0f;
                                                                        return;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            this.TargetClosest(true);
                                                            this.spriteDirection = this.direction;
                                                            if (this.collideX)
                                                            {
                                                                this.velocity.X = this.velocity.X * (-this.oldVelocity.X * 0.5f);
                                                                if (this.velocity.X > 4f)
                                                                {
                                                                    this.velocity.X = 4f;
                                                                }
                                                                if (this.velocity.X < -4f)
                                                                {
                                                                    this.velocity.X = -4f;
                                                                }
                                                            }
                                                            if (this.collideY)
                                                            {
                                                                this.velocity.Y = this.velocity.Y * (-this.oldVelocity.Y * 0.5f);
                                                                if (this.velocity.Y > 4f)
                                                                {
                                                                    this.velocity.Y = 4f;
                                                                }
                                                                if (this.velocity.Y < -4f)
                                                                {
                                                                    this.velocity.Y = -4f;
                                                                }
                                                            }
                                                            Vector2 center126 = Main.player[this.target].Center - base.Center;
                                                            if (center126.Length() > 800f)
                                                            {
                                                                this.ai[0] = 1f;
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                            }
                                                            else if (center126.Length() > 200f)
                                                            {
                                                                float single584 = 5.5f + center126.Length() / 100f + this.ai[1] / 15f;
                                                                float single585 = 40f;
                                                                center126.Normalize();
                                                                center126 = center126 * single584;
                                                                this.velocity = ((this.velocity * (single585 - 1f)) + center126) / single585;
                                                            }
                                                            else if (this.velocity.Length() > 2f)
                                                            {
                                                                NPC nPC270 = this;
                                                                nPC270.velocity = nPC270.velocity * 0.95f;
                                                            }
                                                            else if (this.velocity.Length() < 1f)
                                                            {
                                                                NPC nPC271 = this;
                                                                nPC271.velocity = nPC271.velocity * 1.05f;
                                                            }
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= 90f)
                                                            {
                                                                this.ai[1] = 0f;
                                                                this.ai[0] = 2f;
                                                                return;
                                                            }
                                                        }
                                                    }
                                                    else if (this.aiStyle == 91)
                                                    {
                                                        this.noGravity = true;
                                                        this.noTileCollide = false;
                                                        this.dontTakeDamage = false;
                                                        if (this.justHit && Main.netMode != 1 && Main.expertMode && Main.rand.Next(6) == 0)
                                                        {
                                                            this.netUpdate = true;
                                                            this.ai[0] = -1f;
                                                            this.ai[1] = 0f;
                                                        }
                                                        if (this.ai[0] == -1f)
                                                        {
                                                            this.dontTakeDamage = true;
                                                            this.noGravity = false;
                                                            this.velocity.X = this.velocity.X * 0.98f;
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] >= 120f)
                                                            {
                                                                float single586 = 0f;
                                                                single1 = single586;
                                                                this.ai[3] = single586;
                                                                float single587 = single1;
                                                                single1 = single587;
                                                                this.ai[2] = single587;
                                                                float single588 = single1;
                                                                single1 = single588;
                                                                this.ai[1] = single588;
                                                                this.ai[0] = single1;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 0f)
                                                        {
                                                            this.TargetClosest(true);
                                                            if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 1f;
                                                                return;
                                                            }
                                                            Vector2 center127 = Main.player[this.target].Center - base.Center;
                                                            center127.Y = center127.Y - (float)(Main.player[this.target].height / 4);
                                                            if (center127.Length() > 800f)
                                                            {
                                                                this.ai[0] = 2f;
                                                                return;
                                                            }
                                                            Vector2 center128 = base.Center;
                                                            center128.X = Main.player[this.target].Center.X;
                                                            Vector2 center129 = center128 - base.Center;
                                                            if (center129.Length() <= 8f || !Collision.CanHit(base.Center, 1, 1, center128, 1, 1))
                                                            {
                                                                center128 = base.Center;
                                                                center128.Y = Main.player[this.target].Center.Y;
                                                                center129 = center128 - base.Center;
                                                                if (center129.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center128, 1, 1))
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = center128.X;
                                                                    this.ai[2] = center128.Y;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                this.ai[0] = 3f;
                                                                this.ai[1] = center128.X;
                                                                this.ai[2] = center128.Y;
                                                                Vector2 center130 = base.Center;
                                                                center130.Y = Main.player[this.target].Center.Y;
                                                                if (center129.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center130, 1, 1) && Collision.CanHit(center130, 1, 1, Main.player[this.target].position, 1, 1))
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = center130.X;
                                                                    this.ai[2] = center130.Y;
                                                                }
                                                            }
                                                            if (this.ai[0] == 0f)
                                                            {
                                                                this.localAI[0] = 0f;
                                                                center127.Normalize();
                                                                center127 = center127 * 0.5f;
                                                                NPC nPC272 = this;
                                                                nPC272.velocity = nPC272.velocity + center127;
                                                                this.ai[0] = 4f;
                                                                this.ai[1] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 1f)
                                                        {
                                                            Vector2 center131 = Main.player[this.target].Center - base.Center;
                                                            float single589 = 2f + center131.Length() / 200f;
                                                            int num851 = 50;
                                                            center131.Normalize();
                                                            center131 = center131 * single589;
                                                            this.velocity = ((this.velocity * (float)(num851 - 1)) + center131) / (float)num851;
                                                            if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 2f)
                                                        {
                                                            this.noTileCollide = true;
                                                            Vector2 center132 = Main.player[this.target].Center - base.Center;
                                                            float single590 = center132.Length();
                                                            float single591 = 2f;
                                                            int num852 = 4;
                                                            center132.Normalize();
                                                            center132 = center132 * single591;
                                                            this.velocity = ((this.velocity * (float)(num852 - 1)) + center132) / (float)num852;
                                                            if (single590 < 600f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                            {
                                                                this.ai[0] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 3f)
                                                        {
                                                            Vector2 vector2310 = new Vector2(this.ai[1], this.ai[2]);
                                                            Vector2 center133 = vector2310 - base.Center;
                                                            float single592 = center133.Length();
                                                            float single593 = 1f;
                                                            float single594 = 3f;
                                                            center133.Normalize();
                                                            center133 = center133 * single593;
                                                            this.velocity = ((this.velocity * (single594 - 1f)) + center133) / single594;
                                                            if (this.collideX || this.collideY)
                                                            {
                                                                this.ai[0] = 4f;
                                                                this.ai[1] = 0f;
                                                            }
                                                            if (single592 < single593 || single592 > 800f || Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.ai[0] == 4f)
                                                        {
                                                            if (this.collideX)
                                                            {
                                                                this.velocity.X = this.velocity.X * -0.8f;
                                                            }
                                                            if (this.collideY)
                                                            {
                                                                this.velocity.Y = this.velocity.Y * -0.8f;
                                                            }
                                                            if (this.velocity.X == 0f && this.velocity.Y == 0f)
                                                            {
                                                                y = Main.player[this.target].Center - base.Center;
                                                                y.Y = y.Y - (float)(Main.player[this.target].height / 4);
                                                                y.Normalize();
                                                                this.velocity = y * 0.1f;
                                                            }
                                                            float single595 = 1.5f;
                                                            float single596 = 20f;
                                                            y = this.velocity;
                                                            y.Normalize();
                                                            y = y * single595;
                                                            this.velocity = ((this.velocity * (single596 - 1f)) + y) / single596;
                                                            this.ai[1] = this.ai[1] + 1f;
                                                            if (this.ai[1] > 180f)
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                            }
                                                            if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 0f;
                                                            }
                                                            this.localAI[0] = this.localAI[0] + 1f;
                                                            if (this.localAI[0] >= 5f && !Collision.SolidCollision(this.position - new Vector2(10f, 10f), this.width + 20, this.height + 20))
                                                            {
                                                                this.localAI[0] = 0f;
                                                                Vector2 center134 = base.Center;
                                                                center134.X = Main.player[this.target].Center.X;
                                                                if (Collision.CanHit(base.Center, 1, 1, center134, 1, 1) && Collision.CanHit(base.Center, 1, 1, center134, 1, 1) && Collision.CanHit(Main.player[this.target].Center, 1, 1, center134, 1, 1))
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = center134.X;
                                                                    this.ai[2] = center134.Y;
                                                                    return;
                                                                }
                                                                center134 = base.Center;
                                                                center134.Y = Main.player[this.target].Center.Y;
                                                                if (Collision.CanHit(base.Center, 1, 1, center134, 1, 1) && Collision.CanHit(Main.player[this.target].Center, 1, 1, center134, 1, 1))
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = center134.X;
                                                                    this.ai[2] = center134.Y;
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else if (this.aiStyle != 92)
                                                    {
                                                        if (this.aiStyle == 93)
                                                        {
                                                            if (this.localAI[0] == 0f)
                                                            {
                                                                this.localAI[0] = 1f;
                                                                for (int p7 = 0; p7 < 4; p7++)
                                                                {
                                                                    int num853 = NPC.NewNPC((int)base.Center.X + p7 * 40 - 150, (int)base.Center.Y, 492, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                                    Main.npc[num853].netUpdate = true;
                                                                    Main.npc[num853].ai[0] = (float)this.whoAmI;
                                                                    Main.npc[num853].ai[1] = (float)p7;
                                                                    Main.npc[num853].ai[3] = (float)(60 * p7);
                                                                    Main.npc[num853].TargetClosest(false);
                                                                    Main.npc[num853].timeLeft = 600;
                                                                    this.ai[p7] = (float)num853;
                                                                }
                                                            }
                                                            bool flag155 = true;
                                                            for (int q7 = 0; q7 < 4; q7++)
                                                            {
                                                                if (this.ai[q7] >= 0f && (!Main.npc[(int)this.ai[q7]].active || Main.npc[(int)this.ai[q7]].type != 492))
                                                                {
                                                                    this.ai[q7] = -1f;
                                                                    this.netUpdate = true;
                                                                }
                                                                else if (this.ai[q7] >= 0f)
                                                                {
                                                                    flag155 = false;
                                                                }
                                                            }
                                                            if (flag155)
                                                            {
                                                                this.life = 0;
                                                                this.HitEffect(9999, 10);
                                                                this.checkDead();
                                                                return;
                                                            }
                                                            if (Main.netMode != 1 && Main.rand.Next(300) == 0)
                                                            {
                                                                Vector2 vector2311 = new Vector2((Main.rand.NextFloat() - 0.5f) * (float)(this.width - 70), (Main.rand.NextFloat() - 0.5f) * 20f - (float)(this.height / 2) - 20f);
                                                                double num854 = (double)this.rotation;
                                                                vector24 = new Vector2();
                                                                Vector2 center135 = vector2311.RotatedBy(num854, vector24);
                                                                center135 = center135 + base.Center;
                                                                int x213 = (int)center135.X;
                                                                int y213 = (int)center135.Y;
                                                                Random random4 = Main.rand;
                                                                numArray = new int[] { 213, 215, 214, 212 };
                                                                int num855 = NPC.NewNPC(x213, y213, Utils.SelectRandom<int>(random4, numArray), 0, 0f, 0f, 0f, 0f, 255);
                                                                Main.npc[num855].velocity = new Vector2((Main.rand.NextFloat() - 0.5f) * 5f, -8.01f) + this.velocity;
                                                                Main.npc[num855].netUpdate = true;
                                                                Main.npc[num855].timeLeft = 600;
                                                            }
                                                            float single597 = this.localAI[3] + 1f;
                                                            single1 = single597;
                                                            this.localAI[3] = single597;
                                                            if (single1 >= 64f)
                                                            {
                                                                this.localAI[3] = 0f;
                                                            }
                                                            this.TargetClosest(true);
                                                            int x214 = (int)base.Center.X / 16 + Math.Sign(this.velocity.X) * 10;
                                                            int y214 = (int)(this.position.Y + (float)this.height) / 16;
                                                            int num856 = 0;
                                                            if ((!Main.tile[x214, y214].nactive() || !Main.tileSolid[Main.tile[x214, y214].type] ? true : Main.tileSolidTop[Main.tile[x214, y214].type]))
                                                            {
                                                                while (num856 < 150 && y214 + num856 < Main.maxTilesY)
                                                                {
                                                                    int num857 = y214 + num856;
                                                                    if ((!Main.tile[x214, num857].nactive() || !Main.tileSolid[Main.tile[x214, num857].type] ? true : Main.tileSolidTop[Main.tile[x214, num857].type]))
                                                                    {
                                                                        num856++;
                                                                    }
                                                                    else
                                                                    {
                                                                        num856--;
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                num856 = 1;
                                                            }
                                                            float single598 = (float)(num856 * 16);
                                                            if (single598 < 350f)
                                                            {
                                                                float single599 = single598 - 350f;
                                                                if (single599 < -4f)
                                                                {
                                                                    single599 = -4f;
                                                                }
                                                                this.velocity.Y = MathHelper.Lerp(this.velocity.Y, single599, 0.05f);
                                                            }
                                                            else if (single598 <= 450f)
                                                            {
                                                                this.velocity.Y = this.velocity.Y * 0.95f;
                                                            }
                                                            else
                                                            {
                                                                float single600 = single598 - 350f;
                                                                if (single600 > 4f)
                                                                {
                                                                    single600 = 4f;
                                                                }
                                                                this.velocity.Y = MathHelper.Lerp(this.velocity.Y, single600, 0.05f);
                                                            }
                                                            if (Math.Abs(Main.player[this.target].Center.X - base.Center.X) >= 300f && (Math.Abs(this.velocity.X) < 6f || Math.Sign(this.velocity.X) != this.direction))
                                                            {
                                                                this.velocity.X = this.velocity.X + (float)this.direction * 0.06f;
                                                            }
                                                            this.rotation = this.velocity.X * 0.025f;
                                                            this.spriteDirection = -Math.Sign(this.velocity.X);
                                                            return;
                                                        }
                                                        if (this.aiStyle == 94)
                                                        {
                                                            if (this.ai[2] == 1f)
                                                            {
                                                                this.velocity = Vector2.UnitY * this.velocity.Length();
                                                                if (this.velocity.Y < 0.25f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y + 0.02f;
                                                                }
                                                                if (this.velocity.Y > 0.25f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 0.02f;
                                                                }
                                                                this.dontTakeDamage = true;
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                if (this.ai[1] > 120f)
                                                                {
                                                                    this.Opacity = 1f - (this.ai[1] - 120f) / 60f;
                                                                }
                                                                int num859 = 6;
                                                                num6 = this.type;
                                                                if (num6 <= 493)
                                                                {
                                                                    if (num6 == 422)
                                                                    {
                                                                        num859 = 229;
                                                                    }
                                                                    else if (num6 == 493)
                                                                    {
                                                                        num859 = 135;
                                                                    }
                                                                }
                                                                else if (num6 == 507)
                                                                {
                                                                    num859 = 242;
                                                                }
                                                                else if (num6 == 517)
                                                                {
                                                                    num859 = 127;
                                                                }
                                                                if (Main.rand.Next(5) == 0 && this.ai[1] < 150f)
                                                                {
                                                                }
                                                                if (this.ai[1] >= 180f)
                                                                {
                                                                    this.life = 0;
                                                                    this.HitEffect(0, 1337);
                                                                    this.checkDead();
                                                                }
                                                                return;
                                                            }
                                                            if (this.ai[3] > 0f)
                                                            {
                                                                bool shieldStrengthTowerVortex = this.dontTakeDamage;
                                                                num6 = this.type;
                                                                if (num6 <= 493)
                                                                {
                                                                    if (num6 == 422)
                                                                    {
                                                                        shieldStrengthTowerVortex = NPC.ShieldStrengthTowerVortex != 0;
                                                                    }
                                                                    else if (num6 == 493)
                                                                    {
                                                                        shieldStrengthTowerVortex = NPC.ShieldStrengthTowerStardust != 0;
                                                                    }
                                                                }
                                                                else if (num6 == 507)
                                                                {
                                                                    shieldStrengthTowerVortex = NPC.ShieldStrengthTowerNebula != 0;
                                                                }
                                                                else if (num6 == 517)
                                                                {
                                                                    shieldStrengthTowerVortex = NPC.ShieldStrengthTowerSolar != 0;
                                                                }
                                                                this.ai[3] = this.ai[3] + 1f;
                                                                if (this.ai[3] > 120f)
                                                                {
                                                                    this.ai[3] = 0f;
                                                                }
                                                            }
                                                            num6 = this.type;
                                                            if (num6 <= 493)
                                                            {
                                                                if (num6 == 422)
                                                                {
                                                                    this.dontTakeDamage = NPC.ShieldStrengthTowerVortex != 0;
                                                                }
                                                                else if (num6 == 493)
                                                                {
                                                                    this.dontTakeDamage = NPC.ShieldStrengthTowerStardust != 0;
                                                                }
                                                            }
                                                            else if (num6 == 507)
                                                            {
                                                                this.dontTakeDamage = NPC.ShieldStrengthTowerNebula != 0;
                                                            }
                                                            else if (num6 == 517)
                                                            {
                                                                this.dontTakeDamage = NPC.ShieldStrengthTowerSolar != 0;
                                                            }
                                                            this.TargetClosest(false);
                                                            if (Main.player[this.target].Distance(base.Center) > 2000f)
                                                            {
                                                                this.localAI[0] = this.localAI[0] + 1f;
                                                            }
                                                            if (this.localAI[0] < 60f || Main.netMode == 1)
                                                            {
                                                                this.localAI[0] = 0f;
                                                            }
                                                            else
                                                            {
                                                                this.localAI[0] = 0f;
                                                                this.netUpdate = true;
                                                                this.life = (int)MathHelper.Clamp((float)(this.life + 200), 0f, (float)this.lifeMax);
                                                            }
                                                            this.velocity = new Vector2(0f, (float)Math.Sin((double)(6.28318548f * this.ai[0] / 300f)) * 0.5f);
                                                            this.ai[0] = this.ai[0] + 1f;
                                                            if (this.ai[0] >= 300f)
                                                            {
                                                                this.ai[0] = 0f;
                                                            }
                                                            if (this.type == 493)
                                                            {
                                                                if (this.ai[1] > 0f)
                                                                {
                                                                    this.ai[1] = this.ai[1] - 1f;
                                                                }
                                                                if (Main.netMode != 1 && this.ai[1] <= 0f && Main.player[this.target].active && !Main.player[this.target].dead && base.Distance(Main.player[this.target].Center) < 1080f && Main.player[this.target].position.Y - this.position.Y < 400f)
                                                                {
                                                                    List<int> nums8 = new List<int>();
                                                                    if (NPC.CountNPCS(405) + NPC.CountNPCS(406) < 2)
                                                                    {
                                                                        nums8.Add(405);
                                                                    }
                                                                    if (NPC.CountNPCS(402) < 2)
                                                                    {
                                                                        nums8.Add(402);
                                                                    }
                                                                    if (NPC.CountNPCS(407) < 1)
                                                                    {
                                                                        nums8.Add(407);
                                                                    }
                                                                    if (nums8.Count <= 0)
                                                                    {
                                                                        this.ai[1] = 30f;
                                                                    }
                                                                    else
                                                                    {
                                                                        int num868 = Utils.SelectRandom<int>(Main.rand, nums8.ToArray());
                                                                        this.ai[1] = (float)(30 * Main.rand.Next(5, 16));
                                                                        int num869 = Main.rand.Next(3, 6);
                                                                        int num870 = Main.rand.Next(0, 4);
                                                                        int num871 = 0;
                                                                        List<Tuple<Vector2, int, int>> tuples = new List<Tuple<Vector2, int, int>>();
                                                                        List<Vector2> vector2s = new List<Vector2>();
                                                                        tuples.Add(Tuple.Create<Vector2, int, int>(base.Top - (Vector2.UnitY * 120f), num869, 0));
                                                                        int num872 = 0;
                                                                        int count4 = tuples.Count;
                                                                        while (tuples.Count > 0)
                                                                        {
                                                                            Vector2 item1 = tuples[0].Item1;
                                                                            int num873 = 1;
                                                                            int num874 = 1;
                                                                            if (num872 > 0 && num870 > 0 && (Main.rand.Next(3) != 0 || num872 == 1))
                                                                            {
                                                                                num874 = Main.rand.Next(Math.Max(1, tuples[0].Item2));
                                                                                num873++;
                                                                                num870--;
                                                                            }
                                                                            for (int x710 = 0; x710 < num873; x710++)
                                                                            {
                                                                                int item3 = tuples[0].Item3;
                                                                                if (num872 == 0)
                                                                                {
                                                                                    Random random6 = Main.rand;
                                                                                    numArray = new int[] { -1, 1 };
                                                                                    item3 = Utils.SelectRandom<int>(random6, numArray);
                                                                                }
                                                                                else if (x710 == 1)
                                                                                {
                                                                                    item3 = item3 * -1;
                                                                                }
                                                                                float single602 = (num872 % 2 == 0 ? 0f : 3.14159274f) + (0.5f - Main.rand.NextFloat()) * 0.7853982f + (float)item3 * 0.7853982f * (float)(num872 % 2 == 0).ToDirectionInt();
                                                                                float single603 = 100f + 50f * Main.rand.NextFloat();
                                                                                int item2 = tuples[0].Item2;
                                                                                if (x710 != 0)
                                                                                {
                                                                                    item2 = num874;
                                                                                }
                                                                                if (num872 == 0)
                                                                                {
                                                                                    single602 = (0.5f - Main.rand.NextFloat()) * 0.7853982f;
                                                                                    single603 = 100f + 100f * Main.rand.NextFloat();
                                                                                }
                                                                                Vector2 unitY20 = -Vector2.UnitY;
                                                                                double num875 = (double)single602;
                                                                                vector24 = new Vector2();
                                                                                Vector2 zero6 = unitY20.RotatedBy(num875, vector24) * single603;
                                                                                if (item2 - 1 < 0)
                                                                                {
                                                                                    zero6 = Vector2.Zero;
                                                                                }
                                                                                num871 = Projectile.NewProjectile(item1.X, item1.Y, zero6.X, zero6.Y, 540, 0, 0f, Main.myPlayer, (float)(-num872) * 10f, 0.5f + Main.rand.NextFloat() * 0.5f);
                                                                                vector2s.Add(item1 + zero6);
                                                                                if (num872 < num869 && tuples[0].Item2 > 0)
                                                                                {
                                                                                    tuples.Add(Tuple.Create<Vector2, int, int>(item1 + zero6, item2 - 1, item3));
                                                                                }
                                                                            }
                                                                            tuples.Remove(tuples[0]);
                                                                            int num876 = count4 - 1;
                                                                            count4 = num876;
                                                                            if (num876 != 0)
                                                                            {
                                                                                continue;
                                                                            }
                                                                            count4 = tuples.Count;
                                                                            num872++;
                                                                        }
                                                                        Main.projectile[num871].localAI[0] = (float)num868;
                                                                    }
                                                                }
                                                            }
                                                            if (this.type == 422)
                                                            {
                                                                if (this.ai[1] > 0f)
                                                                {
                                                                    this.ai[1] = this.ai[1] - 1f;
                                                                }
                                                                if (Main.netMode != 1 && this.ai[1] <= 0f && Main.player[this.target].active && !Main.player[this.target].dead && base.Distance(Main.player[this.target].Center) < 1080f && Main.player[this.target].position.Y - this.position.Y < 400f && NPC.CountNPCS(427) + NPC.CountNPCS(426) * 3 + NPC.CountNPCS(428) < 20)
                                                                {
                                                                    this.ai[1] = (float)(420 + Main.rand.Next(360));
                                                                    Point point6 = base.Center.ToTileCoordinates();
                                                                    Point tileCoordinates7 = Main.player[this.target].Center.ToTileCoordinates();
                                                                    Vector2 center138 = Main.player[this.target].Center - base.Center;
                                                                    int num883 = 20;
                                                                    int num884 = 3;
                                                                    int num885 = 8;
                                                                    int num886 = 2;
                                                                    int num887 = 0;
                                                                    bool flag156 = false;
                                                                    if (center138.Length() > 2000f)
                                                                    {
                                                                        flag156 = true;
                                                                    }
                                                                    do
                                                                    {
                                                                    Label1:
                                                                        if (flag156 || num887 >= 100)
                                                                        {
                                                                            goto Label0;
                                                                        }
                                                                        num887++;
                                                                        num4 = Main.rand.Next(tileCoordinates7.X - num883, tileCoordinates7.X + num883 + 1);
                                                                        num5 = Main.rand.Next(tileCoordinates7.Y - num883, tileCoordinates7.Y + num883 + 1);
                                                                        if ((num5 < tileCoordinates7.Y - num885 || num5 > tileCoordinates7.Y + num885 || num4 < tileCoordinates7.X - num885 || num4 > tileCoordinates7.X + num885) && (num5 < point6.Y - num884 || num5 > point6.Y + num884 || num4 < point6.X - num884 || num4 > point6.X + num884) && !Main.tile[num4, num5].nactive())
                                                                        {
                                                                            flag1 = true;
                                                                            if (flag1 && Main.tile[num4, num5].lava())
                                                                            {
                                                                                flag1 = false;
                                                                            }
                                                                            if (flag1 && Collision.SolidTiles(num4 - num886, num4 + num886, num5 - num886, num5 + num886))
                                                                            {
                                                                                flag1 = false;
                                                                            }
                                                                            if (!flag1 || Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                                                                            {
                                                                                continue;
                                                                            }
                                                                            flag1 = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            goto Label1;
                                                                        }
                                                                    }
                                                                    while (!flag1);
                                                                    Projectile.NewProjectile((float)(num4 * 16 + 8), (float)(num5 * 16 + 8), 0f, 0f, 579, 0, 0f, Main.myPlayer, 0f, 0f);
                                                                    flag156 = true;
                                                                }
                                                            }
                                                        Label0:
                                                            if (this.type == 517)
                                                            {
                                                                if (this.ai[1] > 0f)
                                                                {
                                                                    this.ai[1] = this.ai[1] - 1f;
                                                                }
                                                                if (Main.netMode != 1 && this.ai[1] <= 0f && Main.player[this.target].active && !Main.player[this.target].dead && base.Distance(Main.player[this.target].Center) < 1080f && Main.player[this.target].position.Y - this.position.Y < 700f)
                                                                {
                                                                    Vector2 top6 = (base.Top + new Vector2((float)(-this.width) * 0.33f, -20f)) + (new Vector2((float)this.width * 0.66f, 20f) * Utils.RandomVector2(Main.rand, 0f, 1f));
                                                                    Vector2 vector2314 = -Vector2.UnitY.RotatedByRandom(0.785398185253143) * (7f + Main.rand.NextFloat() * 5f);
                                                                    int num891 = NPC.NewNPC((int)top6.X, (int)top6.Y, 519, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                                    Main.npc[num891].velocity = vector2314;
                                                                    Main.npc[num891].netUpdate = true;
                                                                    this.ai[1] = 60f;
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                        else if (this.aiStyle == 95)
                                                        {
                                                            float single604 = 300f;
                                                            if (this.velocity.Length() > 4f)
                                                            {
                                                                NPC nPC273 = this;
                                                                nPC273.velocity = nPC273.velocity * 0.95f;
                                                            }
                                                            NPC nPC274 = this;
                                                            nPC274.velocity = nPC274.velocity * 0.99f;
                                                            this.ai[0] = this.ai[0] + 1f;
                                                            this.scale = 1f + 0.3f * (this.ai[0] / single604);
                                                            if (this.ai[0] >= single604)
                                                            {
                                                                if (Main.netMode != 1)
                                                                {
                                                                    this.Transform(405);
                                                                }
                                                                return;
                                                            }
                                                            NPC x215 = this;
                                                            x215.rotation = x215.rotation + this.velocity.X * 0.1f;
                                                            if (this.ai[0] > 20f)
                                                            {
                                                                Vector2 center139 = base.Center;
                                                                int num892 = (int)(this.ai[0] / (single604 / 2f));
                                                                return;
                                                            }
                                                        }
                                                        else if (this.aiStyle == 96)
                                                        {
                                                            float single606 = 5f;
                                                            float single607 = 0.15f;
                                                            this.TargetClosest(true);
                                                            Vector2 center140 = (Main.player[this.target].Center - base.Center) + new Vector2(0f, -250f);
                                                            float single608 = center140.Length();
                                                            if (single608 < 20f)
                                                            {
                                                                center140 = this.velocity;
                                                            }
                                                            else if (single608 < 40f)
                                                            {
                                                                center140.Normalize();
                                                                center140 = center140 * (single606 * 0.35f);
                                                            }
                                                            else if (single608 >= 80f)
                                                            {
                                                                center140.Normalize();
                                                                center140 = center140 * single606;
                                                            }
                                                            else
                                                            {
                                                                center140.Normalize();
                                                                center140 = center140 * (single606 * 0.65f);
                                                            }
                                                            this.SimpleFlyMovement(center140, single607);
                                                            this.rotation = this.velocity.X * 0.1f;
                                                            float single609 = this.ai[0] + 1f;
                                                            single1 = single609;
                                                            this.ai[0] = single609;
                                                            if (single1 >= 70f)
                                                            {
                                                                this.ai[0] = 0f;
                                                                if (Main.netMode != 1)
                                                                {
                                                                    Vector2 zero7 = Vector2.Zero;
                                                                    while (Math.Abs(zero7.X) < 1.5f)
                                                                    {
                                                                        zero7 = Vector2.UnitY.RotatedByRandom(1.57079637050629) * new Vector2(5f, 3f);
                                                                    }
                                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, zero7.X, zero7.Y, 539, 60, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                        else if (this.aiStyle == 97)
                                                        {
                                                            float single610 = 7f;
                                                            int num895 = 480;
                                                            if (this.localAI[2] < 180f)
                                                            {
                                                                this.localAI[2] = this.localAI[2] + 1f;
                                                                if (Main.netMode != 1 && this.localAI[2] % 60f == 0f)
                                                                {
                                                                    Vector2 zero8 = Vector2.Zero;
                                                                    while (Math.Abs(zero8.X) < 1.5f)
                                                                    {
                                                                        zero8 = Vector2.UnitY.RotatedByRandom(1.57079637050629) * new Vector2(4f, 2.5f);
                                                                    }
                                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, zero8.X, zero8.Y, 574, 0, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                                }
                                                            }
                                                            if (this.localAI[1] == 1f)
                                                            {
                                                                this.localAI[1] = 0f;
                                                                if (Main.rand.Next(4) == 0)
                                                                {
                                                                    this.ai[0] = (float)num895;
                                                                }
                                                            }
                                                            this.TargetClosest(true);
                                                            this.rotation = Math.Abs(this.velocity.X) * (float)this.direction * 0.1f;
                                                            this.spriteDirection = -this.direction;
                                                            Vector2 center141 = base.Center + new Vector2((float)(this.direction * 20), 6f);
                                                            Vector2 center142 = Main.player[this.target].Center - center141;
                                                            bool flag157 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1);
                                                            bool flag158 = false;
                                                            if (center142.Length() > 400f || !flag157)
                                                            {
                                                                Vector2 vector2315 = center142;
                                                                if (vector2315.Length() > single610)
                                                                {
                                                                    vector2315.Normalize();
                                                                    vector2315 = vector2315 * single610;
                                                                }
                                                                int num896 = 30;
                                                                this.velocity = ((this.velocity * (float)(num896 - 1)) + vector2315) / (float)num896;
                                                            }
                                                            else
                                                            {
                                                                NPC nPC275 = this;
                                                                nPC275.velocity = nPC275.velocity * 0.98f;
                                                                flag158 = true;
                                                            }
                                                            if (this.ai[2] != 0f && this.ai[3] != 0f)
                                                            {
                                                                base.Center = new Vector2(this.ai[2] * 16f, this.ai[3] * 16f);
                                                                this.velocity = Vector2.Zero;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                            }
                                                            this.ai[0] = this.ai[0] + 1f;
                                                            if (this.ai[0] >= (float)num895 && Main.netMode != 1)
                                                            {
                                                                this.ai[0] = 0f;
                                                                Point point7 = base.Center.ToTileCoordinates();
                                                                Point tileCoordinates8 = Main.player[this.target].Center.ToTileCoordinates();
                                                                int num903 = 20;
                                                                int num904 = 3;
                                                                int num905 = 10;
                                                                int num906 = 1;
                                                                int num907 = 0;
                                                                bool flag159 = false;
                                                                if (center142.Length() > 2000f)
                                                                {
                                                                    flag159 = true;
                                                                }
                                                                while (!flag159 && num907 < 100)
                                                                {
                                                                    num907++;
                                                                    int num908 = Main.rand.Next(tileCoordinates8.X - num903, tileCoordinates8.X + num903 + 1);
                                                                    int num909 = Main.rand.Next(tileCoordinates8.Y - num903, tileCoordinates8.Y + num903 + 1);
                                                                    if (num909 >= tileCoordinates8.Y - num905 && num909 <= tileCoordinates8.Y + num905 && num908 >= tileCoordinates8.X - num905 && num908 <= tileCoordinates8.X + num905 || num909 >= point7.Y - num904 && num909 <= point7.Y + num904 && num908 >= point7.X - num904 && num908 <= point7.X + num904 || Main.tile[num908, num909].nactive())
                                                                    {
                                                                        continue;
                                                                    }
                                                                    bool flag160 = true;
                                                                    if (flag160 && Main.tile[num908, num909].lava())
                                                                    {
                                                                        flag160 = false;
                                                                    }
                                                                    if (flag160 && Collision.SolidTiles(num908 - num906, num908 + num906, num909 - num906, num909 + num906))
                                                                    {
                                                                        flag160 = false;
                                                                    }
                                                                    if (!flag160)
                                                                    {
                                                                        continue;
                                                                    }
                                                                    this.ai[1] = 20f;
                                                                    this.ai[2] = (float)num908;
                                                                    this.ai[3] = (float)num909;
                                                                    flag159 = true;
                                                                    break;
                                                                }
                                                                this.netUpdate = true;
                                                            }
                                                            if (flag158 && this.velocity.Length() < 2f && Main.netMode != 1)
                                                            {
                                                                this.localAI[0] = this.localAI[0] + 1f;
                                                                if (this.localAI[0] >= 13f)
                                                                {
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                        else if (this.aiStyle == 98)
                                                        {
                                                            this.noTileCollide = false;
                                                            if (this.ai[0] == 0f)
                                                            {
                                                                this.TargetClosest(true);
                                                                this.ai[0] = 1f;
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                this.ai[3] = 0f;
                                                            }
                                                            bool flag161 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].position, 1, 1);
                                                            bool flag162 = true;
                                                            if (!flag161 || Main.player[this.target].dead)
                                                            {
                                                                flag162 = false;
                                                            }
                                                            else
                                                            {
                                                                int x217 = (int)(Main.player[this.target].Center.X / 16f);
                                                                int y216 = (int)(Main.player[this.target].Center.Y / 16f);
                                                                for (int f7 = x217 - 2; f7 <= x217 + 2; f7++)
                                                                {
                                                                    for (int g7 = y216; g7 <= y216 + 25; g7++)
                                                                    {
                                                                        if (WorldGen.SolidTile2(f7, g7))
                                                                        {
                                                                            flag162 = false;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            if (this.ai[0] < 0f)
                                                            {
                                                                Vector2 center143 = Main.player[this.target].Center - base.Center;
                                                                float single611 = center143.Length();
                                                                if (this.ai[0] == -1f)
                                                                {
                                                                    center143.Normalize();
                                                                    if (center143.HasNaNs())
                                                                    {
                                                                        center143 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    float single612 = 8f + single611 / 100f;
                                                                    float single613 = 12f;
                                                                    if (Main.player[this.target].velocity.Length() > single613)
                                                                    {
                                                                        single613 = Main.player[this.target].velocity.Length();
                                                                    }
                                                                    if (single612 > single613)
                                                                    {
                                                                        single612 = single613;
                                                                    }
                                                                    center143 = center143 * single612;
                                                                    float single614 = 10f;
                                                                    this.velocity = ((this.velocity * (single614 - 1f)) + center143) / single614;
                                                                    for (int h7 = 0; h7 < 200; h7++)
                                                                    {
                                                                        if (Main.npc[h7].active && Main.npc[h7].type == this.type && h7 != this.whoAmI)
                                                                        {
                                                                            Vector2 center144 = Main.npc[h7].Center - base.Center;
                                                                            if (center144.Length() < 40f)
                                                                            {
                                                                                center144.Normalize();
                                                                                center144 = center144 * 1f;
                                                                                NPC nPC276 = this;
                                                                                nPC276.velocity = nPC276.velocity - center144;
                                                                            }
                                                                        }
                                                                    }
                                                                    NPC x218 = this;
                                                                    x218.rotation = x218.rotation + this.velocity.X * 0.03f;
                                                                    if ((double)this.rotation < -6.2831)
                                                                    {
                                                                        NPC nPC277 = this;
                                                                        nPC277.rotation = nPC277.rotation + 6.2831f;
                                                                    }
                                                                    if ((double)this.rotation > 6.2831)
                                                                    {
                                                                        NPC nPC278 = this;
                                                                        nPC278.rotation = nPC278.rotation - 6.2831f;
                                                                    }
                                                                    if (this.velocity.X > 0f)
                                                                    {
                                                                        this.direction = 1;
                                                                    }
                                                                    else if (this.velocity.X < 0f)
                                                                    {
                                                                        this.direction = -1;
                                                                    }
                                                                    this.spriteDirection = this.direction;
                                                                }
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                if (this.ai[1] >= 60f && !flag162)
                                                                {
                                                                    this.ai[0] = 0f;
                                                                }
                                                            }
                                                            else if (this.ai[0] == 2f)
                                                            {
                                                                NPC nPC279 = this;
                                                                nPC279.rotation = nPC279.rotation * 0.92f;
                                                                if ((double)Math.Abs(this.rotation) < 0.02)
                                                                {
                                                                    this.rotation = 0f;
                                                                }
                                                                if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) >= (float)300 || !Collision.CanHit(base.Center, 1, 1, Main.player[this.target].position, 1, 1))
                                                                {
                                                                    this.ai[0] = 0f;
                                                                }
                                                                else
                                                                {
                                                                    this.velocity.X = this.velocity.X * 0.96f;
                                                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                                                    this.ai[1] = this.ai[1] + 1f;
                                                                    if (this.ai[1] == 20f)
                                                                    {
                                                                        if (Main.netMode != 1)
                                                                        {
                                                                            NPC.NewNPC((int)base.Center.X, (int)base.Center.Y + 26, 516, 0, 0f, 0f, 0f, 0f, this.target);
                                                                        }
                                                                    }
                                                                    else if (this.ai[1] >= 30f)
                                                                    {
                                                                        this.ai[1] = 0f;
                                                                    }
                                                                    for (int i8 = 0; i8 < 200; i8++)
                                                                    {
                                                                        if (Main.npc[i8].active && Main.npc[i8].type == this.type && i8 != this.whoAmI)
                                                                        {
                                                                            Vector2 center145 = Main.npc[i8].Center - base.Center;
                                                                            if (center145.Length() < 100f)
                                                                            {
                                                                                center145.Normalize();
                                                                                center145 = center145 * 0.1f;
                                                                                NPC nPC280 = this;
                                                                                nPC280.velocity = nPC280.velocity - center145;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                if (Main.player[this.target].Center.X < base.Center.X)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else if (Main.player[this.target].Center.X > base.Center.X)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                            }
                                                            if (this.ai[0] == 1f)
                                                            {
                                                                NPC nPC281 = this;
                                                                nPC281.rotation = nPC281.rotation * 0.92f;
                                                                if ((double)Math.Abs(this.rotation) < 0.02)
                                                                {
                                                                    this.rotation = 0f;
                                                                }
                                                                if (flag162)
                                                                {
                                                                    this.ai[0] = -1f;
                                                                    this.ai[1] = 0f;
                                                                    this.ai[2] = 0f;
                                                                    this.ai[3] = 0f;
                                                                }
                                                                int num910 = 300;
                                                                for (int j8 = 0; j8 < 200; j8++)
                                                                {
                                                                    if (Main.npc[j8].active && Main.npc[j8].type == this.type && j8 != this.whoAmI)
                                                                    {
                                                                        Vector2 center146 = Main.npc[j8].Center - base.Center;
                                                                        if (center146.Length() < 50f)
                                                                        {
                                                                            center146.Normalize();
                                                                            center146 = center146 * 0.1f;
                                                                            NPC nPC282 = this;
                                                                            nPC282.velocity = nPC282.velocity - center146;
                                                                            this.velocity.X = this.velocity.X - center146.X * 1f;
                                                                        }
                                                                    }
                                                                }
                                                                int num911 = 800;
                                                                float single615 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                                                if (single615 >= (float)num910 || !flag161)
                                                                {
                                                                    if (this.collideX)
                                                                    {
                                                                        this.velocity.X = this.velocity.X * -0.5f;
                                                                        this.ai[1] = 60f;
                                                                        NPC nPC283 = this;
                                                                        nPC283.direction = nPC283.direction * -1;
                                                                    }
                                                                    if (this.ai[1] > 0f)
                                                                    {
                                                                        this.ai[1] = this.ai[1] - 1f;
                                                                    }
                                                                    else if (flag161)
                                                                    {
                                                                        if (base.Center.X <= Main.player[this.target].Center.X)
                                                                        {
                                                                            this.direction = 1;
                                                                        }
                                                                        else
                                                                        {
                                                                            this.direction = -1;
                                                                        }
                                                                    }
                                                                    else if (single615 > (float)num911)
                                                                    {
                                                                        if (base.Center.X <= Main.player[this.target].Center.X)
                                                                        {
                                                                            this.direction = 1;
                                                                        }
                                                                        else
                                                                        {
                                                                            this.direction = -1;
                                                                        }
                                                                    }
                                                                    float single616 = 2f;
                                                                    float single617 = 0.1f;
                                                                    if (this.velocity.X <= single616 && this.velocity.X >= -single616)
                                                                    {
                                                                        this.velocity.X = this.velocity.X + (float)this.direction * single617;
                                                                    }
                                                                    else if (Math.Abs(this.velocity.X) >= single616 + single617 * 2f)
                                                                    {
                                                                        this.velocity.X = this.velocity.X * 0.99f;
                                                                    }
                                                                    else if (this.velocity.X >= 0f)
                                                                    {
                                                                        this.velocity.X = single616;
                                                                    }
                                                                    else
                                                                    {
                                                                        this.velocity.X = -single616;
                                                                    }
                                                                    this.spriteDirection = this.direction;
                                                                }
                                                                else
                                                                {
                                                                    this.ai[0] = 2f;
                                                                    this.ai[1] = 0f;
                                                                }
                                                                if (this.collideY)
                                                                {
                                                                    this.ai[2] = 60f;
                                                                    NPC nPC284 = this;
                                                                    nPC284.directionY = nPC284.directionY * -1;
                                                                    this.velocity.Y = this.velocity.Y * -0.5f;
                                                                }
                                                                if (this.ai[2] <= 0f)
                                                                {
                                                                    int y217 = (int)(base.Center.Y / 16f);
                                                                    int x219 = (int)((base.Center.X - 8f) / 16f);
                                                                    int num912 = 30;
                                                                    int num913 = 15;
                                                                    int num914 = 0;
                                                                    for (int k8 = y217; k8 < y217 + num912; k8++)
                                                                    {
                                                                        int num915 = x219;
                                                                        while (num915 <= x219 + 1)
                                                                        {
                                                                            if (WorldGen.SolidTile(num915, k8) || Main.tile[num915, k8].liquid > 0)
                                                                            {
                                                                                num914 = k8 - y217;
                                                                                break;
                                                                            }
                                                                            else
                                                                            {
                                                                                num915++;
                                                                            }
                                                                        }
                                                                        if (num914 != 0)
                                                                        {
                                                                            break;
                                                                        }
                                                                    }
                                                                    if (num914 == 0)
                                                                    {
                                                                        this.directionY = 1;
                                                                    }
                                                                    else if (num914 < num913)
                                                                    {
                                                                        this.directionY = -1;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    this.ai[2] = this.ai[2] - 1f;
                                                                }
                                                                float single618 = 2f;
                                                                float single619 = 0.1f;
                                                                if (this.velocity.Y <= single618 && this.velocity.Y >= -single618)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y + (float)this.directionY * single619;
                                                                    return;
                                                                }
                                                                if (Math.Abs(this.velocity.Y) >= single618 + single619 * 2f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y * 0.99f;
                                                                    return;
                                                                }
                                                                if (this.velocity.Y >= 0f)
                                                                {
                                                                    this.velocity.Y = single618;
                                                                    return;
                                                                }
                                                                this.velocity.Y = -single618;
                                                                return;
                                                            }
                                                        }
                                                        else if (this.aiStyle == 99)
                                                        {
                                                            if (this.velocity.Y == 0f && this.ai[0] == 0f)
                                                            {
                                                                this.ai[0] = 1f;
                                                                this.ai[1] = 0f;
                                                                this.netUpdate = true;
                                                                return;
                                                            }
                                                            if (this.ai[0] == 1f)
                                                            {
                                                                this.velocity = Vector2.Zero;
                                                                this.position = this.oldPosition;
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                if (this.ai[1] >= 5f)
                                                                {
                                                                    this.HitEffect(0, 9999);
                                                                    this.active = false;
                                                                }
                                                                return;
                                                            }
                                                            this.velocity.Y = this.velocity.Y + 0.2f;
                                                            if (this.velocity.Y > 12f)
                                                            {
                                                                this.velocity.Y = 12f;
                                                            }
                                                            this.rotation = this.velocity.ToRotation() - 1.57079637f;
                                                            if (this.type == 519)
                                                            {
                                                                if (this.localAI[0] == 0f)
                                                                {
                                                                    this.localAI[0] = 1f;
                                                                }
                                                                return;
                                                            }
                                                        }
                                                        else if (this.aiStyle == 100)
                                                        {
                                                            if (this.velocity.Y == 0f && this.ai[0] >= 0f)
                                                            {
                                                                this.ai[0] = -1f;
                                                                this.ai[1] = 0f;
                                                                this.netUpdate = true;
                                                                return;
                                                            }
                                                            if (this.ai[0] == -1f)
                                                            {
                                                                this.velocity = Vector2.Zero;
                                                                this.position = this.oldPosition;
                                                                this.ai[1] = this.ai[1] + 1f;
                                                                if (this.ai[1] >= 5f)
                                                                {
                                                                    this.HitEffect(0, 9999);
                                                                    this.active = false;
                                                                }
                                                                return;
                                                            }
                                                            this.rotation = this.velocity.ToRotation() - 1.57079637f;
                                                            if (this.type == 522)
                                                            {
                                                                if (this.localAI[0] == 0f)
                                                                {
                                                                    this.localAI[0] = 1f;
                                                                    this.velocity.X = this.ai[2];
                                                                    this.velocity.Y = this.ai[3];
                                                                }
                                                                this.dontTakeDamage = (this.ai[0] < 0f ? false : this.ai[0] <= 20f);
                                                                if (this.ai[0] >= 0f)
                                                                {
                                                                    this.ai[0] = this.ai[0] + 1f;
                                                                    if (this.ai[0] > 60f)
                                                                    {
                                                                        Vector2 vector2322 = this.velocity;
                                                                        double num928 = (double)this.ai[1];
                                                                        vector24 = new Vector2();
                                                                        this.velocity = vector2322.RotatedBy(num928, vector24);
                                                                    }
                                                                    if (this.ai[0] > 120f)
                                                                    {
                                                                        NPC nPC285 = this;
                                                                        nPC285.velocity = nPC285.velocity * 0.98f;
                                                                    }
                                                                    if (this.velocity.Length() < 0.2f)
                                                                    {
                                                                        this.velocity = Vector2.Zero;
                                                                        return;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else if (this.aiStyle == 101)
                                                        {
                                                            float single620 = 420f;
                                                            float single621 = 120f;
                                                            int num929 = 1;
                                                            float single622 = 0f;
                                                            float single623 = 1f;
                                                            float single624 = 4f;
                                                            bool flag163 = (this.ai[1] < 0f ? true : !Main.npc[(int)this.ai[0]].active);
                                                            if (Main.npc[(int)this.ai[0]].type != 439)
                                                            {
                                                                flag163 = true;
                                                            }
                                                            else
                                                            {
                                                                if (Main.npc[(int)this.ai[0]].life < Main.npc[(int)this.ai[0]].lifeMax / 2)
                                                                {
                                                                    num929 = 2;
                                                                }
                                                                if (Main.npc[(int)this.ai[0]].life < Main.npc[(int)this.ai[0]].lifeMax / 4)
                                                                {
                                                                    num929 = 3;
                                                                }
                                                            }
                                                            this.ai[1] = this.ai[1] + (float)num929;
                                                            float single625 = this.ai[1] / single621;
                                                            single625 = MathHelper.Clamp(single625, 0f, 1f);
                                                            this.position = base.Center;
                                                            this.scale = MathHelper.Lerp(single622, single623, single625);
                                                            base.Center = this.position;
                                                            this.alpha = (int)(255f - single625 * 255f);
                                                            this.localAI[0] = this.localAI[0] + 0.05235988f;
                                                            float[] singleArray15 = this.localAI;
                                                            Vector2 unitY21 = Vector2.UnitY;
                                                            double num930 = (double)(this.ai[1] * 6.28318548f / 60f);
                                                            vector24 = new Vector2();
                                                            singleArray15[1] = 0.25f + unitY21.RotatedBy(num930, vector24).Y * 0.25f;
                                                            if (this.ai[1] >= single620)
                                                            {
                                                                flag163 = true;
                                                                if (Main.netMode != 1)
                                                                {
                                                                    for (int p8 = 0; p8 < 4; p8++)
                                                                    {
                                                                        Vector2 vector2326 = new Vector2(0f, -single624);
                                                                        double num931 = (double)(1.57079637f * (float)p8);
                                                                        vector24 = new Vector2();
                                                                        Vector2 vector2327 = vector2326.RotatedBy(num931, vector24);
                                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, vector2327.X, vector2327.Y, 593, this.damage, 0f, Main.myPlayer, 0f, 0f);
                                                                    }
                                                                }
                                                            }
                                                            if (flag163)
                                                            {
                                                                this.HitEffect(0, 9999);
                                                                this.active = false;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (Main.rand.Next(20) == 0)
                                                        {
                                                            this.soundHit = Main.rand.Next(15, 18);
                                                        }
                                                        if (Main.netMode != 1)
                                                        {
                                                            bool flag164 = false;
                                                            int num932 = (int)this.ai[0];
                                                            int num933 = (int)this.ai[1];
                                                            if (!flag164 && (!Main.tile[num932, num933].active() || Main.tile[num932, num933].type != 378))
                                                            {
                                                                flag164 = true;
                                                            }
                                                            if (!flag164 && (this.target == 255 || Main.player[this.target].dead || Vector2.Distance(base.Center, Main.player[this.target].Center) > 160000f))
                                                            {
                                                                this.TargetClosest(false);
                                                                if (this.target == 255 || Main.player[this.target].dead || Vector2.Distance(base.Center, Main.player[this.target].Center) > 160000f)
                                                                {
                                                                    flag164 = true;
                                                                }
                                                            }
                                                            if (flag164)
                                                            {
                                                                this.life = 0;
                                                                this.HitEffect(0, 10);
                                                                this.active = false;
                                                                int num934 = TETrainingDummy.Find((int)this.ai[0], (int)this.ai[1]);
                                                                if (num934 != -1)
                                                                {
                                                                    ((TETrainingDummy)TileEntity.ByID[num934]).Deactivate();
                                                                }
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.type == 437)
                                                    {
                                                        if (this.localAI[3] == 0f && Main.netMode != 1)
                                                        {
                                                            this.localAI[3] = 1f;
                                                            this.netUpdate = true;
                                                            Point[] pointArray = null;
                                                            if (!CultistRitual.CheckFloor(base.Center, out pointArray))
                                                            {
                                                                this.life = 0;
                                                                this.HitEffect(0, 10);
                                                                this.active = false;
                                                                return;
                                                            }
                                                            int num935 = 0;
                                                            int num936 = 1;
                                                            for (int q8 = 0; q8 < 4; q8++)
                                                            {
                                                                int num937 = 0;
                                                                bool flag165 = (q8 == 1 ? true : q8 == 2);
                                                                num937 = (!flag165 ? 379 : 438);
                                                                int num938 = NPC.NewNPC(pointArray[q8].X * 16 + 8, pointArray[q8].Y * 16 - 48, num937, 0, 0f, 0f, 0f, 0f, 255);
                                                                if (!flag165)
                                                                {
                                                                    int num939 = num935;
                                                                    num935 = num939 + 1;
                                                                    this.ai[num939] = (float)(num938 + 1);
                                                                    Main.npc[num938].ai[3] = (float)(-(this.whoAmI + 1));
                                                                }
                                                                else
                                                                {
                                                                    int num940 = num936;
                                                                    num936 = num940 + 1;
                                                                    this.localAI[num940] = (float)(num938 + 1);
                                                                    Main.npc[num938].ai[3] = (float)(-(this.whoAmI + 1));
                                                                }
                                                                Main.npc[num938].netUpdate = true;
                                                            }
                                                        }
                                                        if (this.localAI[0] == 1f && Main.netMode != 1)
                                                        {
                                                            this.localAI[0] = 2f;
                                                            for (int r8 = 0; r8 < 2; r8++)
                                                            {
                                                                Main.npc[(int)this.localAI[r8 + 1] - 1].ai[1] = 1f;
                                                                Main.npc[(int)this.localAI[r8 + 1] - 1].netUpdate = true;
                                                                Main.npc[(int)this.ai[r8] - 1].ai[3] = 0f;
                                                                Main.npc[(int)this.ai[r8] - 1].TargetClosest(true);
                                                                Main.npc[(int)this.ai[r8] - 1].netUpdate = true;
                                                            }
                                                        }
                                                        if (this.ai[0] != -1f && Main.netMode != 1)
                                                        {
                                                            bool flag166 = true;
                                                            for (int s8 = 0; s8 < 2; s8++)
                                                            {
                                                                if (Main.npc[(int)this.localAI[s8 + 1] - 1].active && Main.npc[(int)this.localAI[s8 + 1] - 1].type == 438)
                                                                {
                                                                    flag166 = false;
                                                                }
                                                                if (Main.npc[(int)this.ai[s8] - 1].active && Main.npc[(int)this.ai[s8] - 1].type == 379)
                                                                {
                                                                    flag166 = false;
                                                                }
                                                            }
                                                            if (flag166)
                                                            {
                                                                this.ai[0] = -1f;
                                                                this.ai[1] = 0f;
                                                                this.ai[3] = 0f;
                                                                int x220 = (int)base.Center.X / 16 + 11 * (Main.rand.Next(2) == 0).ToDirectionInt();
                                                                int num941 = 0;
                                                                int num942 = -5;
                                                                while (num942 < 12)
                                                                {
                                                                    int num943 = x220;
                                                                    int y218 = (int)base.Center.Y / 16 + num942;
                                                                    if (!WorldGen.SolidTile(num943, y218) || Collision.SolidTiles(num943 - 1, num943 + 1, y218 - 3, y218 - 1))
                                                                    {
                                                                        if (num942 == 11)
                                                                        {
                                                                            num941 = y218;
                                                                        }
                                                                        num942++;
                                                                    }
                                                                    else
                                                                    {
                                                                        num941 = y218;
                                                                        break;
                                                                    }
                                                                }
                                                                int num944 = NPC.NewNPC(x220 * 16 + 10, num941 * 16 - 2, 439, 0, 0f, 0f, 0f, 0f, 255);
                                                                NPC nPC286 = Main.npc[num944];
                                                                NPC nPC287 = Main.npc[num944];
                                                                int num945 = Math.Sign(base.Center.X - (float)(x220 * 16) - 10f);
                                                                num6 = num945;
                                                                nPC287.spriteDirection = num945;
                                                                nPC286.direction = num6;
                                                                this.ai[2] = (float)num944;
                                                                this.netUpdate = true;
                                                                CultistRitual.TabletDestroyed();
                                                            }
                                                        }
                                                        if (this.ai[0] == -1f)
                                                        {
                                                            this.ai[3] = this.ai[3] + 1f;
                                                            if (this.ai[3] > 300f)
                                                            {
                                                                this.life = 0;
                                                                this.HitEffect(0, 9999);
                                                                this.active = false;
                                                                if (Main.netMode != 1)
                                                                {
                                                                    for (int t8 = 0; t8 < 6; t8++)
                                                                    {
                                                                        float single626 = 3f + Main.rand.NextFloat() * 6f;
                                                                        Vector2 vector2328 = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                                                                        Vector2 center150 = base.Center;
                                                                        center150 = center150 + (vector2328 * 30f);
                                                                        Projectile.NewProjectile(center150.X, center150.Y, vector2328.X * single626, vector2328.Y * single626, 526, 0, 0f, Main.myPlayer, Main.npc[(int)this.ai[2]].Center.X, Main.npc[(int)this.ai[2]].Center.Y);
                                                                    }
                                                                    for (int u8 = 0; u8 < 20; u8++)
                                                                    {
                                                                        if (Main.rand.Next(2) != 0)
                                                                        {
                                                                            float single627 = 3f + Main.rand.NextFloat() * 6f;
                                                                            Vector2 vector2329 = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                                                                            Vector2 center151 = base.Center;
                                                                            center151 = center151 + (vector2329 * 30f);
                                                                            Vector2 center152 = (base.Center + (vector2329 * (Main.rand.NextFloat() * 45f + 45f))) + (Vector2.UnitY * 20f);
                                                                            Projectile.NewProjectile(center151.X, center151.Y, vector2329.X * single627, -20f, 526, 0, 0f, Main.myPlayer, center152.X, center152.Y);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else if (this.ai[3] % 10f == 1f && this.ai[3] > 120f && Main.netMode != 1)
                                                            {
                                                                float single628 = 3f + Main.rand.NextFloat() * 6f;
                                                                Vector2 vector2330 = Vector2.UnitY.RotatedByRandom(6.28318548202515);
                                                                Vector2 center153 = base.Center;
                                                                center153 = center153 + (vector2330 * 25f);
                                                                Projectile.NewProjectile(center153.X, center153.Y, vector2330.X * single628, vector2330.Y * single628, 526, 0, 0f, Main.myPlayer, Main.npc[(int)this.ai[2]].Center.X, Main.npc[(int)this.ai[2]].Center.Y);
                                                            }
                                                        }
                                                    }
                                                    if (this.type == 438)
                                                    {
                                                        this.velocity.X = this.velocity.X * 0.93f;
                                                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                                        {
                                                            this.velocity.X = 0f;
                                                        }
                                                        int num946 = (int)(-this.ai[3] - 1f);
                                                        if (num946 == -1)
                                                        {
                                                            this.life = 0;
                                                            this.HitEffect(0, 10);
                                                            this.active = false;
                                                            return;
                                                        }
                                                        int num947 = Math.Sign(Main.npc[num946].Center.X - base.Center.X);
                                                        if (num947 != this.direction)
                                                        {
                                                            this.velocity.X = 0f;
                                                            int num948 = num947;
                                                            num6 = num948;
                                                            this.spriteDirection = num948;
                                                            this.direction = num6;
                                                            this.netUpdate = true;
                                                        }
                                                        if (this.justHit && Main.netMode != 1 && Main.npc[num946].localAI[0] == 0f)
                                                        {
                                                            Main.npc[num946].localAI[0] = 1f;
                                                        }
                                                    }
                                                    if (this.type == 437)
                                                    {
                                                        return;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Vector2 vector2331 = new Vector2(30f);
                                                if (!Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 398)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10);
                                                    this.active = false;
                                                }
                                                float single629 = 0f;
                                                float moonLordAttacksArray2 = 0f;
                                                float single630 = this.ai[0];
                                                this.ai[1] = this.ai[1] + 1f;
                                                int num949 = 0;
                                                int num950 = 0;
                                                while (num949 < 10)
                                                {
                                                    moonLordAttacksArray2 = (float)NPC.MoonLordAttacksArray2[1, num949];
                                                    if (moonLordAttacksArray2 + (float)num950 > this.ai[1])
                                                    {
                                                        break;
                                                    }
                                                    num950 = num950 + (int)moonLordAttacksArray2;
                                                    num949++;
                                                }
                                                if (num949 == 10)
                                                {
                                                    num949 = 0;
                                                    this.ai[1] = 0f;
                                                    moonLordAttacksArray2 = (float)NPC.MoonLordAttacksArray2[1, num949];
                                                    num950 = 0;
                                                }
                                                this.ai[0] = (float)NPC.MoonLordAttacksArray2[0, num949];
                                                single629 = (float)((int)this.ai[1] - num950);
                                                if (this.ai[0] != single630)
                                                {
                                                    this.netUpdate = true;
                                                }
                                                if (this.ai[0] == -1f)
                                                {
                                                    this.ai[1] = this.ai[1] + 1f;
                                                    if (this.ai[1] > 180f)
                                                    {
                                                        this.ai[1] = 0f;
                                                    }
                                                    float single631 = 1f;
                                                    if (this.ai[1] < 60f)
                                                    {
                                                        single631 = 0.75f;
                                                        this.localAI[0] = 0f;
                                                        this.localAI[1] = (float)Math.Sin((double)(this.ai[1] * 6.28318548f / 15f)) * 0.35f;
                                                        if (this.localAI[1] < 0f)
                                                        {
                                                            this.localAI[0] = 3.14159274f;
                                                        }
                                                    }
                                                    else if (this.ai[1] >= 120f)
                                                    {
                                                        single631 = 1.15f;
                                                        this.localAI[1] = this.localAI[1] - 0.05f;
                                                        if (this.localAI[1] < 0f)
                                                        {
                                                            this.localAI[1] = 0f;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        single631 = 1f;
                                                        if (this.localAI[1] < 0.5f)
                                                        {
                                                            this.localAI[1] = this.localAI[1] + 0.025f;
                                                        }
                                                        this.localAI[0] = this.localAI[0] + 0.209439516f;
                                                    }
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], single631, 0.3f);
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(false);
                                                    Vector2 center154 = (Main.player[this.target].Center + (Main.player[this.target].velocity * 20f)) - base.Center;
                                                    this.localAI[0] = this.localAI[0].AngleLerp(center154.ToRotation(), 0.5f);
                                                    this.localAI[1] = this.localAI[1] + 0.05f;
                                                    if (this.localAI[1] > 0.7f)
                                                    {
                                                        this.localAI[1] = 0.7f;
                                                    }
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                                    float single632 = 24f;
                                                    Vector2 center155 = base.Center;
                                                    Vector2 center156 = Main.player[this.target].Center;
                                                    Vector2 vector2332 = center156 - center155;
                                                    Vector2 unitY22 = vector2332 - (Vector2.UnitY * 200f);
                                                    unitY22 = Vector2.Normalize(unitY22) * single632;
                                                    int num951 = 30;
                                                    this.velocity.X = (this.velocity.X * (float)(num951 - 1) + unitY22.X) / (float)num951;
                                                    this.velocity.Y = (this.velocity.Y * (float)(num951 - 1) + unitY22.Y) / (float)num951;
                                                    float single633 = 0.25f;
                                                    for (int v8 = 0; v8 < 200; v8++)
                                                    {
                                                        if (v8 != this.whoAmI && Main.npc[v8].active && Main.npc[v8].type == 400 && Vector2.Distance(base.Center, Main.npc[v8].Center) < 150f)
                                                        {
                                                            if (this.position.X >= Main.npc[v8].position.X)
                                                            {
                                                                this.velocity.X = this.velocity.X + single633;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X - single633;
                                                            }
                                                            if (this.position.Y >= Main.npc[v8].position.Y)
                                                            {
                                                                this.velocity.Y = this.velocity.Y + single633;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.Y = this.velocity.Y - single633;
                                                            }
                                                        }
                                                    }
                                                    return;
                                                }
                                                if (this.ai[0] == 1f)
                                                {
                                                    if (single629 == 0f)
                                                    {
                                                        this.TargetClosest(false);
                                                        this.netUpdate = true;
                                                    }
                                                    NPC nPC288 = this;
                                                    nPC288.velocity = nPC288.velocity * 0.95f;
                                                    if (this.velocity.Length() < 1f)
                                                    {
                                                        this.velocity = Vector2.Zero;
                                                    }
                                                    Vector2 center157 = (Main.player[this.target].Center + (Main.player[this.target].velocity * 20f)) - base.Center;
                                                    this.localAI[0] = this.localAI[0].AngleLerp(center157.ToRotation(), 0.5f);
                                                    this.localAI[1] = this.localAI[1] + 0.05f;
                                                    if (this.localAI[1] > 1f)
                                                    {
                                                        this.localAI[1] = 1f;
                                                    }
                                                    if (single629 >= 20f)
                                                    {
                                                        this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.4f, 0.2f);
                                                    }
                                                    else
                                                    {
                                                        this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1.1f, 0.2f);
                                                    }
                                                    if ((single629 == moonLordAttacksArray2 - 14f || single629 == moonLordAttacksArray2 - 7f || single629 == moonLordAttacksArray2) && Main.netMode != 1)
                                                    {
                                                        Vector2 vector2333 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector2331 * this.localAI[1]);
                                                        Vector2 vector2334 = Vector2.Normalize(center157) * 8f;
                                                        Projectile.NewProjectile(base.Center.X + vector2333.X, base.Center.Y + vector2333.Y, vector2334.X, vector2334.Y, 462, 35, 0f, Main.myPlayer, 0f, 0f);
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    if (single629 >= 15f)
                                                    {
                                                        if (single629 >= 75f)
                                                        {
                                                            if (single629 >= 105f)
                                                            {
                                                                if (single629 >= 120f)
                                                                {
                                                                    NPC nPC289 = this;
                                                                    nPC289.velocity = nPC289.velocity * 0.92f;
                                                                    this.rotation = this.rotation.AngleLerp(0f, 0.2f);
                                                                    return;
                                                                }
                                                                if (single629 == 105f)
                                                                {
                                                                    this.netUpdate = true;
                                                                }
                                                                Vector2 rotationVector27 = (this.ai[2] - 1.57079637f).ToRotationVector2() * 12f;
                                                                this.velocity = rotationVector27 * 2f;
                                                                for (int w8 = 0; w8 < 1000; w8++)
                                                                {
                                                                    Projectile projectile4 = Main.projectile[w8];
                                                                    if (projectile4.active && projectile4.type == 454 && projectile4.ai[1] == (float)this.whoAmI && projectile4.ai[0] != -1f)
                                                                    {
                                                                        projectile4.ai[0] = -1f;
                                                                        projectile4.velocity = rotationVector27;
                                                                        projectile4.netUpdate = true;
                                                                    }
                                                                }
                                                                return;
                                                            }
                                                            this.localAI[0] = this.localAI[0].AngleLerp(this.ai[2] - 1.57079637f, 0.2f);
                                                            this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.75f, 0.2f);
                                                            if (single629 == 75f)
                                                            {
                                                                this.TargetClosest(false);
                                                                this.netUpdate = true;
                                                                this.velocity = Vector2.UnitY * -7f;
                                                                for (int x810 = 0; x810 < 1000; x810++)
                                                                {
                                                                    Projectile projectile5 = Main.projectile[x810];
                                                                    if (projectile5.active && projectile5.type == 454 && projectile5.ai[1] == (float)this.whoAmI && projectile5.ai[0] != -1f)
                                                                    {
                                                                        Projectile projectile6 = projectile5;
                                                                        projectile6.velocity = projectile6.velocity + this.velocity;
                                                                        projectile5.netUpdate = true;
                                                                    }
                                                                }
                                                            }
                                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                                            this.ai[2] = (Main.player[this.target].Center - base.Center).ToRotation() + 1.57079637f;
                                                            this.rotation = this.rotation.AngleTowards(this.ai[2], 0.104719758f);
                                                            return;
                                                        }
                                                        float single634 = (single629 - 15f) / 10f;
                                                        int num952 = 0;
                                                        int num953 = 0;
                                                        num6 = (int)single634;
                                                        switch (num6)
                                                        {
                                                            case 0:
                                                            {
                                                                num952 = 0;
                                                                num953 = 2;
                                                                break;
                                                            }
                                                            case 1:
                                                            {
                                                                num952 = 2;
                                                                num953 = 5;
                                                                break;
                                                            }
                                                            case 2:
                                                            {
                                                                num952 = 5;
                                                                num953 = 3;
                                                                break;
                                                            }
                                                            case 3:
                                                            {
                                                                num952 = 3;
                                                                num953 = 1;
                                                                break;
                                                            }
                                                            case 4:
                                                            {
                                                                num952 = 1;
                                                                num953 = 4;
                                                                break;
                                                            }
                                                            case 5:
                                                            {
                                                                num952 = 4;
                                                                num953 = 0;
                                                                break;
                                                            }
                                                        }
                                                        Vector2 unitY23 = Vector2.UnitY * -30f;
                                                        double num954 = (double)((float)num952 * 6.28318548f / 6f);
                                                        vector24 = new Vector2();
                                                        Vector2 vector2335 = unitY23.RotatedBy(num954, vector24);
                                                        double num955 = (double)((float)num953 * 6.28318548f / 6f);
                                                        vector24 = new Vector2();
                                                        Vector2 vector2336 = unitY23.RotatedBy(num955, vector24);
                                                        Vector2 vector2337 = Vector2.Lerp(vector2335, vector2336, single634 - (float)((int)single634));
                                                        float single635 = vector2337.Length() / 30f;
                                                        this.localAI[0] = vector2337.ToRotation();
                                                        this.localAI[1] = MathHelper.Lerp(this.localAI[1], single635, 0.5f);
                                                        if ((single629 - 15f) % 10f == 0f && Main.netMode != 1)
                                                        {
                                                            Vector2 unitY24 = Vector2.Normalize(vector2337);
                                                            if (unitY24.HasNaNs())
                                                            {
                                                                unitY24 = Vector2.UnitY * -1f;
                                                            }
                                                            unitY24 = unitY24 * 4f;
                                                            Projectile.NewProjectile(base.Center.X + vector2337.X, base.Center.Y + vector2337.Y, unitY24.X, unitY24.Y, 454, 55, 0f, Main.myPlayer, 30f, (float)this.whoAmI);
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.localAI[1] = this.localAI[1] - 0.07f;
                                                        if (this.localAI[1] < 0f)
                                                        {
                                                            this.localAI[1] = 0f;
                                                        }
                                                        this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.4f, 0.2f);
                                                        NPC nPC290 = this;
                                                        nPC290.velocity = nPC290.velocity * 0.8f;
                                                        if (this.velocity.Length() < 1f)
                                                        {
                                                            this.velocity = Vector2.Zero;
                                                            return;
                                                        }
                                                    }
                                                }
                                                else if (this.ai[0] != 3f)
                                                {
                                                    if (this.ai[0] == 4f)
                                                    {
                                                        if (single629 == 0f)
                                                        {
                                                            this.TargetClosest(false);
                                                            this.netUpdate = true;
                                                        }
                                                        if (single629 >= 180f)
                                                        {
                                                            if (single629 < moonLordAttacksArray2 - 15f)
                                                            {
                                                                if (single629 == 180f && Main.netMode != 1)
                                                                {
                                                                    this.TargetClosest(false);
                                                                    Vector2 center159 = Main.player[this.target].Center - base.Center;
                                                                    center159.Normalize();
                                                                    float single636 = -1f;
                                                                    if (center159.X < 0f)
                                                                    {
                                                                        single636 = 1f;
                                                                    }
                                                                    double num957 = (double)(-single636 * 6.28318548f / 6f);
                                                                    vector24 = new Vector2();
                                                                    center159 = center159.RotatedBy(num957, vector24);
                                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, center159.X, center159.Y, 455, 50, 0f, Main.myPlayer, single636 * 6.28318548f / 540f, (float)this.whoAmI);
                                                                    this.ai[2] = (center159.ToRotation() + 9.424778f) * single636;
                                                                    this.netUpdate = true;
                                                                }
                                                                this.localAI[1] = this.localAI[1] + 0.05f;
                                                                if (this.localAI[1] > 1f)
                                                                {
                                                                    this.localAI[1] = 1f;
                                                                }
                                                                float directionInt6 = (float)(this.ai[2] >= 0f).ToDirectionInt();
                                                                float single637 = this.ai[2];
                                                                if (single637 < 0f)
                                                                {
                                                                    single637 = single637 * -1f;
                                                                }
                                                                single637 = single637 + -9.424778f;
                                                                single637 = single637 + directionInt6 * 6.28318548f / 540f;
                                                                this.localAI[0] = single637;
                                                                this.ai[2] = (single637 + 9.424778f) * directionInt6;
                                                                return;
                                                            }
                                                            this.localAI[1] = this.localAI[1] - 0.07f;
                                                            if (this.localAI[1] < 0f)
                                                            {
                                                                this.localAI[1] = 0f;
                                                                return;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                                            this.localAI[1] = this.localAI[1] - 0.05f;
                                                            if (this.localAI[1] < 0f)
                                                            {
                                                                this.localAI[1] = 0f;
                                                            }
                                                            NPC nPC291 = this;
                                                            nPC291.velocity = nPC291.velocity * 0.95f;
                                                            if (this.velocity.Length() < 1f)
                                                            {
                                                                this.velocity = Vector2.Zero;
                                                            }
                                                            if (single629 >= 60f)
                                                            {
                                                                Vector2 center160 = base.Center;
                                                                int num958 = 0;
                                                                if (single629 >= 120f)
                                                                {
                                                                    num958 = 1;
                                                                }
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                                else if (single629 < 15f)
                                                {
                                                    this.localAI[1] = this.localAI[1] - 0.07f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.4f, 0.2f);
                                                    NPC nPC292 = this;
                                                    nPC292.velocity = nPC292.velocity * 0.9f;
                                                    if (this.velocity.Length() < 1f)
                                                    {
                                                        this.velocity = Vector2.Zero;
                                                        return;
                                                    }
                                                }
                                                else if (single629 >= 45f)
                                                {
                                                    if (single629 >= 185f)
                                                    {
                                                        NPC nPC293 = this;
                                                        nPC293.velocity = nPC293.velocity * 0.88f;
                                                        this.rotation = this.rotation.AngleLerp(0f, 0.2f);
                                                        this.localAI[1] = this.localAI[1] - 0.07f;
                                                        if (this.localAI[1] < 0f)
                                                        {
                                                            this.localAI[1] = 0f;
                                                        }
                                                        this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                                        return;
                                                    }
                                                    if (single629 == 45f)
                                                    {
                                                        this.ai[2] = (float)(Main.rand.Next(2) == 0).ToDirectionInt() * 6.28318548f / 40f;
                                                        this.netUpdate = true;
                                                    }
                                                    if ((single629 - 15f - 30f) % 40f == 0f)
                                                    {
                                                        this.ai[2] = this.ai[2] * 0.95f;
                                                    }
                                                    this.localAI[0] = this.localAI[0] + this.ai[2];
                                                    this.localAI[1] = this.localAI[1] + 0.05f;
                                                    if (this.localAI[1] > 1f)
                                                    {
                                                        this.localAI[1] = 1f;
                                                    }
                                                    Vector2 rotationVector29 = (this.localAI[0].ToRotationVector2() * vector2331) * this.localAI[1];
                                                    float single639 = MathHelper.Lerp(8f, 20f, (single629 - 15f - 30f) / 140f);
                                                    this.velocity = Vector2.Normalize(rotationVector29) * single639;
                                                    this.rotation = this.rotation.AngleLerp(this.velocity.ToRotation() + 1.57079637f, 0.2f);
                                                    if ((single629 - 15f - 30f) % 10f == 0f && Main.netMode != 1)
                                                    {
                                                        Vector2 center161 = base.Center + ((Vector2.Normalize(rotationVector29) * vector2331.Length()) * 0.4f);
                                                        Vector2 vector2338 = Vector2.Normalize(rotationVector29) * 8f;
                                                        float single640 = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * this.ai[2];
                                                        Projectile.NewProjectile(center161.X, center161.Y, vector2338.X, vector2338.Y, 452, 35, 0f, Main.myPlayer, 0f, single640);
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    this.localAI[0] = 0f;
                                                    this.localAI[1] = (float)Math.Sin((double)((single629 - 15f) * 6.28318548f / 15f)) * 0.5f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[0] = 3.14159274f;
                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (!Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 398)
                                            {
                                                this.life = 0;
                                                this.HitEffect(0, 10);
                                                this.active = false;
                                            }
                                            this.dontTakeDamage = this.localAI[3] >= 15f;
                                            this.velocity = Vector2.Zero;
                                            base.Center = Main.npc[(int)this.ai[3]].Center + new Vector2(0f, -400f);
                                            Vector2 vector2339 = new Vector2(27f, 59f);
                                            float single641 = 0f;
                                            float moonLordAttacksArray1 = 0f;
                                            int num961 = 0;
                                            int num962 = 0;
                                            if (this.ai[0] >= 0f)
                                            {
                                                float single642 = this.ai[0];
                                                this.ai[1] = this.ai[1] + 1f;
                                                int num963 = (int)Main.npc[(int)this.ai[3]].ai[2];
                                                int num964 = 2;
                                                int num965 = 0;
                                                int num966 = 0;
                                                while (num965 < 5)
                                                {
                                                    moonLordAttacksArray1 = (float)NPC.MoonLordAttacksArray[num963, num964, 1, num965];
                                                    if (moonLordAttacksArray1 + (float)num966 > this.ai[1])
                                                    {
                                                        break;
                                                    }
                                                    num966 = num966 + (int)moonLordAttacksArray1;
                                                    num965++;
                                                }
                                                if (num965 == 5)
                                                {
                                                    num965 = 0;
                                                    this.ai[1] = 0f;
                                                    moonLordAttacksArray1 = (float)NPC.MoonLordAttacksArray[num963, num964, 1, num965];
                                                    num966 = 0;
                                                }
                                                this.ai[0] = (float)NPC.MoonLordAttacksArray[num963, num964, 0, num965];
                                                single641 = (float)((int)this.ai[1] - num966);
                                                if (this.ai[0] != single642)
                                                {
                                                    this.netUpdate = true;
                                                }
                                            }
                                            if (this.ai[0] == -3f)
                                            {
                                                this.damage = 0;
                                                this.dontTakeDamage = true;
                                                this.rotation = MathHelper.Lerp(this.rotation, 0.2617994f, 0.07f);
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 32f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                                if (this.ai[1] < 0f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                                if (this.localAI[2] < 14f)
                                                {
                                                    this.localAI[2] = this.localAI[2] + 1f;
                                                }
                                            }
                                            else if (this.ai[0] == -2f)
                                            {
                                                if (Main.npc[(int)this.ai[3]].ai[0] == 2f)
                                                {
                                                    this.ai[0] = -3f;
                                                    return;
                                                }
                                                this.damage = 80;
                                                this.dontTakeDamage = true;
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 32f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                                if (this.ai[1] < 0f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                                this.ai[2] = this.ai[2] + 1f;
                                                if (this.ai[2] >= 555f)
                                                {
                                                    this.ai[2] = 0f;
                                                }
                                                if (this.ai[2] >= 120f)
                                                {
                                                    single641 = this.ai[2] - 120f;
                                                    moonLordAttacksArray1 = 555f;
                                                    num961 = 2;
                                                    Vector2 vector2340 = new Vector2(0f, 216f);
                                                    if (single641 == 0f && Main.netMode != 1)
                                                    {
                                                        Vector2 center162 = base.Center + vector2340;
                                                        for (int b8 = 0; b8 < 255; b8++)
                                                        {
                                                            Player player10 = Main.player[b8];
                                                            if (player10.active && !player10.dead && Vector2.Distance(player10.Center, center162) <= 3000f)
                                                            {
                                                                Vector2 center163 = Main.player[this.target].Center - center162;
                                                                if (center163 != Vector2.Zero)
                                                                {
                                                                    center163.Normalize();
                                                                }
                                                                Projectile.NewProjectile(center162.X, center162.Y, center163.X, center163.Y, 456, 0, 0f, Main.myPlayer, (float)(this.whoAmI + 1), (float)b8);
                                                            }
                                                        }
                                                    }
                                                    if ((single641 == 120f || single641 == 180f || single641 == 240f) && Main.netMode != 1)
                                                    {
                                                        for (int c8 = 0; c8 < 1000; c8++)
                                                        {
                                                            Projectile projectile7 = Main.projectile[c8];
                                                            if (projectile7.active && projectile7.type == 456 && Main.player[(int)projectile7.ai[1]].HasBuff(145) != -1)
                                                            {
                                                                Vector2 center164 = Main.player[this.target].Center;
                                                                int num967 = NPC.NewNPC((int)center164.X, (int)center164.Y, 401, 0, 0f, 0f, 0f, 0f, 255);
                                                                Main.npc[num967].netUpdate = true;
                                                                Main.npc[num967].ai[0] = (float)(this.whoAmI + 1);
                                                                Main.npc[num967].ai[1] = (float)c8;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else if (this.ai[0] == 0f)
                                            {
                                                num962 = 3;
                                                this.TargetClosest(false);
                                                Vector2 center165 = (Main.player[this.target].Center - base.Center) - new Vector2(0f, -22f);
                                                float single643 = center165.Length() / 500f;
                                                if (single643 > 1f)
                                                {
                                                    single643 = 1f;
                                                }
                                                single643 = 1f - single643;
                                                single643 = single643 * 2f;
                                                if (single643 > 1f)
                                                {
                                                    single643 = 1f;
                                                }
                                                this.localAI[0] = center165.ToRotation();
                                                this.localAI[1] = single643;
                                                this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                            }
                                            if (this.ai[0] == 1f)
                                            {
                                                if (single641 < 180f)
                                                {
                                                    this.localAI[1] = this.localAI[1] - 0.05f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                    if (single641 >= 60f)
                                                    {
                                                        Vector2 center166 = base.Center;
                                                        int num968 = 0;
                                                        if (single641 >= 120f)
                                                        {
                                                            num968 = 1;
                                                        }
                                                        for (int d8 = 0; d8 < 1 + num968; d8++)
                                                        {
                                                            int num969 = 229;
                                                            float single644 = 0.8f;
                                                            if (d8 % 2 == 1)
                                                            {
                                                                num969 = 229;
                                                                single644 = 1.65f;
                                                            }
                                                        }
                                                    }
                                                }
                                                else if (single641 >= moonLordAttacksArray1 - 15f)
                                                {
                                                    this.localAI[1] = this.localAI[1] - 0.07f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                    num962 = 3;
                                                }
                                                else
                                                {
                                                    if (single641 == 180f && Main.netMode != 1)
                                                    {
                                                        this.TargetClosest(false);
                                                        Vector2 center167 = Main.player[this.target].Center - base.Center;
                                                        center167.Normalize();
                                                        float single645 = -1f;
                                                        if (center167.X < 0f)
                                                        {
                                                            single645 = 1f;
                                                        }
                                                        double num971 = (double)(-single645 * 6.28318548f / 6f);
                                                        vector24 = new Vector2();
                                                        center167 = center167.RotatedBy(num971, vector24);
                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, center167.X, center167.Y, 455, 75, 0f, Main.myPlayer, single645 * 6.28318548f / 540f, (float)this.whoAmI);
                                                        this.ai[2] = (center167.ToRotation() + 9.424778f) * single645;
                                                        this.netUpdate = true;
                                                    }
                                                    this.localAI[1] = this.localAI[1] + 0.05f;
                                                    if (this.localAI[1] > 1f)
                                                    {
                                                        this.localAI[1] = 1f;
                                                    }
                                                    float directionInt7 = (float)(this.ai[2] >= 0f).ToDirectionInt();
                                                    float single646 = this.ai[2];
                                                    if (single646 < 0f)
                                                    {
                                                        single646 = single646 * -1f;
                                                    }
                                                    single646 = single646 + -9.424778f;
                                                    single646 = single646 + directionInt7 * 6.28318548f / 540f;
                                                    this.localAI[0] = single646;
                                                    this.ai[2] = (single646 + 9.424778f) * directionInt7;
                                                }
                                            }
                                            else if (this.ai[0] == 2f)
                                            {
                                                num961 = 2;
                                                num962 = 3;
                                                Vector2 vector2341 = new Vector2(0f, 216f);
                                                if (single641 == 0f && Main.netMode != 1)
                                                {
                                                    Vector2 center168 = base.Center + vector2341;
                                                    for (int e8 = 0; e8 < 255; e8++)
                                                    {
                                                        Player player11 = Main.player[e8];
                                                        if (player11.active && !player11.dead && Vector2.Distance(player11.Center, center168) <= 3000f)
                                                        {
                                                            Vector2 center169 = Main.player[this.target].Center - center168;
                                                            if (center169 != Vector2.Zero)
                                                            {
                                                                center169.Normalize();
                                                            }
                                                            Projectile.NewProjectile(center168.X, center168.Y, center169.X, center169.Y, 456, 0, 0f, Main.myPlayer, (float)(this.whoAmI + 1), (float)e8);
                                                        }
                                                    }
                                                }
                                                if ((single641 == 120f || single641 == 180f || single641 == 240f) && Main.netMode != 1)
                                                {
                                                    for (int f8 = 0; f8 < 1000; f8++)
                                                    {
                                                        Projectile projectile8 = Main.projectile[f8];
                                                        if (projectile8.active && projectile8.type == 456 && Main.player[(int)projectile8.ai[1]].HasBuff(145) != -1)
                                                        {
                                                            Vector2 center170 = Main.player[this.target].Center;
                                                            int num972 = NPC.NewNPC((int)center170.X, (int)center170.Y, 401, 0, 0f, 0f, 0f, 0f, 255);
                                                            Main.npc[num972].netUpdate = true;
                                                            Main.npc[num972].ai[0] = (float)(this.whoAmI + 1);
                                                            Main.npc[num972].ai[1] = (float)f8;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (this.ai[0] == 3f)
                                            {
                                                if (single641 == 0f)
                                                {
                                                    this.TargetClosest(false);
                                                    this.netUpdate = true;
                                                }
                                                Vector2 center171 = (Main.player[this.target].Center + (Main.player[this.target].velocity * 20f)) - base.Center;
                                                this.localAI[0] = this.localAI[0].AngleLerp(center171.ToRotation(), 0.5f);
                                                this.localAI[1] = this.localAI[1] + 0.05f;
                                                if (this.localAI[1] > 1f)
                                                {
                                                    this.localAI[1] = 1f;
                                                }
                                                if ((single641 == moonLordAttacksArray1 - 14f || single641 == moonLordAttacksArray1 - 7f || single641 == moonLordAttacksArray1) && Main.netMode != 1)
                                                {
                                                    Vector2 vector2342 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector2339 * this.localAI[1]);
                                                    Vector2 vector2343 = Vector2.Normalize(center171) * 8f;
                                                    Projectile.NewProjectile(base.Center.X + vector2342.X, base.Center.Y + vector2342.Y, vector2343.X, vector2343.Y, 462, 30, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                            }
                                            int num973 = num961 * 7;
                                            if ((float)num973 > this.localAI[2])
                                            {
                                                this.localAI[2] = this.localAI[2] + 1f;
                                            }
                                            if ((float)num973 < this.localAI[2])
                                            {
                                                this.localAI[2] = this.localAI[2] - 1f;
                                            }
                                            if (this.localAI[2] < 0f)
                                            {
                                                this.localAI[2] = 0f;
                                            }
                                            if (this.localAI[2] > 14f)
                                            {
                                                this.localAI[2] = 14f;
                                            }
                                            int num974 = num962 * 5;
                                            if ((float)num974 > this.localAI[3])
                                            {
                                                this.localAI[3] = this.localAI[3] + 1f;
                                            }
                                            if ((float)num974 < this.localAI[3])
                                            {
                                                this.localAI[3] = this.localAI[3] - 1f;
                                            }
                                            if (this.localAI[3] < 0f)
                                            {
                                                this.localAI[2] = 0f;
                                            }
                                            if (this.localAI[3] > 15f)
                                            {
                                                this.localAI[2] = 15f;
                                            }
                                            int num975 = 0;
                                            if (num975 == 1)
                                            {
                                                Vector2 vector2344 = new Vector2(27f, 59f);
                                                this.TargetClosest(false);
                                                Vector2 vector2345 = (Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY)) - base.Center;
                                                float single647 = vector2345.Length() / 200f;
                                                if (single647 > 1f)
                                                {
                                                    single647 = 1f;
                                                }
                                                single647 = 1f - single647;
                                                single647 = single647 * 2f;
                                                if (single647 > 1f)
                                                {
                                                    single647 = 1f;
                                                }
                                                this.localAI[0] = vector2345.ToRotation();
                                                this.localAI[1] = single647;
                                                this.localAI[1] = 1f;
                                            }
                                            if (num975 == 2)
                                            {
                                                Vector2 vector2346 = new Vector2(27f, 59f);
                                                float single648 = 6.28318548f * ((float)Main.time % 600f) / 600f;
                                                this.localAI[0] = (new Vector2((float)Math.Cos((double)single648) * vector2346.X, (float)Math.Sin((double)single648) * vector2346.Y)).ToRotation();
                                                this.localAI[1] = 0.75f;
                                                if (this.ai[1] == 0f)
                                                {
                                                    Vector2 one3 = single648.ToRotationVector2();
                                                    one3 = Vector2.One;
                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, one3.X, one3.Y, 455, 1, 0f, Main.myPlayer, 0.0104719754f, (float)this.whoAmI);
                                                }
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 600f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                            }
                                            if (num975 == 3)
                                            {
                                                Vector2 vector2347 = new Vector2(0f, 216f);
                                                if (this.ai[1] == 0f)
                                                {
                                                    this.TargetClosest(false);
                                                    Vector2 center172 = Main.player[this.target].Center - base.Center;
                                                    center172.Normalize();
                                                    Projectile.NewProjectile(base.Center.X + vector2347.X, base.Center.Y + vector2347.Y, center172.X, center172.Y, 456, 0, 0f, Main.myPlayer, (float)(this.whoAmI + 1), (float)this.target);
                                                }
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] >= 600f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                            }
                                            if (num975 == 4)
                                            {
                                                Vector2 vector2348 = new Vector2(27f, 59f);
                                                this.TargetClosest(false);
                                                Vector2 center173 = (Main.player[this.target].Center + (Main.player[this.target].velocity * 20f)) - base.Center;
                                                this.localAI[0] = this.localAI[0].AngleLerp(center173.ToRotation(), 0.5f);
                                                this.localAI[1] = 1f;
                                                this.ai[1] = this.ai[1] + 1f;
                                                if (this.ai[1] == 76f || this.ai[1] == 83f || this.ai[1] == 90f)
                                                {
                                                    vector2339 = new Vector2(27f, 59f);
                                                    Vector2 vector2349 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector2339 * this.localAI[1]);
                                                    Vector2 vector2350 = Vector2.Normalize(center173) * 8f;
                                                    Projectile.NewProjectile(base.Center.X + vector2349.X, base.Center.Y + vector2349.Y, vector2350.X, vector2350.Y, 462, 5, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                                if (this.ai[1] >= 90f)
                                                {
                                                    this.ai[1] = 0f;
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        this.TargetClosest(true);
                                        this.rotation = Math.Abs(this.velocity.X) * (float)this.direction * 0.1f;
                                        this.spriteDirection = this.direction;
                                        float single649 = 7f;
                                        Vector2 vector2351 = new Vector2(base.Center.X + (float)(this.direction * 20), base.Center.Y + 6f);
                                        float x223 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2351.X;
                                        float y221 = Main.player[this.target].position.Y - vector2351.Y;
                                        float single650 = (float)Math.Sqrt((double)(x223 * x223 + y221 * y221));
                                        float single651 = single649 / single650;
                                        x223 = x223 * single651;
                                        y221 = y221 * single651;
                                        bool flag167 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1);
                                        if (!Main.dayTime)
                                        {
                                            if (single650 > 600f || !flag167)
                                            {
                                                int num976 = 60;
                                                this.velocity.X = (this.velocity.X * (float)(num976 - 1) + x223) / (float)num976;
                                                this.velocity.Y = (this.velocity.Y * (float)(num976 - 1) + y221) / (float)num976;
                                                return;
                                            }
                                            NPC nPC294 = this;
                                            nPC294.velocity = nPC294.velocity * 0.98f;
                                            if (Math.Abs(this.velocity.X) < 1f && Math.Abs(this.velocity.Y) < 1f && Main.netMode != 1)
                                            {
                                                this.localAI[0] = this.localAI[0] + 1f;
                                                if (this.localAI[0] >= 15f)
                                                {
                                                    this.localAI[0] = 0f;
                                                    x223 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2351.X;
                                                    y221 = Main.player[this.target].Center.Y - vector2351.Y;
                                                    x223 = x223 + (float)Main.rand.Next(-35, 36);
                                                    y221 = y221 + (float)Main.rand.Next(-35, 36);
                                                    x223 = x223 * (1f + (float)Main.rand.Next(-20, 21) * 0.015f);
                                                    y221 = y221 * (1f + (float)Main.rand.Next(-20, 21) * 0.015f);
                                                    single650 = (float)Math.Sqrt((double)(x223 * x223 + y221 * y221));
                                                    single651 = 10f / single650;
                                                    x223 = x223 * single651;
                                                    y221 = y221 * single651;
                                                    x223 = x223 * (1f + (float)Main.rand.Next(-20, 21) * 0.0125f);
                                                    y221 = y221 * (1f + (float)Main.rand.Next(-20, 21) * 0.0125f);
                                                    Projectile.NewProjectile(vector2351.X, vector2351.Y, x223, y221, 180, 32, 0f, Main.myPlayer, 0f, 0f);
                                                    return;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            int num977 = 60;
                                            this.velocity.X = (this.velocity.X * (float)(num977 - 1) - x223) / (float)num977;
                                            this.velocity.Y = (this.velocity.Y * (float)(num977 - 1) - y221) / (float)num977;
                                            if (this.timeLeft > 10)
                                            {
                                                this.timeLeft = 10;
                                                return;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    float single652 = 2f;
                                    this.noGravity = true;
                                    this.noTileCollide = true;
                                    if (!Main.dayTime)
                                    {
                                        this.TargetClosest(true);
                                    }
                                    bool flag168 = false;
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        single652 = 3f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        single652 = 4f;
                                    }
                                    if (Main.dayTime)
                                    {
                                        if (this.timeLeft > 10)
                                        {
                                            this.timeLeft = 10;
                                        }
                                        single652 = 8f;
                                    }
                                    else if (this.ai[0] == 0f)
                                    {
                                        this.ai[1] = this.ai[1] + 1f;
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            this.ai[1] = this.ai[1] + 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            this.ai[1] = this.ai[1] + 1f;
                                        }
                                        if (this.ai[1] >= 300f && Main.netMode != 1)
                                        {
                                            this.ai[1] = 0f;
                                            if ((double)this.life >= (double)this.lifeMax * 0.25 || this.type == 344)
                                            {
                                                this.ai[0] = (float)Main.rand.Next(1, 3);
                                            }
                                            else
                                            {
                                                this.ai[0] = (float)Main.rand.Next(3, 5);
                                            }
                                            this.netUpdate = true;
                                        }
                                    }
                                    else if (this.ai[0] == 1f)
                                    {
                                        if (this.type != 344)
                                        {
                                            flag168 = true;
                                            this.ai[1] = this.ai[1] + 1f;
                                            if (this.ai[1] % 15f == 0f)
                                            {
                                                Vector2 vector2352 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                                float x224 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2352.X;
                                                float y222 = Main.player[this.target].position.Y - vector2352.Y;
                                                float single653 = (float)Math.Sqrt((double)(x224 * x224 + y222 * y222));
                                                single653 = 10f / single653;
                                                x224 = x224 * single653;
                                                y222 = y222 * single653;
                                                x224 = x224 * (1f + (float)Main.rand.Next(-20, 21) * 0.01f);
                                                y222 = y222 * (1f + (float)Main.rand.Next(-20, 21) * 0.01f);
                                                Projectile.NewProjectile(vector2352.X, vector2352.Y, x224, y222, 325, 50, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (this.ai[1] >= 120f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[0] = 0f;
                                            }
                                        }
                                        else
                                        {
                                            flag168 = true;
                                            this.ai[1] = this.ai[1] + 1f;
                                            if (this.ai[1] % 5f == 0f)
                                            {
                                                Vector2 vector2353 = new Vector2(this.position.X + 20f + (float)Main.rand.Next(this.width - 40), this.position.Y + 20f + (float)Main.rand.Next(this.height - 40));
                                                float x225 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2353.X;
                                                float y223 = Main.player[this.target].position.Y - vector2353.Y;
                                                x225 = x225 + (float)Main.rand.Next(-50, 51);
                                                y223 = y223 + (float)Main.rand.Next(-50, 51);
                                                y223 = y223 - Math.Abs(x225) * ((float)Main.rand.Next(0, 21) * 0.01f);
                                                float single654 = (float)Math.Sqrt((double)(x225 * x225 + y223 * y223));
                                                single654 = 12.5f / single654;
                                                x225 = x225 * single654;
                                                y223 = y223 * single654;
                                                x225 = x225 * (1f + (float)Main.rand.Next(-20, 21) * 0.02f);
                                                y223 = y223 * (1f + (float)Main.rand.Next(-20, 21) * 0.02f);
                                                Projectile.NewProjectile(vector2353.X, vector2353.Y, x225, y223, 345, 43, 0f, Main.myPlayer, (float)Main.rand.Next(0, 31), 0f);
                                            }
                                            if (this.ai[1] >= 180f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[0] = 0f;
                                            }
                                        }
                                    }
                                    else if (this.ai[0] == 2f)
                                    {
                                        if (this.type != 344)
                                        {
                                            flag168 = true;
                                            this.ai[1] = this.ai[1] + 1f;
                                            if (this.ai[1] > 60f && this.ai[1] < 240f && this.ai[1] % 8f == 0f)
                                            {
                                                float single655 = 10f;
                                                Vector2 vector2354 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                                float x226 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2354.X;
                                                float y224 = Main.player[this.target].position.Y - vector2354.Y;
                                                y224 = y224 - Math.Abs(x226) * 0.3f;
                                                single655 = single655 + Math.Abs(x226) * 0.004f;
                                                if (single655 > 14f)
                                                {
                                                    single655 = 14f;
                                                }
                                                x226 = x226 + (float)Main.rand.Next(-50, 51);
                                                y224 = y224 - (float)Main.rand.Next(50, 201);
                                                float single656 = (float)Math.Sqrt((double)(x226 * x226 + y224 * y224));
                                                single656 = single655 / single656;
                                                x226 = x226 * single656;
                                                y224 = y224 * single656;
                                                x226 = x226 * (1f + (float)Main.rand.Next(-30, 31) * 0.01f);
                                                y224 = y224 * (1f + (float)Main.rand.Next(-30, 31) * 0.01f);
                                                Projectile.NewProjectile(vector2354.X, vector2354.Y, x226, y224, Main.rand.Next(326, 329), 40, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (this.ai[1] >= 300f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[0] = 0f;
                                            }
                                        }
                                        else
                                        {
                                            flag168 = true;
                                            this.ai[1] = this.ai[1] + 1f;
                                            if (this.ai[1] > 60f && this.ai[1] < 240f && this.ai[1] % 15f == 0f)
                                            {
                                                float single657 = 4.5f;
                                                Vector2 vector2355 = new Vector2(this.position.X + 20f + (float)Main.rand.Next(this.width - 40), this.position.Y + 60f + (float)Main.rand.Next(this.height - 80));
                                                float x227 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2355.X;
                                                float y225 = Main.player[this.target].position.Y - vector2355.Y;
                                                y225 = y225 - Math.Abs(x227) * 0.3f;
                                                single657 = single657 + Math.Abs(x227) * 0.004f;
                                                x227 = x227 + (float)Main.rand.Next(-50, 51);
                                                y225 = y225 - (float)Main.rand.Next(50, 201);
                                                float single658 = (float)Math.Sqrt((double)(x227 * x227 + y225 * y225));
                                                single658 = single657 / single658;
                                                x227 = x227 * single658;
                                                y225 = y225 * single658;
                                                x227 = x227 * (1f + (float)Main.rand.Next(-30, 31) * 0.01f);
                                                y225 = y225 * (1f + (float)Main.rand.Next(-30, 31) * 0.01f);
                                                Projectile.NewProjectile(vector2355.X, vector2355.Y, x227, y225, 346, 57, 0f, Main.myPlayer, 0f, (float)Main.rand.Next(2));
                                            }
                                            if (this.ai[1] >= 300f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[0] = 0f;
                                            }
                                        }
                                    }
                                    else if (this.ai[0] == 3f)
                                    {
                                        single652 = 4f;
                                        this.ai[1] = this.ai[1] + 1f;
                                        if (this.ai[1] % 30f == 0f)
                                        {
                                            Vector2 vector2356 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                            float x228 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2356.X;
                                            float y226 = Main.player[this.target].position.Y - vector2356.Y;
                                            float single659 = (float)Math.Sqrt((double)(x228 * x228 + y226 * y226));
                                            single659 = 16f / single659;
                                            x228 = x228 * single659;
                                            y226 = y226 * single659;
                                            x228 = x228 * (1f + (float)Main.rand.Next(-20, 21) * 0.001f);
                                            y226 = y226 * (1f + (float)Main.rand.Next(-20, 21) * 0.001f);
                                            Projectile.NewProjectile(vector2356.X, vector2356.Y, x228, y226, 325, 75, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                        if (this.ai[1] >= 120f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 0f;
                                        }
                                    }
                                    else if (this.ai[0] == 4f)
                                    {
                                        single652 = 4f;
                                        this.ai[1] = this.ai[1] + 1f;
                                        if (this.ai[1] % 10f == 0f)
                                        {
                                            float single660 = 12f;
                                            Vector2 vector2357 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                            float x229 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector2357.X;
                                            float y227 = Main.player[this.target].position.Y - vector2357.Y;
                                            y227 = y227 - Math.Abs(x229) * 0.2f;
                                            single660 = single660 + Math.Abs(x229) * 0.002f;
                                            if (single660 > 16f)
                                            {
                                                single660 = 16f;
                                            }
                                            x229 = x229 + (float)Main.rand.Next(-50, 51);
                                            y227 = y227 - (float)Main.rand.Next(50, 201);
                                            float single661 = (float)Math.Sqrt((double)(x229 * x229 + y227 * y227));
                                            single661 = single660 / single661;
                                            x229 = x229 * single661;
                                            y227 = y227 * single661;
                                            x229 = x229 * (1f + (float)Main.rand.Next(-30, 31) * 0.005f);
                                            y227 = y227 * (1f + (float)Main.rand.Next(-30, 31) * 0.005f);
                                            Projectile.NewProjectile(vector2357.X, vector2357.Y, x229, y227, Main.rand.Next(326, 329), 50, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                        if (this.ai[1] >= 240f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 0f;
                                        }
                                    }
                                    if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 50f)
                                    {
                                        flag168 = true;
                                    }
                                    if (!flag168)
                                    {
                                        if (this.direction > 0)
                                        {
                                            this.velocity.X = (this.velocity.X * 20f + single652) / 21f;
                                        }
                                        if (this.direction < 0)
                                        {
                                            this.velocity.X = (this.velocity.X * 20f - single652) / 21f;
                                        }
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X * 0.9f;
                                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                        {
                                            this.velocity.X = 0f;
                                        }
                                    }
                                    int num978 = 80;
                                    int num979 = 20;
                                    Vector2 vector2358 = new Vector2(base.Center.X - (float)(num978 / 2), this.position.Y + (float)this.height - (float)num979);
                                    bool flag169 = false;
                                    if (this.position.X < Main.player[this.target].position.X && this.position.X + (float)this.width > Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y + (float)this.height < Main.player[this.target].position.Y + (float)Main.player[this.target].height - 16f)
                                    {
                                        flag169 = true;
                                    }
                                    if (flag169)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.5f;
                                    }
                                    else if (!Collision.SolidCollision(vector2358, num978, num979))
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = 0f;
                                        }
                                        if ((double)this.velocity.Y >= 0.1)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.5f;
                                        }
                                        else
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.025f;
                                        }
                                    }
                                    else
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = 0f;
                                        }
                                        if ((double)this.velocity.Y <= -0.2)
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.2f;
                                        }
                                        else
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.025f;
                                        }
                                        if (this.velocity.Y < -4f)
                                        {
                                            this.velocity.Y = -4f;
                                        }
                                    }
                                    if (this.velocity.Y > 10f)
                                    {
                                        this.velocity.Y = 10f;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                if (NPC.crimsonBoss < 0)
                                {
                                    this.active = false;
                                    this.netUpdate = true;
                                    return;
                                }
                                if (this.ai[0] != 0f)
                                {
                                    if (Main.expertMode)
                                    {
                                        Vector2 center174 = Main.player[this.target].Center - base.Center;
                                        center174.Normalize();
                                        center174 = center174 * 9f;
                                        this.velocity = ((this.velocity * 99f) + center174) / 100f;
                                    }
                                    Vector2 vector2359 = new Vector2(base.Center.X, base.Center.Y);
                                    float x230 = Main.npc[NPC.crimsonBoss].Center.X - vector2359.X;
                                    float y228 = Main.npc[NPC.crimsonBoss].Center.Y - vector2359.Y;
                                    if ((float)Math.Sqrt((double)(x230 * x230 + y228 * y228)) > 700f || this.justHit)
                                    {
                                        this.ai[0] = 0f;
                                        return;
                                    }
                                }
                                else
                                {
                                    Vector2 vector2360 = new Vector2(base.Center.X, base.Center.Y);
                                    float x231 = Main.npc[NPC.crimsonBoss].Center.X - vector2360.X;
                                    float y229 = Main.npc[NPC.crimsonBoss].Center.Y - vector2360.Y;
                                    float single662 = (float)Math.Sqrt((double)(x231 * x231 + y229 * y229));
                                    if (single662 > 90f)
                                    {
                                        single662 = 8f / single662;
                                        x231 = x231 * single662;
                                        y229 = y229 * single662;
                                        this.velocity.X = (this.velocity.X * 15f + x231) / 16f;
                                        this.velocity.Y = (this.velocity.Y * 15f + y229) / 16f;
                                        return;
                                    }
                                    if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < 8f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 1.05f;
                                        this.velocity.X = this.velocity.X * 1.05f;
                                    }
                                    if (Main.netMode != 1 && (Main.expertMode && Main.rand.Next(100) == 0 || Main.rand.Next(200) == 0))
                                    {
                                        this.TargetClosest(true);
                                        vector2360 = new Vector2(base.Center.X, base.Center.Y);
                                        x231 = Main.player[this.target].Center.X - vector2360.X;
                                        y229 = Main.player[this.target].Center.Y - vector2360.Y;
                                        single662 = (float)Math.Sqrt((double)(x231 * x231 + y229 * y229));
                                        single662 = 8f / single662;
                                        this.velocity.X = x231 * single662;
                                        this.velocity.Y = y229 * single662;
                                        this.ai[0] = 1f;
                                        this.netUpdate = true;
                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.noGravity = true;
                            this.TargetClosest(true);
                            float single663 = 4f;
                            float single664 = 0.25f;
                            Vector2 vector2361 = new Vector2(base.Center.X, base.Center.Y);
                            float x232 = Main.player[this.target].Center.X - vector2361.X;
                            float y230 = Main.player[this.target].Center.Y - vector2361.Y - 200f;
                            float single665 = (float)Math.Sqrt((double)(x232 * x232 + y230 * y230));
                            if (single665 >= 20f)
                            {
                                single665 = single663 / single665;
                                x232 = x232 * single665;
                                y230 = y230 * single665;
                            }
                            else
                            {
                                x232 = this.velocity.X;
                                y230 = this.velocity.Y;
                            }
                            if (this.velocity.X < x232)
                            {
                                this.velocity.X = this.velocity.X + single664;
                                if (this.velocity.X < 0f && x232 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + single664 * 2f;
                                }
                            }
                            else if (this.velocity.X > x232)
                            {
                                this.velocity.X = this.velocity.X - single664;
                                if (this.velocity.X > 0f && x232 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - single664 * 2f;
                                }
                            }
                            if (this.velocity.Y < y230)
                            {
                                this.velocity.Y = this.velocity.Y + single664;
                                if (this.velocity.Y < 0f && y230 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + single664 * 2f;
                                }
                            }
                            else if (this.velocity.Y > y230)
                            {
                                this.velocity.Y = this.velocity.Y - single664;
                                if (this.velocity.Y > 0f && y230 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - single664 * 2f;
                                }
                            }
                            if (this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y + (float)this.height < Main.player[this.target].position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && Main.netMode != 1)
                            {
                                this.ai[0] = this.ai[0] + 1f;
                                if (this.ai[0] > 8f)
                                {
                                    this.ai[0] = 0f;
                                    int x233 = (int)(this.position.X + 10f + (float)Main.rand.Next(this.width - 20));
                                    int y231 = (int)(this.position.Y + (float)this.height + 4f);
                                    Projectile.NewProjectile((float)x233, (float)y231, 0f, 5f, 264, 20, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        NPC.golemBoss = this.whoAmI;
                        if (this.localAI[0] == 0f && Main.netMode != 1)
                        {
                            this.localAI[0] = 1f;
                            NPC.NewNPC((int)base.Center.X - 84, (int)base.Center.Y - 9, 247, 0, 0f, 0f, 0f, 0f, 255);
                            NPC.NewNPC((int)base.Center.X + 78, (int)base.Center.Y - 9, 248, 0, 0f, 0f, 0f, 0f, 255);
                            NPC.NewNPC((int)base.Center.X - 3, (int)base.Center.Y - 57, 246, 0, 0f, 0f, 0f, 0f, 255);
                        }
                        if (this.target >= 0 && Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                            if (Main.player[this.target].dead)
                            {
                                this.noTileCollide = true;
                            }
                        }
                        if (this.alpha > 0)
                        {
                            NPC nPC295 = this;
                            nPC295.alpha = nPC295.alpha - 10;
                            if (this.alpha < 0)
                            {
                                this.alpha = 0;
                            }
                            this.ai[1] = 0f;
                        }
                        bool flag170 = false;
                        bool flag171 = false;
                        bool flag172 = false;
                        this.dontTakeDamage = false;
                        for (int g8 = 0; g8 < 200; g8++)
                        {
                            if (Main.npc[g8].active && Main.npc[g8].type == 246)
                            {
                                flag170 = true;
                            }
                            if (Main.npc[g8].active && Main.npc[g8].type == 247)
                            {
                                flag171 = true;
                            }
                            if (Main.npc[g8].active && Main.npc[g8].type == 248)
                            {
                                flag172 = true;
                            }
                        }
                        this.dontTakeDamage = flag170;
                        if (this.ai[0] == 0f)
                        {
                            this.noTileCollide = false;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.8f;
                                this.ai[1] = this.ai[1] + 1f;
                                if (this.ai[1] > 0f)
                                {
                                    if (!flag171)
                                    {
                                        this.ai[1] = this.ai[1] + 2f;
                                    }
                                    if (!flag172)
                                    {
                                        this.ai[1] = this.ai[1] + 2f;
                                    }
                                    if (!flag170)
                                    {
                                        this.ai[1] = this.ai[1] + 2f;
                                    }
                                    if (this.life < this.lifeMax)
                                    {
                                        this.ai[1] = this.ai[1] + 1f;
                                    }
                                    if (this.life < this.lifeMax / 2)
                                    {
                                        this.ai[1] = this.ai[1] + 4f;
                                    }
                                    if (this.life < this.lifeMax / 3)
                                    {
                                        this.ai[1] = this.ai[1] + 8f;
                                    }
                                }
                                if (this.ai[1] >= 300f)
                                {
                                    this.ai[1] = -20f;
                                    this.frameCounter = 0;
                                }
                                else if (this.ai[1] == -1f)
                                {
                                    this.TargetClosest(true);
                                    this.velocity.X = (float)(4 * this.direction);
                                    this.velocity.Y = -12.1f;
                                    this.ai[0] = 1f;
                                    this.ai[1] = 0f;
                                }
                            }
                        }
                        else if (this.ai[0] == 1f)
                        {
                            if (this.velocity.Y != 0f)
                            {
                                this.TargetClosest(true);
                                if (this.position.X >= Main.player[this.target].position.X || this.position.X + (float)this.width <= Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    if (this.direction < 0)
                                    {
                                        this.velocity.X = this.velocity.X - 0.2f;
                                    }
                                    else if (this.direction > 0)
                                    {
                                        this.velocity.X = this.velocity.X + 0.2f;
                                    }
                                    float single666 = 3f;
                                    if (this.life < this.lifeMax)
                                    {
                                        single666 = single666 + 1f;
                                    }
                                    if (this.life < this.lifeMax / 2)
                                    {
                                        single666 = single666 + 1f;
                                    }
                                    if (this.life < this.lifeMax / 4)
                                    {
                                        single666 = single666 + 1f;
                                    }
                                    if (this.velocity.X < -single666)
                                    {
                                        this.velocity.X = -single666;
                                    }
                                    if (this.velocity.X > single666)
                                    {
                                        this.velocity.X = single666;
                                    }
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                    this.velocity.Y = this.velocity.Y + 0.2f;
                                }
                            }
                            else
                            {
                                this.ai[0] = 0f;
                            }
                        }
                        if (this.target <= 0 || this.target == 255 || Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                        }
                        int num984 = 3000;
                        if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)num984)
                        {
                            this.TargetClosest(true);
                            if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)num984)
                            {
                                this.active = false;
                                return;
                            }
                        }
                    }
                }
                else
                {
                    if (Main.wof < 0)
                    {
                        this.active = false;
                        return;
                    }
                    this.realLife = Main.wof;
                    if (Main.npc[Main.wof].life > 0)
                    {
                        this.life = Main.npc[Main.wof].life;
                    }
                    this.TargetClosest(true);
                    this.position.X = Main.npc[Main.wof].position.X;
                    this.direction = Main.npc[Main.wof].direction;
                    this.spriteDirection = this.direction;
                    float single667 = (float)((Main.wofB + Main.wofT) / 2);
                    single667 = (this.ai[0] <= 0f ? (single667 + (float)Main.wofB) / 2f : (single667 + (float)Main.wofT) / 2f);
                    single667 = single667 - (float)(this.height / 2);
                    if (this.position.Y > single667 + 1f)
                    {
                        this.velocity.Y = -1f;
                    }
                    else if (this.position.Y >= single667 - 1f)
                    {
                        this.velocity.Y = 0f;
                        this.position.Y = single667;
                    }
                    else
                    {
                        this.velocity.Y = 1f;
                    }
                    if (this.velocity.Y > 5f)
                    {
                        this.velocity.Y = 5f;
                    }
                    if (this.velocity.Y < -5f)
                    {
                        this.velocity.Y = -5f;
                    }
                    Vector2 y232 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float x234 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - y232.X;
                    float y233 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - y232.Y;
                    float single668 = (float)Math.Sqrt((double)(x234 * x234 + y233 * y233));
                    x234 = x234 * single668;
                    y233 = y233 * single668;
                    bool flag173 = true;
                    if (this.direction > 0)
                    {
                        if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) <= this.position.X + (float)(this.width / 2))
                        {
                            this.rotation = 0f;
                            flag173 = false;
                        }
                        else
                        {
                            this.rotation = (float)Math.Atan2((double)(-y233), (double)(-x234)) + 3.14f;
                        }
                    }
                    else if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) >= this.position.X + (float)(this.width / 2))
                    {
                        this.rotation = 0f;
                        flag173 = false;
                    }
                    else
                    {
                        this.rotation = (float)Math.Atan2((double)y233, (double)x234) + 3.14f;
                    }
                    if (Main.netMode != 1)
                    {
                        int num985 = 4;
                        this.localAI[1] = this.localAI[1] + 1f;
                        if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.75)
                        {
                            this.localAI[1] = this.localAI[1] + 1f;
                            num985++;
                        }
                        if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.5)
                        {
                            this.localAI[1] = this.localAI[1] + 1f;
                            num985++;
                        }
                        if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.25)
                        {
                            this.localAI[1] = this.localAI[1] + 1f;
                            num985 = num985 + 2;
                        }
                        if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.1)
                        {
                            this.localAI[1] = this.localAI[1] + 2f;
                            num985 = num985 + 3;
                        }
                        if (Main.expertMode)
                        {
                            this.localAI[1] = this.localAI[1] + 0.5f;
                            num985++;
                            if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.1)
                            {
                                this.localAI[1] = this.localAI[1] + 2f;
                                num985 = num985 + 3;
                            }
                        }
                        if (this.localAI[2] == 0f)
                        {
                            if (this.localAI[1] > 600f)
                            {
                                this.localAI[2] = 1f;
                                this.localAI[1] = 0f;
                                return;
                            }
                        }
                        else if (this.localAI[1] > 45f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            this.localAI[1] = 0f;
                            this.localAI[2] = this.localAI[2] + 1f;
                            if (this.localAI[2] >= (float)num985)
                            {
                                this.localAI[2] = 0f;
                            }
                            if (flag173)
                            {
                                float single669 = 9f;
                                int num986 = 11;
                                int num987 = 83;
                                if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.5)
                                {
                                    num986++;
                                    single669 = single669 + 1f;
                                }
                                if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.25)
                                {
                                    num986++;
                                    single669 = single669 + 1f;
                                }
                                if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.1)
                                {
                                    num986 = num986 + 2;
                                    single669 = single669 + 2f;
                                }
                                y232 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                x234 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - y232.X;
                                y233 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - y232.Y;
                                single668 = (float)Math.Sqrt((double)(x234 * x234 + y233 * y233));
                                single668 = single669 / single668;
                                x234 = x234 * single668;
                                y233 = y233 * single668;
                                y232.X = y232.X + x234;
                                y232.Y = y232.Y + y233;
                                Projectile.NewProjectile(y232.X, y232.Y, x234, y233, num987, num986, 0f, Main.myPlayer, 0f, 0f);
                                return;
                            }
                        }
                    }
                }
            }
            else
            {
                this.TargetClosest(true);
                float single670 = 12f;
                Vector2 vector2368 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float x235 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector2368.X;
                float y234 = Main.player[this.target].position.Y - vector2368.Y;
                float single671 = (float)Math.Sqrt((double)(x235 * x235 + y234 * y234));
                single671 = single670 / single671;
                x235 = x235 * single671;
                y234 = y234 * single671;
                bool flag174 = false;
                if (this.directionY < 0)
                {
                    this.rotation = (float)(Math.Atan2((double)y234, (double)x235) + 1.57);
                    flag174 = ((double)this.rotation < -1.2 || (double)this.rotation > 1.2 ? false : true);
                    if ((double)this.rotation < -0.8)
                    {
                        this.rotation = -0.8f;
                    }
                    else if ((double)this.rotation > 0.8)
                    {
                        this.rotation = 0.8f;
                    }
                    if (this.velocity.X != 0f)
                    {
                        this.velocity.X = this.velocity.X * 0.9f;
                        if ((double)this.velocity.X > -0.1 || (double)this.velocity.X < 0.1)
                        {
                            this.netUpdate = true;
                            this.velocity.X = 0f;
                        }
                    }
                }
                if (this.ai[0] > 0f)
                {
                    this.ai[0] = this.ai[0] - 1f;
                }
                if (Main.netMode != 1 && flag174 && this.ai[0] == 0f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                {
                    this.ai[0] = 200f;
                    int num988 = 10;
                    int num989 = 31;
                    int num990 = Projectile.NewProjectile(vector2368.X, vector2368.Y, x235, y234, num989, num988, 0f, Main.myPlayer, 0f, 0f);
                    Main.projectile[num990].ai[0] = 2f;
                    Main.projectile[num990].timeLeft = 300;
                    Main.projectile[num990].friendly = false;
                    NetMessage.SendData(27, -1, -1, "", num990, 0f, 0f, 0f, 0, 0, 0);
                    this.netUpdate = true;
                }
                try
                {
                    int x236 = (int)this.position.X / 16;
                    int x237 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                    int x238 = (int)(this.position.X + (float)this.width) / 16;
                    int y235 = (int)(this.position.Y + (float)this.height) / 16;
                    bool flag175 = false;
                    if (Main.tile[x236, y235] == null)
                    {
                        Main.tile[x236, y235] = new Tile();
                    }
                    if (Main.tile[x237, y235] == null)
                    {
                        Main.tile[x236, y235] = new Tile();
                    }
                    if (Main.tile[x238, y235] == null)
                    {
                        Main.tile[x236, y235] = new Tile();
                    }
                    if (Main.tile[x236, y235].nactive() && Main.tileSolid[Main.tile[x236, y235].type] || Main.tile[x237, y235].nactive() && Main.tileSolid[Main.tile[x237, y235].type] || Main.tile[x238, y235].nactive() && Main.tileSolid[Main.tile[x238, y235].type])
                    {
                        flag175 = true;
                    }
                    if (!flag175)
                    {
                        this.noGravity = false;
                        this.noTileCollide = false;
                    }
                    else
                    {
                        this.noGravity = true;
                        this.noTileCollide = true;
                        this.velocity.Y = -0.2f;
                    }
                }
                catch (Exception ex)
                {
            #if DEBUG
                    Console.WriteLine(ex);
                    System.Diagnostics.Debugger.Break();

            #endif
                }
            }
        }
示例#58
0
文件: Door.cs 项目: garytm/TOLD
        public void DoorDamage()
        {
            int randomNumber = random.Next(1500);

            if (randomNumber <= 1)
            {
                Damage();
            }
            Vector2 Distance  = m_player.Hitbox.Location.ToVector2() - m_position;
            Vector2 Direction = Vector2.Normalize(Distance);

            if (m_player.woodPiles > 0 && m_player.nails > 0 && Hitbox.Contains(Input.WorldMousePosition) && Input.isMouseJustReleased() && Distance.Length() < 450)
            {
                if (m_state == states.Damaged || (m_state == states.Repaired && CurrentState != RepairedTextures.Count - 1))
                {
                    repairSound.Play();
                    m_player.woodPiles--;
                    m_player.nails--;
                    OnRepair();
                }
            }
        }
示例#59
0
        public void AI()
        {
            if (this.aiStyle == 0)
            {
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active && Main.player[i].talkNPC == this.whoAmI)
                    {
                        if (this.type == NPCID.BoundGoblin)
                        {
                            this.Transform(107);
                            return;
                        }
                        if (this.type == NPCID.BoundWizard)
                        {
                            this.Transform(108);
                            return;
                        }
                        if (this.type == NPCID.BoundMechanic)
                        {
                            this.Transform(124);
                            return;
                        }
                        if (this.type == NPCID.WebbedStylist)
                        {
                            this.Transform(353);
                            return;
                        }
                        if (this.type == NPCID.SleepingAngler)
                        {
                            this.Transform(369);
                            return;
                        }
                    }
                }
                if (this.type != NPCID.SleepingAngler)
                {
                    this.TargetClosest(true);
                    this.spriteDirection = this.direction;
                }
                if (this.type == NPCID.SleepingAngler)
                {
                    if (this.wet || Main.tile[(int)(base.Center.X / 16f), (int)(this.position.Y - 4f) / 16].liquid > 0)
                    {
                        this.velocity.Y = -0.4f;
                        int num = 1;
                        if (base.Center.X / 16f > (float)(Main.maxTilesX / 2))
                        {
                            num = -1;
                        }
                        int num2 = 12;
                        int num3 = (int)base.Center.X / 16;
                        int j = (int)base.Center.Y / 16;
                        bool flag = false;
                        if (num > 0)
                        {
                            for (int k = num3; k < num3 + num2; k++)
                            {
                                if (WorldGen.SolidTile(k, j))
                                {
                                    flag = true;
                                }
                            }
                        }
                        else
                        {
                            for (int l = num3; l > num3 - num2; l--)
                            {
                                if (WorldGen.SolidTile(l, j))
                                {
                                    flag = true;
                                }
                            }
                        }
                        if (flag)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                            if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                            {
                                this.velocity.X = 0f;
                                return;
                            }
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X + (float)num * 0.01f;
                            if (this.velocity.X > 0.2f)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.velocity.X < -0.2f)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                                return;
                            }
                        }
                    }
                    else
                    {
                        this.velocity.X = this.velocity.X * 0.93f;
                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                        {
                            this.velocity.X = 0f;
                            return;
                        }
                    }
                }
                else
                {
                    this.velocity.X = this.velocity.X * 0.93f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                        return;
                    }
                }
            }
            else if (this.aiStyle == 1)
            {
                if (this.type == NPCID.BlueSlime && (this.ai[1] == 1f || this.ai[1] == 2f || this.ai[1] == 3f))
                {
                    this.ai[1] = -1f;
                }
                if (this.type == NPCID.BlueSlime && this.ai[1] == 0f && Main.netMode != 1 && this.value > 0f)
                {
                    this.ai[1] = -1f;
                    if (Main.rand.Next(20) == 0)
                    {
                        int num4 = Main.rand.Next(4);
                        if (num4 == 0)
                        {
                            num4 = Main.rand.Next(7);
                            if (num4 == 0)
                            {
                                num4 = 290;
                            }
                            else if (num4 == 1)
                            {
                                num4 = 292;
                            }
                            else if (num4 == 2)
                            {
                                num4 = 296;
                            }
                            else if (num4 == 3)
                            {
                                num4 = 2322;
                            }
                            else if (Main.netMode != 0 && Main.rand.Next(2) == 0)
                            {
                                num4 = 2997;
                            }
                            else
                            {
                                num4 = 2350;
                            }
                        }
                        else if (num4 == 1)
                        {
                            num4 = Main.rand.Next(4);
                            if (num4 == 0)
                            {
                                num4 = 8;
                            }
                            else if (num4 == 1)
                            {
                                num4 = 166;
                            }
                            else if (num4 == 2)
                            {
                                num4 = 965;
                            }
                            else
                            {
                                num4 = 58;
                            }
                        }
                        else if (num4 == 2)
                        {
                            if (Main.rand.Next(2) == 0)
                            {
                                num4 = Main.rand.Next(11, 15);
                            }
                            else
                            {
                                num4 = Main.rand.Next(699, 703);
                            }
                        }
                        else
                        {
                            num4 = Main.rand.Next(3);
                            if (num4 == 0)
                            {
                                num4 = 71;
                            }
                            else if (num4 == 1)
                            {
                                num4 = 72;
                            }
                            else
                            {
                                num4 = 73;
                            }
                        }
                        this.ai[1] = (float)num4;
                        this.netUpdate = true;
                    }
                }
                if (this.type == NPCID.RainbowSlime)
                {
                    float num5 = (float)Main.DiscoR / 255f;
                    float num6 = (float)Main.DiscoG / 255f;
                    float num7 = (float)Main.DiscoB / 255f;
                    num5 *= 1f;
                    num6 *= 1f;
                    num7 *= 1f;
                    this.color.R = (byte)Main.DiscoR;
                    this.color.G = (byte)Main.DiscoG;
                    this.color.B = (byte)Main.DiscoB;
                    this.color.A = 100;
                    this.alpha = 175;
                }
                bool flag2 = false;
                if (!Main.dayTime || this.life != this.lifeMax || (double)this.position.Y > Main.worldSurface * 16.0 || Main.slimeRain)
                {
                    flag2 = true;
                }
                if (this.type == NPCID.CorruptSlime)
                {
                    flag2 = true;
                }
                if ((this.type == NPCID.Grasshopper || this.type == NPCID.GoldGrasshopper) && this.target != 255 && !Main.player[this.target].dead && Vector2.Distance(base.Center, Main.player[this.target].Center) <= 200f)
                {
                    flag2 = true;
                }
                if (this.type == NPCID.Crimslime)
                {
                    flag2 = true;
                }
                if (this.type == NPCID.HoppinJack)
                {
                    flag2 = true;
                }
                if (this.type == NPCID.IceSlime && Main.rand.Next(10) == 0)
                {
                }
                if (this.type == NPCID.RainbowSlime)
                {
                    flag2 = true;
                    this.ai[0] += 2f;
                }
                if (this.type == NPCID.SpikedIceSlime)
                {
                    flag2 = true;
                    if (this.localAI[0] > 0f)
                    {
                        this.localAI[0] -= 1f;
                    }
                    if (!this.wet && !Main.player[this.target].npcTypeNoAggro[this.type])
                    {
                        Vector2 vector = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num11 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector.X;
                        float num12 = Main.player[this.target].position.Y - vector.Y;
                        float num13 = (float)Math.Sqrt((double)(num11 * num11 + num12 * num12));
                        if (Main.expertMode && num13 < 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                for (int m = 0; m < 5; m++)
                                {
                                    Vector2 vector2 = new Vector2((float)(m - 2), -4f);
                                    vector2.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
                                    vector2.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
                                    vector2.Normalize();
                                    vector2 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f;
                                    Projectile.NewProjectile(vector.X, vector.Y, vector2.X, vector2.Y, 174, 9, 0f, Main.myPlayer, 0f, 0f);
                                    this.localAI[0] = 30f;
                                }
                            }
                        }
                        else if (num13 < 200f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                num12 = Main.player[this.target].position.Y - vector.Y - (float)Main.rand.Next(0, 200);
                                num13 = (float)Math.Sqrt((double)(num11 * num11 + num12 * num12));
                                num13 = 4.5f / num13;
                                num11 *= num13;
                                num12 *= num13;
                                this.localAI[0] = 50f;
                                Projectile.NewProjectile(vector.X, vector.Y, num11, num12, 174, 9, 0f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                if (this.type == NPCID.SlimeSpiked)
                {
                    flag2 = true;
                    if (this.localAI[0] > 0f)
                    {
                        this.localAI[0] -= 1f;
                    }
                    if (!this.wet && !Main.player[this.target].npcTypeNoAggro[this.type])
                    {
                        Vector2 vector3 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num14 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector3.X;
                        float num15 = Main.player[this.target].position.Y - vector3.Y;
                        float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15));
                        if (Main.expertMode && num16 < 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                for (int n = 0; n < 5; n++)
                                {
                                    Vector2 vector4 = new Vector2((float)(n - 2), -4f);
                                    vector4.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
                                    vector4.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.005f;
                                    vector4.Normalize();
                                    vector4 *= 4f + (float)Main.rand.Next(-50, 51) * 0.01f;
                                    Projectile.NewProjectile(vector3.X, vector3.Y, vector4.X, vector4.Y, 605, 9, 0f, Main.myPlayer, 0f, 0f);
                                    this.localAI[0] = 30f;
                                }
                            }
                        }
                        else if (num16 < 200f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                num15 = Main.player[this.target].position.Y - vector3.Y - (float)Main.rand.Next(0, 200);
                                num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15));
                                num16 = 4.5f / num16;
                                num14 *= num16;
                                num15 *= num16;
                                this.localAI[0] = 50f;
                                Projectile.NewProjectile(vector3.X, vector3.Y, num14, num15, 605, 9, 0f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                if (this.type == NPCID.SpikedJungleSlime)
                {
                    flag2 = true;
                    if (this.localAI[0] > 0f)
                    {
                        this.localAI[0] -= 1f;
                    }
                    if (!this.wet && !Main.player[this.target].npcTypeNoAggro[this.type])
                    {
                        Vector2 vector5 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num17 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector5.X;
                        float num18 = Main.player[this.target].position.Y - vector5.Y;
                        float num19 = (float)Math.Sqrt((double)(num17 * num17 + num18 * num18));
                        if (Main.expertMode && num19 < 200f && Collision.CanHit(new Vector2(this.position.X, this.position.Y - 20f), this.width, this.height + 20, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -40f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                for (int num20 = 0; num20 < 5; num20++)
                                {
                                    Vector2 vector6 = new Vector2((float)(num20 - 2), -2f);
                                    vector6.X *= 1f + (float)Main.rand.Next(-50, 51) * 0.02f;
                                    vector6.Y *= 1f + (float)Main.rand.Next(-50, 51) * 0.02f;
                                    vector6.Normalize();
                                    vector6 *= 3f + (float)Main.rand.Next(-50, 51) * 0.01f;
                                    Projectile.NewProjectile(vector5.X, vector5.Y, vector6.X, vector6.Y, 176, 13, 0f, Main.myPlayer, 0f, 0f);
                                    this.localAI[0] = 80f;
                                }
                            }
                        }
                        if (num19 < 400f && Collision.CanHit(new Vector2(this.position.X, this.position.Y - 20f), this.width, this.height + 20, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && this.velocity.Y == 0f)
                        {
                            this.ai[0] = -80f;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                num18 = Main.player[this.target].position.Y - vector5.Y - (float)Main.rand.Next(-30, 20);
                                num18 -= num19 * 0.05f;
                                num17 = Main.player[this.target].position.X - vector5.X - (float)Main.rand.Next(-20, 20);
                                num19 = (float)Math.Sqrt((double)(num17 * num17 + num18 * num18));
                                num19 = 7f / num19;
                                num17 *= num19;
                                num18 *= num19;
                                this.localAI[0] = 65f;
                                Projectile.NewProjectile(vector5.X, vector5.Y, num17, num18, 176, 13, 0f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                if (this.type == NPCID.Grasshopper || this.type == NPCID.GoldGrasshopper)
                {
                    if (this.localAI[2] < 90f)
                    {
                        this.localAI[2] += 1f;
                    }
                    else
                    {
                        this.friendly = false;
                    }
                }
                if (this.type == NPCID.LavaSlime)
                {
                }
                if (this.ai[2] > 1f)
                {
                    this.ai[2] -= 1f;
                }
                if (this.wet)
                {
                    if (this.collideY)
                    {
                        this.velocity.Y = -2f;
                    }
                    if (this.velocity.Y < 0f && this.ai[3] == this.position.X)
                    {
                        this.direction *= -1;
                        this.ai[2] = 200f;
                    }
                    if (this.velocity.Y > 0f)
                    {
                        this.ai[3] = this.position.X;
                    }
                    if (this.type == NPCID.LavaSlime)
                    {
                        if (this.velocity.Y > 2f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.9f;
                        }
                        else if (this.directionY < 0)
                        {
                            this.velocity.Y = this.velocity.Y - 0.8f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -10f)
                        {
                            this.velocity.Y = -10f;
                        }
                    }
                    else
                    {
                        if (this.velocity.Y > 2f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.9f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                    }
                    if (this.ai[2] == 1f && flag2)
                    {
                        this.TargetClosest(true);
                    }
                }
                this.aiAction = 0;
                if (this.ai[2] == 0f)
                {
                    this.ai[0] = -100f;
                    this.ai[2] = 1f;
                    this.TargetClosest(true);
                }
                if (this.velocity.Y == 0f)
                {
                    if (this.ai[3] == this.position.X)
                    {
                        this.direction *= -1;
                        this.ai[2] = 200f;
                    }
                    this.ai[3] = 0f;
                    this.velocity.X = this.velocity.X * 0.8f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                    }
                    if (flag2)
                    {
                        this.ai[0] += 1f;
                    }
                    this.ai[0] += 1f;
                    if (this.type == NPCID.LavaSlime)
                    {
                        this.ai[0] += 2f;
                    }
                    if (this.type == NPCID.DungeonSlime)
                    {
                        this.ai[0] += 3f;
                    }
                    if (this.type == NPCID.IlluminantSlime)
                    {
                        this.ai[0] += 2f;
                    }
                    if (this.type == NPCID.Crimslime)
                    {
                        this.ai[0] += 1f;
                    }
                    if (this.type == NPCID.HoppinJack)
                    {
                        float num22 = (float)((1 - this.life / this.lifeMax) * 10);
                        this.ai[0] += num22;
                    }
                    if (this.type == NPCID.Grasshopper || this.type == NPCID.GoldGrasshopper)
                    {
                        this.ai[0] += 3f;
                    }
                    if (this.type == NPCID.CorruptSlime)
                    {
                        if (this.scale >= 0f)
                        {
                            this.ai[0] += 4f;
                        }
                        else
                        {
                            this.ai[0] += 1f;
                        }
                    }
                    int num23 = 0;
                    if (this.ai[0] >= 0f)
                    {
                        num23 = 1;
                    }
                    if (this.ai[0] >= -1000f && this.ai[0] <= -500f)
                    {
                        num23 = 2;
                    }
                    if (this.ai[0] >= -2000f && this.ai[0] <= -1500f)
                    {
                        num23 = 3;
                    }
                    if (num23 > 0)
                    {
                        this.netUpdate = true;
                        if (flag2 && this.ai[2] == 1f)
                        {
                            this.TargetClosest(true);
                        }
                        if (num23 == 3)
                        {
                            this.velocity.Y = -8f;
                            if (this.type == NPCID.LavaSlime)
                            {
                                this.velocity.Y = this.velocity.Y - 2f;
                            }
                            this.velocity.X = this.velocity.X + (float)(3 * this.direction);
                            if (this.type == NPCID.LavaSlime)
                            {
                                this.velocity.X = this.velocity.X + 0.5f * (float)this.direction;
                            }
                            this.ai[0] = -200f;
                            this.ai[3] = this.position.X;
                        }
                        else
                        {
                            this.velocity.Y = -6f;
                            this.velocity.X = this.velocity.X + (float)(2 * this.direction);
                            if (this.type == NPCID.LavaSlime)
                            {
                                this.velocity.X = this.velocity.X + (float)(2 * this.direction);
                            }
                            this.ai[0] = -120f;
                            if (num23 == 1)
                            {
                                this.ai[0] -= 1000f;
                            }
                            else
                            {
                                this.ai[0] -= 2000f;
                            }
                        }
                        if (this.type == NPCID.ToxicSludge)
                        {
                            this.velocity.Y = this.velocity.Y * 1.3f;
                            this.velocity.X = this.velocity.X * 1.2f;
                        }
                        if (this.type == NPCID.Grasshopper || this.type == NPCID.GoldGrasshopper)
                        {
                            this.velocity.Y = this.velocity.Y * 0.9f;
                            this.velocity.X = this.velocity.X * 0.6f;
                            if (flag2)
                            {
                                this.direction = -this.direction;
                                this.velocity.X = this.velocity.X * -1f;
                                return;
                            }
                        }
                    }
                    else if (this.ai[0] >= -30f)
                    {
                        this.aiAction = 1;
                        return;
                    }
                }
                else if (this.target < 255 && ((this.direction == 1 && this.velocity.X < 3f) || (this.direction == -1 && this.velocity.X > -3f)))
                {
                    if ((this.direction == -1 && (double)this.velocity.X < 0.1) || (this.direction == 1 && (double)this.velocity.X > -0.1))
                    {
                        this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                        return;
                    }
                    this.velocity.X = this.velocity.X * 0.93f;
                    return;
                }
            }
            else if (this.aiStyle == 2)
            {
                if ((this.type == NPCID.PigronCorruption || this.type == NPCID.PigronHallow || this.type == NPCID.PigronCrimson) && Main.rand.Next(1000) == 0)
                {
                }
                this.noGravity = true;
                if (!this.noTileCollide)
                {
                    if (this.collideX)
                    {
                        this.velocity.X = this.oldVelocity.X * -0.5f;
                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                        {
                            this.velocity.X = 2f;
                        }
                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                    if (this.collideY)
                    {
                        this.velocity.Y = this.oldVelocity.Y * -0.5f;
                        if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                        {
                            this.velocity.Y = 1f;
                        }
                        if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                        {
                            this.velocity.Y = -1f;
                        }
                    }
                }
                if (Main.dayTime && (double)this.position.Y <= Main.worldSurface * 16.0 && (this.type == NPCID.DemonEye || this.type == NPCID.WanderingEye || this.type == NPCID.CataractEye || this.type == NPCID.SleepyEye || this.type == NPCID.DialatedEye || this.type == NPCID.GreenEye || this.type == NPCID.PurpleEye || this.type == NPCID.DemonEyeOwl || this.type == NPCID.DemonEyeSpaceship))
                {
                    if (this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                    this.directionY = -1;
                    if (this.velocity.Y > 0f)
                    {
                        this.direction = 1;
                    }
                    this.direction = -1;
                    if (this.velocity.X > 0f)
                    {
                        this.direction = 1;
                    }
                }
                else
                {
                    this.TargetClosest(true);
                }
                if (this.type == NPCID.PigronCorruption || this.type == NPCID.PigronHallow || this.type == NPCID.PigronCrimson)
                {
                    if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        if (this.ai[1] > 0f && !Collision.SolidCollision(this.position, this.width, this.height))
                        {
                            this.ai[1] = 0f;
                            this.ai[0] = 0f;
                            this.netUpdate = true;
                        }
                    }
                    else if (this.ai[1] == 0f)
                    {
                        this.ai[0] += 1f;
                    }
                    if (this.ai[0] >= 300f)
                    {
                        this.ai[1] = 1f;
                        this.ai[0] = 0f;
                        this.netUpdate = true;
                    }
                    if (this.ai[1] == 0f)
                    {
                        this.alpha = 0;
                        this.noTileCollide = false;
                    }
                    else
                    {
                        this.wet = false;
                        this.alpha = 200;
                        this.noTileCollide = true;
                    }
                    this.rotation = this.velocity.Y * 0.1f * (float)this.direction;
                    this.TargetClosest(true);
                    if (this.direction == -1 && this.velocity.X > -4f && this.position.X > Main.player[this.target].position.X + (float)Main.player[this.target].width)
                    {
                        this.velocity.X = this.velocity.X - 0.08f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.04f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.2f;
                        }
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 4f && this.position.X + (float)this.width < Main.player[this.target].position.X)
                    {
                        this.velocity.X = this.velocity.X + 0.08f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.04f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.2f;
                        }
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -2.5 && this.position.Y > Main.player[this.target].position.Y + (float)Main.player[this.target].height)
                    {
                        this.velocity.Y = this.velocity.Y - 0.1f;
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.15f;
                        }
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = -2.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 2.5 && this.position.Y + (float)this.height < Main.player[this.target].position.Y)
                    {
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.15f;
                        }
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = 2.5f;
                        }
                    }
                }
                else if (this.type == NPCID.TheHungryII)
                {
                    this.TargetClosest(true);
                    if (this.direction == -1 && this.velocity.X > -6f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.2f;
                        }
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = -6f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 6f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.2f;
                        }
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = 6f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -2.5)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.15f;
                        }
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = -2.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.15f;
                        }
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = 2.5f;
                        }
                    }
                }
                else if (this.type == NPCID.WanderingEye)
                {
                    if ((double)this.life < (double)this.lifeMax * 0.5)
                    {
                        if (this.direction == -1 && this.velocity.X > -6f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.05f;
                            }
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = -6f;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < 6f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.05f;
                            }
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = 6f;
                            }
                        }
                        if (this.directionY == -1 && this.velocity.Y > -4f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.1f;
                            if (this.velocity.Y > 4f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.1f;
                            }
                            else if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.05f;
                            }
                            if (this.velocity.Y < -4f)
                            {
                                this.velocity.Y = -4f;
                            }
                        }
                        else if (this.directionY == 1 && this.velocity.Y < 4f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.1f;
                            if (this.velocity.Y < -4f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.1f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.05f;
                            }
                            if (this.velocity.Y > 4f)
                            {
                                this.velocity.Y = 4f;
                            }
                        }
                    }
                    else
                    {
                        if (this.direction == -1 && this.velocity.X > -4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.05f;
                            }
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = -4f;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < 4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.05f;
                            }
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = 4f;
                            }
                        }
                        if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = this.velocity.Y - 0.05f;
                            }
                            else if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = -1.5f;
                            }
                        }
                        else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = this.velocity.Y + 0.05f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = 1.5f;
                            }
                        }
                    }
                }
                else
                {
                    float num25 = 4f;
                    float num26 = 1.5f;
                    num25 *= 1f + (1f - this.scale);
                    num26 *= 1f + (1f - this.scale);
                    if (this.direction == -1 && this.velocity.X > -num25)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > num25)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -num25)
                        {
                            this.velocity.X = -num25;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < num25)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -num25)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > num25)
                        {
                            this.velocity.X = num25;
                        }
                    }
                    if (this.directionY == -1 && this.velocity.Y > -num26)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if (this.velocity.Y > num26)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if (this.velocity.Y < -num26)
                        {
                            this.velocity.Y = -num26;
                        }
                    }
                    else if (this.directionY == 1 && this.velocity.Y < num26)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if (this.velocity.Y < -num26)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if (this.velocity.Y > num26)
                        {
                            this.velocity.Y = num26;
                        }
                    }
                }
                if ((this.type == NPCID.DemonEye || this.type == NPCID.WanderingEye || this.type == NPCID.CataractEye || this.type == NPCID.SleepyEye || this.type == NPCID.DialatedEye || this.type == NPCID.GreenEye || this.type == NPCID.PurpleEye) && Main.rand.Next(40) == 0)
                {
                }
                if (this.wet && this.type != NPCID.PigronCorruption && this.type != NPCID.PigronHallow && this.type != NPCID.RuneWizard)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.5f;
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                    this.TargetClosest(true);
                    return;
                }
            }
            else if (this.aiStyle == 3)
            {
                if (this.type == NPCID.Psycho)
                {
                    int num28 = 200;
                    if (this.ai[2] == 0f)
                    {
                        this.alpha = num28;
                        this.TargetClosest(true);
                        if (!Main.player[this.target].dead && (Main.player[this.target].Center - base.Center).Length() < 170f)
                        {
                            this.ai[2] = -16f;
                        }
                        if (this.velocity.X != 0f || this.velocity.Y < 0f || this.velocity.Y > 2f || this.justHit)
                        {
                            this.ai[2] = -16f;
                        }
                        return;
                    }
                    if (this.ai[2] < 0f)
                    {
                        if (this.alpha > 0)
                        {
                            this.alpha -= num28 / 16;
                            if (this.alpha < 0)
                            {
                                this.alpha = 0;
                            }
                        }
                        this.ai[2] += 1f;
                        if (this.ai[2] == 0f)
                        {
                            this.ai[2] = 1f;
                            this.velocity.X = (float)(this.direction * 2);
                        }
                        return;
                    }
                    this.alpha = 0;
                }
                if (this.type == NPCID.SwampThing)
                {
                    if (Main.netMode != 1 && Main.rand.Next(240) == 0)
                    {
                        this.ai[2] = (float)Main.rand.Next(-480, -60);
                        this.netUpdate = true;
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.TargetClosest(true);
                        if (this.justHit)
                        {
                            this.ai[2] = 0f;
                        }
                        if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[2] = 0f;
                        }
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.velocity.X = this.velocity.X * 0.9f;
                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                        {
                            this.velocity.X = 0f;
                        }
                        this.ai[2] += 1f;
                        if (this.ai[2] == 0f)
                        {
                            this.velocity.X = (float)this.direction * 0.1f;
                        }
                        return;
                    }
                }
                if (this.type == NPCID.CreatureFromTheDeep)
                {
                    if (this.wet)
                    {
                        this.knockBackResist = 0f;
                        this.ai[3] = -0.10101f;
                        this.noGravity = true;
                        Vector2 center = base.Center;
                        this.width = 34;
                        this.height = 24;
                        this.position.X = center.X - (float)(this.width / 2);
                        this.position.Y = center.Y - (float)(this.height / 2);
                        this.TargetClosest(true);
                        if (this.collideX)
                        {
                            this.velocity.X = -this.oldVelocity.X;
                        }
                        if (this.velocity.X < 0f)
                        {
                            this.direction = -1;
                        }
                        if (this.velocity.X > 0f)
                        {
                            this.direction = 1;
                        }
                        if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].Center, 1, 1))
                        {
                            Vector2 value = Main.player[this.target].Center - base.Center;
                            value.Normalize();
                            value *= 5f;
                            this.velocity = (this.velocity * 19f + value) / 20f;
                            return;
                        }
                        float num29 = 5f;
                        if (this.velocity.Y > 0f)
                        {
                            num29 = 3f;
                        }
                        if (this.velocity.Y < 0f)
                        {
                            num29 = 8f;
                        }
                        Vector2 value2 = new Vector2((float)this.direction, -1f);
                        value2.Normalize();
                        value2 *= num29;
                        if (num29 < 5f)
                        {
                            this.velocity = (this.velocity * 24f + value2) / 25f;
                            return;
                        }
                        this.velocity = (this.velocity * 9f + value2) / 10f;
                        return;
                    }
                    else
                    {
                        this.knockBackResist = 0.4f * Main.knockBackMultiplier;
                        this.noGravity = false;
                        Vector2 center2 = base.Center;
                        this.width = 18;
                        this.height = 40;
                        this.position.X = center2.X - (float)(this.width / 2);
                        this.position.Y = center2.Y - (float)(this.height / 2);
                        if (this.ai[3] == -0.10101f)
                        {
                            this.ai[3] = 0f;
                            float num30 = this.velocity.Length();
                            num30 *= 2f;
                            if (num30 > 10f)
                            {
                                num30 = 10f;
                            }
                            this.velocity.Normalize();
                            this.velocity *= num30;
                            if (this.velocity.X < 0f)
                            {
                                this.direction = -1;
                            }
                            if (this.velocity.X > 0f)
                            {
                                this.direction = 1;
                            }
                            this.spriteDirection = this.direction;
                        }
                    }
                }
                if (this.type == NPCID.CultistArcherBlue || this.type == NPCID.CultistArcherWhite)
                {
                    if (this.ai[3] < 0f)
                    {
                        this.damage = 0;
                        this.velocity.X = this.velocity.X * 0.93f;
                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                        {
                            this.velocity.X = 0f;
                        }
                        int num31 = (int)(-this.ai[3] - 1f);
                        int num32 = Math.Sign(Main.npc[num31].Center.X - base.Center.X);
                        if (num32 != this.direction)
                        {
                            this.velocity.X = 0f;
                            this.direction = num32;
                            this.netUpdate = true;
                        }
                        if (this.justHit && Main.netMode != 1 && Main.npc[num31].localAI[0] == 0f)
                        {
                            Main.npc[num31].localAI[0] = 1f;
                        }
                        if (this.ai[0] < 1000f)
                        {
                            this.ai[0] = 1000f;
                        }
                        if ((this.ai[0] += 1f) >= 1300f)
                        {
                            this.ai[0] = 1000f;
                            this.netUpdate = true;
                        }
                        return;
                    }
                    if (this.ai[0] >= 1000f)
                    {
                        this.ai[0] = 0f;
                    }
                    this.damage = this.defDamage;
                }
                if (this.type == NPCID.MartianOfficer && this.ai[2] == 0f && this.localAI[0] == 0f && Main.netMode != 1)
                {
                    int num33 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 384, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                    this.ai[2] = (float)(num33 + 1);
                    this.localAI[0] = -1f;
                    this.netUpdate = true;
                    Main.npc[num33].ai[0] = (float)this.whoAmI;
                    Main.npc[num33].netUpdate = true;
                }
                if (this.type == NPCID.MartianOfficer)
                {
                    int num34 = (int)this.ai[2] - 1;
                    if (num34 != -1 && Main.npc[num34].active && Main.npc[num34].type == NPCID.ForceBubble)
                    {
                        this.dontTakeDamage = true;
                    }
                    else
                    {
                        this.dontTakeDamage = false;
                        this.ai[2] = 0f;
                        if (this.localAI[0] == -1f)
                        {
                            this.localAI[0] = 180f;
                        }
                        if (this.localAI[0] > 0f)
                        {
                            this.localAI[0] -= 1f;
                        }
                    }
                }
                if (this.type == NPCID.GraniteGolem)
                {
                    int num35 = 300;
                    int num36 = 120;
                    this.dontTakeDamage = false;
                    if (this.ai[2] < 0f)
                    {
                        this.dontTakeDamage = true;
                        this.ai[2] += 1f;
                        this.velocity.X = this.velocity.X * 0.9f;
                        if ((double)Math.Abs(this.velocity.X) < 0.001)
                        {
                            this.velocity.X = 0.001f * (float)this.direction;
                        }
                        if (Math.Abs(this.velocity.Y) > 1f)
                        {
                            this.ai[2] += 10f;
                        }
                        if (this.ai[2] >= 0f)
                        {
                            this.netUpdate = true;
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.3f;
                        }
                        return;
                    }
                    if (this.ai[2] < (float)num35)
                    {
                        if (this.justHit)
                        {
                            this.ai[2] += 15f;
                        }
                        this.ai[2] += 1f;
                    }
                    else if (this.velocity.Y == 0f)
                    {
                        this.ai[2] = (float)(-(float)num36);
                        this.netUpdate = true;
                    }
                }
                if (this.type == NPCID.Medusa)
                {
                    int num37 = 180;
                    int num38 = 300;
                    int num39 = 180;
                    int num40 = 60;
                    int num41 = 20;
                    if (this.life < this.lifeMax / 3)
                    {
                        num37 = 120;
                        num38 = 240;
                        num39 = 240;
                        num40 = 90;
                    }
                    if (this.ai[2] > 0f)
                    {
                        this.ai[2] -= 1f;
                    }
                    else if (this.ai[2] == 0f)
                    {
                        if (((Main.player[this.target].Center.X < base.Center.X && this.direction < 0) || (Main.player[this.target].Center.X > base.Center.X && this.direction > 0)) && this.velocity.Y == 0f && base.Distance(Main.player[this.target].Center) < 900f && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[2] = (float)(-(float)num39 - num41);
                            this.netUpdate = true;
                        }
                    }
                    else
                    {
                        if (this.ai[2] < 0f && this.ai[2] < (float)(-(float)num39))
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                            if (this.velocity.Y < -2f || this.velocity.Y > 4f || this.justHit)
                            {
                                this.ai[2] = (float)num37;
                            }
                            else
                            {
                                this.ai[2] += 1f;
                                if (this.ai[2] == 0f)
                                {
                                    this.ai[2] = (float)num38;
                                }
                            }
                            float num42 = this.ai[2] + (float)num39 + (float)num41;
                            if (num42 == 1f)
                            {
                            }
                            if (num42 < (float)num41)
                            {
                            }
                            return;
                        }
                        if (this.ai[2] < 0f && this.ai[2] >= (float)(-(float)num39))
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                            if (this.velocity.Y < -2f || this.velocity.Y > 4f || this.justHit)
                            {
                                this.ai[2] = (float)num37;
                            }
                            else
                            {
                                this.ai[2] += 1f;
                                if (this.ai[2] == 0f)
                                {
                                    this.ai[2] = (float)num38;
                                }
                            }
                            float num44 = this.ai[2] + (float)num39;
                            if (num44 < 180f && (Main.rand.Next(3) == 0 || this.ai[2] % 3f == 0f))
                            {
                            }
                            if (Main.netMode != 2)
                            {
                                Player player = Main.player[Main.myPlayer];
                                int arg_44C1_0 = Main.myPlayer;
                                if (!player.dead && player.active && player.HasBuff(BuffID.Stoned) == -1 && (player.Center - base.Center).Length() < 700f && ((player.Center.X < base.Center.X && this.direction < 0 && player.direction > 0) || (player.Center.X > base.Center.X && this.direction > 0 && player.direction < 0)))
                                {
                                    bool flag3 = Collision.CanHitLine(base.Center, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(base.Center - Vector2.UnitY * 16f, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(base.Center + Vector2.UnitY * 8f, 1, 1, player.Center, 1, 1);
                                    if (flag3)
                                    {
                                        player.AddBuff(BuffID.Stoned, num40 + (int)this.ai[2] * -1, true);
                                    }
                                }
                            }
                            return;
                        }
                    }
                }
                if (this.type == NPCID.GoblinSummoner)
                {
                    if (this.ai[3] < 0f)
                    {
                        this.knockBackResist = 0f;
                        this.defense = (int)((double)this.defDefense * 1.1);
                        this.noGravity = true;
                        this.noTileCollide = true;
                        if (this.velocity.X < 0f)
                        {
                            this.direction = -1;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.direction = 1;
                        }
                        this.rotation = this.velocity.X * 0.1f;
                        if (Main.netMode != 1)
                        {
                            this.localAI[3] += 1f;
                            if (this.localAI[3] > (float)Main.rand.Next(20, 180))
                            {
                                this.localAI[3] = 0f;
                                Vector2 value3 = base.Center;
                                value3 += this.velocity;
                                NPC.NewNPC((int)value3.X, (int)value3.Y, 30, 0, 0f, 0f, 0f, 0f, 255);
                            }
                        }
                    }
                    else
                    {
                        this.localAI[3] = 0f;
                        this.knockBackResist = 0.35f * Main.knockBackMultiplier;
                        this.rotation *= 0.9f;
                        this.defense = this.defDefense;
                        this.noGravity = false;
                        this.noTileCollide = false;
                    }
                    if (this.ai[3] == 1f)
                    {
                        this.knockBackResist = 0f;
                        this.defense += 10;
                    }
                    if (this.ai[3] == -1f)
                    {
                        this.TargetClosest(true);
                        float num46 = 8f;
                        float num47 = 40f;
                        Vector2 value4 = Main.player[this.target].Center - base.Center;
                        float num48 = value4.Length();
                        num46 += num48 / 200f;
                        value4.Normalize();
                        value4 *= num46;
                        this.velocity = (this.velocity * (num47 - 1f) + value4) / num47;
                        if (num48 < 500f && !Collision.SolidCollision(this.position, this.width, this.height))
                        {
                            this.ai[3] = 0f;
                            this.ai[2] = 0f;
                        }
                        return;
                    }
                    if (this.ai[3] == -2f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.2f;
                        if (this.velocity.Y < -10f)
                        {
                            this.velocity.Y = -10f;
                        }
                        if (Main.player[this.target].Center.Y - base.Center.Y > 200f)
                        {
                            this.TargetClosest(true);
                            this.ai[3] = -3f;
                            if (Main.player[this.target].Center.X > base.Center.X)
                            {
                                this.ai[2] = 1f;
                            }
                            else
                            {
                                this.ai[2] = -1f;
                            }
                        }
                        this.velocity.X = this.velocity.X * 0.99f;
                        return;
                    }
                    if (this.ai[3] == -3f)
                    {
                        if (this.direction == 0)
                        {
                            this.TargetClosest(true);
                        }
                        if (this.ai[2] == 0f)
                        {
                            this.ai[2] = (float)this.direction;
                        }
                        this.velocity.Y = this.velocity.Y * 0.9f;
                        this.velocity.X = this.velocity.X + this.ai[2] * 0.3f;
                        if (this.velocity.X > 10f)
                        {
                            this.velocity.X = 10f;
                        }
                        if (this.velocity.X < -10f)
                        {
                            this.velocity.X = -10f;
                        }
                        float num49 = Main.player[this.target].Center.X - base.Center.X;
                        if ((this.ai[2] < 0f && num49 > 300f) || (this.ai[2] > 0f && num49 < -300f))
                        {
                            this.ai[3] = -4f;
                            this.ai[2] = 0f;
                            return;
                        }
                        if (Math.Abs(num49) > 800f)
                        {
                            this.ai[3] = -1f;
                            this.ai[2] = 0f;
                        }
                        return;
                    }
                    else
                    {
                        if (this.ai[3] == -4f)
                        {
                            this.ai[2] += 1f;
                            this.velocity.Y = this.velocity.Y + 0.1f;
                            if (this.velocity.Length() > 4f)
                            {
                                this.velocity *= 0.9f;
                            }
                            int num50 = (int)base.Center.X / 16;
                            int num51 = (int)(this.position.Y + (float)this.height + 12f) / 16;
                            bool flag4 = false;
                            for (int num52 = num50 - 1; num52 <= num50 + 1; num52++)
                            {
                                if (Main.tile[num52, num51] == null)
                                {
                                    Main.tile[num50, num51] = new Tile();
                                }
                                if (Main.tile[num52, num51].active() && Main.tileSolid[(int)Main.tile[num52, num51].type])
                                {
                                    flag4 = true;
                                }
                            }
                            if (flag4 && !Collision.SolidCollision(this.position, this.width, this.height))
                            {
                                this.ai[3] = 0f;
                                this.ai[2] = 0f;
                            }
                            else if (this.ai[2] > 300f || base.Center.Y > Main.player[this.target].Center.Y + 200f)
                            {
                                this.ai[3] = -1f;
                                this.ai[2] = 0f;
                            }
                        }
                        else
                        {
                            if (this.ai[3] == 1f)
                            {
                                Vector2 center3 = base.Center;
                                center3.Y -= 70f;
                                this.velocity.X = this.velocity.X * 0.8f;
                                this.ai[2] += 1f;
                                if (this.ai[2] == 60f)
                                {
                                    if (Main.netMode != 1)
                                    {
                                        NPC.NewNPC((int)center3.X, (int)center3.Y + 18, 472, 0, 0f, 0f, 0f, 0f, 255);
                                    }
                                }
                                else if (this.ai[2] >= 90f)
                                {
                                    this.ai[3] = -2f;
                                    this.ai[2] = 0f;
                                }
                                return;
                            }
                            this.ai[2] += 1f;
                            int num55 = 10;
                            if (this.velocity.Y == 0f && NPC.CountNPCS(472) < num55)
                            {
                                if (this.ai[2] >= 180f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[3] = 1f;
                                }
                            }
                            else
                            {
                                if (NPC.CountNPCS(472) >= num55)
                                {
                                    this.ai[2] += 1f;
                                }
                                if (this.ai[2] >= 360f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[3] = -2f;
                                    this.velocity.Y = this.velocity.Y - 3f;
                                }
                            }
                            if (this.target >= 0 && !Main.player[this.target].dead && (Main.player[this.target].Center - base.Center).Length() > 800f)
                            {
                                this.ai[3] = -1f;
                                this.ai[2] = 0f;
                            }
                        }
                        if (Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                            if (Main.player[this.target].dead && this.timeLeft > 1)
                            {
                                this.timeLeft = 1;
                            }
                        }
                    }
                }
                if (this.type == NPCID.SolarSolenian)
                {
                    this.reflectingProjectiles = false;
                    this.takenDamageMultiplier = 1f;
                    int num56 = 6;
                    int num57 = 10;
                    float scaleFactor3 = 16f;
                    if (this.ai[2] > 0f)
                    {
                        this.ai[2] -= 1f;
                    }
                    if (this.ai[2] == 0f)
                    {
                        if (((Main.player[this.target].Center.X < base.Center.X && this.direction < 0) || (Main.player[this.target].Center.X > base.Center.X && this.direction > 0)) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[2] = -1f;
                            this.netUpdate = true;
                            this.TargetClosest(true);
                        }
                    }
                    else
                    {
                        if (this.ai[2] < 0f && this.ai[2] > (float)(-(float)num56))
                        {
                            this.ai[2] -= 1f;
                            this.velocity.X = this.velocity.X * 0.9f;
                            return;
                        }
                        if (this.ai[2] == (float)(-(float)num56))
                        {
                            this.ai[2] -= 1f;
                            this.TargetClosest(true);
                            Vector2 vec = base.DirectionTo(Main.player[this.target].Top + new Vector2(0f, -30f));
                            if (vec.HasNaNs())
                            {
                                vec = Vector2.Normalize(new Vector2((float)this.spriteDirection, -1f));
                            }
                            this.velocity = vec * scaleFactor3;
                            this.netUpdate = true;
                            return;
                        }
                        if (this.ai[2] < (float)(-(float)num56))
                        {
                            this.ai[2] -= 1f;
                            if (this.velocity.Y == 0f)
                            {
                                this.ai[2] = 60f;
                            }
                            else if (this.ai[2] < (float)(-(float)num56 - num57))
                            {
                                this.velocity.Y = this.velocity.Y + 0.15f;
                                if (this.velocity.Y > 24f)
                                {
                                    this.velocity.Y = 24f;
                                }
                            }
                            this.reflectingProjectiles = true;
                            this.takenDamageMultiplier = 3f;
                            if (this.justHit)
                            {
                                this.ai[2] = 60f;
                                this.netUpdate = true;
                            }
                            return;
                        }
                    }
                }
                if (this.type == NPCID.SolarDrakomire)
                {
                    int num58 = 42;
                    int num59 = 18;
                    if (this.justHit)
                    {
                        this.ai[2] = 120f;
                        this.netUpdate = true;
                    }
                    if (this.ai[2] > 0f)
                    {
                        this.ai[2] -= 1f;
                    }
                    if (this.ai[2] == 0f)
                    {
                        int num60 = 0;
                        for (int num61 = 0; num61 < 200; num61++)
                        {
                            if (Main.npc[num61].active && Main.npc[num61].type == NPCID.SolarFlare)
                            {
                                num60++;
                            }
                        }
                        if (num60 > 6)
                        {
                            this.ai[2] = 90f;
                        }
                        else if (((Main.player[this.target].Center.X < base.Center.X && this.direction < 0) || (Main.player[this.target].Center.X > base.Center.X && this.direction > 0)) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[2] = -1f;
                            this.netUpdate = true;
                            this.TargetClosest(true);
                        }
                    }
                    else if (this.ai[2] < 0f && this.ai[2] > (float)(-(float)num58))
                    {
                        this.ai[2] -= 1f;
                        if (this.ai[2] == (float)(-(float)num58))
                        {
                            this.ai[2] = (float)(180 + 30 * Main.rand.Next(10));
                        }
                        this.velocity.X = this.velocity.X * 0.8f;
                        if (this.ai[2] == (float)(-(float)num59) || this.ai[2] == (float)(-(float)num59 - 8) || this.ai[2] == (float)(-(float)num59 - 16))
                        {
                            if (this.velocity.X > -0.5f && this.velocity.X < 0.5f)
                            {
                                this.velocity.X = 0f;
                            }
                            if (Main.netMode != 1)
                            {
                                NPC.NewNPC((int)base.Center.X + this.spriteDirection * 45, (int)base.Center.Y + 8, 516, 0, 0f, 0f, 0f, 0f, this.target);
                            }
                        }
                        return;
                    }
                }
                if (this.type == NPCID.VortexLarva)
                {
                    this.localAI[0] += 1f;
                    if (this.localAI[0] >= 300f)
                    {
                        int num63 = (int)base.Center.X / 16 - 1;
                        int num64 = (int)base.Center.Y / 16 - 1;
                        if (!Collision.SolidTiles(num63, num63 + 2, num64, num64 + 1) && Main.netMode != 1)
                        {
                            this.Transform(427);
                            this.life = this.lifeMax;
                            this.localAI[0] = 0f;
                            return;
                        }
                    }
                }
                if (this.type == NPCID.VortexHornet)
                {
                    this.localAI[0] += 1f;
                    this.localAI[0] += Math.Abs(this.velocity.X) / 2f;
                    if (this.localAI[0] >= 1200f && Main.netMode != 1)
                    {
                        int num65 = (int)base.Center.X / 16 - 2;
                        int num66 = (int)base.Center.Y / 16 - 3;
                        if (!Collision.SolidTiles(num65, num65 + 4, num66, num66 + 4))
                        {
                            this.Transform(426);
                            this.life = this.lifeMax;
                            this.localAI[0] = 0f;
                            return;
                        }
                    }
                }
                bool flag5 = false;
                if (this.velocity.X == 0f)
                {
                    flag5 = true;
                }
                if (this.justHit)
                {
                    flag5 = false;
                }
                if (Main.netMode != 1 && this.type == NPCID.Lihzahrd && (double)this.life <= (double)this.lifeMax * 0.55)
                {
                    this.Transform(199);
                }
                if (Main.netMode != 1 && this.type == NPCID.Nutcracker && (double)this.life <= (double)this.lifeMax * 0.55)
                {
                    this.Transform(349);
                }
                int num67 = 60;
                if (this.type == NPCID.ChaosElemental)
                {
                    num67 = 180;
                    if (this.ai[3] == -120f)
                    {
                        this.velocity *= 0f;
                        this.ai[3] = 0f;
                        Vector2 vector14 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num68 = this.oldPos[2].X + (float)this.width * 0.5f - vector14.X;
                        float num69 = this.oldPos[2].Y + (float)this.height * 0.5f - vector14.Y;
                        float num70 = (float)Math.Sqrt((double)(num68 * num68 + num69 * num69));
                        num70 = 2f / num70;
                        num68 *= num70;
                        num69 *= num70;
                    }
                }
                bool flag6 = false;
                bool flag7 = true;
                if (this.type == NPCID.Yeti || this.type == NPCID.CorruptBunny || this.type == NPCID.Crab || this.type == NPCID.Clown || this.type == NPCID.SkeletonArcher || this.type == NPCID.GoblinArcher || this.type == NPCID.ChaosElemental || this.type == NPCID.BlackRecluse || this.type == NPCID.WallCreeper || this.type == NPCID.BloodCrawler || this.type == NPCID.CorruptPenguin || this.type == NPCID.LihzahrdCrawler || this.type == NPCID.IcyMerman || this.type == NPCID.PirateDeadeye || this.type == NPCID.PirateCrossbower || this.type == NPCID.PirateCaptain || this.type == NPCID.CochinealBeetle || this.type == NPCID.CyanBeetle || this.type == NPCID.LacBeetle || this.type == NPCID.SeaSnail || this.type == NPCID.FlyingSnake || this.type == NPCID.IceGolem || this.type == NPCID.Eyezor || this.type == NPCID.AnomuraFungus || this.type == NPCID.MushiLadybug || this.type == NPCID.Paladin || this.type == NPCID.SkeletonSniper || this.type == NPCID.TacticalSkeleton || this.type == NPCID.SkeletonCommando || this.type == NPCID.Scarecrow1 || this.type == NPCID.Scarecrow2 || this.type == NPCID.Scarecrow3 || this.type == NPCID.Scarecrow4 || this.type == NPCID.Scarecrow5 || this.type == NPCID.Nutcracker || this.type == NPCID.NutcrackerSpinning || this.type == NPCID.ElfArcher || this.type == NPCID.Krampus || this.type == NPCID.CultistArcherBlue || (this.type >= NPCID.ArmedZombie && this.type <= NPCID.ArmedZombieCenx) || (this.type == NPCID.CultistArcherWhite || this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner || this.type == NPCID.MartianOfficer || this.type == NPCID.MartianEngineer || this.type == NPCID.Scutlix || (this.type >= NPCID.BoneThrowingSkeleton && this.type <= NPCID.BoneThrowingSkeleton4)) || (this.type == NPCID.Psycho || this.type == NPCID.CrimsonBunny || this.type == NPCID.SwampThing || this.type == NPCID.ThePossessed || this.type == NPCID.DrManFly || this.type == NPCID.GoblinSummoner || this.type == NPCID.CrimsonPenguin || this.type == NPCID.Medusa || this.type == NPCID.GreekSkeleton || this.type == NPCID.GraniteGolem || this.type == NPCID.StardustSoldier || this.type == NPCID.NebulaSoldier || this.type == NPCID.StardustSpiderBig || (this.type >= NPCID.Crawdad && this.type <= NPCID.Salamander9)) || (this.type == NPCID.VortexRifleman || this.type == NPCID.VortexHornet || this.type == NPCID.VortexHornetQueen || this.type == NPCID.VortexLarva || this.type == NPCID.WalkingAntlion || this.type == NPCID.SolarDrakomire || this.type == NPCID.SolarSolenian || this.type == NPCID.MartianWalker || (this.type >= NPCID.DesertGhoul && this.type <= NPCID.DesertGhoulHallow)) || this.type == NPCID.DesertLamiaLight || this.type == NPCID.DesertLamiaDark || this.type == NPCID.DesertScorpionWalk || this.type == NPCID.DesertBeast)
                {
                    flag7 = false;
                }
                bool flag8 = false;
                int num75 = this.type;
                if (num75 == 425 || num75 == 471)
                {
                    flag8 = true;
                }
                bool flag9 = true;
                num75 = this.type;
                if (num75 <= 350)
                {
                    if (num75 <= 206)
                    {
                        switch (num75)
                        {
                            case 110:
                            case 111:
                                break;
                            default:
                                if (num75 != 206)
                                {
                                    goto IL_62C5;
                                }
                                break;
                        }
                    }
                    else
                    {
                        switch (num75)
                        {
                            case 214:
                            case 215:
                            case 216:
                                break;
                            default:
                                switch (num75)
                                {
                                    case 291:
                                    case 292:
                                    case 293:
                                        break;
                                    default:
                                        if (num75 != 350)
                                        {
                                            goto IL_62C5;
                                        }
                                        break;
                                }
                                break;
                        }
                    }
                }
                else if (num75 <= 426)
                {
                    switch (num75)
                    {
                        case 379:
                        case 380:
                        case 381:
                        case 382:
                            break;
                        default:
                            switch (num75)
                            {
                                case 409:
                                case 411:
                                    break;
                                case 410:
                                    goto IL_62C5;
                                default:
                                    switch (num75)
                                    {
                                        case 424:
                                        case 426:
                                            break;
                                        case 425:
                                            goto IL_62C5;
                                        default:
                                            goto IL_62C5;
                                    }
                                    break;
                            }
                            break;
                    }
                }
                else if (num75 != 466)
                {
                    switch (num75)
                    {
                        case 498:
                        case 499:
                        case 500:
                        case 501:
                        case 502:
                        case 503:
                        case 504:
                        case 505:
                        case 506:
                            break;
                        default:
                            if (num75 != 520)
                            {
                                goto IL_62C5;
                            }
                            break;
                    }
                }
                if (this.ai[2] > 0f)
                {
                    flag9 = false;
                }
            IL_62C5:
                if (!flag8 && flag9)
                {
                    if (this.velocity.Y == 0f && ((this.velocity.X > 0f && this.direction < 0) || (this.velocity.X < 0f && this.direction > 0)))
                    {
                        flag6 = true;
                    }
                    if (this.position.X == this.oldPosition.X || this.ai[3] >= (float)num67 || flag6)
                    {
                        this.ai[3] += 1f;
                    }
                    else if ((double)Math.Abs(this.velocity.X) > 0.9 && this.ai[3] > 0f)
                    {
                        this.ai[3] -= 1f;
                    }
                    if (this.ai[3] > (float)(num67 * 10))
                    {
                        this.ai[3] = 0f;
                    }
                    if (this.justHit)
                    {
                        this.ai[3] = 0f;
                    }
                    if (this.ai[3] == (float)num67)
                    {
                        this.netUpdate = true;
                    }
                }
                if (this.type == NPCID.Nailhead && Main.netMode != 1)
                {
                    if (this.localAI[3] > 0f)
                    {
                        this.localAI[3] -= 1f;
                    }
                    if (this.justHit && this.localAI[3] <= 0f && Main.rand.Next(3) == 0)
                    {
                        this.localAI[3] = 30f;
                        int num76 = Main.rand.Next(3, 6);
                        int[] array = new int[num76];
                        int num77 = 0;
                        for (int num78 = 0; num78 < 255; num78++)
                        {
                            if (Main.player[num78].active && !Main.player[num78].dead && Collision.CanHitLine(this.position, this.width, this.height, Main.player[num78].position, Main.player[num78].width, Main.player[num78].height))
                            {
                                array[num77] = num78;
                                num77++;
                                if (num77 == num76)
                                {
                                    break;
                                }
                            }
                        }
                        if (num77 > 1)
                        {
                            for (int num79 = 0; num79 < 100; num79++)
                            {
                                int num80 = Main.rand.Next(num77);
                                int num81;
                                for (num81 = num80; num81 == num80; num81 = Main.rand.Next(num77))
                                {
                                }
                                int num82 = array[num80];
                                array[num80] = array[num81];
                                array[num81] = num82;
                            }
                        }
                        Vector2 vector15 = new Vector2(-1f, -1f);
                        for (int num83 = 0; num83 < num77; num83++)
                        {
                            Vector2 value6 = Main.npc[array[num83]].Center - base.Center;
                            value6.Normalize();
                            vector15 += value6;
                        }
                        vector15.Normalize();
                        for (int num84 = 0; num84 < num76; num84++)
                        {
                            float scaleFactor4 = (float)Main.rand.Next(8, 13);
                            Vector2 value7 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
                            value7.Normalize();
                            if (num77 > 0)
                            {
                                value7 += vector15;
                                value7.Normalize();
                            }
                            value7 *= scaleFactor4;
                            if (num77 > 0)
                            {
                                num77--;
                                value7 = Main.player[array[num77]].Center - base.Center;
                                value7.Normalize();
                                value7 *= scaleFactor4;
                            }
                            Projectile.NewProjectile(base.Center.X, this.position.Y + (float)(this.width / 4), value7.X, value7.Y, 498, (int)((double)this.damage * 0.15), 1f, 255, 0f, 0f);
                        }
                    }
                }
                if (this.type == NPCID.Butcher)
                {
                    if (this.velocity.Y < -NPC.gravity || this.velocity.Y > NPC.gravity)
                    {
                        this.knockBackResist = 0f;
                    }
                    else
                    {
                        this.knockBackResist = 0.25f * Main.knockBackMultiplier;
                    }
                }
                if (this.type == NPCID.ThePossessed)
                {
                    this.knockBackResist = 0.45f * Main.knockBackMultiplier;
                    if (this.ai[2] == 1f)
                    {
                        this.knockBackResist = 0f;
                    }
                    bool flag10 = false;
                    int num85 = (int)base.Center.X / 16;
                    int num86 = (int)base.Center.Y / 16;
                    for (int num87 = num85 - 1; num87 <= num85 + 1; num87++)
                    {
                        for (int num88 = num86 - 1; num88 <= num86 + 1; num88++)
                        {
                            if (Main.tile[num87, num88] != null && Main.tile[num87, num88].wall > 0)
                            {
                                flag10 = true;
                                break;
                            }
                        }
                        if (flag10)
                        {
                            break;
                        }
                    }
                    if (this.ai[2] == 0f && flag10)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.Y = -4.6f;
                            this.velocity.X = this.velocity.X * 1.3f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.ai[2] = 1f;
                        }
                    }
                    if (flag10 && this.ai[2] == 1f && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                    {
                        Vector2 value8 = Main.player[this.target].Center - base.Center;
                        float num89 = value8.Length();
                        value8.Normalize();
                        value8 *= 4.5f + num89 / 300f;
                        this.velocity = (this.velocity * 29f + value8) / 30f;
                        this.noGravity = true;
                        this.ai[2] = 1f;
                        return;
                    }
                    this.noGravity = false;
                    this.ai[2] = 0f;
                }
                if (this.type == NPCID.Fritz && this.velocity.Y == 0f && (Main.player[this.target].Center - base.Center).Length() < 150f && Math.Abs(this.velocity.X) > 3f && ((this.velocity.X < 0f && base.Center.X > Main.player[this.target].Center.X) || (this.velocity.X > 0f && base.Center.X < Main.player[this.target].Center.X)))
                {
                    this.velocity.X = this.velocity.X * 1.75f;
                    this.velocity.Y = this.velocity.Y - 4.5f;
                    if (base.Center.Y - Main.player[this.target].Center.Y > 20f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.5f;
                    }
                    if (base.Center.Y - Main.player[this.target].Center.Y > 40f)
                    {
                        this.velocity.Y = this.velocity.Y - 1f;
                    }
                    if (base.Center.Y - Main.player[this.target].Center.Y > 80f)
                    {
                        this.velocity.Y = this.velocity.Y - 1.5f;
                    }
                    if (base.Center.Y - Main.player[this.target].Center.Y > 100f)
                    {
                        this.velocity.Y = this.velocity.Y - 1.5f;
                    }
                    if (Math.Abs(this.velocity.X) > 7f)
                    {
                        if (this.velocity.X < 0f)
                        {
                            this.velocity.X = -7f;
                        }
                        else
                        {
                            this.velocity.X = 7f;
                        }
                    }
                }
                if (this.ai[3] < (float)num67 && (Main.eclipse || !Main.dayTime || (double)this.position.Y > Main.worldSurface * 16.0 || (Main.invasionType == 1 && (this.type == NPCID.Yeti || this.type == NPCID.ElfArcher)) || (Main.invasionType == 1 && (this.type == NPCID.GoblinPeon || this.type == NPCID.GoblinThief || this.type == NPCID.GoblinWarrior || this.type == NPCID.GoblinArcher || this.type == NPCID.GoblinSummoner)) || (this.type == NPCID.GoblinScout || (Main.invasionType == 3 && this.type >= NPCID.PirateDeckhand && this.type <= NPCID.PirateCaptain)) || (Main.invasionType == 4 && (this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner || this.type == NPCID.MartianOfficer || this.type == NPCID.GrayGrunt || this.type == NPCID.MartianEngineer || this.type == NPCID.GigaZapper || this.type == NPCID.Scutlix || this.type == NPCID.MartianWalker)) || (this.type == NPCID.AngryBones || this.type == NPCID.AngryBonesBig || this.type == NPCID.AngryBonesBigMuscle || this.type == NPCID.AngryBonesBigHelmet || this.type == NPCID.CorruptBunny || this.type == NPCID.Crab || this.type == NPCID.ArmoredSkeleton || this.type == NPCID.Mummy || this.type == NPCID.DarkMummy || this.type == NPCID.LightMummy || this.type == NPCID.SkeletonArcher || this.type == NPCID.ChaosElemental || this.type == NPCID.CorruptPenguin || this.type == NPCID.FaceMonster || this.type == NPCID.SnowFlinx || this.type == NPCID.Lihzahrd || this.type == NPCID.LihzahrdCrawler || this.type == NPCID.IcyMerman || this.type == NPCID.CochinealBeetle || this.type == NPCID.CyanBeetle || this.type == NPCID.LacBeetle || this.type == NPCID.SeaSnail || this.type == NPCID.BloodCrawler || this.type == NPCID.IceGolem || this.type == NPCID.ZombieMushroom || this.type == NPCID.ZombieMushroomHat || this.type == NPCID.AnomuraFungus || this.type == NPCID.MushiLadybug || this.type == NPCID.SkeletonSniper || this.type == NPCID.TacticalSkeleton || this.type == NPCID.SkeletonCommando || this.type == NPCID.CultistArcherBlue || this.type == NPCID.CultistArcherWhite || this.type == NPCID.CrimsonBunny || this.type == NPCID.CrimsonPenguin || this.type == NPCID.NebulaSoldier || (this.type == NPCID.StardustSoldier && (this.ai[1] >= 180f || this.ai[1] < 90f))) || (this.type == NPCID.StardustSpiderBig || this.type == NPCID.VortexRifleman || this.type == NPCID.VortexSoldier || this.type == NPCID.VortexHornet || this.type == NPCID.VortexLarva || this.type == NPCID.WalkingAntlion || this.type == NPCID.SolarDrakomire || this.type == NPCID.SolarSolenian || (this.type >= NPCID.DesertGhoul && this.type <= NPCID.DesertGhoulHallow)) || this.type == NPCID.DesertLamiaLight || this.type == NPCID.DesertLamiaDark || this.type == NPCID.DesertScorpionWalk || this.type == NPCID.DesertBeast))
                {
                    if ((this.type == NPCID.Zombie || this.type == NPCID.ZombieXmas || this.type == NPCID.ZombieSweater || this.type == NPCID.Skeleton || (this.type >= NPCID.BoneThrowingSkeleton && this.type <= NPCID.BoneThrowingSkeleton4) || this.type == NPCID.AngryBones || this.type == NPCID.AngryBonesBig || this.type == NPCID.AngryBonesBigMuscle || this.type == NPCID.AngryBonesBigHelmet || this.type == NPCID.ArmoredSkeleton || this.type == NPCID.SkeletonArcher || this.type == NPCID.BaldZombie || this.type == NPCID.UndeadViking || this.type == NPCID.ZombieEskimo || this.type == NPCID.Frankenstein || this.type == NPCID.PincushionZombie || this.type == NPCID.SlimedZombie || this.type == NPCID.SwampZombie || this.type == NPCID.TwiggyZombie || this.type == NPCID.ArmoredViking || this.type == NPCID.FemaleZombie || this.type == NPCID.HeadacheSkeleton || this.type == NPCID.MisassembledSkeleton || this.type == NPCID.PantlessSkeleton || this.type == NPCID.ZombieRaincoat || this.type == NPCID.SkeletonSniper || this.type == NPCID.TacticalSkeleton || this.type == NPCID.SkeletonCommando || this.type == NPCID.ZombieSuperman || this.type == NPCID.ZombiePixie || this.type == NPCID.ZombieDoctor || this.type == NPCID.GreekSkeleton) && Main.rand.Next(1000) == 0)
                    {
                    }
                    if (this.type == NPCID.BloodZombie && Main.rand.Next(800) == 0)
                    {
                    }
                    if ((this.type == NPCID.Mummy || this.type == NPCID.DarkMummy || this.type == NPCID.LightMummy) && Main.rand.Next(500) == 0)
                    {
                    }
                    if (this.type == NPCID.Vampire && Main.rand.Next(500) == 0)
                    {
                    }
                    if (this.type == NPCID.Frankenstein && Main.rand.Next(500) == 0)
                    {
                    }
                    if (this.type == NPCID.FaceMonster && Main.rand.Next(500) == 0)
                    {
                    }
                    if (this.type >= NPCID.RustyArmoredBonesAxe && this.type <= NPCID.HellArmoredBonesSword && Main.rand.Next(1000) == 0)
                    {
                    }
                    this.TargetClosest(true);
                }
                else if (this.ai[2] <= 0f || (this.type != NPCID.SkeletonArcher && this.type != NPCID.GoblinArcher && this.type != NPCID.IcyMerman && this.type != NPCID.PirateCaptain && this.type != NPCID.PirateDeadeye && this.type != NPCID.PirateCrossbower && this.type != NPCID.SkeletonSniper && this.type != NPCID.TacticalSkeleton && this.type != NPCID.SkeletonCommando && this.type != NPCID.ElfArcher && this.type != NPCID.BrainScrambler && this.type != NPCID.RayGunner && this.type != NPCID.MartianOfficer && this.type != NPCID.GrayGrunt && this.type != NPCID.MartianEngineer && this.type != NPCID.GigaZapper && this.type != NPCID.Scutlix && this.type != NPCID.ThePossessed && this.type != NPCID.SwampThing && this.type != NPCID.Psycho && this.type != NPCID.GoblinSummoner && this.type != NPCID.StardustSoldier && this.type != NPCID.StardustSpiderBig && this.type != NPCID.NebulaSoldier && this.type != NPCID.VortexRifleman && this.type != NPCID.VortexHornetQueen && this.type != NPCID.SolarDrakomire && this.type != NPCID.SolarSolenian && this.type != NPCID.MartianWalker))
                {
                    if (Main.dayTime && (double)(this.position.Y / 16f) < Main.worldSurface && this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                    if (this.velocity.X == 0f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.ai[0] += 1f;
                            if (this.ai[0] >= 2f)
                            {
                                this.direction *= -1;
                                this.spriteDirection = this.direction;
                                this.ai[0] = 0f;
                            }
                        }
                    }
                    else
                    {
                        this.ai[0] = 0f;
                    }
                    if (this.direction == 0)
                    {
                        this.direction = 1;
                    }
                }
                if (this.type == NPCID.Vampire || this.type == NPCID.NutcrackerSpinning)
                {
                    if (this.type == NPCID.Vampire && ((this.velocity.X > 0f && this.direction < 0) || (this.velocity.X < 0f && this.direction > 0)))
                    {
                        this.velocity.X = this.velocity.X * 0.95f;
                    }
                    if (this.velocity.X < -6f || this.velocity.X > 6f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < 6f && this.direction == 1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = 6f;
                        }
                    }
                    else if (this.velocity.X > -6f && this.direction == -1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = -6f;
                        }
                    }
                }
                else if (this.type == NPCID.LihzahrdCrawler)
                {
                    if (this.velocity.X < -4f || this.velocity.X > 4f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < 4f && this.direction == 1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.8f;
                        }
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    else if (this.velocity.X > -4f && this.direction == -1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.8f;
                        }
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                }
                else if (this.type == NPCID.ChaosElemental || this.type == NPCID.SwampThing || this.type == NPCID.PirateCorsair || this.type == NPCID.MushiLadybug || this.type == NPCID.DesertLamiaLight || this.type == NPCID.DesertLamiaDark)
                {
                    if (this.velocity.X < -3f || this.velocity.X > 3f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < 3f && this.direction == 1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > 3f)
                        {
                            this.velocity.X = 3f;
                        }
                    }
                    else if (this.velocity.X > -3f && this.direction == -1)
                    {
                        if (this.velocity.Y == 0f && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.99f;
                        }
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -3f)
                        {
                            this.velocity.X = -3f;
                        }
                    }
                }
                else if (this.type == NPCID.CreatureFromTheDeep || this.type == NPCID.GoblinThief || this.type == NPCID.ArmoredSkeleton || this.type == NPCID.Werewolf || this.type == NPCID.BlackRecluse || this.type == NPCID.Frankenstein || this.type == NPCID.Nymph || this.type == NPCID.ArmoredViking || this.type == NPCID.PirateDeckhand || this.type == NPCID.AnomuraFungus || this.type == NPCID.Splinterling || this.type == NPCID.Yeti || this.type == NPCID.Nutcracker || this.type == NPCID.Krampus || (this.type >= NPCID.DesertGhoul && this.type <= NPCID.DesertGhoulHallow) || this.type == NPCID.DesertScorpionWalk)
                {
                    if (this.velocity.X < -2f || this.velocity.X > 2f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < 2f && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > 2f)
                        {
                            this.velocity.X = 2f;
                        }
                    }
                    else if (this.velocity.X > -2f && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                }
                else if (this.type == NPCID.Clown)
                {
                    if (this.velocity.X < -2f || this.velocity.X > 2f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < 2f && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.04f;
                        if (this.velocity.X > 2f)
                        {
                            this.velocity.X = 2f;
                        }
                    }
                    else if (this.velocity.X > -2f && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.04f;
                        if (this.velocity.X < -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                }
                else if (this.type == NPCID.Skeleton || this.type == NPCID.GoblinPeon || this.type == NPCID.AngryBones || this.type == NPCID.AngryBonesBig || this.type == NPCID.AngryBonesBigMuscle || this.type == NPCID.AngryBonesBigHelmet || this.type == NPCID.CorruptBunny || this.type == NPCID.GoblinScout || this.type == NPCID.PossessedArmor || this.type == NPCID.WallCreeper || this.type == NPCID.BloodCrawler || this.type == NPCID.UndeadViking || this.type == NPCID.CorruptPenguin || this.type == NPCID.SnowFlinx || this.type == NPCID.Lihzahrd || this.type == NPCID.HeadacheSkeleton || this.type == NPCID.MisassembledSkeleton || this.type == NPCID.PantlessSkeleton || this.type == NPCID.CochinealBeetle || this.type == NPCID.CyanBeetle || this.type == NPCID.LacBeetle || this.type == NPCID.FlyingSnake || this.type == NPCID.FaceMonster || this.type == NPCID.ZombieMushroom || this.type == NPCID.ZombieElf || this.type == NPCID.ZombieElfBeard || this.type == NPCID.ZombieElfGirl || this.type == NPCID.GingerbreadMan || this.type == NPCID.GrayGrunt || this.type == NPCID.GigaZapper || this.type == NPCID.Fritz || this.type == NPCID.Nailhead || this.type == NPCID.Psycho || this.type == NPCID.CrimsonBunny || this.type == NPCID.ThePossessed || this.type == NPCID.CrimsonPenguin || this.type == NPCID.Medusa || this.type == NPCID.GraniteGolem || this.type == NPCID.VortexRifleman || this.type == NPCID.VortexSoldier)
                {
                    float num90 = 1.5f;
                    if (this.type == NPCID.AngryBonesBig)
                    {
                        num90 = 2f;
                    }
                    else if (this.type == NPCID.AngryBonesBigMuscle)
                    {
                        num90 = 1.75f;
                    }
                    else if (this.type == NPCID.AngryBonesBigHelmet)
                    {
                        num90 = 1.25f;
                    }
                    else if (this.type == NPCID.HeadacheSkeleton)
                    {
                        num90 = 1.1f;
                    }
                    else if (this.type == NPCID.MisassembledSkeleton)
                    {
                        num90 = 0.9f;
                    }
                    else if (this.type == NPCID.PantlessSkeleton)
                    {
                        num90 = 1.2f;
                    }
                    else if (this.type == NPCID.ZombieElf)
                    {
                        num90 = 1.75f;
                    }
                    else if (this.type == NPCID.ZombieElfBeard)
                    {
                        num90 = 1.25f;
                    }
                    else if (this.type == NPCID.ZombieElfGirl)
                    {
                        num90 = 2f;
                    }
                    else if (this.type == NPCID.GrayGrunt)
                    {
                        num90 = 1.8f;
                    }
                    else if (this.type == NPCID.GigaZapper)
                    {
                        num90 = 2.25f;
                    }
                    else if (this.type == NPCID.Fritz)
                    {
                        num90 = 4f;
                    }
                    else if (this.type == NPCID.Nailhead)
                    {
                        num90 = 0.75f;
                    }
                    else if (this.type == NPCID.Psycho)
                    {
                        num90 = 3.75f;
                    }
                    else if (this.type == NPCID.ThePossessed)
                    {
                        num90 = 3.25f;
                    }
                    else if (this.type == NPCID.Medusa)
                    {
                        num90 = 1.5f + (1f - (float)this.life / (float)this.lifeMax) * 2f;
                    }
                    else if (this.type == NPCID.VortexRifleman)
                    {
                        num90 = 6f;
                    }
                    else if (this.type == NPCID.VortexSoldier)
                    {
                        num90 = 4f;
                    }
                    if (this.type == NPCID.Skeleton || this.type == NPCID.HeadacheSkeleton || this.type == NPCID.MisassembledSkeleton || this.type == NPCID.PantlessSkeleton || this.type == NPCID.GingerbreadMan)
                    {
                        num90 *= 1f + (1f - this.scale);
                    }
                    if (this.velocity.X < -num90 || this.velocity.X > num90)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < num90 && this.direction == 1)
                    {
                        if (this.type == NPCID.Psycho && this.velocity.X < -2f)
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                        }
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > num90)
                        {
                            this.velocity.X = num90;
                        }
                    }
                    else if (this.velocity.X > -num90 && this.direction == -1)
                    {
                        if (this.type == NPCID.Psycho && this.velocity.X > 2f)
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                        }
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -num90)
                        {
                            this.velocity.X = -num90;
                        }
                    }
                    if (this.velocity.Y == 0f && this.type == NPCID.Fritz && ((this.direction > 0 && this.velocity.X < 0f) || (this.direction < 0 && this.velocity.X > 0f)))
                    {
                        this.velocity.X = this.velocity.X * 0.9f;
                    }
                }
                else if (this.type >= NPCID.RustyArmoredBonesAxe && this.type <= NPCID.HellArmoredBonesSword)
                {
                    float num91 = 1.5f;
                    if (this.type == NPCID.RustyArmoredBonesAxe)
                    {
                        num91 = 2f;
                    }
                    if (this.type == NPCID.RustyArmoredBonesFlail)
                    {
                        num91 = 1f;
                    }
                    if (this.type == NPCID.RustyArmoredBonesSword)
                    {
                        num91 = 1.5f;
                    }
                    if (this.type == NPCID.RustyArmoredBonesSwordNoArmor)
                    {
                        num91 = 3f;
                    }
                    if (this.type == NPCID.BlueArmoredBones)
                    {
                        num91 = 1.25f;
                    }
                    if (this.type == NPCID.BlueArmoredBonesMace)
                    {
                        num91 = 3f;
                    }
                    if (this.type == NPCID.BlueArmoredBonesNoPants)
                    {
                        num91 = 3.25f;
                    }
                    if (this.type == NPCID.BlueArmoredBonesSword)
                    {
                        num91 = 2f;
                    }
                    if (this.type == NPCID.HellArmoredBones)
                    {
                        num91 = 2.75f;
                    }
                    if (this.type == NPCID.HellArmoredBonesSpikeShield)
                    {
                        num91 = 1.8f;
                    }
                    if (this.type == NPCID.HellArmoredBonesMace)
                    {
                        num91 = 1.3f;
                    }
                    if (this.type == NPCID.HellArmoredBonesSword)
                    {
                        num91 = 2.5f;
                    }
                    num91 *= 1f + (1f - this.scale);
                    if (this.velocity.X < -num91 || this.velocity.X > num91)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < num91 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > num91)
                        {
                            this.velocity.X = num91;
                        }
                    }
                    else if (this.velocity.X > -num91 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -num91)
                        {
                            this.velocity.X = -num91;
                        }
                    }
                }
                else if (this.type >= NPCID.Scarecrow1 && this.type <= NPCID.Scarecrow10)
                {
                    float num92 = 1.5f;
                    if (this.type == NPCID.Scarecrow1 || this.type == NPCID.Scarecrow6)
                    {
                        num92 = 2f;
                    }
                    if (this.type == NPCID.Scarecrow2 || this.type == NPCID.Scarecrow7)
                    {
                        num92 = 1.25f;
                    }
                    if (this.type == NPCID.Scarecrow3 || this.type == NPCID.Scarecrow8)
                    {
                        num92 = 2.25f;
                    }
                    if (this.type == NPCID.Scarecrow4 || this.type == NPCID.Scarecrow9)
                    {
                        num92 = 1.5f;
                    }
                    if (this.type == NPCID.Scarecrow5 || this.type == NPCID.Scarecrow10)
                    {
                        num92 = 1f;
                    }
                    if (this.type < 310)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.85f;
                            if ((double)this.velocity.X > -0.3 && (double)this.velocity.X < 0.3)
                            {
                                this.velocity.Y = -7f;
                                this.velocity.X = num92 * (float)this.direction;
                            }
                        }
                        else if (this.spriteDirection == this.direction)
                        {
                            this.velocity.X = (this.velocity.X * 10f + num92 * (float)this.direction) / 11f;
                        }
                    }
                    else if (this.velocity.X < -num92 || this.velocity.X > num92)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < num92 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > num92)
                        {
                            this.velocity.X = num92;
                        }
                    }
                    else if (this.velocity.X > -num92 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -num92)
                        {
                            this.velocity.X = -num92;
                        }
                    }
                }
                else if (this.type == NPCID.Crab || this.type == NPCID.SeaSnail || this.type == NPCID.VortexLarva)
                {
                    if (this.velocity.X < -0.5f || this.velocity.X > 0.5f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.7f;
                        }
                    }
                    else if (this.velocity.X < 0.5f && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.03f;
                        if (this.velocity.X > 0.5f)
                        {
                            this.velocity.X = 0.5f;
                        }
                    }
                    else if (this.velocity.X > -0.5f && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.03f;
                        if (this.velocity.X < -0.5f)
                        {
                            this.velocity.X = -0.5f;
                        }
                    }
                }
                else if (this.type == NPCID.Mummy || this.type == NPCID.DarkMummy || this.type == NPCID.LightMummy)
                {
                    float num93 = 1f;
                    float num94 = 0.05f;
                    if (this.life < this.lifeMax / 2)
                    {
                        num93 = 2f;
                        num94 = 0.1f;
                    }
                    if (this.type == NPCID.DarkMummy)
                    {
                        num93 *= 1.5f;
                    }
                    if (this.velocity.X < -num93 || this.velocity.X > num93)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.7f;
                        }
                    }
                    else if (this.velocity.X < num93 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + num94;
                        if (this.velocity.X > num93)
                        {
                            this.velocity.X = num93;
                        }
                    }
                    else if (this.velocity.X > -num93 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - num94;
                        if (this.velocity.X < -num93)
                        {
                            this.velocity.X = -num93;
                        }
                    }
                }
                else if (this.type == NPCID.BoneLee)
                {
                    float num95 = 5f;
                    float num96 = 0.2f;
                    if (this.velocity.X < -num95 || this.velocity.X > num95)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.7f;
                        }
                    }
                    else if (this.velocity.X < num95 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + num96;
                        if (this.velocity.X > num95)
                        {
                            this.velocity.X = num95;
                        }
                    }
                    else if (this.velocity.X > -num95 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - num96;
                        if (this.velocity.X < -num95)
                        {
                            this.velocity.X = -num95;
                        }
                    }
                }
                else if (this.type == NPCID.IceGolem)
                {
                    float num97 = 1f;
                    float num98 = 0.07f;
                    num97 += (1f - (float)this.life / (float)this.lifeMax) * 1.5f;
                    num98 += (1f - (float)this.life / (float)this.lifeMax) * 0.15f;
                    if (this.velocity.X < -num97 || this.velocity.X > num97)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.7f;
                        }
                    }
                    else if (this.velocity.X < num97 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + num98;
                        if (this.velocity.X > num97)
                        {
                            this.velocity.X = num97;
                        }
                    }
                    else if (this.velocity.X > -num97 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - num98;
                        if (this.velocity.X < -num97)
                        {
                            this.velocity.X = -num97;
                        }
                    }
                }
                else if (this.type == NPCID.Eyezor)
                {
                    float num99 = 1f;
                    float num100 = 0.08f;
                    num99 += (1f - (float)this.life / (float)this.lifeMax) * 2f;
                    num100 += (1f - (float)this.life / (float)this.lifeMax) * 0.2f;
                    if (this.velocity.X < -num99 || this.velocity.X > num99)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.7f;
                        }
                    }
                    else if (this.velocity.X < num99 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + num100;
                        if (this.velocity.X > num99)
                        {
                            this.velocity.X = num99;
                        }
                    }
                    else if (this.velocity.X > -num99 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - num100;
                        if (this.velocity.X < -num99)
                        {
                            this.velocity.X = -num99;
                        }
                    }
                }
                else if (this.type == NPCID.MartianEngineer)
                {
                    if (this.ai[2] > 0f)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.8f;
                        }
                    }
                    else
                    {
                        float num101 = 0.15f;
                        float num102 = 1.5f;
                        if (this.velocity.X < -num102 || this.velocity.X > num102)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity *= 0.7f;
                            }
                        }
                        else if (this.velocity.X < num102 && this.direction == 1)
                        {
                            this.velocity.X = this.velocity.X + num101;
                            if (this.velocity.X > num102)
                            {
                                this.velocity.X = num102;
                            }
                        }
                        else if (this.velocity.X > -num102 && this.direction == -1)
                        {
                            this.velocity.X = this.velocity.X - num101;
                            if (this.velocity.X < -num102)
                            {
                                this.velocity.X = -num102;
                            }
                        }
                    }
                }
                else if (this.type == NPCID.Butcher)
                {
                    float num103 = 3f;
                    float num104 = 0.1f;
                    if (Math.Abs(this.velocity.X) > 2f)
                    {
                        num104 *= 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 2.5)
                    {
                        num104 *= 0.8f;
                    }
                    if (Math.Abs(this.velocity.X) > 3f)
                    {
                        num104 *= 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 3.5)
                    {
                        num104 *= 0.8f;
                    }
                    if (Math.Abs(this.velocity.X) > 4f)
                    {
                        num104 *= 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 4.5)
                    {
                        num104 *= 0.8f;
                    }
                    if (Math.Abs(this.velocity.X) > 5f)
                    {
                        num104 *= 0.8f;
                    }
                    if ((double)Math.Abs(this.velocity.X) > 5.5)
                    {
                        num104 *= 0.8f;
                    }
                    num103 += (1f - (float)this.life / (float)this.lifeMax) * 3f;
                    if (this.velocity.X < -num103 || this.velocity.X > num103)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.7f;
                        }
                    }
                    else if (this.velocity.X < num103 && this.direction == 1)
                    {
                        if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.93f;
                        }
                        this.velocity.X = this.velocity.X + num104;
                        if (this.velocity.X > num103)
                        {
                            this.velocity.X = num103;
                        }
                    }
                    else if (this.velocity.X > -num103 && this.direction == -1)
                    {
                        if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.93f;
                        }
                        this.velocity.X = this.velocity.X - num104;
                        if (this.velocity.X < -num103)
                        {
                            this.velocity.X = -num103;
                        }
                    }
                }
                else if (this.type == NPCID.WalkingAntlion)
                {
                    float num105 = 2.5f;
                    float num106 = 40f;
                    float num107 = Math.Abs(this.velocity.X);
                    if (num107 > 2.75f)
                    {
                        num105 = 3.5f;
                        num106 += 80f;
                    }
                    else if ((double)num107 > 2.25)
                    {
                        num105 = 3f;
                        num106 += 60f;
                    }
                    if ((double)Math.Abs(this.velocity.Y) < 0.5)
                    {
                        if (this.velocity.X > 0f && this.direction < 0)
                        {
                            this.velocity *= 0.9f;
                        }
                        if (this.velocity.X < 0f && this.direction > 0)
                        {
                            this.velocity *= 0.9f;
                        }
                    }
                    if (Math.Abs(this.velocity.Y) > NPC.gravity)
                    {
                        num106 *= 3f;
                    }
                    if (this.velocity.X <= 0f && this.direction < 0)
                    {
                        this.velocity.X = (this.velocity.X * num106 - num105) / (num106 + 1f);
                    }
                    else if (this.velocity.X >= 0f && this.direction > 0)
                    {
                        this.velocity.X = (this.velocity.X * num106 + num105) / (num106 + 1f);
                    }
                    else if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 20f && Math.Abs(this.velocity.Y) <= NPC.gravity)
                    {
                        this.velocity.X = this.velocity.X * 0.99f;
                        this.velocity.X = this.velocity.X + (float)this.direction * 0.025f;
                    }
                }
                else if (this.type == NPCID.Scutlix || this.type == NPCID.VortexHornet || this.type == NPCID.SolarDrakomire || this.type == NPCID.SolarSolenian || this.type == NPCID.SolarSpearman || this.type == NPCID.DesertBeast)
                {
                    float num108 = 5f;
                    float num109 = 0.25f;
                    float scaleFactor5 = 0.7f;
                    if (this.type == NPCID.VortexHornet)
                    {
                        num108 = 6f;
                        num109 = 0.2f;
                        scaleFactor5 = 0.8f;
                    }
                    else if (this.type == NPCID.SolarDrakomire)
                    {
                        num108 = 4f;
                        num109 = 0.1f;
                        scaleFactor5 = 0.95f;
                    }
                    else if (this.type == NPCID.SolarSolenian)
                    {
                        num108 = 6f;
                        num109 = 0.15f;
                        scaleFactor5 = 0.85f;
                    }
                    else if (this.type == NPCID.SolarSpearman)
                    {
                        num108 = 5f;
                        num109 = 0.1f;
                        scaleFactor5 = 0.95f;
                    }
                    else if (this.type == NPCID.DesertBeast)
                    {
                        num108 = 5f;
                        num109 = 0.15f;
                        scaleFactor5 = 0.98f;
                    }
                    if (this.velocity.X < -num108 || this.velocity.X > num108)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= scaleFactor5;
                        }
                    }
                    else if (this.velocity.X < num108 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + num109;
                        if (this.velocity.X > num108)
                        {
                            this.velocity.X = num108;
                        }
                    }
                    else if (this.velocity.X > -num108 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - num109;
                        if (this.velocity.X < -num108)
                        {
                            this.velocity.X = -num108;
                        }
                    }
                }
                else if ((this.type >= NPCID.ArmedZombie && this.type <= NPCID.ArmedZombieCenx) || this.type == NPCID.Crawdad || this.type == NPCID.Crawdad2)
                {
                    if (this.ai[2] == 0f)
                    {
                        this.damage = this.defDamage;
                        float num110 = 1f;
                        num110 *= 1f + (1f - this.scale);
                        if (this.velocity.X < -num110 || this.velocity.X > num110)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity *= 0.8f;
                            }
                        }
                        else if (this.velocity.X < num110 && this.direction == 1)
                        {
                            this.velocity.X = this.velocity.X + 0.07f;
                            if (this.velocity.X > num110)
                            {
                                this.velocity.X = num110;
                            }
                        }
                        else if (this.velocity.X > -num110 && this.direction == -1)
                        {
                            this.velocity.X = this.velocity.X - 0.07f;
                            if (this.velocity.X < -num110)
                            {
                                this.velocity.X = -num110;
                            }
                        }
                        if (this.velocity.Y == 0f && (!Main.dayTime || (double)this.position.Y > Main.worldSurface * 16.0) && !Main.player[this.target].dead)
                        {
                            Vector2 vector16 = base.Center - Main.player[this.target].Center;
                            int num111 = 50;
                            if (this.type >= NPCID.Crawdad && this.type <= NPCID.Crawdad2)
                            {
                                num111 = 42;
                            }
                            if (vector16.Length() < (float)num111 && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                this.velocity.X = this.velocity.X * 0.7f;
                                this.ai[2] = 1f;
                            }
                        }
                    }
                    else
                    {
                        this.damage = (int)((double)this.defDamage * 1.5);
                        this.ai[3] = 1f;
                        this.velocity.X = this.velocity.X * 0.9f;
                        if ((double)Math.Abs(this.velocity.X) < 0.1)
                        {
                            this.velocity.X = 0f;
                        }
                        this.ai[2] += 1f;
                        if (this.ai[2] >= 20f || this.velocity.Y != 0f || (Main.dayTime && (double)this.position.Y < Main.worldSurface * 16.0))
                        {
                            this.ai[2] = 0f;
                        }
                    }
                }
                else if (this.type != NPCID.SkeletonArcher && this.type != NPCID.GoblinArcher && this.type != NPCID.IcyMerman && this.type != NPCID.PirateDeadeye && this.type != NPCID.PirateCrossbower && this.type != NPCID.PirateCaptain && this.type != NPCID.Paladin && this.type != NPCID.SkeletonSniper && this.type != NPCID.TacticalSkeleton && this.type != NPCID.SkeletonCommando && this.type != NPCID.ElfArcher && this.type != NPCID.CultistArcherBlue && this.type != NPCID.CultistArcherWhite && this.type != NPCID.BrainScrambler && this.type != NPCID.RayGunner && (this.type < 449 || this.type > 452) && this.type != NPCID.DrManFly && this.type != NPCID.GreekSkeleton && this.type != NPCID.StardustSoldier && this.type != NPCID.StardustSpiderBig && (this.type < 498 || this.type > 506) && this.type != NPCID.NebulaSoldier && this.type != NPCID.VortexHornetQueen && this.type != NPCID.MartianWalker)
                {
                    float num112 = 1f;
                    if (this.type == NPCID.PincushionZombie)
                    {
                        num112 = 1.1f;
                    }
                    if (this.type == NPCID.SlimedZombie)
                    {
                        num112 = 0.9f;
                    }
                    if (this.type == NPCID.SwampZombie)
                    {
                        num112 = 1.2f;
                    }
                    if (this.type == NPCID.TwiggyZombie)
                    {
                        num112 = 0.8f;
                    }
                    if (this.type == NPCID.BaldZombie)
                    {
                        num112 = 0.95f;
                    }
                    if (this.type == NPCID.FemaleZombie)
                    {
                        num112 = 0.87f;
                    }
                    if (this.type == NPCID.ZombieRaincoat)
                    {
                        num112 = 1.05f;
                    }
                    if (this.type == NPCID.BloodZombie)
                    {
                        float num113 = (Main.player[this.target].Center - base.Center).Length();
                        num113 *= 0.0025f;
                        if ((double)num113 > 1.5)
                        {
                            num113 = 1.5f;
                        }
                        if (Main.expertMode)
                        {
                            num112 = 3f - num113;
                        }
                        else
                        {
                            num112 = 2.5f - num113;
                        }
                        num112 *= 0.8f;
                    }
                    if (this.type == NPCID.BloodZombie || this.type == NPCID.Zombie || this.type == NPCID.BaldZombie || this.type == NPCID.PincushionZombie || this.type == NPCID.SlimedZombie || this.type == NPCID.SwampZombie || this.type == NPCID.TwiggyZombie || this.type == NPCID.FemaleZombie || this.type == NPCID.ZombieRaincoat || this.type == NPCID.ZombieXmas || this.type == NPCID.ZombieSweater)
                    {
                        num112 *= 1f + (1f - this.scale);
                    }
                    if (this.velocity.X < -num112 || this.velocity.X > num112)
                    {
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity *= 0.8f;
                        }
                    }
                    else if (this.velocity.X < num112 && this.direction == 1)
                    {
                        this.velocity.X = this.velocity.X + 0.07f;
                        if (this.velocity.X > num112)
                        {
                            this.velocity.X = num112;
                        }
                    }
                    else if (this.velocity.X > -num112 && this.direction == -1)
                    {
                        this.velocity.X = this.velocity.X - 0.07f;
                        if (this.velocity.X < -num112)
                        {
                            this.velocity.X = -num112;
                        }
                    }
                }
                if (this.type >= NPCID.HellArmoredBones && this.type <= NPCID.HellArmoredBonesSword)
                {
                }
                else if (this.type == NPCID.MartianWalker)
                {
                }
                else if (this.type == NPCID.DesertGhoulCorruption)
                {
                }
                else if (this.type == NPCID.DesertGhoulCrimson)
                {
                }
                else if (this.type == NPCID.DesertGhoulHallow)
                {
                }
                else if (this.type == NPCID.SolarDrakomire)
                {
                    this.hide = false;
                    for (int num114 = 0; num114 < 200; num114++)
                    {
                        if (Main.npc[num114].active && Main.npc[num114].type == NPCID.SolarDrakomireRider && Main.npc[num114].ai[0] == (float)this.whoAmI)
                        {
                            this.hide = true;
                            break;
                        }
                    }
                }
                else if (this.type == NPCID.MushiLadybug)
                {
                    if (this.velocity.Y != 0f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = this.direction;
                        if (Main.player[this.target].Center.X < this.position.X && this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.95f;
                        }
                        else if (Main.player[this.target].Center.X > this.position.X + (float)this.width && this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.95f;
                        }
                        if (Main.player[this.target].Center.X < this.position.X && this.velocity.X > -5f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (Main.player[this.target].Center.X > this.position.X + (float)this.width && this.velocity.X < 5f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 50f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -7f;
                    }
                }
                else if (this.type == NPCID.VortexRifleman)
                {
                    if (this.velocity.Y == 0f)
                    {
                        this.ai[2] = 0f;
                    }
                    if (this.velocity.Y != 0f && this.ai[2] == 1f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = -this.direction;
                        if (Collision.CanHit(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            float num115 = Main.player[this.target].Center.X - (float)(this.direction * 400) - base.Center.X;
                            float num116 = Main.player[this.target].Bottom.Y - base.Bottom.Y;
                            if (num115 < 0f && this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            else if (num115 > 0f && this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (num115 < 0f && this.velocity.X > -5f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (num115 > 0f && this.velocity.X < 5f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = 6f;
                            }
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = -6f;
                            }
                            if (num116 < -20f && this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.8f;
                            }
                            else if (num116 > 20f && this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.8f;
                            }
                            if (num116 < -20f && this.velocity.Y > -5f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.3f;
                            }
                            else if (num116 > 20f && this.velocity.Y < 5f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.3f;
                            }
                        }
                        for (int num117 = 0; num117 < 200; num117++)
                        {
                            if (num117 != this.whoAmI && Main.npc[num117].active && Main.npc[num117].type == this.type && Math.Abs(this.position.X - Main.npc[num117].position.X) + Math.Abs(this.position.Y - Main.npc[num117].position.Y) < (float)this.width)
                            {
                                if (this.position.X < Main.npc[num117].position.X)
                                {
                                    this.velocity.X = this.velocity.X - 0.05f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X + 0.05f;
                                }
                                if (this.position.Y < Main.npc[num117].position.Y)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.05f;
                                }
                                else
                                {
                                    this.velocity.Y = this.velocity.Y + 0.05f;
                                }
                            }
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 100f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -5f;
                        this.ai[2] = 1f;
                    }
                    if (Main.netMode != 1)
                    {
                        this.localAI[2] += 1f;
                        if (this.localAI[2] >= (float)(360 + Main.rand.Next(360)) && base.Distance(Main.player[this.target].Center) < 400f && Math.Abs(base.DirectionTo(Main.player[this.target].Center).Y) < 0.5f && Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            this.localAI[2] = 0f;
                            Vector2 vector17 = base.Center + new Vector2((float)(this.direction * 30), 2f);
                            Vector2 vector18 = base.DirectionTo(Main.player[this.target].Center) * 7f;
                            if (vector18.HasNaNs())
                            {
                                vector18 = new Vector2((float)(this.direction * 8), 0f);
                            }
                            int num118 = Main.expertMode ? 50 : 75;
                            for (int num119 = 0; num119 < 4; num119++)
                            {
                                Vector2 vector19 = vector18 + Utils.RandomVector2(Main.rand, -0.8f, 0.8f);
                                Projectile.NewProjectile(vector17.X, vector17.Y, vector19.X, vector19.Y, 577, num118, 1f, Main.myPlayer, 0f, 0f);
                            }
                        }
                    }
                }
                else if (this.type == NPCID.VortexHornet)
                {
                    if (this.velocity.Y == 0f)
                    {
                        this.ai[2] = 0f;
                        this.rotation = 0f;
                    }
                    else
                    {
                        this.rotation = this.velocity.X * 0.1f;
                    }
                    if (this.velocity.Y != 0f && this.ai[2] == 1f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = -this.direction;
                        if (Collision.CanHit(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            float num120 = Main.player[this.target].Center.X - base.Center.X;
                            float num121 = Main.player[this.target].Center.Y - base.Center.Y;
                            if (num120 < 0f && this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            else if (num120 > 0f && this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            if (num120 < -20f && this.velocity.X > -6f)
                            {
                                this.velocity.X = this.velocity.X - 0.015f;
                            }
                            else if (num120 > 20f && this.velocity.X < 6f)
                            {
                                this.velocity.X = this.velocity.X + 0.015f;
                            }
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = 6f;
                            }
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = -6f;
                            }
                            if (num121 < -20f && this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.98f;
                            }
                            else if (num121 > 20f && this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.98f;
                            }
                            if (num121 < -20f && this.velocity.Y > -6f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.15f;
                            }
                            else if (num121 > 20f && this.velocity.Y < 6f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.15f;
                            }
                        }
                        for (int num122 = 0; num122 < 200; num122++)
                        {
                            if (num122 != this.whoAmI && Main.npc[num122].active && Main.npc[num122].type == this.type && Math.Abs(this.position.X - Main.npc[num122].position.X) + Math.Abs(this.position.Y - Main.npc[num122].position.Y) < (float)this.width)
                            {
                                if (this.position.X < Main.npc[num122].position.X)
                                {
                                    this.velocity.X = this.velocity.X - 0.05f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X + 0.05f;
                                }
                                if (this.position.Y < Main.npc[num122].position.Y)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.05f;
                                }
                                else
                                {
                                    this.velocity.Y = this.velocity.Y + 0.05f;
                                }
                            }
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 100f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -5f;
                        this.ai[2] = 1f;
                    }
                }
                else if (this.type == NPCID.VortexHornetQueen)
                {
                    if (this.ai[1] > 0f && this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.85f;
                        if (this.velocity.Y == 0f)
                        {
                            this.velocity.Y = -0.4f;
                        }
                    }
                    if (this.velocity.Y != 0f)
                    {
                        this.TargetClosest(true);
                        this.spriteDirection = this.direction;
                        if (Collision.CanHit(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                        {
                            float num123 = Main.player[this.target].Center.X - (float)(this.direction * 300) - base.Center.X;
                            if (num123 < 40f && this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            else if (num123 > 40f && this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.98f;
                            }
                            if (num123 < 40f && this.velocity.X > -5f)
                            {
                                this.velocity.X = this.velocity.X - 0.2f;
                            }
                            else if (num123 > 40f && this.velocity.X < 5f)
                            {
                                this.velocity.X = this.velocity.X + 0.2f;
                            }
                            if (this.velocity.X > 6f)
                            {
                                this.velocity.X = 6f;
                            }
                            if (this.velocity.X < -6f)
                            {
                                this.velocity.X = -6f;
                            }
                        }
                    }
                    else if (Main.player[this.target].Center.Y + 100f < this.position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.velocity.Y = -6f;
                    }
                    for (int num124 = 0; num124 < 200; num124++)
                    {
                        if (num124 != this.whoAmI && Main.npc[num124].active && Main.npc[num124].type == this.type && Math.Abs(this.position.X - Main.npc[num124].position.X) + Math.Abs(this.position.Y - Main.npc[num124].position.Y) < (float)this.width)
                        {
                            if (this.position.X < Main.npc[num124].position.X)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            if (this.position.Y < Main.npc[num124].position.Y)
                            {
                                this.velocity.Y = this.velocity.Y - 0.1f;
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y + 0.1f;
                            }
                        }
                    }
                }
                else if (this.type == NPCID.SnowFlinx)
                {
                    if (this.velocity.Y == 0f)
                    {
                        this.rotation = 0f;
                        this.localAI[0] = 0f;
                    }
                    else if (this.localAI[0] == 1f)
                    {
                        this.rotation += this.velocity.X * 0.05f;
                    }
                }
                else if (this.type == NPCID.VortexLarva)
                {
                    if (this.velocity.Y == 0f)
                    {
                        this.rotation = 0f;
                    }
                    else
                    {
                        this.rotation += this.velocity.X * 0.08f;
                    }
                }
                if (this.type == NPCID.Vampire && Main.netMode != 1)
                {
                    Vector2 vector20 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num126 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector20.X;
                    float num127 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector20.Y;
                    float num128 = (float)Math.Sqrt((double)(num126 * num126 + num127 * num127));
                    if (num128 > 300f)
                    {
                        this.Transform(158);
                    }
                }
                if (this.type == NPCID.WallCreeper && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int num129 = (int)base.Center.X / 16;
                    int num130 = (int)base.Center.Y / 16;
                    bool flag11 = false;
                    for (int num131 = num129 - 1; num131 <= num129 + 1; num131++)
                    {
                        for (int num132 = num130 - 1; num132 <= num130 + 1; num132++)
                        {
                            if (Main.tile[num131, num132].wall > 0)
                            {
                                flag11 = true;
                            }
                        }
                    }
                    if (flag11)
                    {
                        this.Transform(165);
                    }
                }
                if (this.type == NPCID.BloodCrawler && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int num133 = (int)base.Center.X / 16;
                    int num134 = (int)base.Center.Y / 16;
                    bool flag12 = false;
                    for (int num135 = num133 - 1; num135 <= num133 + 1; num135++)
                    {
                        for (int num136 = num134 - 1; num136 <= num134 + 1; num136++)
                        {
                            if (Main.tile[num135, num136].wall > 0)
                            {
                                flag12 = true;
                            }
                        }
                    }
                    if (flag12)
                    {
                        this.Transform(240);
                    }
                }
                if (this.type == NPCID.DesertScorpionWalk && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int num137 = (int)base.Center.X / 16;
                    int num138 = (int)base.Center.Y / 16;
                    bool flag13 = false;
                    for (int num139 = num137 - 1; num139 <= num137 + 1; num139++)
                    {
                        for (int num140 = num138 - 1; num140 <= num138 + 1; num140++)
                        {
                            if (Main.tile[num139, num140].wall > 0)
                            {
                                flag13 = true;
                            }
                        }
                    }
                    if (flag13)
                    {
                        this.Transform(531);
                    }
                }
                if (Main.netMode != 1 && Main.expertMode && this.target >= 0 && (this.type == NPCID.BlackRecluse || this.type == NPCID.BlackRecluseWall) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                {
                    this.localAI[0] += 1f;
                    if (this.justHit)
                    {
                        this.localAI[0] -= (float)Main.rand.Next(20, 60);
                        if (this.localAI[0] < 0f)
                        {
                            this.localAI[0] = 0f;
                        }
                    }
                    if (this.localAI[0] > (float)Main.rand.Next(180, 900))
                    {
                        this.localAI[0] = 0f;
                        Vector2 vector21 = Main.player[this.target].Center - base.Center;
                        vector21.Normalize();
                        vector21 *= 8f;
                        Projectile.NewProjectile(base.Center.X, base.Center.Y, vector21.X, vector21.Y, 472, 18, 0f, Main.myPlayer, 0f, 0f);
                    }
                }
                if (this.type == NPCID.BlackRecluse && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int num141 = (int)base.Center.X / 16;
                    int num142 = (int)base.Center.Y / 16;
                    bool flag14 = false;
                    for (int num143 = num141 - 1; num143 <= num141 + 1; num143++)
                    {
                        for (int num144 = num142 - 1; num144 <= num142 + 1; num144++)
                        {
                            if (Main.tile[num143, num144].wall > 0)
                            {
                                flag14 = true;
                            }
                        }
                    }
                    if (flag14)
                    {
                        this.Transform(238);
                    }
                }
                if (this.type == NPCID.JungleCreeper && Main.netMode != 1 && this.velocity.Y == 0f)
                {
                    int num145 = (int)base.Center.X / 16;
                    int num146 = (int)base.Center.Y / 16;
                    bool flag15 = false;
                    for (int num147 = num145 - 1; num147 <= num145 + 1; num147++)
                    {
                        for (int num148 = num146 - 1; num148 <= num146 + 1; num148++)
                        {
                            if (Main.tile[num147, num148].wall > 0)
                            {
                                flag15 = true;
                            }
                        }
                    }
                    if (flag15)
                    {
                        this.Transform(237);
                    }
                }
                if (this.type == NPCID.IceGolem)
                {
                    if (this.justHit && Main.rand.Next(3) == 0)
                    {
                        this.ai[2] -= (float)Main.rand.Next(30);
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.ai[2] = 0f;
                    }
                    if (this.confused)
                    {
                        this.ai[2] = 0f;
                    }
                    this.ai[2] += 1f;
                    float num149 = (float)Main.rand.Next(30, 900);
                    num149 *= (float)this.life / (float)this.lifeMax;
                    num149 += 30f;
                    if (Main.netMode != 1 && this.ai[2] >= num149 && this.velocity.Y == 0f && !Main.player[this.target].dead && !Main.player[this.target].frozen && ((this.direction > 0 && base.Center.X < Main.player[this.target].Center.X) || (this.direction < 0 && base.Center.X > Main.player[this.target].Center.X)) && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        float num150 = 15f;
                        Vector2 vector22 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + 20f);
                        vector22.X += (float)(10 * this.direction);
                        float num151 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector22.X;
                        float num152 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector22.Y;
                        num151 += (float)Main.rand.Next(-40, 41);
                        num152 += (float)Main.rand.Next(-40, 41);
                        float num153 = (float)Math.Sqrt((double)(num151 * num151 + num152 * num152));
                        this.netUpdate = true;
                        num153 = num150 / num153;
                        num151 *= num153;
                        num152 *= num153;
                        int num154 = 32;
                        int num155 = 257;
                        vector22.X += num151 * 3f;
                        vector22.Y += num152 * 3f;
                        Projectile.NewProjectile(vector22.X, vector22.Y, num151, num152, num155, num154, 0f, Main.myPlayer, 0f, 0f);
                        this.ai[2] = 0f;
                    }
                }
                if (this.type == NPCID.Eyezor)
                {
                    if (this.justHit)
                    {
                        this.ai[2] -= (float)Main.rand.Next(30);
                    }
                    if (this.ai[2] < 0f)
                    {
                        this.ai[2] = 0f;
                    }
                    if (this.confused)
                    {
                        this.ai[2] = 0f;
                    }
                    this.ai[2] += 1f;
                    float num156 = (float)Main.rand.Next(60, 1800);
                    num156 *= (float)this.life / (float)this.lifeMax;
                    num156 += 15f;
                    if (Main.netMode != 1 && this.ai[2] >= num156 && this.velocity.Y == 0f && !Main.player[this.target].dead && !Main.player[this.target].frozen && ((this.direction > 0 && base.Center.X < Main.player[this.target].Center.X) || (this.direction < 0 && base.Center.X > Main.player[this.target].Center.X)) && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        float num157 = 15f;
                        Vector2 vector23 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + 12f);
                        vector23.X += (float)(6 * this.direction);
                        float num158 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector23.X;
                        float num159 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector23.Y;
                        num158 += (float)Main.rand.Next(-40, 41);
                        num159 += (float)Main.rand.Next(-30, 0);
                        float num160 = (float)Math.Sqrt((double)(num158 * num158 + num159 * num159));
                        this.netUpdate = true;
                        num160 = num157 / num160;
                        num158 *= num160;
                        num159 *= num160;
                        int num161 = 30;
                        int num162 = 83;
                        vector23.X += num158 * 3f;
                        vector23.Y += num159 * 3f;
                        Projectile.NewProjectile(vector23.X, vector23.Y, num158, num159, num162, num161, 0f, Main.myPlayer, 0f, 0f);
                        this.ai[2] = 0f;
                    }
                }
                if (this.type == NPCID.MartianEngineer)
                {
                    if (this.confused)
                    {
                        this.ai[2] = -60f;
                    }
                    else
                    {
                        if (this.ai[2] < 60f)
                        {
                            this.ai[2] += 1f;
                        }
                        if (this.ai[2] > 0f && NPC.CountNPCS(387) >= 4 * NPC.CountNPCS(386))
                        {
                            this.ai[2] = 0f;
                        }
                        if (this.justHit)
                        {
                            this.ai[2] = -30f;
                        }
                        if (this.ai[2] == 30f)
                        {
                            int num163 = (int)this.position.X / 16;
                            int num164 = (int)this.position.Y / 16;
                            int num165 = (int)this.position.X / 16;
                            int num166 = (int)this.position.Y / 16;
                            int num167 = 5;
                            int num168 = 0;
                            bool flag16 = false;
                            int num169 = 2;
                            int num170 = 0;
                            while (!flag16 && num168 < 100)
                            {
                                num168++;
                                int num171 = Main.rand.Next(num163 - num167, num163 + num167);
                                int num172 = Main.rand.Next(num164 - num167, num164 + num167);
                                for (int num173 = num172; num173 < num164 + num167; num173++)
                                {
                                    if ((num173 < num164 - num169 || num173 > num164 + num169 || num171 < num163 - num169 || num171 > num163 + num169) && (num173 < num166 - num170 || num173 > num166 + num170 || num171 < num165 - num170 || num171 > num165 + num170) && Main.tile[num171, num173].nactive())
                                    {
                                        bool flag17 = true;
                                        if (Main.tile[num171, num173 - 1].lava())
                                        {
                                            flag17 = false;
                                        }
                                        if (flag17 && Main.tileSolid[(int)Main.tile[num171, num173].type] && !Collision.SolidTiles(num171 - 1, num171 + 1, num173 - 4, num173 - 1))
                                        {
                                            int num174 = NPC.NewNPC(num171 * 16 - this.width / 2, num173 * 16, 387, 0, 0f, 0f, 0f, 0f, 255);
                                            Main.npc[num174].position.Y = (float)(num173 * 16 - Main.npc[num174].height);
                                            flag16 = true;
                                            this.netUpdate = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if (this.ai[2] == 60f)
                        {
                            this.ai[2] = -120f;
                        }
                    }
                }
                if (this.type == NPCID.GigaZapper)
                {
                    if (this.confused)
                    {
                        this.ai[2] = -60f;
                    }
                    else
                    {
                        if (this.ai[2] < 20f)
                        {
                            this.ai[2] += 1f;
                        }
                        if (this.justHit)
                        {
                            this.ai[2] = -30f;
                        }
                        if (this.ai[2] == 20f && Main.netMode != 1)
                        {
                            this.ai[2] = (float)(-10 + Main.rand.Next(3) * -10);
                            Projectile.NewProjectile(base.Center.X, base.Center.Y + 8f, (float)(this.direction * 6), 0f, 437, 25, 1f, Main.myPlayer, 0f, 0f);
                        }
                    }
                }
                if (this.type == NPCID.SkeletonArcher || this.type == NPCID.GoblinArcher || this.type == NPCID.IcyMerman || this.type == NPCID.PirateDeadeye || this.type == NPCID.PirateCrossbower || this.type == NPCID.PirateCaptain || this.type == NPCID.Paladin || this.type == NPCID.SkeletonSniper || this.type == NPCID.TacticalSkeleton || this.type == NPCID.SkeletonCommando || this.type == NPCID.ElfArcher || this.type == NPCID.CultistArcherBlue || this.type == NPCID.CultistArcherWhite || this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner || (this.type >= NPCID.BoneThrowingSkeleton && this.type <= NPCID.BoneThrowingSkeleton4) || (this.type == NPCID.DrManFly || this.type == NPCID.GreekSkeleton || this.type == NPCID.StardustSoldier || this.type == NPCID.StardustSpiderBig || (this.type >= NPCID.Salamander && this.type <= NPCID.Salamander9)) || this.type == NPCID.NebulaSoldier || this.type == NPCID.VortexHornetQueen || this.type == NPCID.MartianWalker)
                {
                    bool flag18 = this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner || this.type == NPCID.MartianWalker;
                    bool flag19 = this.type == NPCID.VortexHornetQueen;
                    bool flag20 = true;
                    int num175 = -1;
                    int num176 = -1;
                    if (this.type == NPCID.StardustSoldier)
                    {
                        flag18 = true;
                        num175 = 90;
                        num176 = 90;
                        if (this.ai[1] <= 150f)
                        {
                            flag20 = false;
                        }
                    }
                    if (this.confused)
                    {
                        this.ai[2] = 0f;
                    }
                    else
                    {
                        if (this.ai[1] > 0f)
                        {
                            this.ai[1] -= 1f;
                        }
                        if (this.justHit)
                        {
                            this.ai[1] = 30f;
                            this.ai[2] = 0f;
                        }
                        int num177 = 70;
                        if (this.type == NPCID.CultistArcherBlue || this.type == NPCID.CultistArcherWhite)
                        {
                            num177 = 80;
                        }
                        if (this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner)
                        {
                            num177 = 80;
                        }
                        if (this.type == NPCID.MartianWalker)
                        {
                            num177 = 15;
                        }
                        if (this.type == NPCID.ElfArcher)
                        {
                            num177 = 110;
                        }
                        if (this.type == NPCID.SkeletonSniper)
                        {
                            num177 = 200;
                        }
                        if (this.type == NPCID.TacticalSkeleton)
                        {
                            num177 = 120;
                        }
                        if (this.type == NPCID.SkeletonCommando)
                        {
                            num177 = 90;
                        }
                        if (this.type == NPCID.GoblinArcher)
                        {
                            num177 = 180;
                        }
                        if (this.type == NPCID.IcyMerman)
                        {
                            num177 = 50;
                        }
                        if (this.type == NPCID.PirateDeadeye)
                        {
                            num177 = 40;
                        }
                        if (this.type == NPCID.PirateCrossbower)
                        {
                            num177 = 80;
                        }
                        if (this.type == NPCID.Paladin)
                        {
                            num177 = 30;
                        }
                        if (this.type == NPCID.StardustSoldier)
                        {
                            num177 = 300;
                        }
                        if (this.type == NPCID.StardustSpiderBig)
                        {
                            num177 = 60;
                        }
                        if (this.type == NPCID.NebulaSoldier)
                        {
                            num177 = 180;
                        }
                        if (this.type == NPCID.VortexHornetQueen)
                        {
                            num177 = 60;
                        }
                        bool flag21 = false;
                        if (this.type == NPCID.PirateCaptain)
                        {
                            if (this.localAI[2] >= 20f)
                            {
                                flag21 = true;
                            }
                            if (flag21)
                            {
                                num177 = 60;
                            }
                            else
                            {
                                num177 = 8;
                            }
                        }
                        int num178 = num177 / 2;
                        if (this.type == NPCID.NebulaSoldier)
                        {
                            num178 = num177 - 1;
                        }
                        if (this.type == NPCID.VortexHornetQueen)
                        {
                            num178 = num177 - 1;
                        }
                        if (this.ai[2] > 0f)
                        {
                            if (flag20)
                            {
                                this.TargetClosest(true);
                            }
                            if (this.ai[1] == (float)num178)
                            {
                                if (this.type == NPCID.PirateCaptain)
                                {
                                    this.localAI[2] += 1f;
                                }
                                float num179 = 11f;
                                if (this.type == NPCID.GoblinArcher)
                                {
                                    num179 = 9f;
                                }
                                if (this.type == NPCID.IcyMerman)
                                {
                                    num179 = 7f;
                                }
                                if (this.type == NPCID.Paladin)
                                {
                                    num179 = 9f;
                                }
                                if (this.type == NPCID.SkeletonCommando)
                                {
                                    num179 = 4f;
                                }
                                if (this.type == NPCID.PirateDeadeye)
                                {
                                    num179 = 14f;
                                }
                                if (this.type == NPCID.PirateCrossbower)
                                {
                                    num179 = 16f;
                                }
                                if (this.type == NPCID.RayGunner)
                                {
                                    num179 = 7f;
                                }
                                if (this.type == NPCID.MartianWalker)
                                {
                                    num179 = 8f;
                                }
                                if (this.type == NPCID.StardustSpiderBig)
                                {
                                    num179 = 4f;
                                }
                                if (this.type >= NPCID.BoneThrowingSkeleton && this.type <= NPCID.BoneThrowingSkeleton4)
                                {
                                    num179 = 7f;
                                }
                                if (this.type == NPCID.GreekSkeleton)
                                {
                                    num179 = 9f;
                                }
                                if (this.type == NPCID.DrManFly)
                                {
                                    num179 = 7.5f;
                                }
                                if (this.type == NPCID.StardustSoldier)
                                {
                                    num179 = 1f;
                                }
                                if (this.type >= NPCID.Salamander && this.type <= NPCID.Salamander9)
                                {
                                    num179 = 7f;
                                }
                                Vector2 value9 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                if (this.type == NPCID.GreekSkeleton)
                                {
                                    value9.Y -= 14f;
                                }
                                if (this.type == NPCID.IcyMerman)
                                {
                                    value9.Y -= 10f;
                                }
                                if (this.type == NPCID.Paladin)
                                {
                                    value9.Y -= 10f;
                                }
                                if (this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner)
                                {
                                    value9.Y += 6f;
                                }
                                if (this.type == NPCID.MartianWalker)
                                {
                                    value9.Y = this.position.Y + 20f;
                                }
                                if (this.type >= NPCID.Salamander && this.type <= NPCID.Salamander9)
                                {
                                    value9.Y -= 8f;
                                }
                                if (this.type == NPCID.VortexHornetQueen)
                                {
                                    value9 += new Vector2((float)(this.spriteDirection * 2), -12f);
                                }
                                float num180 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - value9.X;
                                float num181 = Math.Abs(num180) * 0.1f;
                                if (this.type == NPCID.SkeletonSniper || this.type == NPCID.TacticalSkeleton)
                                {
                                    num181 = 0f;
                                }
                                if (this.type == NPCID.PirateCrossbower)
                                {
                                    num181 = Math.Abs(num180) * 0.08f;
                                }
                                if (this.type == NPCID.PirateDeadeye || (this.type == NPCID.PirateCaptain && !flag21))
                                {
                                    num181 = 0f;
                                }
                                if (this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner || this.type == NPCID.MartianWalker)
                                {
                                    num181 = 0f;
                                }
                                if (this.type >= NPCID.BoneThrowingSkeleton && this.type <= NPCID.BoneThrowingSkeleton4)
                                {
                                    num181 = Math.Abs(num180) * (float)Main.rand.Next(10, 50) * 0.01f;
                                }
                                if (this.type == NPCID.DrManFly)
                                {
                                    num181 = Math.Abs(num180) * (float)Main.rand.Next(10, 50) * 0.01f;
                                }
                                if (this.type == NPCID.GreekSkeleton)
                                {
                                    num181 = Math.Abs(num180) * (float)Main.rand.Next(-10, 11) * 0.0025f;
                                }
                                if (this.type >= NPCID.Salamander && this.type <= NPCID.Salamander9)
                                {
                                    num181 = Math.Abs(num180) * (float)Main.rand.Next(1, 11) * 0.0025f;
                                }
                                float num182 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - value9.Y - num181;
                                if (this.type == NPCID.SkeletonSniper)
                                {
                                    num180 += (float)Main.rand.Next(-40, 41) * 0.2f;
                                    num182 += (float)Main.rand.Next(-40, 41) * 0.2f;
                                }
                                else if (this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner || this.type == NPCID.MartianWalker)
                                {
                                    num180 += (float)Main.rand.Next(-100, 101) * 0.4f;
                                    num182 += (float)Main.rand.Next(-100, 101) * 0.4f;
                                    num180 *= (float)Main.rand.Next(85, 116) * 0.01f;
                                    num182 *= (float)Main.rand.Next(85, 116) * 0.01f;
                                    if (this.type == NPCID.MartianWalker)
                                    {
                                        num180 += (float)Main.rand.Next(-100, 101) * 0.6f;
                                        num182 += (float)Main.rand.Next(-100, 101) * 0.6f;
                                        num180 *= (float)Main.rand.Next(85, 116) * 0.015f;
                                        num182 *= (float)Main.rand.Next(85, 116) * 0.015f;
                                    }
                                }
                                else if (this.type == NPCID.GreekSkeleton)
                                {
                                    num180 += (float)Main.rand.Next(-40, 41) * 0.4f;
                                    num182 += (float)Main.rand.Next(-40, 41) * 0.4f;
                                }
                                else if (this.type >= NPCID.Salamander && this.type <= NPCID.Salamander9)
                                {
                                    num180 += (float)Main.rand.Next(-40, 41) * 0.3f;
                                    num182 += (float)Main.rand.Next(-40, 41) * 0.3f;
                                }
                                else if (this.type != NPCID.TacticalSkeleton)
                                {
                                    num180 += (float)Main.rand.Next(-40, 41);
                                    num182 += (float)Main.rand.Next(-40, 41);
                                }
                                float num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182));
                                this.netUpdate = true;
                                num183 = num179 / num183;
                                num180 *= num183;
                                num182 *= num183;
                                int num184 = 35;
                                int num185 = 82;
                                if (this.type == NPCID.GoblinArcher)
                                {
                                    num184 = 11;
                                }
                                if (this.type == NPCID.IcyMerman)
                                {
                                    num184 = 37;
                                }
                                if (this.type == NPCID.CultistArcherBlue || this.type == NPCID.CultistArcherWhite)
                                {
                                    num184 = 40;
                                }
                                if (this.type == NPCID.ElfArcher)
                                {
                                    num184 = 45;
                                }
                                if (this.type == NPCID.DrManFly)
                                {
                                    num184 = 50;
                                }
                                if (this.type == NPCID.GoblinArcher)
                                {
                                    num185 = 81;
                                }
                                if (this.type == NPCID.CultistArcherBlue || this.type == NPCID.CultistArcherWhite)
                                {
                                    num185 = 81;
                                }
                                if (this.type == NPCID.BrainScrambler)
                                {
                                    num185 = 436;
                                    num184 = 24;
                                }
                                if (this.type == NPCID.RayGunner)
                                {
                                    num185 = 438;
                                    num184 = 30;
                                }
                                if (this.type == NPCID.MartianWalker)
                                {
                                    num185 = 592;
                                    num184 = 35;
                                }
                                if (this.type >= NPCID.BoneThrowingSkeleton && this.type <= NPCID.BoneThrowingSkeleton4)
                                {
                                    num185 = 471;
                                    num184 = 20;
                                }
                                if (this.type >= NPCID.Salamander && this.type <= NPCID.Salamander9)
                                {
                                    num185 = 572;
                                    num184 = 14;
                                }
                                if (this.type == NPCID.GreekSkeleton)
                                {
                                    num185 = 508;
                                    num184 = 24;
                                }
                                if (this.type == NPCID.IcyMerman)
                                {
                                    num185 = 177;
                                }
                                if (this.type == NPCID.DrManFly)
                                {
                                    num185 = 501;
                                }
                                if (this.type == NPCID.StardustSoldier)
                                {
                                    num185 = 537;
                                    num184 = (Main.expertMode ? 45 : 60);
                                }
                                if (this.type == NPCID.NebulaSoldier)
                                {
                                    num185 = 573;
                                    num184 = (Main.expertMode ? 45 : 60);
                                }
                                if (this.type == NPCID.VortexHornetQueen)
                                {
                                    num185 = 581;
                                    num184 = (Main.expertMode ? 45 : 60);
                                }
                                if (this.type == NPCID.SkeletonSniper)
                                {
                                    num185 = 302;
                                    num184 = 100;
                                }
                                if (this.type == NPCID.Paladin)
                                {
                                    num185 = 300;
                                    num184 = 60;
                                }
                                if (this.type == NPCID.SkeletonCommando)
                                {
                                    num185 = 303;
                                    num184 = 60;
                                }
                                if (this.type == NPCID.PirateDeadeye)
                                {
                                    num185 = 180;
                                    num184 = 25;
                                }
                                if (this.type == NPCID.PirateCrossbower)
                                {
                                    num185 = 82;
                                    num184 = 40;
                                }
                                if (this.type == NPCID.TacticalSkeleton)
                                {
                                    num184 = 50;
                                    num185 = 180;
                                }
                                if (this.type == NPCID.PirateCaptain)
                                {
                                    num185 = 180;
                                    num184 = 30;
                                    if (flag21)
                                    {
                                        num184 = 100;
                                        num185 = 240;
                                        this.localAI[2] = 0f;
                                    }
                                }
                                value9.X += num180;
                                value9.Y += num182;
                                if (Main.expertMode && this.type == NPCID.Paladin)
                                {
                                    num184 = (int)((double)num184 * 0.75);
                                }
                                if (Main.expertMode && this.type >= NPCID.BrainScrambler && this.type <= NPCID.MartianSaucer)
                                {
                                    num184 = (int)((double)num184 * 0.8);
                                }
                                if (Main.netMode != 1)
                                {
                                    if (this.type == NPCID.TacticalSkeleton)
                                    {
                                        for (int num186 = 0; num186 < 4; num186++)
                                        {
                                            num180 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - value9.X;
                                            num182 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - value9.Y;
                                            num183 = (float)Math.Sqrt((double)(num180 * num180 + num182 * num182));
                                            num183 = 12f / num183;
                                            num180 += (float)Main.rand.Next(-40, 41);
                                            num182 += (float)Main.rand.Next(-40, 41);
                                            num180 *= num183;
                                            num182 *= num183;
                                            Projectile.NewProjectile(value9.X, value9.Y, num180, num182, num185, num184, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                    }
                                    else if (this.type == NPCID.StardustSoldier)
                                    {
                                        Projectile.NewProjectile(value9.X, value9.Y, num180, num182, num185, num184, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                    }
                                    else if (this.type == NPCID.NebulaSoldier)
                                    {
                                        for (int num187 = 0; num187 < 4; num187++)
                                        {
                                            Projectile.NewProjectile(base.Center.X - (float)(this.spriteDirection * 4), base.Center.Y + 6f, (float)(-3 + 2 * num187) * 0.15f, (float)(-(float)Main.rand.Next(0, 3)) * 0.2f - 0.1f, num185, num184, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                        }
                                    }
                                    else if (this.type == NPCID.StardustSpiderBig)
                                    {
                                        int num188 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 410, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                        Main.npc[num188].velocity = new Vector2(num180, -6f + num182);
                                    }
                                    else
                                    {
                                        Projectile.NewProjectile(value9.X, value9.Y, num180, num182, num185, num184, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                }
                                if (Math.Abs(num182) > Math.Abs(num180) * 2f)
                                {
                                    if (num182 > 0f)
                                    {
                                        this.ai[2] = 1f;
                                    }
                                    else
                                    {
                                        this.ai[2] = 5f;
                                    }
                                }
                                else if (Math.Abs(num180) > Math.Abs(num182) * 2f)
                                {
                                    this.ai[2] = 3f;
                                }
                                else if (num182 > 0f)
                                {
                                    this.ai[2] = 2f;
                                }
                                else
                                {
                                    this.ai[2] = 4f;
                                }
                            }
                            if ((this.velocity.Y != 0f && !flag19) || this.ai[1] <= 0f)
                            {
                                this.ai[2] = 0f;
                                this.ai[1] = 0f;
                            }
                            else if (!flag18 || (num175 != -1 && this.ai[1] >= (float)num175 && this.ai[1] < (float)(num175 + num176) && (!flag19 || this.velocity.Y == 0f)))
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                this.spriteDirection = this.direction;
                            }
                        }
                        if (this.type == NPCID.DrManFly && !Main.eclipse)
                        {
                            flag18 = true;
                        }
                        else if ((this.ai[2] <= 0f || flag18) && (this.velocity.Y == 0f || flag19) && this.ai[1] <= 0f && !Main.player[this.target].dead)
                        {
                            bool flag22 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                            if (this.type == NPCID.MartianWalker)
                            {
                                flag22 = Collision.CanHitLine(base.Top + new Vector2(0f, 20f), 0, 0, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                            }
                            if (Main.player[this.target].stealth == 0f && Main.player[this.target].itemAnimation == 0)
                            {
                                flag22 = false;
                            }
                            if (flag22)
                            {
                                float num189 = 10f;
                                Vector2 vector24 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num190 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector24.X;
                                float num191 = Math.Abs(num190) * 0.1f;
                                float num192 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector24.Y - num191;
                                num190 += (float)Main.rand.Next(-40, 41);
                                num192 += (float)Main.rand.Next(-40, 41);
                                float num193 = (float)Math.Sqrt((double)(num190 * num190 + num192 * num192));
                                float num194 = 700f;
                                if (this.type == NPCID.PirateDeadeye)
                                {
                                    num194 = 550f;
                                }
                                if (this.type == NPCID.PirateCrossbower)
                                {
                                    num194 = 800f;
                                }
                                if (this.type >= NPCID.Salamander && this.type <= NPCID.Salamander9)
                                {
                                    num194 = 190f;
                                }
                                if (this.type >= NPCID.BoneThrowingSkeleton && this.type <= NPCID.BoneThrowingSkeleton4)
                                {
                                    num194 = 200f;
                                }
                                if (this.type == NPCID.GreekSkeleton)
                                {
                                    num194 = 400f;
                                }
                                if (this.type == NPCID.DrManFly)
                                {
                                    num194 = 400f;
                                }
                                if (num193 < num194)
                                {
                                    this.netUpdate = true;
                                    this.velocity.X = this.velocity.X * 0.5f;
                                    num193 = num189 / num193;
                                    num190 *= num193;
                                    num192 *= num193;
                                    this.ai[2] = 3f;
                                    this.ai[1] = (float)num177;
                                    if (Math.Abs(num192) > Math.Abs(num190) * 2f)
                                    {
                                        if (num192 > 0f)
                                        {
                                            this.ai[2] = 1f;
                                        }
                                        else
                                        {
                                            this.ai[2] = 5f;
                                        }
                                    }
                                    else if (Math.Abs(num190) > Math.Abs(num192) * 2f)
                                    {
                                        this.ai[2] = 3f;
                                    }
                                    else if (num192 > 0f)
                                    {
                                        this.ai[2] = 2f;
                                    }
                                    else
                                    {
                                        this.ai[2] = 4f;
                                    }
                                }
                            }
                        }
                        if (this.ai[2] <= 0f || (flag18 && (num175 == -1 || this.ai[1] < (float)num175 || this.ai[1] >= (float)(num175 + num176))))
                        {
                            float num195 = 1f;
                            float num196 = 0.07f;
                            float scaleFactor6 = 0.8f;
                            if (this.type == NPCID.PirateDeadeye)
                            {
                                num195 = 2f;
                                num196 = 0.09f;
                            }
                            else if (this.type == NPCID.PirateCrossbower)
                            {
                                num195 = 1.5f;
                                num196 = 0.08f;
                            }
                            else if (this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner)
                            {
                                num195 = 2f;
                                num196 = 0.5f;
                            }
                            else if (this.type == NPCID.MartianWalker)
                            {
                                num195 = 4f;
                                num196 = 1f;
                                scaleFactor6 = 0.7f;
                            }
                            else if (this.type == NPCID.StardustSoldier)
                            {
                                num195 = 2f;
                                num196 = 0.5f;
                            }
                            else if (this.type == NPCID.StardustSpiderBig)
                            {
                                num195 = 2f;
                                num196 = 0.5f;
                            }
                            bool flag23 = false;
                            if ((this.type == NPCID.BrainScrambler || this.type == NPCID.RayGunner) && Vector2.Distance(base.Center, Main.player[this.target].Center) < 300f && Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                            {
                                flag23 = true;
                                this.ai[3] = 0f;
                            }
                            if (this.type == NPCID.MartianWalker && Vector2.Distance(base.Center, Main.player[this.target].Center) < 400f && Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                            {
                                flag23 = true;
                                this.ai[3] = 0f;
                            }
                            if (this.velocity.X < -num195 || this.velocity.X > num195 || flag23)
                            {
                                if (this.velocity.Y == 0f)
                                {
                                    this.velocity *= scaleFactor6;
                                }
                            }
                            else if (this.velocity.X < num195 && this.direction == 1)
                            {
                                this.velocity.X = this.velocity.X + num196;
                                if (this.velocity.X > num195)
                                {
                                    this.velocity.X = num195;
                                }
                            }
                            else if (this.velocity.X > -num195 && this.direction == -1)
                            {
                                this.velocity.X = this.velocity.X - num196;
                                if (this.velocity.X < -num195)
                                {
                                    this.velocity.X = -num195;
                                }
                            }
                        }
                        if (this.type == NPCID.MartianWalker)
                        {
                            this.localAI[2] += 1f;
                            if (this.localAI[2] >= 6f)
                            {
                                this.localAI[2] = 0f;
                                this.localAI[3] = Main.player[this.target].DirectionFrom(base.Top + new Vector2(0f, 20f)).ToRotation();
                            }
                        }
                    }
                }
                if (this.type == NPCID.Clown && Main.netMode != 1 && !Main.player[this.target].dead)
                {
                    if (this.justHit)
                    {
                        this.ai[2] = 0f;
                    }
                    this.ai[2] += 1f;
                    if (this.ai[2] > 450f)
                    {
                        Vector2 vector25 = new Vector2(this.position.X + (float)this.width * 0.5f - (float)(this.direction * 24), this.position.Y + 4f);
                        int num197 = 3 * this.direction;
                        int num198 = -5;
                        int num199 = Projectile.NewProjectile(vector25.X, vector25.Y, (float)num197, (float)num198, 75, 0, 0f, Main.myPlayer, 0f, 0f);
                        Main.projectile[num199].timeLeft = 300;
                        this.ai[2] = 0f;
                    }
                }
                bool flag24 = false;
                if (this.velocity.Y == 0f)
                {
                    int num200 = (int)(this.position.Y + (float)this.height + 7f) / 16;
                    int num201 = (int)this.position.X / 16;
                    int num202 = (int)(this.position.X + (float)this.width) / 16;
                    for (int num203 = num201; num203 <= num202; num203++)
                    {
                        if (Main.tile[num203, num200] == null)
                        {
                            return;
                        }
                        if (Main.tile[num203, num200].nactive() && Main.tileSolid[(int)Main.tile[num203, num200].type])
                        {
                            flag24 = true;
                            break;
                        }
                    }
                }
                if (this.type == NPCID.VortexLarva)
                {
                    flag24 = false;
                }
                if (this.velocity.Y >= 0f)
                {
                    int num204 = 0;
                    if (this.velocity.X < 0f)
                    {
                        num204 = -1;
                    }
                    if (this.velocity.X > 0f)
                    {
                        num204 = 1;
                    }
                    Vector2 position2 = this.position;
                    position2.X += this.velocity.X;
                    int num205 = (int)((position2.X + (float)(this.width / 2) + (float)((this.width / 2 + 1) * num204)) / 16f);
                    int num206 = (int)((position2.Y + (float)this.height - 1f) / 16f);
                    if (Main.tile[num205, num206] == null)
                    {
                        Main.tile[num205, num206] = new Tile();
                    }
                    if (Main.tile[num205, num206 - 1] == null)
                    {
                        Main.tile[num205, num206 - 1] = new Tile();
                    }
                    if (Main.tile[num205, num206 - 2] == null)
                    {
                        Main.tile[num205, num206 - 2] = new Tile();
                    }
                    if (Main.tile[num205, num206 - 3] == null)
                    {
                        Main.tile[num205, num206 - 3] = new Tile();
                    }
                    if (Main.tile[num205, num206 + 1] == null)
                    {
                        Main.tile[num205, num206 + 1] = new Tile();
                    }
                    if (Main.tile[num205 - num204, num206 - 3] == null)
                    {
                        Main.tile[num205 - num204, num206 - 3] = new Tile();
                    }
                    if ((float)(num205 * 16) < position2.X + (float)this.width && (float)(num205 * 16 + 16) > position2.X && ((Main.tile[num205, num206].nactive() && !Main.tile[num205, num206].topSlope() && !Main.tile[num205, num206 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num205, num206].type] && !Main.tileSolidTop[(int)Main.tile[num205, num206].type]) || (Main.tile[num205, num206 - 1].halfBrick() && Main.tile[num205, num206 - 1].nactive())) && (!Main.tile[num205, num206 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num205, num206 - 1].type] || Main.tileSolidTop[(int)Main.tile[num205, num206 - 1].type] || (Main.tile[num205, num206 - 1].halfBrick() && (!Main.tile[num205, num206 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num205, num206 - 4].type] || Main.tileSolidTop[(int)Main.tile[num205, num206 - 4].type]))) && (!Main.tile[num205, num206 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num205, num206 - 2].type] || Main.tileSolidTop[(int)Main.tile[num205, num206 - 2].type]) && (!Main.tile[num205, num206 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num205, num206 - 3].type] || Main.tileSolidTop[(int)Main.tile[num205, num206 - 3].type]) && (!Main.tile[num205 - num204, num206 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num205 - num204, num206 - 3].type]))
                    {
                        float num207 = (float)(num206 * 16);
                        if (Main.tile[num205, num206].halfBrick())
                        {
                            num207 += 8f;
                        }
                        if (Main.tile[num205, num206 - 1].halfBrick())
                        {
                            num207 -= 8f;
                        }
                        if (num207 < position2.Y + (float)this.height)
                        {
                            float num208 = position2.Y + (float)this.height - num207;
                            float num209 = 16.1f;
                            if (this.type == NPCID.BlackRecluse || this.type == NPCID.WallCreeper || this.type == NPCID.JungleCreeper || this.type == NPCID.BloodCrawler || this.type == NPCID.DesertScorpionWalk)
                            {
                                num209 += 8f;
                            }
                            if (num208 <= num209)
                            {
                                this.gfxOffY += this.position.Y + (float)this.height - num207;
                                this.position.Y = num207 - (float)this.height;
                                if (num208 < 9f)
                                {
                                    this.stepSpeed = 1f;
                                }
                                else
                                {
                                    this.stepSpeed = 2f;
                                }
                            }
                        }
                    }
                }
                if (flag24)
                {
                    int num210 = (int)((this.position.X + (float)(this.width / 2) + (float)(15 * this.direction)) / 16f);
                    int num211 = (int)((this.position.Y + (float)this.height - 15f) / 16f);
                    if (this.type == NPCID.Clown || this.type == NPCID.BlackRecluse || this.type == NPCID.WallCreeper || this.type == NPCID.LihzahrdCrawler || this.type == NPCID.JungleCreeper || this.type == NPCID.BloodCrawler || this.type == NPCID.AnomuraFungus || this.type == NPCID.MushiLadybug || this.type == NPCID.Paladin || this.type == NPCID.Scutlix || this.type == NPCID.VortexRifleman || this.type == NPCID.VortexHornet || this.type == NPCID.VortexHornetQueen || this.type == NPCID.WalkingAntlion || this.type == NPCID.SolarDrakomire || this.type == NPCID.DesertScorpionWalk || this.type == NPCID.DesertBeast)
                    {
                        num210 = (int)((this.position.X + (float)(this.width / 2) + (float)((this.width / 2 + 16) * this.direction)) / 16f);
                    }
                    if (Main.tile[num210, num211] == null)
                    {
                        Main.tile[num210, num211] = new Tile();
                    }
                    if (Main.tile[num210, num211 - 1] == null)
                    {
                        Main.tile[num210, num211 - 1] = new Tile();
                    }
                    if (Main.tile[num210, num211 - 2] == null)
                    {
                        Main.tile[num210, num211 - 2] = new Tile();
                    }
                    if (Main.tile[num210, num211 - 3] == null)
                    {
                        Main.tile[num210, num211 - 3] = new Tile();
                    }
                    if (Main.tile[num210, num211 + 1] == null)
                    {
                        Main.tile[num210, num211 + 1] = new Tile();
                    }
                    if (Main.tile[num210 + this.direction, num211 - 1] == null)
                    {
                        Main.tile[num210 + this.direction, num211 - 1] = new Tile();
                    }
                    if (Main.tile[num210 + this.direction, num211 + 1] == null)
                    {
                        Main.tile[num210 + this.direction, num211 + 1] = new Tile();
                    }
                    if (Main.tile[num210 - this.direction, num211 + 1] == null)
                    {
                        Main.tile[num210 - this.direction, num211 + 1] = new Tile();
                    }
                    Main.tile[num210, num211 + 1].halfBrick();
                    if (Main.tile[num210, num211 - 1].nactive() && (Main.tile[num210, num211 - 1].type == 10 || Main.tile[num210, num211 - 1].type == 388) && flag7)
                    {
                        this.ai[2] += 1f;
                        this.ai[3] = 0f;
                        if (this.ai[2] >= 60f)
                        {
                            if (!Main.bloodMoon && (this.type == NPCID.Zombie || this.type == NPCID.ZombieXmas || this.type == NPCID.ZombieSweater || this.type == NPCID.BaldZombie || this.type == NPCID.ZombieEskimo || this.type == NPCID.PincushionZombie || this.type == NPCID.SlimedZombie || this.type == NPCID.SwampZombie || this.type == NPCID.TwiggyZombie || this.type == NPCID.FemaleZombie || this.type == NPCID.ZombieRaincoat || this.type == NPCID.ZombieSuperman || this.type == NPCID.ZombiePixie || this.type == NPCID.ZombieDoctor))
                            {
                                this.ai[1] = 0f;
                            }
                            this.velocity.X = 0.5f * (float)(-(float)this.direction);
                            int num212 = 5;
                            if (Main.tile[num210, num211 - 1].type == 388)
                            {
                                num212 = 2;
                            }
                            this.ai[1] += (float)num212;
                            if (this.type == NPCID.GoblinThief)
                            {
                                this.ai[1] += 1f;
                            }
                            if (this.type == NPCID.AngryBones || this.type == NPCID.AngryBonesBig || this.type == NPCID.AngryBonesBigMuscle || this.type == NPCID.AngryBonesBigHelmet)
                            {
                                this.ai[1] += 6f;
                            }
                            this.ai[2] = 0f;
                            bool flag25 = false;
                            if (this.ai[1] >= 10f)
                            {
                                flag25 = true;
                                this.ai[1] = 10f;
                            }
                            if (this.type == NPCID.Butcher)
                            {
                                flag25 = true;
                            }
                            WorldGen.KillTile(num210, num211 - 1, true, false, false);
                            if ((Main.netMode != 1 || !flag25) && flag25 && Main.netMode != 1)
                            {
                                if (this.type == NPCID.GoblinPeon)
                                {
                                    WorldGen.KillTile(num210, num211 - 1, false, false, false);
                                    if (Main.netMode == 2)
                                    {
                                        NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)num210, (float)(num211 - 1), 0f, 0, 0, 0);
                                    }
                                }
                                else
                                {
                                    if (Main.tile[num210, num211 - 1].type == 10)
                                    {
                                        bool flag26 = WorldGen.OpenDoor(num210, num211 - 1, this.direction);
                                        if (!flag26)
                                        {
                                            this.ai[3] = (float)num67;
                                            this.netUpdate = true;
                                        }
                                        if (Main.netMode == 2 && flag26)
                                        {
                                            NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 0, (float)num210, (float)(num211 - 1), (float)this.direction, 0, 0, 0);
                                        }
                                    }
                                    if (Main.tile[num210, num211 - 1].type == 388)
                                    {
                                        bool flag27 = WorldGen.ShiftTallGate(num210, num211 - 1, false);
                                        if (!flag27)
                                        {
                                            this.ai[3] = (float)num67;
                                            this.netUpdate = true;
                                        }
                                        if (Main.netMode == 2 && flag27)
                                        {
                                            NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 4, (float)num210, (float)(num211 - 1), 0f, 0, 0, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        int num213 = this.spriteDirection;
                        if (this.type == NPCID.VortexRifleman)
                        {
                            num213 *= -1;
                        }
                        if ((this.velocity.X < 0f && num213 == -1) || (this.velocity.X > 0f && num213 == 1))
                        {
                            if (this.height >= 32 && Main.tile[num210, num211 - 2].nactive() && Main.tileSolid[(int)Main.tile[num210, num211 - 2].type])
                            {
                                if (Main.tile[num210, num211 - 3].nactive() && Main.tileSolid[(int)Main.tile[num210, num211 - 3].type])
                                {
                                    this.velocity.Y = -8f;
                                    this.netUpdate = true;
                                }
                                else
                                {
                                    this.velocity.Y = -7f;
                                    this.netUpdate = true;
                                }
                            }
                            else if (Main.tile[num210, num211 - 1].nactive() && Main.tileSolid[(int)Main.tile[num210, num211 - 1].type])
                            {
                                this.velocity.Y = -6f;
                                this.netUpdate = true;
                            }
                            else if (this.position.Y + (float)this.height - (float)(num211 * 16) > 20f && Main.tile[num210, num211].nactive() && !Main.tile[num210, num211].topSlope() && Main.tileSolid[(int)Main.tile[num210, num211].type])
                            {
                                this.velocity.Y = -5f;
                                this.netUpdate = true;
                            }
                            else if (this.directionY < 0 && this.type != NPCID.Crab && (!Main.tile[num210, num211 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num210, num211 + 1].type]) && (!Main.tile[num210 + this.direction, num211 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num210 + this.direction, num211 + 1].type]))
                            {
                                this.velocity.Y = -8f;
                                this.velocity.X = this.velocity.X * 1.5f;
                                this.netUpdate = true;
                            }
                            else if (flag7)
                            {
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                            }
                            if (this.velocity.Y == 0f && flag5 && this.ai[3] == 1f)
                            {
                                this.velocity.Y = -5f;
                            }
                        }
                        if ((this.type == NPCID.AngryBones || this.type == NPCID.AngryBonesBig || this.type == NPCID.AngryBonesBigMuscle || this.type == NPCID.AngryBonesBigHelmet || this.type == NPCID.CorruptBunny || this.type == NPCID.ArmoredSkeleton || this.type == NPCID.Werewolf || this.type == NPCID.CorruptPenguin || this.type == NPCID.Nymph || this.type == NPCID.GrayGrunt || this.type == NPCID.GigaZapper || this.type == NPCID.CrimsonBunny || this.type == NPCID.CrimsonPenguin || (this.type >= NPCID.DesertGhoul && this.type <= NPCID.DesertGhoulHallow)) && this.velocity.Y == 0f && Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) < 100f && Math.Abs(this.position.Y + (float)(this.height / 2) - (Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))) < 50f && ((this.direction > 0 && this.velocity.X >= 1f) || (this.direction < 0 && this.velocity.X <= -1f)))
                        {
                            this.velocity.X = this.velocity.X * 2f;
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = 3f;
                            }
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = -3f;
                            }
                            this.velocity.Y = -4f;
                            this.netUpdate = true;
                        }
                        if (this.type == NPCID.ChaosElemental && this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 1.1f;
                        }
                        if (this.type == NPCID.BoneLee && this.velocity.Y == 0f && Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) < 150f && Math.Abs(this.position.Y + (float)(this.height / 2) - (Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))) < 50f && ((this.direction > 0 && this.velocity.X >= 1f) || (this.direction < 0 && this.velocity.X <= -1f)))
                        {
                            this.velocity.X = (float)(8 * this.direction);
                            this.velocity.Y = -4f;
                            this.netUpdate = true;
                        }
                        if (this.type == NPCID.BoneLee && this.velocity.Y < 0f)
                        {
                            this.velocity.X = this.velocity.X * 1.2f;
                            this.velocity.Y = this.velocity.Y * 1.1f;
                        }
                        if (this.type == NPCID.Butcher && this.velocity.Y < 0f)
                        {
                            this.velocity.X = this.velocity.X * 1.3f;
                            this.velocity.Y = this.velocity.Y * 1.1f;
                        }
                    }
                }
                else if (flag7)
                {
                    this.ai[1] = 0f;
                    this.ai[2] = 0f;
                }
                if (Main.netMode != 1 && this.type == NPCID.ChaosElemental && this.ai[3] >= (float)num67)
                {
                    int num214 = (int)Main.player[this.target].position.X / 16;
                    int num215 = (int)Main.player[this.target].position.Y / 16;
                    int num216 = (int)this.position.X / 16;
                    int num217 = (int)this.position.Y / 16;
                    int num218 = 20;
                    int num219 = 0;
                    bool flag28 = false;
                    if (Math.Abs(this.position.X - Main.player[this.target].position.X) + Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                    {
                        num219 = 100;
                        flag28 = true;
                    }
                    while (!flag28)
                    {
                        if (num219 >= 100)
                        {
                            return;
                        }
                        num219++;
                        int num220 = Main.rand.Next(num214 - num218, num214 + num218);
                        int num221 = Main.rand.Next(num215 - num218, num215 + num218);
                        for (int num222 = num221; num222 < num215 + num218; num222++)
                        {
                            if ((num222 < num215 - 4 || num222 > num215 + 4 || num220 < num214 - 4 || num220 > num214 + 4) && (num222 < num217 - 1 || num222 > num217 + 1 || num220 < num216 - 1 || num220 > num216 + 1) && Main.tile[num220, num222].nactive())
                            {
                                bool flag29 = true;
                                if (this.type == NPCID.DarkCaster && Main.tile[num220, num222 - 1].wall == 0)
                                {
                                    flag29 = false;
                                }
                                else if (Main.tile[num220, num222 - 1].lava())
                                {
                                    flag29 = false;
                                }
                                if (flag29 && Main.tileSolid[(int)Main.tile[num220, num222].type] && !Collision.SolidTiles(num220 - 1, num220 + 1, num222 - 4, num222 - 1))
                                {
                                    this.position.X = (float)(num220 * 16 - this.width / 2);
                                    this.position.Y = (float)(num222 * 16 - this.height);
                                    this.netUpdate = true;
                                    this.ai[3] = -120f;
                                }
                            }
                        }
                    }
                }
            }
            else if (this.aiStyle == 4)
            {
                bool flag30 = false;
                if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.12)
                {
                    flag30 = true;
                }
                bool flag31 = false;
                if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.04)
                {
                    flag31 = true;
                }
                float num223 = 20f;
                if (flag31)
                {
                    num223 = 10f;
                }
                if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                {
                    this.TargetClosest(true);
                }
                bool dead = Main.player[this.target].dead;
                float num224 = this.position.X + (float)(this.width / 2) - Main.player[this.target].position.X - (float)(Main.player[this.target].width / 2);
                float num225 = this.position.Y + (float)this.height - 59f - Main.player[this.target].position.Y - (float)(Main.player[this.target].height / 2);
                float num226 = (float)Math.Atan2((double)num225, (double)num224) + 1.57f;
                if (num226 < 0f)
                {
                    num226 += 6.283f;
                }
                else if ((double)num226 > 6.283)
                {
                    num226 -= 6.283f;
                }
                float num227 = 0f;
                if (this.ai[0] == 0f && this.ai[1] == 0f)
                {
                    num227 = 0.02f;
                }
                if (this.ai[0] == 0f && this.ai[1] == 2f && this.ai[2] > 40f)
                {
                    num227 = 0.05f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 0f)
                {
                    num227 = 0.05f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 2f && this.ai[2] > 40f)
                {
                    num227 = 0.08f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 4f && this.ai[2] > num223)
                {
                    num227 = 0.15f;
                }
                if (this.ai[0] == 3f && this.ai[1] == 5f)
                {
                    num227 = 0.05f;
                }
                if (Main.expertMode)
                {
                    num227 *= 1.5f;
                }
                if (flag31 && Main.expertMode)
                {
                    num227 = 0f;
                }
                if (this.rotation < num226)
                {
                    if ((double)(num226 - this.rotation) > 3.1415)
                    {
                        this.rotation -= num227;
                    }
                    else
                    {
                        this.rotation += num227;
                    }
                }
                else if (this.rotation > num226)
                {
                    if ((double)(this.rotation - num226) > 3.1415)
                    {
                        this.rotation += num227;
                    }
                    else
                    {
                        this.rotation -= num227;
                    }
                }
                if (this.rotation > num226 - num227 && this.rotation < num226 + num227)
                {
                    this.rotation = num226;
                }
                if (this.rotation < 0f)
                {
                    this.rotation += 6.283f;
                }
                else if ((double)this.rotation > 6.283)
                {
                    this.rotation -= 6.283f;
                }
                if (this.rotation > num226 - num227 && this.rotation < num226 + num227)
                {
                    this.rotation = num226;
                }
                if (Main.dayTime || dead)
                {
                    this.velocity.Y = this.velocity.Y - 0.04f;
                    if (this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                        return;
                    }
                }
                else if (this.ai[0] == 0f)
                {
                    if (this.ai[1] == 0f)
                    {
                        float num229 = 5f;
                        float num230 = 0.04f;
                        if (Main.expertMode)
                        {
                            num230 = 0.15f;
                            num229 = 7f;
                        }
                        Vector2 vector26 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num231 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector26.X;
                        float num232 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 200f - vector26.Y;
                        float num233 = (float)Math.Sqrt((double)(num231 * num231 + num232 * num232));
                        float num234 = num233;
                        num233 = num229 / num233;
                        num231 *= num233;
                        num232 *= num233;
                        if (this.velocity.X < num231)
                        {
                            this.velocity.X = this.velocity.X + num230;
                            if (this.velocity.X < 0f && num231 > 0f)
                            {
                                this.velocity.X = this.velocity.X + num230;
                            }
                        }
                        else if (this.velocity.X > num231)
                        {
                            this.velocity.X = this.velocity.X - num230;
                            if (this.velocity.X > 0f && num231 < 0f)
                            {
                                this.velocity.X = this.velocity.X - num230;
                            }
                        }
                        if (this.velocity.Y < num232)
                        {
                            this.velocity.Y = this.velocity.Y + num230;
                            if (this.velocity.Y < 0f && num232 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num230;
                            }
                        }
                        else if (this.velocity.Y > num232)
                        {
                            this.velocity.Y = this.velocity.Y - num230;
                            if (this.velocity.Y > 0f && num232 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num230;
                            }
                        }
                        this.ai[2] += 1f;
                        float num235 = 600f;
                        if (Main.expertMode)
                        {
                            num235 *= 0.35f;
                        }
                        if (this.ai[2] >= num235)
                        {
                            this.ai[1] = 1f;
                            this.ai[2] = 0f;
                            this.ai[3] = 0f;
                            this.target = 255;
                            this.netUpdate = true;
                        }
                        else if ((this.position.Y + (float)this.height < Main.player[this.target].position.Y && num234 < 500f) || (Main.expertMode && num234 < 500f))
                        {
                            if (!Main.player[this.target].dead)
                            {
                                this.ai[3] += 1f;
                            }
                            float num236 = 110f;
                            if (Main.expertMode)
                            {
                                num236 *= 0.4f;
                            }
                            if (this.ai[3] >= num236)
                            {
                                this.ai[3] = 0f;
                                this.rotation = num226;
                                float num237 = 5f;
                                if (Main.expertMode)
                                {
                                    num237 = 6f;
                                }
                                float num238 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector26.X;
                                float num239 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector26.Y;
                                float num240 = (float)Math.Sqrt((double)(num238 * num238 + num239 * num239));
                                num240 = num237 / num240;
                                Vector2 position3 = vector26;
                                Vector2 vector27;
                                vector27.X = num238 * num240;
                                vector27.Y = num239 * num240;
                                position3.X += vector27.X * 10f;
                                position3.Y += vector27.Y * 10f;
                                if (Main.netMode != 1)
                                {
                                    int num241 = NPC.NewNPC((int)position3.X, (int)position3.Y, 5, 0, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num241].velocity.X = vector27.X;
                                    Main.npc[num241].velocity.Y = vector27.Y;
                                    if (Main.netMode == 2 && num241 < 200)
                                    {
                                        NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num241, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                }
                            }
                        }
                    }
                    else if (this.ai[1] == 1f)
                    {
                        this.rotation = num226;
                        float num243 = 6f;
                        if (Main.expertMode)
                        {
                            num243 = 7f;
                        }
                        Vector2 vector28 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num244 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector28.X;
                        float num245 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector28.Y;
                        float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245));
                        num246 = num243 / num246;
                        this.velocity.X = num244 * num246;
                        this.velocity.Y = num245 * num246;
                        this.ai[1] = 2f;
                        this.netUpdate = true;
                        if (this.netSpam > 10)
                        {
                            this.netSpam = 10;
                        }
                    }
                    else if (this.ai[1] == 2f)
                    {
                        this.ai[2] += 1f;
                        if (this.ai[2] >= 40f)
                        {
                            this.velocity *= 0.98f;
                            if (Main.expertMode)
                            {
                                this.velocity *= 0.985f;
                            }
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                            }
                        }
                        else
                        {
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                        }
                        int num247 = 150;
                        if (Main.expertMode)
                        {
                            num247 = 100;
                        }
                        if (this.ai[2] >= (float)num247)
                        {
                            this.ai[3] += 1f;
                            this.ai[2] = 0f;
                            this.target = 255;
                            this.rotation = num226;
                            if (this.ai[3] >= 3f)
                            {
                                this.ai[1] = 0f;
                                this.ai[3] = 0f;
                            }
                            else
                            {
                                this.ai[1] = 1f;
                            }
                        }
                    }
                    float num248 = 0.5f;
                    if (Main.expertMode)
                    {
                        num248 = 0.65f;
                    }
                    if ((float)this.life < (float)this.lifeMax * num248)
                    {
                        this.ai[0] = 1f;
                        this.ai[1] = 0f;
                        this.ai[2] = 0f;
                        this.ai[3] = 0f;
                        this.netUpdate = true;
                        if (this.netSpam > 10)
                        {
                            this.netSpam = 10;
                            return;
                        }
                    }
                }
                else if (this.ai[0] == 1f || this.ai[0] == 2f)
                {
                    if (this.ai[0] == 1f)
                    {
                        this.ai[2] += 0.005f;
                        if ((double)this.ai[2] > 0.5)
                        {
                            this.ai[2] = 0.5f;
                        }
                    }
                    else
                    {
                        this.ai[2] -= 0.005f;
                        if (this.ai[2] < 0f)
                        {
                            this.ai[2] = 0f;
                        }
                    }
                    this.rotation += this.ai[2];
                    this.ai[1] += 1f;
                    if (Main.expertMode && this.ai[1] % 20f == 0f)
                    {
                        float num249 = 5f;
                        Vector2 vector29 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num250 = (float)Main.rand.Next(-200, 200);
                        float num251 = (float)Main.rand.Next(-200, 200);
                        float num252 = (float)Math.Sqrt((double)(num250 * num250 + num251 * num251));
                        num252 = num249 / num252;
                        Vector2 position4 = vector29;
                        Vector2 vector30;
                        vector30.X = num250 * num252;
                        vector30.Y = num251 * num252;
                        position4.X += vector30.X * 10f;
                        position4.Y += vector30.Y * 10f;
                        if (Main.netMode != 1)
                        {
                            int num253 = NPC.NewNPC((int)position4.X, (int)position4.Y, 5, 0, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num253].velocity.X = vector30.X;
                            Main.npc[num253].velocity.Y = vector30.Y;
                            if (Main.netMode == 2 && num253 < 200)
                            {
                                NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num253, 0f, 0f, 0f, 0, 0, 0);
                            }
                        }
                    }
                    if (this.ai[1] == 100f)
                    {
                        this.ai[0] += 1f;
                        this.ai[1] = 0f;
                        if (this.ai[0] == 3f)
                        {
                            this.ai[2] = 0f;
                        }
                    }
                    this.velocity.X *= 0.98f;
                    this.velocity.Y *= 0.98f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                    }
                    if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                    {
                        this.velocity.Y = 0f;
                        return;
                    }
                }
                else
                {
                    this.defense = 0;
                    this.damage = 23;
                    if (Main.expertMode)
                    {
                        if (flag30)
                        {
                            this.defense = -15;
                        }
                        if (flag31)
                        {
                            this.damage = (int)(20f * Main.expertDamage);
                            this.defense = -30;
                        }
                        else
                        {
                            this.damage = (int)(18f * Main.expertDamage);
                        }
                    }
                    if (this.ai[1] == 0f && flag30)
                    {
                        this.ai[1] = 5f;
                    }
                    if (this.ai[1] == 0f)
                    {
                        float num257 = 6f;
                        float num258 = 0.07f;
                        Vector2 vector31 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num259 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector31.X;
                        float num260 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 120f - vector31.Y;
                        float num261 = (float)Math.Sqrt((double)(num259 * num259 + num260 * num260));
                        if (num261 > 400f && Main.expertMode)
                        {
                            num257 += 1f;
                            num258 += 0.05f;
                            if (num261 > 600f)
                            {
                                num257 += 1f;
                                num258 += 0.05f;
                                if (num261 > 800f)
                                {
                                    num257 += 1f;
                                    num258 += 0.05f;
                                }
                            }
                        }
                        num261 = num257 / num261;
                        num259 *= num261;
                        num260 *= num261;
                        if (this.velocity.X < num259)
                        {
                            this.velocity.X = this.velocity.X + num258;
                            if (this.velocity.X < 0f && num259 > 0f)
                            {
                                this.velocity.X = this.velocity.X + num258;
                            }
                        }
                        else if (this.velocity.X > num259)
                        {
                            this.velocity.X = this.velocity.X - num258;
                            if (this.velocity.X > 0f && num259 < 0f)
                            {
                                this.velocity.X = this.velocity.X - num258;
                            }
                        }
                        if (this.velocity.Y < num260)
                        {
                            this.velocity.Y = this.velocity.Y + num258;
                            if (this.velocity.Y < 0f && num260 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num258;
                            }
                        }
                        else if (this.velocity.Y > num260)
                        {
                            this.velocity.Y = this.velocity.Y - num258;
                            if (this.velocity.Y > 0f && num260 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num258;
                            }
                        }
                        this.ai[2] += 1f;
                        if (this.ai[2] >= 200f)
                        {
                            this.ai[1] = 1f;
                            this.ai[2] = 0f;
                            this.ai[3] = 0f;
                            if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.35)
                            {
                                this.ai[1] = 3f;
                            }
                            this.target = 255;
                            this.netUpdate = true;
                        }
                        if (Main.expertMode && flag31)
                        {
                            this.TargetClosest(true);
                            this.netUpdate = true;
                            this.ai[1] = 3f;
                            this.ai[2] = 0f;
                            this.ai[3] -= 1000f;
                        }
                    }
                    else if (this.ai[1] == 1f)
                    {
                        this.rotation = num226;
                        float num262 = 6.8f;
                        if (Main.expertMode && this.ai[3] == 1f)
                        {
                            num262 *= 1.15f;
                        }
                        if (Main.expertMode && this.ai[3] == 2f)
                        {
                            num262 *= 1.3f;
                        }
                        Vector2 vector32 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num263 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector32.X;
                        float num264 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector32.Y;
                        float num265 = (float)Math.Sqrt((double)(num263 * num263 + num264 * num264));
                        num265 = num262 / num265;
                        this.velocity.X = num263 * num265;
                        this.velocity.Y = num264 * num265;
                        this.ai[1] = 2f;
                        this.netUpdate = true;
                        if (this.netSpam > 10)
                        {
                            this.netSpam = 10;
                        }
                    }
                    else if (this.ai[1] == 2f)
                    {
                        float num266 = 40f;
                        this.ai[2] += 1f;
                        if (Main.expertMode)
                        {
                            num266 = 50f;
                        }
                        if (this.ai[2] >= num266)
                        {
                            this.velocity *= 0.97f;
                            if (Main.expertMode)
                            {
                                this.velocity *= 0.98f;
                            }
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                            }
                        }
                        else
                        {
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                        }
                        int num267 = 130;
                        if (Main.expertMode)
                        {
                            num267 = 90;
                        }
                        if (this.ai[2] >= (float)num267)
                        {
                            this.ai[3] += 1f;
                            this.ai[2] = 0f;
                            this.target = 255;
                            this.rotation = num226;
                            if (this.ai[3] >= 3f)
                            {
                                this.ai[1] = 0f;
                                this.ai[3] = 0f;
                                if (Main.expertMode && Main.netMode != 1 && (double)this.life < (double)this.lifeMax * 0.5)
                                {
                                    this.ai[1] = 3f;
                                    this.ai[3] += (float)Main.rand.Next(1, 4);
                                }
                                this.netUpdate = true;
                                if (this.netSpam > 10)
                                {
                                    this.netSpam = 10;
                                }
                            }
                            else
                            {
                                this.ai[1] = 1f;
                            }
                        }
                    }
                    else if (this.ai[1] == 3f)
                    {
                        if (this.ai[3] == 4f && flag30 && base.Center.Y > Main.player[this.target].Center.Y)
                        {
                            this.TargetClosest(true);
                            this.ai[1] = 0f;
                            this.ai[2] = 0f;
                            this.ai[3] = 0f;
                            this.netUpdate = true;
                            if (this.netSpam > 10)
                            {
                                this.netSpam = 10;
                            }
                        }
                        else if (Main.netMode != 1)
                        {
                            this.TargetClosest(true);
                            float num268 = 20f;
                            Vector2 vector33 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num269 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector33.X;
                            float num270 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector33.Y;
                            float num271 = Math.Abs(Main.player[this.target].velocity.X) + Math.Abs(Main.player[this.target].velocity.Y) / 4f;
                            num271 += 10f - num271;
                            if (num271 < 5f)
                            {
                                num271 = 5f;
                            }
                            if (num271 > 15f)
                            {
                                num271 = 15f;
                            }
                            if (this.ai[2] == -1f && !flag31)
                            {
                                num271 *= 4f;
                                num268 *= 1.3f;
                            }
                            if (flag31)
                            {
                                num271 *= 2f;
                            }
                            num269 -= Main.player[this.target].velocity.X * num271;
                            num270 -= Main.player[this.target].velocity.Y * num271 / 4f;
                            num269 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f;
                            num270 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f;
                            if (flag31)
                            {
                                num269 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f;
                                num270 *= 1f + (float)Main.rand.Next(-10, 11) * 0.01f;
                            }
                            float num272 = (float)Math.Sqrt((double)(num269 * num269 + num270 * num270));
                            float num273 = num272;
                            num272 = num268 / num272;
                            this.velocity.X = num269 * num272;
                            this.velocity.Y = num270 * num272;
                            this.velocity.X = this.velocity.X + (float)Main.rand.Next(-20, 21) * 0.1f;
                            this.velocity.Y = this.velocity.Y + (float)Main.rand.Next(-20, 21) * 0.1f;
                            if (flag31)
                            {
                                this.velocity.X = this.velocity.X + (float)Main.rand.Next(-50, 51) * 0.1f;
                                this.velocity.Y = this.velocity.Y + (float)Main.rand.Next(-50, 51) * 0.1f;
                                float num274 = Math.Abs(this.velocity.X);
                                float num275 = Math.Abs(this.velocity.Y);
                                if (base.Center.X > Main.player[this.target].Center.X)
                                {
                                    num275 *= -1f;
                                }
                                if (base.Center.Y > Main.player[this.target].Center.Y)
                                {
                                    num274 *= -1f;
                                }
                                this.velocity.X = num275 + this.velocity.X;
                                this.velocity.Y = num274 + this.velocity.Y;
                                this.velocity.Normalize();
                                this.velocity *= num268;
                                this.velocity.X = this.velocity.X + (float)Main.rand.Next(-20, 21) * 0.1f;
                                this.velocity.Y = this.velocity.Y + (float)Main.rand.Next(-20, 21) * 0.1f;
                            }
                            else if (num273 < 100f)
                            {
                                if (Math.Abs(this.velocity.X) > Math.Abs(this.velocity.Y))
                                {
                                    float num276 = Math.Abs(this.velocity.X);
                                    float num277 = Math.Abs(this.velocity.Y);
                                    if (base.Center.X > Main.player[this.target].Center.X)
                                    {
                                        num277 *= -1f;
                                    }
                                    if (base.Center.Y > Main.player[this.target].Center.Y)
                                    {
                                        num276 *= -1f;
                                    }
                                    this.velocity.X = num277;
                                    this.velocity.Y = num276;
                                }
                            }
                            else if (Math.Abs(this.velocity.X) > Math.Abs(this.velocity.Y))
                            {
                                float num278 = (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) / 2f;
                                float num279 = num278;
                                if (base.Center.X > Main.player[this.target].Center.X)
                                {
                                    num279 *= -1f;
                                }
                                if (base.Center.Y > Main.player[this.target].Center.Y)
                                {
                                    num278 *= -1f;
                                }
                                this.velocity.X = num279;
                                this.velocity.Y = num278;
                            }
                            this.ai[1] = 4f;
                            this.netUpdate = true;
                            if (this.netSpam > 10)
                            {
                                this.netSpam = 10;
                            }
                        }
                    }
                    else if (this.ai[1] == 4f)
                    {
                        float num280 = num223;
                        this.ai[2] += 1f;
                        if (this.ai[2] == num280 && Vector2.Distance(this.position, Main.player[this.target].position) < 200f)
                        {
                            this.ai[2] -= 1f;
                        }
                        if (this.ai[2] >= num280)
                        {
                            this.velocity *= 0.95f;
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                            }
                        }
                        else
                        {
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                        }
                        float num281 = num280 + 13f;
                        if (this.ai[2] >= num281)
                        {
                            this.netUpdate = true;
                            if (this.netSpam > 10)
                            {
                                this.netSpam = 10;
                            }
                            this.ai[3] += 1f;
                            this.ai[2] = 0f;
                            if (this.ai[3] >= 5f)
                            {
                                this.ai[1] = 0f;
                                this.ai[3] = 0f;
                            }
                            else
                            {
                                this.ai[1] = 3f;
                            }
                        }
                    }
                    else if (this.ai[1] == 5f)
                    {
                        float num282 = 600f;
                        float num283 = 9f;
                        float num284 = 0.3f;
                        Vector2 vector34 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num285 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector34.X;
                        float num286 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) + num282 - vector34.Y;
                        float num287 = (float)Math.Sqrt((double)(num285 * num285 + num286 * num286));
                        num287 = num283 / num287;
                        num285 *= num287;
                        num286 *= num287;
                        if (this.velocity.X < num285)
                        {
                            this.velocity.X = this.velocity.X + num284;
                            if (this.velocity.X < 0f && num285 > 0f)
                            {
                                this.velocity.X = this.velocity.X + num284;
                            }
                        }
                        else if (this.velocity.X > num285)
                        {
                            this.velocity.X = this.velocity.X - num284;
                            if (this.velocity.X > 0f && num285 < 0f)
                            {
                                this.velocity.X = this.velocity.X - num284;
                            }
                        }
                        if (this.velocity.Y < num286)
                        {
                            this.velocity.Y = this.velocity.Y + num284;
                            if (this.velocity.Y < 0f && num286 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num284;
                            }
                        }
                        else if (this.velocity.Y > num286)
                        {
                            this.velocity.Y = this.velocity.Y - num284;
                            if (this.velocity.Y > 0f && num286 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num284;
                            }
                        }
                        this.ai[2] += 1f;
                        if (this.ai[2] >= 70f)
                        {
                            this.TargetClosest(true);
                            this.ai[1] = 3f;
                            this.ai[2] = -1f;
                            this.ai[3] = (float)Main.rand.Next(-3, 1);
                            this.netUpdate = true;
                        }
                    }
                    if (flag31 && this.ai[1] == 5f)
                    {
                        this.ai[1] = 3f;
                        return;
                    }
                }
            }
            else if (this.aiStyle == 5)
            {
                if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                {
                    this.TargetClosest(true);
                }
                float num288 = 6f;
                float num289 = 0.05f;
                if (this.type == NPCID.EaterofSouls || this.type == NPCID.Crimera)
                {
                    num288 = 4f;
                    num289 = 0.02f;
                    if (this.type == NPCID.EaterofSouls && Main.expertMode)
                    {
                        num289 = 0.035f;
                    }
                }
                else if (this.type == NPCID.Corruptor)
                {
                    num288 = 4.2f;
                    num289 = 0.022f;
                }
                else if (this.type == NPCID.Parrot)
                {
                    if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        num288 = 6f;
                        num289 = 0.1f;
                    }
                    else
                    {
                        num289 = 0.01f;
                        num288 = 2f;
                    }
                }
                else if (this.type == NPCID.Hornet || (this.type >= NPCID.HornetFatty && this.type <= NPCID.HornetStingy))
                {
                    num288 = 3.5f;
                    num289 = 0.021f;
                    if (this.type == NPCID.HornetFatty)
                    {
                        num288 = 3f;
                        num289 = 0.017f;
                    }
                    num288 *= 1f - this.scale;
                    num289 *= 1f - this.scale;
                }
                else if (this.type == NPCID.Moth)
                {
                    num288 = 3.25f;
                    num289 = 0.018f;
                }
                else if (this.type == NPCID.MossHornet)
                {
                    num288 = 4f;
                    num289 = 0.017f;
                }
                else if (this.type == NPCID.MeteorHead)
                {
                    num288 = 1f;
                    num289 = 0.03f;
                }
                else if (this.type == NPCID.ServantofCthulhu)
                {
                    num288 = 5f;
                    num289 = 0.03f;
                }
                else if (this.type == NPCID.Bee || this.type == NPCID.BeeSmall)
                {
                    this.localAI[0] += 1f;
                    float num290 = (this.localAI[0] - 60f) / 60f;
                    if (num290 > 1f)
                    {
                        num290 = 1f;
                    }
                    else
                    {
                        if (this.velocity.X > 6f)
                        {
                            this.velocity.X = 6f;
                        }
                        if (this.velocity.X < -6f)
                        {
                            this.velocity.X = -6f;
                        }
                        if (this.velocity.Y > 6f)
                        {
                            this.velocity.Y = 6f;
                        }
                        if (this.velocity.Y < -6f)
                        {
                            this.velocity.Y = -6f;
                        }
                    }
                    num288 = 5f;
                    num289 = 0.1f;
                    num289 *= num290;
                }
                Vector2 vector35 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num291 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                float num292 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                num291 = (float)((int)(num291 / 8f) * 8);
                num292 = (float)((int)(num292 / 8f) * 8);
                vector35.X = (float)((int)(vector35.X / 8f) * 8);
                vector35.Y = (float)((int)(vector35.Y / 8f) * 8);
                num291 -= vector35.X;
                num292 -= vector35.Y;
                float num293 = (float)Math.Sqrt((double)(num291 * num291 + num292 * num292));
                float num294 = num293;
                bool flag32 = false;
                if (num293 > 600f)
                {
                    flag32 = true;
                }
                if (num293 == 0f)
                {
                    num291 = this.velocity.X;
                    num292 = this.velocity.Y;
                }
                else
                {
                    num293 = num288 / num293;
                    num291 *= num293;
                    num292 *= num293;
                }
                if (this.type == NPCID.EaterofSouls || this.type == NPCID.Hornet || this.type == NPCID.Corruptor || this.type == NPCID.Probe || this.type == NPCID.Crimera || this.type == NPCID.MossHornet || this.type == NPCID.Moth || this.type == NPCID.Bee || this.type == NPCID.BeeSmall || (this.type >= NPCID.HornetFatty && this.type <= NPCID.HornetStingy))
                {
                    if (num294 > 100f || this.type == NPCID.Hornet || this.type == NPCID.Corruptor || this.type == NPCID.MossHornet || this.type == NPCID.Bee || this.type == NPCID.BeeSmall || (this.type >= NPCID.HornetFatty && this.type <= NPCID.HornetStingy))
                    {
                        this.ai[0] += 1f;
                        if (this.ai[0] > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.023f;
                        }
                        else
                        {
                            this.velocity.Y = this.velocity.Y - 0.023f;
                        }
                        if (this.ai[0] < -100f || this.ai[0] > 100f)
                        {
                            this.velocity.X = this.velocity.X + 0.023f;
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X - 0.023f;
                        }
                        if (this.ai[0] > 200f)
                        {
                            this.ai[0] = -200f;
                        }
                    }
                    if (num294 < 150f && (this.type == NPCID.EaterofSouls || this.type == NPCID.Corruptor || this.type == NPCID.Crimera))
                    {
                        this.velocity.X = this.velocity.X + num291 * 0.007f;
                        this.velocity.Y = this.velocity.Y + num292 * 0.007f;
                    }
                }
                if (Main.player[this.target].dead)
                {
                    num291 = (float)this.direction * num288 / 2f;
                    num292 = -num288 / 2f;
                }
                if (this.velocity.X < num291)
                {
                    this.velocity.X = this.velocity.X + num289;
                    if (this.type != NPCID.Crimera && this.type != NPCID.EaterofSouls && this.type != NPCID.Hornet && (this.type < 231 || this.type > 235) && this.type != NPCID.Corruptor && this.type != NPCID.Probe && this.velocity.X < 0f && num291 > 0f)
                    {
                        this.velocity.X = this.velocity.X + num289;
                    }
                }
                else if (this.velocity.X > num291)
                {
                    this.velocity.X = this.velocity.X - num289;
                    if (this.type != NPCID.Crimera && this.type != NPCID.EaterofSouls && this.type != NPCID.Hornet && (this.type < 231 || this.type > 235) && this.type != NPCID.Corruptor && this.type != NPCID.Probe && this.velocity.X > 0f && num291 < 0f)
                    {
                        this.velocity.X = this.velocity.X - num289;
                    }
                }
                if (this.velocity.Y < num292)
                {
                    this.velocity.Y = this.velocity.Y + num289;
                    if (this.type != NPCID.Crimera && this.type != NPCID.EaterofSouls && this.type != NPCID.Hornet && (this.type < 231 || this.type > 235) && this.type != NPCID.Corruptor && this.type != NPCID.Probe && this.velocity.Y < 0f && num292 > 0f)
                    {
                        this.velocity.Y = this.velocity.Y + num289;
                    }
                }
                else if (this.velocity.Y > num292)
                {
                    this.velocity.Y = this.velocity.Y - num289;
                    if (this.type != NPCID.Crimera && this.type != NPCID.EaterofSouls && this.type != NPCID.Hornet && (this.type < 231 || this.type > 235) && this.type != NPCID.Corruptor && this.type != NPCID.Probe && this.velocity.Y > 0f && num292 < 0f)
                    {
                        this.velocity.Y = this.velocity.Y - num289;
                    }
                }
                if (this.type == NPCID.MeteorHead)
                {
                    if (num291 > 0f)
                    {
                        this.spriteDirection = 1;
                        this.rotation = (float)Math.Atan2((double)num292, (double)num291);
                    }
                    else if (num291 < 0f)
                    {
                        this.spriteDirection = -1;
                        this.rotation = (float)Math.Atan2((double)num292, (double)num291) + 3.14f;
                    }
                }
                else if (this.type == NPCID.Probe)
                {
                    this.localAI[0] += 1f;
                    if (this.justHit)
                    {
                        this.localAI[0] = 0f;
                    }
                    if (Main.netMode != 1 && this.localAI[0] >= 120f)
                    {
                        this.localAI[0] = 0f;
                        if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            int num295 = 25;
                            if (Main.expertMode)
                            {
                                num295 = 22;
                            }
                            int num296 = 84;
                            Projectile.NewProjectile(vector35.X, vector35.Y, num291, num292, num296, num295, 0f, Main.myPlayer, 0f, 0f);
                        }
                    }
                    int num297 = (int)this.position.X + this.width / 2;
                    int num298 = (int)this.position.Y + this.height / 2;
                    num297 /= 16;
                    num298 /= 16;
                    if (num291 > 0f)
                    {
                        this.spriteDirection = 1;
                        this.rotation = (float)Math.Atan2((double)num292, (double)num291);
                    }
                    if (num291 < 0f)
                    {
                        this.spriteDirection = -1;
                        this.rotation = (float)Math.Atan2((double)num292, (double)num291) + 3.14f;
                    }
                }
                else if (this.type == NPCID.EaterofSouls || this.type == NPCID.Corruptor || this.type == NPCID.Crimera)
                {
                    this.rotation = (float)Math.Atan2((double)num292, (double)num291) - 1.57f;
                }
                else if (this.type == NPCID.Hornet || this.type == NPCID.MossHornet || this.type == NPCID.Moth || (this.type >= NPCID.HornetFatty && this.type <= NPCID.HornetStingy))
                {
                    if (this.velocity.X > 0f)
                    {
                        this.spriteDirection = 1;
                    }
                    if (this.velocity.X < 0f)
                    {
                        this.spriteDirection = -1;
                    }
                    this.rotation = this.velocity.X * 0.1f;
                }
                else
                {
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                }
                if (this.type == NPCID.EaterofSouls || this.type == NPCID.MeteorHead || this.type == NPCID.Hornet || this.type == NPCID.Corruptor || this.type == NPCID.Probe || this.type == NPCID.Crimera || this.type == NPCID.MossHornet || this.type == NPCID.Moth || this.type == NPCID.Bee || this.type == NPCID.BeeSmall || (this.type >= NPCID.HornetFatty && this.type <= NPCID.HornetStingy))
                {
                    float num299 = 0.7f;
                    if (this.type == NPCID.EaterofSouls || this.type == NPCID.Crimera)
                    {
                        num299 = 0.4f;
                    }
                    if (this.collideX)
                    {
                        this.netUpdate = true;
                        this.velocity.X = this.oldVelocity.X * -num299;
                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                        {
                            this.velocity.X = 2f;
                        }
                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                    if (this.collideY)
                    {
                        this.netUpdate = true;
                        this.velocity.Y = this.oldVelocity.Y * -num299;
                        if (this.velocity.Y > 0f && (double)this.velocity.Y < 1.5)
                        {
                            this.velocity.Y = 2f;
                        }
                        if (this.velocity.Y < 0f && (double)this.velocity.Y > -1.5)
                        {
                            this.velocity.Y = -2f;
                        }
                    }
                }
                if ((this.type == NPCID.EaterofSouls || this.type == NPCID.Corruptor || this.type == NPCID.Crimera) && this.wet)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.3f;
                    if (this.velocity.Y < -2f)
                    {
                        this.velocity.Y = -2f;
                    }
                }
                if (this.type == NPCID.Moth && this.wet)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.5f;
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                    this.TargetClosest(true);
                }
                if (this.type == NPCID.Hornet || this.type == NPCID.MossHornet || (this.type >= NPCID.HornetFatty && this.type <= NPCID.HornetStingy))
                {
                    if (this.wet)
                    {
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.95f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                        this.TargetClosest(true);
                    }
                    if (this.ai[1] == 101f)
                    {
                        this.ai[1] = 0f;
                    }
                    if (Main.netMode != 1)
                    {
                        this.ai[1] += (float)Main.rand.Next(5, 20) * 0.1f * this.scale;
                        if (this.type == NPCID.MossHornet)
                        {
                            this.ai[1] += (float)Main.rand.Next(5, 20) * 0.1f * this.scale;
                        }
                        if (Main.player[this.target].stealth == 0f && Main.player[this.target].itemAnimation == 0)
                        {
                            this.ai[1] = 0f;
                        }
                        if (this.ai[1] >= 130f)
                        {
                            if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float num304 = 8f;
                                Vector2 vector36 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)(this.height / 2));
                                float num305 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector36.X + (float)Main.rand.Next(-20, 21);
                                float num306 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector36.Y + (float)Main.rand.Next(-20, 21);
                                if ((num305 < 0f && this.velocity.X < 0f) || (num305 > 0f && this.velocity.X > 0f))
                                {
                                    float num307 = (float)Math.Sqrt((double)(num305 * num305 + num306 * num306));
                                    num307 = num304 / num307;
                                    num305 *= num307;
                                    num306 *= num307;
                                    int num308 = (int)(10f * this.scale);
                                    if (this.type == NPCID.MossHornet)
                                    {
                                        num308 = (int)(30f * this.scale);
                                    }
                                    int num309 = 55;
                                    int num310 = Projectile.NewProjectile(vector36.X, vector36.Y, num305, num306, num309, num308, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num310].timeLeft = 300;
                                    this.ai[1] = 101f;
                                    this.netUpdate = true;
                                }
                                else
                                {
                                    this.ai[1] = 0f;
                                }
                            }
                            else
                            {
                                this.ai[1] = 0f;
                            }
                        }
                    }
                }
                if (this.type == NPCID.Probe && flag32)
                {
                    if ((this.velocity.X > 0f && num291 > 0f) || (this.velocity.X < 0f && num291 < 0f))
                    {
                        if (Math.Abs(this.velocity.X) < 12f)
                        {
                            this.velocity.X = this.velocity.X * 1.05f;
                        }
                    }
                    else
                    {
                        this.velocity.X = this.velocity.X * 0.9f;
                    }
                }
                if (Main.netMode != 1 && this.type == NPCID.Corruptor && !Main.player[this.target].dead)
                {
                    if (this.justHit)
                    {
                        this.localAI[0] = 0f;
                    }
                    this.localAI[0] += 1f;
                    if (this.localAI[0] == 180f)
                    {
                        if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            NPC.NewNPC((int)(this.position.X + (float)(this.width / 2) + this.velocity.X), (int)(this.position.Y + (float)(this.height / 2) + this.velocity.Y), 112, 0, 0f, 0f, 0f, 0f, 255);
                        }
                        this.localAI[0] = 0f;
                    }
                }
                if ((Main.dayTime && this.type != NPCID.Crimera && this.type != NPCID.EaterofSouls && this.type != NPCID.MeteorHead && this.type != NPCID.Hornet && this.type != NPCID.Corruptor && this.type != NPCID.MossHornet && this.type != NPCID.Moth && this.type != NPCID.Bee && this.type != NPCID.BeeSmall && this.type != NPCID.Parrot && (this.type < 231 || this.type > 235)) || Main.player[this.target].dead)
                {
                    this.velocity.Y = this.velocity.Y - num289 * 2f;
                    if (this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                }
                if (((this.velocity.X > 0f && this.oldVelocity.X < 0f) || (this.velocity.X < 0f && this.oldVelocity.X > 0f) || (this.velocity.Y > 0f && this.oldVelocity.Y < 0f) || (this.velocity.Y < 0f && this.oldVelocity.Y > 0f)) && !this.justHit)
                {
                    this.netUpdate = true;
                    return;
                }
            }
            else if (this.aiStyle == 6)
            {
                if (this.type == NPCID.LeechHead && this.localAI[1] == 0f)
                {
                    this.localAI[1] = 1f;
                }
                if (this.type == NPCID.CultistDragonHead && this.localAI[3] == 0f)
                {
                    this.localAI[3] = 1f;
                }
                if (this.type >= NPCID.CultistDragonHead && this.type <= NPCID.CultistDragonTail)
                {
                    this.dontTakeDamage = (this.alpha > 0);
                    if (this.type == NPCID.CultistDragonHead || (this.type != NPCID.CultistDragonHead && Main.npc[(int)this.ai[1]].alpha < 85))
                    {
                        this.alpha -= 42;
                        if (this.alpha < 0)
                        {
                            this.alpha = 0;
                        }
                    }
                }
                else if (this.type == NPCID.StardustWormHead && this.ai[1] == 0f)
                {
                    this.ai[1] = (float)Main.rand.Next(-2, 0);
                    this.netUpdate = true;
                }
                if (Main.netMode != 1 && Main.expertMode)
                {
                    if (this.type == NPCID.EaterofWorldsBody && (double)(this.position.Y / 16f) < Main.worldSurface)
                    {
                        if (Main.rand.Next(900) == 0)
                        {
                            this.TargetClosest(true);
                            if (Collision.CanHitLine(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                NPC.NewNPC((int)(this.position.X + (float)(this.width / 2) + this.velocity.X), (int)(this.position.Y + (float)(this.height / 2) + this.velocity.Y), 112, 0, 0f, 1f, 0f, 0f, 255);
                            }
                        }
                    }
                    else if (this.type == NPCID.EaterofWorldsHead)
                    {
                        int num315 = 90;
                        num315 += (int)((float)this.life / (float)this.lifeMax * 60f * 5f);
                        if (Main.rand.Next(num315) == 0)
                        {
                            this.TargetClosest(true);
                            if (Collision.CanHitLine(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                NPC.NewNPC((int)(this.position.X + (float)(this.width / 2) + this.velocity.X), (int)(this.position.Y + (float)(this.height / 2) + this.velocity.Y), 112, 0, 0f, 1f, 0f, 0f, 255);
                            }
                        }
                    }
                }
                if (this.type >= NPCID.EaterofWorldsHead && this.type <= NPCID.EaterofWorldsTail)
                {
                    this.realLife = -1;
                }
                else if (this.ai[3] > 0f)
                {
                    this.realLife = (int)this.ai[3];
                }
                if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                {
                    this.TargetClosest(true);
                }
                if (Main.player[this.target].dead && this.timeLeft > 300)
                {
                    this.timeLeft = 300;
                }
                if (Main.netMode != 1)
                {
                    if (this.type == NPCID.WyvernHead && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num316 = this.whoAmI;
                        for (int num317 = 0; num317 < 14; num317++)
                        {
                            int num318 = 89;
                            if (num317 == 1 || num317 == 8)
                            {
                                num318 = 88;
                            }
                            else if (num317 == 11)
                            {
                                num318 = 90;
                            }
                            else if (num317 == 12)
                            {
                                num318 = 91;
                            }
                            else if (num317 == 13)
                            {
                                num318 = 92;
                            }
                            int num319 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num318, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num319].ai[3] = (float)this.whoAmI;
                            Main.npc[num319].realLife = this.whoAmI;
                            Main.npc[num319].ai[1] = (float)num316;
                            Main.npc[num316].ai[0] = (float)num319;
                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num319, 0f, 0f, 0f, 0, 0, 0);
                            num316 = num319;
                        }
                    }
                    if (this.type == NPCID.CultistDragonHead && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num320 = this.whoAmI;
                        for (int num321 = 0; num321 < 30; num321++)
                        {
                            int num322 = 456;
                            if ((num321 - 2) % 4 == 0 && num321 < 26)
                            {
                                num322 = 455;
                            }
                            else if (num321 == 27)
                            {
                                num322 = 457;
                            }
                            else if (num321 == 28)
                            {
                                num322 = 458;
                            }
                            else if (num321 == 29)
                            {
                                num322 = 459;
                            }
                            int num323 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num322, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num323].ai[3] = (float)this.whoAmI;
                            Main.npc[num323].realLife = this.whoAmI;
                            Main.npc[num323].ai[1] = (float)num320;
                            Main.npc[num320].ai[0] = (float)num323;
                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num323, 0f, 0f, 0f, 0, 0, 0);
                            num320 = num323;
                        }
                    }
                    if (this.type == NPCID.TombCrawlerHead && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num324 = this.whoAmI;
                        int num325 = Main.rand.Next(6, 10);
                        for (int num326 = 0; num326 < num325; num326++)
                        {
                            int num327 = 514;
                            if (num326 == num325 - 1)
                            {
                                num327 = 515;
                            }
                            int num328 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num327, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num328].ai[3] = (float)this.whoAmI;
                            Main.npc[num328].realLife = this.whoAmI;
                            Main.npc[num328].ai[1] = (float)num324;
                            Main.npc[num324].ai[0] = (float)num328;
                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num328, 0f, 0f, 0f, 0, 0, 0);
                            num324 = num328;
                        }
                    }
                    if (this.type == NPCID.DuneSplicerHead && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num329 = this.whoAmI;
                        int num330 = Main.rand.Next(12, 21);
                        for (int num331 = 0; num331 < num330; num331++)
                        {
                            int num332 = 511;
                            if (num331 == num330 - 1)
                            {
                                num332 = 512;
                            }
                            int num333 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num332, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num333].ai[3] = (float)this.whoAmI;
                            Main.npc[num333].realLife = this.whoAmI;
                            Main.npc[num333].ai[1] = (float)num329;
                            Main.npc[num329].ai[0] = (float)num333;
                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num333, 0f, 0f, 0f, 0, 0, 0);
                            num329 = num333;
                        }
                    }
                    else if ((this.type == NPCID.DevourerHead || this.type == NPCID.DevourerBody || this.type == NPCID.GiantWormHead || this.type == NPCID.GiantWormBody || this.type == NPCID.EaterofWorldsHead || this.type == NPCID.EaterofWorldsBody || this.type == NPCID.BoneSerpentHead || this.type == NPCID.BoneSerpentBody || this.type == NPCID.DiggerHead || this.type == NPCID.DiggerBody || this.type == NPCID.SeekerHead || this.type == NPCID.SeekerBody || this.type == NPCID.LeechHead || this.type == NPCID.LeechBody) && this.ai[0] == 0f)
                    {
                        if (this.type == NPCID.DevourerHead || this.type == NPCID.GiantWormHead || this.type == NPCID.EaterofWorldsHead || this.type == NPCID.BoneSerpentHead || this.type == NPCID.DiggerHead || this.type == NPCID.SeekerHead || this.type == NPCID.LeechHead)
                        {
                            if (this.type < 13 || this.type > 15)
                            {
                                this.ai[3] = (float)this.whoAmI;
                                this.realLife = this.whoAmI;
                            }
                            this.ai[2] = (float)Main.rand.Next(8, 13);
                            if (this.type == NPCID.GiantWormHead)
                            {
                                this.ai[2] = (float)Main.rand.Next(4, 7);
                            }
                            if (this.type == NPCID.EaterofWorldsHead)
                            {
                                this.ai[2] = (float)Main.rand.Next(45, 56);
                                if (Main.expertMode)
                                {
                                    this.ai[2] = (float)((int)(this.ai[2] * 1.1f));
                                }
                            }
                            if (this.type == NPCID.BoneSerpentHead)
                            {
                                this.ai[2] = (float)Main.rand.Next(12, 19);
                            }
                            if (this.type == NPCID.DiggerHead)
                            {
                                this.ai[2] = (float)Main.rand.Next(6, 12);
                            }
                            if (this.type == NPCID.SeekerHead)
                            {
                                this.ai[2] = (float)Main.rand.Next(20, 26);
                            }
                            if (this.type == NPCID.LeechHead)
                            {
                                this.ai[2] = (float)Main.rand.Next(3, 6);
                            }
                            this.ai[0] = (float)NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), this.type + 1, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        }
                        else if ((this.type == NPCID.DevourerBody || this.type == NPCID.GiantWormBody || this.type == NPCID.EaterofWorldsBody || this.type == NPCID.BoneSerpentBody || this.type == NPCID.DiggerBody || this.type == NPCID.SeekerBody || this.type == NPCID.LeechBody) && this.ai[2] > 0f)
                        {
                            this.ai[0] = (float)NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), this.type, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        }
                        else
                        {
                            this.ai[0] = (float)NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), this.type + 1, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        }
                        if (this.type < 13 || this.type > 15)
                        {
                            Main.npc[(int)this.ai[0]].ai[3] = this.ai[3];
                            Main.npc[(int)this.ai[0]].realLife = this.realLife;
                        }
                        Main.npc[(int)this.ai[0]].ai[1] = (float)this.whoAmI;
                        Main.npc[(int)this.ai[0]].ai[2] = this.ai[2] - 1f;
                        this.netUpdate = true;
                    }
                    if (this.type == NPCID.SolarCrawltipedeHead && this.ai[0] == 0f)
                    {
                        this.ai[3] = (float)this.whoAmI;
                        this.realLife = this.whoAmI;
                        int num334 = this.whoAmI;
                        int num335 = 30;
                        for (int num336 = 0; num336 < num335; num336++)
                        {
                            int num337 = 413;
                            if (num336 == num335 - 1)
                            {
                                num337 = 414;
                            }
                            int num338 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num337, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num338].ai[3] = (float)this.whoAmI;
                            Main.npc[num338].realLife = this.whoAmI;
                            Main.npc[num338].ai[1] = (float)num334;
                            Main.npc[num334].ai[0] = (float)num338;
                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num338, 0f, 0f, 0f, 0, 0, 0);
                            num334 = num338;
                        }
                    }
                    int num75 = this.type;
                    if (num75 <= 100)
                    {
                        switch (num75)
                        {
                            case 8:
                            case 9:
                            case 11:
                            case 12:
                                break;
                            case 10:
                                goto IL_15374;
                            default:
                                switch (num75)
                                {
                                    case 40:
                                    case 41:
                                        break;
                                    default:
                                        switch (num75)
                                        {
                                            case 88:
                                            case 89:
                                            case 90:
                                            case 91:
                                            case 92:
                                            case 96:
                                            case 97:
                                            case 99:
                                            case 100:
                                                break;
                                            case 93:
                                            case 94:
                                            case 95:
                                            case 98:
                                                goto IL_15374;
                                            default:
                                                goto IL_15374;
                                        }
                                        break;
                                }
                                break;
                        }
                    }
                    else if (num75 <= 414)
                    {
                        switch (num75)
                        {
                            case 118:
                            case 119:
                                break;
                            default:
                                switch (num75)
                                {
                                    case 413:
                                    case 414:
                                        break;
                                    default:
                                        goto IL_15374;
                                }
                                break;
                        }
                    }
                    else
                    {
                        switch (num75)
                        {
                            case 455:
                            case 456:
                            case 457:
                            case 458:
                            case 459:
                                break;
                            default:
                                switch (num75)
                                {
                                    case 511:
                                    case 512:
                                    case 514:
                                    case 515:
                                        break;
                                    case 513:
                                        goto IL_15374;
                                    default:
                                        goto IL_15374;
                                }
                                break;
                        }
                    }
                    if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != this.aiStyle)
                    {
                        this.life = 0;
                        this.HitEffect(0, 10.0);
                        this.active = false;
                        NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                    }
                IL_15374:
                    num75 = this.type;
                    if (num75 <= 99)
                    {
                        switch (num75)
                        {
                            case 7:
                            case 8:
                            case 10:
                            case 11:
                                break;
                            case 9:
                                goto IL_154F7;
                            default:
                                switch (num75)
                                {
                                    case 39:
                                    case 40:
                                        break;
                                    default:
                                        switch (num75)
                                        {
                                            case 87:
                                            case 88:
                                            case 89:
                                            case 90:
                                            case 91:
                                            case 95:
                                            case 96:
                                            case 98:
                                            case 99:
                                                break;
                                            case 92:
                                            case 93:
                                            case 94:
                                            case 97:
                                                goto IL_154F7;
                                            default:
                                                goto IL_154F7;
                                        }
                                        break;
                                }
                                break;
                        }
                    }
                    else if (num75 <= 413)
                    {
                        switch (num75)
                        {
                            case 117:
                            case 118:
                                break;
                            default:
                                switch (num75)
                                {
                                    case 412:
                                    case 413:
                                        break;
                                    default:
                                        goto IL_154F7;
                                }
                                break;
                        }
                    }
                    else
                    {
                        switch (num75)
                        {
                            case 454:
                            case 455:
                            case 456:
                            case 457:
                            case 458:
                                break;
                            default:
                                switch (num75)
                                {
                                    case 510:
                                    case 511:
                                    case 513:
                                    case 514:
                                        break;
                                    case 512:
                                        goto IL_154F7;
                                    default:
                                        goto IL_154F7;
                                }
                                break;
                        }
                    }
                    if (!Main.npc[(int)this.ai[0]].active || Main.npc[(int)this.ai[0]].aiStyle != this.aiStyle)
                    {
                        this.life = 0;
                        this.HitEffect(0, 10.0);
                        this.active = false;
                        NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                    }
                IL_154F7:
                    if (this.type == NPCID.EaterofWorldsHead || this.type == NPCID.EaterofWorldsBody || this.type == NPCID.EaterofWorldsTail)
                    {
                        if (!Main.npc[(int)this.ai[1]].active && !Main.npc[(int)this.ai[0]].active)
                        {
                            this.life = 0;
                            this.HitEffect(0, 10.0);
                            this.checkDead();
                            this.active = false;
                            NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                        }
                        if (this.type == NPCID.EaterofWorldsHead && !Main.npc[(int)this.ai[0]].active)
                        {
                            this.life = 0;
                            this.HitEffect(0, 10.0);
                            this.checkDead();
                            this.active = false;
                            NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                        }
                        if (this.type == NPCID.EaterofWorldsTail && !Main.npc[(int)this.ai[1]].active)
                        {
                            this.life = 0;
                            this.HitEffect(0, 10.0);
                            this.checkDead();
                            this.active = false;
                            NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                        }
                        if (this.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != this.aiStyle))
                        {
                            this.type = 13;
                            int whoAmI = this.whoAmI;
                            float num339 = (float)this.life / (float)this.lifeMax;
                            float num340 = this.ai[0];
                            this.SetDefaultsKeepPlayerInteraction(this.type);
                            this.life = (int)((float)this.lifeMax * num339);
                            this.ai[0] = num340;
                            this.TargetClosest(true);
                            this.netUpdate = true;
                            this.whoAmI = whoAmI;
                        }
                        if (this.type == NPCID.EaterofWorldsBody && (!Main.npc[(int)this.ai[0]].active || Main.npc[(int)this.ai[0]].aiStyle != this.aiStyle))
                        {
                            int whoAmI2 = this.whoAmI;
                            float num341 = (float)this.life / (float)this.lifeMax;
                            float num342 = this.ai[1];
                            this.SetDefaultsKeepPlayerInteraction(this.type);
                            this.life = (int)((float)this.lifeMax * num341);
                            this.ai[1] = num342;
                            this.TargetClosest(true);
                            this.netUpdate = true;
                            this.whoAmI = whoAmI2;
                        }
                    }
                    if (!this.active && Main.netMode == 2)
                    {
                        NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                    }
                }
                int num343 = (int)(this.position.X / 16f) - 1;
                int num344 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                int num345 = (int)(this.position.Y / 16f) - 1;
                int num346 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                if (num343 < 0)
                {
                    num343 = 0;
                }
                if (num344 > Main.maxTilesX)
                {
                    num344 = Main.maxTilesX;
                }
                if (num345 < 0)
                {
                    num345 = 0;
                }
                if (num346 > Main.maxTilesY)
                {
                    num346 = Main.maxTilesY;
                }
                bool flag33 = false;
                if (this.type >= NPCID.WyvernHead && this.type <= NPCID.WyvernTail)
                {
                    flag33 = true;
                }
                if (this.type >= NPCID.CultistDragonHead && this.type <= NPCID.CultistDragonTail)
                {
                    flag33 = true;
                }
                if (this.type == NPCID.StardustWormHead && this.ai[1] == -1f)
                {
                    flag33 = true;
                }
                if (this.type >= NPCID.SolarCrawltipedeHead && this.type <= NPCID.SolarCrawltipedeTail)
                {
                    flag33 = true;
                }
                if (!flag33)
                {
                    for (int num347 = num343; num347 < num344; num347++)
                    {
                        for (int num348 = num345; num348 < num346; num348++)
                        {
                            if (Main.tile[num347, num348] != null && ((Main.tile[num347, num348].nactive() && (Main.tileSolid[(int)Main.tile[num347, num348].type] || (Main.tileSolidTop[(int)Main.tile[num347, num348].type] && Main.tile[num347, num348].frameY == 0))) || Main.tile[num347, num348].liquid > 64))
                            {
                                Vector2 vector37;
                                vector37.X = (float)(num347 * 16);
                                vector37.Y = (float)(num348 * 16);
                                if (this.position.X + (float)this.width > vector37.X && this.position.X < vector37.X + 16f && this.position.Y + (float)this.height > vector37.Y && this.position.Y < vector37.Y + 16f)
                                {
                                    flag33 = true;
                                    if (Main.rand.Next(100) == 0 && this.type != NPCID.LeechHead && Main.tile[num347, num348].nactive())
                                    {
                                        WorldGen.KillTile(num347, num348, true, true, false);
                                    }
                                }
                            }
                        }
                    }
                }
                if (!flag33 && (this.type == NPCID.DevourerHead || this.type == NPCID.GiantWormHead || this.type == NPCID.EaterofWorldsHead || this.type == NPCID.BoneSerpentHead || this.type == NPCID.DiggerHead || this.type == NPCID.SeekerHead || this.type == NPCID.LeechHead || this.type == NPCID.TruffleWormDigger || this.type == NPCID.CultistDragonHead || this.type == NPCID.DuneSplicerHead || this.type == NPCID.TombCrawlerHead))
                {
                    Rectangle rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                    int num349 = 1000;
                    bool flag34 = true;
                    for (int num350 = 0; num350 < 255; num350++)
                    {
                        if (Main.player[num350].active)
                        {
                            Rectangle rectangle2 = new Rectangle((int)Main.player[num350].position.X - num349, (int)Main.player[num350].position.Y - num349, num349 * 2, num349 * 2);
                            if (rectangle.Intersects(rectangle2))
                            {
                                flag34 = false;
                                break;
                            }
                        }
                    }
                    if (flag34)
                    {
                        flag33 = true;
                    }
                }
                if ((this.type >= NPCID.WyvernHead && this.type <= NPCID.WyvernTail) || (this.type >= NPCID.CultistDragonHead && this.type <= NPCID.CultistDragonTail))
                {
                    if (this.velocity.X < 0f)
                    {
                        this.spriteDirection = 1;
                    }
                    else if (this.velocity.X > 0f)
                    {
                        this.spriteDirection = -1;
                    }
                }
                if (this.type == NPCID.SolarCrawltipedeTail)
                {
                    if (this.justHit)
                    {
                        this.localAI[3] = 3f;
                    }
                    if (this.localAI[2] > 0f)
                    {
                        this.localAI[2] -= 16f;
                        if (this.localAI[2] == 0f)
                        {
                            this.localAI[2] = -128f;
                        }
                    }
                    else if (this.localAI[2] < 0f)
                    {
                        this.localAI[2] += 16f;
                    }
                    else if (this.localAI[3] > 0f)
                    {
                        this.localAI[2] = 128f;
                        this.localAI[3] -= 1f;
                    }
                }
                float num351 = 8f;
                float num352 = 0.07f;
                if (this.type == NPCID.DiggerHead)
                {
                    num351 = 5.5f;
                    num352 = 0.045f;
                }
                if (this.type == NPCID.GiantWormHead)
                {
                    num351 = 6f;
                    num352 = 0.05f;
                }
                if (this.type == NPCID.TombCrawlerHead)
                {
                    num351 = 7f;
                    num352 = 0.03f;
                }
                if (this.type == NPCID.EaterofWorldsHead)
                {
                    num351 = 10f;
                    num352 = 0.07f;
                    if (Main.expertMode)
                    {
                        num351 = 12f;
                        num352 = 0.15f;
                    }
                }
                if (this.type == NPCID.DuneSplicerHead)
                {
                    num351 = 10f;
                    num352 = 0.25f;
                }
                if (this.type == NPCID.WyvernHead)
                {
                    num351 = 11f;
                    num352 = 0.25f;
                }
                if (this.type == NPCID.TruffleWormDigger)
                {
                    num351 = 6f;
                    num352 = 0.15f;
                }
                if (this.type == NPCID.CultistDragonHead)
                {
                    num351 = 20f;
                    num352 = 0.55f;
                }
                if (this.type == NPCID.StardustWormHead)
                {
                    num351 = 6f;
                    num352 = 0.2f;
                }
                if (this.type == NPCID.LeechHead && Main.wof >= 0)
                {
                    float num353 = (float)Main.npc[Main.wof].life / (float)Main.npc[Main.wof].lifeMax;
                    if ((double)num353 < 0.5)
                    {
                        num351 += 1f;
                        num352 += 0.1f;
                    }
                    if ((double)num353 < 0.25)
                    {
                        num351 += 1f;
                        num352 += 0.1f;
                    }
                    if ((double)num353 < 0.1)
                    {
                        num351 += 2f;
                        num352 += 0.1f;
                    }
                }
                Vector2 vector38 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num354 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                float num355 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                if (this.type == NPCID.SolarCrawltipedeHead)
                {
                    num351 = 10f;
                    num352 = 0.3f;
                    int num356 = -1;
                    int num357 = (int)(Main.player[this.target].Center.X / 16f);
                    int num358 = (int)(Main.player[this.target].Center.Y / 16f);
                    for (int num359 = num357 - 2; num359 <= num357 + 2; num359++)
                    {
                        for (int num360 = num358; num360 <= num358 + 15; num360++)
                        {
                            if (WorldGen.SolidTile2(num359, num360))
                            {
                                num356 = num360;
                                break;
                            }
                        }
                        if (num356 > 0)
                        {
                            break;
                        }
                    }
                    if (num356 > 0)
                    {
                        num356 *= 16;
                        float num361 = (float)(num356 - 800);
                        if (Main.player[this.target].position.Y > num361)
                        {
                            num355 = num361;
                            if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 500f)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    num354 = Main.player[this.target].Center.X + 600f;
                                }
                                else
                                {
                                    num354 = Main.player[this.target].Center.X - 600f;
                                }
                            }
                        }
                    }
                    else
                    {
                        num351 = 14f;
                        num352 = 0.5f;
                    }
                    float num362 = num351 * 1.3f;
                    float num363 = num351 * 0.7f;
                    float num364 = this.velocity.Length();
                    if (num364 > 0f)
                    {
                        if (num364 > num362)
                        {
                            this.velocity.Normalize();
                            this.velocity *= num362;
                        }
                        else if (num364 < num363)
                        {
                            this.velocity.Normalize();
                            this.velocity *= num363;
                        }
                    }
                    if (num356 > 0)
                    {
                        for (int num365 = 0; num365 < 200; num365++)
                        {
                            if (Main.npc[num365].active && Main.npc[num365].type == this.type && num365 != this.whoAmI)
                            {
                                Vector2 vector39 = Main.npc[num365].Center - base.Center;
                                if (vector39.Length() < 400f)
                                {
                                    vector39.Normalize();
                                    vector39 *= 1000f;
                                    num354 -= vector39.X;
                                    num355 -= vector39.Y;
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int num366 = 0; num366 < 200; num366++)
                        {
                            if (Main.npc[num366].active && Main.npc[num366].type == this.type && num366 != this.whoAmI)
                            {
                                Vector2 vector40 = Main.npc[num366].Center - base.Center;
                                if (vector40.Length() < 60f)
                                {
                                    vector40.Normalize();
                                    vector40 *= 200f;
                                    num354 -= vector40.X;
                                    num355 -= vector40.Y;
                                }
                            }
                        }
                    }
                }
                num354 = (float)((int)(num354 / 16f) * 16);
                num355 = (float)((int)(num355 / 16f) * 16);
                vector38.X = (float)((int)(vector38.X / 16f) * 16);
                vector38.Y = (float)((int)(vector38.Y / 16f) * 16);
                num354 -= vector38.X;
                num355 -= vector38.Y;
                if (this.type == NPCID.TruffleWormDigger)
                {
                    num354 *= -1f;
                    num355 *= -1f;
                }
                float num367 = (float)Math.Sqrt((double)(num354 * num354 + num355 * num355));
                if (this.ai[1] > 0f && this.ai[1] < (float)Main.npc.Length)
                {
                    try
                    {
                        vector38 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        num354 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - vector38.X;
                        num355 = Main.npc[(int)this.ai[1]].position.Y + (float)(Main.npc[(int)this.ai[1]].height / 2) - vector38.Y;
                    }
                    catch
                    {
                    }
                    this.rotation = (float)Math.Atan2((double)num355, (double)num354) + 1.57f;
                    num367 = (float)Math.Sqrt((double)(num354 * num354 + num355 * num355));
                    int num368 = this.width;
                    if (this.type >= NPCID.WyvernHead && this.type <= NPCID.WyvernTail)
                    {
                        num368 = 42;
                    }
                    if (this.type >= NPCID.CultistDragonHead && this.type <= NPCID.CultistDragonTail)
                    {
                        num368 = 36;
                    }
                    if (this.type >= NPCID.EaterofWorldsHead && this.type <= NPCID.EaterofWorldsTail)
                    {
                        num368 = (int)((float)num368 * this.scale);
                    }
                    if (this.type >= NPCID.SolarCrawltipedeHead && this.type <= NPCID.SolarCrawltipedeTail)
                    {
                        num368 += 6;
                    }
                    num367 = (num367 - (float)num368) / num367;
                    num354 *= num367;
                    num355 *= num367;
                    this.velocity = Vector2.Zero;
                    this.position.X = this.position.X + num354;
                    this.position.Y = this.position.Y + num355;
                    if (this.type >= NPCID.WyvernHead && this.type <= NPCID.WyvernTail)
                    {
                        if (num354 < 0f)
                        {
                            this.spriteDirection = 1;
                        }
                        else if (num354 > 0f)
                        {
                            this.spriteDirection = -1;
                        }
                    }
                    if (this.type >= NPCID.CultistDragonHead && this.type <= NPCID.CultistDragonTail)
                    {
                        if (num354 < 0f)
                        {
                            this.spriteDirection = 1;
                            return;
                        }
                        if (num354 > 0f)
                        {
                            this.spriteDirection = -1;
                            return;
                        }
                    }
                }
                else
                {
                    if (!flag33)
                    {
                        this.TargetClosest(true);
                        this.velocity.Y = this.velocity.Y + 0.11f;
                        if (this.velocity.Y > num351)
                        {
                            this.velocity.Y = num351;
                        }
                        if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)num351 * 0.4)
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - num352 * 1.1f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X + num352 * 1.1f;
                            }
                        }
                        else if (this.velocity.Y == num351)
                        {
                            if (this.velocity.X < num354)
                            {
                                this.velocity.X = this.velocity.X + num352;
                            }
                            else if (this.velocity.X > num354)
                            {
                                this.velocity.X = this.velocity.X - num352;
                            }
                        }
                        else if (this.velocity.Y > 4f)
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X + num352 * 0.9f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X - num352 * 0.9f;
                            }
                        }
                    }
                    else
                    {
                        if (this.type != NPCID.WyvernHead && this.type != NPCID.LeechHead && this.type != NPCID.CultistDragonHead && this.type != NPCID.SolarCrawltipedeHead && this.soundDelay == 0)
                        {
                            float num369 = num367 / 40f;
                            if (num369 < 10f)
                            {
                                num369 = 10f;
                            }
                            if (num369 > 20f)
                            {
                                num369 = 20f;
                            }
                            this.soundDelay = (int)num369;
                        }
                        num367 = (float)Math.Sqrt((double)(num354 * num354 + num355 * num355));
                        float num370 = Math.Abs(num354);
                        float num371 = Math.Abs(num355);
                        float num372 = num351 / num367;
                        num354 *= num372;
                        num355 *= num372;
                        bool flag35 = false;
                        if ((this.type == NPCID.DevourerHead || this.type == NPCID.EaterofWorldsHead) && !Main.player[this.target].ZoneCorrupt && !Main.player[this.target].ZoneCrimson)
                        {
                            flag35 = true;
                        }
                        if (this.type == NPCID.TombCrawlerHead && (double)Main.player[this.target].position.Y < Main.worldSurface * 16.0)
                        {
                            flag35 = true;
                        }
                        if (this.type == NPCID.DuneSplicerHead && (double)Main.player[this.target].position.Y < Main.worldSurface * 16.0)
                        {
                            flag35 = true;
                        }
                        if (flag35)
                        {
                            bool flag36 = true;
                            for (int num373 = 0; num373 < 255; num373++)
                            {
                                if (Main.player[num373].active && !Main.player[num373].dead && Main.player[num373].ZoneCorrupt)
                                {
                                    flag36 = false;
                                }
                            }
                            if (flag36)
                            {
                                if (Main.netMode != 1 && (double)(this.position.Y / 16f) > (Main.rockLayer + (double)Main.maxTilesY) / 2.0)
                                {
                                    this.active = false;
                                    int num374 = (int)this.ai[0];
                                    while (num374 > 0 && num374 < 200 && Main.npc[num374].active && Main.npc[num374].aiStyle == this.aiStyle)
                                    {
                                        int num375 = (int)Main.npc[num374].ai[0];
                                        Main.npc[num374].active = false;
                                        this.life = 0;
                                        if (Main.netMode == 2)
                                        {
                                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num374, 0f, 0f, 0f, 0, 0, 0);
                                        }
                                        num374 = num375;
                                    }
                                    if (Main.netMode == 2)
                                    {
                                        NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                }
                                num354 = 0f;
                                num355 = num351;
                            }
                        }
                        bool flag37 = false;
                        if (this.type == NPCID.WyvernHead)
                        {
                            if (((this.velocity.X > 0f && num354 < 0f) || (this.velocity.X < 0f && num354 > 0f) || (this.velocity.Y > 0f && num355 < 0f) || (this.velocity.Y < 0f && num355 > 0f)) && Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) > num352 / 2f && num367 < 300f)
                            {
                                flag37 = true;
                                if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < num351)
                                {
                                    this.velocity *= 1.1f;
                                }
                            }
                            if (this.position.Y > Main.player[this.target].position.Y || (double)(Main.player[this.target].position.Y / 16f) > Main.worldSurface || Main.player[this.target].dead)
                            {
                                flag37 = true;
                                if (Math.Abs(this.velocity.X) < num351 / 2f)
                                {
                                    if (this.velocity.X == 0f)
                                    {
                                        this.velocity.X = this.velocity.X - (float)this.direction;
                                    }
                                    this.velocity.X = this.velocity.X * 1.1f;
                                }
                                else if (this.velocity.Y > -num351)
                                {
                                    this.velocity.Y = this.velocity.Y - num352;
                                }
                            }
                        }
                        if (this.type == NPCID.CultistDragonHead)
                        {
                            if (((this.velocity.X > 0f && num354 < 0f) || (this.velocity.X < 0f && num354 > 0f) || (this.velocity.Y > 0f && num355 < 0f) || (this.velocity.Y < 0f && num355 > 0f)) && Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) > num352 / 2f && num367 < 300f)
                            {
                                flag37 = true;
                                if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < num351)
                                {
                                    this.velocity *= 1.1f;
                                }
                            }
                            if (this.position.Y > Main.player[this.target].position.Y || Main.player[this.target].dead)
                            {
                                flag37 = true;
                                if (Math.Abs(this.velocity.X) < num351 / 2f)
                                {
                                    if (this.velocity.X == 0f)
                                    {
                                        this.velocity.X = this.velocity.X - (float)this.direction;
                                    }
                                    this.velocity.X = this.velocity.X * 1.1f;
                                }
                                else if (this.velocity.Y > -num351)
                                {
                                    this.velocity.Y = this.velocity.Y - num352;
                                }
                            }
                        }
                        if (!flag37)
                        {
                            if ((this.velocity.X > 0f && num354 > 0f) || (this.velocity.X < 0f && num354 < 0f) || (this.velocity.Y > 0f && num355 > 0f) || (this.velocity.Y < 0f && num355 < 0f))
                            {
                                if (this.velocity.X < num354)
                                {
                                    this.velocity.X = this.velocity.X + num352;
                                }
                                else if (this.velocity.X > num354)
                                {
                                    this.velocity.X = this.velocity.X - num352;
                                }
                                if (this.velocity.Y < num355)
                                {
                                    this.velocity.Y = this.velocity.Y + num352;
                                }
                                else if (this.velocity.Y > num355)
                                {
                                    this.velocity.Y = this.velocity.Y - num352;
                                }
                                if ((double)Math.Abs(num355) < (double)num351 * 0.2 && ((this.velocity.X > 0f && num354 < 0f) || (this.velocity.X < 0f && num354 > 0f)))
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num352 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y - num352 * 2f;
                                    }
                                }
                                if ((double)Math.Abs(num354) < (double)num351 * 0.2 && ((this.velocity.Y > 0f && num355 < 0f) || (this.velocity.Y < 0f && num355 > 0f)))
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num352 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X - num352 * 2f;
                                    }
                                }
                            }
                            else if (num370 > num371)
                            {
                                if (this.velocity.X < num354)
                                {
                                    this.velocity.X = this.velocity.X + num352 * 1.1f;
                                }
                                else if (this.velocity.X > num354)
                                {
                                    this.velocity.X = this.velocity.X - num352 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)num351 * 0.5)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num352;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y - num352;
                                    }
                                }
                            }
                            else
                            {
                                if (this.velocity.Y < num355)
                                {
                                    this.velocity.Y = this.velocity.Y + num352 * 1.1f;
                                }
                                else if (this.velocity.Y > num355)
                                {
                                    this.velocity.Y = this.velocity.Y - num352 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)num351 * 0.5)
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num352;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X - num352;
                                    }
                                }
                            }
                        }
                    }
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    if (this.type == NPCID.DevourerHead || this.type == NPCID.GiantWormHead || this.type == NPCID.EaterofWorldsHead || this.type == NPCID.BoneSerpentHead || this.type == NPCID.DiggerHead || this.type == NPCID.SeekerHead || this.type == NPCID.LeechHead || this.type == NPCID.DuneSplicerHead || this.type == NPCID.TombCrawlerHead)
                    {
                        if (flag33)
                        {
                            if (this.localAI[0] != 1f)
                            {
                                this.netUpdate = true;
                            }
                            this.localAI[0] = 1f;
                        }
                        else
                        {
                            if (this.localAI[0] != 0f)
                            {
                                this.netUpdate = true;
                            }
                            this.localAI[0] = 0f;
                        }
                        if (((this.velocity.X > 0f && this.oldVelocity.X < 0f) || (this.velocity.X < 0f && this.oldVelocity.X > 0f) || (this.velocity.Y > 0f && this.oldVelocity.Y < 0f) || (this.velocity.Y < 0f && this.oldVelocity.Y > 0f)) && !this.justHit)
                        {
                            this.netUpdate = true;
                        }
                    }
                    if (this.type == NPCID.CultistDragonHead)
                    {
                        float num376 = Vector2.Distance(Main.player[this.target].Center, base.Center);
                        int num377 = 0;
                        if (Vector2.Normalize(Main.player[this.target].Center - base.Center).ToRotation().AngleTowards(this.velocity.ToRotation(), 1.57079637f) == this.velocity.ToRotation() && num376 < 350f)
                        {
                            num377 = 4;
                        }
                        if ((double)num377 > this.frameCounter)
                        {
                            this.frameCounter += 1.0;
                        }
                        if ((double)num377 < this.frameCounter)
                        {
                            this.frameCounter -= 1.0;
                        }
                        if (this.frameCounter < 0.0)
                        {
                            this.frameCounter = 0.0;
                        }
                        if (this.frameCounter > 4.0)
                        {
                            this.frameCounter = 4.0;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 7)
            {
                bool flag38 = Main.raining;
                if (!Main.dayTime)
                {
                    flag38 = true;
                }
                if (Main.eclipse)
                {
                    flag38 = true;
                }
                if (Main.slimeRain)
                {
                    flag38 = true;
                }
                float num378 = 1f;
                if (Main.expertMode)
                {
                    this.defense = (this.dryadWard ? (this.defDefense + 10) : this.defDefense);
                }
                else
                {
                    this.defense = (this.dryadWard ? (this.defDefense + 6) : this.defDefense);
                }
                if (this.townNPC || this.type == NPCID.SkeletonMerchant)
                {
                    if (NPC.downedBoss1)
                    {
                        num378 += 0.1f;
                        this.defense += 3;
                    }
                    if (NPC.downedBoss2)
                    {
                        num378 += 0.1f;
                        this.defense += 3;
                    }
                    if (NPC.downedBoss3)
                    {
                        num378 += 0.1f;
                        this.defense += 3;
                    }
                    if (NPC.downedQueenBee)
                    {
                        num378 += 0.1f;
                        this.defense += 3;
                    }
                    if (Main.hardMode)
                    {
                        num378 += 0.4f;
                        this.defense += 12;
                    }
                    if (NPC.downedMechBoss1)
                    {
                        num378 += 0.15f;
                        this.defense += 6;
                    }
                    if (NPC.downedMechBoss2)
                    {
                        num378 += 0.15f;
                        this.defense += 6;
                    }
                    if (NPC.downedMechBoss3)
                    {
                        num378 += 0.15f;
                        this.defense += 6;
                    }
                    if (NPC.downedPlantBoss)
                    {
                        num378 += 0.15f;
                        this.defense += 8;
                    }
                    if (NPC.downedGolemBoss)
                    {
                        num378 += 0.15f;
                        this.defense += 8;
                    }
                    if (NPC.downedAncientCultist)
                    {
                        num378 += 0.15f;
                        this.defense += 8;
                    }
                }
                if (this.type == NPCID.SantaClaus && Main.netMode != 1 && !Main.xMas)
                {
                    this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                    if (Main.netMode == 2)
                    {
                        NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, 9999f, 0f, 0f, 0, 0, 0);
                    }
                }
                if ((this.type == NPCID.Penguin || this.type == NPCID.PenguinBlack) && this.localAI[0] == 0f)
                {
                    this.localAI[0] = (float)Main.rand.Next(1, 5);
                }
                if (this.type == NPCID.Mechanic)
                {
                    bool flag39 = false;
                    for (int num379 = 0; num379 < 1000; num379++)
                    {
                        if (Main.projectile[num379].active && Main.projectile[num379].type == ProjectileID.MechanicWrench && Main.projectile[num379].ai[1] == (float)this.whoAmI)
                        {
                            flag39 = true;
                            break;
                        }
                    }
                    this.localAI[0] = (float)flag39.ToInt();
                }
                if ((this.type == NPCID.Duck || this.type == NPCID.DuckWhite) && Main.netMode != 1 && (this.velocity.Y > 4f || this.velocity.Y < -4f || this.wet))
                {
                    int direction = this.direction;
                    this.Transform(this.type + 1);
                    this.TargetClosest(true);
                    this.direction = direction;
                    this.netUpdate = true;
                    return;
                }
                int num75 = this.type;
                if (num75 <= 124)
                {
                    switch (num75)
                    {
                        case 107:
                            NPC.savedGoblin = true;
                            break;
                        case 108:
                            NPC.savedWizard = true;
                            break;
                        default:
                            if (num75 == 124)
                            {
                                NPC.savedMech = true;
                            }
                            break;
                    }
                }
                else if (num75 != 353)
                {
                    if (num75 != 369)
                    {
                        if (num75 == 441)
                        {
                            NPC.savedTaxCollector = true;
                        }
                    }
                    else
                    {
                        NPC.savedAngler = true;
                    }
                }
                else
                {
                    NPC.savedStylist = true;
                }
                if (this.type >= NPCID.None && this.type < 540 && NPCID.Sets.TownCritter[this.type] && this.target == 255)
                {
                    this.TargetClosest(true);
                    if (this.position.X < Main.player[this.target].position.X)
                    {
                        this.direction = 1;
                        this.spriteDirection = this.direction;
                    }
                    if (this.position.X > Main.player[this.target].position.X)
                    {
                        this.direction = -1;
                        this.spriteDirection = this.direction;
                    }
                    if (this.homeTileX == -1)
                    {
                        this.homeTileX = (int)((this.position.X + (float)(this.width / 2)) / 16f);
                    }
                }
                else if (this.homeTileX == -1 && this.homeTileY == -1 && this.velocity.Y == 0f)
                {
                    this.homeTileX = (int)base.Center.X / 16;
                    this.homeTileY = (int)(this.position.Y + (float)this.height + 4f) / 16;
                }
                bool flag40 = false;
                int num380 = this.homeTileY;
                if (this.type == NPCID.TaxCollector)
                {
                    NPC.taxCollector = true;
                }
                this.directionY = -1;
                if (this.direction == 0)
                {
                    this.direction = 1;
                }
                for (int num381 = 0; num381 < 255; num381++)
                {
                    if (Main.player[num381].active && Main.player[num381].talkNPC == this.whoAmI)
                    {
                        flag40 = true;
                        if (this.ai[0] != 0f)
                        {
                            this.netUpdate = true;
                        }
                        this.ai[0] = 0f;
                        this.ai[1] = 300f;
                        this.localAI[3] = 100f;
                        if (Main.player[num381].position.X + (float)(Main.player[num381].width / 2) < this.position.X + (float)(this.width / 2))
                        {
                            this.direction = -1;
                        }
                        else
                        {
                            this.direction = 1;
                        }
                    }
                }
                if (this.ai[3] == 1f)
                {
                    this.life = -1;
                    this.HitEffect(0, 10.0);
                    this.active = false;
                    this.netUpdate = true;
                    return;
                }
                if (this.type == NPCID.OldMan && Main.netMode != 1)
                {
                    this.homeless = false;
                    this.homeTileX = Main.dungeonX;
                    this.homeTileY = Main.dungeonY;
                    if (NPC.downedBoss3)
                    {
                        this.ai[3] = 1f;
                        this.netUpdate = true;
                    }
                }
                if (Main.netMode != 1 && this.homeTileY > 0)
                {
                    while (!WorldGen.SolidTile(this.homeTileX, num380) && num380 < Main.maxTilesY - 20)
                    {
                        num380++;
                    }
                }
                if (this.type == NPCID.TravellingMerchant)
                {
                    this.homeless = true;
                    if (!Main.dayTime)
                    {
                        this.homeTileX = (int)(base.Center.X / 16f);
                        this.homeTileY = (int)(this.position.Y + (float)this.height + 2f) / 16;
                        if (!flag40)
                        {
                            this.ai[0] = 1f;
                            this.ai[1] = 200f;
                        }
                        flag38 = false;
                    }
                }
                if (this.type == NPCID.Angler && this.homeless && this.wet)
                {
                    if (base.Center.X / 16f < 380f || base.Center.X / 16f > (float)(Main.maxTilesX - 380))
                    {
                        this.homeTileX = Main.spawnTileX;
                        this.homeTileY = Main.spawnTileY;
                        this.ai[0] = 1f;
                        this.ai[1] = 200f;
                    }
                    if (this.position.X / 16f < 200f)
                    {
                        this.direction = 1;
                    }
                    else if (this.position.X / 16f > (float)(Main.maxTilesX - 200))
                    {
                        this.direction = -1;
                    }
                }
                int num382 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                int num383 = (int)(this.position.Y + (float)this.height + 1f) / 16;
                if (!WorldGen.InWorld(num382, num383, 0) || Main.tile[num382, num383] == null)
                {
                    return;
                }
                if (!this.homeless && Main.netMode != 1 && this.townNPC && (flag38 || Main.tileDungeon[(int)Main.tile[num382, num383].type]) && (num382 != this.homeTileX || num383 != num380))
                {
                    bool flag41 = true;
                    for (int num384 = 0; num384 < 2; num384++)
                    {
                        Rectangle rectangle3 = new Rectangle((int)(this.position.X + (float)(this.width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(this.position.Y + (float)(this.height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
                        if (num384 == 1)
                        {
                            rectangle3 = new Rectangle(this.homeTileX * 16 + 8 - NPC.sWidth / 2 - NPC.safeRangeX, num380 * 16 + 8 - NPC.sHeight / 2 - NPC.safeRangeY, NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
                        }
                        for (int num385 = 0; num385 < 255; num385++)
                        {
                            if (Main.player[num385].active)
                            {
                                Rectangle rectangle4 = new Rectangle((int)Main.player[num385].position.X, (int)Main.player[num385].position.Y, Main.player[num385].width, Main.player[num385].height);
                                if (rectangle4.Intersects(rectangle3))
                                {
                                    flag41 = false;
                                    break;
                                }
                            }
                            if (!flag41)
                            {
                                break;
                            }
                        }
                    }
                    if (flag41)
                    {
                        if (this.type == NPCID.OldMan || !Collision.SolidTiles(this.homeTileX - 1, this.homeTileX + 1, num380 - 3, num380 - 1))
                        {
                            this.velocity.X = 0f;
                            this.velocity.Y = 0f;
                            this.position.X = (float)(this.homeTileX * 16 + 8 - this.width / 2);
                            this.position.Y = (float)(num380 * 16 - this.height) - 0.1f;
                            this.netUpdate = true;
                        }
                        else
                        {
                            this.homeless = true;
                            WorldGen.QuickFindHome(this.whoAmI);
                        }
                    }
                }
                bool flag42 = this.type == NPCID.Mouse || this.type == NPCID.GoldMouse;
                float num386 = 200f;
                if (NPCID.Sets.DangerDetectRange[this.type] != -1)
                {
                    num386 = (float)NPCID.Sets.DangerDetectRange[this.type];
                }
                bool flag43 = false;
                bool flag44 = false;
                float num387 = -1f;
                float num388 = -1f;
                int num389 = 0;
                int num390 = -1;
                int num391 = -1;
                if (Main.netMode != 1 && !flag40)
                {
                    for (int num392 = 0; num392 < 200; num392++)
                    {
                        if (Main.npc[num392].active && !Main.npc[num392].friendly && Main.npc[num392].damage > 0 && Main.npc[num392].Distance(base.Center) < num386 && (this.type != NPCID.SkeletonMerchant || !NPCID.Sets.Skeletons.Contains(Main.npc[num392].netID)))
                        {
                            flag43 = true;
                            float num393 = Main.npc[num392].Center.X - base.Center.X;
                            if (num393 < 0f && (num387 == -1f || num393 > num387))
                            {
                                num387 = num393;
                                num390 = num392;
                            }
                            if (num393 > 0f && (num388 == -1f || num393 < num388))
                            {
                                num388 = num393;
                                num391 = num392;
                            }
                        }
                    }
                    if (flag43)
                    {
                        if (num387 == -1f)
                        {
                            num389 = 1;
                        }
                        else if (num388 == -1f)
                        {
                            num389 = -1;
                        }
                        else
                        {
                            num389 = (num388 < -num387).ToDirectionInt();
                        }
                        float num394 = 0f;
                        if (num387 != -1f)
                        {
                            num394 = -num387;
                        }
                        if (num394 == 0f || (num388 < num394 && num388 > 0f))
                        {
                            num394 = num388;
                        }
                        if (this.ai[0] == 8f)
                        {
                            if (this.direction == -num389)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = (float)(300 + Main.rand.Next(300));
                                this.ai[2] = 0f;
                                this.localAI[3] = 0f;
                                this.netUpdate = true;
                            }
                        }
                        else if (this.ai[0] != 10f && this.ai[0] != 12f && this.ai[0] != 13f && this.ai[0] != 14f && this.ai[0] != 15f)
                        {
                            if (NPCID.Sets.PrettySafe[this.type] != -1 && (float)NPCID.Sets.PrettySafe[this.type] < num394)
                            {
                                flag43 = false;
                                flag44 = true;
                            }
                            else if (this.ai[0] != 1f)
                            {
                                bool flag45 = this.ai[0] == 3f || this.ai[0] == 4f || this.ai[0] == 16f || this.ai[0] == 17f;
                                if (flag45)
                                {
                                    NPC nPC = Main.npc[(int)this.ai[2]];
                                    if (nPC.active)
                                    {
                                        nPC.ai[0] = 1f;
                                        nPC.ai[1] = (float)(120 + Main.rand.Next(120));
                                        nPC.ai[2] = 0f;
                                        nPC.localAI[3] = 0f;
                                        nPC.direction = -num389;
                                        nPC.netUpdate = true;
                                    }
                                }
                                this.ai[0] = 1f;
                                this.ai[1] = (float)(120 + Main.rand.Next(120));
                                this.ai[2] = 0f;
                                this.localAI[3] = 0f;
                                this.direction = -num389;
                                this.netUpdate = true;
                            }
                            else if (this.ai[0] == 1f && this.direction != -num389)
                            {
                                this.direction = -num389;
                                this.netUpdate = true;
                            }
                        }
                    }
                }
                if (this.ai[0] == 0f)
                {
                    if (this.localAI[3] > 0f)
                    {
                        this.localAI[3] -= 1f;
                    }
                    if (flag38 && !flag40 && !NPCID.Sets.TownCritter[this.type])
                    {
                        if (Main.netMode != 1)
                        {
                            if (num382 == this.homeTileX && num383 == num380)
                            {
                                if (this.velocity.X != 0f)
                                {
                                    this.netUpdate = true;
                                }
                                if (this.velocity.X > 0.1f)
                                {
                                    this.velocity.X = this.velocity.X - 0.1f;
                                }
                                else if (this.velocity.X < -0.1f)
                                {
                                    this.velocity.X = this.velocity.X + 0.1f;
                                }
                                else
                                {
                                    this.velocity.X = 0f;
                                }
                            }
                            else
                            {
                                if (num382 > this.homeTileX)
                                {
                                    this.direction = -1;
                                }
                                else
                                {
                                    this.direction = 1;
                                }
                                this.ai[0] = 1f;
                                this.ai[1] = (float)(200 + Main.rand.Next(200));
                                this.ai[2] = 0f;
                                this.localAI[3] = 0f;
                                this.netUpdate = true;
                            }
                        }
                    }
                    else
                    {
                        if (flag42)
                        {
                            this.velocity.X = this.velocity.X * 0.5f;
                        }
                        if (this.velocity.X > 0.1f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X < -0.1f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else
                        {
                            this.velocity.X = 0f;
                        }
                        if (Main.netMode != 1)
                        {
                            if (this.ai[1] > 0f)
                            {
                                this.ai[1] -= 1f;
                            }
                            if (this.ai[1] <= 0f)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = (float)(200 + Main.rand.Next(300));
                                this.ai[2] = 0f;
                                if (NPCID.Sets.TownCritter[this.type])
                                {
                                    this.ai[1] += (float)Main.rand.Next(200, 400);
                                }
                                this.localAI[3] = 0f;
                                this.netUpdate = true;
                            }
                        }
                    }
                    if (Main.netMode != 1 && (!flag38 || (num382 == this.homeTileX && num383 == num380)))
                    {
                        if (num382 < this.homeTileX - 25 || num382 > this.homeTileX + 25)
                        {
                            if (this.localAI[3] == 0f)
                            {
                                if (num382 < this.homeTileX - 50 && this.direction == -1)
                                {
                                    this.direction = 1;
                                    this.netUpdate = true;
                                }
                                else if (num382 > this.homeTileX + 50 && this.direction == 1)
                                {
                                    this.direction = -1;
                                    this.netUpdate = true;
                                }
                            }
                        }
                        else if (Main.rand.Next(80) == 0 && this.localAI[3] == 0f)
                        {
                            this.localAI[3] = 200f;
                            this.direction *= -1;
                            this.netUpdate = true;
                        }
                    }
                }
                else if (this.ai[0] == 1f)
                {
                    if (Main.netMode != 1 && flag38 && num382 == this.homeTileX && num383 == this.homeTileY && !NPCID.Sets.TownCritter[this.type])
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(200 + Main.rand.Next(200));
                        this.localAI[3] = 60f;
                        this.netUpdate = true;
                    }
                    else
                    {
                        bool flag46 = Collision.DrownCollision(this.position, this.width, this.height, 1f);
                        if (!flag46)
                        {
                            if (Main.netMode != 1 && !this.homeless && !Main.tileDungeon[(int)Main.tile[num382, num383].type] && (num382 < this.homeTileX - 35 || num382 > this.homeTileX + 35))
                            {
                                if (this.position.X < (float)(this.homeTileX * 16) && this.direction == -1)
                                {
                                    this.ai[1] -= 5f;
                                }
                                else if (this.position.X > (float)(this.homeTileX * 16) && this.direction == 1)
                                {
                                    this.ai[1] -= 5f;
                                }
                            }
                            this.ai[1] -= 1f;
                        }
                        if (this.ai[1] <= 0f)
                        {
                            this.ai[0] = 0f;
                            this.ai[1] = (float)(300 + Main.rand.Next(300));
                            this.ai[2] = 0f;
                            if (NPCID.Sets.TownCritter[this.type])
                            {
                                this.ai[1] -= (float)Main.rand.Next(100);
                            }
                            else
                            {
                                this.ai[1] += (float)Main.rand.Next(900);
                            }
                            this.localAI[3] = 60f;
                            this.netUpdate = true;
                        }
                        if (this.closeDoor && ((this.position.X + (float)(this.width / 2)) / 16f > (float)(this.doorX + 2) || (this.position.X + (float)(this.width / 2)) / 16f < (float)(this.doorX - 2)))
                        {
                            Tile tileSafely = Framing.GetTileSafely(this.doorX, this.doorY);
                            if (tileSafely.type == 11)
                            {
                                bool flag47 = WorldGen.CloseDoor(this.doorX, this.doorY, false);
                                if (flag47)
                                {
                                    this.closeDoor = false;
                                    NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 1, (float)this.doorX, (float)this.doorY, (float)this.direction, 0, 0, 0);
                                }
                                if ((this.position.X + (float)(this.width / 2)) / 16f > (float)(this.doorX + 4) || (this.position.X + (float)(this.width / 2)) / 16f < (float)(this.doorX - 4) || (this.position.Y + (float)(this.height / 2)) / 16f > (float)(this.doorY + 4) || (this.position.Y + (float)(this.height / 2)) / 16f < (float)(this.doorY - 4))
                                {
                                    this.closeDoor = false;
                                }
                            }
                            else if (tileSafely.type == 389)
                            {
                                bool flag48 = WorldGen.ShiftTallGate(this.doorX, this.doorY, true);
                                if (flag48)
                                {
                                    this.closeDoor = false;
                                    NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 5, (float)this.doorX, (float)this.doorY, 0f, 0, 0, 0);
                                }
                                if ((this.position.X + (float)(this.width / 2)) / 16f > (float)(this.doorX + 4) || (this.position.X + (float)(this.width / 2)) / 16f < (float)(this.doorX - 4) || (this.position.Y + (float)(this.height / 2)) / 16f > (float)(this.doorY + 4) || (this.position.Y + (float)(this.height / 2)) / 16f < (float)(this.doorY - 4))
                                {
                                    this.closeDoor = false;
                                }
                            }
                            else
                            {
                                this.closeDoor = false;
                            }
                        }
                        float num395 = 1f;
                        float num396 = 0.07f;
                        if (this.type == NPCID.Squirrel || this.type == NPCID.SquirrelGold || this.type == NPCID.SquirrelRed)
                        {
                            num395 = 1.5f;
                        }
                        if (flag42)
                        {
                            num395 = 2f;
                            num396 = 1f;
                        }
                        if (this.friendly && (flag43 || flag46))
                        {
                            num395 = 1.5f;
                            float num397 = 1f - (float)this.life / (float)this.lifeMax;
                            num395 += num397 * 0.9f;
                            num396 = 0.1f;
                        }
                        if (this.velocity.X < -num395 || this.velocity.X > num395)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity *= 0.8f;
                            }
                        }
                        else if (this.velocity.X < num395 && this.direction == 1)
                        {
                            this.velocity.X = this.velocity.X + num396;
                            if (this.velocity.X > num395)
                            {
                                this.velocity.X = num395;
                            }
                        }
                        else if (this.velocity.X > -num395 && this.direction == -1)
                        {
                            this.velocity.X = this.velocity.X - num396;
                            if (this.velocity.X > num395)
                            {
                                this.velocity.X = num395;
                            }
                        }
                        bool holdsMatching = true;
                        if ((float)(this.homeTileY * 16 - 32) > this.position.Y)
                        {
                            holdsMatching = false;
                        }
                        if ((this.direction == 1 && this.position.Y + (float)(this.width / 2) > (float)(this.homeTileX * 16)) || (this.direction == -1 && this.position.Y + (float)(this.width / 2) < (float)(this.homeTileX * 16)))
                        {
                            holdsMatching = true;
                        }
                        if (this.velocity.Y == 0f)
                        {
                            Collision.StepDown(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, 1, false);
                        }
                        if (this.velocity.Y >= 0f)
                        {
                            Collision.StepUp(ref this.position, ref this.velocity, this.width, this.height, ref this.stepSpeed, ref this.gfxOffY, 1, holdsMatching, 1);
                        }
                        if (this.velocity.Y == 0f)
                        {
                            int num398 = (int)((this.position.X + (float)(this.width / 2) + (float)(15 * this.direction)) / 16f);
                            int num399 = (int)((this.position.Y + (float)this.height - 16f) / 16f);
                            bool flag49 = false;
                            bool flag50 = true;
                            if (this.townNPC && this.ai[1] < 30f)
                            {
                                flag49 = !Utils.PlotTileLine(base.Top, base.Bottom, (float)this.width, new Utils.PerLinePoint(DelegateMethods.SearchAvoidedByNPCs));
                                if (!flag49)
                                {
                                    Rectangle hitbox = base.Hitbox;
                                    hitbox.X -= 20;
                                    hitbox.Width += 40;
                                    for (int num400 = 0; num400 < 200; num400++)
                                    {
                                        if (Main.npc[num400].active && Main.npc[num400].friendly && num400 != this.whoAmI && Main.npc[num400].velocity.X == 0f && hitbox.Intersects(Main.npc[num400].Hitbox))
                                        {
                                            flag49 = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!flag49 && flag46)
                            {
                                flag49 = true;
                            }
                            if (flag50 && (NPCID.Sets.TownCritter[this.type] || num382 < this.homeTileX - 35 || num382 > this.homeTileX + 35))
                            {
                                flag50 = false;
                            }
                            if (flag50)
                            {
                                int num401 = 0;
                                for (int num402 = -1; num402 <= 4; num402++)
                                {
                                    Tile tileSafely2 = Framing.GetTileSafely(num398 - this.direction * num401, num399 + num402);
                                    if (tileSafely2.lava() && tileSafely2.liquid > 0)
                                    {
                                        flag50 = true;
                                        break;
                                    }
                                    if (tileSafely2.nactive() && Main.tileSolid[(int)tileSafely2.type])
                                    {
                                        flag50 = false;
                                    }
                                }
                            }
                            if (!flag50 && this.wet)
                            {
                                bool flag51 = flag46;
                                bool flag52 = false;
                                if (!flag51)
                                {
                                    flag52 = Collision.DrownCollision(this.position + new Vector2((float)(this.width * this.direction), 0f), this.width, this.height, 1f);
                                }
                                flag52 = (flag52 || Collision.DrownCollision(this.position + new Vector2((float)(this.width * this.direction), (float)(this.height * 2 - 16 - (flag51 ? 16 : 0))), this.width, 16 + (flag51 ? 16 : 0), 1f));
                                if (flag52 && this.localAI[3] <= 0f)
                                {
                                    flag50 = true;
                                    this.localAI[3] = 600f;
                                }
                            }
                            if (this.position.X == this.localAI[3])
                            {
                                this.direction *= -1;
                                this.netUpdate = true;
                                this.localAI[3] = 600f;
                            }
                            if (flag46)
                            {
                                if (this.localAI[3] > 0f)
                                {
                                    this.localAI[3] -= 1f;
                                }
                            }
                            else
                            {
                                this.localAI[3] = -1f;
                            }
                            Tile tileSafely3 = Framing.GetTileSafely(num398, num399);
                            Tile tileSafely4 = Framing.GetTileSafely(num398, num399 - 1);
                            Tile tileSafely5 = Framing.GetTileSafely(num398, num399 - 2);
                            if (this.townNPC && tileSafely5.nactive() && (tileSafely5.type == 10 || tileSafely5.type == 388) && (Main.rand.Next(10) == 0 || flag38))
                            {
                                if (Main.netMode != 1)
                                {
                                    if (WorldGen.OpenDoor(num398, num399 - 2, this.direction))
                                    {
                                        this.closeDoor = true;
                                        this.doorX = num398;
                                        this.doorY = num399 - 2;
                                        NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 0, (float)num398, (float)(num399 - 2), (float)this.direction, 0, 0, 0);
                                        this.netUpdate = true;
                                        this.ai[1] += 80f;
                                    }
                                    else if (WorldGen.OpenDoor(num398, num399 - 2, -this.direction))
                                    {
                                        this.closeDoor = true;
                                        this.doorX = num398;
                                        this.doorY = num399 - 2;
                                        NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 0, (float)num398, (float)(num399 - 2), (float)(-(float)this.direction), 0, 0, 0);
                                        this.netUpdate = true;
                                        this.ai[1] += 80f;
                                    }
                                    else if (WorldGen.ShiftTallGate(num398, num399 - 2, false))
                                    {
                                        this.closeDoor = true;
                                        this.doorX = num398;
                                        this.doorY = num399 - 2;
                                        NetMessage.SendData((int)PacketTypes.DoorUse, -1, -1, "", 4, (float)num398, (float)(num399 - 2), 0f, 0, 0, 0);
                                        this.netUpdate = true;
                                        this.ai[1] += 80f;
                                    }
                                    else
                                    {
                                        this.direction *= -1;
                                        this.netUpdate = true;
                                    }
                                }
                            }
                            else
                            {
                                if ((this.velocity.X < 0f && this.spriteDirection == -1) || (this.velocity.X > 0f && this.spriteDirection == 1))
                                {
                                    if (tileSafely5.nactive() && Main.tileSolid[(int)tileSafely5.type] && !Main.tileSolidTop[(int)tileSafely5.type])
                                    {
                                        if (!Collision.SolidTilesVersatile(num398 - this.direction * 2, num398 - this.direction, num399 - 5, num399 - 1) && !Collision.SolidTiles(num398, num398, num399 - 5, num399 - 3))
                                        {
                                            this.velocity.Y = -6f;
                                            this.netUpdate = true;
                                        }
                                        else if (flag42)
                                        {
                                            if (WorldGen.SolidTile((int)(base.Center.X / 16f) + this.direction, (int)(base.Center.Y / 16f)))
                                            {
                                                this.direction *= -1;
                                                this.velocity.X = this.velocity.X * 0f;
                                                this.netUpdate = true;
                                            }
                                        }
                                        else if (flag43)
                                        {
                                            flag49 = false;
                                            this.velocity.X = 0f;
                                            this.direction *= -1;
                                            this.netUpdate = true;
                                            this.ai[0] = 8f;
                                            this.ai[1] = 240f;
                                        }
                                        else
                                        {
                                            this.direction *= -1;
                                            this.netUpdate = true;
                                        }
                                    }
                                    else if (tileSafely4.nactive() && Main.tileSolid[(int)tileSafely4.type] && !Main.tileSolidTop[(int)tileSafely4.type])
                                    {
                                        if (!Collision.SolidTilesVersatile(num398 - this.direction * 2, num398 - this.direction, num399 - 4, num399 - 1) && !Collision.SolidTiles(num398, num398, num399 - 4, num399 - 2))
                                        {
                                            this.velocity.Y = -5f;
                                            this.netUpdate = true;
                                        }
                                        else if (flag43)
                                        {
                                            flag49 = false;
                                            this.velocity.X = 0f;
                                            this.direction *= -1;
                                            this.netUpdate = true;
                                            this.ai[0] = 8f;
                                            this.ai[1] = 240f;
                                        }
                                        else
                                        {
                                            this.direction *= -1;
                                            this.netUpdate = true;
                                        }
                                    }
                                    else if (this.position.Y + (float)this.height - (float)(num399 * 16) > 20f && tileSafely3.nactive() && Main.tileSolid[(int)tileSafely3.type] && !tileSafely3.topSlope())
                                    {
                                        if (!Collision.SolidTilesVersatile(num398 - this.direction * 2, num398, num399 - 3, num399 - 1))
                                        {
                                            this.velocity.Y = -4.4f;
                                            this.netUpdate = true;
                                        }
                                        else if (flag43)
                                        {
                                            flag49 = false;
                                            this.velocity.X = 0f;
                                            this.direction *= -1;
                                            this.netUpdate = true;
                                            this.ai[0] = 8f;
                                            this.ai[1] = 240f;
                                        }
                                        else
                                        {
                                            this.direction *= -1;
                                            this.netUpdate = true;
                                        }
                                    }
                                    else if (flag50)
                                    {
                                        this.direction *= -1;
                                        this.velocity.X = this.velocity.X * -1f;
                                        this.netUpdate = true;
                                        if (flag43)
                                        {
                                            flag49 = false;
                                            this.velocity.X = 0f;
                                            this.ai[0] = 8f;
                                            this.ai[1] = 240f;
                                        }
                                    }
                                    if (flag49)
                                    {
                                        this.ai[1] = 90f;
                                        this.netUpdate = true;
                                    }
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.localAI[3] = this.position.X;
                                    }
                                }
                                if (this.velocity.Y < 0f && this.wet)
                                {
                                    this.velocity.Y = this.velocity.Y * 1.2f;
                                }
                                if (this.velocity.Y < 0f && NPCID.Sets.TownCritter[this.type] && !flag42)
                                {
                                    this.velocity.Y = this.velocity.Y * 1.2f;
                                }
                            }
                        }
                    }
                }
                else if (this.ai[0] == 2f || this.ai[0] == 11f)
                {
                    if (Main.netMode != 1)
                    {
                        this.localAI[3] -= 1f;
                        if (Main.rand.Next(60) == 0 && this.localAI[3] == 0f)
                        {
                            this.localAI[3] = 60f;
                            this.direction *= -1;
                            this.netUpdate = true;
                        }
                    }
                    this.ai[1] -= 1f;
                    this.velocity.X = this.velocity.X * 0.8f;
                    if (this.ai[1] <= 0f)
                    {
                        this.localAI[3] = 40f;
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(60 + Main.rand.Next(60));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 3f || this.ai[0] == 4f || this.ai[0] == 5f || this.ai[0] == 8f || this.ai[0] == 9f || this.ai[0] == 16f || this.ai[0] == 17f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] -= 1f;
                    if (this.ai[0] == 8f && this.ai[1] < 60f && flag43)
                    {
                        this.ai[1] = 180f;
                        this.netUpdate = true;
                    }
                    if (this.ai[0] == 5f)
                    {
                        Point point = base.Center.ToTileCoordinates();
                        Tile tile = Main.tile[point.X, point.Y];
                        if (tile.type != TileID.Chairs)
                        {
                            this.ai[1] = 0f;
                        }
                    }
                    if (this.ai[1] <= 0f)
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(60 + Main.rand.Next(60));
                        this.ai[2] = 0f;
                        this.localAI[3] = (float)(30 + Main.rand.Next(60));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 6f || this.ai[0] == 7f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] -= 1f;
                    int num403 = (int)this.ai[2];
                    if (num403 < 0 || num403 > 255 || !Main.player[num403].active || Main.player[num403].dead || Main.player[num403].Distance(base.Center) > 200f || !Collision.CanHitLine(base.Top, 0, 0, Main.player[num403].Top, 0, 0))
                    {
                        this.ai[1] = 0f;
                    }
                    if (this.ai[1] > 0f)
                    {
                        int num404 = (base.Center.X < Main.player[num403].Center.X) ? 1 : -1;
                        if (num404 != this.direction)
                        {
                            this.netUpdate = true;
                        }
                        this.direction = num404;
                    }
                    else
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(60 + Main.rand.Next(60));
                        this.ai[2] = 0f;
                        this.localAI[3] = (float)(30 + Main.rand.Next(60));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 10f)
                {
                    int num405 = 0;
                    int num406 = 0;
                    float knockBack = 0f;
                    float scaleFactor7 = 0f;
                    int num407 = 0;
                    int num408 = 0;
                    int maxValue3 = 0;
                    float num409 = 0f;
                    float num410 = (float)NPCID.Sets.DangerDetectRange[this.type];
                    float num411 = 0f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0.0;
                        this.localAI[3] = 0f;
                    }
                    if (this.type == NPCID.Demolitionist)
                    {
                        num405 = 30;
                        scaleFactor7 = 6f;
                        num406 = 20;
                        num407 = 10;
                        num408 = 180;
                        maxValue3 = 120;
                        num409 = 16f;
                        knockBack = 7f;
                    }
                    else if (this.type == NPCID.PartyGirl)
                    {
                        num405 = 588;
                        scaleFactor7 = 6f;
                        num406 = 30;
                        num407 = 10;
                        num408 = 60;
                        maxValue3 = 120;
                        num409 = 16f;
                        knockBack = 6f;
                    }
                    else if (this.type == NPCID.Merchant)
                    {
                        num405 = 48;
                        scaleFactor7 = 9f;
                        num406 = 12;
                        num407 = 10;
                        num408 = 60;
                        maxValue3 = 60;
                        num409 = 16f;
                        knockBack = 1.5f;
                    }
                    else if (this.type == NPCID.Angler)
                    {
                        num405 = 520;
                        scaleFactor7 = 12f;
                        num406 = 10;
                        num407 = 10;
                        num408 = 0;
                        maxValue3 = 1;
                        num409 = 16f;
                        knockBack = 3f;
                    }
                    else if (this.type == NPCID.SkeletonMerchant)
                    {
                        num405 = 21;
                        scaleFactor7 = 14f;
                        num406 = 14;
                        num407 = 10;
                        num408 = 0;
                        maxValue3 = 1;
                        num409 = 16f;
                        knockBack = 3f;
                    }
                    else if (this.type == NPCID.GoblinTinkerer)
                    {
                        num405 = 24;
                        scaleFactor7 = 5f;
                        num406 = 15;
                        num407 = 10;
                        num408 = 60;
                        maxValue3 = 60;
                        num409 = 16f;
                        knockBack = 1f;
                    }
                    else if (this.type == NPCID.Mechanic)
                    {
                        num405 = 582;
                        scaleFactor7 = 10f;
                        num406 = 11;
                        num407 = 1;
                        num408 = 30;
                        maxValue3 = 30;
                        knockBack = 3.5f;
                    }
                    else if (this.type == NPCID.Nurse)
                    {
                        num405 = 583;
                        scaleFactor7 = 8f;
                        num406 = 8;
                        num407 = 1;
                        num408 = 15;
                        maxValue3 = 10;
                        knockBack = 2f;
                        num409 = 10f;
                    }
                    else if (this.type == NPCID.SantaClaus)
                    {
                        num405 = 589;
                        scaleFactor7 = 7f;
                        num406 = 22;
                        num407 = 1;
                        num408 = 10;
                        maxValue3 = 1;
                        knockBack = 2f;
                        num409 = 10f;
                    }
                    if (Main.expertMode)
                    {
                        num406 = (int)((float)num406 * Main.expertNPCDamage);
                    }
                    num406 = (int)((float)num406 * num378);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] -= 1f;
                    this.localAI[3] += 1f;
                    if (this.localAI[3] == (float)num407 && Main.netMode != 1)
                    {
                        Vector2 vector41 = -Vector2.UnitY;
                        if (num389 == 1 && this.spriteDirection == 1 && num391 != -1)
                        {
                            vector41 = base.DirectionTo(Main.npc[num391].Center + new Vector2(0f, -num409 * MathHelper.Clamp(base.Distance(Main.npc[num391].Center) / num410, 0f, 1f)));
                        }
                        if (num389 == -1 && this.spriteDirection == -1 && num390 != -1)
                        {
                            vector41 = base.DirectionTo(Main.npc[num390].Center + new Vector2(0f, -num409 * MathHelper.Clamp(base.Distance(Main.npc[num390].Center) / num410, 0f, 1f)));
                        }
                        if (vector41.HasNaNs() || Math.Sign(vector41.X) != this.spriteDirection)
                        {
                            vector41 = new Vector2((float)this.spriteDirection, -1f);
                        }
                        vector41 *= scaleFactor7;
                        vector41 += Utils.RandomVector2(Main.rand, -num411, num411);
                        int num412;
                        if (this.type == NPCID.Mechanic)
                        {
                            num412 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector41.X, vector41.Y, num405, num406, knockBack, Main.myPlayer, 0f, (float)this.whoAmI);
                        }
                        else if (this.type == NPCID.SantaClaus)
                        {
                            num412 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector41.X, vector41.Y, num405, num406, knockBack, Main.myPlayer, 0f, (float)Main.rand.Next(5));
                        }
                        else
                        {
                            num412 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector41.X, vector41.Y, num405, num406, knockBack, Main.myPlayer, 0f, 0f);
                        }
                        Main.projectile[num412].npcProj = true;
                        Main.projectile[num412].noDropItem = true;
                    }
                    if (this.ai[1] <= 0f && !false)
                    {
                        this.ai[0] = (float)((this.localAI[2] == 8f && flag43) ? 8 : 0);
                        this.ai[1] = (float)(num408 + Main.rand.Next(maxValue3));
                        this.ai[2] = 0f;
                        this.localAI[1] = (this.localAI[3] = (float)(num408 / 2 + Main.rand.Next(maxValue3)));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 12f)
                {
                    int num413 = 0;
                    int num414 = 0;
                    float scaleFactor8 = 0f;
                    int num415 = 0;
                    int num416 = 0;
                    int maxValue4 = 0;
                    float knockBack2 = 0f;
                    int num417 = 0;
                    bool flag53 = false;
                    float num418 = 0f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0.0;
                        this.localAI[3] = 0f;
                    }
                    int num419 = -1;
                    if (num389 == 1 && this.spriteDirection == 1)
                    {
                        num419 = num391;
                    }
                    if (num389 == -1 && this.spriteDirection == -1)
                    {
                        num419 = num390;
                    }
                    if (this.type == NPCID.ArmsDealer)
                    {
                        num413 = 14;
                        scaleFactor8 = 13f;
                        num414 = 24;
                        num416 = 14;
                        maxValue4 = 4;
                        knockBack2 = 3f;
                        num415 = 1;
                        num418 = 0.5f;
                        if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                        {
                            this.frameCounter = 0.0;
                            this.localAI[3] = 0f;
                        }
                        if (Main.hardMode)
                        {
                            num414 = 15;
                            if (this.localAI[3] > (float)num415)
                            {
                                num415 = 10;
                                flag53 = true;
                            }
                            if (this.localAI[3] > (float)num415)
                            {
                                num415 = 20;
                                flag53 = true;
                            }
                            if (this.localAI[3] > (float)num415)
                            {
                                num415 = 30;
                                flag53 = true;
                            }
                        }
                    }
                    else if (this.type == NPCID.Painter)
                    {
                        num413 = 587;
                        scaleFactor8 = 10f;
                        num414 = 8;
                        num416 = 10;
                        maxValue4 = 1;
                        knockBack2 = 1.75f;
                        num415 = 1;
                        num418 = 0.5f;
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 12;
                            flag53 = true;
                        }
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 24;
                            flag53 = true;
                        }
                        if (Main.hardMode)
                        {
                            num414 += 2;
                        }
                    }
                    else if (this.type == NPCID.TravellingMerchant)
                    {
                        num413 = 14;
                        scaleFactor8 = 13f;
                        num414 = 24;
                        num416 = 12;
                        maxValue4 = 5;
                        knockBack2 = 2f;
                        num415 = 1;
                        num418 = 0.2f;
                        if (Main.hardMode)
                        {
                            num414 = 30;
                            num413 = 357;
                        }
                    }
                    else if (this.type == NPCID.Guide)
                    {
                        scaleFactor8 = 10f;
                        num414 = 8;
                        num415 = 1;
                        if (Main.hardMode)
                        {
                            num413 = 2;
                            num416 = 15;
                            maxValue4 = 10;
                            num414 += 6;
                        }
                        else
                        {
                            num413 = 1;
                            num416 = 30;
                            maxValue4 = 20;
                        }
                        knockBack2 = 2.75f;
                        num417 = 4;
                        num418 = 0.7f;
                    }
                    else if (this.type == NPCID.WitchDoctor)
                    {
                        num413 = 267;
                        scaleFactor8 = 14f;
                        num414 = 20;
                        num415 = 1;
                        num416 = 10;
                        maxValue4 = 1;
                        knockBack2 = 3f;
                        num417 = 6;
                        num418 = 0.4f;
                    }
                    else if (this.type == NPCID.Steampunker)
                    {
                        num413 = 242;
                        scaleFactor8 = 13f;
                        num414 = 15;
                        num416 = 10;
                        maxValue4 = 1;
                        knockBack2 = 2f;
                        num415 = 1;
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 8;
                            flag53 = true;
                        }
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 16;
                            flag53 = true;
                        }
                        num418 = 0.3f;
                    }
                    else if (this.type == NPCID.Pirate)
                    {
                        num413 = 14;
                        scaleFactor8 = 14f;
                        num414 = 24;
                        num416 = 10;
                        maxValue4 = 1;
                        knockBack2 = 2f;
                        num415 = 1;
                        num418 = 0.7f;
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 16;
                            flag53 = true;
                        }
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 24;
                            flag53 = true;
                        }
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 32;
                            flag53 = true;
                        }
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 40;
                            flag53 = true;
                        }
                        if (this.localAI[3] > (float)num415)
                        {
                            num415 = 48;
                            flag53 = true;
                        }
                        if (this.localAI[3] == 0f && num419 != -1 && base.Distance(Main.npc[num419].Center) < (float)NPCID.Sets.PrettySafe[this.type])
                        {
                            num418 = 0.1f;
                            num413 = 162;
                            num414 = 50;
                            knockBack2 = 10f;
                            scaleFactor8 = 24f;
                        }
                    }
                    else if (this.type == NPCID.Cyborg)
                    {
                        int num420 = Utils.SelectRandom<int>(Main.rand, new int[]
                        {
                            134,
                            133,
                            135
                        });
                        num413 = num420;
                        num415 = 1;
                        if (num413 == 135)
                        {
                            scaleFactor8 = 12f;
                            num414 = 30;
                            num416 = 30;
                            maxValue4 = 10;
                            knockBack2 = 7f;
                            num418 = 0.2f;
                        }
                        else if (num413 == 133)
                        {
                            scaleFactor8 = 10f;
                            num414 = 25;
                            num416 = 10;
                            maxValue4 = 1;
                            knockBack2 = 6f;
                            num418 = 0.2f;
                        }
                        else if (num413 == 134)
                        {
                            scaleFactor8 = 13f;
                            num414 = 20;
                            num416 = 20;
                            maxValue4 = 10;
                            knockBack2 = 4f;
                            num418 = 0.1f;
                        }
                    }
                    if (Main.expertMode)
                    {
                        num414 = (int)((float)num414 * Main.expertNPCDamage);
                    }
                    num414 = (int)((float)num414 * num378);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] -= 1f;
                    this.localAI[3] += 1f;
                    if (this.localAI[3] == (float)num415 && Main.netMode != 1)
                    {
                        Vector2 vector42 = Vector2.Zero;
                        if (num419 != -1)
                        {
                            vector42 = base.DirectionTo(Main.npc[num419].Center + new Vector2(0f, (float)(-(float)num417)));
                        }
                        if (vector42.HasNaNs() || Math.Sign(vector42.X) != this.spriteDirection)
                        {
                            vector42 = new Vector2((float)this.spriteDirection, 0f);
                        }
                        vector42 *= scaleFactor8;
                        vector42 += Utils.RandomVector2(Main.rand, -num418, num418);
                        int num421;
                        if (this.type == NPCID.Painter)
                        {
                            num421 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector42.X, vector42.Y, num413, num414, knockBack2, Main.myPlayer, 0f, (float)Main.rand.Next(12) / 6f);
                        }
                        else
                        {
                            num421 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector42.X, vector42.Y, num413, num414, knockBack2, Main.myPlayer, 0f, 0f);
                        }
                        Main.projectile[num421].npcProj = true;
                        Main.projectile[num421].noDropItem = true;
                    }
                    if (this.localAI[3] == (float)num415 && flag53 && num419 != -1)
                    {
                        Vector2 vector43 = base.DirectionTo(Main.npc[num419].Center);
                        if (vector43.Y <= 0.5f && vector43.Y >= -0.5f)
                        {
                            this.ai[2] = vector43.Y;
                        }
                    }
                    if (this.ai[1] <= 0f && !false)
                    {
                        this.ai[0] = (float)((this.localAI[2] == 8f && flag43) ? 8 : 0);
                        this.ai[1] = (float)(num416 + Main.rand.Next(maxValue4));
                        this.ai[2] = 0f;
                        this.localAI[1] = (this.localAI[3] = (float)(num416 / 2 + Main.rand.Next(maxValue4)));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 13f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0.0;
                    }
                    this.ai[1] -= 1f;
                    this.localAI[3] += 1f;
                    if (this.localAI[3] == 1f && Main.netMode != 1)
                    {
                        Vector2 vec2 = base.DirectionTo(Main.npc[(int)this.ai[2]].Center + new Vector2(0f, -20f));
                        if (vec2.HasNaNs() || Math.Sign(vec2.X) == -this.spriteDirection)
                        {
                            vec2 = new Vector2((float)this.spriteDirection, -1f);
                        }
                        vec2 *= 8f;
                        int num422 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vec2.X, vec2.Y, 584, 0, 0f, Main.myPlayer, this.ai[2], 0f);
                        Main.projectile[num422].npcProj = true;
                        Main.projectile[num422].noDropItem = true;
                    }
                    if (this.ai[1] <= 0f)
                    {
                        this.ai[0] = 0f;
                        this.ai[1] = (float)(10 + Main.rand.Next(10));
                        this.ai[2] = 0f;
                        this.localAI[3] = (float)(5 + Main.rand.Next(10));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 14f)
                {
                    int num423 = 0;
                    int num424 = 0;
                    float scaleFactor9 = 0f;
                    int num425 = 0;
                    int num426 = 0;
                    int maxValue5 = 0;
                    float knockBack3 = 0f;
                    float num427 = 0f;
                    float num428 = (float)NPCID.Sets.DangerDetectRange[this.type];
                    float num429 = 1f;
                    float num430 = 0f;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0.0;
                        this.localAI[3] = 0f;
                    }
                    int num431 = -1;
                    if (num389 == 1 && this.spriteDirection == 1)
                    {
                        num431 = num391;
                    }
                    if (num389 == -1 && this.spriteDirection == -1)
                    {
                        num431 = num390;
                    }
                    if (this.type == NPCID.Clothier)
                    {
                        num423 = 585;
                        scaleFactor9 = 10f;
                        num424 = 16;
                        num425 = 30;
                        num426 = 20;
                        maxValue5 = 15;
                        knockBack3 = 2f;
                        num430 = 1f;
                    }
                    else if (this.type == NPCID.Wizard)
                    {
                        num423 = 15;
                        scaleFactor9 = 6f;
                        num424 = 18;
                        num425 = 15;
                        num426 = 15;
                        maxValue5 = 5;
                        knockBack3 = 3f;
                        num427 = 20f;
                    }
                    else if (this.type == NPCID.Truffle)
                    {
                        num423 = 590;
                        num424 = 40;
                        num425 = 15;
                        num426 = 10;
                        maxValue5 = 1;
                        knockBack3 = 3f;
                        while (this.localAI[3] > (float)num425)
                        {
                            num425 += 15;
                        }
                    }
                    else if (this.type == NPCID.Dryad)
                    {
                        num423 = 586;
                        num425 = 24;
                        num426 = 10;
                        maxValue5 = 1;
                        knockBack3 = 3f;
                    }
                    if (Main.expertMode)
                    {
                        num424 = (int)((float)num424 * Main.expertNPCDamage);
                    }
                    num424 = (int)((float)num424 * num378);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] -= 1f;
                    this.localAI[3] += 1f;
                    if (this.localAI[3] == (float)num425 && Main.netMode != 1)
                    {
                        Vector2 vector44 = Vector2.Zero;
                        if (num431 != -1)
                        {
                            vector44 = base.DirectionTo(Main.npc[num431].Center + new Vector2(0f, -num427 * MathHelper.Clamp(base.Distance(Main.npc[num431].Center) / num428, 0f, 1f)));
                        }
                        if (vector44.HasNaNs() || Math.Sign(vector44.X) != this.spriteDirection)
                        {
                            vector44 = new Vector2((float)this.spriteDirection, 0f);
                        }
                        vector44 *= scaleFactor9;
                        vector44 += Utils.RandomVector2(Main.rand, -num430, num430);
                        if (this.type == NPCID.Wizard)
                        {
                            int num432 = Utils.SelectRandom<int>(Main.rand, new int[]
                            {
                                1,
                                1,
                                1,
                                1,
                                2,
                                2,
                                3
                            });
                            for (int num433 = 0; num433 < num432; num433++)
                            {
                                Vector2 vector45 = Utils.RandomVector2(Main.rand, -3.4f, 3.4f);
                                int num434 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector44.X + vector45.X, vector44.Y + vector45.Y, num423, num424, knockBack3, Main.myPlayer, 0f, 0f);
                                Main.projectile[num434].npcProj = true;
                                Main.projectile[num434].noDropItem = true;
                            }
                        }
                        else if (this.type == NPCID.Truffle)
                        {
                            if (num431 != -1)
                            {
                                Vector2 vector46 = Main.npc[num431].position - Main.npc[num431].Size * 2f + Main.npc[num431].Size * Utils.RandomVector2(Main.rand, 0f, 1f) * 5f;
                                int num435 = 10;
                                while (num435 > 0 && WorldGen.SolidTile(Framing.GetTileSafely((int)vector46.X / 16, (int)vector46.Y / 16)))
                                {
                                    num435--;
                                    vector46 = Main.npc[num431].position - Main.npc[num431].Size * 2f + Main.npc[num431].Size * Utils.RandomVector2(Main.rand, 0f, 1f) * 5f;
                                }
                                int num436 = Projectile.NewProjectile(vector46.X, vector46.Y, 0f, 0f, num423, num424, knockBack3, Main.myPlayer, 0f, 0f);
                                Main.projectile[num436].npcProj = true;
                                Main.projectile[num436].noDropItem = true;
                            }
                        }
                        else if (this.type == NPCID.Dryad)
                        {
                            int num437 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector44.X, vector44.Y, num423, num424, knockBack3, Main.myPlayer, 0f, (float)this.whoAmI);
                            Main.projectile[num437].npcProj = true;
                            Main.projectile[num437].noDropItem = true;
                        }
                        else
                        {
                            int num438 = Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * 16), base.Center.Y - 2f, vector44.X, vector44.Y, num423, num424, knockBack3, Main.myPlayer, 0f, 0f);
                            Main.projectile[num438].npcProj = true;
                            Main.projectile[num438].noDropItem = true;
                        }
                    }
                    if (num429 > 0f)
                    {
                        Vector3 vector47 = NPCID.Sets.MagicAuraColor[this.type].ToVector3() * num429;
                    }
                    if (this.ai[1] <= 0f && !false)
                    {
                        this.ai[0] = (float)((this.localAI[2] == 8f && flag43) ? 8 : 0);
                        this.ai[1] = (float)(num426 + Main.rand.Next(maxValue5));
                        this.ai[2] = 0f;
                        this.localAI[1] = (this.localAI[3] = (float)(num426 / 2 + Main.rand.Next(maxValue5)));
                        this.netUpdate = true;
                    }
                }
                else if (this.ai[0] == 15f)
                {
                    int num439 = 0;
                    int maxValue6 = 0;
                    if ((float)NPCID.Sets.AttackTime[this.type] == this.ai[1])
                    {
                        this.frameCounter = 0.0;
                        this.localAI[3] = 0f;
                    }
                    int num440 = 0;
                    float num441 = 0f;
                    int num442 = 0;
                    int num443 = 0;
                    if (num389 == 1)
                    {
                        int arg_1BD94_0 = this.spriteDirection;
                    }
                    if (num389 == -1)
                    {
                        int arg_1BDA4_0 = this.spriteDirection;
                    }
                    if (this.type == NPCID.DyeTrader)
                    {
                        num440 = 11;
                        num443 = (num442 = 32);
                        num439 = 12;
                        maxValue6 = 6;
                        num441 = 4.25f;
                    }
                    else if (this.type == NPCID.TaxCollector)
                    {
                        num440 = 9;
                        num443 = (num442 = 28);
                        num439 = 9;
                        maxValue6 = 3;
                        num441 = 3.5f;
                    }
                    else if (this.type == NPCID.Stylist)
                    {
                        num440 = 10;
                        num443 = (num442 = 32);
                        num439 = 15;
                        maxValue6 = 8;
                        num441 = 5f;
                    }
                    if (Main.expertMode)
                    {
                        num440 = (int)((float)num440 * Main.expertNPCDamage);
                    }
                    num440 = (int)((float)num440 * num378);
                    this.velocity.X = this.velocity.X * 0.8f;
                    this.ai[1] -= 1f;
                    if (Main.netMode != 1)
                    {
                        Tuple<Vector2, float> swingStats = this.GetSwingStats(NPCID.Sets.AttackTime[this.type] * 2, (int)this.ai[1], this.spriteDirection, num442, num443);
                        Rectangle rectangle5 = new Rectangle((int)swingStats.Item1.X, (int)swingStats.Item1.Y, num442, num443);
                        if (this.spriteDirection == -1)
                        {
                            rectangle5.X -= num442;
                        }
                        rectangle5.Y -= num443;
                        this.TweakSwingStats(NPCID.Sets.AttackTime[this.type] * 2, (int)this.ai[1], this.spriteDirection, ref rectangle5);
                        int myPlayer = Main.myPlayer;
                        for (int num444 = 0; num444 < 200; num444++)
                        {
                            NPC nPC2 = Main.npc[num444];
                            if (nPC2.active && nPC2.immune[myPlayer] == 0 && !nPC2.dontTakeDamage && !nPC2.friendly && nPC2.damage > 0 && rectangle5.Intersects(nPC2.Hitbox) && (nPC2.noTileCollide || Collision.CanHit(this.position, this.width, this.height, nPC2.position, nPC2.width, nPC2.height)))
                            {
                                nPC2.StrikeNPCNoInteraction(num440, num441, this.spriteDirection, false, false, false);
                                if (Main.netMode != 0)
                                {
                                    NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", num444, (float)num440, num441, (float)this.spriteDirection, 0, 0, 0);
                                }
                                nPC2.netUpdate = true;
                                nPC2.immune[myPlayer] = (int)this.ai[1] + 2;
                            }
                        }
                    }
                    if (this.ai[1] <= 0f)
                    {
                        bool flag54 = false;
                        if (flag43)
                        {
                            int num445 = -num389;
                            if (!Collision.CanHit(base.Center, 0, 0, base.Center + Vector2.UnitX * (float)num445 * 32f, 0, 0) || this.localAI[2] == 8f)
                            {
                                flag54 = true;
                            }
                            if (flag54)
                            {
                                int num446 = NPCID.Sets.AttackTime[this.type];
                                int num447 = (num389 == 1) ? num391 : num390;
                                int num448 = (num389 == 1) ? num390 : num391;
                                if (num447 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num447].Center, 0, 0))
                                {
                                    if (num448 != -1 && Collision.CanHit(base.Center, 0, 0, Main.npc[num448].Center, 0, 0))
                                    {
                                        num447 = num448;
                                    }
                                    else
                                    {
                                        num447 = -1;
                                    }
                                }
                                if (num447 != -1)
                                {
                                    this.ai[0] = 15f;
                                    this.ai[1] = (float)num446;
                                    this.ai[2] = 0f;
                                    this.localAI[3] = 0f;
                                    this.direction = ((this.position.X < Main.npc[num447].position.X) ? 1 : -1);
                                    this.netUpdate = true;
                                }
                                else
                                {
                                    flag54 = false;
                                }
                            }
                        }
                        if (!flag54)
                        {
                            this.ai[0] = (float)((this.localAI[2] == 8f && flag43) ? 8 : 0);
                            this.ai[1] = (float)(num439 + Main.rand.Next(maxValue6));
                            this.ai[2] = 0f;
                            this.localAI[1] = (this.localAI[3] = (float)(num439 / 2 + Main.rand.Next(maxValue6)));
                            this.netUpdate = true;
                        }
                    }
                }
                if (Main.netMode != 1 && (this.townNPC || this.type == NPCID.SkeletonMerchant) && !flag40)
                {
                    bool flag55 = this.ai[0] < 2f && !flag43;
                    bool flag56 = (this.ai[0] < 2f || this.ai[0] == 8f) && (flag43 || flag44);
                    if (this.localAI[1] > 0f)
                    {
                        this.localAI[1] -= 1f;
                    }
                    if (this.localAI[1] > 0f)
                    {
                        flag56 = false;
                    }
                    if (flag56 && this.type == NPCID.Mechanic && this.localAI[0] == 1f)
                    {
                        flag56 = false;
                    }
                    if (flag56 && this.type == NPCID.Dryad)
                    {
                        flag56 = false;
                        for (int num449 = 0; num449 < 200; num449++)
                        {
                            NPC nPC3 = Main.npc[num449];
                            if (nPC3.active && nPC3.townNPC && base.Distance(nPC3.Center) <= 1200f && nPC3.HasBuff(BuffID.DryadsWard) == -1)
                            {
                                flag56 = true;
                                break;
                            }
                        }
                    }
                    if (flag55 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(300) == 0)
                    {
                        int num450 = 420;
                        if (Main.rand.Next(2) == 0)
                        {
                            num450 *= Main.rand.Next(1, 4);
                        }
                        else
                        {
                            num450 *= Main.rand.Next(1, 3);
                        }
                        int num451 = 100;
                        int num452 = 20;
                        for (int num453 = 0; num453 < 200; num453++)
                        {
                            NPC nPC4 = Main.npc[num453];
                            bool flag57 = (nPC4.ai[0] == 1f && nPC4.closeDoor) || (nPC4.ai[0] == 1f && nPC4.ai[1] > 200f) || nPC4.ai[0] > 1f;
                            if (nPC4 != this && nPC4.active && nPC4.CanTalk && !flag57 && nPC4.Distance(base.Center) < (float)num451 && nPC4.Distance(base.Center) > (float)num452 && Collision.CanHit(base.Center, 0, 0, nPC4.Center, 0, 0))
                            {
                                int num454 = (this.position.X < nPC4.position.X).ToDirectionInt();
                                this.ai[0] = 3f;
                                this.ai[1] = (float)num450;
                                this.ai[2] = (float)num453;
                                this.direction = num454;
                                this.netUpdate = true;
                                nPC4.ai[0] = 4f;
                                nPC4.ai[1] = (float)num450;
                                nPC4.ai[2] = (float)this.whoAmI;
                                nPC4.direction = -num454;
                                nPC4.netUpdate = true;
                                break;
                            }
                        }
                    }
                    else if (flag55 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1800) == 0)
                    {
                        int num455 = 420;
                        if (Main.rand.Next(2) == 0)
                        {
                            num455 *= Main.rand.Next(1, 4);
                        }
                        else
                        {
                            num455 *= Main.rand.Next(1, 3);
                        }
                        int num456 = 100;
                        int num457 = 20;
                        for (int num458 = 0; num458 < 200; num458++)
                        {
                            NPC nPC5 = Main.npc[num458];
                            bool flag58 = (nPC5.ai[0] == 1f && nPC5.closeDoor) || (nPC5.ai[0] == 1f && nPC5.ai[1] > 200f) || nPC5.ai[0] > 1f;
                            if (nPC5 != this && nPC5.active && nPC5.CanTalk && !flag58 && nPC5.Distance(base.Center) < (float)num456 && nPC5.Distance(base.Center) > (float)num457 && Collision.CanHit(base.Center, 0, 0, nPC5.Center, 0, 0))
                            {
                                int num459 = (this.position.X < nPC5.position.X).ToDirectionInt();
                                this.ai[0] = 16f;
                                this.ai[1] = (float)num455;
                                this.ai[2] = (float)num458;
                                this.localAI[2] = (float)Main.rand.Next(4);
                                this.localAI[3] = (float)Main.rand.Next(3 - (int)this.localAI[2]);
                                this.direction = num459;
                                this.netUpdate = true;
                                nPC5.ai[0] = 17f;
                                nPC5.ai[1] = (float)num455;
                                nPC5.ai[2] = (float)this.whoAmI;
                                nPC5.localAI[2] = 0f;
                                nPC5.localAI[3] = 0f;
                                nPC5.direction = -num459;
                                nPC5.netUpdate = true;
                                break;
                            }
                        }
                    }
                    else if (flag55 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1200) == 0 && this.type == NPCID.PartyGirl)
                    {
                        int num460 = 300;
                        int num461 = 150;
                        for (int num462 = 0; num462 < 255; num462++)
                        {
                            Player player2 = Main.player[num462];
                            if (player2.active && !player2.dead && player2.Distance(base.Center) < (float)num461 && Collision.CanHitLine(base.Top, 0, 0, player2.Top, 0, 0))
                            {
                                int direction2 = (this.position.X < player2.position.X).ToDirectionInt();
                                this.ai[0] = 6f;
                                this.ai[1] = (float)num460;
                                this.ai[2] = (float)num462;
                                this.direction = direction2;
                                this.netUpdate = true;
                                break;
                            }
                        }
                    }
                    else if (flag55 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1800) == 0)
                    {
                        this.ai[0] = 2f;
                        this.ai[1] = (float)(45 * Main.rand.Next(1, 2));
                        this.netUpdate = true;
                    }
                    else if (flag55 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(600) == 0 && this.type == NPCID.Pirate && !flag44)
                    {
                        this.ai[0] = 11f;
                        this.ai[1] = (float)(30 * Main.rand.Next(1, 4));
                        this.netUpdate = true;
                    }
                    else if (flag55 && this.ai[0] == 0f && this.velocity.Y == 0f && Main.rand.Next(1200) == 0)
                    {
                        int num463 = 220;
                        int num464 = 150;
                        for (int num465 = 0; num465 < 255; num465++)
                        {
                            Player player3 = Main.player[num465];
                            if (player3.active && !player3.dead && player3.Distance(base.Center) < (float)num464 && Collision.CanHitLine(base.Top, 0, 0, player3.Top, 0, 0))
                            {
                                int direction3 = (this.position.X < player3.position.X).ToDirectionInt();
                                this.ai[0] = 7f;
                                this.ai[1] = (float)num463;
                                this.ai[2] = (float)num465;
                                this.direction = direction3;
                                this.netUpdate = true;
                                break;
                            }
                        }
                    }
                    else if (flag55 && this.ai[0] == 1f && this.velocity.Y == 0f && Main.rand.Next(300) == 0)
                    {
                        Point b = base.Center.ToTileCoordinates();
                        bool flag59 = WorldGen.InWorld(b.X, b.Y, 1);
                        if (flag59)
                        {
                            for (int num466 = 0; num466 < 200; num466++)
                            {
                                if (Main.npc[num466].active && Main.npc[num466].aiStyle == 7 && Main.npc[num466].townNPC && Main.npc[num466].ai[0] == 5f)
                                {
                                    Point a = Main.npc[num466].Center.ToTileCoordinates();
                                    if (a == b)
                                    {
                                        flag59 = false;
                                        break;
                                    }
                                }
                            }
                        }
                        if (flag59)
                        {
                            Tile tile2 = Main.tile[b.X, b.Y];
                            flag59 = (tile2.type == 15);
                            if (flag59 && tile2.frameY == 1080)
                            {
                                flag59 = false;
                            }
                            if (flag59)
                            {
                                this.ai[0] = 5f;
                                this.ai[1] = (float)(900 + Main.rand.Next(10800));
                                this.direction = ((tile2.frameX == 0) ? -1 : 1);
                                base.Bottom = new Vector2((float)(b.X * 16 + 8 + 2 * this.direction), (float)(b.Y * 16 + 32));
                                this.velocity = Vector2.Zero;
                                this.localAI[3] = 0f;
                                this.netUpdate = true;
                            }
                        }
                    }
                    else if (flag55 && this.ai[0] == 1f && this.velocity.Y == 0f && Main.rand.Next(600) == 0 && Utils.PlotTileLine(base.Top, base.Bottom, (float)this.width, new Utils.PerLinePoint(DelegateMethods.SearchAvoidedByNPCs)))
                    {
                        Point point2 = (base.Center + new Vector2((float)(this.direction * 10), 0f)).ToTileCoordinates();
                        bool flag60 = WorldGen.InWorld(point2.X, point2.Y, 1);
                        if (flag60)
                        {
                            Tile tileSafely6 = Framing.GetTileSafely(point2.X, point2.Y);
                            if (!tileSafely6.nactive() || !TileID.Sets.InteractibleByNPCs[(int)tileSafely6.type])
                            {
                                flag60 = false;
                            }
                        }
                        if (flag60)
                        {
                            this.ai[0] = 9f;
                            this.ai[1] = (float)(40 + Main.rand.Next(90));
                            this.velocity = Vector2.Zero;
                            this.localAI[3] = 0f;
                            this.netUpdate = true;
                        }
                    }
                    if (this.ai[0] < 2f && this.velocity.Y == 0f && this.type == NPCID.Nurse)
                    {
                        int num467 = -1;
                        for (int num468 = 0; num468 < 200; num468++)
                        {
                            NPC nPC6 = Main.npc[num468];
                            if (nPC6.active && nPC6.townNPC && nPC6.life != nPC6.lifeMax && (num467 == -1 || nPC6.lifeMax - nPC6.life > Main.npc[num467].lifeMax - Main.npc[num467].life) && Collision.CanHitLine(this.position, this.width, this.height, nPC6.position, nPC6.width, nPC6.height) && base.Distance(nPC6.Center) < 500f)
                            {
                                num467 = num468;
                            }
                        }
                        if (num467 != -1)
                        {
                            this.ai[0] = 13f;
                            this.ai[1] = 34f;
                            this.ai[2] = (float)num467;
                            this.localAI[3] = 0f;
                            this.direction = ((this.position.X < Main.npc[num467].position.X) ? 1 : -1);
                            this.netUpdate = true;
                        }
                    }
                    if (flag56 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 0 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int num469 = NPCID.Sets.AttackTime[this.type];
                        int num470 = (num389 == 1) ? num391 : num390;
                        int num471 = (num389 == 1) ? num390 : num391;
                        if (num470 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num470].Center, 0, 0))
                        {
                            if (num471 != -1 && Collision.CanHit(base.Center, 0, 0, Main.npc[num471].Center, 0, 0))
                            {
                                num470 = num471;
                            }
                            else
                            {
                                num470 = -1;
                            }
                        }
                        if (num470 != -1)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 10f;
                            this.ai[1] = (float)num469;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.direction = ((this.position.X < Main.npc[num470].position.X) ? 1 : -1);
                            this.netUpdate = true;
                        }
                    }
                    else if (flag56 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 1 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int num472 = NPCID.Sets.AttackTime[this.type];
                        int num473 = (num389 == 1) ? num391 : num390;
                        int num474 = (num389 == 1) ? num390 : num391;
                        if (num473 != -1 && !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num473].Center, 0, 0))
                        {
                            if (num474 != -1 && Collision.CanHitLine(base.Center, 0, 0, Main.npc[num474].Center, 0, 0))
                            {
                                num473 = num474;
                            }
                            else
                            {
                                num473 = -1;
                            }
                        }
                        if (num473 != -1)
                        {
                            Vector2 vector48 = base.DirectionTo(Main.npc[num473].Center);
                            if (vector48.Y <= 0.5f && vector48.Y >= -0.5f)
                            {
                                this.localAI[2] = this.ai[0];
                                this.ai[0] = 12f;
                                this.ai[1] = (float)num472;
                                this.ai[2] = vector48.Y;
                                this.localAI[3] = 0f;
                                this.direction = ((this.position.X < Main.npc[num473].position.X) ? 1 : -1);
                                this.netUpdate = true;
                            }
                        }
                    }
                    if (flag56 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 2 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int num475 = NPCID.Sets.AttackTime[this.type];
                        int num476 = (num389 == 1) ? num391 : num390;
                        int num477 = (num389 == 1) ? num390 : num391;
                        if (num476 != -1 && !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num476].Center, 0, 0))
                        {
                            if (num477 != -1 && Collision.CanHitLine(base.Center, 0, 0, Main.npc[num477].Center, 0, 0))
                            {
                                num476 = num477;
                            }
                            else
                            {
                                num476 = -1;
                            }
                        }
                        if (num476 != -1)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 14f;
                            this.ai[1] = (float)num475;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.direction = ((this.position.X < Main.npc[num476].position.X) ? 1 : -1);
                            this.netUpdate = true;
                        }
                        else if (this.type == NPCID.Dryad)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 14f;
                            this.ai[1] = (float)num475;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.netUpdate = true;
                        }
                    }
                    if (flag56 && this.velocity.Y == 0f && NPCID.Sets.AttackType[this.type] == 3 && NPCID.Sets.AttackAverageChance[this.type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[this.type] * 2) == 0)
                    {
                        int num478 = NPCID.Sets.AttackTime[this.type];
                        int num479 = (num389 == 1) ? num391 : num390;
                        int num480 = (num389 == 1) ? num390 : num391;
                        if (num479 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num479].Center, 0, 0))
                        {
                            if (num480 != -1 && Collision.CanHit(base.Center, 0, 0, Main.npc[num480].Center, 0, 0))
                            {
                                num479 = num480;
                            }
                            else
                            {
                                num479 = -1;
                            }
                        }
                        if (num479 != -1)
                        {
                            this.localAI[2] = this.ai[0];
                            this.ai[0] = 15f;
                            this.ai[1] = (float)num478;
                            this.ai[2] = 0f;
                            this.localAI[3] = 0f;
                            this.direction = ((this.position.X < Main.npc[num479].position.X) ? 1 : -1);
                            this.netUpdate = true;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 8)
            {
                this.TargetClosest(true);
                this.velocity.X = this.velocity.X * 0.93f;
                if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                {
                    this.velocity.X = 0f;
                }
                if (this.ai[0] == 0f)
                {
                    this.ai[0] = 500f;
                }
                if (this.type == NPCID.RuneWizard)
                {
                    if (this.alpha < 255)
                    {
                        this.alpha++;
                    }
                    if (this.justHit)
                    {
                        this.alpha = 0;
                    }
                }
                if (this.ai[2] != 0f && this.ai[3] != 0f)
                {
                    if (this.type == NPCID.RuneWizard)
                    {
                        this.alpha = 255;
                    }

                    this.position.X = this.ai[2] * 16f - (float)(this.width / 2) + 8f;
                    this.position.Y = this.ai[3] * 16f - (float)this.height;
                    this.velocity.X = 0f;
                    this.velocity.Y = 0f;
                    this.ai[2] = 0f;
                    this.ai[3] = 0f;
                }
                this.ai[0] += 1f;
                if (this.type == NPCID.Necromancer || this.type == NPCID.NecromancerArmored)
                {
                    if (this.ai[0] == 50f || this.ai[0] == 100f || this.ai[0] == 150f || this.ai[0] == 200f || this.ai[0] == 250f)
                    {
                        this.ai[1] = 30f;
                        this.netUpdate = true;
                    }
                    if (this.ai[0] >= 400f)
                    {
                        this.ai[0] = 700f;
                    }
                }
                else if (this.type == NPCID.RuneWizard)
                {
                    if (this.ai[0] == 75f || this.ai[0] == 150f || this.ai[0] == 225f || this.ai[0] == 300f || this.ai[0] == 375f || this.ai[0] == 450f)
                    {
                        this.ai[1] = 30f;
                        this.netUpdate = true;
                    }
                }
                else if (this.type == NPCID.DesertDjinn)
                {
                    if (this.ai[0] == 180f)
                    {
                        this.ai[1] = 181f;
                        this.netUpdate = true;
                    }
                }
                else if (this.type == NPCID.RaggedCaster || this.type == NPCID.RaggedCasterOpenCoat)
                {
                    if (this.ai[0] == 20f || this.ai[0] == 40f || this.ai[0] == 60f || this.ai[0] == 120f || this.ai[0] == 140f || this.ai[0] == 160f || this.ai[0] == 220f || this.ai[0] == 240f || this.ai[0] == 260f)
                    {
                        this.ai[1] = 30f;
                        this.netUpdate = true;
                    }
                    if (this.ai[0] >= 460f)
                    {
                        this.ai[0] = 700f;
                    }
                }
                else if (this.ai[0] == 100f || this.ai[0] == 200f || this.ai[0] == 300f)
                {
                    this.ai[1] = 30f;
                    this.netUpdate = true;
                }
                if ((this.type == NPCID.DiabolistRed || this.type == NPCID.DiabolistWhite) && this.ai[0] > 400f)
                {
                    this.ai[0] = 650f;
                }
                if (this.type == NPCID.DesertDjinn && this.ai[0] >= 360f)
                {
                    this.ai[0] = 650f;
                }
                if (this.ai[0] >= 650f && Main.netMode != 1)
                {
                    this.ai[0] = 1f;
                    int num499 = (int)Main.player[this.target].position.X / 16;
                    int num500 = (int)Main.player[this.target].position.Y / 16;
                    int num501 = (int)this.position.X / 16;
                    int num502 = (int)this.position.Y / 16;
                    int num503 = 20;
                    int num504 = 0;
                    bool flag61 = false;
                    if (Math.Abs(this.position.X - Main.player[this.target].position.X) + Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                    {
                        num504 = 100;
                        flag61 = true;
                    }
                    while (!flag61 && num504 < 100)
                    {
                        num504++;
                        int num505 = Main.rand.Next(num499 - num503, num499 + num503);
                        int num506 = Main.rand.Next(num500 - num503, num500 + num503);
                        for (int num507 = num506; num507 < num500 + num503; num507++)
                        {
                            if ((num507 < num500 - 4 || num507 > num500 + 4 || num505 < num499 - 4 || num505 > num499 + 4) && (num507 < num502 - 1 || num507 > num502 + 1 || num505 < num501 - 1 || num505 > num501 + 1) && Main.tile[num505, num507].nactive())
                            {
                                bool flag62 = true;
                                if ((this.type == NPCID.DarkCaster || (this.type >= NPCID.RaggedCaster && this.type <= NPCID.DiabolistWhite)) && !Main.wallDungeon[(int)Main.tile[num505, num507 - 1].wall])
                                {
                                    flag62 = false;
                                }
                                else if (Main.tile[num505, num507 - 1].lava())
                                {
                                    flag62 = false;
                                }
                                if (flag62 && Main.tileSolid[(int)Main.tile[num505, num507].type] && !Collision.SolidTiles(num505 - 1, num505 + 1, num507 - 4, num507 - 1))
                                {
                                    this.ai[1] = 20f;
                                    this.ai[2] = (float)num505;
                                    this.ai[3] = (float)num507;
                                    flag61 = true;
                                    break;
                                }
                            }
                        }
                    }
                    this.netUpdate = true;
                }
                if (this.ai[1] > 0f)
                {
                    this.ai[1] -= 1f;
                    if (this.type == NPCID.DesertDjinn)
                    {
                        if (this.ai[1] % 30f == 0f && this.ai[1] / 30f < 5f)
                        {
                            if (Main.netMode != 1)
                            {
                                Point point3 = base.Center.ToTileCoordinates();
                                Point point4 = Main.player[this.target].Center.ToTileCoordinates();
                                Vector2 vector49 = Main.player[this.target].Center - base.Center;
                                int num508 = 6;
                                int num509 = 6;
                                int num510 = 0;
                                int num511 = 2;
                                int num512 = 0;
                                bool flag63 = false;
                                if (vector49.Length() > 2000f)
                                {
                                    flag63 = true;
                                }
                                while (!flag63)
                                {
                                    if (num512 >= 50)
                                    {
                                        break;
                                    }
                                    num512++;
                                    int num513 = Main.rand.Next(point4.X - num508, point4.X + num508 + 1);
                                    int num514 = Main.rand.Next(point4.Y - num508, point4.Y + num508 + 1);
                                    if ((num514 < point4.Y - num510 || num514 > point4.Y + num510 || num513 < point4.X - num510 || num513 > point4.X + num510) && (num514 < point3.Y - num509 || num514 > point3.Y + num509 || num513 < point3.X - num509 || num513 > point3.X + num509) && !Main.tile[num513, num514].nactive())
                                    {
                                        bool flag64 = true;
                                        if (flag64 && Main.tile[num513, num514].lava())
                                        {
                                            flag64 = false;
                                        }
                                        if (flag64 && Collision.SolidTiles(num513 - num511, num513 + num511, num514 - num511, num514 + num511))
                                        {
                                            flag64 = false;
                                        }
                                        if (flag64)
                                        {
                                            Projectile.NewProjectile((float)(num513 * 16 + 8), (float)(num514 * 16 + 8), 0f, 0f, 596, 0, 1f, Main.myPlayer, (float)this.target, 0f);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (this.ai[1] == 25f)
                    {
                        if (this.type >= NPCID.RaggedCaster && this.type <= NPCID.DiabolistWhite)
                        {
                            if (Main.netMode != 1)
                            {
                                float num515 = 6f;
                                if (this.type == NPCID.DiabolistRed || this.type == NPCID.DiabolistWhite)
                                {
                                    num515 = 8f;
                                }
                                if (this.type == NPCID.RaggedCaster || this.type == NPCID.RaggedCasterOpenCoat)
                                {
                                    num515 = 4f;
                                }
                                Vector2 vector50 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y);
                                float num516 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector50.X;
                                float num517 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector50.Y;
                                if (this.type == NPCID.Necromancer || this.type == NPCID.NecromancerArmored)
                                {
                                    num516 += (float)Main.rand.Next(-30, 31);
                                    num517 += (float)Main.rand.Next(-30, 31);
                                    num516 -= Main.player[this.target].velocity.X * 10f;
                                    num517 -= Main.player[this.target].velocity.Y * 10f;
                                }
                                float num518 = (float)Math.Sqrt((double)(num516 * num516 + num517 * num517));
                                num518 = num515 / num518;
                                num516 *= num518;
                                num517 *= num518;
                                int num519 = 30;
                                int num520 = 290;
                                if (this.type == NPCID.DiabolistRed || this.type == NPCID.DiabolistWhite)
                                {
                                    num520 = 291;
                                    num519 = 40;
                                }
                                if (this.type == NPCID.RaggedCaster || this.type == NPCID.RaggedCasterOpenCoat)
                                {
                                    num520 = 293;
                                    num519 = 40;
                                }
                                if (Main.expertMode)
                                {
                                    num519 = (int)((double)num519 * 0.8);
                                }
                                int num521 = Projectile.NewProjectile(vector50.X, vector50.Y, num516, num517, num520, num519, 0f, Main.myPlayer, 0f, 0f);
                                Main.projectile[num521].timeLeft = 300;
                                if (num520 == 291)
                                {
                                    Main.projectile[num521].ai[0] = Main.player[this.target].Center.X;
                                    Main.projectile[num521].ai[1] = Main.player[this.target].Center.Y;
                                    Main.projectile[num521].netUpdate = true;
                                }
                                this.localAI[0] = 0f;
                            }
                        }
                        else
                        {
                            if (Main.netMode != 1)
                            {
                                if (this.type == NPCID.GoblinSorcerer || this.type == NPCID.Tim)
                                {
                                    NPC.NewNPC((int)this.position.X + this.width / 2, (int)this.position.Y - 8, 30, 0, 0f, 0f, 0f, 0f, 255);
                                }
                                else if (this.type == NPCID.DarkCaster)
                                {
                                    NPC.NewNPC((int)this.position.X + this.width / 2, (int)this.position.Y - 8, 33, 0, 0f, 0f, 0f, 0f, 255);
                                }
                                else if (this.type == NPCID.RuneWizard)
                                {
                                    float num522 = 10f;
                                    Vector2 vector51 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float num523 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector51.X + (float)Main.rand.Next(-10, 11);
                                    float num524 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector51.Y + (float)Main.rand.Next(-10, 11);
                                    float num525 = (float)Math.Sqrt((double)(num523 * num523 + num524 * num524));
                                    num525 = num522 / num525;
                                    num523 *= num525;
                                    num524 *= num525;
                                    int num526 = 40;
                                    int num527 = 129;
                                    int num528 = Projectile.NewProjectile(vector51.X, vector51.Y, num523, num524, num527, num526, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num528].timeLeft = 300;
                                    this.localAI[0] = 0f;
                                }
                                else
                                {
                                    NPC.NewNPC((int)this.position.X + this.width / 2 + this.direction * 8, (int)this.position.Y + 20, 25, 0, 0f, 0f, 0f, 0f, 255);
                                }
                            }
                        }
                    }
                }
                if (this.type == NPCID.GoblinSorcerer || this.type == NPCID.Tim)
                {
                    if (Main.rand.Next(5) == 0)
                    {
                        return;
                    }
                }
                else if (this.type == NPCID.DarkCaster)
                {
                    if (Main.rand.Next(3) != 0)
                    {
                        return;
                    }
                }
                else
                {
                    if (this.type == NPCID.RuneWizard)
                    {
                        return;
                    }
                    if (this.type == NPCID.Necromancer || this.type == NPCID.NecromancerArmored)
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            return;
                        }
                    }
                    else if (this.type == NPCID.DiabolistRed || this.type == NPCID.DiabolistWhite)
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            return;
                        }
                    }
                    else if (this.type == NPCID.RaggedCaster || this.type == NPCID.RaggedCasterOpenCoat)
                    {
                        if (Main.rand.Next(2) == 0)
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (this.type == NPCID.DesertDjinn)
                        {
                            return;
                        }
                        if (Main.rand.Next(2) == 0)
                        {
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 9)
            {
                if (this.type == NPCID.SolarFlare)
                {
                    if (this.alpha < 220)
                    {
                        this.alpha += 40;
                    }
                    if (this.ai[0] == 0f)
                    {
                        this.ai[0] = 1f;
                        Vector2 vector52 = Main.player[this.target].Center - base.Center;
                        vector52.Normalize();
                        if (vector52.HasNaNs())
                        {
                            vector52 = -Vector2.UnitY;
                        }
                        vector52 = vector52.RotatedByRandom(1.5707963705062866).RotatedBy(-0.78539818525314331, default(Vector2));
                        if (vector52.Y > 0.2f)
                        {
                            vector52.Y = 0.2f;
                        }
                        this.velocity = vector52 * (6f + Main.rand.NextFloat() * 4f);
                    }
                    if (this.collideX || this.collideY || base.Distance(Main.player[this.target].Center) < 20f)
                    {
                        this.StrikeNPCNoInteraction(9999, 0f, this.direction, false, false, false);
                    }
                }
                if (this.target == 255)
                {
                    this.TargetClosest(true);
                    float num538 = 6f;
                    if (this.type == NPCID.BurningSphere)
                    {
                        num538 = 5f;
                    }
                    if (this.type == NPCID.VileSpit)
                    {
                        num538 = 7f;
                    }
                    Vector2 vector53 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num539 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector53.X;
                    float num540 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector53.Y;
                    float num541 = (float)Math.Sqrt((double)(num539 * num539 + num540 * num540));
                    num541 = num538 / num541;
                    this.velocity.X = num539 * num541;
                    this.velocity.Y = num540 * num541;
                }
                if (this.type == NPCID.VileSpit)
                {
                    this.damage = ((this.ai[1] == 1f) ? 65 : this.defDamage);
                    this.ai[0] += 1f;
                    if (this.ai[0] > 3f)
                    {
                        this.ai[0] = 3f;
                    }
                    if (this.ai[0] == 2f)
                    {
                        this.position += this.velocity;
                    }
                }
                if (this.type == NPCID.VileSpit && Collision.SolidCollision(this.position, this.width, this.height))
                {
                    int arg_1FD8D_0 = Main.netMode;
                    this.StrikeNPCNoInteraction(999, 0f, 0, false, false, false);
                }
                if (this.timeLeft > 100)
                {
                    this.timeLeft = 100;
                }
                if (this.type != NPCID.SolarFlare)
                {
                    for (int num544 = 0; num544 < 2; num544++)
                    {
                        if (this.type == NPCID.ChaosBall)
                        {
                            this.alpha = 255;
                        }
                    }
                    this.rotation += 0.4f * (float)this.direction;
                    return;
                }
                this.rotation += 0.1f * (float)this.direction;
                float num556 = 15f;
                float num557 = 0.0833333358f;
                Vector2 center4 = base.Center;
                Vector2 center5 = Main.player[this.target].Center;
                Vector2 vec3 = center5 - center4;
                vec3.Normalize();
                if (vec3.HasNaNs())
                {
                    vec3 = new Vector2((float)this.direction, 0f);
                }
                this.velocity = (this.velocity * (num556 - 1f) + vec3 * (this.velocity.Length() + num557)) / num556;
                if (this.velocity.Length() < 6f)
                {
                    this.velocity *= 1.05f;
                    return;
                }
            }
            else if (this.aiStyle == 10)
            {
                float num558 = 1f;
                float num559 = 0.011f;
                this.TargetClosest(true);
                Vector2 vector54 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                float num560 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector54.X;
                float num561 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector54.Y;
                float num562 = (float)Math.Sqrt((double)(num560 * num560 + num561 * num561));
                float num563 = num562;
                this.ai[1] += 1f;
                if (this.ai[1] > 600f)
                {
                    num559 *= 8f;
                    num558 = 4f;
                    if (this.ai[1] > 650f)
                    {
                        this.ai[1] = 0f;
                    }
                }
                else if (num563 < 250f)
                {
                    this.ai[0] += 0.9f;
                    if (this.ai[0] > 0f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.019f;
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y - 0.019f;
                    }
                    if (this.ai[0] < -100f || this.ai[0] > 100f)
                    {
                        this.velocity.X = this.velocity.X + 0.019f;
                    }
                    else
                    {
                        this.velocity.X = this.velocity.X - 0.019f;
                    }
                    if (this.ai[0] > 200f)
                    {
                        this.ai[0] = -200f;
                    }
                }
                if (num563 > 350f)
                {
                    num558 = 5f;
                    num559 = 0.3f;
                }
                else if (num563 > 300f)
                {
                    num558 = 3f;
                    num559 = 0.2f;
                }
                else if (num563 > 250f)
                {
                    num558 = 1.5f;
                    num559 = 0.1f;
                }
                num562 = num558 / num562;
                num560 *= num562;
                num561 *= num562;
                if (Main.player[this.target].dead)
                {
                    num560 = (float)this.direction * num558 / 2f;
                    num561 = -num558 / 2f;
                }
                if (this.velocity.X < num560)
                {
                    this.velocity.X = this.velocity.X + num559;
                }
                else if (this.velocity.X > num560)
                {
                    this.velocity.X = this.velocity.X - num559;
                }
                if (this.velocity.Y < num561)
                {
                    this.velocity.Y = this.velocity.Y + num559;
                }
                else if (this.velocity.Y > num561)
                {
                    this.velocity.Y = this.velocity.Y - num559;
                }
                if (num560 > 0f)
                {
                    this.spriteDirection = -1;
                    this.rotation = (float)Math.Atan2((double)num561, (double)num560);
                }
                if (num560 < 0f)
                {
                    this.spriteDirection = 1;
                    this.rotation = (float)Math.Atan2((double)num561, (double)num560) + 3.14f;
                }
                if (this.type == NPCID.GiantCursedSkull)
                {
                    if (this.justHit)
                    {
                        this.ai[2] = 0f;
                        this.ai[3] = 0f;
                    }
                    vector54 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    num560 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector54.X;
                    num561 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector54.Y;
                    num562 = (float)Math.Sqrt((double)(num560 * num560 + num561 * num561));
                    if (num562 > 500f)
                    {
                        this.ai[2] = 0f;
                        this.ai[3] = 0f;
                        return;
                    }
                    this.ai[2] += 1f;
                    if (this.ai[3] == 0f)
                    {
                        if (this.ai[2] > 120f)
                        {
                            this.ai[2] = 0f;
                            this.ai[3] = 1f;
                            this.netUpdate = true;
                            return;
                        }
                    }
                    else
                    {
                        if (this.ai[2] > 40f)
                        {
                            this.ai[3] = 0f;
                        }
                        if (Main.netMode != 1 && this.ai[2] == 20f)
                        {
                            float num564 = 6f;
                            int num565 = 25;
                            int num566 = 299;
                            num562 = num564 / num562;
                            num560 *= num562;
                            num561 *= num562;
                            Projectile.NewProjectile(vector54.X, vector54.Y, num560, num561, num566, num565, 0f, Main.myPlayer, 0f, 0f);
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 11)
            {
                this.defense = this.defDefense;
                if (this.ai[0] == 0f && Main.netMode != 1)
                {
                    this.TargetClosest(true);
                    this.ai[0] = 1f;
                    if (this.type != NPCID.DungeonGuardian)
                    {
                        int num567 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 36, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        Main.npc[num567].ai[0] = -1f;
                        Main.npc[num567].ai[1] = (float)this.whoAmI;
                        Main.npc[num567].target = this.target;
                        Main.npc[num567].netUpdate = true;
                        num567 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 36, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                        Main.npc[num567].ai[0] = 1f;
                        Main.npc[num567].ai[1] = (float)this.whoAmI;
                        Main.npc[num567].ai[3] = 150f;
                        Main.npc[num567].target = this.target;
                        Main.npc[num567].netUpdate = true;
                    }
                }
                if (this.type == NPCID.DungeonGuardian && this.ai[1] != 3f && this.ai[1] != 2f)
                {
                    this.ai[1] = 2f;
                }
                if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                {
                    this.TargetClosest(true);
                    if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                    {
                        this.ai[1] = 3f;
                    }
                }
                if (Main.dayTime && this.ai[1] != 3f && this.ai[1] != 2f)
                {
                    this.ai[1] = 2f;
                }
                int num568 = 0;
                if (Main.expertMode)
                {
                    for (int num569 = 0; num569 < 200; num569++)
                    {
                        if (Main.npc[num569].active && Main.npc[num569].type == this.type + 1)
                        {
                            num568++;
                        }
                    }
                    this.defense += num568 * 25;
                    if ((num568 < 2 || (double)this.life < (double)this.lifeMax * 0.75) && this.ai[1] == 0f)
                    {
                        float num570 = 80f;
                        if (num568 == 0)
                        {
                            num570 /= 2f;
                        }
                        if (Main.netMode != 1 && this.ai[2] % num570 == 0f)
                        {
                            Vector2 vector55 = base.Center;
                            float num571 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector55.X;
                            float num572 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector55.Y;
                            Math.Sqrt((double)(num571 * num571 + num572 * num572));
                            if (Collision.CanHit(vector55, 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float num573 = 3f;
                                if (num568 == 0)
                                {
                                    num573 += 2f;
                                }
                                float num574 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector55.X + (float)Main.rand.Next(-20, 21);
                                float num575 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector55.Y + (float)Main.rand.Next(-20, 21);
                                float num576 = (float)Math.Sqrt((double)(num574 * num574 + num575 * num575));
                                num576 = num573 / num576;
                                num574 *= num576;
                                num575 *= num576;
                                Vector2 value12 = new Vector2(num574 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f, num575 * 1f + (float)Main.rand.Next(-50, 51) * 0.01f);
                                value12.Normalize();
                                value12 *= num573;
                                value12 += this.velocity;
                                num574 = value12.X;
                                num575 = value12.Y;
                                int num577 = 17;
                                int num578 = 270;
                                vector55 += value12 * 5f;
                                int num579 = Projectile.NewProjectile(vector55.X, vector55.Y, num574, num575, num578, num577, 0f, Main.myPlayer, -1f, 0f);
                                Main.projectile[num579].timeLeft = 300;
                            }
                        }
                    }
                }
                if (this.ai[1] == 0f)
                {
                    this.damage = this.defDamage;
                    this.ai[2] += 1f;
                    if (this.ai[2] >= 800f)
                    {
                        this.ai[2] = 0f;
                        this.ai[1] = 1f;
                        this.TargetClosest(true);
                        this.netUpdate = true;
                    }
                    this.rotation = this.velocity.X / 15f;
                    float num580 = 0.02f;
                    float num581 = 2f;
                    float num582 = 0.05f;
                    float num583 = 8f;
                    if (Main.expertMode)
                    {
                        num580 = 0.03f;
                        num581 = 4f;
                        num582 = 0.07f;
                        num583 = 9.5f;
                    }
                    if (this.position.Y > Main.player[this.target].position.Y - 250f)
                    {
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.98f;
                        }
                        this.velocity.Y = this.velocity.Y - num580;
                        if (this.velocity.Y > num581)
                        {
                            this.velocity.Y = num581;
                        }
                    }
                    else if (this.position.Y < Main.player[this.target].position.Y - 250f)
                    {
                        if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.98f;
                        }
                        this.velocity.Y = this.velocity.Y + num580;
                        if (this.velocity.Y < -num581)
                        {
                            this.velocity.Y = -num581;
                        }
                    }
                    if (this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))
                    {
                        if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.98f;
                        }
                        this.velocity.X = this.velocity.X - num582;
                        if (this.velocity.X > num583)
                        {
                            this.velocity.X = num583;
                        }
                    }
                    if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))
                    {
                        if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.98f;
                        }
                        this.velocity.X = this.velocity.X + num582;
                        if (this.velocity.X < -num583)
                        {
                            this.velocity.X = -num583;
                        }
                    }
                }
                else if (this.ai[1] == 1f)
                {
                    this.defense -= 10;
                    this.ai[2] += 1f;
                    if (this.ai[2] >= 400f)
                    {
                        this.ai[2] = 0f;
                        this.ai[1] = 0f;
                    }
                    this.rotation += (float)this.direction * 0.3f;
                    Vector2 vector56 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num584 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector56.X;
                    float num585 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector56.Y;
                    float num586 = (float)Math.Sqrt((double)(num584 * num584 + num585 * num585));
                    float num587 = 1.5f;
                    if (Main.expertMode)
                    {
                        this.damage = (int)((double)this.defDamage * 1.3);
                        num587 = 4f;
                        if (num586 > 150f)
                        {
                            num587 *= 1.05f;
                        }
                        if (num586 > 200f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 250f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 300f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 350f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 400f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 450f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 500f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 550f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num586 > 600f)
                        {
                            num587 *= 1.1f;
                        }
                        if (num568 == 0)
                        {
                            num587 *= 1.2f;
                        }
                        else if (num568 == 1)
                        {
                            num587 *= 1.1f;
                        }
                    }
                    num586 = num587 / num586;
                    this.velocity.X = num584 * num586;
                    this.velocity.Y = num585 * num586;
                }
                else if (this.ai[1] == 2f)
                {
                    this.damage = 1000;
                    this.defense = 9999;
                    this.rotation += (float)this.direction * 0.3f;
                    Vector2 vector57 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num588 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector57.X;
                    float num589 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector57.Y;
                    float num590 = (float)Math.Sqrt((double)(num588 * num588 + num589 * num589));
                    num590 = 8f / num590;
                    this.velocity.X = num588 * num590;
                    this.velocity.Y = num589 * num590;
                }
                else if (this.ai[1] == 3f)
                {
                    this.velocity.Y = this.velocity.Y + 0.1f;
                    if (this.velocity.Y < 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.X = this.velocity.X * 0.95f;
                    if (this.timeLeft > 50)
                    {
                        this.timeLeft = 50;
                    }
                }
                if (this.ai[1] != 2f && this.ai[1] != 3f && this.type != NPCID.DungeonGuardian)
                {
                    if (num568 == 0 && Main.expertMode)
                    {
                        return;
                    }
                    return;
                }
            }
            else if (this.aiStyle == 12)
            {
                this.spriteDirection = -(int)this.ai[0];
                if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 11)
                {
                    this.ai[2] += 10f;
                    if (this.ai[2] > 50f || Main.netMode != 2)
                    {
                        this.life = -1;
                        this.HitEffect(0, 10.0);
                        this.active = false;
                    }
                }
                if (this.ai[2] == 0f || this.ai[2] == 3f)
                {
                    if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                    {
                        this.timeLeft = 10;
                    }
                    if (Main.npc[(int)this.ai[1]].ai[1] != 0f)
                    {
                        if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                        {
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y - 0.07f;
                            if (this.velocity.Y > 6f)
                            {
                                this.velocity.Y = 6f;
                            }
                        }
                        else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                        {
                            if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y + 0.07f;
                            if (this.velocity.Y < -6f)
                            {
                                this.velocity.Y = -6f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                        {
                            if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 8f)
                            {
                                this.velocity.X = 8f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -8f)
                            {
                                this.velocity.X = -8f;
                            }
                        }
                    }
                    else
                    {
                        this.ai[3] += 1f;
                        if (Main.expertMode)
                        {
                            this.ai[3] += 0.5f;
                        }
                        if (this.ai[3] >= 300f)
                        {
                            this.ai[2] += 1f;
                            this.ai[3] = 0f;
                            this.netUpdate = true;
                        }
                        if (Main.expertMode)
                        {
                            if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 230f)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.04f;
                                if (this.velocity.Y > 3f)
                                {
                                    this.velocity.Y = 3f;
                                }
                            }
                            else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 230f)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.04f;
                                if (this.velocity.Y < -3f)
                                {
                                    this.velocity.Y = -3f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X - 0.07f;
                                if (this.velocity.X > 8f)
                                {
                                    this.velocity.X = 8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X + 0.07f;
                                if (this.velocity.X < -8f)
                                {
                                    this.velocity.X = -8f;
                                }
                            }
                        }
                        if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 230f)
                        {
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if (this.velocity.Y > 3f)
                            {
                                this.velocity.Y = 3f;
                            }
                        }
                        else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 230f)
                        {
                            if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.96f;
                            }
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if (this.velocity.Y < -3f)
                            {
                                this.velocity.Y = -3f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                        {
                            if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X - 0.07f;
                            if (this.velocity.X > 8f)
                            {
                                this.velocity.X = 8f;
                            }
                        }
                        if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0])
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.96f;
                            }
                            this.velocity.X = this.velocity.X + 0.07f;
                            if (this.velocity.X < -8f)
                            {
                                this.velocity.X = -8f;
                            }
                        }
                    }
                    Vector2 vector58 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num593 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector58.X;
                    float num594 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector58.Y;
                    Math.Sqrt((double)(num593 * num593 + num594 * num594));
                    this.rotation = (float)Math.Atan2((double)num594, (double)num593) + 1.57f;
                    return;
                }
                if (this.ai[2] == 1f)
                {
                    Vector2 vector59 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num595 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector59.X;
                    float num596 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector59.Y;
                    float num597 = (float)Math.Sqrt((double)(num595 * num595 + num596 * num596));
                    this.rotation = (float)Math.Atan2((double)num596, (double)num595) + 1.57f;
                    this.velocity.X = this.velocity.X * 0.95f;
                    this.velocity.Y = this.velocity.Y - 0.1f;
                    if (Main.expertMode)
                    {
                        this.velocity.Y = this.velocity.Y - 0.06f;
                        if (this.velocity.Y < -13f)
                        {
                            this.velocity.Y = -13f;
                        }
                    }
                    else if (this.velocity.Y < -8f)
                    {
                        this.velocity.Y = -8f;
                    }
                    if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 200f)
                    {
                        this.TargetClosest(true);
                        this.ai[2] = 2f;
                        vector59 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        num595 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector59.X;
                        num596 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector59.Y;
                        num597 = (float)Math.Sqrt((double)(num595 * num595 + num596 * num596));
                        if (Main.expertMode)
                        {
                            num597 = 21f / num597;
                        }
                        else
                        {
                            num597 = 18f / num597;
                        }
                        this.velocity.X = num595 * num597;
                        this.velocity.Y = num596 * num597;
                        this.netUpdate = true;
                        return;
                    }
                }
                else if (this.ai[2] == 2f)
                {
                    if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f)
                    {
                        this.ai[2] = 3f;
                        return;
                    }
                }
                else if (this.ai[2] == 4f)
                {
                    Vector2 vector60 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num598 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector60.X;
                    float num599 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector60.Y;
                    float num600 = (float)Math.Sqrt((double)(num598 * num598 + num599 * num599));
                    this.rotation = (float)Math.Atan2((double)num599, (double)num598) + 1.57f;
                    this.velocity.Y = this.velocity.Y * 0.95f;
                    this.velocity.X = this.velocity.X + 0.1f * -this.ai[0];
                    if (Main.expertMode)
                    {
                        this.velocity.X = this.velocity.X + 0.07f * -this.ai[0];
                        if (this.velocity.X < -12f)
                        {
                            this.velocity.X = -12f;
                        }
                        else if (this.velocity.X > 12f)
                        {
                            this.velocity.X = 12f;
                        }
                    }
                    else if (this.velocity.X < -8f)
                    {
                        this.velocity.X = -8f;
                    }
                    else if (this.velocity.X > 8f)
                    {
                        this.velocity.X = 8f;
                    }
                    if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 500f || this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 500f)
                    {
                        this.TargetClosest(true);
                        this.ai[2] = 5f;
                        vector60 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        num598 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector60.X;
                        num599 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector60.Y;
                        num600 = (float)Math.Sqrt((double)(num598 * num598 + num599 * num599));
                        if (Main.expertMode)
                        {
                            num600 = 22f / num600;
                        }
                        else
                        {
                            num600 = 17f / num600;
                        }
                        this.velocity.X = num598 * num600;
                        this.velocity.Y = num599 * num600;
                        this.netUpdate = true;
                        return;
                    }
                }
                else if (this.ai[2] == 5f && ((this.velocity.X > 0f && this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)) || (this.velocity.X < 0f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))))
                {
                    this.ai[2] = 0f;
                    return;
                }
            }
            else if (this.aiStyle == 13)
            {
                if (this.ai[0] < 0f || this.ai[0] >= (float)Main.maxTilesX || this.ai[1] < 0f || this.ai[1] >= (float)Main.maxTilesX)
                {
                    return;
                }
                if (Main.tile[(int)this.ai[0], (int)this.ai[1]] == null)
                {
                    Main.tile[(int)this.ai[0], (int)this.ai[1]] = new Tile();
                }
                if (!Main.tile[(int)this.ai[0], (int)this.ai[1]].active())
                {
                    this.life = -1;
                    this.HitEffect(0, 10.0);
                    this.active = false;
                    return;
                }
                this.TargetClosest(true);
                float num601 = 0.035f;
                float num602 = 150f;
                if (this.type == NPCID.ManEater)
                {
                    num602 = 250f;
                }
                if (this.type == NPCID.Clinger)
                {
                    num602 = 175f;
                }
                if (this.type == NPCID.FungiBulb)
                {
                    num602 = 100f;
                }
                if (this.type == NPCID.AngryTrapper)
                {
                    num602 = 500f;
                    num601 = 0.05f;
                }
                if (this.type == NPCID.GiantFungiBulb)
                {
                    num602 = 350f;
                    num601 = 0.15f;
                }
                this.ai[2] += 1f;
                if (this.ai[2] > 300f)
                {
                    num602 = (float)((int)((double)num602 * 1.3));
                    if (this.ai[2] > 450f)
                    {
                        this.ai[2] = 0f;
                    }
                }
                Vector2 vector61 = new Vector2(this.ai[0] * 16f + 8f, this.ai[1] * 16f + 8f);
                float num603 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - (float)(this.width / 2) - vector61.X;
                float num604 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - (float)(this.height / 2) - vector61.Y;
                float num605 = (float)Math.Sqrt((double)(num603 * num603 + num604 * num604));
                if (num605 > num602)
                {
                    num605 = num602 / num605;
                    num603 *= num605;
                    num604 *= num605;
                }
                if (this.position.X < this.ai[0] * 16f + 8f + num603)
                {
                    this.velocity.X = this.velocity.X + num601;
                    if (this.velocity.X < 0f && num603 > 0f)
                    {
                        this.velocity.X = this.velocity.X + num601 * 1.5f;
                    }
                }
                else if (this.position.X > this.ai[0] * 16f + 8f + num603)
                {
                    this.velocity.X = this.velocity.X - num601;
                    if (this.velocity.X > 0f && num603 < 0f)
                    {
                        this.velocity.X = this.velocity.X - num601 * 1.5f;
                    }
                }
                if (this.position.Y < this.ai[1] * 16f + 8f + num604)
                {
                    this.velocity.Y = this.velocity.Y + num601;
                    if (this.velocity.Y < 0f && num604 > 0f)
                    {
                        this.velocity.Y = this.velocity.Y + num601 * 1.5f;
                    }
                }
                else if (this.position.Y > this.ai[1] * 16f + 8f + num604)
                {
                    this.velocity.Y = this.velocity.Y - num601;
                    if (this.velocity.Y > 0f && num604 < 0f)
                    {
                        this.velocity.Y = this.velocity.Y - num601 * 1.5f;
                    }
                }
                if (this.type == NPCID.ManEater)
                {
                    if (this.velocity.X > 3f)
                    {
                        this.velocity.X = 3f;
                    }
                    if (this.velocity.X < -3f)
                    {
                        this.velocity.X = -3f;
                    }
                    if (this.velocity.Y > 3f)
                    {
                        this.velocity.Y = 3f;
                    }
                    if (this.velocity.Y < -3f)
                    {
                        this.velocity.Y = -3f;
                    }
                }
                else if (this.type == NPCID.AngryTrapper)
                {
                    if (this.velocity.X > 4f)
                    {
                        this.velocity.X = 4f;
                    }
                    if (this.velocity.X < -4f)
                    {
                        this.velocity.X = -4f;
                    }
                    if (this.velocity.Y > 4f)
                    {
                        this.velocity.Y = 4f;
                    }
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                }
                else
                {
                    if (this.velocity.X > 2f)
                    {
                        this.velocity.X = 2f;
                    }
                    if (this.velocity.X < -2f)
                    {
                        this.velocity.X = -2f;
                    }
                    if (this.velocity.Y > 2f)
                    {
                        this.velocity.Y = 2f;
                    }
                    if (this.velocity.Y < -2f)
                    {
                        this.velocity.Y = -2f;
                    }
                }
                if (this.type == NPCID.FungiBulb || this.type == NPCID.GiantFungiBulb)
                {
                    this.rotation = (float)Math.Atan2((double)num604, (double)num603) + 1.57f;
                }
                else
                {
                    if (num603 > 0f)
                    {
                        this.spriteDirection = 1;
                        this.rotation = (float)Math.Atan2((double)num604, (double)num603);
                    }
                    if (num603 < 0f)
                    {
                        this.spriteDirection = -1;
                        this.rotation = (float)Math.Atan2((double)num604, (double)num603) + 3.14f;
                    }
                }
                if (this.collideX)
                {
                    this.netUpdate = true;
                    this.velocity.X = this.oldVelocity.X * -0.7f;
                    if (this.velocity.X > 0f && this.velocity.X < 2f)
                    {
                        this.velocity.X = 2f;
                    }
                    if (this.velocity.X < 0f && this.velocity.X > -2f)
                    {
                        this.velocity.X = -2f;
                    }
                }
                if (this.collideY)
                {
                    this.netUpdate = true;
                    this.velocity.Y = this.oldVelocity.Y * -0.7f;
                    if (this.velocity.Y > 0f && this.velocity.Y < 2f)
                    {
                        this.velocity.Y = 2f;
                    }
                    if (this.velocity.Y < 0f && this.velocity.Y > -2f)
                    {
                        this.velocity.Y = -2f;
                    }
                }
                if (Main.netMode != 1)
                {
                    if (this.type == NPCID.Clinger && !Main.player[this.target].dead)
                    {
                        if (this.justHit)
                        {
                            this.localAI[0] = 0f;
                        }
                        this.localAI[0] += 1f;
                        if (this.localAI[0] >= 120f)
                        {
                            if (!Collision.SolidCollision(this.position, this.width, this.height) && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float num606 = 10f;
                                vector61 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                num603 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector61.X + (float)Main.rand.Next(-10, 11);
                                num604 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector61.Y + (float)Main.rand.Next(-10, 11);
                                num605 = (float)Math.Sqrt((double)(num603 * num603 + num604 * num604));
                                num605 = num606 / num605;
                                num603 *= num605;
                                num604 *= num605;
                                int num607 = 22;
                                if (Main.expertMode)
                                {
                                    num607 = (int)((double)num607 * 0.8);
                                }
                                int num608 = 96;
                                int num609 = Projectile.NewProjectile(vector61.X, vector61.Y, num603, num604, num608, num607, 0f, Main.myPlayer, 0f, 0f);
                                Main.projectile[num609].timeLeft = 300;
                                this.localAI[0] = 0f;
                            }
                            else
                            {
                                this.localAI[0] = 100f;
                            }
                        }
                    }
                    if (this.type == NPCID.GiantFungiBulb && !Main.player[this.target].dead)
                    {
                        if (this.justHit)
                        {
                            this.localAI[0] = 0f;
                        }
                        this.localAI[0] += 1f;
                        if (this.localAI[0] >= 150f)
                        {
                            if (!Collision.SolidCollision(this.position, this.width, this.height))
                            {
                                float num610 = 14f;
                                vector61 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                num603 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector61.X + (float)Main.rand.Next(-10, 11);
                                float num611 = Math.Abs(num603 * 0.1f);
                                if (num604 > 0f)
                                {
                                    num611 = 0f;
                                }
                                num604 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector61.Y + (float)Main.rand.Next(-10, 11) - num611;
                                num605 = (float)Math.Sqrt((double)(num603 * num603 + num604 * num604));
                                num605 = num610 / num605;
                                num603 *= num605;
                                num604 *= num605;
                                int num612 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 261, 0, 0f, 0f, 0f, 0f, 255);
                                Main.npc[num612].velocity.X = num603;
                                Main.npc[num612].velocity.Y = num604;
                                Main.npc[num612].netUpdate = true;
                                this.localAI[0] = 0f;
                                return;
                            }
                            this.localAI[0] = 250f;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 14)
            {
                this.noGravity = true;
                if (this.collideX)
                {
                    this.velocity.X = this.oldVelocity.X * -0.5f;
                    if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                    {
                        this.velocity.X = 2f;
                    }
                    if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                    {
                        this.velocity.X = -2f;
                    }
                }
                if (this.collideY)
                {
                    this.velocity.Y = this.oldVelocity.Y * -0.5f;
                    if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                    {
                        this.velocity.Y = 1f;
                    }
                    if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                    {
                        this.velocity.Y = -1f;
                    }
                }
                if (this.type == NPCID.FlyingSnake)
                {
                    int direction4 = 1;
                    int num615 = 1;
                    if (this.velocity.X < 0f)
                    {
                        direction4 = -1;
                    }
                    if (this.velocity.Y < 0f)
                    {
                        num615 = -1;
                    }
                    this.TargetClosest(true);
                    if (!Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.direction = direction4;
                        this.directionY = num615;
                    }
                }
                else
                {
                    this.TargetClosest(true);
                }
                if (this.type == NPCID.VampireBat)
                {
                    if ((double)this.position.Y < Main.worldSurface * 16.0 && Main.dayTime && !Main.eclipse)
                    {
                        this.directionY = -1;
                        this.direction *= -1;
                    }
                    if (this.direction == -1 && this.velocity.X > -7f)
                    {
                        this.velocity.X = this.velocity.X - 0.2f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -7f)
                        {
                            this.velocity.X = -7f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 7f)
                    {
                        this.velocity.X = this.velocity.X + 0.2f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 7f)
                        {
                            this.velocity.X = 7f;
                        }
                    }
                    if (this.directionY == -1 && this.velocity.Y > -7f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.2f;
                        if (this.velocity.Y > 4f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.1f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        if (this.velocity.Y < -7f)
                        {
                            this.velocity.Y = -7f;
                        }
                    }
                    else if (this.directionY == 1 && this.velocity.Y < 7f)
                    {
                        this.velocity.Y = this.velocity.Y + 0.2f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.1f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        if (this.velocity.Y > 7f)
                        {
                            this.velocity.Y = 7f;
                        }
                    }
                }
                else if (this.type == NPCID.FlyingSnake)
                {
                    if (this.direction == -1 && this.velocity.X > -4f)
                    {
                        this.velocity.X = this.velocity.X - 0.2f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 4f)
                    {
                        this.velocity.X = this.velocity.X + 0.2f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -2.5)
                    {
                        this.velocity.Y = this.velocity.Y - 0.1f;
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = -2.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 2.5)
                    {
                        this.velocity.Y = this.velocity.Y + 0.1f;
                        if ((double)this.velocity.Y < -2.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if ((double)this.velocity.Y > 2.5)
                        {
                            this.velocity.Y = 2.5f;
                        }
                    }
                }
                else
                {
                    if (this.direction == -1 && this.velocity.X > -4f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = -4f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 4f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X > 4f)
                        {
                            this.velocity.X = 4f;
                        }
                    }
                    if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                    {
                        this.velocity.Y = this.velocity.Y - 0.04f;
                        if ((double)this.velocity.Y > 1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.05f;
                        }
                        else if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.03f;
                        }
                        if ((double)this.velocity.Y < -1.5)
                        {
                            this.velocity.Y = -1.5f;
                        }
                    }
                    else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                    {
                        this.velocity.Y = this.velocity.Y + 0.04f;
                        if ((double)this.velocity.Y < -1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.05f;
                        }
                        else if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.03f;
                        }
                        if ((double)this.velocity.Y > 1.5)
                        {
                            this.velocity.Y = 1.5f;
                        }
                    }
                }
                if (this.type == NPCID.CaveBat || this.type == NPCID.JungleBat || this.type == NPCID.Hellbat || this.type == NPCID.Demon || this.type == NPCID.VoodooDemon || this.type == NPCID.GiantBat || this.type == NPCID.IlluminantBat || this.type == NPCID.IceBat || this.type == NPCID.Lavabat || this.type == NPCID.GiantFlyingFox)
                {
                    if (this.wet)
                    {
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y * 0.95f;
                        }
                        this.velocity.Y = this.velocity.Y - 0.5f;
                        if (this.velocity.Y < -4f)
                        {
                            this.velocity.Y = -4f;
                        }
                        this.TargetClosest(true);
                    }
                    if (this.type == NPCID.Hellbat)
                    {
                        if (this.direction == -1 && this.velocity.X > -4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = this.velocity.X - 0.07f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.03f;
                            }
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = -4f;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < 4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = this.velocity.X + 0.07f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.03f;
                            }
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = 4f;
                            }
                        }
                        if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            else if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.02f;
                            }
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = -1.5f;
                            }
                        }
                        else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.02f;
                            }
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = 1.5f;
                            }
                        }
                    }
                    else
                    {
                        if (this.direction == -1 && this.velocity.X > -4f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.05f;
                            }
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = -4f;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < 4f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -4f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.05f;
                            }
                            if (this.velocity.X > 4f)
                            {
                                this.velocity.X = 4f;
                            }
                        }
                        if (this.directionY == -1 && (double)this.velocity.Y > -1.5)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = this.velocity.Y - 0.05f;
                            }
                            else if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = -1.5f;
                            }
                        }
                        else if (this.directionY == 1 && (double)this.velocity.Y < 1.5)
                        {
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = this.velocity.Y + 0.05f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = 1.5f;
                            }
                        }
                    }
                }
                if (this.type == NPCID.VampireBat && Main.netMode != 1)
                {
                    Vector2 vector62 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num616 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector62.X;
                    float num617 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector62.Y;
                    float num618 = (float)Math.Sqrt((double)(num616 * num616 + num617 * num617));
                    if (num618 < 200f && this.position.Y + (float)this.height < Main.player[this.target].position.Y + (float)Main.player[this.target].height && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.Transform(159);
                    }
                }
                this.ai[1] += 1f;
                if (this.type == NPCID.VampireBat)
                {
                    this.ai[1] += 1f;
                }
                if (this.ai[1] > 200f)
                {
                    if (!Main.player[this.target].wet && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.ai[1] = 0f;
                    }
                    float num619 = 0.2f;
                    float num620 = 0.1f;
                    float num621 = 4f;
                    float num622 = 1.5f;
                    if (this.type == NPCID.Harpy || this.type == NPCID.Demon || this.type == NPCID.VoodooDemon)
                    {
                        num619 = 0.12f;
                        num620 = 0.07f;
                        num621 = 3f;
                        num622 = 1.25f;
                    }
                    if (this.ai[1] > 1000f)
                    {
                        this.ai[1] = 0f;
                    }
                    this.ai[2] += 1f;
                    if (this.ai[2] > 0f)
                    {
                        if (this.velocity.Y < num622)
                        {
                            this.velocity.Y = this.velocity.Y + num620;
                        }
                    }
                    else if (this.velocity.Y > -num622)
                    {
                        this.velocity.Y = this.velocity.Y - num620;
                    }
                    if (this.ai[2] < -150f || this.ai[2] > 150f)
                    {
                        if (this.velocity.X < num621)
                        {
                            this.velocity.X = this.velocity.X + num619;
                        }
                    }
                    else if (this.velocity.X > -num621)
                    {
                        this.velocity.X = this.velocity.X - num619;
                    }
                    if (this.ai[2] > 300f)
                    {
                        this.ai[2] = -300f;
                    }
                }
                if (Main.netMode != 1)
                {
                    if (this.type == NPCID.Harpy)
                    {
                        this.ai[0] += 1f;
                        if (this.ai[0] == 30f || this.ai[0] == 60f || this.ai[0] == 90f)
                        {
                            if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float num623 = 6f;
                                Vector2 vector63 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num624 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector63.X + (float)Main.rand.Next(-100, 101);
                                float num625 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector63.Y + (float)Main.rand.Next(-100, 101);
                                float num626 = (float)Math.Sqrt((double)(num624 * num624 + num625 * num625));
                                num626 = num623 / num626;
                                num624 *= num626;
                                num625 *= num626;
                                int num627 = 15;
                                int num628 = 38;
                                int num629 = Projectile.NewProjectile(vector63.X, vector63.Y, num624, num625, num628, num627, 0f, Main.myPlayer, 0f, 0f);
                                Main.projectile[num629].timeLeft = 300;
                            }
                        }
                        else if (this.ai[0] >= (float)(400 + Main.rand.Next(400)))
                        {
                            this.ai[0] = 0f;
                        }
                    }
                    if (this.type == NPCID.Demon || this.type == NPCID.VoodooDemon)
                    {
                        this.ai[0] += 1f;
                        if (this.ai[0] == 20f || this.ai[0] == 40f || this.ai[0] == 60f || this.ai[0] == 80f)
                        {
                            if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float num630 = 0.2f;
                                Vector2 vector64 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num631 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector64.X + (float)Main.rand.Next(-100, 101);
                                float num632 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector64.Y + (float)Main.rand.Next(-100, 101);
                                float num633 = (float)Math.Sqrt((double)(num631 * num631 + num632 * num632));
                                num633 = num630 / num633;
                                num631 *= num633;
                                num632 *= num633;
                                int num634 = 21;
                                int num635 = 44;
                                int num636 = Projectile.NewProjectile(vector64.X, vector64.Y, num631, num632, num635, num634, 0f, Main.myPlayer, 0f, 0f);
                                Main.projectile[num636].timeLeft = 300;
                            }
                        }
                        else if (this.ai[0] >= (float)(300 + Main.rand.Next(300)))
                        {
                            this.ai[0] = 0f;
                        }
                    }
                    if (this.type == NPCID.RedDevil)
                    {
                        this.ai[0] += 1f;
                        if (this.ai[0] == 20f || this.ai[0] == 40f || this.ai[0] == 60f || this.ai[0] == 80f || this.ai[0] == 100f)
                        {
                            if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float num637 = 0.2f;
                                Vector2 value13 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num638 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - value13.X + (float)Main.rand.Next(-50, 51);
                                float num639 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - value13.Y + (float)Main.rand.Next(-50, 51);
                                float num640 = (float)Math.Sqrt((double)(num638 * num638 + num639 * num639));
                                num640 = num637 / num640;
                                num638 *= num640;
                                num639 *= num640;
                                int num641 = 80;
                                int num642 = 115;
                                value13 += this.velocity * 5f;
                                int num643 = Projectile.NewProjectile(value13.X + num638 * 100f, value13.Y + num639 * 100f, num638, num639, num642, num641, 0f, Main.myPlayer, 0f, 0f);
                                Main.projectile[num643].timeLeft = 300;
                                return;
                            }
                        }
                        else if (this.ai[0] >= (float)(250 + Main.rand.Next(250)))
                        {
                            this.ai[0] = 0f;
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 15)
            {
                float num644 = 1f;
                bool flag65 = false;
                bool flag66 = false;
                this.aiAction = 0;
                if (this.ai[3] == 0f && this.life > 0)
                {
                    this.ai[3] = (float)this.lifeMax;
                }
                if (this.localAI[3] == 0f && Main.netMode != 1)
                {
                    this.ai[0] = -100f;
                    this.localAI[3] = 1f;
                    this.TargetClosest(true);
                    this.netUpdate = true;
                }
                if (Main.player[this.target].dead)
                {
                    this.TargetClosest(true);
                    if (Main.player[this.target].dead)
                    {
                        this.timeLeft = 0;
                        if (Main.player[this.target].Center.X < base.Center.X)
                        {
                            this.direction = 1;
                        }
                        else
                        {
                            this.direction = -1;
                        }
                    }
                }
                if (!Main.player[this.target].dead && this.ai[2] >= 300f && this.ai[1] < 5f && this.velocity.Y == 0f)
                {
                    this.ai[2] = 0f;
                    this.ai[0] = 0f;
                    this.ai[1] = 5f;
                    if (Main.netMode != 1)
                    {
                        this.TargetClosest(false);
                        Point point5 = base.Center.ToTileCoordinates();
                        Point point6 = Main.player[this.target].Center.ToTileCoordinates();
                        Vector2 vector65 = Main.player[this.target].Center - base.Center;
                        int num645 = 10;
                        int num646 = 0;
                        int num647 = 7;
                        int num648 = 0;
                        bool flag67 = false;
                        if (vector65.Length() > 2000f)
                        {
                            flag67 = true;
                            num648 = 100;
                        }
                        while (!flag67 && num648 < 100)
                        {
                            num648++;
                            int num649 = Main.rand.Next(point6.X - num645, point6.X + num645 + 1);
                            int num650 = Main.rand.Next(point6.Y - num645, point6.Y + 1);
                            if ((num650 < point6.Y - num647 || num650 > point6.Y + num647 || num649 < point6.X - num647 || num649 > point6.X + num647) && (num650 < point5.Y - num646 || num650 > point5.Y + num646 || num649 < point5.X - num646 || num649 > point5.X + num646) && !Main.tile[num649, num650].nactive())
                            {
                                int num651 = num650;
                                int num652 = 0;
                                bool flag68 = Main.tile[num649, num651].nactive() && Main.tileSolid[(int)Main.tile[num649, num651].type] && !Main.tileSolidTop[(int)Main.tile[num649, num651].type];
                                if (flag68)
                                {
                                    num652 = 1;
                                }
                                else
                                {
                                    while (num652 < 150 && num651 + num652 < Main.maxTilesY)
                                    {
                                        int num653 = num651 + num652;
                                        bool flag69 = Main.tile[num649, num653].nactive() && Main.tileSolid[(int)Main.tile[num649, num653].type] && !Main.tileSolidTop[(int)Main.tile[num649, num653].type];
                                        if (flag69)
                                        {
                                            num652--;
                                            break;
                                        }
                                        num652++;
                                    }
                                }
                                num650 += num652;
                                bool flag70 = true;
                                if (flag70 && Main.tile[num649, num650].lava())
                                {
                                    flag70 = false;
                                }
                                if (flag70 && !Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                                {
                                    var nearPlayer = new Vector2(num649 * 16, num650 * 16);
                                    this.Teleport(nearPlayer, 4, 0);
                                    flag70 = false;
                                }
                                if (flag70)
                                {
                                    this.localAI[1] = (float)(num649 * 16 + 8);
                                    this.localAI[2] = (float)(num650 * 16 + 16);
                                    break;
                                }
                            }
                        }
                        if (num648 >= 100)
                        {
                            Vector2 bottom = Main.player[(int)Player.FindClosest(this.position, this.width, this.height)].Bottom;
                            this.localAI[1] = bottom.X;
                            this.localAI[2] = bottom.Y;
                        }
                    }
                }
                if (!Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                {
                    this.ai[2] += 1f;
                }
                if (Math.Abs(base.Top.Y - Main.player[this.target].Bottom.Y) > 320f)
                {
                    this.ai[2] += 1f;
                }
                if (this.ai[1] == 5f)
                {
                    this.aiAction = 1;
                    this.ai[0] += 1f;
                    num644 = MathHelper.Clamp((60f - this.ai[0]) / 60f, 0f, 1f);
                    num644 = 0.5f + num644 * 0.5f;
                    if (this.ai[0] >= 60f && Main.netMode != 1)
                    {
                        base.Bottom = new Vector2(this.localAI[1], this.localAI[2]);
                        this.ai[1] = 6f;
                        this.ai[0] = 0f;
                        this.netUpdate = true;
                    }
                    if (Main.netMode == 1 && this.ai[0] >= 120f)
                    {
                        this.ai[1] = 6f;
                        this.ai[0] = 0f;
                    }
                }
                else if (this.ai[1] == 6f)
                {
                    flag65 = true;
                    this.aiAction = 0;
                    this.ai[0] += 1f;
                    num644 = MathHelper.Clamp(this.ai[0] / 30f, 0f, 1f);
                    num644 = 0.5f + num644 * 0.5f;
                    if (this.ai[0] >= 30f && Main.netMode != 1)
                    {
                        this.ai[1] = 0f;
                        this.ai[0] = 0f;
                        this.netUpdate = true;
                        this.TargetClosest(true);
                    }
                    if (Main.netMode == 1 && this.ai[0] >= 60f)
                    {
                        this.ai[1] = 0f;
                        this.ai[0] = 0f;
                        this.TargetClosest(true);
                    }
                }
                this.dontTakeDamage = (this.hide = flag66);
                if (this.velocity.Y == 0f)
                {
                    this.velocity.X = this.velocity.X * 0.8f;
                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                    {
                        this.velocity.X = 0f;
                    }
                    if (!flag65)
                    {
                        this.ai[0] += 2f;
                        if ((double)this.life < (double)this.lifeMax * 0.8)
                        {
                            this.ai[0] += 1f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.6)
                        {
                            this.ai[0] += 1f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.4)
                        {
                            this.ai[0] += 2f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.2)
                        {
                            this.ai[0] += 3f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.1)
                        {
                            this.ai[0] += 4f;
                        }
                        if (this.ai[0] >= 0f)
                        {
                            this.netUpdate = true;
                            this.TargetClosest(true);
                            if (this.ai[1] == 3f)
                            {
                                this.velocity.Y = -13f;
                                this.velocity.X = this.velocity.X + 3.5f * (float)this.direction;
                                this.ai[0] = -200f;
                                this.ai[1] = 0f;
                            }
                            else if (this.ai[1] == 2f)
                            {
                                this.velocity.Y = -6f;
                                this.velocity.X = this.velocity.X + 4.5f * (float)this.direction;
                                this.ai[0] = -120f;
                                this.ai[1] += 1f;
                            }
                            else
                            {
                                this.velocity.Y = -8f;
                                this.velocity.X = this.velocity.X + 4f * (float)this.direction;
                                this.ai[0] = -120f;
                                this.ai[1] += 1f;
                            }
                        }
                        else if (this.ai[0] >= -30f)
                        {
                            this.aiAction = 1;
                        }
                    }
                }
                else if (this.target < 255 && ((this.direction == 1 && this.velocity.X < 3f) || (this.direction == -1 && this.velocity.X > -3f)))
                {
                    if ((this.direction == -1 && (double)this.velocity.X < 0.1) || (this.direction == 1 && (double)this.velocity.X > -0.1))
                    {
                        this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                    }
                    else
                    {
                        this.velocity.X = this.velocity.X * 0.93f;
                    }
                }
                if (this.life > 0)
                {
                    float num659 = (float)this.life / (float)this.lifeMax;
                    num659 = num659 * 0.5f + 0.75f;
                    num659 *= num644;
                    if (num659 != this.scale)
                    {
                        this.position.X = this.position.X + (float)(this.width / 2);
                        this.position.Y = this.position.Y + (float)this.height;
                        this.scale = num659;
                        this.width = (int)(98f * this.scale);
                        this.height = (int)(92f * this.scale);
                        this.position.X = this.position.X - (float)(this.width / 2);
                        this.position.Y = this.position.Y - (float)this.height;
                    }
                    if (Main.netMode != 1)
                    {
                        int num660 = (int)((double)this.lifeMax * 0.05);
                        if ((float)(this.life + num660) < this.ai[3])
                        {
                            this.ai[3] = (float)this.life;
                            int num661 = Main.rand.Next(1, 4);
                            for (int num662 = 0; num662 < num661; num662++)
                            {
                                int x = (int)(this.position.X + (float)Main.rand.Next(this.width - 32));
                                int y = (int)(this.position.Y + (float)Main.rand.Next(this.height - 32));
                                int num663 = 1;
                                if (Main.expertMode && Main.rand.Next(4) == 0)
                                {
                                    num663 = 535;
                                }
                                int num664 = NPC.NewNPC(x, y, num663, 0, 0f, 0f, 0f, 0f, 255);
                                Main.npc[num664].SetDefaults(num663, -1f);
                                Main.npc[num664].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f;
                                Main.npc[num664].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f;
                                Main.npc[num664].ai[0] = (float)(-1000 * Main.rand.Next(3));
                                Main.npc[num664].ai[1] = 0f;
                                if (Main.netMode == 2 && num664 < 200)
                                {
                                    NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num664, 0f, 0f, 0f, 0, 0, 0);
                                }
                            }
                            return;
                        }
                    }
                }
            }
            else if (this.aiStyle == 16)
            {
                if (this.direction == 0)
                {
                    this.TargetClosest(true);
                }
                if (this.wet)
                {
                    bool flag71 = false;
                    if (this.type != NPCID.Goldfish)
                    {
                        this.TargetClosest(false);
                        if (Main.player[this.target].wet && !Main.player[this.target].dead)
                        {
                            flag71 = true;
                        }
                    }
                    if (!flag71)
                    {
                        if (this.collideX)
                        {
                            this.velocity.X = this.velocity.X * -1f;
                            this.direction *= -1;
                            this.netUpdate = true;
                        }
                        if (this.collideY)
                        {
                            this.netUpdate = true;
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = Math.Abs(this.velocity.Y) * -1f;
                                this.directionY = -1;
                                this.ai[0] = -1f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = Math.Abs(this.velocity.Y);
                                this.directionY = 1;
                                this.ai[0] = 1f;
                            }
                        }
                    }
                    if (flag71)
                    {
                        this.TargetClosest(true);
                        if (this.type == NPCID.Arapaima)
                        {
                            if (this.velocity.X > 0f && this.direction < 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.velocity.X < 0f && this.direction > 0)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.25f;
                            this.velocity.Y = this.velocity.Y + (float)this.directionY * 0.2f;
                            if (this.velocity.X > 8f)
                            {
                                this.velocity.X = 7f;
                            }
                            if (this.velocity.X < -8f)
                            {
                                this.velocity.X = -7f;
                            }
                            if (this.velocity.Y > 5f)
                            {
                                this.velocity.Y = 4f;
                            }
                            if (this.velocity.Y < -5f)
                            {
                                this.velocity.Y = -4f;
                            }
                        }
                        else if (this.type == NPCID.Shark || this.type == NPCID.AnglerFish)
                        {
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.15f;
                            this.velocity.Y = this.velocity.Y + (float)this.directionY * 0.15f;
                            if (this.velocity.X > 5f)
                            {
                                this.velocity.X = 5f;
                            }
                            if (this.velocity.X < -5f)
                            {
                                this.velocity.X = -5f;
                            }
                            if (this.velocity.Y > 3f)
                            {
                                this.velocity.Y = 3f;
                            }
                            if (this.velocity.Y < -3f)
                            {
                                this.velocity.Y = -3f;
                            }
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.1f;
                            this.velocity.Y = this.velocity.Y + (float)this.directionY * 0.1f;
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = 3f;
                            }
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = -3f;
                            }
                            if (this.velocity.Y > 2f)
                            {
                                this.velocity.Y = 2f;
                            }
                            if (this.velocity.Y < -2f)
                            {
                                this.velocity.Y = -2f;
                            }
                        }
                    }
                    else
                    {
                        if (this.type == NPCID.Arapaima)
                        {
                            if (Main.player[this.target].position.Y > this.position.Y)
                            {
                                this.directionY = 1;
                            }
                            else
                            {
                                this.directionY = -1;
                            }
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.2f;
                            if (this.velocity.X < -2f || this.velocity.X > 2f)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.ai[0] == -1f)
                            {
                                float num665 = -0.6f;
                                if (this.directionY < 0)
                                {
                                    num665 = -1f;
                                }
                                if (this.directionY > 0)
                                {
                                    num665 = -0.2f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.02f;
                                if (this.velocity.Y < num665)
                                {
                                    this.ai[0] = 1f;
                                }
                            }
                            else
                            {
                                float num666 = 0.6f;
                                if (this.directionY < 0)
                                {
                                    num666 = 0.2f;
                                }
                                if (this.directionY > 0)
                                {
                                    num666 = 1f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.02f;
                                if (this.velocity.Y > num666)
                                {
                                    this.ai[0] = -1f;
                                }
                            }
                        }
                        else
                        {
                            this.velocity.X = this.velocity.X + (float)this.direction * 0.1f;
                            if (this.velocity.X < -1f || this.velocity.X > 1f)
                            {
                                this.velocity.X = this.velocity.X * 0.95f;
                            }
                            if (this.ai[0] == -1f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.01f;
                                if ((double)this.velocity.Y < -0.3)
                                {
                                    this.ai[0] = 1f;
                                }
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y + 0.01f;
                                if ((double)this.velocity.Y > 0.3)
                                {
                                    this.ai[0] = -1f;
                                }
                            }
                        }
                        int num667 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                        int num668 = (int)(this.position.Y + (float)(this.height / 2)) / 16;
                        if (Main.tile[num667, num668 - 1] == null)
                        {
                            Main.tile[num667, num668 - 1] = new Tile();
                        }
                        if (Main.tile[num667, num668 + 1] == null)
                        {
                            Main.tile[num667, num668 + 1] = new Tile();
                        }
                        if (Main.tile[num667, num668 + 2] == null)
                        {
                            Main.tile[num667, num668 + 2] = new Tile();
                        }
                        if (Main.tile[num667, num668 - 1].liquid > 128)
                        {
                            if (Main.tile[num667, num668 + 1].active())
                            {
                                this.ai[0] = -1f;
                            }
                            else if (Main.tile[num667, num668 + 2].active())
                            {
                                this.ai[0] = -1f;
                            }
                        }
                        if (this.type != NPCID.Arapaima && ((double)this.velocity.Y > 0.4 || (double)this.velocity.Y < -0.4))
                        {
                            this.velocity.Y = this.velocity.Y * 0.95f;
                        }
                    }
                }
                else
                {
                    if (this.velocity.Y == 0f)
                    {
                        if (this.type == NPCID.Shark)
                        {
                            this.velocity.X = this.velocity.X * 0.94f;
                            if ((double)this.velocity.X > -0.2 && (double)this.velocity.X < 0.2)
                            {
                                this.velocity.X = 0f;
                            }
                        }
                        else if (Main.netMode != 1)
                        {
                            this.velocity.Y = (float)Main.rand.Next(-50, -20) * 0.1f;
                            this.velocity.X = (float)Main.rand.Next(-20, 20) * 0.1f;
                            this.netUpdate = true;
                        }
                    }
                    this.velocity.Y = this.velocity.Y + 0.3f;
                    if (this.velocity.Y > 10f)
                    {
                        this.velocity.Y = 10f;
                    }
                    this.ai[0] = 1f;
                }
                this.rotation = this.velocity.Y * (float)this.direction * 0.1f;
                if ((double)this.rotation < -0.2)
                {
                    this.rotation = -0.2f;
                }
                if ((double)this.rotation > 0.2)
                {
                    this.rotation = 0.2f;
                    return;
                }
            }
            else if (this.aiStyle == 17)
            {
                this.noGravity = true;
                if (this.ai[0] == 0f)
                {
                    this.noGravity = false;
                    this.TargetClosest(true);
                    if (Main.netMode != 1)
                    {
                        if (this.velocity.X != 0f || this.velocity.Y < 0f || (double)this.velocity.Y > 0.3)
                        {
                            this.ai[0] = 1f;
                            this.netUpdate = true;
                        }
                        else
                        {
                            Rectangle rectangle6 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                            Rectangle rectangle7 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                            if (rectangle7.Intersects(rectangle6) || this.life < this.lifeMax)
                            {
                                this.ai[0] = 1f;
                                this.velocity.Y = this.velocity.Y - 6f;
                                this.netUpdate = true;
                            }
                        }
                    }
                }
                else if (!Main.player[this.target].dead)
                {
                    if (this.collideX)
                    {
                        this.velocity.X = this.oldVelocity.X * -0.5f;
                        if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                        {
                            this.velocity.X = 2f;
                        }
                        if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                        {
                            this.velocity.X = -2f;
                        }
                    }
                    if (this.collideY)
                    {
                        this.velocity.Y = this.oldVelocity.Y * -0.5f;
                        if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                        {
                            this.velocity.Y = 1f;
                        }
                        if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                        {
                            this.velocity.Y = -1f;
                        }
                    }
                    this.TargetClosest(true);
                    if (this.direction == -1 && this.velocity.X > -3f)
                    {
                        this.velocity.X = this.velocity.X - 0.1f;
                        if (this.velocity.X > 3f)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                        }
                        else if (this.velocity.X > 0f)
                        {
                            this.velocity.X = this.velocity.X - 0.05f;
                        }
                        if (this.velocity.X < -3f)
                        {
                            this.velocity.X = -3f;
                        }
                    }
                    else if (this.direction == 1 && this.velocity.X < 3f)
                    {
                        this.velocity.X = this.velocity.X + 0.1f;
                        if (this.velocity.X < -3f)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                        }
                        else if (this.velocity.X < 0f)
                        {
                            this.velocity.X = this.velocity.X + 0.05f;
                        }
                        if (this.velocity.X > 3f)
                        {
                            this.velocity.X = 3f;
                        }
                    }
                    float num669 = Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)));
                    float num670 = Main.player[this.target].position.Y - (float)(this.height / 2);
                    if (num669 > 50f)
                    {
                        num670 -= 100f;
                    }
                    if (this.position.Y < num670)
                    {
                        this.velocity.Y = this.velocity.Y + 0.05f;
                        if (this.velocity.Y < 0f)
                        {
                            this.velocity.Y = this.velocity.Y + 0.01f;
                        }
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y - 0.05f;
                        if (this.velocity.Y > 0f)
                        {
                            this.velocity.Y = this.velocity.Y - 0.01f;
                        }
                    }
                    if (this.velocity.Y < -3f)
                    {
                        this.velocity.Y = -3f;
                    }
                    if (this.velocity.Y > 3f)
                    {
                        this.velocity.Y = 3f;
                    }
                }
                if (this.wet)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = this.velocity.Y * 0.95f;
                    }
                    this.velocity.Y = this.velocity.Y - 0.5f;
                    if (this.velocity.Y < -4f)
                    {
                        this.velocity.Y = -4f;
                    }
                    this.TargetClosest(true);
                    return;
                }
            }
            else if (this.aiStyle == 18)
            {
                bool flag72 = false;
                if (this.wet && this.ai[1] == 1f)
                {
                    flag72 = true;
                }
                else
                {
                    this.dontTakeDamage = false;
                }
                if (Main.expertMode && (this.type == NPCID.BlueJellyfish || this.type == NPCID.PinkJellyfish || this.type == NPCID.GreenJellyfish || this.type == NPCID.BloodJelly))
                {
                    if (this.wet)
                    {
                        if (this.target >= 0 && Main.player[this.target].wet && !Main.player[this.target].dead && (Main.player[this.target].Center - base.Center).Length() < 150f)
                        {
                            if (this.ai[1] == 0f)
                            {
                                this.ai[2] += 2f;
                            }
                            else
                            {
                                this.ai[2] -= 0.25f;
                            }
                        }
                        if (flag72)
                        {
                            this.dontTakeDamage = true;
                            this.ai[2] += 1f;
                            if (this.ai[2] >= 120f)
                            {
                                this.ai[1] = 0f;
                            }
                        }
                        else
                        {
                            this.ai[2] += 1f;
                            if (this.ai[2] >= 420f)
                            {
                                this.ai[1] = 1f;
                                this.ai[2] = 0f;
                            }
                        }
                    }
                    else
                    {
                        this.ai[1] = 0f;
                        this.ai[2] = 0f;
                    }
                }
                float num671 = 1f;
                if (flag72)
                {
                    num671 += 0.5f;
                }
                if (this.direction == 0)
                {
                    this.TargetClosest(true);
                }
                if (flag72)
                {
                    return;
                }
                if (!this.wet)
                {
                    this.rotation += this.velocity.X * 0.1f;
                    if (this.velocity.Y == 0f)
                    {
                        this.velocity.X = this.velocity.X * 0.98f;
                        if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
                        {
                            this.velocity.X = 0f;
                        }
                    }
                    this.velocity.Y = this.velocity.Y + 0.2f;
                    if (this.velocity.Y > 10f)
                    {
                        this.velocity.Y = 10f;
                    }
                    this.ai[0] = 1f;
                    return;
                }
                if (this.collideX)
                {
                    this.velocity.X = this.velocity.X * -1f;
                    this.direction *= -1;
                }
                if (this.collideY)
                {
                    if (this.velocity.Y > 0f)
                    {
                        this.velocity.Y = Math.Abs(this.velocity.Y) * -1f;
                        this.directionY = -1;
                        this.ai[0] = -1f;
                    }
                    else if (this.velocity.Y < 0f)
                    {
                        this.velocity.Y = Math.Abs(this.velocity.Y);
                        this.directionY = 1;
                        this.ai[0] = 1f;
                    }
                }
                bool flag73 = false;
                if (!this.friendly)
                {
                    this.TargetClosest(false);
                    if (Main.player[this.target].wet && !Main.player[this.target].dead)
                    {
                        flag73 = true;
                    }
                }
                if (flag73)
                {
                    this.localAI[2] = 1f;
                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                    this.velocity *= 0.98f;
                    float num672 = 0.2f;
                    if (this.type == NPCID.GreenJellyfish)
                    {
                        this.velocity *= 0.98f;
                        num672 = 0.6f;
                    }
                    if (this.type == NPCID.Squid)
                    {
                        this.velocity *= 0.99f;
                        num672 = 1f;
                    }
                    if (this.type == NPCID.BloodJelly)
                    {
                        this.velocity *= 0.995f;
                        num672 = 3f;
                    }
                    if (this.velocity.X > -num672 && this.velocity.X < num672 && this.velocity.Y > -num672 && this.velocity.Y < num672)
                    {
                        if (this.type == NPCID.Squid)
                        {
                            this.localAI[0] = 1f;
                        }
                        this.TargetClosest(true);
                        float num673 = 7f;
                        if (this.type == NPCID.GreenJellyfish)
                        {
                            num673 = 9f;
                        }
                        Vector2 vector66 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num674 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector66.X;
                        float num675 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector66.Y;
                        float num676 = (float)Math.Sqrt((double)(num674 * num674 + num675 * num675));
                        num676 = num673 / num676;
                        num674 *= num676;
                        num675 *= num676;
                        this.velocity.X = num674;
                        this.velocity.Y = num675;
                        return;
                    }
                }
                else
                {
                    this.localAI[2] = 0f;
                    this.velocity.X = this.velocity.X + (float)this.direction * 0.02f;
                    this.rotation = this.velocity.X * 0.4f;
                    if (this.velocity.X < -1f || this.velocity.X > 1f)
                    {
                        this.velocity.X = this.velocity.X * 0.95f;
                    }
                    if (this.ai[0] == -1f)
                    {
                        this.velocity.Y = this.velocity.Y - 0.01f;
                        if (this.velocity.Y < -1f)
                        {
                            this.ai[0] = 1f;
                        }
                    }
                    else
                    {
                        this.velocity.Y = this.velocity.Y + 0.01f;
                        if (this.velocity.Y > 1f)
                        {
                            this.ai[0] = -1f;
                        }
                    }
                    int num677 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                    int num678 = (int)(this.position.Y + (float)(this.height / 2)) / 16;
                    if (Main.tile[num677, num678 - 1] == null)
                    {
                        Main.tile[num677, num678 - 1] = new Tile();
                    }
                    if (Main.tile[num677, num678 + 1] == null)
                    {
                        Main.tile[num677, num678 + 1] = new Tile();
                    }
                    if (Main.tile[num677, num678 + 2] == null)
                    {
                        Main.tile[num677, num678 + 2] = new Tile();
                    }
                    if (Main.tile[num677, num678 - 1].liquid > 128)
                    {
                        if (Main.tile[num677, num678 + 1].active())
                        {
                            this.ai[0] = -1f;
                        }
                        else if (Main.tile[num677, num678 + 2].active())
                        {
                            this.ai[0] = -1f;
                        }
                    }
                    else
                    {
                        this.ai[0] = 1f;
                    }
                    if ((double)this.velocity.Y > 1.2 || (double)this.velocity.Y < -1.2)
                    {
                        this.velocity.Y = this.velocity.Y * 0.99f;
                        return;
                    }
                }
            }
            else
            {
                if (this.aiStyle == 19)
                {
                    this.TargetClosest(true);
                    float num679 = 12f;
                    Vector2 vector67 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                    float num680 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector67.X;
                    float num681 = Main.player[this.target].position.Y - vector67.Y;
                    float num682 = (float)Math.Sqrt((double)(num680 * num680 + num681 * num681));
                    num682 = num679 / num682;
                    num680 *= num682;
                    num681 *= num682;
                    bool flag74 = false;
                    if (this.directionY < 0)
                    {
                        this.rotation = (float)(Math.Atan2((double)num681, (double)num680) + 1.57);
                        flag74 = ((double)this.rotation >= -1.2 && (double)this.rotation <= 1.2);
                        if ((double)this.rotation < -0.8)
                        {
                            this.rotation = -0.8f;
                        }
                        else if ((double)this.rotation > 0.8)
                        {
                            this.rotation = 0.8f;
                        }
                        if (this.velocity.X != 0f)
                        {
                            this.velocity.X = this.velocity.X * 0.9f;
                            if ((double)this.velocity.X > -0.1 || (double)this.velocity.X < 0.1)
                            {
                                this.netUpdate = true;
                                this.velocity.X = 0f;
                            }
                        }
                    }
                    if (this.ai[0] > 0f)
                    {
                        this.ai[0] -= 1f;
                    }
                    if (Main.netMode != 1 && flag74 && this.ai[0] == 0f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                    {
                        this.ai[0] = 200f;
                        int num683 = 10;
                        int num684 = 31;
                        int num685 = Projectile.NewProjectile(vector67.X, vector67.Y, num680, num681, num684, num683, 0f, Main.myPlayer, 0f, 0f);
                        Main.projectile[num685].ai[0] = 2f;
                        Main.projectile[num685].timeLeft = 300;
                        Main.projectile[num685].friendly = false;
                        NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", num685, 0f, 0f, 0f, 0, 0, 0);
                        this.netUpdate = true;
                    }
                    try
                    {
                        int num686 = (int)this.position.X / 16;
                        int num687 = (int)(this.position.X + (float)(this.width / 2)) / 16;
                        int num688 = (int)(this.position.X + (float)this.width) / 16;
                        int num689 = (int)(this.position.Y + (float)this.height) / 16;
                        bool flag75 = false;
                        if (Main.tile[num686, num689] == null)
                        {
                            Main.tile[num686, num689] = new Tile();
                        }
                        if (Main.tile[num687, num689] == null)
                        {
                            Main.tile[num686, num689] = new Tile();
                        }
                        if (Main.tile[num688, num689] == null)
                        {
                            Main.tile[num686, num689] = new Tile();
                        }
                        if ((Main.tile[num686, num689].nactive() && Main.tileSolid[(int)Main.tile[num686, num689].type]) || (Main.tile[num687, num689].nactive() && Main.tileSolid[(int)Main.tile[num687, num689].type]) || (Main.tile[num688, num689].nactive() && Main.tileSolid[(int)Main.tile[num688, num689].type]))
                        {
                            flag75 = true;
                        }
                        if (flag75)
                        {
                            this.noGravity = true;
                            this.noTileCollide = true;
                            this.velocity.Y = -0.2f;
                        }
                        else
                        {
                            this.noGravity = false;
                            this.noTileCollide = false;
                        }
                        return;
                    }
                    catch
                    {
                        return;
                    }
                }
                if (this.aiStyle == 20)
                {
                    if (this.ai[0] == 0f)
                    {
                        if (Main.netMode != 1)
                        {
                            this.TargetClosest(true);
                            this.direction *= -1;
                            this.directionY *= -1;
                            this.position.Y = this.position.Y + (float)(this.height / 2 + 8);
                            this.ai[1] = this.position.X + (float)(this.width / 2);
                            this.ai[2] = this.position.Y + (float)(this.height / 2);
                            if (this.direction == 0)
                            {
                                this.direction = 1;
                            }
                            if (this.directionY == 0)
                            {
                                this.directionY = 1;
                            }
                            this.ai[3] = 1f + (float)Main.rand.Next(15) * 0.1f;
                            this.velocity.Y = (float)(this.directionY * 6) * this.ai[3];
                            this.ai[0] += 1f;
                            this.netUpdate = true;
                            return;
                        }
                        this.ai[1] = this.position.X + (float)(this.width / 2);
                        this.ai[2] = this.position.Y + (float)(this.height / 2);
                        return;
                    }
                    else
                    {
                        float num691 = 6f * this.ai[3];
                        float num692 = 0.2f * this.ai[3];
                        float num693 = num691 / num692 / 2f;
                        if (this.ai[0] >= 1f && this.ai[0] < (float)((int)num693))
                        {
                            this.velocity.Y = (float)this.directionY * num691;
                            this.ai[0] += 1f;
                            return;
                        }
                        if (this.ai[0] >= (float)((int)num693))
                        {
                            this.velocity.Y = 0f;
                            this.directionY *= -1;
                            this.velocity.X = num691 * (float)this.direction;
                            this.ai[0] = -1f;
                            return;
                        }
                        if (this.directionY > 0)
                        {
                            if (this.velocity.Y >= num691)
                            {
                                this.directionY *= -1;
                                this.velocity.Y = num691;
                            }
                        }
                        else if (this.directionY < 0 && this.velocity.Y <= -num691)
                        {
                            this.directionY *= -1;
                            this.velocity.Y = -num691;
                        }
                        if (this.direction > 0)
                        {
                            if (this.velocity.X >= num691)
                            {
                                this.direction *= -1;
                                this.velocity.X = num691;
                            }
                        }
                        else if (this.direction < 0 && this.velocity.X <= -num691)
                        {
                            this.direction *= -1;
                            this.velocity.X = -num691;
                        }
                        this.velocity.X = this.velocity.X + num692 * (float)this.direction;
                        this.velocity.Y = this.velocity.Y + num692 * (float)this.directionY;
                        return;
                    }
                }
                else
                {
                    if (this.aiStyle == 21)
                    {
                        if (this.ai[0] == 0f)
                        {
                            this.TargetClosest(true);
                            this.directionY = 1;
                            this.ai[0] = 1f;
                        }
                        int num694 = 6;
                        if (this.ai[1] == 0f)
                        {
                            this.rotation += (float)(this.direction * this.directionY) * 0.13f;
                            if (this.collideY)
                            {
                                this.ai[0] = 2f;
                            }
                            if (!this.collideY && this.ai[0] == 2f)
                            {
                                this.direction = -this.direction;
                                this.ai[1] = 1f;
                                this.ai[0] = 1f;
                            }
                            if (this.collideX)
                            {
                                this.directionY = -this.directionY;
                                this.ai[1] = 1f;
                            }
                        }
                        else
                        {
                            this.rotation -= (float)(this.direction * this.directionY) * 0.13f;
                            if (this.collideX)
                            {
                                this.ai[0] = 2f;
                            }
                            if (!this.collideX && this.ai[0] == 2f)
                            {
                                this.directionY = -this.directionY;
                                this.ai[1] = 0f;
                                this.ai[0] = 1f;
                            }
                            if (this.collideY)
                            {
                                this.direction = -this.direction;
                                this.ai[1] = 0f;
                            }
                        }
                        this.velocity.X = (float)(num694 * this.direction);
                        this.velocity.Y = (float)(num694 * this.directionY);
                        float num695 = (float)(270 - (int)Main.mouseTextColor) / 400f;
                        return;
                    }
                    if (this.aiStyle == 22)
                    {
                        bool flag76 = false;
                        bool flag77 = this.type == NPCID.Poltergeist && !Main.pumpkinMoon;
                        if (this.type == NPCID.Reaper && !Main.eclipse)
                        {
                            flag77 = true;
                        }
                        if (this.type == NPCID.Drippler && Main.dayTime)
                        {
                            flag77 = true;
                        }
                        if (this.justHit)
                        {
                            this.ai[2] = 0f;
                        }
                        if (!flag77)
                        {
                            if (this.ai[2] >= 0f)
                            {
                                int num696 = 16;
                                bool flag78 = false;
                                bool flag79 = false;
                                if (this.position.X > this.ai[0] - (float)num696 && this.position.X < this.ai[0] + (float)num696)
                                {
                                    flag78 = true;
                                }
                                else if ((this.velocity.X < 0f && this.direction > 0) || (this.velocity.X > 0f && this.direction < 0))
                                {
                                    flag78 = true;
                                }
                                num696 += 24;
                                if (this.position.Y > this.ai[1] - (float)num696 && this.position.Y < this.ai[1] + (float)num696)
                                {
                                    flag79 = true;
                                }
                                if (flag78 && flag79)
                                {
                                    this.ai[2] += 1f;
                                    if (this.ai[2] >= 30f && num696 == 16)
                                    {
                                        flag76 = true;
                                    }
                                    if (this.ai[2] >= 60f)
                                    {
                                        this.ai[2] = -200f;
                                        this.direction *= -1;
                                        this.velocity.X = this.velocity.X * -1f;
                                        this.collideX = false;
                                    }
                                }
                                else
                                {
                                    this.ai[0] = this.position.X;
                                    this.ai[1] = this.position.Y;
                                    this.ai[2] = 0f;
                                }
                                this.TargetClosest(true);
                            }
                            else if (this.type == NPCID.Reaper)
                            {
                                this.TargetClosest(true);
                                this.ai[2] += 2f;
                            }
                            else
                            {
                                if (this.type == NPCID.Poltergeist)
                                {
                                    this.ai[2] += 0.1f;
                                }
                                else
                                {
                                    this.ai[2] += 1f;
                                }
                                if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) > this.position.X + (float)(this.width / 2))
                                {
                                    this.direction = -1;
                                }
                                else
                                {
                                    this.direction = 1;
                                }
                            }
                        }
                        int num697 = (int)((this.position.X + (float)(this.width / 2)) / 16f) + this.direction * 2;
                        int num698 = (int)((this.position.Y + (float)this.height) / 16f);
                        bool flag80 = true;
                        bool flag81 = false;
                        int num699 = 3;
                        if (this.type == NPCID.Gastropod)
                        {
                            if (this.justHit)
                            {
                                this.ai[3] = 0f;
                                this.localAI[1] = 0f;
                            }
                            float num700 = 7f;
                            Vector2 vector68 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num701 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector68.X;
                            float num702 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector68.Y;
                            float num703 = (float)Math.Sqrt((double)(num701 * num701 + num702 * num702));
                            num703 = num700 / num703;
                            num701 *= num703;
                            num702 *= num703;
                            if (Main.netMode != 1 && this.ai[3] == 32f && !Main.player[this.target].npcTypeNoAggro[this.type])
                            {
                                int num704 = 25;
                                int num705 = 84;
                                Projectile.NewProjectile(vector68.X, vector68.Y, num701, num702, num705, num704, 0f, Main.myPlayer, 0f, 0f);
                            }
                            num699 = 8;
                            if (this.ai[3] > 0f)
                            {
                                this.ai[3] += 1f;
                                if (this.ai[3] >= 64f)
                                {
                                    this.ai[3] = 0f;
                                }
                            }
                            if (Main.netMode != 1 && this.ai[3] == 0f)
                            {
                                this.localAI[1] += 1f;
                                if (this.localAI[1] > 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && !Main.player[this.target].npcTypeNoAggro[this.type])
                                {
                                    this.localAI[1] = 0f;
                                    this.ai[3] = 1f;
                                    this.netUpdate = true;
                                }
                            }
                        }
                        else if (this.type == NPCID.Pixie)
                        {
                            num699 = 4;
                        }
                        else if (this.type == NPCID.IceElemental)
                        {
                            this.alpha = 30;
                            if (this.justHit)
                            {
                                this.ai[3] = 0f;
                                this.localAI[1] = 0f;
                            }
                            float num708 = 5f;
                            Vector2 vector69 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num709 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector69.X;
                            float num710 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector69.Y;
                            float num711 = (float)Math.Sqrt((double)(num709 * num709 + num710 * num710));
                            num711 = num708 / num711;
                            num709 *= num711;
                            num710 *= num711;
                            if (num709 > 0f)
                            {
                                this.direction = 1;
                            }
                            else
                            {
                                this.direction = -1;
                            }
                            this.spriteDirection = this.direction;
                            if (this.direction < 0)
                            {
                                this.rotation = (float)Math.Atan2((double)(-(double)num710), (double)(-(double)num709));
                            }
                            else
                            {
                                this.rotation = (float)Math.Atan2((double)num710, (double)num709);
                            }
                            if (Main.netMode != 1 && this.ai[3] == 16f)
                            {
                                int num712 = 45;
                                int num713 = 128;
                                Projectile.NewProjectile(vector69.X, vector69.Y, num709, num710, num713, num712, 0f, Main.myPlayer, 0f, 0f);
                            }
                            num699 = 10;
                            if (this.ai[3] > 0f)
                            {
                                this.ai[3] += 1f;
                                if (this.ai[3] >= 64f)
                                {
                                    this.ai[3] = 0f;
                                }
                            }
                            if (Main.netMode != 1 && this.ai[3] == 0f)
                            {
                                this.localAI[1] += 1f;
                                if (this.localAI[1] > 120f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                {
                                    this.localAI[1] = 0f;
                                    this.ai[3] = 1f;
                                    this.netUpdate = true;
                                }
                            }
                        }
                        else if (this.type == NPCID.IchorSticker)
                        {
                            this.rotation = this.velocity.X * 0.1f;
                            if (Main.player[this.target].Center.Y < base.Center.Y)
                            {
                                num699 = 12;
                            }
                            else
                            {
                                num699 = 6;
                            }
                            if (Main.netMode != 1 && !this.confused)
                            {
                                this.ai[3] += 1f;
                                if (this.justHit)
                                {
                                    this.ai[3] = -45f;
                                    this.localAI[1] = 0f;
                                }
                                if (Main.netMode != 1 && this.ai[3] >= (float)(60 + Main.rand.Next(60)))
                                {
                                    this.ai[3] = 0f;
                                    if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].head))
                                    {
                                        float num714 = 10f;
                                        Vector2 vector70 = new Vector2(this.position.X + (float)this.width * 0.5f - 4f, this.position.Y + (float)this.height * 0.7f);
                                        float num715 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector70.X;
                                        float num716 = Math.Abs(num715) * 0.1f;
                                        float num717 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector70.Y - num716;
                                        num715 += (float)Main.rand.Next(-10, 11);
                                        num717 += (float)Main.rand.Next(-30, 21);
                                        float num718 = (float)Math.Sqrt((double)(num715 * num715 + num717 * num717));
                                        num718 = num714 / num718;
                                        num715 *= num718;
                                        num717 *= num718;
                                        int num719 = 40;
                                        int num720 = 288;
                                        Projectile.NewProjectile(vector70.X, vector70.Y, num715, num717, num720, num719, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                }
                            }
                        }
                        if (this.type == NPCID.Drippler)
                        {
                            num699 = 4;
                            if (this.target >= 0)
                            {
                                float num721 = (Main.player[this.target].Center - base.Center).Length();
                                num721 /= 70f;
                                if (num721 > 8f)
                                {
                                    num721 = 8f;
                                }
                                num699 += (int)num721;
                            }
                        }
                        for (int num722 = num698; num722 < num698 + num699; num722++)
                        {
                            if (Main.tile[num697, num722] == null)
                            {
                                Main.tile[num697, num722] = new Tile();
                            }
                            if ((Main.tile[num697, num722].nactive() && Main.tileSolid[(int)Main.tile[num697, num722].type]) || Main.tile[num697, num722].liquid > 0)
                            {
                                if (num722 <= num698 + 1)
                                {
                                    flag81 = true;
                                }
                                flag80 = false;
                                break;
                            }
                        }
                        if (Main.player[this.target].npcTypeNoAggro[this.type])
                        {
                            bool flag82 = false;
                            for (int num723 = num698; num723 < num698 + num699 - 2; num723++)
                            {
                                if (Main.tile[num697, num723] == null)
                                {
                                    Main.tile[num697, num723] = new Tile();
                                }
                                if ((Main.tile[num697, num723].nactive() && Main.tileSolid[(int)Main.tile[num697, num723].type]) || Main.tile[num697, num723].liquid > 0)
                                {
                                    flag82 = true;
                                    break;
                                }
                            }
                            this.directionY = (!flag82).ToDirectionInt();
                        }
                        if (this.type == NPCID.IceElemental || this.type == NPCID.IchorSticker)
                        {
                            for (int num724 = num698 - 3; num724 < num698; num724++)
                            {
                                if (Main.tile[num697, num724] == null)
                                {
                                    Main.tile[num697, num724] = new Tile();
                                }
                                if ((Main.tile[num697, num724].nactive() && Main.tileSolid[(int)Main.tile[num697, num724].type]) || Main.tile[num697, num724].liquid > 0)
                                {
                                    flag81 = false;
                                    flag76 = true;
                                    break;
                                }
                            }
                        }
                        if (flag76)
                        {
                            flag81 = false;
                            flag80 = true;
                            if (this.type == NPCID.IchorSticker)
                            {
                                this.velocity.Y = this.velocity.Y + 2f;
                            }
                        }
                        if (flag80)
                        {
                            if (this.type == NPCID.Pixie || this.type == NPCID.IceElemental)
                            {
                                this.velocity.Y = this.velocity.Y + 0.2f;
                                if (this.velocity.Y > 2f)
                                {
                                    this.velocity.Y = 2f;
                                }
                            }
                            else if (this.type == NPCID.Drippler)
                            {
                                this.velocity.Y = this.velocity.Y + 0.03f;
                                if ((double)this.velocity.Y > 0.75)
                                {
                                    this.velocity.Y = 0.75f;
                                }
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y > 3f)
                                {
                                    this.velocity.Y = 3f;
                                }
                            }
                        }
                        else
                        {
                            if (this.type == NPCID.Pixie || this.type == NPCID.IceElemental)
                            {
                                if ((this.directionY < 0 && this.velocity.Y > 0f) || flag81)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.2f;
                                }
                            }
                            else if (this.type == NPCID.Drippler)
                            {
                                if ((this.directionY < 0 && this.velocity.Y > 0f) || flag81)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.075f;
                                }
                                if (this.velocity.Y < -0.75f)
                                {
                                    this.velocity.Y = -0.75f;
                                }
                            }
                            else if (this.directionY < 0 && this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.1f;
                            }
                            if (this.velocity.Y < -4f)
                            {
                                this.velocity.Y = -4f;
                            }
                        }
                        if (this.type == NPCID.Pixie && this.wet)
                        {
                            this.velocity.Y = this.velocity.Y - 0.2f;
                            if (this.velocity.Y < -2f)
                            {
                                this.velocity.Y = -2f;
                            }
                        }
                        if (this.collideX)
                        {
                            this.velocity.X = this.oldVelocity.X * -0.4f;
                            if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 1f)
                            {
                                this.velocity.X = 1f;
                            }
                            if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -1f)
                            {
                                this.velocity.X = -1f;
                            }
                        }
                        if (this.collideY)
                        {
                            this.velocity.Y = this.oldVelocity.Y * -0.25f;
                            if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                            {
                                this.velocity.Y = 1f;
                            }
                            if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                            {
                                this.velocity.Y = -1f;
                            }
                        }
                        float num725 = 2f;
                        if (this.type == NPCID.Pixie)
                        {
                            num725 = 3f;
                        }
                        if (this.type == NPCID.Reaper)
                        {
                            num725 = 4f;
                        }
                        if (this.type == NPCID.Drippler)
                        {
                            num725 = 1.5f;
                        }
                        if (this.type == NPCID.Poltergeist)
                        {
                            this.alpha = 0;
                            num725 = 4f;
                            if (!flag77)
                            {
                                this.TargetClosest(true);
                            }
                            else if (this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                            }
                            if (this.direction < 0 && this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if (this.direction > 0 && this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                        }
                        if (this.direction == -1 && this.velocity.X > -num725)
                        {
                            this.velocity.X = this.velocity.X - 0.1f;
                            if (this.velocity.X > num725)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.velocity.X = this.velocity.X + 0.05f;
                            }
                            if (this.velocity.X < -num725)
                            {
                                this.velocity.X = -num725;
                            }
                        }
                        else if (this.direction == 1 && this.velocity.X < num725)
                        {
                            this.velocity.X = this.velocity.X + 0.1f;
                            if (this.velocity.X < -num725)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            else if (this.velocity.X < 0f)
                            {
                                this.velocity.X = this.velocity.X - 0.05f;
                            }
                            if (this.velocity.X > num725)
                            {
                                this.velocity.X = num725;
                            }
                        }
                        if (this.type == NPCID.Drippler)
                        {
                            num725 = 1f;
                        }
                        else
                        {
                            num725 = 1.5f;
                        }
                        if (this.directionY == -1 && this.velocity.Y > -num725)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if (this.velocity.Y > num725)
                            {
                                this.velocity.Y = this.velocity.Y - 0.05f;
                            }
                            else if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            if (this.velocity.Y < -num725)
                            {
                                this.velocity.Y = -num725;
                            }
                        }
                        else if (this.directionY == 1 && this.velocity.Y < num725)
                        {
                            this.velocity.Y = this.velocity.Y + 0.04f;
                            if (this.velocity.Y < -num725)
                            {
                                this.velocity.Y = this.velocity.Y + 0.05f;
                            }
                            else if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            if (this.velocity.Y > num725)
                            {
                                this.velocity.Y = num725;
                            }
                        }
                        if (this.type == NPCID.Gastropod)
                        {
                            return;
                        }
                    }
                    else if (this.aiStyle == 23)
                    {
                        this.noGravity = true;
                        this.noTileCollide = true;
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                        }
                        if (this.ai[0] == 0f)
                        {
                            float num726 = 9f;
                            Vector2 vector71 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num727 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector71.X;
                            float num728 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector71.Y;
                            float num729 = (float)Math.Sqrt((double)(num727 * num727 + num728 * num728));
                            num729 = num726 / num729;
                            num727 *= num729;
                            num728 *= num729;
                            this.velocity.X = num727;
                            this.velocity.Y = num728;
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 0.785f;
                            this.ai[0] = 1f;
                            this.ai[1] = 0f;
                            this.netUpdate = true;
                            return;
                        }
                        if (this.ai[0] == 1f)
                        {
                            if (this.justHit)
                            {
                                this.ai[0] = 2f;
                                this.ai[1] = 0f;
                            }
                            this.velocity *= 0.99f;
                            this.ai[1] += 1f;
                            if (this.ai[1] >= 100f)
                            {
                                this.netUpdate = true;
                                this.ai[0] = 2f;
                                this.ai[1] = 0f;
                                this.velocity.X = 0f;
                                this.velocity.Y = 0f;
                                return;
                            }
                        }
                        else
                        {
                            if (this.justHit)
                            {
                                this.ai[0] = 2f;
                                this.ai[1] = 0f;
                            }
                            this.velocity *= 0.96f;
                            this.ai[1] += 1f;
                            float num730 = this.ai[1] / 120f;
                            num730 = 0.1f + num730 * 0.4f;
                            this.rotation += num730 * (float)this.direction;
                            if (this.ai[1] >= 120f)
                            {
                                this.netUpdate = true;
                                this.ai[0] = 0f;
                                this.ai[1] = 0f;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 24)
                    {
                        this.noGravity = true;
                        if (this.ai[0] == 0f)
                        {
                            this.noGravity = false;
                            this.TargetClosest(true);
                            if (Main.netMode != 1)
                            {
                                if (this.velocity.X != 0f || this.velocity.Y < 0f || (double)this.velocity.Y > 0.3)
                                {
                                    this.ai[0] = 1f;
                                    this.netUpdate = true;
                                    this.direction = -this.direction;
                                }
                                else
                                {
                                    Rectangle rectangle8 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                                    Rectangle rectangle9 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                                    if (rectangle9.Intersects(rectangle8) || this.life < this.lifeMax)
                                    {
                                        this.ai[0] = 1f;
                                        this.velocity.Y = this.velocity.Y - 6f;
                                        this.netUpdate = true;
                                        this.direction = -this.direction;
                                    }
                                }
                            }
                        }
                        else if (!Main.player[this.target].dead)
                        {
                            if (this.collideX)
                            {
                                this.direction *= -1;
                                this.velocity.X = this.oldVelocity.X * -0.5f;
                                if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                                {
                                    this.velocity.X = 2f;
                                }
                                if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                                {
                                    this.velocity.X = -2f;
                                }
                            }
                            if (this.collideY)
                            {
                                this.velocity.Y = this.oldVelocity.Y * -0.5f;
                                if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                                {
                                    this.velocity.Y = 1f;
                                }
                                if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                                {
                                    this.velocity.Y = -1f;
                                }
                            }
                            if (this.direction == -1 && this.velocity.X > -3f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                                if (this.velocity.X > 3f)
                                {
                                    this.velocity.X = this.velocity.X - 0.1f;
                                }
                                else if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X - 0.05f;
                                }
                                if (this.velocity.X < -3f)
                                {
                                    this.velocity.X = -3f;
                                }
                            }
                            else if (this.direction == 1 && this.velocity.X < 3f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                                if (this.velocity.X < -3f)
                                {
                                    this.velocity.X = this.velocity.X + 0.1f;
                                }
                                else if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X + 0.05f;
                                }
                                if (this.velocity.X > 3f)
                                {
                                    this.velocity.X = 3f;
                                }
                            }
                            int num731 = (int)((this.position.X + (float)(this.width / 2)) / 16f) + this.direction;
                            int num732 = (int)((this.position.Y + (float)this.height) / 16f);
                            bool flag83 = true;
                            int num733 = 15;
                            bool flag84 = false;
                            for (int num734 = num732; num734 < num732 + num733; num734++)
                            {
                                if (Main.tile[num731, num734] == null)
                                {
                                    Main.tile[num731, num734] = new Tile();
                                }
                                if ((Main.tile[num731, num734].nactive() && Main.tileSolid[(int)Main.tile[num731, num734].type]) || Main.tile[num731, num734].liquid > 0)
                                {
                                    if (num734 < num732 + 5)
                                    {
                                        flag84 = true;
                                    }
                                    flag83 = false;
                                    break;
                                }
                            }
                            if (flag83)
                            {
                                this.velocity.Y = this.velocity.Y + 0.05f;
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y - 0.1f;
                            }
                            if (flag84)
                            {
                                this.velocity.Y = this.velocity.Y - 0.2f;
                            }
                            if (this.velocity.Y > 2f)
                            {
                                this.velocity.Y = 2f;
                            }
                            if (this.velocity.Y < -4f)
                            {
                                this.velocity.Y = -4f;
                            }
                        }
                        if (this.wet)
                        {
                            this.ai[1] = 0f;
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.95f;
                            }
                            this.velocity.Y = this.velocity.Y - 0.5f;
                            if (this.velocity.Y < -4f)
                            {
                                this.velocity.Y = -4f;
                            }
                            this.TargetClosest(true);
                            return;
                        }
                    }
                    else if (this.aiStyle == 25)
                    {
                        bool flag85 = this.type == NPCID.PresentMimic && !Main.snowMoon;
                        if (this.ai[3] == 0f)
                        {
                            this.position.X = this.position.X + 8f;
                            if (this.position.Y / 16f > (float)(Main.maxTilesY - 200))
                            {
                                this.ai[3] = 3f;
                            }
                            else if ((double)(this.position.Y / 16f) > Main.worldSurface)
                            {
                                this.TargetClosest(true);
                                if (Main.player[this.target].ZoneSnow)
                                {
                                    this.ai[3] = 4f;
                                }
                                else
                                {
                                    this.ai[3] = 2f;
                                }
                            }
                            else
                            {
                                this.ai[3] = 1f;
                            }
                        }
                        if (this.type == NPCID.PresentMimic)
                        {
                            this.ai[3] = 1f;
                        }
                        if (this.ai[0] == 0f)
                        {
                            if (!flag85)
                            {
                                this.TargetClosest(true);
                            }
                            if (Main.netMode != 1)
                            {
                                if (this.velocity.X != 0f || this.velocity.Y < 0f || (double)this.velocity.Y > 0.3)
                                {
                                    this.ai[0] = 1f;
                                    this.netUpdate = true;
                                    return;
                                }
                                Rectangle rectangle10 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                                Rectangle rectangle11 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                                if (rectangle11.Intersects(rectangle10) || this.life < this.lifeMax)
                                {
                                    this.ai[0] = 1f;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                        }
                        else if (this.velocity.Y == 0f)
                        {
                            this.ai[2] += 1f;
                            int num735 = 20;
                            if (this.ai[1] == 0f)
                            {
                                num735 = 12;
                            }
                            if (this.ai[2] < (float)num735)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                return;
                            }
                            this.ai[2] = 0f;
                            if (!flag85)
                            {
                                this.TargetClosest(true);
                            }
                            if (this.direction == 0)
                            {
                                this.direction = -1;
                            }
                            this.spriteDirection = this.direction;
                            this.ai[1] += 1f;
                            if (this.ai[1] == 2f)
                            {
                                this.velocity.X = (float)this.direction * 2.5f;
                                this.velocity.Y = -8f;
                                this.ai[1] = 0f;
                            }
                            else
                            {
                                this.velocity.X = (float)this.direction * 3.5f;
                                this.velocity.Y = -4f;
                            }
                            this.netUpdate = true;
                            return;
                        }
                        else
                        {
                            if (this.direction == 1 && this.velocity.X < 1f)
                            {
                                this.velocity.X = this.velocity.X + 0.1f;
                                return;
                            }
                            if (this.direction == -1 && this.velocity.X > -1f)
                            {
                                this.velocity.X = this.velocity.X - 0.1f;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 26)
                    {
                        int num736 = 30;
                        int num737 = 10;
                        bool flag86 = false;
                        bool flag87 = false;
                        bool flag88 = false;
                        if (this.velocity.Y == 0f && ((this.velocity.X > 0f && this.direction < 0) || (this.velocity.X < 0f && this.direction > 0)))
                        {
                            flag87 = true;
                            this.ai[3] += 1f;
                        }
                        if (this.position.X == this.oldPosition.X || this.ai[3] >= (float)num736 || flag87)
                        {
                            this.ai[3] += 1f;
                            flag88 = true;
                        }
                        else if (this.ai[3] > 0f)
                        {
                            this.ai[3] -= 1f;
                        }
                        if (this.ai[3] > (float)(num736 * num737))
                        {
                            this.ai[3] = 0f;
                        }
                        if (this.justHit)
                        {
                            this.ai[3] = 0f;
                        }
                        if (this.ai[3] == (float)num736)
                        {
                            this.netUpdate = true;
                        }
                        Vector2 vector72 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num738 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector72.X;
                        float num739 = Main.player[this.target].position.Y - vector72.Y;
                        float num740 = (float)Math.Sqrt((double)(num738 * num738 + num739 * num739));
                        if (num740 < 200f && !flag88)
                        {
                            this.ai[3] = 0f;
                        }
                        if (this.type == NPCID.StardustSpiderSmall)
                        {
                            this.ai[1] += 1f;
                            bool flag89 = this.ai[1] >= 240f;
                            if (!flag89 && this.velocity.Y == 0f)
                            {
                                for (int num741 = 0; num741 < 255; num741++)
                                {
                                    if (Main.player[num741].active && !Main.player[num741].dead && Main.player[num741].Distance(base.Center) < 800f && Main.player[num741].Center.Y < base.Center.Y && Math.Abs(Main.player[num741].Center.X - base.Center.X) < 20f)
                                    {
                                        flag89 = true;
                                        break;
                                    }
                                }
                            }
                            if (flag89 && Main.netMode != 1)
                            {
                                for (int num742 = 0; num742 < 3; num742++)
                                {
                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, (Main.rand.NextFloat() - 0.5f) * 2f, -4f - 10f * Main.rand.NextFloat(), 538, 50, 0f, Main.myPlayer, 0f, 0f);
                                }
                                this.HitEffect(9999, 10.0);
                                this.active = false;
                                return;
                            }
                        }
                        else if (this.type == NPCID.NebulaBeast)
                        {
                            if (this.ai[2] == 1f)
                            {
                                this.ai[1] += 1f;
                                this.velocity.X = this.velocity.X * 0.7f;
                                if (this.velocity.X > -0.5f && this.velocity.X < 0.5f)
                                {
                                    this.velocity.X = 0f;
                                }
                                if (this.ai[1] == 30f && Main.netMode != 1)
                                {
                                    int num744 = Main.expertMode ? 35 : 50;
                                    Projectile.NewProjectile(base.Center.X + (float)(this.spriteDirection * -20), base.Center.Y, (float)(this.spriteDirection * -7), 0f, 575, num744, 0f, Main.myPlayer, (float)this.target, 0f);
                                }
                                if (this.ai[1] >= 60f)
                                {
                                    this.ai[1] = (float)(-(float)Main.rand.Next(320, 601));
                                    this.ai[2] = 0f;
                                }
                            }
                            else
                            {
                                this.ai[1] += 1f;
                                if (this.ai[1] >= 180f && num740 < 500f && this.velocity.Y == 0f)
                                {
                                    flag86 = true;
                                    this.ai[1] = 0f;
                                    this.ai[2] = 1f;
                                    this.netUpdate = true;
                                }
                                else if (this.velocity.Y == 0f && num740 < 100f && Math.Abs(this.velocity.X) > 3f && ((base.Center.X < Main.player[this.target].Center.X && this.velocity.X > 0f) || (base.Center.X > Main.player[this.target].Center.X && this.velocity.X < 0f)))
                                {
                                    this.velocity.Y = this.velocity.Y - 4f;
                                }
                            }
                        }
                        else if ((this.type == NPCID.Wolf || this.type == NPCID.Hellhound) && this.velocity.Y == 0f && num740 < 100f && Math.Abs(this.velocity.X) > 3f && ((this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) && this.velocity.X > 0f) || (this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) && this.velocity.X < 0f)))
                        {
                            this.velocity.Y = this.velocity.Y - 4f;
                        }
                        if (this.ai[3] < (float)num736)
                        {
                            if ((this.type == NPCID.Hellhound || this.type == NPCID.HeadlessHorseman) && !Main.pumpkinMoon)
                            {
                                if (this.timeLeft > 10)
                                {
                                    this.timeLeft = 10;
                                }
                            }
                            else
                            {
                                this.TargetClosest(true);
                            }
                        }
                        else
                        {
                            if (this.velocity.X == 0f)
                            {
                                if (this.velocity.Y == 0f)
                                {
                                    this.ai[0] += 1f;
                                    if (this.ai[0] >= 2f)
                                    {
                                        this.direction *= -1;
                                        this.spriteDirection = this.direction;
                                        this.ai[0] = 0f;
                                    }
                                }
                            }
                            else
                            {
                                this.ai[0] = 0f;
                            }
                            this.directionY = -1;
                            if (this.direction == 0)
                            {
                                this.direction = 1;
                            }
                        }
                        float num745 = 6f;
                        float num746 = 0.07f;
                        if (!flag86 && (this.velocity.Y == 0f || this.wet || (this.velocity.X <= 0f && this.direction < 0) || (this.velocity.X >= 0f && this.direction > 0)))
                        {
                            if (this.type == NPCID.Wolf)
                            {
                                if (this.velocity.X > 0f && this.direction < 0)
                                {
                                    this.velocity.X = this.velocity.X * 0.95f;
                                }
                                if (this.velocity.X < 0f && this.direction > 0)
                                {
                                    this.velocity.X = this.velocity.X * 0.95f;
                                }
                            }
                            else if (this.type == NPCID.Hellhound)
                            {
                                if (this.velocity.X > 0f && this.direction < 0)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                if (this.velocity.X < 0f && this.direction > 0)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                if (this.direction > 0 && this.velocity.X < 3f)
                                {
                                    this.velocity.X = this.velocity.X + 0.1f;
                                }
                                if (this.direction < 0 && this.velocity.X > -3f)
                                {
                                    this.velocity.X = this.velocity.X - 0.1f;
                                }
                            }
                            else if (this.type == NPCID.HeadlessHorseman)
                            {
                                if (this.velocity.X > 0f && this.direction < 0)
                                {
                                    this.velocity.X = this.velocity.X * 0.95f;
                                }
                                if (this.velocity.X < 0f && this.direction > 0)
                                {
                                    this.velocity.X = this.velocity.X * 0.95f;
                                }
                                if (this.velocity.X < -num745 || this.velocity.X > num745)
                                {
                                    if (this.velocity.Y == 0f)
                                    {
                                        this.velocity *= 0.8f;
                                    }
                                }
                                else if (this.velocity.X < num745 && this.direction == 1)
                                {
                                    this.velocity.X = this.velocity.X + 0.07f;
                                    if (this.velocity.X > num745)
                                    {
                                        this.velocity.X = num745;
                                    }
                                }
                                else if (this.velocity.X > -num745 && this.direction == -1)
                                {
                                    this.velocity.X = this.velocity.X - 0.07f;
                                    if (this.velocity.X < -num745)
                                    {
                                        this.velocity.X = -num745;
                                    }
                                }
                            }
                            else if (this.type == NPCID.StardustSpiderSmall)
                            {
                                if (Math.Sign(this.velocity.X) != this.direction)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                num745 = 6f;
                                num746 = 0.2f;
                            }
                            else if (this.type == NPCID.NebulaBeast)
                            {
                                if (Math.Sign(this.velocity.X) != this.direction)
                                {
                                    this.velocity.X = this.velocity.X * 0.85f;
                                }
                                num745 = 10f;
                                num746 = 0.2f;
                            }
                            if (this.velocity.X < -num745 || this.velocity.X > num745)
                            {
                                if (this.velocity.Y == 0f)
                                {
                                    this.velocity *= 0.8f;
                                }
                            }
                            else if (this.velocity.X < num745 && this.direction == 1)
                            {
                                this.velocity.X = this.velocity.X + num746;
                                if (this.velocity.X > num745)
                                {
                                    this.velocity.X = num745;
                                }
                            }
                            else if (this.velocity.X > -num745 && this.direction == -1)
                            {
                                this.velocity.X = this.velocity.X - num746;
                                if (this.velocity.X < -num745)
                                {
                                    this.velocity.X = -num745;
                                }
                            }
                        }
                        if (this.velocity.Y >= 0f)
                        {
                            int num747 = 0;
                            if (this.velocity.X < 0f)
                            {
                                num747 = -1;
                            }
                            if (this.velocity.X > 0f)
                            {
                                num747 = 1;
                            }
                            Vector2 position5 = this.position;
                            position5.X += this.velocity.X;
                            int num748 = (int)((position5.X + (float)(this.width / 2) + (float)((this.width / 2 + 1) * num747)) / 16f);
                            int num749 = (int)((position5.Y + (float)this.height - 1f) / 16f);
                            if (Main.tile[num748, num749] == null)
                            {
                                Main.tile[num748, num749] = new Tile();
                            }
                            if (Main.tile[num748, num749 - 1] == null)
                            {
                                Main.tile[num748, num749 - 1] = new Tile();
                            }
                            if (Main.tile[num748, num749 - 2] == null)
                            {
                                Main.tile[num748, num749 - 2] = new Tile();
                            }
                            if (Main.tile[num748, num749 - 3] == null)
                            {
                                Main.tile[num748, num749 - 3] = new Tile();
                            }
                            if (Main.tile[num748, num749 + 1] == null)
                            {
                                Main.tile[num748, num749 + 1] = new Tile();
                            }
                            if ((float)(num748 * 16) < position5.X + (float)this.width && (float)(num748 * 16 + 16) > position5.X && ((Main.tile[num748, num749].nactive() && !Main.tile[num748, num749].topSlope() && !Main.tile[num748, num749 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num748, num749].type] && !Main.tileSolidTop[(int)Main.tile[num748, num749].type]) || (Main.tile[num748, num749 - 1].halfBrick() && Main.tile[num748, num749 - 1].nactive())) && (!Main.tile[num748, num749 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num748, num749 - 1].type] || Main.tileSolidTop[(int)Main.tile[num748, num749 - 1].type] || (Main.tile[num748, num749 - 1].halfBrick() && (!Main.tile[num748, num749 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num748, num749 - 4].type] || Main.tileSolidTop[(int)Main.tile[num748, num749 - 4].type]))) && (!Main.tile[num748, num749 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num748, num749 - 2].type] || Main.tileSolidTop[(int)Main.tile[num748, num749 - 2].type]) && (!Main.tile[num748, num749 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num748, num749 - 3].type] || Main.tileSolidTop[(int)Main.tile[num748, num749 - 3].type]) && (!Main.tile[num748 - num747, num749 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num748 - num747, num749 - 3].type]))
                            {
                                float num750 = (float)(num749 * 16);
                                if (Main.tile[num748, num749].halfBrick())
                                {
                                    num750 += 8f;
                                }
                                if (Main.tile[num748, num749 - 1].halfBrick())
                                {
                                    num750 -= 8f;
                                }
                                if (num750 < position5.Y + (float)this.height)
                                {
                                    float num751 = position5.Y + (float)this.height - num750;
                                    if ((double)num751 <= 16.1)
                                    {
                                        this.gfxOffY += this.position.Y + (float)this.height - num750;
                                        this.position.Y = num750 - (float)this.height;
                                        if (num751 < 9f)
                                        {
                                            this.stepSpeed = 1f;
                                        }
                                        else
                                        {
                                            this.stepSpeed = 2f;
                                        }
                                    }
                                }
                            }
                        }
                        if (this.velocity.Y == 0f)
                        {
                            int num752 = (int)((this.position.X + (float)(this.width / 2) + (float)((this.width / 2 + 2) * this.direction) + this.velocity.X * 5f) / 16f);
                            int num753 = (int)((this.position.Y + (float)this.height - 15f) / 16f);
                            if (Main.tile[num752, num753] == null)
                            {
                                Main.tile[num752, num753] = new Tile();
                            }
                            if (Main.tile[num752, num753 - 1] == null)
                            {
                                Main.tile[num752, num753 - 1] = new Tile();
                            }
                            if (Main.tile[num752, num753 - 2] == null)
                            {
                                Main.tile[num752, num753 - 2] = new Tile();
                            }
                            if (Main.tile[num752, num753 - 3] == null)
                            {
                                Main.tile[num752, num753 - 3] = new Tile();
                            }
                            if (Main.tile[num752, num753 + 1] == null)
                            {
                                Main.tile[num752, num753 + 1] = new Tile();
                            }
                            if (Main.tile[num752 + this.direction, num753 - 1] == null)
                            {
                                Main.tile[num752 + this.direction, num753 - 1] = new Tile();
                            }
                            if (Main.tile[num752 + this.direction, num753 + 1] == null)
                            {
                                Main.tile[num752 + this.direction, num753 + 1] = new Tile();
                            }
                            if (Main.tile[num752 - this.direction, num753 + 1] == null)
                            {
                                Main.tile[num752 - this.direction, num753 + 1] = new Tile();
                            }
                            int num754 = this.spriteDirection;
                            if (this.type == NPCID.NebulaBeast || this.type == NPCID.StardustSpiderSmall)
                            {
                                num754 *= -1;
                            }
                            if ((this.velocity.X < 0f && num754 == -1) || (this.velocity.X > 0f && num754 == 1))
                            {
                                bool flag90 = this.type == NPCID.StardustSpiderSmall || this.type == NPCID.NebulaBeast;
                                float num755 = 3f;
                                if (Main.tile[num752, num753 - 2].nactive() && Main.tileSolid[(int)Main.tile[num752, num753 - 2].type])
                                {
                                    if (Main.tile[num752, num753 - 3].nactive() && Main.tileSolid[(int)Main.tile[num752, num753 - 3].type])
                                    {
                                        this.velocity.Y = -8.5f;
                                        this.netUpdate = true;
                                    }
                                    else
                                    {
                                        this.velocity.Y = -7.5f;
                                        this.netUpdate = true;
                                    }
                                }
                                else if (Main.tile[num752, num753 - 1].nactive() && !Main.tile[num752, num753 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num752, num753 - 1].type])
                                {
                                    this.velocity.Y = -7f;
                                    this.netUpdate = true;
                                }
                                else if (this.position.Y + (float)this.height - (float)(num753 * 16) > 20f && Main.tile[num752, num753].nactive() && !Main.tile[num752, num753].topSlope() && Main.tileSolid[(int)Main.tile[num752, num753].type])
                                {
                                    this.velocity.Y = -6f;
                                    this.netUpdate = true;
                                }
                                else if ((this.directionY < 0 || Math.Abs(this.velocity.X) > num755) && (!flag90 || !Main.tile[num752, num753 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num752, num753 + 1].type]) && (!Main.tile[num752, num753 + 2].nactive() || !Main.tileSolid[(int)Main.tile[num752, num753 + 2].type]) && (!Main.tile[num752 + this.direction, num753 + 3].nactive() || !Main.tileSolid[(int)Main.tile[num752 + this.direction, num753 + 3].type]))
                                {
                                    this.velocity.Y = -8f;
                                    this.netUpdate = true;
                                }
                            }
                        }
                        if (this.type == NPCID.NebulaBeast && Math.Abs(this.velocity.X) >= num745 * 0.95f)
                        {
                            return;
                        }
                    }
                    else if (this.aiStyle == 27)
                    {
                        if (this.position.X < 160f || this.position.X > (float)((Main.maxTilesX - 10) * 16))
                        {
                            this.active = false;
                        }
                        if (this.localAI[0] == 0f)
                        {
                            this.localAI[0] = 1f;
                            Main.wofB = -1;
                            Main.wofT = -1;
                        }
                        this.ai[1] += 1f;
                        if (this.ai[2] == 0f)
                        {
                            if ((double)this.life < (double)this.lifeMax * 0.5)
                            {
                                this.ai[1] += 1f;
                            }
                            if ((double)this.life < (double)this.lifeMax * 0.2)
                            {
                                this.ai[1] += 1f;
                            }
                            if (this.ai[1] > 2700f)
                            {
                                this.ai[2] = 1f;
                            }
                        }
                        if (this.ai[2] > 0f && this.ai[1] > 60f)
                        {
                            int num757 = 3;
                            if ((double)this.life < (double)this.lifeMax * 0.3)
                            {
                                num757++;
                            }
                            this.ai[2] += 1f;
                            this.ai[1] = 0f;
                            if (this.ai[2] > (float)num757)
                            {
                                this.ai[2] = 0f;
                            }
                            if (Main.netMode != 1)
                            {
                                int num758 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)(this.height / 2) + 20f), 117, 1, 0f, 0f, 0f, 0f, 255);
                                Main.npc[num758].velocity.X = (float)(this.direction * 8);
                            }
                        }
                        this.localAI[3] += 1f;
                        if (this.localAI[3] >= (float)(600 + Main.rand.Next(1000)))
                        {
                            this.localAI[3] = (float)(-(float)Main.rand.Next(200));
                        }
                        Main.wof = this.whoAmI;
                        int num759 = (int)(this.position.X / 16f);
                        int num760 = (int)((this.position.X + (float)this.width) / 16f);
                        int num761 = (int)((this.position.Y + (float)(this.height / 2)) / 16f);
                        int num762 = 0;
                        int num763 = num761 + 7;
                        while (num762 < 15 && num763 > Main.maxTilesY - 200)
                        {
                            num763++;
                            for (int num764 = num759; num764 <= num760; num764++)
                            {
                                try
                                {
                                    if (WorldGen.SolidTile(num764, num763) || Main.tile[num764, num763].liquid > 0)
                                    {
                                        num762++;
                                    }
                                }
                                catch
                                {
                                    num762 += 15;
                                }
                            }
                        }
                        num763 += 4;
                        if (Main.wofB == -1)
                        {
                            Main.wofB = num763 * 16;
                        }
                        else if (Main.wofB > num763 * 16)
                        {
                            Main.wofB--;
                            if (Main.wofB < num763 * 16)
                            {
                                Main.wofB = num763 * 16;
                            }
                        }
                        else if (Main.wofB < num763 * 16)
                        {
                            Main.wofB++;
                            if (Main.wofB > num763 * 16)
                            {
                                Main.wofB = num763 * 16;
                            }
                        }
                        num762 = 0;
                        num763 = num761 - 7;
                        while (num762 < 15 && num763 < Main.maxTilesY - 10)
                        {
                            num763--;
                            for (int num765 = num759; num765 <= num760; num765++)
                            {
                                try
                                {
                                    if (WorldGen.SolidTile(num765, num763) || Main.tile[num765, num763].liquid > 0)
                                    {
                                        num762++;
                                    }
                                }
                                catch
                                {
                                    num762 += 15;
                                }
                            }
                        }
                        num763 -= 4;
                        if (Main.wofT == -1)
                        {
                            Main.wofT = num763 * 16;
                        }
                        else if (Main.wofT > num763 * 16)
                        {
                            Main.wofT--;
                            if (Main.wofT < num763 * 16)
                            {
                                Main.wofT = num763 * 16;
                            }
                        }
                        else if (Main.wofT < num763 * 16)
                        {
                            Main.wofT++;
                            if (Main.wofT > num763 * 16)
                            {
                                Main.wofT = num763 * 16;
                            }
                        }
                        float num766 = (float)((Main.wofB + Main.wofT) / 2 - this.height / 2);
                        if (this.position.Y > num766 + 1f)
                        {
                            this.velocity.Y = -1f;
                        }
                        else if (this.position.Y < num766 - 1f)
                        {
                            this.velocity.Y = 1f;
                        }
                        this.velocity.Y = 0f;
                        this.position.Y = num766;
                        float num767 = 1.5f;
                        if ((double)this.life < (double)this.lifeMax * 0.75)
                        {
                            num767 += 0.25f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.5)
                        {
                            num767 += 0.4f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.25)
                        {
                            num767 += 0.5f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.1)
                        {
                            num767 += 0.6f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.66 && Main.expertMode)
                        {
                            num767 += 0.3f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.33 && Main.expertMode)
                        {
                            num767 += 0.3f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.05 && Main.expertMode)
                        {
                            num767 += 0.6f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.035 && Main.expertMode)
                        {
                            num767 += 0.6f;
                        }
                        if ((double)this.life < (double)this.lifeMax * 0.025 && Main.expertMode)
                        {
                            num767 += 0.6f;
                        }
                        if (Main.expertMode)
                        {
                            num767 *= 1.35f;
                            num767 += 0.35f;
                        }
                        if (this.velocity.X == 0f)
                        {
                            this.TargetClosest(true);
                            this.velocity.X = (float)this.direction;
                        }
                        if (this.velocity.X < 0f)
                        {
                            this.velocity.X = -num767;
                            this.direction = -1;
                        }
                        else
                        {
                            this.velocity.X = num767;
                            this.direction = 1;
                        }
                        this.spriteDirection = this.direction;
                        Vector2 vector77 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num768 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector77.X;
                        float num769 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector77.Y;
                        float num770 = (float)Math.Sqrt((double)(num768 * num768 + num769 * num769));
                        num768 *= num770;
                        num769 *= num770;
                        if (this.direction > 0)
                        {
                            if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) > this.position.X + (float)(this.width / 2))
                            {
                                this.rotation = (float)Math.Atan2((double)(-(double)num769), (double)(-(double)num768)) + 3.14f;
                            }
                            else
                            {
                                this.rotation = 0f;
                            }
                        }
                        else if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) < this.position.X + (float)(this.width / 2))
                        {
                            this.rotation = (float)Math.Atan2((double)num769, (double)num768) + 3.14f;
                        }
                        else
                        {
                            this.rotation = 0f;
                        }
                        if (Main.expertMode && Main.netMode != 1)
                        {
                            int num771 = (int)(1f + (float)this.life / (float)this.lifeMax * 10f);
                            num771 *= num771;
                            if (num771 < 400)
                            {
                                num771 = (num771 * 19 + 400) / 20;
                            }
                            if (num771 < 60)
                            {
                                num771 = (num771 * 3 + 60) / 4;
                            }
                            if (num771 < 20)
                            {
                                num771 = (num771 + 20) / 2;
                            }
                            num771 = (int)((double)num771 * 0.7);
                            if (Main.rand.Next(num771) == 0)
                            {
                                int num772 = 0;
                                float[] array2 = new float[10];
                                for (int num773 = 0; num773 < 200; num773++)
                                {
                                    if (num772 < 10 && Main.npc[num773].active && Main.npc[num773].type == NPCID.TheHungry)
                                    {
                                        array2[num772] = Main.npc[num773].ai[0];
                                        num772++;
                                    }
                                }
                                int maxValue7 = 1 + num772 * 2;
                                if (num772 < 10 && Main.rand.Next(maxValue7) <= 1)
                                {
                                    int num774 = -1;
                                    for (int num775 = 0; num775 < 1000; num775++)
                                    {
                                        int num776 = Main.rand.Next(10);
                                        float num777 = (float)num776 * 0.1f - 0.05f;
                                        bool flag91 = true;
                                        for (int num778 = 0; num778 < num772; num778++)
                                        {
                                            if (num777 == array2[num778])
                                            {
                                                flag91 = false;
                                                break;
                                            }
                                        }
                                        if (flag91)
                                        {
                                            num774 = num776;
                                            break;
                                        }
                                    }
                                    if (num774 >= 0)
                                    {
                                        int num779 = NPC.NewNPC((int)this.position.X, (int)num766, 115, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                        Main.npc[num779].ai[0] = (float)num774 * 0.1f - 0.05f;
                                    }
                                }
                            }
                        }
                        if (this.localAI[0] == 1f && Main.netMode != 1)
                        {
                            this.localAI[0] = 2f;
                            num766 = (float)((Main.wofB + Main.wofT) / 2);
                            num766 = (num766 + (float)Main.wofT) / 2f;
                            int num780 = NPC.NewNPC((int)this.position.X, (int)num766, 114, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num780].ai[0] = 1f;
                            num766 = (float)((Main.wofB + Main.wofT) / 2);
                            num766 = (num766 + (float)Main.wofB) / 2f;
                            num780 = NPC.NewNPC((int)this.position.X, (int)num766, 114, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num780].ai[0] = -1f;
                            num766 = (float)((Main.wofB + Main.wofT) / 2);
                            num766 = (num766 + (float)Main.wofB) / 2f;
                            for (int num781 = 0; num781 < 11; num781++)
                            {
                                num780 = NPC.NewNPC((int)this.position.X, (int)num766, 115, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                Main.npc[num780].ai[0] = (float)num781 * 0.1f - 0.05f;
                            }
                            return;
                        }
                    }
                    else if (this.aiStyle == 28)
                    {
                        if (Main.wof < 0)
                        {
                            this.active = false;
                            return;
                        }
                        this.realLife = Main.wof;
                        if (Main.npc[Main.wof].life > 0)
                        {
                            this.life = Main.npc[Main.wof].life;
                        }
                        this.TargetClosest(true);
                        this.position.X = Main.npc[Main.wof].position.X;
                        this.direction = Main.npc[Main.wof].direction;
                        this.spriteDirection = this.direction;
                        float num782 = (float)((Main.wofB + Main.wofT) / 2);
                        if (this.ai[0] > 0f)
                        {
                            num782 = (num782 + (float)Main.wofT) / 2f;
                        }
                        else
                        {
                            num782 = (num782 + (float)Main.wofB) / 2f;
                        }
                        num782 -= (float)(this.height / 2);
                        if (this.position.Y > num782 + 1f)
                        {
                            this.velocity.Y = -1f;
                        }
                        else if (this.position.Y < num782 - 1f)
                        {
                            this.velocity.Y = 1f;
                        }
                        else
                        {
                            this.velocity.Y = 0f;
                            this.position.Y = num782;
                        }
                        if (this.velocity.Y > 5f)
                        {
                            this.velocity.Y = 5f;
                        }
                        if (this.velocity.Y < -5f)
                        {
                            this.velocity.Y = -5f;
                        }
                        Vector2 vector78 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num783 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector78.X;
                        float num784 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector78.Y;
                        float num785 = (float)Math.Sqrt((double)(num783 * num783 + num784 * num784));
                        num783 *= num785;
                        num784 *= num785;
                        bool flag92 = true;
                        if (this.direction > 0)
                        {
                            if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) > this.position.X + (float)(this.width / 2))
                            {
                                this.rotation = (float)Math.Atan2((double)(-(double)num784), (double)(-(double)num783)) + 3.14f;
                            }
                            else
                            {
                                this.rotation = 0f;
                                flag92 = false;
                            }
                        }
                        else if (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) < this.position.X + (float)(this.width / 2))
                        {
                            this.rotation = (float)Math.Atan2((double)num784, (double)num783) + 3.14f;
                        }
                        else
                        {
                            this.rotation = 0f;
                            flag92 = false;
                        }
                        if (Main.netMode != 1)
                        {
                            int num786 = 4;
                            this.localAI[1] += 1f;
                            if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.75)
                            {
                                this.localAI[1] += 1f;
                                num786++;
                            }
                            if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.5)
                            {
                                this.localAI[1] += 1f;
                                num786++;
                            }
                            if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.25)
                            {
                                this.localAI[1] += 1f;
                                num786 += 2;
                            }
                            if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.1)
                            {
                                this.localAI[1] += 2f;
                                num786 += 3;
                            }
                            if (Main.expertMode)
                            {
                                this.localAI[1] += 0.5f;
                                num786++;
                                if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.1)
                                {
                                    this.localAI[1] += 2f;
                                    num786 += 3;
                                }
                            }
                            if (this.localAI[2] == 0f)
                            {
                                if (this.localAI[1] > 600f)
                                {
                                    this.localAI[2] = 1f;
                                    this.localAI[1] = 0f;
                                    return;
                                }
                            }
                            else if (this.localAI[1] > 45f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                this.localAI[1] = 0f;
                                this.localAI[2] += 1f;
                                if (this.localAI[2] >= (float)num786)
                                {
                                    this.localAI[2] = 0f;
                                }
                                if (flag92)
                                {
                                    float num787 = 9f;
                                    int num788 = 11;
                                    int num789 = 83;
                                    if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.5)
                                    {
                                        num788++;
                                        num787 += 1f;
                                    }
                                    if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.25)
                                    {
                                        num788++;
                                        num787 += 1f;
                                    }
                                    if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.1)
                                    {
                                        num788 += 2;
                                        num787 += 2f;
                                    }
                                    vector78 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    num783 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector78.X;
                                    num784 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector78.Y;
                                    num785 = (float)Math.Sqrt((double)(num783 * num783 + num784 * num784));
                                    num785 = num787 / num785;
                                    num783 *= num785;
                                    num784 *= num785;
                                    vector78.X += num783;
                                    vector78.Y += num784;
                                    Projectile.NewProjectile(vector78.X, vector78.Y, num783, num784, num789, num788, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 29)
                    {
                        if (this.justHit)
                        {
                            this.ai[1] = 10f;
                        }
                        if (Main.wof < 0)
                        {
                            this.active = false;
                            return;
                        }
                        this.TargetClosest(true);
                        float num790 = 0.1f;
                        float num791 = 300f;
                        if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.25)
                        {
                            this.damage = (int)(75f * Main.damageMultiplier);
                            this.defense = 40;
                            if (!Main.expertMode)
                            {
                                num791 = 900f;
                            }
                            else
                            {
                                num790 += 0.1f;
                            }
                        }
                        else if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.5)
                        {
                            this.damage = (int)(60f * Main.damageMultiplier);
                            this.defense = 30;
                            if (!Main.expertMode)
                            {
                                num791 = 700f;
                            }
                            else
                            {
                                num790 += 0.066f;
                            }
                        }
                        else if ((double)Main.npc[Main.wof].life < (double)Main.npc[Main.wof].lifeMax * 0.75)
                        {
                            this.damage = (int)(45f * Main.damageMultiplier);
                            this.defense = 20;
                            if (!Main.expertMode)
                            {
                                num791 = 500f;
                            }
                            else
                            {
                                num790 += 0.033f;
                            }
                        }
                        if (Main.expertMode)
                        {
                            this.defense = this.defDefense;
                            if (this.whoAmI % 4 == 0)
                            {
                                num791 *= 1.75f;
                            }
                            if (this.whoAmI % 4 == 1)
                            {
                                num791 *= 1.5f;
                            }
                            if (this.whoAmI % 4 == 2)
                            {
                                num791 *= 1.25f;
                            }
                            if (this.whoAmI % 3 == 0)
                            {
                                num791 *= 1.5f;
                            }
                            if (this.whoAmI % 3 == 1)
                            {
                                num791 *= 1.25f;
                            }
                            num791 *= 0.75f;
                        }
                        float num792 = Main.npc[Main.wof].position.X + (float)(Main.npc[Main.wof].width / 2);
                        float num793 = Main.npc[Main.wof].position.Y;
                        float num794 = (float)(Main.wofB - Main.wofT);
                        num793 = (float)Main.wofT + num794 * this.ai[0];
                        this.ai[2] += 1f;
                        if (this.ai[2] > 100f)
                        {
                            num791 = (float)((int)(num791 * 1.3f));
                            if (this.ai[2] > 200f)
                            {
                                this.ai[2] = 0f;
                            }
                        }
                        Vector2 vector79 = new Vector2(num792, num793);
                        float num795 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - (float)(this.width / 2) - vector79.X;
                        float num796 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - (float)(this.height / 2) - vector79.Y;
                        float num797 = (float)Math.Sqrt((double)(num795 * num795 + num796 * num796));
                        if (this.ai[1] == 0f)
                        {
                            if (num797 > num791)
                            {
                                num797 = num791 / num797;
                                num795 *= num797;
                                num796 *= num797;
                            }
                            if (this.position.X < num792 + num795)
                            {
                                this.velocity.X = this.velocity.X + num790;
                                if (this.velocity.X < 0f && num795 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + num790 * 2.5f;
                                }
                            }
                            else if (this.position.X > num792 + num795)
                            {
                                this.velocity.X = this.velocity.X - num790;
                                if (this.velocity.X > 0f && num795 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - num790 * 2.5f;
                                }
                            }
                            if (this.position.Y < num793 + num796)
                            {
                                this.velocity.Y = this.velocity.Y + num790;
                                if (this.velocity.Y < 0f && num796 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + num790 * 2.5f;
                                }
                            }
                            else if (this.position.Y > num793 + num796)
                            {
                                this.velocity.Y = this.velocity.Y - num790;
                                if (this.velocity.Y > 0f && num796 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - num790 * 2.5f;
                                }
                            }
                            float num798 = 4f;
                            if (Main.expertMode && Main.wof >= 0)
                            {
                                float num799 = 1.5f;
                                float num800 = (float)(Main.npc[Main.wof].life / Main.npc[Main.wof].lifeMax);
                                if ((double)num800 < 0.75)
                                {
                                    num799 += 0.7f;
                                }
                                if ((double)num800 < 0.5)
                                {
                                    num799 += 0.7f;
                                }
                                if ((double)num800 < 0.25)
                                {
                                    num799 += 0.9f;
                                }
                                if ((double)num800 < 0.1)
                                {
                                    num799 += 0.9f;
                                }
                                num799 *= 1.25f;
                                num799 += 0.3f;
                                num798 += num799 * 0.35f;
                                if (base.Center.X < Main.npc[Main.wof].Center.X && Main.npc[Main.wof].velocity.X > 0f)
                                {
                                    num798 += 6f;
                                }
                                if (base.Center.X > Main.npc[Main.wof].Center.X && Main.npc[Main.wof].velocity.X < 0f)
                                {
                                    num798 += 6f;
                                }
                            }
                            if (this.velocity.X > num798)
                            {
                                this.velocity.X = num798;
                            }
                            if (this.velocity.X < -num798)
                            {
                                this.velocity.X = -num798;
                            }
                            if (this.velocity.Y > num798)
                            {
                                this.velocity.Y = num798;
                            }
                            if (this.velocity.Y < -num798)
                            {
                                this.velocity.Y = -num798;
                            }
                        }
                        else if (this.ai[1] > 0f)
                        {
                            this.ai[1] -= 1f;
                        }
                        else
                        {
                            this.ai[1] = 0f;
                        }
                        if (num795 > 0f)
                        {
                            this.spriteDirection = 1;
                            this.rotation = (float)Math.Atan2((double)num796, (double)num795);
                        }
                        if (num795 < 0f)
                        {
                            this.spriteDirection = -1;
                            this.rotation = (float)Math.Atan2((double)num796, (double)num795) + 3.14f;
                        }
                        return;
                    }
                    else if (this.aiStyle == 30)
                    {
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                        {
                            this.TargetClosest(true);
                        }
                        bool dead2 = Main.player[this.target].dead;
                        float num801 = this.position.X + (float)(this.width / 2) - Main.player[this.target].position.X - (float)(Main.player[this.target].width / 2);
                        float num802 = this.position.Y + (float)this.height - 59f - Main.player[this.target].position.Y - (float)(Main.player[this.target].height / 2);
                        float num803 = (float)Math.Atan2((double)num802, (double)num801) + 1.57f;
                        if (num803 < 0f)
                        {
                            num803 += 6.283f;
                        }
                        else if ((double)num803 > 6.283)
                        {
                            num803 -= 6.283f;
                        }
                        float num804 = 0.1f;
                        if (this.rotation < num803)
                        {
                            if ((double)(num803 - this.rotation) > 3.1415)
                            {
                                this.rotation -= num804;
                            }
                            else
                            {
                                this.rotation += num804;
                            }
                        }
                        else if (this.rotation > num803)
                        {
                            if ((double)(this.rotation - num803) > 3.1415)
                            {
                                this.rotation += num804;
                            }
                            else
                            {
                                this.rotation -= num804;
                            }
                        }
                        if (this.rotation > num803 - num804 && this.rotation < num803 + num804)
                        {
                            this.rotation = num803;
                        }
                        if (this.rotation < 0f)
                        {
                            this.rotation += 6.283f;
                        }
                        else if ((double)this.rotation > 6.283)
                        {
                            this.rotation -= 6.283f;
                        }
                        if (this.rotation > num803 - num804 && this.rotation < num803 + num804)
                        {
                            this.rotation = num803;
                        }
                        if (Main.netMode != 1 && !Main.dayTime && !dead2 && this.timeLeft < 10)
                        {
                            for (int num806 = 0; num806 < 200; num806++)
                            {
                                if (num806 != this.whoAmI && Main.npc[num806].active && (Main.npc[num806].type == NPCID.Retinazer || Main.npc[num806].type == NPCID.Spazmatism) && Main.npc[num806].timeLeft - 1 > this.timeLeft)
                                {
                                    this.timeLeft = Main.npc[num806].timeLeft - 1;
                                }
                            }
                        }
                        if (Main.dayTime || dead2)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if (this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                                return;
                            }
                        }
                        else if (this.ai[0] == 0f)
                        {
                            if (this.ai[1] == 0f)
                            {
                                float num807 = 7f;
                                float num808 = 0.1f;
                                if (Main.expertMode)
                                {
                                    num807 = 8.25f;
                                    num808 = 0.115f;
                                }
                                int num809 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num809 = -1;
                                }
                                Vector2 vector80 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num810 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num809 * 300) - vector80.X;
                                float num811 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 300f - vector80.Y;
                                float num812 = (float)Math.Sqrt((double)(num810 * num810 + num811 * num811));
                                float num813 = num812;
                                num812 = num807 / num812;
                                num810 *= num812;
                                num811 *= num812;
                                if (this.velocity.X < num810)
                                {
                                    this.velocity.X = this.velocity.X + num808;
                                    if (this.velocity.X < 0f && num810 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num808;
                                    }
                                }
                                else if (this.velocity.X > num810)
                                {
                                    this.velocity.X = this.velocity.X - num808;
                                    if (this.velocity.X > 0f && num810 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num808;
                                    }
                                }
                                if (this.velocity.Y < num811)
                                {
                                    this.velocity.Y = this.velocity.Y + num808;
                                    if (this.velocity.Y < 0f && num811 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num808;
                                    }
                                }
                                else if (this.velocity.Y > num811)
                                {
                                    this.velocity.Y = this.velocity.Y - num808;
                                    if (this.velocity.Y > 0f && num811 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num808;
                                    }
                                }
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 600f)
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.target = 255;
                                    this.netUpdate = true;
                                }
                                else if (this.position.Y + (float)this.height < Main.player[this.target].position.Y && num813 < 400f)
                                {
                                    if (!Main.player[this.target].dead)
                                    {
                                        this.ai[3] += 1f;
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.9)
                                        {
                                            this.ai[3] += 0.3f;
                                        }
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.8)
                                        {
                                            this.ai[3] += 0.3f;
                                        }
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.7)
                                        {
                                            this.ai[3] += 0.3f;
                                        }
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.6)
                                        {
                                            this.ai[3] += 0.3f;
                                        }
                                    }
                                    if (this.ai[3] >= 60f)
                                    {
                                        this.ai[3] = 0f;
                                        vector80 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        num810 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector80.X;
                                        num811 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector80.Y;
                                        if (Main.netMode != 1)
                                        {
                                            float num814 = 9f;
                                            int num815 = 20;
                                            int num816 = 83;
                                            if (Main.expertMode)
                                            {
                                                num814 = 10.5f;
                                                num815 = 19;
                                            }
                                            num812 = (float)Math.Sqrt((double)(num810 * num810 + num811 * num811));
                                            num812 = num814 / num812;
                                            num810 *= num812;
                                            num811 *= num812;
                                            num810 += (float)Main.rand.Next(-40, 41) * 0.08f;
                                            num811 += (float)Main.rand.Next(-40, 41) * 0.08f;
                                            vector80.X += num810 * 15f;
                                            vector80.Y += num811 * 15f;
                                            Projectile.NewProjectile(vector80.X, vector80.Y, num810, num811, num816, num815, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                    }
                                }
                            }
                            else if (this.ai[1] == 1f)
                            {
                                this.rotation = num803;
                                float num817 = 12f;
                                if (Main.expertMode)
                                {
                                    num817 = 15f;
                                }
                                Vector2 vector81 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num818 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector81.X;
                                float num819 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector81.Y;
                                float num820 = (float)Math.Sqrt((double)(num818 * num818 + num819 * num819));
                                num820 = num817 / num820;
                                this.velocity.X = num818 * num820;
                                this.velocity.Y = num819 * num820;
                                this.ai[1] = 2f;
                            }
                            else if (this.ai[1] == 2f)
                            {
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 25f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                    {
                                        this.velocity.X = 0f;
                                    }
                                    if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                                    {
                                        this.velocity.Y = 0f;
                                    }
                                }
                                else
                                {
                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                }
                                if (this.ai[2] >= 70f)
                                {
                                    this.ai[3] += 1f;
                                    this.ai[2] = 0f;
                                    this.target = 255;
                                    this.rotation = num803;
                                    if (this.ai[3] >= 4f)
                                    {
                                        this.ai[1] = 0f;
                                        this.ai[3] = 0f;
                                    }
                                    else
                                    {
                                        this.ai[1] = 1f;
                                    }
                                }
                            }
                            if ((double)this.life < (double)this.lifeMax * 0.4)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.ai[0] == 1f || this.ai[0] == 2f)
                        {
                            if (this.ai[0] == 1f)
                            {
                                this.ai[2] += 0.005f;
                                if ((double)this.ai[2] > 0.5)
                                {
                                    this.ai[2] = 0.5f;
                                }
                            }
                            else
                            {
                                this.ai[2] -= 0.005f;
                                if (this.ai[2] < 0f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            this.rotation += this.ai[2];
                            this.ai[1] += 1f;
                            if (this.ai[1] == 100f)
                            {
                                this.ai[0] += 1f;
                                this.ai[1] = 0f;
                                if (this.ai[0] == 3f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            this.velocity.X *= 0.98f;
                            this.velocity.Y *= 0.98f;
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                                return;
                            }
                        }
                        else
                        {
                            this.damage = (int)((double)this.defDamage * 1.5);
                            this.defense = this.defDefense + 10;
                            this.soundHit = 4;
                            if (this.ai[1] == 0f)
                            {
                                float num823 = 8f;
                                float num824 = 0.15f;
                                if (Main.expertMode)
                                {
                                    num823 = 9.5f;
                                    num824 = 0.175f;
                                }
                                Vector2 vector82 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num825 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector82.X;
                                float num826 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 300f - vector82.Y;
                                float num827 = (float)Math.Sqrt((double)(num825 * num825 + num826 * num826));
                                num827 = num823 / num827;
                                num825 *= num827;
                                num826 *= num827;
                                if (this.velocity.X < num825)
                                {
                                    this.velocity.X = this.velocity.X + num824;
                                    if (this.velocity.X < 0f && num825 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num824;
                                    }
                                }
                                else if (this.velocity.X > num825)
                                {
                                    this.velocity.X = this.velocity.X - num824;
                                    if (this.velocity.X > 0f && num825 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num824;
                                    }
                                }
                                if (this.velocity.Y < num826)
                                {
                                    this.velocity.Y = this.velocity.Y + num824;
                                    if (this.velocity.Y < 0f && num826 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num824;
                                    }
                                }
                                else if (this.velocity.Y > num826)
                                {
                                    this.velocity.Y = this.velocity.Y - num824;
                                    if (this.velocity.Y > 0f && num826 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num824;
                                    }
                                }
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 300f)
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.TargetClosest(true);
                                    this.netUpdate = true;
                                }
                                vector82 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                num825 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector82.X;
                                num826 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector82.Y;
                                this.rotation = (float)Math.Atan2((double)num826, (double)num825) - 1.57f;
                                if (Main.netMode != 1)
                                {
                                    this.localAI[1] += 1f;
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        this.localAI[1] += 2f;
                                    }
                                    if (this.localAI[1] > 180f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                    {
                                        this.localAI[1] = 0f;
                                        float num828 = 8.5f;
                                        int num829 = 25;
                                        int num830 = 100;
                                        if (Main.expertMode)
                                        {
                                            num828 = 10f;
                                            num829 = 23;
                                        }
                                        num827 = (float)Math.Sqrt((double)(num825 * num825 + num826 * num826));
                                        num827 = num828 / num827;
                                        num825 *= num827;
                                        num826 *= num827;
                                        vector82.X += num825 * 15f;
                                        vector82.Y += num826 * 15f;
                                        Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, num830, num829, 0f, Main.myPlayer, 0f, 0f);
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                int num831 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num831 = -1;
                                }
                                float num832 = 8f;
                                float num833 = 0.2f;
                                if (Main.expertMode)
                                {
                                    num832 = 9.5f;
                                    num833 = 0.25f;
                                }
                                Vector2 vector83 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num834 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num831 * 340) - vector83.X;
                                float num835 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector83.Y;
                                float num836 = (float)Math.Sqrt((double)(num834 * num834 + num835 * num835));
                                num836 = num832 / num836;
                                num834 *= num836;
                                num835 *= num836;
                                if (this.velocity.X < num834)
                                {
                                    this.velocity.X = this.velocity.X + num833;
                                    if (this.velocity.X < 0f && num834 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num833;
                                    }
                                }
                                else if (this.velocity.X > num834)
                                {
                                    this.velocity.X = this.velocity.X - num833;
                                    if (this.velocity.X > 0f && num834 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num833;
                                    }
                                }
                                if (this.velocity.Y < num835)
                                {
                                    this.velocity.Y = this.velocity.Y + num833;
                                    if (this.velocity.Y < 0f && num835 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num833;
                                    }
                                }
                                else if (this.velocity.Y > num835)
                                {
                                    this.velocity.Y = this.velocity.Y - num833;
                                    if (this.velocity.Y > 0f && num835 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num833;
                                    }
                                }
                                vector83 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                num834 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector83.X;
                                num835 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector83.Y;
                                this.rotation = (float)Math.Atan2((double)num835, (double)num834) - 1.57f;
                                if (Main.netMode != 1)
                                {
                                    this.localAI[1] += 1f;
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        this.localAI[1] += 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        this.localAI[1] += 0.75f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        this.localAI[1] += 1.5f;
                                    }
                                    if (Main.expertMode)
                                    {
                                        this.localAI[1] += 1.5f;
                                    }
                                    if (this.localAI[1] > 60f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                    {
                                        this.localAI[1] = 0f;
                                        float num837 = 9f;
                                        int num838 = 18;
                                        int num839 = 100;
                                        if (Main.expertMode)
                                        {
                                            num838 = 17;
                                        }
                                        num836 = (float)Math.Sqrt((double)(num834 * num834 + num835 * num835));
                                        num836 = num837 / num836;
                                        num834 *= num836;
                                        num835 *= num836;
                                        vector83.X += num834 * 15f;
                                        vector83.Y += num835 * 15f;
                                        Projectile.NewProjectile(vector83.X, vector83.Y, num834, num835, num839, num838, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                }
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 180f)
                                {
                                    this.ai[1] = 0f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.TargetClosest(true);
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 31)
                    {
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                        {
                            this.TargetClosest(true);
                        }
                        bool dead3 = Main.player[this.target].dead;
                        float num840 = this.position.X + (float)(this.width / 2) - Main.player[this.target].position.X - (float)(Main.player[this.target].width / 2);
                        float num841 = this.position.Y + (float)this.height - 59f - Main.player[this.target].position.Y - (float)(Main.player[this.target].height / 2);
                        float num842 = (float)Math.Atan2((double)num841, (double)num840) + 1.57f;
                        if (num842 < 0f)
                        {
                            num842 += 6.283f;
                        }
                        else if ((double)num842 > 6.283)
                        {
                            num842 -= 6.283f;
                        }
                        float num843 = 0.15f;
                        if (this.rotation < num842)
                        {
                            if ((double)(num842 - this.rotation) > 3.1415)
                            {
                                this.rotation -= num843;
                            }
                            else
                            {
                                this.rotation += num843;
                            }
                        }
                        else if (this.rotation > num842)
                        {
                            if ((double)(this.rotation - num842) > 3.1415)
                            {
                                this.rotation += num843;
                            }
                            else
                            {
                                this.rotation -= num843;
                            }
                        }
                        if (this.rotation > num842 - num843 && this.rotation < num842 + num843)
                        {
                            this.rotation = num842;
                        }
                        if (this.rotation < 0f)
                        {
                            this.rotation += 6.283f;
                        }
                        else if ((double)this.rotation > 6.283)
                        {
                            this.rotation -= 6.283f;
                        }
                        if (this.rotation > num842 - num843 && this.rotation < num842 + num843)
                        {
                            this.rotation = num842;
                        }
                        if (Main.netMode != 1 && !Main.dayTime && !dead3 && this.timeLeft < 10)
                        {
                            for (int num845 = 0; num845 < 200; num845++)
                            {
                                if (num845 != this.whoAmI && Main.npc[num845].active && (Main.npc[num845].type == NPCID.Retinazer || Main.npc[num845].type == NPCID.Spazmatism) && Main.npc[num845].timeLeft - 1 > this.timeLeft)
                                {
                                    this.timeLeft = Main.npc[num845].timeLeft - 1;
                                }
                            }
                        }
                        if (Main.dayTime || dead3)
                        {
                            this.velocity.Y = this.velocity.Y - 0.04f;
                            if (this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                                return;
                            }
                        }
                        else if (this.ai[0] == 0f)
                        {
                            if (this.ai[1] == 0f)
                            {
                                this.TargetClosest(true);
                                float num846 = 12f;
                                float num847 = 0.4f;
                                int num848 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num848 = -1;
                                }
                                Vector2 vector84 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num849 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num848 * 400) - vector84.X;
                                float num850 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector84.Y;
                                float num851 = (float)Math.Sqrt((double)(num849 * num849 + num850 * num850));
                                num851 = num846 / num851;
                                num849 *= num851;
                                num850 *= num851;
                                if (this.velocity.X < num849)
                                {
                                    this.velocity.X = this.velocity.X + num847;
                                    if (this.velocity.X < 0f && num849 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num847;
                                    }
                                }
                                else if (this.velocity.X > num849)
                                {
                                    this.velocity.X = this.velocity.X - num847;
                                    if (this.velocity.X > 0f && num849 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num847;
                                    }
                                }
                                if (this.velocity.Y < num850)
                                {
                                    this.velocity.Y = this.velocity.Y + num847;
                                    if (this.velocity.Y < 0f && num850 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num847;
                                    }
                                }
                                else if (this.velocity.Y > num850)
                                {
                                    this.velocity.Y = this.velocity.Y - num847;
                                    if (this.velocity.Y > 0f && num850 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num847;
                                    }
                                }
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 600f)
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.target = 255;
                                    this.netUpdate = true;
                                }
                                else
                                {
                                    if (!Main.player[this.target].dead)
                                    {
                                        this.ai[3] += 1f;
                                        if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.8)
                                        {
                                            this.ai[3] += 0.6f;
                                        }
                                    }
                                    if (this.ai[3] >= 60f)
                                    {
                                        this.ai[3] = 0f;
                                        vector84 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        num849 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector84.X;
                                        num850 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector84.Y;
                                        if (Main.netMode != 1)
                                        {
                                            float num852 = 12f;
                                            int num853 = 25;
                                            int num854 = 96;
                                            if (Main.expertMode)
                                            {
                                                num852 = 14f;
                                                num853 = 22;
                                            }
                                            num851 = (float)Math.Sqrt((double)(num849 * num849 + num850 * num850));
                                            num851 = num852 / num851;
                                            num849 *= num851;
                                            num850 *= num851;
                                            num849 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                            num850 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                            vector84.X += num849 * 4f;
                                            vector84.Y += num850 * 4f;
                                            Projectile.NewProjectile(vector84.X, vector84.Y, num849, num850, num854, num853, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                    }
                                }
                            }
                            else if (this.ai[1] == 1f)
                            {
                                this.rotation = num842;
                                float num855 = 13f;
                                if (Main.expertMode)
                                {
                                    if ((double)this.life < (double)this.lifeMax * 0.9)
                                    {
                                        num855 += 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.8)
                                    {
                                        num855 += 0.5f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.7)
                                    {
                                        num855 += 0.55f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.6)
                                    {
                                        num855 += 0.6f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        num855 += 0.65f;
                                    }
                                }
                                Vector2 vector85 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num856 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector85.X;
                                float num857 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector85.Y;
                                float num858 = (float)Math.Sqrt((double)(num856 * num856 + num857 * num857));
                                num858 = num855 / num858;
                                this.velocity.X = num856 * num858;
                                this.velocity.Y = num857 * num858;
                                this.ai[1] = 2f;
                            }
                            else if (this.ai[1] == 2f)
                            {
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 8f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                    {
                                        this.velocity.X = 0f;
                                    }
                                    if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                                    {
                                        this.velocity.Y = 0f;
                                    }
                                }
                                else
                                {
                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                }
                                if (this.ai[2] >= 42f)
                                {
                                    this.ai[3] += 1f;
                                    this.ai[2] = 0f;
                                    this.target = 255;
                                    this.rotation = num842;
                                    if (this.ai[3] >= 10f)
                                    {
                                        this.ai[1] = 0f;
                                        this.ai[3] = 0f;
                                    }
                                    else
                                    {
                                        this.ai[1] = 1f;
                                    }
                                }
                            }
                            if ((double)this.life < (double)this.lifeMax * 0.4)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.ai[0] == 1f || this.ai[0] == 2f)
                        {
                            if (this.ai[0] == 1f)
                            {
                                this.ai[2] += 0.005f;
                                if ((double)this.ai[2] > 0.5)
                                {
                                    this.ai[2] = 0.5f;
                                }
                            }
                            else
                            {
                                this.ai[2] -= 0.005f;
                                if (this.ai[2] < 0f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            this.rotation += this.ai[2];
                            this.ai[1] += 1f;
                            if (this.ai[1] == 100f)
                            {
                                this.ai[0] += 1f;
                                this.ai[1] = 0f;
                                if (this.ai[0] == 3f)
                                {
                                    this.ai[2] = 0f;
                                }
                            }
                            this.velocity.X = this.velocity.X * 0.98f;
                            this.velocity.Y = this.velocity.Y * 0.98f;
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                            {
                                this.velocity.Y = 0f;
                                return;
                            }
                        }
                        else
                        {
                            this.soundHit = 4;
                            this.damage = (int)((double)this.defDamage * 1.5);
                            this.defense = this.defDefense + 18;
                            if (this.ai[1] == 0f)
                            {
                                float num861 = 4f;
                                float num862 = 0.1f;
                                int num863 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    num863 = -1;
                                }
                                Vector2 vector86 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num864 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + (float)(num863 * 180) - vector86.X;
                                float num865 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector86.Y;
                                float num866 = (float)Math.Sqrt((double)(num864 * num864 + num865 * num865));
                                if (Main.expertMode)
                                {
                                    if (num866 > 300f)
                                    {
                                        num861 += 0.5f;
                                    }
                                    if (num866 > 400f)
                                    {
                                        num861 += 0.5f;
                                    }
                                    if (num866 > 500f)
                                    {
                                        num861 += 0.55f;
                                    }
                                    if (num866 > 600f)
                                    {
                                        num861 += 0.55f;
                                    }
                                    if (num866 > 700f)
                                    {
                                        num861 += 0.6f;
                                    }
                                    if (num866 > 800f)
                                    {
                                        num861 += 0.6f;
                                    }
                                }
                                num866 = num861 / num866;
                                num864 *= num866;
                                num865 *= num866;
                                if (this.velocity.X < num864)
                                {
                                    this.velocity.X = this.velocity.X + num862;
                                    if (this.velocity.X < 0f && num864 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num862;
                                    }
                                }
                                else if (this.velocity.X > num864)
                                {
                                    this.velocity.X = this.velocity.X - num862;
                                    if (this.velocity.X > 0f && num864 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num862;
                                    }
                                }
                                if (this.velocity.Y < num865)
                                {
                                    this.velocity.Y = this.velocity.Y + num862;
                                    if (this.velocity.Y < 0f && num865 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num862;
                                    }
                                }
                                else if (this.velocity.Y > num865)
                                {
                                    this.velocity.Y = this.velocity.Y - num862;
                                    if (this.velocity.Y > 0f && num865 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num862;
                                    }
                                }
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 400f)
                                {
                                    this.ai[1] = 1f;
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    this.target = 255;
                                    this.netUpdate = true;
                                }
                                if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                {
                                    this.localAI[2] += 1f;
                                    if (this.localAI[2] > 22f)
                                    {
                                        this.localAI[2] = 0f;
                                    }
                                    if (Main.netMode != 1)
                                    {
                                        this.localAI[1] += 1f;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            this.localAI[1] += 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            this.localAI[1] += 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            this.localAI[1] += 1f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.1)
                                        {
                                            this.localAI[1] += 2f;
                                        }
                                        if (this.localAI[1] > 8f)
                                        {
                                            this.localAI[1] = 0f;
                                            float num867 = 6f;
                                            int num868 = 30;
                                            if (Main.expertMode)
                                            {
                                                num868 = 27;
                                            }
                                            int num869 = 101;
                                            vector86 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            num864 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector86.X;
                                            num865 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector86.Y;
                                            num866 = (float)Math.Sqrt((double)(num864 * num864 + num865 * num865));
                                            num866 = num867 / num866;
                                            num864 *= num866;
                                            num865 *= num866;
                                            num865 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                            num864 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                            num865 += this.velocity.Y * 0.5f;
                                            num864 += this.velocity.X * 0.5f;
                                            vector86.X -= num864 * 1f;
                                            vector86.Y -= num865 * 1f;
                                            Projectile.NewProjectile(vector86.X, vector86.Y, num864, num865, num869, num868, 0f, Main.myPlayer, 0f, 0f);
                                            return;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (this.ai[1] == 1f)
                                {
                                    this.rotation = num842;
                                    float num870 = 14f;
                                    if (Main.expertMode)
                                    {
                                        num870 += 2.5f;
                                    }
                                    Vector2 vector87 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float num871 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector87.X;
                                    float num872 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector87.Y;
                                    float num873 = (float)Math.Sqrt((double)(num871 * num871 + num872 * num872));
                                    num873 = num870 / num873;
                                    this.velocity.X = num871 * num873;
                                    this.velocity.Y = num872 * num873;
                                    this.ai[1] = 2f;
                                    return;
                                }
                                if (this.ai[1] == 2f)
                                {
                                    this.ai[2] += 1f;
                                    if (Main.expertMode)
                                    {
                                        this.ai[2] += 0.5f;
                                    }
                                    if (this.ai[2] >= 50f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.93f;
                                        this.velocity.Y = this.velocity.Y * 0.93f;
                                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                        {
                                            this.velocity.X = 0f;
                                        }
                                        if ((double)this.velocity.Y > -0.1 && (double)this.velocity.Y < 0.1)
                                        {
                                            this.velocity.Y = 0f;
                                        }
                                    }
                                    else
                                    {
                                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) - 1.57f;
                                    }
                                    if (this.ai[2] >= 80f)
                                    {
                                        this.ai[3] += 1f;
                                        this.ai[2] = 0f;
                                        this.target = 255;
                                        this.rotation = num842;
                                        if (this.ai[3] >= 6f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[3] = 0f;
                                            return;
                                        }
                                        this.ai[1] = 1f;
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 32)
                    {
                        this.damage = this.defDamage;
                        this.defense = this.defDefense;
                        if (this.ai[0] == 0f && Main.netMode != 1)
                        {
                            this.TargetClosest(true);
                            this.ai[0] = 1f;
                            int num874 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 128, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num874].ai[0] = -1f;
                            Main.npc[num874].ai[1] = (float)this.whoAmI;
                            Main.npc[num874].target = this.target;
                            Main.npc[num874].netUpdate = true;
                            num874 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 129, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num874].ai[0] = 1f;
                            Main.npc[num874].ai[1] = (float)this.whoAmI;
                            Main.npc[num874].target = this.target;
                            Main.npc[num874].netUpdate = true;
                            num874 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 130, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num874].ai[0] = -1f;
                            Main.npc[num874].ai[1] = (float)this.whoAmI;
                            Main.npc[num874].target = this.target;
                            Main.npc[num874].ai[3] = 150f;
                            Main.npc[num874].netUpdate = true;
                            num874 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 131, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            Main.npc[num874].ai[0] = 1f;
                            Main.npc[num874].ai[1] = (float)this.whoAmI;
                            Main.npc[num874].target = this.target;
                            Main.npc[num874].netUpdate = true;
                            Main.npc[num874].ai[3] = 150f;
                        }
                        if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 6000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 6000f)
                        {
                            this.TargetClosest(true);
                            if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 6000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 6000f)
                            {
                                this.ai[1] = 3f;
                            }
                        }
                        if (Main.dayTime && this.ai[1] != 3f && this.ai[1] != 2f)
                        {
                            this.ai[1] = 2f;
                        }
                        if (this.ai[1] == 0f)
                        {
                            this.ai[2] += 1f;
                            if (this.ai[2] >= 600f)
                            {
                                this.ai[2] = 0f;
                                this.ai[1] = 1f;
                                this.TargetClosest(true);
                                this.netUpdate = true;
                            }
                            this.rotation = this.velocity.X / 15f;
                            if (this.position.Y > Main.player[this.target].position.Y - 200f)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.98f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y > 2f)
                                {
                                    this.velocity.Y = 2f;
                                }
                            }
                            else if (this.position.Y < Main.player[this.target].position.Y - 500f)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.98f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < -2f)
                                {
                                    this.velocity.Y = -2f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) + 100f)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                this.velocity.X = this.velocity.X - 0.1f;
                                if (this.velocity.X > 8f)
                                {
                                    this.velocity.X = 8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - 100f)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                this.velocity.X = this.velocity.X + 0.1f;
                                if (this.velocity.X < -8f)
                                {
                                    this.velocity.X = -8f;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (this.ai[1] == 1f)
                            {
                                this.defense *= 2;
                                this.damage *= 2;
                                this.ai[2] += 1f;
                                if (this.ai[2] >= 400f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                }
                                this.rotation += (float)this.direction * 0.3f;
                                Vector2 vector88 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num875 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector88.X;
                                float num876 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector88.Y;
                                float num877 = (float)Math.Sqrt((double)(num875 * num875 + num876 * num876));
                                num877 = 2f / num877;
                                this.velocity.X = num875 * num877;
                                this.velocity.Y = num876 * num877;
                                return;
                            }
                            if (this.ai[1] == 2f)
                            {
                                this.damage = 1000;
                                this.defense = 9999;
                                this.rotation += (float)this.direction * 0.3f;
                                Vector2 vector89 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num878 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector89.X;
                                float num879 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector89.Y;
                                float num880 = (float)Math.Sqrt((double)(num878 * num878 + num879 * num879));
                                float num881 = 10f;
                                num881 += num880 / 100f;
                                if (num881 < 8f)
                                {
                                    num881 = 8f;
                                }
                                if (num881 > 32f)
                                {
                                    num881 = 32f;
                                }
                                num880 = num881 / num880;
                                this.velocity.X = num878 * num880;
                                this.velocity.Y = num879 * num880;
                                return;
                            }
                            if (this.ai[1] == 3f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.95f;
                                }
                                this.velocity.X = this.velocity.X * 0.95f;
                                if (this.timeLeft > 500)
                                {
                                    this.timeLeft = 500;
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 33)
                    {
                        Vector2 vector90 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num882 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector90.X;
                        float num883 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector90.Y;
                        float num884 = (float)Math.Sqrt((double)(num882 * num882 + num883 * num883));
                        if (this.ai[2] != 99f)
                        {
                            if (num884 > 800f)
                            {
                                this.ai[2] = 99f;
                            }
                        }
                        else if (num884 < 400f)
                        {
                            this.ai[2] = 0f;
                        }
                        this.spriteDirection = -(int)this.ai[0];
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] += 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10.0);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] == 99f)
                        {
                            if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y > 8f)
                                {
                                    this.velocity.Y = 8f;
                                }
                            }
                            else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < -8f)
                                {
                                    this.velocity.Y = -8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X - 0.5f;
                                if (this.velocity.X > 12f)
                                {
                                    this.velocity.X = 12f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X + 0.5f;
                                if (this.velocity.X < -12f)
                                {
                                    this.velocity.X = -12f;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (this.ai[2] == 0f || this.ai[2] == 3f)
                            {
                                if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                                {
                                    this.timeLeft = 10;
                                }
                                if (Main.npc[(int)this.ai[1]].ai[1] != 0f)
                                {
                                    this.TargetClosest(true);
                                    if (Main.player[this.target].dead)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                        if (this.velocity.Y > 16f)
                                        {
                                            this.velocity.Y = 16f;
                                        }
                                    }
                                    else
                                    {
                                        Vector2 vector91 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num885 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector91.X;
                                        float num886 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector91.Y;
                                        float num887 = (float)Math.Sqrt((double)(num885 * num885 + num886 * num886));
                                        num887 = 7f / num887;
                                        num885 *= num887;
                                        num886 *= num887;
                                        this.rotation = (float)Math.Atan2((double)num886, (double)num885) - 1.57f;
                                        if (this.velocity.X > num885)
                                        {
                                            if (this.velocity.X > 0f)
                                            {
                                                this.velocity.X = this.velocity.X * 0.97f;
                                            }
                                            this.velocity.X = this.velocity.X - 0.05f;
                                        }
                                        if (this.velocity.X < num885)
                                        {
                                            if (this.velocity.X < 0f)
                                            {
                                                this.velocity.X = this.velocity.X * 0.97f;
                                            }
                                            this.velocity.X = this.velocity.X + 0.05f;
                                        }
                                        if (this.velocity.Y > num886)
                                        {
                                            if (this.velocity.Y > 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y * 0.97f;
                                            }
                                            this.velocity.Y = this.velocity.Y - 0.05f;
                                        }
                                        if (this.velocity.Y < num886)
                                        {
                                            if (this.velocity.Y < 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y * 0.97f;
                                            }
                                            this.velocity.Y = this.velocity.Y + 0.05f;
                                        }
                                    }
                                    this.ai[3] += 1f;
                                    if (this.ai[3] >= 600f)
                                    {
                                        this.ai[2] = 0f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                }
                                else
                                {
                                    this.ai[3] += 1f;
                                    if (this.ai[3] >= 300f)
                                    {
                                        this.ai[2] += 1f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                    if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 320f)
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y - 0.04f;
                                        if (this.velocity.Y > 3f)
                                        {
                                            this.velocity.Y = 3f;
                                        }
                                    }
                                    else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 260f)
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y + 0.04f;
                                        if (this.velocity.Y < -3f)
                                        {
                                            this.velocity.Y = -3f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.96f;
                                        }
                                        this.velocity.X = this.velocity.X - 0.3f;
                                        if (this.velocity.X > 12f)
                                        {
                                            this.velocity.X = 12f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 250f)
                                    {
                                        if (this.velocity.X < 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.96f;
                                        }
                                        this.velocity.X = this.velocity.X + 0.3f;
                                        if (this.velocity.X < -12f)
                                        {
                                            this.velocity.X = -12f;
                                        }
                                    }
                                }
                                Vector2 vector92 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num888 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector92.X;
                                float num889 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector92.Y;
                                Math.Sqrt((double)(num888 * num888 + num889 * num889));
                                this.rotation = (float)Math.Atan2((double)num889, (double)num888) + 1.57f;
                                return;
                            }
                            if (this.ai[2] == 1f)
                            {
                                Vector2 vector93 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num890 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector93.X;
                                float num891 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector93.Y;
                                float num892 = (float)Math.Sqrt((double)(num890 * num890 + num891 * num891));
                                this.rotation = (float)Math.Atan2((double)num891, (double)num890) + 1.57f;
                                this.velocity.X = this.velocity.X * 0.95f;
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y < -8f)
                                {
                                    this.velocity.Y = -8f;
                                }
                                if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 200f)
                                {
                                    this.TargetClosest(true);
                                    this.ai[2] = 2f;
                                    vector93 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    num890 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector93.X;
                                    num891 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector93.Y;
                                    num892 = (float)Math.Sqrt((double)(num890 * num890 + num891 * num891));
                                    num892 = 22f / num892;
                                    this.velocity.X = num890 * num892;
                                    this.velocity.Y = num891 * num892;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else if (this.ai[2] == 2f)
                            {
                                if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f)
                                {
                                    this.ai[2] = 3f;
                                    return;
                                }
                            }
                            else
                            {
                                if (this.ai[2] == 4f)
                                {
                                    this.TargetClosest(true);
                                    Vector2 vector94 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float num893 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector94.X;
                                    float num894 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector94.Y;
                                    float num895 = (float)Math.Sqrt((double)(num893 * num893 + num894 * num894));
                                    num895 = 7f / num895;
                                    num893 *= num895;
                                    num894 *= num895;
                                    if (this.velocity.X > num893)
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.97f;
                                        }
                                        this.velocity.X = this.velocity.X - 0.05f;
                                    }
                                    if (this.velocity.X < num893)
                                    {
                                        if (this.velocity.X < 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.97f;
                                        }
                                        this.velocity.X = this.velocity.X + 0.05f;
                                    }
                                    if (this.velocity.Y > num894)
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.97f;
                                        }
                                        this.velocity.Y = this.velocity.Y - 0.05f;
                                    }
                                    if (this.velocity.Y < num894)
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.97f;
                                        }
                                        this.velocity.Y = this.velocity.Y + 0.05f;
                                    }
                                    this.ai[3] += 1f;
                                    if (this.ai[3] >= 600f)
                                    {
                                        this.ai[2] = 0f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                    vector94 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    num893 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector94.X;
                                    num894 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector94.Y;
                                    num895 = (float)Math.Sqrt((double)(num893 * num893 + num894 * num894));
                                    this.rotation = (float)Math.Atan2((double)num894, (double)num893) + 1.57f;
                                    return;
                                }
                                if (this.ai[2] == 5f && ((this.velocity.X > 0f && this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)) || (this.velocity.X < 0f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))))
                                {
                                    this.ai[2] = 0f;
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 34)
                    {
                        this.spriteDirection = -(int)this.ai[0];
                        Vector2 vector95 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num896 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector95.X;
                        float num897 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector95.Y;
                        float num898 = (float)Math.Sqrt((double)(num896 * num896 + num897 * num897));
                        if (this.ai[2] != 99f)
                        {
                            if (num898 > 800f)
                            {
                                this.ai[2] = 99f;
                            }
                        }
                        else if (num898 < 400f)
                        {
                            this.ai[2] = 0f;
                        }
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] += 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10.0);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] == 99f)
                        {
                            if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.1f;
                                if (this.velocity.Y > 8f)
                                {
                                    this.velocity.Y = 8f;
                                }
                            }
                            else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.96f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.1f;
                                if (this.velocity.Y < -8f)
                                {
                                    this.velocity.Y = -8f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X - 0.5f;
                                if (this.velocity.X > 12f)
                                {
                                    this.velocity.X = 12f;
                                }
                            }
                            if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.96f;
                                }
                                this.velocity.X = this.velocity.X + 0.5f;
                                if (this.velocity.X < -12f)
                                {
                                    this.velocity.X = -12f;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (this.ai[2] == 0f || this.ai[2] == 3f)
                            {
                                if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                                {
                                    this.timeLeft = 10;
                                }
                                if (Main.npc[(int)this.ai[1]].ai[1] != 0f)
                                {
                                    this.TargetClosest(true);
                                    this.TargetClosest(true);
                                    if (Main.player[this.target].dead)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                        if (this.velocity.Y > 16f)
                                        {
                                            this.velocity.Y = 16f;
                                        }
                                    }
                                    else
                                    {
                                        Vector2 vector96 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num899 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector96.X;
                                        float num900 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector96.Y;
                                        float num901 = (float)Math.Sqrt((double)(num899 * num899 + num900 * num900));
                                        num901 = 12f / num901;
                                        num899 *= num901;
                                        num900 *= num901;
                                        this.rotation = (float)Math.Atan2((double)num900, (double)num899) - 1.57f;
                                        if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < 2f)
                                        {
                                            this.rotation = (float)Math.Atan2((double)num900, (double)num899) - 1.57f;
                                            this.velocity.X = num899;
                                            this.velocity.Y = num900;
                                            this.netUpdate = true;
                                        }
                                        else
                                        {
                                            this.velocity *= 0.97f;
                                        }
                                        this.ai[3] += 1f;
                                        if (this.ai[3] >= 600f)
                                        {
                                            this.ai[2] = 0f;
                                            this.ai[3] = 0f;
                                            this.netUpdate = true;
                                        }
                                    }
                                }
                                else
                                {
                                    this.ai[3] += 1f;
                                    if (this.ai[3] >= 600f)
                                    {
                                        this.ai[2] += 1f;
                                        this.ai[3] = 0f;
                                        this.netUpdate = true;
                                    }
                                    if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y + 300f)
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y - 0.1f;
                                        if (this.velocity.Y > 3f)
                                        {
                                            this.velocity.Y = 3f;
                                        }
                                    }
                                    else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y + 230f)
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.96f;
                                        }
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                        if (this.velocity.Y < -3f)
                                        {
                                            this.velocity.Y = -3f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 250f)
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.94f;
                                        }
                                        this.velocity.X = this.velocity.X - 0.3f;
                                        if (this.velocity.X > 9f)
                                        {
                                            this.velocity.X = 9f;
                                        }
                                    }
                                    if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2))
                                    {
                                        if (this.velocity.X < 0f)
                                        {
                                            this.velocity.X = this.velocity.X * 0.94f;
                                        }
                                        this.velocity.X = this.velocity.X + 0.2f;
                                        if (this.velocity.X < -8f)
                                        {
                                            this.velocity.X = -8f;
                                        }
                                    }
                                }
                                Vector2 vector97 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num902 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector97.X;
                                float num903 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector97.Y;
                                Math.Sqrt((double)(num902 * num902 + num903 * num903));
                                this.rotation = (float)Math.Atan2((double)num903, (double)num902) + 1.57f;
                                return;
                            }
                            if (this.ai[2] == 1f)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                Vector2 vector98 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num904 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 280f * this.ai[0] - vector98.X;
                                float num905 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector98.Y;
                                float num906 = (float)Math.Sqrt((double)(num904 * num904 + num905 * num905));
                                this.rotation = (float)Math.Atan2((double)num905, (double)num904) + 1.57f;
                                this.velocity.X = (this.velocity.X * 5f + Main.npc[(int)this.ai[1]].velocity.X) / 6f;
                                this.velocity.X = this.velocity.X + 0.5f;
                                this.velocity.Y = this.velocity.Y - 0.5f;
                                if (this.velocity.Y < -9f)
                                {
                                    this.velocity.Y = -9f;
                                }
                                if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 280f)
                                {
                                    this.TargetClosest(true);
                                    this.ai[2] = 2f;
                                    vector98 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    num904 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector98.X;
                                    num905 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector98.Y;
                                    num906 = (float)Math.Sqrt((double)(num904 * num904 + num905 * num905));
                                    num906 = 20f / num906;
                                    this.velocity.X = num904 * num906;
                                    this.velocity.Y = num905 * num906;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else if (this.ai[2] == 2f)
                            {
                                if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f)
                                {
                                    if (this.ai[3] >= 4f)
                                    {
                                        this.ai[2] = 3f;
                                        this.ai[3] = 0f;
                                        return;
                                    }
                                    this.ai[2] = 1f;
                                    this.ai[3] += 1f;
                                    return;
                                }
                            }
                            else if (this.ai[2] == 4f)
                            {
                                Vector2 vector99 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num907 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector99.X;
                                float num908 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector99.Y;
                                float num909 = (float)Math.Sqrt((double)(num907 * num907 + num908 * num908));
                                this.rotation = (float)Math.Atan2((double)num908, (double)num907) + 1.57f;
                                this.velocity.Y = (this.velocity.Y * 5f + Main.npc[(int)this.ai[1]].velocity.Y) / 6f;
                                this.velocity.X = this.velocity.X + 0.5f;
                                if (this.velocity.X > 12f)
                                {
                                    this.velocity.X = 12f;
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 500f || this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 500f)
                                {
                                    this.TargetClosest(true);
                                    this.ai[2] = 5f;
                                    vector99 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    num907 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector99.X;
                                    num908 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector99.Y;
                                    num909 = (float)Math.Sqrt((double)(num907 * num907 + num908 * num908));
                                    num909 = 17f / num909;
                                    this.velocity.X = num907 * num909;
                                    this.velocity.Y = num908 * num909;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else if (this.ai[2] == 5f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - 100f)
                            {
                                if (this.ai[3] >= 4f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[3] = 0f;
                                    return;
                                }
                                this.ai[2] = 4f;
                                this.ai[3] += 1f;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 35)
                    {
                        this.spriteDirection = -(int)this.ai[0];
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] += 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10.0);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] == 0f)
                        {
                            if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                            }
                            if (Main.npc[(int)this.ai[1]].ai[1] != 0f)
                            {
                                this.localAI[0] += 2f;
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.07f;
                                    if (this.velocity.Y > 6f)
                                    {
                                        this.velocity.Y = 6f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.07f;
                                    if (this.velocity.Y < -6f)
                                    {
                                        this.velocity.Y = -6f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.1f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.1f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            else
                            {
                                this.ai[3] += 1f;
                                if (this.ai[3] >= 1100f)
                                {
                                    this.localAI[0] = 0f;
                                    this.ai[2] = 1f;
                                    this.ai[3] = 0f;
                                    this.netUpdate = true;
                                }
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 150f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.04f;
                                    if (this.velocity.Y > 3f)
                                    {
                                        this.velocity.Y = 3f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 150f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.04f;
                                    if (this.velocity.Y < -3f)
                                    {
                                        this.velocity.Y = -3f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 200f)
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.2f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 160f)
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.2f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            Vector2 vector100 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num910 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector100.X;
                            float num911 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector100.Y;
                            float num912 = (float)Math.Sqrt((double)(num910 * num910 + num911 * num911));
                            this.rotation = (float)Math.Atan2((double)num911, (double)num910) + 1.57f;
                            if (Main.netMode != 1)
                            {
                                this.localAI[0] += 1f;
                                if (this.localAI[0] > 140f)
                                {
                                    this.localAI[0] = 0f;
                                    float num913 = 12f;
                                    int num914 = 0;
                                    int num915 = 102;
                                    num912 = num913 / num912;
                                    num910 = -num910 * num912;
                                    num911 = -num911 * num912;
                                    num910 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                    num911 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                    vector100.X += num910 * 4f;
                                    vector100.Y += num911 * 4f;
                                    Projectile.NewProjectile(vector100.X, vector100.Y, num910, num911, num915, num914, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                        else if (this.ai[2] == 1f)
                        {
                            this.ai[3] += 1f;
                            if (this.ai[3] >= 300f)
                            {
                                this.localAI[0] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                            }
                            Vector2 vector101 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num916 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - vector101.X;
                            float num917 = Main.npc[(int)this.ai[1]].position.Y - vector101.Y;
                            num917 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 80f - vector101.Y;
                            float num918 = (float)Math.Sqrt((double)(num916 * num916 + num917 * num917));
                            num918 = 6f / num918;
                            num916 *= num918;
                            num917 *= num918;
                            if (this.velocity.X > num916)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X - 0.04f;
                            }
                            if (this.velocity.X < num916)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X + 0.04f;
                            }
                            if (this.velocity.Y > num917)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.08f;
                            }
                            if (this.velocity.Y < num917)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.08f;
                            }
                            this.TargetClosest(true);
                            vector101 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            num916 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector101.X;
                            num917 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector101.Y;
                            num918 = (float)Math.Sqrt((double)(num916 * num916 + num917 * num917));
                            this.rotation = (float)Math.Atan2((double)num917, (double)num916) - 1.57f;
                            if (Main.netMode != 1)
                            {
                                this.localAI[0] += 1f;
                                if (this.localAI[0] > 40f)
                                {
                                    this.localAI[0] = 0f;
                                    float num919 = 10f;
                                    int num920 = 0;
                                    int num921 = 102;
                                    num918 = num919 / num918;
                                    num916 *= num918;
                                    num917 *= num918;
                                    num916 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                    num917 += (float)Main.rand.Next(-40, 41) * 0.01f;
                                    vector101.X += num916 * 4f;
                                    vector101.Y += num917 * 4f;
                                    Projectile.NewProjectile(vector101.X, vector101.Y, num916, num917, num921, num920, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 36)
                    {
                        this.spriteDirection = -(int)this.ai[0];
                        if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 32)
                        {
                            this.ai[2] += 10f;
                            if (this.ai[2] > 50f || Main.netMode != 2)
                            {
                                this.life = -1;
                                this.HitEffect(0, 10.0);
                                this.active = false;
                            }
                        }
                        if (this.ai[2] == 0f || this.ai[2] == 3f)
                        {
                            if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                            }
                            if (Main.npc[(int)this.ai[1]].ai[1] != 0f)
                            {
                                this.localAI[0] += 3f;
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.07f;
                                    if (this.velocity.Y > 6f)
                                    {
                                        this.velocity.Y = 6f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.07f;
                                    if (this.velocity.Y < -6f)
                                    {
                                        this.velocity.Y = -6f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.1f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 120f * this.ai[0])
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.1f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            else
                            {
                                this.ai[3] += 1f;
                                if (this.ai[3] >= 800f)
                                {
                                    this.ai[2] += 1f;
                                    this.ai[3] = 0f;
                                    this.netUpdate = true;
                                }
                                if (this.position.Y > Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y - 0.1f;
                                    if (this.velocity.Y > 3f)
                                    {
                                        this.velocity.Y = 3f;
                                    }
                                }
                                else if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 100f)
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                    }
                                    this.velocity.Y = this.velocity.Y + 0.1f;
                                    if (this.velocity.Y < -3f)
                                    {
                                        this.velocity.Y = -3f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 180f * this.ai[0])
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X - 0.14f;
                                    if (this.velocity.X > 8f)
                                    {
                                        this.velocity.X = 8f;
                                    }
                                }
                                if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 180f * this.ai[0])
                                {
                                    if (this.velocity.X < 0f)
                                    {
                                        this.velocity.X = this.velocity.X * 0.96f;
                                    }
                                    this.velocity.X = this.velocity.X + 0.14f;
                                    if (this.velocity.X < -8f)
                                    {
                                        this.velocity.X = -8f;
                                    }
                                }
                            }
                            this.TargetClosest(true);
                            Vector2 vector102 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num922 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector102.X;
                            float num923 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector102.Y;
                            float num924 = (float)Math.Sqrt((double)(num922 * num922 + num923 * num923));
                            this.rotation = (float)Math.Atan2((double)num923, (double)num922) - 1.57f;
                            if (Main.netMode != 1)
                            {
                                this.localAI[0] += 1f;
                                if (this.localAI[0] > 200f)
                                {
                                    this.localAI[0] = 0f;
                                    float num925 = 8f;
                                    int num926 = 25;
                                    int num927 = 100;
                                    num924 = num925 / num924;
                                    num922 *= num924;
                                    num923 *= num924;
                                    num922 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                    num923 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                    vector102.X += num922 * 8f;
                                    vector102.Y += num923 * 8f;
                                    Projectile.NewProjectile(vector102.X, vector102.Y, num922, num923, num927, num926, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                        else if (this.ai[2] == 1f)
                        {
                            this.ai[3] += 1f;
                            if (this.ai[3] >= 200f)
                            {
                                this.localAI[0] = 0f;
                                this.ai[2] = 0f;
                                this.ai[3] = 0f;
                                this.netUpdate = true;
                            }
                            Vector2 vector103 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num928 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - 350f - vector103.X;
                            float num929 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 20f - vector103.Y;
                            float num930 = (float)Math.Sqrt((double)(num928 * num928 + num929 * num929));
                            num930 = 7f / num930;
                            num928 *= num930;
                            num929 *= num930;
                            if (this.velocity.X > num928)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X - 0.1f;
                            }
                            if (this.velocity.X < num928)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                                this.velocity.X = this.velocity.X + 0.1f;
                            }
                            if (this.velocity.Y > num929)
                            {
                                if (this.velocity.Y > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y - 0.03f;
                            }
                            if (this.velocity.Y < num929)
                            {
                                if (this.velocity.Y < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                                this.velocity.Y = this.velocity.Y + 0.03f;
                            }
                            this.TargetClosest(true);
                            vector103 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            num928 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector103.X;
                            num929 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector103.Y;
                            num930 = (float)Math.Sqrt((double)(num928 * num928 + num929 * num929));
                            this.rotation = (float)Math.Atan2((double)num929, (double)num928) - 1.57f;
                            if (Main.netMode == 1)
                            {
                                this.localAI[0] += 1f;
                                if (this.localAI[0] > 80f)
                                {
                                    this.localAI[0] = 0f;
                                    float num931 = 10f;
                                    int num932 = 25;
                                    int num933 = 100;
                                    num930 = num931 / num930;
                                    num928 *= num930;
                                    num929 *= num930;
                                    num928 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                    num929 += (float)Main.rand.Next(-40, 41) * 0.05f;
                                    vector103.X += num928 * 8f;
                                    vector103.Y += num929 * 8f;
                                    Projectile.NewProjectile(vector103.X, vector103.Y, num928, num929, num933, num932, 0f, Main.myPlayer, 0f, 0f);
                                    return;
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 37)
                    {
                        if (this.ai[3] > 0f)
                        {
                            this.realLife = (int)this.ai[3];
                        }
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                        }
                        if (this.type >= NPCID.TheDestroyer && this.type <= NPCID.TheDestroyerTail)
                        {
                            this.velocity.Length();
                            if (this.type == NPCID.TheDestroyer || (this.type != NPCID.TheDestroyer && Main.npc[(int)this.ai[1]].alpha < 128))
                            {
                                this.alpha -= 42;
                                if (this.alpha < 0)
                                {
                                    this.alpha = 0;
                                }
                            }
                        }
                        if (this.type > 134)
                        {
                            bool flag93 = false;
                            if (this.ai[1] <= 0f)
                            {
                                flag93 = true;
                            }
                            else if (Main.npc[(int)this.ai[1]].life <= 0)
                            {
                                flag93 = true;
                            }
                            if (flag93)
                            {
                                this.life = 0;
                                this.HitEffect(0, 10.0);
                                this.checkDead();
                            }
                        }
                        if (Main.netMode != 1)
                        {
                            if (this.ai[0] == 0f && this.type == NPCID.TheDestroyer)
                            {
                                this.ai[3] = (float)this.whoAmI;
                                this.realLife = this.whoAmI;
                                int num936 = this.whoAmI;
                                int num937 = 80;
                                for (int num938 = 0; num938 <= num937; num938++)
                                {
                                    int num939 = 135;
                                    if (num938 == num937)
                                    {
                                        num939 = 136;
                                    }
                                    int num940 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)(this.position.Y + (float)this.height), num939, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num940].ai[3] = (float)this.whoAmI;
                                    Main.npc[num940].realLife = this.whoAmI;
                                    Main.npc[num940].ai[1] = (float)num936;
                                    Main.npc[num936].ai[0] = (float)num940;
                                    NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num940, 0f, 0f, 0f, 0, 0, 0);
                                    num936 = num940;
                                }
                            }
                            if (this.type == NPCID.TheDestroyerBody)
                            {
                                this.localAI[0] += (float)Main.rand.Next(4);
                                if (this.localAI[0] >= (float)Main.rand.Next(1400, 26000))
                                {
                                    this.localAI[0] = 0f;
                                    this.TargetClosest(true);
                                    if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                    {
                                        float num941 = 8f;
                                        Vector2 vector104 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)(this.height / 2));
                                        float num942 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector104.X + (float)Main.rand.Next(-20, 21);
                                        float num943 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector104.Y + (float)Main.rand.Next(-20, 21);
                                        float num944 = (float)Math.Sqrt((double)(num942 * num942 + num943 * num943));
                                        num944 = num941 / num944;
                                        num942 *= num944;
                                        num943 *= num944;
                                        num942 += (float)Main.rand.Next(-20, 21) * 0.05f;
                                        num943 += (float)Main.rand.Next(-20, 21) * 0.05f;
                                        int num945 = 22;
                                        if (Main.expertMode)
                                        {
                                            num945 = 18;
                                        }
                                        int num946 = 100;
                                        vector104.X += num942 * 5f;
                                        vector104.Y += num943 * 5f;
                                        int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, num946, num945, 0f, Main.myPlayer, 0f, 0f);
                                        Main.projectile[num947].timeLeft = 300;
                                        this.netUpdate = true;
                                    }
                                }
                            }
                        }
                        int num948 = (int)(this.position.X / 16f) - 1;
                        int num949 = (int)((this.position.X + (float)this.width) / 16f) + 2;
                        int num950 = (int)(this.position.Y / 16f) - 1;
                        int num951 = (int)((this.position.Y + (float)this.height) / 16f) + 2;
                        if (num948 < 0)
                        {
                            num948 = 0;
                        }
                        if (num949 > Main.maxTilesX)
                        {
                            num949 = Main.maxTilesX;
                        }
                        if (num950 < 0)
                        {
                            num950 = 0;
                        }
                        if (num951 > Main.maxTilesY)
                        {
                            num951 = Main.maxTilesY;
                        }
                        bool flag94 = false;
                        if (!flag94)
                        {
                            for (int num952 = num948; num952 < num949; num952++)
                            {
                                for (int num953 = num950; num953 < num951; num953++)
                                {
                                    if (Main.tile[num952, num953] != null && ((Main.tile[num952, num953].nactive() && (Main.tileSolid[(int)Main.tile[num952, num953].type] || (Main.tileSolidTop[(int)Main.tile[num952, num953].type] && Main.tile[num952, num953].frameY == 0))) || Main.tile[num952, num953].liquid > 64))
                                    {
                                        Vector2 vector105;
                                        vector105.X = (float)(num952 * 16);
                                        vector105.Y = (float)(num953 * 16);
                                        if (this.position.X + (float)this.width > vector105.X && this.position.X < vector105.X + 16f && this.position.Y + (float)this.height > vector105.Y && this.position.Y < vector105.Y + 16f)
                                        {
                                            flag94 = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if (!flag94)
                        {
                            this.localAI[1] = 1f;
                            if (this.type == NPCID.TheDestroyer)
                            {
                                Rectangle rectangle12 = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                                int num954 = 1000;
                                bool flag95 = true;
                                if (this.position.Y > Main.player[this.target].position.Y)
                                {
                                    for (int num955 = 0; num955 < 255; num955++)
                                    {
                                        if (Main.player[num955].active)
                                        {
                                            Rectangle rectangle13 = new Rectangle((int)Main.player[num955].position.X - num954, (int)Main.player[num955].position.Y - num954, num954 * 2, num954 * 2);
                                            if (rectangle12.Intersects(rectangle13))
                                            {
                                                flag95 = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (flag95)
                                    {
                                        flag94 = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.localAI[1] = 0f;
                        }
                        float num956 = 16f;
                        if (Main.dayTime || Main.player[this.target].dead)
                        {
                            flag94 = false;
                            this.velocity.Y = this.velocity.Y + 1f;
                            if ((double)this.position.Y > Main.worldSurface * 16.0)
                            {
                                this.velocity.Y = this.velocity.Y + 1f;
                                num956 = 32f;
                            }
                            if ((double)this.position.Y > Main.rockLayer * 16.0)
                            {
                                for (int num957 = 0; num957 < 200; num957++)
                                {
                                    if (Main.npc[num957].aiStyle == this.aiStyle)
                                    {
                                        Main.npc[num957].active = false;
                                    }
                                }
                            }
                        }
                        float num958 = 0.1f;
                        float num959 = 0.15f;
                        Vector2 vector106 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num960 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                        float num961 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                        num960 = (float)((int)(num960 / 16f) * 16);
                        num961 = (float)((int)(num961 / 16f) * 16);
                        vector106.X = (float)((int)(vector106.X / 16f) * 16);
                        vector106.Y = (float)((int)(vector106.Y / 16f) * 16);
                        num960 -= vector106.X;
                        num961 -= vector106.Y;
                        float num962 = (float)Math.Sqrt((double)(num960 * num960 + num961 * num961));
                        if (this.ai[1] > 0f && this.ai[1] < (float)Main.npc.Length)
                        {
                            try
                            {
                                vector106 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                num960 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - vector106.X;
                                num961 = Main.npc[(int)this.ai[1]].position.Y + (float)(Main.npc[(int)this.ai[1]].height / 2) - vector106.Y;
                            }
                            catch
                            {
                            }
                            this.rotation = (float)Math.Atan2((double)num961, (double)num960) + 1.57f;
                            num962 = (float)Math.Sqrt((double)(num960 * num960 + num961 * num961));
                            int num963 = (int)(44f * this.scale);
                            num962 = (num962 - (float)num963) / num962;
                            num960 *= num962;
                            num961 *= num962;
                            this.velocity = Vector2.Zero;
                            this.position.X = this.position.X + num960;
                            this.position.Y = this.position.Y + num961;
                            return;
                        }
                        if (!flag94)
                        {
                            this.TargetClosest(true);
                            this.velocity.Y = this.velocity.Y + 0.15f;
                            if (this.velocity.Y > num956)
                            {
                                this.velocity.Y = num956;
                            }
                            if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)num956 * 0.4)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X - num958 * 1.1f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X + num958 * 1.1f;
                                }
                            }
                            else if (this.velocity.Y == num956)
                            {
                                if (this.velocity.X < num960)
                                {
                                    this.velocity.X = this.velocity.X + num958;
                                }
                                else if (this.velocity.X > num960)
                                {
                                    this.velocity.X = this.velocity.X - num958;
                                }
                            }
                            else if (this.velocity.Y > 4f)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X + num958 * 0.9f;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X - num958 * 0.9f;
                                }
                            }
                        }
                        else
                        {
                            if (this.soundDelay == 0)
                            {
                                float num964 = num962 / 40f;
                                if (num964 < 10f)
                                {
                                    num964 = 10f;
                                }
                                if (num964 > 20f)
                                {
                                    num964 = 20f;
                                }
                                this.soundDelay = (int)num964;
                            }
                            num962 = (float)Math.Sqrt((double)(num960 * num960 + num961 * num961));
                            float num965 = Math.Abs(num960);
                            float num966 = Math.Abs(num961);
                            float num967 = num956 / num962;
                            num960 *= num967;
                            num961 *= num967;
                            if (((this.velocity.X > 0f && num960 > 0f) || (this.velocity.X < 0f && num960 < 0f)) && ((this.velocity.Y > 0f && num961 > 0f) || (this.velocity.Y < 0f && num961 < 0f)))
                            {
                                if (this.velocity.X < num960)
                                {
                                    this.velocity.X = this.velocity.X + num959;
                                }
                                else if (this.velocity.X > num960)
                                {
                                    this.velocity.X = this.velocity.X - num959;
                                }
                                if (this.velocity.Y < num961)
                                {
                                    this.velocity.Y = this.velocity.Y + num959;
                                }
                                else if (this.velocity.Y > num961)
                                {
                                    this.velocity.Y = this.velocity.Y - num959;
                                }
                            }
                            if ((this.velocity.X > 0f && num960 > 0f) || (this.velocity.X < 0f && num960 < 0f) || (this.velocity.Y > 0f && num961 > 0f) || (this.velocity.Y < 0f && num961 < 0f))
                            {
                                if (this.velocity.X < num960)
                                {
                                    this.velocity.X = this.velocity.X + num958;
                                }
                                else if (this.velocity.X > num960)
                                {
                                    this.velocity.X = this.velocity.X - num958;
                                }
                                if (this.velocity.Y < num961)
                                {
                                    this.velocity.Y = this.velocity.Y + num958;
                                }
                                else if (this.velocity.Y > num961)
                                {
                                    this.velocity.Y = this.velocity.Y - num958;
                                }
                                if ((double)Math.Abs(num961) < (double)num956 * 0.2 && ((this.velocity.X > 0f && num960 < 0f) || (this.velocity.X < 0f && num960 > 0f)))
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num958 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y - num958 * 2f;
                                    }
                                }
                                if ((double)Math.Abs(num960) < (double)num956 * 0.2 && ((this.velocity.Y > 0f && num961 < 0f) || (this.velocity.Y < 0f && num961 > 0f)))
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num958 * 2f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X - num958 * 2f;
                                    }
                                }
                            }
                            else if (num965 > num966)
                            {
                                if (this.velocity.X < num960)
                                {
                                    this.velocity.X = this.velocity.X + num958 * 1.1f;
                                }
                                else if (this.velocity.X > num960)
                                {
                                    this.velocity.X = this.velocity.X - num958 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)num956 * 0.5)
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num958;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y - num958;
                                    }
                                }
                            }
                            else
                            {
                                if (this.velocity.Y < num961)
                                {
                                    this.velocity.Y = this.velocity.Y + num958 * 1.1f;
                                }
                                else if (this.velocity.Y > num961)
                                {
                                    this.velocity.Y = this.velocity.Y - num958 * 1.1f;
                                }
                                if ((double)(Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y)) < (double)num956 * 0.5)
                                {
                                    if (this.velocity.X > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num958;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X - num958;
                                    }
                                }
                            }
                        }
                        this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X) + 1.57f;
                        if (this.type == NPCID.TheDestroyer)
                        {
                            if (flag94)
                            {
                                if (this.localAI[0] != 1f)
                                {
                                    this.netUpdate = true;
                                }
                                this.localAI[0] = 1f;
                            }
                            else
                            {
                                if (this.localAI[0] != 0f)
                                {
                                    this.netUpdate = true;
                                }
                                this.localAI[0] = 0f;
                            }
                            if (((this.velocity.X > 0f && this.oldVelocity.X < 0f) || (this.velocity.X < 0f && this.oldVelocity.X > 0f) || (this.velocity.Y > 0f && this.oldVelocity.Y < 0f) || (this.velocity.Y < 0f && this.oldVelocity.Y > 0f)) && !this.justHit)
                            {
                                this.netUpdate = true;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 38)
                    {
                        float num968 = 4f;
                        float num969 = 1f;
                        if (this.type == NPCID.SnowmanGangsta)
                        {
                            num968 = 3f;
                            num969 = 0.7f;
                        }
                        if (this.type == NPCID.SnowBalla)
                        {
                            num968 = 3.5f;
                            num969 = 0.8f;
                        }
                        if (this.type == NPCID.SnowmanGangsta)
                        {
                            this.ai[2] += 1f;
                            if (this.ai[2] >= 120f)
                            {
                                this.ai[2] = 0f;
                                if (Main.netMode != 1)
                                {
                                    Vector2 vector107 = new Vector2(this.position.X + (float)this.width * 0.5f - (float)(this.direction * 12), this.position.Y + (float)this.height * 0.5f);
                                    float speedX = (float)(12 * this.spriteDirection);
                                    float speedY = 0f;
                                    if (Main.netMode != 1)
                                    {
                                        int num970 = 25;
                                        int num971 = 110;
                                        int num972 = Projectile.NewProjectile(vector107.X, vector107.Y, speedX, speedY, num971, num970, 0f, Main.myPlayer, 0f, 0f);
                                        Main.projectile[num972].ai[0] = 2f;
                                        Main.projectile[num972].timeLeft = 300;
                                        Main.projectile[num972].friendly = false;
                                        NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", num972, 0f, 0f, 0f, 0, 0, 0);
                                        this.netUpdate = true;
                                    }
                                }
                            }
                        }
                        if (this.type == NPCID.MisterStabby && this.ai[1] >= 3f)
                        {
                            this.TargetClosest(true);
                            this.spriteDirection = this.direction;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                this.ai[2] += 1f;
                                if ((double)this.velocity.X > -0.3 && (double)this.velocity.X < 0.3)
                                {
                                    this.velocity.X = 0f;
                                }
                                if (this.ai[2] >= 200f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                }
                            }
                        }
                        else if (this.type == NPCID.SnowBalla && this.ai[1] >= 3f)
                        {
                            this.TargetClosest(true);
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                                this.ai[2] += 1f;
                                if ((double)this.velocity.X > -0.3 && (double)this.velocity.X < 0.3)
                                {
                                    this.velocity.X = 0f;
                                }
                                if (this.ai[2] >= 16f)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                }
                            }
                            if (this.velocity.X == 0f && this.velocity.Y == 0f && this.ai[2] == 8f)
                            {
                                float num973 = 10f;
                                Vector2 vector108 = new Vector2(this.position.X + (float)this.width * 0.5f - (float)(this.direction * 12), this.position.Y + (float)this.height * 0.25f);
                                float num974 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector108.X;
                                float num975 = Main.player[this.target].position.Y - vector108.Y;
                                float num976 = (float)Math.Sqrt((double)(num974 * num974 + num975 * num975));
                                num976 = num973 / num976;
                                num974 *= num976;
                                num975 *= num976;
                                if (Main.netMode != 1)
                                {
                                    int num977 = 35;
                                    int num978 = 109;
                                    int num979 = Projectile.NewProjectile(vector108.X, vector108.Y, num974, num975, num978, num977, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num979].ai[0] = 2f;
                                    Main.projectile[num979].timeLeft = 300;
                                    Main.projectile[num979].friendly = false;
                                    NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", num979, 0f, 0f, 0f, 0, 0, 0);
                                    this.netUpdate = true;
                                }
                            }
                        }
                        else
                        {
                            if (this.velocity.Y == 0f)
                            {
                                if (this.localAI[2] == this.position.X)
                                {
                                    this.direction *= -1;
                                    this.ai[3] = 60f;
                                }
                                this.localAI[2] = this.position.X;
                                if (this.ai[3] == 0f)
                                {
                                    this.TargetClosest(true);
                                }
                                this.ai[0] += 1f;
                                if (this.ai[0] > 2f)
                                {
                                    this.ai[0] = 0f;
                                    this.ai[1] += 1f;
                                    this.velocity.Y = -8.2f;
                                    this.velocity.X = this.velocity.X + (float)this.direction * num969 * 1.1f;
                                }
                                else
                                {
                                    this.velocity.Y = -6f;
                                    this.velocity.X = this.velocity.X + (float)this.direction * num969 * 0.9f;
                                }
                                this.spriteDirection = this.direction;
                            }
                            this.velocity.X = this.velocity.X + (float)this.direction * num969 * 0.01f;
                        }
                        if (this.ai[3] > 0f)
                        {
                            this.ai[3] -= 1f;
                        }
                        if (this.velocity.X > num968 && this.direction > 0)
                        {
                            this.velocity.X = 4f;
                        }
                        if (this.velocity.X < -num968 && this.direction < 0)
                        {
                            this.velocity.X = -4f;
                            return;
                        }
                    }
                    else if (this.aiStyle == 39)
                    {
                        if (this.target < 0 || Main.player[this.target].dead || this.direction == 0)
                        {
                            this.TargetClosest(true);
                        }
                        bool flag96 = true;
                        int num980 = 0;
                        if (this.velocity.X < 0f)
                        {
                            num980 = -1;
                        }
                        if (this.velocity.X > 0f)
                        {
                            num980 = 1;
                        }
                        Vector2 position6 = this.position;
                        position6.X += this.velocity.X;
                        int num981 = (int)((position6.X + (float)(this.width / 2) + (float)((this.width / 2 + 1) * num980)) / 16f);
                        int num982 = (int)((position6.Y + (float)this.height - 1f) / 16f);
                        if ((float)(num981 * 16) < position6.X + (float)this.width && (float)(num981 * 16 + 16) > position6.X && ((Main.tile[num981, num982].nactive() && !Main.tile[num981, num982].topSlope() && !Main.tile[num981, num982 - 1].topSlope() && ((Main.tileSolid[(int)Main.tile[num981, num982].type] && !Main.tileSolidTop[(int)Main.tile[num981, num982].type]) || (flag96 && Main.tileSolidTop[(int)Main.tile[num981, num982].type] && (!Main.tileSolid[(int)Main.tile[num981, num982 - 1].type] || !Main.tile[num981, num982 - 1].nactive()) && Main.tile[num981, num982].type != TileID.Anvils && Main.tile[num981, num982].type != TileID.WorkBenches && Main.tile[num981, num982].type != TileID.MythrilAnvil))) || (Main.tile[num981, num982 - 1].halfBrick() && Main.tile[num981, num982 - 1].nactive())) && (!Main.tile[num981, num982 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num981, num982 - 1].type] || Main.tileSolidTop[(int)Main.tile[num981, num982 - 1].type] || (Main.tile[num981, num982 - 1].halfBrick() && (!Main.tile[num981, num982 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num981, num982 - 4].type] || Main.tileSolidTop[(int)Main.tile[num981, num982 - 4].type]))) && (!Main.tile[num981, num982 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num981, num982 - 2].type] || Main.tileSolidTop[(int)Main.tile[num981, num982 - 2].type]) && (!Main.tile[num981, num982 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num981, num982 - 3].type] || Main.tileSolidTop[(int)Main.tile[num981, num982 - 3].type]) && (!Main.tile[num981 - num980, num982 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num981 - num980, num982 - 3].type] || Main.tileSolidTop[(int)Main.tile[num981 - num980, num982 - 3].type]))
                        {
                            float num983 = (float)(num982 * 16);
                            if (Main.tile[num981, num982].halfBrick())
                            {
                                num983 += 8f;
                            }
                            if (Main.tile[num981, num982 - 1].halfBrick())
                            {
                                num983 -= 8f;
                            }
                            if (num983 < position6.Y + (float)this.height)
                            {
                                float num984 = position6.Y + (float)this.height - num983;
                                if ((double)num984 <= 16.1)
                                {
                                    this.gfxOffY += this.position.Y + (float)this.height - num983;
                                    this.position.Y = num983 - (float)this.height;
                                    if (num984 < 9f)
                                    {
                                        this.stepSpeed = 0.75f;
                                    }
                                    else
                                    {
                                        this.stepSpeed = 1.5f;
                                    }
                                }
                            }
                        }
                        if (this.justHit && this.type != NPCID.SolarSroller)
                        {
                            this.ai[0] = 0f;
                            this.ai[1] = 0f;
                            this.TargetClosest(true);
                        }
                        if (this.ai[0] == 0f)
                        {
                            if (this.velocity.X < 0f)
                            {
                                this.direction = -1;
                            }
                            else if (this.velocity.X > 0f)
                            {
                                this.direction = 1;
                            }
                            this.spriteDirection = this.direction;
                            Vector2 vector109 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num986 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector109.X;
                            float num987 = Main.player[this.target].position.Y - vector109.Y;
                            float num988 = (float)Math.Sqrt((double)(num986 * num986 + num987 * num987));
                            bool flag97 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                            if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                            {
                                if (num988 > 200f && flag97)
                                {
                                    this.ai[1] += 2f;
                                }
                                if (num988 > 600f && (flag97 || this.position.Y + (float)this.height > Main.player[this.target].position.Y - 200f))
                                {
                                    this.ai[1] += 4f;
                                }
                            }
                            else
                            {
                                if (num988 > 200f && flag97)
                                {
                                    this.ai[1] += 4f;
                                }
                                if (num988 > 600f && (flag97 || this.position.Y + (float)this.height > Main.player[this.target].position.Y - 200f))
                                {
                                    this.ai[1] += 10f;
                                }
                                if (this.wet)
                                {
                                    this.ai[1] = 1000f;
                                }
                            }
                            this.defense = this.defDefense;
                            this.damage = this.defDamage;
                            if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                            {
                                this.knockBackResist = 0.75f * Main.knockBackMultiplier;
                            }
                            else
                            {
                                this.knockBackResist = 0.3f * Main.knockBackMultiplier;
                            }
                            this.ai[1] += 1f;
                            if (this.ai[1] >= 400f)
                            {
                                this.ai[1] = 0f;
                                this.ai[0] = 1f;
                            }
                            if (!this.justHit && this.velocity.X != this.oldVelocity.X)
                            {
                                this.direction *= -1;
                            }
                            if (this.velocity.Y == 0f && Main.player[this.target].position.Y < this.position.Y + (float)this.height)
                            {
                                int num989;
                                int num990;
                                if (this.direction > 0)
                                {
                                    num989 = (int)(((double)this.position.X + (double)this.width * 0.5) / 16.0);
                                    num990 = num989 + 3;
                                }
                                else
                                {
                                    num990 = (int)(((double)this.position.X + (double)this.width * 0.5) / 16.0);
                                    num989 = num990 - 3;
                                }
                                int num991 = (int)((this.position.Y + (float)this.height + 2f) / 16f) - 1;
                                int num992 = num991 + 4;
                                bool flag98 = false;
                                for (int num993 = num989; num993 <= num990; num993++)
                                {
                                    for (int num994 = num991; num994 <= num992; num994++)
                                    {
                                        if (Main.tile[num993, num994] != null && Main.tile[num993, num994].nactive() && Main.tileSolid[(int)Main.tile[num993, num994].type])
                                        {
                                            flag98 = true;
                                        }
                                    }
                                }
                                if (!flag98)
                                {
                                    this.direction *= -1;
                                    this.velocity.X = 0.1f * (float)this.direction;
                                }
                            }
                            if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                            {
                                float num995 = 0.5f;
                                if (this.velocity.X < -num995 || this.velocity.X > num995)
                                {
                                    if (this.velocity.Y == 0f)
                                    {
                                        this.velocity *= 0.8f;
                                        return;
                                    }
                                }
                                else if (this.velocity.X < num995 && this.direction == 1)
                                {
                                    this.velocity.X = this.velocity.X + 0.07f;
                                    if (this.velocity.X > num995)
                                    {
                                        this.velocity.X = num995;
                                        return;
                                    }
                                }
                                else if (this.velocity.X > -num995 && this.direction == -1)
                                {
                                    this.velocity.X = this.velocity.X - 0.07f;
                                    if (this.velocity.X < -num995)
                                    {
                                        this.velocity.X = -num995;
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                float num996 = 1f;
                                if (num988 < 400f)
                                {
                                    if (this.velocity.X < -num996 || this.velocity.X > num996)
                                    {
                                        if (this.velocity.Y == 0f)
                                        {
                                            this.velocity *= 0.8f;
                                            return;
                                        }
                                    }
                                    else if (this.velocity.X < num996 && this.direction == 1)
                                    {
                                        this.velocity.X = this.velocity.X + 0.07f;
                                        if (this.velocity.X > num996)
                                        {
                                            this.velocity.X = num996;
                                            return;
                                        }
                                    }
                                    else if (this.velocity.X > -num996 && this.direction == -1)
                                    {
                                        this.velocity.X = this.velocity.X - 0.07f;
                                        if (this.velocity.X < -num996)
                                        {
                                            this.velocity.X = -num996;
                                            return;
                                        }
                                    }
                                }
                                else if (this.velocity.X < -1.5f || this.velocity.X > 1.5f)
                                {
                                    if (this.velocity.Y == 0f)
                                    {
                                        this.velocity *= 0.8f;
                                        return;
                                    }
                                }
                                else if (this.velocity.X < 1.5f && this.direction == 1)
                                {
                                    this.velocity.X = this.velocity.X + 0.07f;
                                    if (this.velocity.X > 1.5f)
                                    {
                                        this.velocity.X = 1.5f;
                                        return;
                                    }
                                }
                                else if (this.velocity.X > -1.5f && this.direction == -1)
                                {
                                    this.velocity.X = this.velocity.X - 0.07f;
                                    if (this.velocity.X < -1.5f)
                                    {
                                        this.velocity.X = -1.5f;
                                        return;
                                    }
                                }
                            }
                        }
                        else if (this.ai[0] == 1f)
                        {
                            this.velocity.X = this.velocity.X * 0.5f;
                            if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                            {
                                this.ai[1] += 0.5f;
                            }
                            else
                            {
                                this.ai[1] += 1f;
                            }
                            if (this.ai[1] >= 30f)
                            {
                                this.netUpdate = true;
                                this.TargetClosest(true);
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.ai[0] = 3f;
                                if (this.type == NPCID.SolarSroller)
                                {
                                    this.ai[0] = 6f;
                                    this.ai[2] = (float)Main.rand.Next(2, 5);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (this.ai[0] == 3f)
                            {
                                if (Main.expertMode)
                                {
                                    if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                                    {
                                        this.damage = (int)((double)this.defDamage * 1.5 * 0.9);
                                    }
                                    else
                                    {
                                        this.damage = (int)((double)(this.defDamage * 2) * 0.9);
                                    }
                                }
                                else if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                                {
                                    this.damage = (int)((double)this.defDamage * 1.5);
                                }
                                else
                                {
                                    this.damage = this.defDamage * 2;
                                }
                                this.defense = this.defDefense * 2;
                                this.ai[1] += 1f;
                                if (this.ai[1] == 1f)
                                {
                                    this.netUpdate = true;
                                    this.TargetClosest(true);
                                    this.ai[2] += 0.3f;
                                    this.rotation += this.ai[2] * (float)this.direction;
                                    this.ai[1] += 1f;
                                    bool flag99 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                                    float num998 = 10f;
                                    if (!flag99)
                                    {
                                        num998 = 6f;
                                    }
                                    if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                                    {
                                        num998 *= 0.75f;
                                    }
                                    Vector2 vector110 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float num999 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector110.X;
                                    float num1000 = Math.Abs(num999) * 0.2f;
                                    if (this.directionY > 0)
                                    {
                                        num1000 = 0f;
                                    }
                                    float num1001 = Main.player[this.target].position.Y - vector110.Y - num1000;
                                    float num1002 = (float)Math.Sqrt((double)(num999 * num999 + num1001 * num1001));
                                    this.netUpdate = true;
                                    num1002 = num998 / num1002;
                                    num999 *= num1002;
                                    num1001 *= num1002;
                                    if (!flag99)
                                    {
                                        num1001 = -10f;
                                    }
                                    this.velocity.X = num999;
                                    this.velocity.Y = num1001;
                                    this.ai[3] = this.velocity.X;
                                }
                                else
                                {
                                    if (this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y < Main.player[this.target].position.Y + (float)Main.player[this.target].height)
                                    {
                                        this.velocity.X = this.velocity.X * 0.8f;
                                        this.ai[3] = 0f;
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.2f;
                                        }
                                    }
                                    if (this.ai[3] != 0f)
                                    {
                                        this.velocity.X = this.ai[3];
                                        this.velocity.Y = this.velocity.Y - 0.22f;
                                    }
                                    if (this.ai[1] >= 90f)
                                    {
                                        this.noGravity = false;
                                        this.ai[1] = 0f;
                                        this.ai[0] = 4f;
                                    }
                                }
                                if (this.wet && this.directionY < 0)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.3f;
                                }
                                this.rotation += this.ai[2] * (float)this.direction;
                                return;
                            }
                            if (this.ai[0] == 4f)
                            {
                                if (this.wet && this.directionY < 0)
                                {
                                    this.velocity.Y = this.velocity.Y - 0.3f;
                                }
                                this.velocity.X = this.velocity.X * 0.96f;
                                if (this.ai[2] > 0f)
                                {
                                    this.ai[2] -= 0.01f;
                                    this.rotation += this.ai[2] * (float)this.direction;
                                }
                                else if (this.velocity.Y >= 0f)
                                {
                                    this.rotation = 0f;
                                }
                                if (this.ai[2] <= 0f && (this.velocity.Y == 0f || this.wet))
                                {
                                    this.netUpdate = true;
                                    this.rotation = 0f;
                                    this.ai[2] = 0f;
                                    this.ai[1] = 0f;
                                    this.ai[0] = 5f;
                                    return;
                                }
                            }
                            else
                            {
                                if (this.ai[0] == 6f)
                                {
                                    this.damage = (int)((float)this.defDamage * (Main.expertMode ? 1.4f : 1.8f));
                                    this.defense = this.defDefense * 2;
                                    this.knockBackResist = 0f;
                                    this.ai[1] += 1f;
                                    if (this.ai[3] > 0f)
                                    {
                                        this.ai[3] += 1f;
                                        if (this.ai[3] >= 10f)
                                        {
                                            this.ai[3] = 0f;
                                        }
                                    }
                                    if (this.ai[1] == 1f)
                                    {
                                        this.netUpdate = true;
                                        this.TargetClosest(true);
                                        bool flag100 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                                        float num1010 = 16f;
                                        if (!flag100)
                                        {
                                            num1010 = 10f;
                                        }
                                        Vector2 vector112 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num1011 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector112.X;
                                        float num1012 = Math.Abs(num1011) * 0.2f;
                                        if (this.directionY > 0)
                                        {
                                            num1012 = 0f;
                                        }
                                        float num1013 = Main.player[this.target].position.Y - vector112.Y - num1012;
                                        float num1014 = (float)Math.Sqrt((double)(num1011 * num1011 + num1013 * num1013));
                                        this.netUpdate = true;
                                        num1014 = num1010 / num1014;
                                        num1011 *= num1014;
                                        num1013 *= num1014;
                                        if (!flag100)
                                        {
                                            num1013 = -12f;
                                        }
                                        this.velocity.X = num1011;
                                        this.velocity.Y = num1013;
                                    }
                                    else
                                    {
                                        if (this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y < Main.player[this.target].position.Y + (float)Main.player[this.target].height)
                                        {
                                            this.velocity.X = this.velocity.X * 0.9f;
                                            if (this.velocity.Y < 0f)
                                            {
                                                this.velocity.Y = this.velocity.Y + 0.2f;
                                            }
                                        }
                                        if (this.ai[2] == 0f || this.ai[1] >= 1200f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 5f;
                                        }
                                    }
                                    if (this.wet && this.directionY < 0)
                                    {
                                        this.velocity.Y = this.velocity.Y - 0.3f;
                                    }
                                    this.rotation += MathHelper.Clamp(this.velocity.X / 10f * (float)this.direction, -0.314159274f, 0.314159274f);
                                    return;
                                }
                                if (this.ai[0] == 5f)
                                {
                                    this.rotation = 0f;
                                    this.velocity.X = 0f;
                                    if (this.type >= NPCID.GiantShelly && this.type <= NPCID.GiantShelly2)
                                    {
                                        this.ai[1] += 0.5f;
                                    }
                                    else
                                    {
                                        this.ai[1] += 1f;
                                    }
                                    if (this.ai[1] >= 30f)
                                    {
                                        this.TargetClosest(true);
                                        this.netUpdate = true;
                                        this.ai[1] = 0f;
                                        this.ai[0] = 0f;
                                    }
                                    if (this.wet)
                                    {
                                        this.ai[0] = 3f;
                                        this.ai[1] = 0f;
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    else if (this.aiStyle == 40)
                    {
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                        }
                        float num1015 = 2f;
                        float num1016 = 0.08f;
                        if (this.type == NPCID.DesertScorpionWall)
                        {
                            num1015 = 4f;
                            num1016 = 0.16f;
                        }
                        Vector2 vector113 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                        float num1017 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2);
                        float num1018 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2);
                        num1017 = (float)((int)(num1017 / 8f) * 8);
                        num1018 = (float)((int)(num1018 / 8f) * 8);
                        vector113.X = (float)((int)(vector113.X / 8f) * 8);
                        vector113.Y = (float)((int)(vector113.Y / 8f) * 8);
                        num1017 -= vector113.X;
                        num1018 -= vector113.Y;
                        float num1019 = (float)Math.Sqrt((double)(num1017 * num1017 + num1018 * num1018));
                        if (num1019 == 0f)
                        {
                            num1017 = this.velocity.X;
                            num1018 = this.velocity.Y;
                        }
                        else
                        {
                            num1019 = num1015 / num1019;
                            num1017 *= num1019;
                            num1018 *= num1019;
                        }
                        if (Main.player[this.target].dead)
                        {
                            num1017 = (float)this.direction * num1015 / 2f;
                            num1018 = -num1015 / 2f;
                        }
                        this.spriteDirection = -1;
                        if (!Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                        {
                            this.ai[0] += 1f;
                            if (this.ai[0] > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + 0.023f;
                            }
                            else
                            {
                                this.velocity.Y = this.velocity.Y - 0.023f;
                            }
                            if (this.ai[0] < -100f || this.ai[0] > 100f)
                            {
                                this.velocity.X = this.velocity.X + 0.023f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X - 0.023f;
                            }
                            if (this.ai[0] > 200f)
                            {
                                this.ai[0] = -200f;
                            }
                            this.velocity.X = this.velocity.X + num1017 * 0.007f;
                            this.velocity.Y = this.velocity.Y + num1018 * 0.007f;
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                            if ((double)this.velocity.X > 1.5)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if ((double)this.velocity.X < -1.5)
                            {
                                this.velocity.X = this.velocity.X * 0.9f;
                            }
                            if ((double)this.velocity.Y > 1.5)
                            {
                                this.velocity.Y = this.velocity.Y * 0.9f;
                            }
                            if ((double)this.velocity.Y < -1.5)
                            {
                                this.velocity.Y = this.velocity.Y * 0.9f;
                            }
                            if (this.velocity.X > 3f)
                            {
                                this.velocity.X = 3f;
                            }
                            if (this.velocity.X < -3f)
                            {
                                this.velocity.X = -3f;
                            }
                            if (this.velocity.Y > 3f)
                            {
                                this.velocity.Y = 3f;
                            }
                            if (this.velocity.Y < -3f)
                            {
                                this.velocity.Y = -3f;
                            }
                        }
                        else
                        {
                            if (this.velocity.X < num1017)
                            {
                                this.velocity.X = this.velocity.X + num1016;
                                if (this.velocity.X < 0f && num1017 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + num1016;
                                }
                            }
                            else if (this.velocity.X > num1017)
                            {
                                this.velocity.X = this.velocity.X - num1016;
                                if (this.velocity.X > 0f && num1017 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - num1016;
                                }
                            }
                            if (this.velocity.Y < num1018)
                            {
                                this.velocity.Y = this.velocity.Y + num1016;
                                if (this.velocity.Y < 0f && num1018 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + num1016;
                                }
                            }
                            else if (this.velocity.Y > num1018)
                            {
                                this.velocity.Y = this.velocity.Y - num1016;
                                if (this.velocity.Y > 0f && num1018 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - num1016;
                                }
                            }
                            this.rotation = (float)Math.Atan2((double)num1018, (double)num1017);
                        }
                        if (this.type == NPCID.DesertScorpionWall)
                        {
                            this.rotation += 1.57079637f;
                        }
                        float num1020 = 0.5f;
                        if (this.collideX)
                        {
                            this.netUpdate = true;
                            this.velocity.X = this.oldVelocity.X * -num1020;
                            if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                            {
                                this.velocity.X = 2f;
                            }
                            if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                            {
                                this.velocity.X = -2f;
                            }
                        }
                        if (this.collideY)
                        {
                            this.netUpdate = true;
                            this.velocity.Y = this.oldVelocity.Y * -num1020;
                            if (this.velocity.Y > 0f && (double)this.velocity.Y < 1.5)
                            {
                                this.velocity.Y = 2f;
                            }
                            if (this.velocity.Y < 0f && (double)this.velocity.Y > -1.5)
                            {
                                this.velocity.Y = -2f;
                            }
                        }
                        if (((this.velocity.X > 0f && this.oldVelocity.X < 0f) || (this.velocity.X < 0f && this.oldVelocity.X > 0f) || (this.velocity.Y > 0f && this.oldVelocity.Y < 0f) || (this.velocity.Y < 0f && this.oldVelocity.Y > 0f)) && !this.justHit)
                        {
                            this.netUpdate = true;
                        }
                        if (Main.netMode != 1)
                        {
                            if (Main.netMode != 1 && Main.expertMode && this.target >= 0 && (this.type == NPCID.BlackRecluse || this.type == NPCID.BlackRecluseWall) && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                this.localAI[0] += 1f;
                                if (this.justHit)
                                {
                                    this.localAI[0] -= (float)Main.rand.Next(20, 60);
                                    if (this.localAI[0] < 0f)
                                    {
                                        this.localAI[0] = 0f;
                                    }
                                }
                                if (this.localAI[0] > (float)Main.rand.Next(180, 900))
                                {
                                    this.localAI[0] = 0f;
                                    Vector2 vector114 = Main.player[this.target].Center - base.Center;
                                    vector114.Normalize();
                                    vector114 *= 8f;
                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, vector114.X, vector114.Y, 472, 18, 0f, Main.myPlayer, 0f, 0f);
                                }
                            }
                            int num1021 = (int)base.Center.X / 16;
                            int num1022 = (int)base.Center.Y / 16;
                            bool flag101 = false;
                            for (int num1023 = num1021 - 1; num1023 <= num1021 + 1; num1023++)
                            {
                                for (int num1024 = num1022 - 1; num1024 <= num1022 + 1; num1024++)
                                {
                                    if (Main.tile[num1023, num1024] == null)
                                    {
                                        return;
                                    }
                                    if (Main.tile[num1023, num1024].wall > 0)
                                    {
                                        flag101 = true;
                                    }
                                }
                            }
                            if (!flag101)
                            {
                                if (this.type == NPCID.JungleCreeperWall)
                                {
                                    this.Transform(236);
                                    return;
                                }
                                if (this.type == NPCID.BlackRecluseWall)
                                {
                                    this.Transform(163);
                                    return;
                                }
                                if (this.type == NPCID.BloodCrawlerWall)
                                {
                                    this.Transform(239);
                                    return;
                                }
                                if (this.type == NPCID.DesertScorpionWall)
                                {
                                    this.Transform(530);
                                    return;
                                }
                                this.Transform(164);
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 41)
                    {
                        if (this.ai[2] > 1f)
                        {
                            this.ai[2] -= 1f;
                        }
                        if (this.ai[2] == 0f)
                        {
                            this.ai[0] = -100f;
                            this.ai[2] = 1f;
                            this.TargetClosest(true);
                            this.spriteDirection = this.direction;
                        }
                        if (this.type == NPCID.ChatteringTeethBomb)
                        {
                            Vector2 value14 = new Vector2(-6f, -10f);
                            value14.X *= (float)this.spriteDirection;
                            if (this.ai[1] == 5f)
                            {
                                this.velocity = Vector2.Zero;
                                this.position.X = this.position.X + (float)(this.width / 2);
                                this.position.Y = this.position.Y + (float)(this.height / 2);
                                this.width = 160;
                                this.height = 160;
                                this.position.X = this.position.X - (float)(this.width / 2);
                                this.position.Y = this.position.Y - (float)(this.height / 2);
                                this.dontTakeDamage = true;

                                if (this.ai[2] == 1f)
                                {
                                    this.life = -1;
                                    this.HitEffect(0, 10.0);
                                    this.active = false;
                                }
                                return;
                            }
                        }
                        if (this.type == NPCID.ChatteringTeethBomb && this.ai[1] != 5f)
                        {
                            if (this.wet || Vector2.Distance(base.Center, Main.player[this.target].Center) < 64f)
                            {
                                this.ai[1] = 5f;
                                this.ai[2] = 3f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.wet && this.type != NPCID.Derpling)
                        {
                            if (this.collideX)
                            {
                                this.direction *= -this.direction;
                                this.spriteDirection = this.direction;
                            }
                            if (this.collideY)
                            {
                                this.TargetClosest(true);
                                if (this.oldVelocity.Y < 0f)
                                {
                                    this.velocity.Y = 5f;
                                }
                                else
                                {
                                    this.velocity.Y = this.velocity.Y - 2f;
                                }
                                this.spriteDirection = this.direction;
                            }
                            if (this.velocity.Y > 4f)
                            {
                                this.velocity.Y = this.velocity.Y * 0.95f;
                            }
                            this.velocity.Y = this.velocity.Y - 0.3f;
                            if (this.velocity.Y < -4f)
                            {
                                this.velocity.Y = -4f;
                            }
                        }
                        if (this.velocity.Y == 0f)
                        {
                            if (this.ai[3] == this.position.X)
                            {
                                this.direction *= -1;
                                this.ai[2] = 300f;
                            }
                            this.ai[3] = 0f;
                            this.velocity.X = this.velocity.X * 0.8f;
                            if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                            {
                                this.velocity.X = 0f;
                            }
                            if (this.type == NPCID.Derpling)
                            {
                                this.ai[0] += 2f;
                            }
                            else
                            {
                                this.ai[0] += 5f;
                            }
                            Vector2 vector115 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num1031 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector115.X;
                            float num1032 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector115.Y;
                            float num1033 = (float)Math.Sqrt((double)(num1031 * num1031 + num1032 * num1032));
                            float num1034 = 400f / num1033;
                            if (this.type == NPCID.Derpling)
                            {
                                num1034 *= 5f;
                            }
                            else
                            {
                                num1034 *= 10f;
                            }
                            if (num1034 > 30f)
                            {
                                num1034 = 30f;
                            }
                            this.ai[0] += (float)((int)num1034);
                            if (this.ai[0] >= 0f)
                            {
                                this.netUpdate = true;
                                if (this.ai[2] == 1f)
                                {
                                    this.TargetClosest(true);
                                }
                                if (this.type == NPCID.Derpling)
                                {
                                    if (this.ai[1] == 2f)
                                    {
                                        this.velocity.Y = -11.5f;
                                        this.velocity.X = this.velocity.X + 2f * (float)this.direction;
                                        if (num1033 < 350f && num1033 > 200f)
                                        {
                                            this.velocity.X = this.velocity.X + (float)this.direction;
                                        }
                                        this.ai[0] = -200f;
                                        this.ai[1] = 0f;
                                        this.ai[3] = this.position.X;
                                    }
                                    else
                                    {
                                        this.velocity.Y = -7.5f;
                                        this.velocity.X = this.velocity.X + (float)(4 * this.direction);
                                        if (num1033 < 350f && num1033 > 200f)
                                        {
                                            this.velocity.X = this.velocity.X + (float)this.direction;
                                        }
                                        this.ai[0] = -120f;
                                        this.ai[1] += 1f;
                                    }
                                }
                                else if (this.ai[1] == 3f)
                                {
                                    this.velocity.Y = -9f;
                                    this.velocity.X = this.velocity.X + (float)(3 * this.direction);
                                    if (num1033 < 350f && num1033 > 200f)
                                    {
                                        this.velocity.X = this.velocity.X + (float)this.direction;
                                    }
                                    this.ai[0] = -200f;
                                    this.ai[1] = 0f;
                                    this.ai[3] = this.position.X;
                                }
                                else
                                {
                                    this.velocity.Y = -5f;
                                    this.velocity.X = this.velocity.X + (float)(5 * this.direction);
                                    if (num1033 < 350f && num1033 > 200f)
                                    {
                                        this.velocity.X = this.velocity.X + (float)this.direction;
                                    }
                                    this.ai[0] = -120f;
                                    this.ai[1] += 1f;
                                }
                            }
                            else if (this.ai[0] >= -30f)
                            {
                                this.aiAction = 1;
                            }
                            this.spriteDirection = this.direction;
                            return;
                        }
                        if (this.target < 255)
                        {
                            if (this.type == NPCID.Derpling)
                            {
                                bool flag102 = false;
                                if (this.position.Y + (float)this.height < Main.player[this.target].position.Y && this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    flag102 = true;
                                    this.velocity.X = this.velocity.X * 0.92f;
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                    }
                                }
                                if (!flag102 && ((this.direction == 1 && this.velocity.X < 4f) || (this.direction == -1 && this.velocity.X > -4f)))
                                {
                                    if ((this.direction == -1 && (double)this.velocity.X < 0.1) || (this.direction == 1 && (double)this.velocity.X > -0.1))
                                    {
                                        this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                                        return;
                                    }
                                    this.velocity.X = this.velocity.X * 0.93f;
                                    return;
                                }
                            }
                            else if ((this.direction == 1 && this.velocity.X < 3f) || (this.direction == -1 && this.velocity.X > -3f))
                            {
                                if ((this.direction == -1 && (double)this.velocity.X < 0.1) || (this.direction == 1 && (double)this.velocity.X > -0.1))
                                {
                                    this.velocity.X = this.velocity.X + 0.2f * (float)this.direction;
                                    return;
                                }
                                this.velocity.X = this.velocity.X * 0.93f;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 42)
                    {
                        this.TargetClosest(true);
                        if (this.ai[0] == 0f)
                        {
                            if (this.target >= 0)
                            {
                                Vector2 vector116 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                float num1035 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector116.X;
                                float num1036 = Main.player[this.target].position.Y - vector116.Y;
                                float num1037 = (float)Math.Sqrt((double)(num1035 * num1035 + num1036 * num1036));
                                if (num1037 < 200f && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                {
                                    this.ai[0] = 1f;
                                }
                            }
                            if (this.velocity.X != 0f || this.velocity.Y < 0f || this.velocity.Y > 2f || this.life != this.lifeMax)
                            {
                                this.ai[0] = 1f;
                                return;
                            }
                        }
                        else
                        {
                            this.ai[0] += 1f;
                            if (this.ai[0] >= 21f)
                            {
                                this.ai[0] = 21f;
                                this.Transform(196);
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 43)
                    {
                        int num1038 = 0;
                        for (int num1039 = 0; num1039 < 255; num1039++)
                        {
                            if (Main.player[num1039].active && !Main.player[num1039].dead && (base.Center - Main.player[num1039].Center).Length() < 1000f)
                            {
                                num1038++;
                            }
                        }
                        if (Main.expertMode)
                        {
                            int num1040 = (int)(20f * (1f - (float)this.life / (float)this.lifeMax));
                            this.defense = this.defDefense + num1040;
                        }
                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead || !Main.player[this.target].active)
                        {
                            this.TargetClosest(true);
                        }
                        bool dead4 = Main.player[this.target].dead;
                        if (dead4 && Main.expertMode)
                        {
                            if ((double)this.position.Y < Main.worldSurface * 16.0 + 2000.0)
                            {
                                this.velocity.Y = this.velocity.Y + 0.04f;
                            }
                            if (this.position.X < (float)(Main.maxTilesX * 8))
                            {
                                this.velocity.X = this.velocity.X - 0.04f;
                            }
                            else
                            {
                                this.velocity.X = this.velocity.X + 0.04f;
                            }
                            if (this.timeLeft > 10)
                            {
                                this.timeLeft = 10;
                                return;
                            }
                        }
                        else if (this.ai[0] == -1f)
                        {
                            if (Main.netMode != 1)
                            {
                                float num1041 = this.ai[1];
                                int num1042;
                                do
                                {
                                    num1042 = Main.rand.Next(3);
                                    if (num1042 == 1)
                                    {
                                        num1042 = 2;
                                    }
                                    else if (num1042 == 2)
                                    {
                                        num1042 = 3;
                                    }
                                }
                                while ((float)num1042 == num1041);
                                this.ai[0] = (float)num1042;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                return;
                            }
                        }
                        else if (this.ai[0] == 0f)
                        {
                            int num1043 = 2;
                            if (Main.expertMode)
                            {
                                if (this.life < this.lifeMax / 2)
                                {
                                    num1043++;
                                }
                                if (this.life < this.lifeMax / 3)
                                {
                                    num1043++;
                                }
                                if (this.life < this.lifeMax / 5)
                                {
                                    num1043++;
                                }
                            }
                            if (this.ai[1] > (float)(2 * num1043) && this.ai[1] % 2f == 0f)
                            {
                                this.ai[0] = -1f;
                                this.ai[1] = 0f;
                                this.ai[2] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                            if (this.ai[1] % 2f == 0f)
                            {
                                this.TargetClosest(true);
                                if (Math.Abs(this.position.Y + (float)(this.height / 2) - (Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))) < 20f)
                                {
                                    this.localAI[0] = 1f;
                                    this.ai[1] += 1f;
                                    this.ai[2] = 0f;
                                    float num1044 = 12f;
                                    if (Main.expertMode)
                                    {
                                        num1044 = 16f;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            num1044 += 2f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            num1044 += 2f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            num1044 += 2f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.1)
                                        {
                                            num1044 += 2f;
                                        }
                                    }
                                    Vector2 vector117 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float num1045 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector117.X;
                                    float num1046 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector117.Y;
                                    float num1047 = (float)Math.Sqrt((double)(num1045 * num1045 + num1046 * num1046));
                                    num1047 = num1044 / num1047;
                                    this.velocity.X = num1045 * num1047;
                                    this.velocity.Y = num1046 * num1047;
                                    this.spriteDirection = this.direction;
                                    return;
                                }
                                this.localAI[0] = 0f;
                                float num1048 = 12f;
                                float num1049 = 0.15f;
                                if (Main.expertMode)
                                {
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        num1048 += 1f;
                                        num1049 += 0.05f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        num1048 += 1f;
                                        num1049 += 0.05f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        num1048 += 2f;
                                        num1049 += 0.05f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        num1048 += 2f;
                                        num1049 += 0.1f;
                                    }
                                }
                                if (this.position.Y + (float)(this.height / 2) < Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2))
                                {
                                    this.velocity.Y = this.velocity.Y + num1049;
                                }
                                else
                                {
                                    this.velocity.Y = this.velocity.Y - num1049;
                                }
                                if (this.velocity.Y < -12f)
                                {
                                    this.velocity.Y = -num1048;
                                }
                                if (this.velocity.Y > 12f)
                                {
                                    this.velocity.Y = num1048;
                                }
                                if (Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) > 600f)
                                {
                                    this.velocity.X = this.velocity.X + 0.15f * (float)this.direction;
                                }
                                else if (Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) < 300f)
                                {
                                    this.velocity.X = this.velocity.X - 0.15f * (float)this.direction;
                                }
                                else
                                {
                                    this.velocity.X = this.velocity.X * 0.8f;
                                }
                                if (this.velocity.X < -16f)
                                {
                                    this.velocity.X = -16f;
                                }
                                if (this.velocity.X > 16f)
                                {
                                    this.velocity.X = 16f;
                                }
                                this.spriteDirection = this.direction;
                                return;
                            }
                            else
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.direction = -1;
                                }
                                else
                                {
                                    this.direction = 1;
                                }
                                this.spriteDirection = this.direction;
                                int num1050 = 600;
                                if (Main.expertMode)
                                {
                                    if ((double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        num1050 = 300;
                                    }
                                    else if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        num1050 = 450;
                                    }
                                    else if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        num1050 = 500;
                                    }
                                    else if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        num1050 = 550;
                                    }
                                }
                                int num1051 = 1;
                                if (this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))
                                {
                                    num1051 = -1;
                                }
                                if (this.direction == num1051 && Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2))) > (float)num1050)
                                {
                                    this.ai[2] = 1f;
                                }
                                if (this.ai[2] != 1f)
                                {
                                    this.localAI[0] = 1f;
                                    return;
                                }
                                this.TargetClosest(true);
                                this.spriteDirection = this.direction;
                                this.localAI[0] = 0f;
                                this.velocity *= 0.9f;
                                float num1052 = 0.1f;
                                if (Main.expertMode)
                                {
                                    if (this.life < this.lifeMax / 2)
                                    {
                                        this.velocity *= 0.9f;
                                        num1052 += 0.05f;
                                    }
                                    if (this.life < this.lifeMax / 3)
                                    {
                                        this.velocity *= 0.9f;
                                        num1052 += 0.05f;
                                    }
                                    if (this.life < this.lifeMax / 5)
                                    {
                                        this.velocity *= 0.9f;
                                        num1052 += 0.05f;
                                    }
                                }
                                if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < num1052)
                                {
                                    this.ai[2] = 0f;
                                    this.ai[1] += 1f;
                                    return;
                                }
                            }
                        }
                        else if (this.ai[0] == 2f)
                        {
                            this.TargetClosest(true);
                            this.spriteDirection = this.direction;
                            float num1053 = 12f;
                            float num1054 = 0.07f;
                            if (Main.expertMode)
                            {
                                num1054 = 0.1f;
                            }
                            Vector2 vector118 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num1055 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector118.X;
                            float num1056 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 200f - vector118.Y;
                            float num1057 = (float)Math.Sqrt((double)(num1055 * num1055 + num1056 * num1056));
                            if (num1057 < 200f)
                            {
                                this.ai[0] = 1f;
                                this.ai[1] = 0f;
                                this.netUpdate = true;
                                return;
                            }
                            num1057 = num1053 / num1057;
                            if (this.velocity.X < num1055)
                            {
                                this.velocity.X = this.velocity.X + num1054;
                                if (this.velocity.X < 0f && num1055 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + num1054;
                                }
                            }
                            else if (this.velocity.X > num1055)
                            {
                                this.velocity.X = this.velocity.X - num1054;
                                if (this.velocity.X > 0f && num1055 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - num1054;
                                }
                            }
                            if (this.velocity.Y < num1056)
                            {
                                this.velocity.Y = this.velocity.Y + num1054;
                                if (this.velocity.Y < 0f && num1056 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + num1054;
                                    return;
                                }
                            }
                            else if (this.velocity.Y > num1056)
                            {
                                this.velocity.Y = this.velocity.Y - num1054;
                                if (this.velocity.Y > 0f && num1056 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - num1054;
                                    return;
                                }
                            }
                        }
                        else if (this.ai[0] == 1f)
                        {
                            this.localAI[0] = 0f;
                            this.TargetClosest(true);
                            Vector2 vector119 = new Vector2(this.position.X + (float)(this.width / 2) + (float)(Main.rand.Next(20) * this.direction), this.position.Y + (float)this.height * 0.8f);
                            Vector2 vector120 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num1058 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector120.X;
                            float num1059 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector120.Y;
                            float num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059));
                            this.ai[1] += 1f;
                            if (Main.expertMode)
                            {
                                this.ai[1] += (float)(num1038 / 2);
                                if ((double)this.life < (double)this.lifeMax * 0.75)
                                {
                                    this.ai[1] += 0.25f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.5)
                                {
                                    this.ai[1] += 0.25f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.25)
                                {
                                    this.ai[1] += 0.25f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.1)
                                {
                                    this.ai[1] += 0.25f;
                                }
                            }
                            bool flag103 = false;
                            if (this.ai[1] > 40f)
                            {
                                this.ai[1] = 0f;
                                this.ai[2] += 1f;
                                flag103 = true;
                            }
                            if (Collision.CanHit(vector119, 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && flag103)
                            {
                                if (Main.netMode != 1)
                                {
                                    int num1061 = Main.rand.Next(210, 212);
                                    int num1062 = NPC.NewNPC((int)vector119.X, (int)vector119.Y, num1061, 0, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num1062].velocity.X = (float)Main.rand.Next(-200, 201) * 0.002f;
                                    Main.npc[num1062].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.002f;
                                    Main.npc[num1062].localAI[0] = 60f;
                                    Main.npc[num1062].netUpdate = true;
                                }
                            }
                            if (num1060 > 400f || !Collision.CanHit(new Vector2(vector119.X, vector119.Y - 30f), 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                float num1063 = 14f;
                                float num1064 = 0.1f;
                                vector120 = vector119;
                                num1058 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector120.X;
                                num1059 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector120.Y;
                                num1060 = (float)Math.Sqrt((double)(num1058 * num1058 + num1059 * num1059));
                                num1060 = num1063 / num1060;
                                if (this.velocity.X < num1058)
                                {
                                    this.velocity.X = this.velocity.X + num1064;
                                    if (this.velocity.X < 0f && num1058 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num1064;
                                    }
                                }
                                else if (this.velocity.X > num1058)
                                {
                                    this.velocity.X = this.velocity.X - num1064;
                                    if (this.velocity.X > 0f && num1058 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num1064;
                                    }
                                }
                                if (this.velocity.Y < num1059)
                                {
                                    this.velocity.Y = this.velocity.Y + num1064;
                                    if (this.velocity.Y < 0f && num1059 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num1064;
                                    }
                                }
                                else if (this.velocity.Y > num1059)
                                {
                                    this.velocity.Y = this.velocity.Y - num1064;
                                    if (this.velocity.Y > 0f && num1059 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num1064;
                                    }
                                }
                            }
                            else
                            {
                                this.velocity *= 0.9f;
                            }
                            this.spriteDirection = this.direction;
                            if (this.ai[2] > 5f)
                            {
                                this.ai[0] = -1f;
                                this.ai[1] = 1f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                        else if (this.ai[0] == 3f)
                        {
                            float num1065 = 4f;
                            float num1066 = 0.05f;
                            if (Main.expertMode)
                            {
                                num1066 = 0.075f;
                                num1065 = 6f;
                            }
                            Vector2 vector121 = new Vector2(this.position.X + (float)(this.width / 2) + (float)(Main.rand.Next(20) * this.direction), this.position.Y + (float)this.height * 0.8f);
                            Vector2 vector122 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                            float num1067 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector122.X;
                            float num1068 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 300f - vector122.Y;
                            float num1069 = (float)Math.Sqrt((double)(num1067 * num1067 + num1068 * num1068));
                            this.ai[1] += 1f;
                            bool flag104 = false;
                            if (Main.expertMode)
                            {
                                if ((double)this.life < (double)this.lifeMax * 0.1)
                                {
                                    if (this.ai[1] % 15f == 14f)
                                    {
                                        flag104 = true;
                                    }
                                }
                                else if (this.life < this.lifeMax / 3)
                                {
                                    if (this.ai[1] % 25f == 24f)
                                    {
                                        flag104 = true;
                                    }
                                }
                                else if (this.life < this.lifeMax / 2)
                                {
                                    if (this.ai[1] % 30f == 29f)
                                    {
                                        flag104 = true;
                                    }
                                }
                                else if (this.ai[1] % 35f == 34f)
                                {
                                    flag104 = true;
                                }
                            }
                            else if (this.ai[1] % 40f == 39f)
                            {
                                flag104 = true;
                            }
                            if (flag104 && this.position.Y + (float)this.height < Main.player[this.target].position.Y && Collision.CanHit(vector121, 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                if (Main.netMode != 1)
                                {
                                    float num1070 = 8f;
                                    if (Main.expertMode)
                                    {
                                        num1070 += 2f;
                                    }
                                    if (Main.expertMode && (double)this.life < (double)this.lifeMax * 0.1)
                                    {
                                        num1070 += 3f;
                                    }
                                    float num1071 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector121.X + (float)Main.rand.Next(-80, 81);
                                    float num1072 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector121.Y + (float)Main.rand.Next(-40, 41);
                                    float num1073 = (float)Math.Sqrt((double)(num1071 * num1071 + num1072 * num1072));
                                    num1073 = num1070 / num1073;
                                    num1071 *= num1073;
                                    num1072 *= num1073;
                                    int num1074 = 11;
                                    int num1075 = 55;
                                    int num1076 = Projectile.NewProjectile(vector121.X, vector121.Y, num1071, num1072, num1075, num1074, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num1076].timeLeft = 300;
                                }
                            }
                            if (!Collision.CanHit(new Vector2(vector121.X, vector121.Y - 30f), 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                            {
                                num1065 = 14f;
                                num1066 = 0.1f;
                                vector122 = vector121;
                                num1067 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector122.X;
                                num1068 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector122.Y;
                                num1069 = (float)Math.Sqrt((double)(num1067 * num1067 + num1068 * num1068));
                                num1069 = num1065 / num1069;
                                if (this.velocity.X < num1067)
                                {
                                    this.velocity.X = this.velocity.X + num1066;
                                    if (this.velocity.X < 0f && num1067 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num1066;
                                    }
                                }
                                else if (this.velocity.X > num1067)
                                {
                                    this.velocity.X = this.velocity.X - num1066;
                                    if (this.velocity.X > 0f && num1067 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num1066;
                                    }
                                }
                                if (this.velocity.Y < num1068)
                                {
                                    this.velocity.Y = this.velocity.Y + num1066;
                                    if (this.velocity.Y < 0f && num1068 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num1066;
                                    }
                                }
                                else if (this.velocity.Y > num1068)
                                {
                                    this.velocity.Y = this.velocity.Y - num1066;
                                    if (this.velocity.Y > 0f && num1068 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num1066;
                                    }
                                }
                            }
                            else if (num1069 > 100f)
                            {
                                this.TargetClosest(true);
                                this.spriteDirection = this.direction;
                                num1069 = num1065 / num1069;
                                if (this.velocity.X < num1067)
                                {
                                    this.velocity.X = this.velocity.X + num1066;
                                    if (this.velocity.X < 0f && num1067 > 0f)
                                    {
                                        this.velocity.X = this.velocity.X + num1066 * 2f;
                                    }
                                }
                                else if (this.velocity.X > num1067)
                                {
                                    this.velocity.X = this.velocity.X - num1066;
                                    if (this.velocity.X > 0f && num1067 < 0f)
                                    {
                                        this.velocity.X = this.velocity.X - num1066 * 2f;
                                    }
                                }
                                if (this.velocity.Y < num1068)
                                {
                                    this.velocity.Y = this.velocity.Y + num1066;
                                    if (this.velocity.Y < 0f && num1068 > 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y + num1066 * 2f;
                                    }
                                }
                                else if (this.velocity.Y > num1068)
                                {
                                    this.velocity.Y = this.velocity.Y - num1066;
                                    if (this.velocity.Y > 0f && num1068 < 0f)
                                    {
                                        this.velocity.Y = this.velocity.Y - num1066 * 2f;
                                    }
                                }
                            }
                            if (this.ai[1] > 800f)
                            {
                                this.ai[0] = -1f;
                                this.ai[1] = 3f;
                                this.netUpdate = true;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 44)
                    {
                        this.noGravity = true;
                        if (this.collideX)
                        {
                            if (this.oldVelocity.X > 0f)
                            {
                                this.direction = -1;
                            }
                            else
                            {
                                this.direction = 1;
                            }
                            this.velocity.X = (float)this.direction;
                        }
                        if (this.collideY)
                        {
                            if (this.oldVelocity.Y > 0f)
                            {
                                this.directionY = -1;
                            }
                            else
                            {
                                this.directionY = 1;
                            }
                            this.velocity.Y = (float)this.directionY;
                        }
                        int num1077 = this.target;
                        int direction5 = this.direction;
                        if (this.target == 255 || Main.player[this.target].dead || Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[0] = 90f;
                            this.TargetClosest(true);
                        }
                        else if (this.ai[0] > 0f)
                        {
                            this.ai[0] -= 1f;
                            this.TargetClosest(true);
                        }
                        if (this.netUpdate && num1077 == this.target && direction5 == this.direction)
                        {
                            this.netUpdate = false;
                        }
                        float num1078 = 0.05f;
                        float num1079 = 0.01f;
                        float num1080 = 3f;
                        float num1081 = 1f;
                        float num1082 = 30f;
                        float num1083 = 100f;
                        float num1084 = Math.Abs(this.position.X + (float)(this.width / 2) - (Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)));
                        float num1085 = Main.player[this.target].position.Y - (float)(this.height / 2);
                        if (this.type == NPCID.FlyingAntlion)
                        {
                            num1078 = 0.09f;
                            num1079 = 0.03f;
                            num1080 = 5f;
                            num1081 = 2f;
                            num1082 = 40f;
                            num1083 = 150f;
                            num1085 = Main.player[this.target].Center.Y - (float)(this.height / 2);
                            this.rotation = this.velocity.X * 0.1f;
                            for (int num1086 = 0; num1086 < 200; num1086++)
                            {
                                if (num1086 != this.whoAmI && Main.npc[num1086].active && Main.npc[num1086].type == this.type && Math.Abs(this.position.X - Main.npc[num1086].position.X) + Math.Abs(this.position.Y - Main.npc[num1086].position.Y) < (float)this.width)
                                {
                                    if (this.position.X < Main.npc[num1086].position.X)
                                    {
                                        this.velocity.X = this.velocity.X - 0.05f;
                                    }
                                    else
                                    {
                                        this.velocity.X = this.velocity.X + 0.05f;
                                    }
                                    if (this.position.Y < Main.npc[num1086].position.Y)
                                    {
                                        this.velocity.Y = this.velocity.Y - 0.05f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.05f;
                                    }
                                }
                            }
                        }
                        if (this.ai[0] <= 0f)
                        {
                            num1080 *= 0.8f;
                            num1078 *= 0.7f;
                            num1085 = base.Center.Y + (float)(this.directionY * 1000);
                            if (this.velocity.X < 0f)
                            {
                                this.direction = -1;
                            }
                            else if (this.velocity.X > 0f || this.direction == 0)
                            {
                                this.direction = 1;
                            }
                        }
                        if (num1084 > num1082)
                        {
                            if (this.direction == -1 && this.velocity.X > -num1080)
                            {
                                this.velocity.X = this.velocity.X - num1078;
                                if (this.velocity.X > num1080)
                                {
                                    this.velocity.X = this.velocity.X - num1078;
                                }
                                else if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X - num1078 / 2f;
                                }
                                if (this.velocity.X < -num1080)
                                {
                                    this.velocity.X = -num1080;
                                }
                            }
                            else if (this.direction == 1 && this.velocity.X < num1080)
                            {
                                this.velocity.X = this.velocity.X + num1078;
                                if (this.velocity.X < -num1080)
                                {
                                    this.velocity.X = this.velocity.X + num1078;
                                }
                                else if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X + num1078 / 2f;
                                }
                                if (this.velocity.X > num1080)
                                {
                                    this.velocity.X = num1080;
                                }
                            }
                        }
                        if (num1084 > num1083)
                        {
                            num1085 -= num1083 / 2f;
                        }
                        if (this.position.Y < num1085)
                        {
                            this.velocity.Y = this.velocity.Y + num1079;
                            if (this.velocity.Y < 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num1079;
                            }
                        }
                        else
                        {
                            this.velocity.Y = this.velocity.Y - num1079;
                            if (this.velocity.Y > 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num1079;
                            }
                        }
                        if (this.velocity.Y < -num1081)
                        {
                            this.velocity.Y = -num1081;
                        }
                        if (this.velocity.Y > num1081)
                        {
                            this.velocity.Y = num1081;
                            return;
                        }
                    }
                    else if (this.aiStyle == 45)
                    {
                        NPC.golemBoss = this.whoAmI;
                        if (this.localAI[0] == 0f && Main.netMode != 1)
                        {
                            this.localAI[0] = 1f;
                            NPC.NewNPC((int)base.Center.X - 84, (int)base.Center.Y - 9, 247, 0, 0f, 0f, 0f, 0f, 255);
                            NPC.NewNPC((int)base.Center.X + 78, (int)base.Center.Y - 9, 248, 0, 0f, 0f, 0f, 0f, 255);
                            NPC.NewNPC((int)base.Center.X - 3, (int)base.Center.Y - 57, 246, 0, 0f, 0f, 0f, 0f, 255);
                        }
                        if (this.target >= 0 && Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                            if (Main.player[this.target].dead)
                            {
                                this.noTileCollide = true;
                            }
                        }
                        if (this.alpha > 0)
                        {
                            this.alpha -= 10;
                            if (this.alpha < 0)
                            {
                                this.alpha = 0;
                            }
                            this.ai[1] = 0f;
                        }
                        bool flag105 = false;
                        bool flag106 = false;
                        bool flag107 = false;
                        this.dontTakeDamage = false;
                        for (int num1087 = 0; num1087 < 200; num1087++)
                        {
                            if (Main.npc[num1087].active && Main.npc[num1087].type == NPCID.GolemHead)
                            {
                                flag105 = true;
                            }
                            if (Main.npc[num1087].active && Main.npc[num1087].type == NPCID.GolemFistLeft)
                            {
                                flag106 = true;
                            }
                            if (Main.npc[num1087].active && Main.npc[num1087].type == NPCID.GolemFistRight)
                            {
                                flag107 = true;
                            }
                        }
                        this.dontTakeDamage = flag105;
                        if (this.ai[0] == 0f)
                        {
                            this.noTileCollide = false;
                            if (this.velocity.Y == 0f)
                            {
                                this.velocity.X = this.velocity.X * 0.8f;
                                this.ai[1] += 1f;
                                if (this.ai[1] > 0f)
                                {
                                    if (!flag106)
                                    {
                                        this.ai[1] += 2f;
                                    }
                                    if (!flag107)
                                    {
                                        this.ai[1] += 2f;
                                    }
                                    if (!flag105)
                                    {
                                        this.ai[1] += 2f;
                                    }
                                    if (this.life < this.lifeMax)
                                    {
                                        this.ai[1] += 1f;
                                    }
                                    if (this.life < this.lifeMax / 2)
                                    {
                                        this.ai[1] += 4f;
                                    }
                                    if (this.life < this.lifeMax / 3)
                                    {
                                        this.ai[1] += 8f;
                                    }
                                }
                                if (this.ai[1] >= 300f)
                                {
                                    this.ai[1] = -20f;
                                    this.frameCounter = 0.0;
                                }
                                else if (this.ai[1] == -1f)
                                {
                                    this.TargetClosest(true);
                                    this.velocity.X = (float)(4 * this.direction);
                                    this.velocity.Y = -12.1f;
                                    this.ai[0] = 1f;
                                    this.ai[1] = 0f;
                                }
                            }
                        }
                        else if (this.ai[0] == 1f)
                        {
                            if (this.velocity.Y == 0f)
                            {
                                this.ai[0] = 0f;
                            }
                            else
                            {
                                this.TargetClosest(true);
                                if (this.position.X < Main.player[this.target].position.X && this.position.X + (float)this.width > Main.player[this.target].position.X + (float)Main.player[this.target].width)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                    this.velocity.Y = this.velocity.Y + 0.2f;
                                }
                                else
                                {
                                    if (this.direction < 0)
                                    {
                                        this.velocity.X = this.velocity.X - 0.2f;
                                    }
                                    else if (this.direction > 0)
                                    {
                                        this.velocity.X = this.velocity.X + 0.2f;
                                    }
                                    float num1094 = 3f;
                                    if (this.life < this.lifeMax)
                                    {
                                        num1094 += 1f;
                                    }
                                    if (this.life < this.lifeMax / 2)
                                    {
                                        num1094 += 1f;
                                    }
                                    if (this.life < this.lifeMax / 4)
                                    {
                                        num1094 += 1f;
                                    }
                                    if (this.velocity.X < -num1094)
                                    {
                                        this.velocity.X = -num1094;
                                    }
                                    if (this.velocity.X > num1094)
                                    {
                                        this.velocity.X = num1094;
                                    }
                                }
                            }
                        }
                        if (this.target <= 0 || this.target == 255 || Main.player[this.target].dead)
                        {
                            this.TargetClosest(true);
                        }
                        int num1095 = 3000;
                        if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)num1095)
                        {
                            this.TargetClosest(true);
                            if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)num1095)
                            {
                                this.active = false;
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 46)
                    {
                        this.noTileCollide = true;
                        if (NPC.golemBoss < 0)
                        {
                            this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                            return;
                        }
                        float num1096 = 12f;
                        Vector2 vector123 = new Vector2(base.Center.X, base.Center.Y);
                        float num1097 = Main.npc[NPC.golemBoss].Center.X - vector123.X;
                        float num1098 = Main.npc[NPC.golemBoss].Center.Y - vector123.Y;
                        num1098 -= 57f;
                        num1097 -= 3f;
                        float num1099 = (float)Math.Sqrt((double)(num1097 * num1097 + num1098 * num1098));
                        if (num1099 < 20f)
                        {
                            this.rotation = 0f;
                            this.velocity.X = num1097;
                            this.velocity.Y = num1098;
                        }
                        else
                        {
                            num1099 = num1096 / num1099;
                            this.velocity.X = num1097 * num1099;
                            this.velocity.Y = num1098 * num1099;
                            this.rotation = this.velocity.X * 0.1f;
                        }
                        if (this.alpha > 0)
                        {
                            this.alpha -= 10;
                            if (this.alpha < 0)
                            {
                                this.alpha = 0;
                            }
                            this.ai[1] = 30f;
                        }
                        if (this.ai[0] == 0f)
                        {
                            this.ai[1] += 1f;
                            int num1100 = 300;
                            if (this.ai[1] < 20f || this.ai[1] > (float)(num1100 - 20))
                            {
                                this.localAI[0] = 1f;
                            }
                            else
                            {
                                this.localAI[0] = 0f;
                            }
                            if (this.ai[1] >= (float)num1100)
                            {
                                this.TargetClosest(true);
                                this.ai[1] = 0f;
                                Vector2 vector124 = new Vector2(base.Center.X, base.Center.Y + 10f);
                                float num1101 = 8f;
                                float num1102 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector124.X;
                                float num1103 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector124.Y;
                                float num1104 = (float)Math.Sqrt((double)(num1102 * num1102 + num1103 * num1103));
                                num1104 = num1101 / num1104;
                                num1102 *= num1104;
                                num1103 *= num1104;
                                int num1105 = 18;
                                int num1106 = 258;
                                if (Main.netMode != 1)
                                {
                                    Projectile.NewProjectile(vector124.X, vector124.Y, num1102, num1103, num1106, num1105, 0f, Main.myPlayer, 0f, 0f);
                                }
                            }
                        }
                        else if (this.ai[0] == 1f)
                        {
                            this.TargetClosest(true);
                            Vector2 vector125 = new Vector2(base.Center.X, base.Center.Y + 10f);
                            if (Main.player[this.target].Center.X < base.Center.X - (float)this.width)
                            {
                                this.localAI[1] = -1f;
                                vector125.X -= 40f;
                            }
                            else if (Main.player[this.target].Center.X > base.Center.X + (float)this.width)
                            {
                                this.localAI[1] = 1f;
                                vector125.X += 40f;
                            }
                            else
                            {
                                this.localAI[1] = 0f;
                            }
                            this.ai[1] += 1f;
                            if ((double)this.life < (double)this.lifeMax * 0.4)
                            {
                                this.ai[1] += 1f;
                            }
                            if ((double)this.life < (double)this.lifeMax * 0.2)
                            {
                                this.ai[1] += 1f;
                            }
                            int num1107 = 300;
                            if (this.ai[1] < 20f || this.ai[1] > (float)(num1107 - 20))
                            {
                                this.localAI[0] = 1f;
                            }
                            else
                            {
                                this.localAI[0] = 0f;
                            }
                            if (this.ai[1] >= (float)num1107)
                            {
                                this.TargetClosest(true);
                                this.ai[1] = 0f;
                                float num1108 = 8f;
                                float num1109 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector125.X;
                                float num1110 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector125.Y;
                                float num1111 = (float)Math.Sqrt((double)(num1109 * num1109 + num1110 * num1110));
                                num1111 = num1108 / num1111;
                                num1109 *= num1111;
                                num1110 *= num1111;
                                int num1112 = 24;
                                int num1113 = 258;
                                if (Main.netMode != 1)
                                {
                                    Projectile.NewProjectile(vector125.X, vector125.Y, num1109, num1110, num1113, num1112, 0f, Main.myPlayer, 0f, 0f);
                                }
                            }
                            this.ai[2] += 1f;
                            if (this.life < this.lifeMax / 3)
                            {
                                this.ai[2] += 1f;
                            }
                            if (this.life < this.lifeMax / 4)
                            {
                                this.ai[2] += 1f;
                            }
                            if (this.life < this.lifeMax / 5)
                            {
                                this.ai[2] += 1f;
                            }
                            if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                            {
                                this.ai[2] += 4f;
                            }
                            if (this.ai[2] > (float)(60 + Main.rand.Next(600)))
                            {
                                this.ai[2] = 0f;
                                int num1114 = 28;
                                int num1115 = 259;
                                if (this.localAI[1] == 0f)
                                {
                                    for (int num1116 = 0; num1116 < 2; num1116++)
                                    {
                                        vector125 = new Vector2(base.Center.X, base.Center.Y - 22f);
                                        if (num1116 == 0)
                                        {
                                            vector125.X -= 18f;
                                        }
                                        else
                                        {
                                            vector125.X += 18f;
                                        }
                                        float num1117 = 11f;
                                        float num1118 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector125.X;
                                        float num1119 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector125.Y;
                                        float num1120 = (float)Math.Sqrt((double)(num1118 * num1118 + num1119 * num1119));
                                        num1120 = num1117 / num1120;
                                        num1118 *= num1120;
                                        num1119 *= num1120;
                                        vector125.X += num1118 * 3f;
                                        vector125.Y += num1119 * 3f;
                                        if (Main.netMode != 1)
                                        {
                                            int num1121 = Projectile.NewProjectile(vector125.X, vector125.Y, num1118, num1119, num1115, num1114, 0f, Main.myPlayer, 0f, 0f);
                                            Main.projectile[num1121].timeLeft = 300;
                                        }
                                    }
                                }
                                else if (this.localAI[1] != 0f)
                                {
                                    vector125 = new Vector2(base.Center.X, base.Center.Y - 22f);
                                    if (this.localAI[1] == -1f)
                                    {
                                        vector125.X -= 30f;
                                    }
                                    else if (this.localAI[1] == 1f)
                                    {
                                        vector125.X += 30f;
                                    }
                                    float num1122 = 12f;
                                    float num1123 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector125.X;
                                    float num1124 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector125.Y;
                                    float num1125 = (float)Math.Sqrt((double)(num1123 * num1123 + num1124 * num1124));
                                    num1125 = num1122 / num1125;
                                    num1123 *= num1125;
                                    num1124 *= num1125;
                                    vector125.X += num1123 * 3f;
                                    vector125.Y += num1124 * 3f;
                                    if (Main.netMode != 1)
                                    {
                                        int num1126 = Projectile.NewProjectile(vector125.X, vector125.Y, num1123, num1124, num1115, num1114, 0f, Main.myPlayer, 0f, 0f);
                                        Main.projectile[num1126].timeLeft = 300;
                                    }
                                }
                            }
                        }
                        if (this.life < this.lifeMax / 2)
                        {
                            this.ai[0] = 1f;
                            return;
                        }
                        this.ai[0] = 0f;
                        return;
                    }
                    else if (this.aiStyle == 47)
                    {
                        if (NPC.golemBoss < 0)
                        {
                            this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                            return;
                        }
                        if (this.alpha > 0)
                        {
                            this.alpha -= 10;
                            if (this.alpha < 0)
                            {
                                this.alpha = 0;
                            }
                            this.ai[1] = 0f;
                        }
                        if (this.ai[0] == 0f)
                        {
                            this.noTileCollide = true;
                            float num1127 = 14f;
                            if (this.life < this.lifeMax / 2)
                            {
                                num1127 += 3f;
                            }
                            if (this.life < this.lifeMax / 4)
                            {
                                num1127 += 3f;
                            }
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax)
                            {
                                num1127 += 8f;
                            }
                            Vector2 vector126 = new Vector2(base.Center.X, base.Center.Y);
                            float num1128 = Main.npc[NPC.golemBoss].Center.X - vector126.X;
                            float num1129 = Main.npc[NPC.golemBoss].Center.Y - vector126.Y;
                            num1129 -= 9f;
                            if (this.type == NPCID.GolemFistLeft)
                            {
                                num1128 -= 84f;
                            }
                            else
                            {
                                num1128 += 78f;
                            }
                            float num1130 = (float)Math.Sqrt((double)(num1128 * num1128 + num1129 * num1129));
                            if (num1130 < 12f + num1127)
                            {
                                this.rotation = 0f;
                                this.velocity.X = num1128;
                                this.velocity.Y = num1129;
                                this.ai[1] += 1f;
                                if (this.life < this.lifeMax / 2)
                                {
                                    this.ai[1] += 1f;
                                }
                                if (this.life < this.lifeMax / 4)
                                {
                                    this.ai[1] += 1f;
                                }
                                if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax)
                                {
                                    this.ai[1] += 10f;
                                }
                                if (this.ai[1] >= 60f)
                                {
                                    this.TargetClosest(true);
                                    if ((this.type == NPCID.GolemFistLeft && base.Center.X + 100f > Main.player[this.target].Center.X) || (this.type == NPCID.GolemFistRight && base.Center.X - 100f < Main.player[this.target].Center.X))
                                    {
                                        this.ai[1] = 0f;
                                        this.ai[0] = 1f;
                                        return;
                                    }
                                    this.ai[1] = 0f;
                                    return;
                                }
                            }
                            else
                            {
                                num1130 = num1127 / num1130;
                                this.velocity.X = num1128 * num1130;
                                this.velocity.Y = num1129 * num1130;
                                this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                if (this.type == NPCID.GolemFistLeft)
                                {
                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                    return;
                                }
                            }
                        }
                        else if (this.ai[0] == 1f)
                        {
                            this.noTileCollide = true;
                            this.collideX = false;
                            this.collideY = false;
                            float num1131 = 12f;
                            if (this.life < this.lifeMax / 2)
                            {
                                num1131 += 4f;
                            }
                            if (this.life < this.lifeMax / 4)
                            {
                                num1131 += 4f;
                            }
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax)
                            {
                                num1131 += 10f;
                            }
                            Vector2 vector127 = new Vector2(base.Center.X, base.Center.Y);
                            float num1132 = Main.player[this.target].Center.X - vector127.X;
                            float num1133 = Main.player[this.target].Center.Y - vector127.Y;
                            float num1134 = (float)Math.Sqrt((double)(num1132 * num1132 + num1133 * num1133));
                            num1134 = num1131 / num1134;
                            this.velocity.X = num1132 * num1134;
                            this.velocity.Y = num1133 * num1134;
                            this.ai[0] = 2f;
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                            if (this.type == NPCID.GolemFistLeft)
                            {
                                this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                return;
                            }
                        }
                        else if (this.ai[0] == 2f)
                        {
                            if (Math.Abs(this.velocity.X) > Math.Abs(this.velocity.Y))
                            {
                                if (this.velocity.X > 0f && base.Center.X > Main.player[this.target].Center.X)
                                {
                                    this.noTileCollide = false;
                                }
                                if (this.velocity.X < 0f && base.Center.X < Main.player[this.target].Center.X)
                                {
                                    this.noTileCollide = false;
                                }
                            }
                            else
                            {
                                if (this.velocity.Y > 0f && base.Center.Y > Main.player[this.target].Center.Y)
                                {
                                    this.noTileCollide = false;
                                }
                                if (this.velocity.Y < 0f && base.Center.Y < Main.player[this.target].Center.Y)
                                {
                                    this.noTileCollide = false;
                                }
                            }
                            Vector2 vector128 = new Vector2(base.Center.X, base.Center.Y);
                            float num1135 = Main.npc[NPC.golemBoss].Center.X - vector128.X;
                            float num1136 = Main.npc[NPC.golemBoss].Center.Y - vector128.Y;
                            num1135 += Main.npc[NPC.golemBoss].velocity.X;
                            num1136 += Main.npc[NPC.golemBoss].velocity.Y;
                            num1136 -= 9f;
                            if (this.type == NPCID.GolemFistLeft)
                            {
                                num1135 -= 84f;
                            }
                            else
                            {
                                num1135 += 78f;
                            }
                            float num1137 = (float)Math.Sqrt((double)(num1135 * num1135 + num1136 * num1136));
                            if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax)
                            {
                                this.knockBackResist = 0f;
                                if (num1137 > 700f || this.collideX || this.collideY)
                                {
                                    this.noTileCollide = true;
                                    this.ai[0] = 0f;
                                    return;
                                }
                            }
                            else
                            {
                                bool flag108 = this.justHit;
                                if (flag108)
                                {
                                    int num1138 = 0;
                                    while (num1138 < 200)
                                    {
                                        if (Main.npc[num1138].active && Main.npc[num1138].type == NPCID.GolemHead)
                                        {
                                            if (Main.npc[num1138].life < Main.npc[num1138].lifeMax / 2)
                                            {
                                                if (this.knockBackResist == 0f)
                                                {
                                                    flag108 = false;
                                                }
                                                this.knockBackResist = 0f;
                                                break;
                                            }
                                            break;
                                        }
                                        else
                                        {
                                            num1138++;
                                        }
                                    }
                                }
                                if (num1137 > 600f || this.collideX || this.collideY || flag108)
                                {
                                    this.noTileCollide = true;
                                    this.ai[0] = 0f;
                                    return;
                                }
                            }
                        }
                        else if (this.ai[0] == 3f)
                        {
                            this.noTileCollide = true;
                            float num1139 = 12f;
                            float num1140 = 0.4f;
                            Vector2 vector129 = new Vector2(base.Center.X, base.Center.Y);
                            float num1141 = Main.player[this.target].Center.X - vector129.X;
                            float num1142 = Main.player[this.target].Center.Y - vector129.Y;
                            float num1143 = (float)Math.Sqrt((double)(num1141 * num1141 + num1142 * num1142));
                            num1143 = num1139 / num1143;
                            num1141 *= num1143;
                            num1142 *= num1143;
                            if (this.velocity.X < num1141)
                            {
                                this.velocity.X = this.velocity.X + num1140;
                                if (this.velocity.X < 0f && num1141 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + num1140 * 2f;
                                }
                            }
                            else if (this.velocity.X > num1141)
                            {
                                this.velocity.X = this.velocity.X - num1140;
                                if (this.velocity.X > 0f && num1141 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - num1140 * 2f;
                                }
                            }
                            if (this.velocity.Y < num1142)
                            {
                                this.velocity.Y = this.velocity.Y + num1140;
                                if (this.velocity.Y < 0f && num1142 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + num1140 * 2f;
                                }
                            }
                            else if (this.velocity.Y > num1142)
                            {
                                this.velocity.Y = this.velocity.Y - num1140;
                                if (this.velocity.Y > 0f && num1142 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - num1140 * 2f;
                                }
                            }
                            this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                            if (this.type == NPCID.GolemFistLeft)
                            {
                                this.rotation = (float)Math.Atan2((double)(-(double)this.velocity.Y), (double)(-(double)this.velocity.X));
                                return;
                            }
                        }
                    }
                    else if (this.aiStyle == 48)
                    {
                        bool flag109 = false;
                        if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.noTileCollide = true;
                            flag109 = true;
                        }
                        else
                        {
                            this.noTileCollide = false;
                        }
                        if (NPC.golemBoss < 0)
                        {
                            this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                            return;
                        }
                        this.TargetClosest(true);
                        float num1144 = 7f;
                        float num1145 = 0.05f;
                        Vector2 vector130 = new Vector2(base.Center.X, base.Center.Y);
                        float num1146 = Main.player[this.target].Center.X - vector130.X;
                        float num1147 = Main.player[this.target].Center.Y - vector130.Y - 300f;
                        float num1148 = (float)Math.Sqrt((double)(num1146 * num1146 + num1147 * num1147));
                        num1148 = num1144 / num1148;
                        num1146 *= num1148;
                        num1147 *= num1148;
                        if (this.velocity.X < num1146)
                        {
                            this.velocity.X = this.velocity.X + num1145;
                            if (this.velocity.X < 0f && num1146 > 0f)
                            {
                                this.velocity.X = this.velocity.X + num1145;
                            }
                        }
                        else if (this.velocity.X > num1146)
                        {
                            this.velocity.X = this.velocity.X - num1145;
                            if (this.velocity.X > 0f && num1146 < 0f)
                            {
                                this.velocity.X = this.velocity.X - num1145;
                            }
                        }
                        if (this.velocity.Y < num1147)
                        {
                            this.velocity.Y = this.velocity.Y + num1145;
                            if (this.velocity.Y < 0f && num1147 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num1145;
                            }
                        }
                        else if (this.velocity.Y > num1147)
                        {
                            this.velocity.Y = this.velocity.Y - num1145;
                            if (this.velocity.Y > 0f && num1147 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num1145;
                            }
                        }
                        this.ai[1] += 1f;
                        if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.8)
                        {
                            this.ai[1] += 1f;
                        }
                        if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.6)
                        {
                            this.ai[1] += 1f;
                        }
                        if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.2)
                        {
                            this.ai[1] += 1f;
                        }
                        if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.1)
                        {
                            this.ai[1] += 1f;
                        }
                        int num1149 = 360;
                        if (this.ai[1] < 20f || this.ai[1] > (float)(num1149 - 20))
                        {
                            this.localAI[0] = 1f;
                        }
                        else
                        {
                            this.localAI[0] = 0f;
                        }
                        if (flag109)
                        {
                            this.ai[1] = 20f;
                        }
                        if (this.ai[1] >= (float)num1149)
                        {
                            this.TargetClosest(true);
                            this.ai[1] = 0f;
                            Vector2 vector131 = new Vector2(base.Center.X, base.Center.Y - 10f);
                            float num1150 = 8f;
                            int num1151 = 20;
                            int num1152 = 258;
                            float num1153 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector131.X;
                            float num1154 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector131.Y;
                            float num1155 = (float)Math.Sqrt((double)(num1153 * num1153 + num1154 * num1154));
                            num1155 = num1150 / num1155;
                            num1153 *= num1155;
                            num1154 *= num1155;
                            if (Main.netMode != 1)
                            {
                                Projectile.NewProjectile(vector131.X, vector131.Y, num1153, num1154, num1152, num1151, 0f, Main.myPlayer, 0f, 0f);
                            }
                        }
                        this.ai[2] += 1f;
                        if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax / 1.25)
                        {
                            this.ai[2] += 1f;
                        }
                        if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax / 1.5)
                        {
                            this.ai[2] += 1f;
                        }
                        if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 2)
                        {
                            this.ai[2] += 1f;
                        }
                        if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 3)
                        {
                            this.ai[2] += 1f;
                        }
                        if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 4)
                        {
                            this.ai[2] += 1f;
                        }
                        if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 5)
                        {
                            this.ai[2] += 1f;
                        }
                        if (Main.npc[NPC.golemBoss].life < Main.npc[NPC.golemBoss].lifeMax / 6)
                        {
                            this.ai[2] += 1f;
                        }
                        if (!Collision.CanHit(Main.npc[NPC.golemBoss].Center, 1, 1, Main.player[this.target].Center, 1, 1))
                        {
                            this.ai[2] += 4f;
                        }
                        if (this.ai[2] > (float)(100 + Main.rand.Next(4800)))
                        {
                            this.ai[2] = 0f;
                            for (int num1156 = 0; num1156 < 2; num1156++)
                            {
                                Vector2 vector132 = new Vector2(base.Center.X, base.Center.Y - 50f);
                                if (num1156 == 0)
                                {
                                    vector132.X -= 14f;
                                }
                                else if (num1156 == 1)
                                {
                                    vector132.X += 14f;
                                }
                                float num1157 = 11f;
                                int num1158 = 24;
                                int num1159 = 259;
                                if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.5)
                                {
                                    num1158++;
                                    num1157 += 0.25f;
                                }
                                if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.4)
                                {
                                    num1158++;
                                    num1157 += 0.25f;
                                }
                                if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.3)
                                {
                                    num1158++;
                                    num1157 += 0.25f;
                                }
                                if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.2)
                                {
                                    num1158++;
                                    num1157 += 0.25f;
                                }
                                if ((double)Main.npc[NPC.golemBoss].life < (double)Main.npc[NPC.golemBoss].lifeMax * 0.1)
                                {
                                    num1158++;
                                    num1157 += 0.25f;
                                }
                                float num1160 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector132.X;
                                float num1161 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector132.Y;
                                float num1162 = (float)Math.Sqrt((double)(num1160 * num1160 + num1161 * num1161));
                                num1162 = num1157 / num1162;
                                num1160 *= num1162;
                                num1161 *= num1162;
                                vector132.X += num1160 * 3f;
                                vector132.Y += num1161 * 3f;
                                if (Main.netMode != 1)
                                {
                                    int num1163 = Projectile.NewProjectile(vector132.X, vector132.Y, num1160, num1161, num1159, num1158, 0f, Main.myPlayer, 0f, 0f);
                                    Main.projectile[num1163].timeLeft = 300;
                                }
                            }
                            return;
                        }
                    }
                    else if (this.aiStyle == 49)
                    {
                        this.noGravity = true;
                        this.TargetClosest(true);
                        float num1164 = 4f;
                        float num1165 = 0.25f;
                        Vector2 vector133 = new Vector2(base.Center.X, base.Center.Y);
                        float num1166 = Main.player[this.target].Center.X - vector133.X;
                        float num1167 = Main.player[this.target].Center.Y - vector133.Y - 200f;
                        float num1168 = (float)Math.Sqrt((double)(num1166 * num1166 + num1167 * num1167));
                        if (num1168 < 20f)
                        {
                            num1166 = this.velocity.X;
                            num1167 = this.velocity.Y;
                        }
                        else
                        {
                            num1168 = num1164 / num1168;
                            num1166 *= num1168;
                            num1167 *= num1168;
                        }
                        if (this.velocity.X < num1166)
                        {
                            this.velocity.X = this.velocity.X + num1165;
                            if (this.velocity.X < 0f && num1166 > 0f)
                            {
                                this.velocity.X = this.velocity.X + num1165 * 2f;
                            }
                        }
                        else if (this.velocity.X > num1166)
                        {
                            this.velocity.X = this.velocity.X - num1165;
                            if (this.velocity.X > 0f && num1166 < 0f)
                            {
                                this.velocity.X = this.velocity.X - num1165 * 2f;
                            }
                        }
                        if (this.velocity.Y < num1167)
                        {
                            this.velocity.Y = this.velocity.Y + num1165;
                            if (this.velocity.Y < 0f && num1167 > 0f)
                            {
                                this.velocity.Y = this.velocity.Y + num1165 * 2f;
                            }
                        }
                        else if (this.velocity.Y > num1167)
                        {
                            this.velocity.Y = this.velocity.Y - num1165;
                            if (this.velocity.Y > 0f && num1167 < 0f)
                            {
                                this.velocity.Y = this.velocity.Y - num1165 * 2f;
                            }
                        }
                        if (this.position.X + (float)this.width > Main.player[this.target].position.X && this.position.X < Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y + (float)this.height < Main.player[this.target].position.Y && Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height) && Main.netMode != 1)
                        {
                            this.ai[0] += 1f;
                            if (this.ai[0] > 8f)
                            {
                                this.ai[0] = 0f;
                                int num1169 = (int)(this.position.X + 10f + (float)Main.rand.Next(this.width - 20));
                                int num1170 = (int)(this.position.Y + (float)this.height + 4f);
                                Projectile.NewProjectile((float)num1169, (float)num1170, 0f, 5f, 264, 20, 0f, Main.myPlayer, 0f, 0f);
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (this.aiStyle == 50)
                        {
                            if (this.timeLeft > 5)
                            {
                                this.timeLeft = 5;
                            }
                            this.noTileCollide = true;
                            this.velocity.Y = this.velocity.Y + 0.02f;
                            if (this.velocity.Y < 0f && !Main.expertMode)
                            {
                                this.velocity.Y = this.velocity.Y * 0.99f;
                            }
                            if (this.velocity.Y > 1f)
                            {
                                this.velocity.Y = 1f;
                            }
                            this.TargetClosest(true);
                            if (this.position.X + (float)this.width < Main.player[this.target].position.X)
                            {
                                if (this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                if (Main.expertMode && this.velocity.X < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                this.velocity.X = this.velocity.X + 0.1f;
                                if (Main.expertMode)
                                {
                                    this.velocity.X = this.velocity.X + 0.1f;
                                }
                            }
                            else if (this.position.X > Main.player[this.target].position.X + (float)Main.player[this.target].width)
                            {
                                if (this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                if (Main.expertMode && this.velocity.X > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.98f;
                                }
                                this.velocity.X = this.velocity.X - 0.1f;
                                if (Main.expertMode)
                                {
                                    this.velocity.X = this.velocity.X + 0.1f;
                                }
                            }
                            if (this.velocity.X > 5f || this.velocity.X < -5f)
                            {
                                this.velocity.X = this.velocity.X * 0.97f;
                            }
                            this.rotation = this.velocity.X * 0.2f;
                            return;
                        }
                        if (this.aiStyle == 51)
                        {
                            bool flag110 = false;
                            bool flag111 = false;
                            this.TargetClosest(true);
                            if (Main.player[this.target].dead)
                            {
                                flag111 = true;
                                flag110 = true;
                            }
                            if (Main.netMode != 1)
                            {
                                int num1171 = 6000;
                                if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)num1171)
                                {
                                    this.active = false;
                                    this.life = 0;
                                    if (Main.netMode == 2)
                                    {
                                        NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            NPC.plantBoss = this.whoAmI;
                            if (this.localAI[0] == 0f && Main.netMode != 1)
                            {
                                this.localAI[0] = 1f;
                                NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 263, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 263, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 263, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                            }
                            int[] array3 = new int[3];
                            float num1172 = 0f;
                            float num1173 = 0f;
                            int num1174 = 0;
                            for (int num1175 = 0; num1175 < 200; num1175++)
                            {
                                if (Main.npc[num1175].active && Main.npc[num1175].aiStyle == 52)
                                {
                                    num1172 += Main.npc[num1175].Center.X;
                                    num1173 += Main.npc[num1175].Center.Y;
                                    array3[num1174] = num1175;
                                    num1174++;
                                    if (num1174 > 2)
                                    {
                                        break;
                                    }
                                }
                            }
                            num1172 /= (float)num1174;
                            num1173 /= (float)num1174;
                            float num1176 = 2.5f;
                            float num1177 = 0.025f;
                            if (this.life < this.lifeMax / 2)
                            {
                                num1176 = 5f;
                                num1177 = 0.05f;
                            }
                            if (this.life < this.lifeMax / 4)
                            {
                                num1176 = 7f;
                            }
                            if (!Main.player[this.target].ZoneJungle || (double)Main.player[this.target].position.Y < Main.worldSurface * 16.0 || Main.player[this.target].position.Y > (float)((Main.maxTilesY - 200) * 16))
                            {
                                flag110 = true;
                                num1176 += 8f;
                                num1177 = 0.15f;
                            }
                            if (Main.expertMode)
                            {
                                num1176 += 1f;
                                num1176 *= 1.1f;
                                num1177 += 0.01f;
                                num1177 *= 1.1f;
                            }
                            Vector2 vector134 = new Vector2(num1172, num1173);
                            float num1178 = Main.player[this.target].Center.X - vector134.X;
                            float num1179 = Main.player[this.target].Center.Y - vector134.Y;
                            if (flag111)
                            {
                                num1179 *= -1f;
                                num1178 *= -1f;
                                num1176 += 8f;
                            }
                            float num1180 = (float)Math.Sqrt((double)(num1178 * num1178 + num1179 * num1179));
                            int num1181 = 500;
                            if (flag110)
                            {
                                num1181 += 350;
                            }
                            if (Main.expertMode)
                            {
                                num1181 += 150;
                            }
                            if (num1180 >= (float)num1181)
                            {
                                num1180 = (float)num1181 / num1180;
                                num1178 *= num1180;
                                num1179 *= num1180;
                            }
                            num1172 += num1178;
                            num1173 += num1179;
                            vector134 = new Vector2(base.Center.X, base.Center.Y);
                            num1178 = num1172 - vector134.X;
                            num1179 = num1173 - vector134.Y;
                            num1180 = (float)Math.Sqrt((double)(num1178 * num1178 + num1179 * num1179));
                            if (num1180 < num1176)
                            {
                                num1178 = this.velocity.X;
                                num1179 = this.velocity.Y;
                            }
                            else
                            {
                                num1180 = num1176 / num1180;
                                num1178 *= num1180;
                                num1179 *= num1180;
                            }
                            if (this.velocity.X < num1178)
                            {
                                this.velocity.X = this.velocity.X + num1177;
                                if (this.velocity.X < 0f && num1178 > 0f)
                                {
                                    this.velocity.X = this.velocity.X + num1177 * 2f;
                                }
                            }
                            else if (this.velocity.X > num1178)
                            {
                                this.velocity.X = this.velocity.X - num1177;
                                if (this.velocity.X > 0f && num1178 < 0f)
                                {
                                    this.velocity.X = this.velocity.X - num1177 * 2f;
                                }
                            }
                            if (this.velocity.Y < num1179)
                            {
                                this.velocity.Y = this.velocity.Y + num1177;
                                if (this.velocity.Y < 0f && num1179 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y + num1177 * 2f;
                                }
                            }
                            else if (this.velocity.Y > num1179)
                            {
                                this.velocity.Y = this.velocity.Y - num1177;
                                if (this.velocity.Y > 0f && num1179 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y - num1177 * 2f;
                                }
                            }
                            Vector2 vector135 = new Vector2(base.Center.X, base.Center.Y);
                            float num1182 = Main.player[this.target].Center.X - vector135.X;
                            float num1183 = Main.player[this.target].Center.Y - vector135.Y;
                            this.rotation = (float)Math.Atan2((double)num1183, (double)num1182) + 1.57f;
                            if (this.life > this.lifeMax / 2)
                            {
                                this.defense = 36;
                                this.damage = (int)(50f * Main.damageMultiplier);
                                if (flag110)
                                {
                                    this.defense *= 2;
                                    this.damage *= 2;
                                }
                                if (Main.netMode != 1)
                                {
                                    this.localAI[1] += 1f;
                                    if ((double)this.life < (double)this.lifeMax * 0.9)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.8)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.7)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.6)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if (flag110)
                                    {
                                        this.localAI[1] += 3f;
                                    }
                                    if (Main.expertMode)
                                    {
                                        this.localAI[1] += 1f;
                                    }
                                    if (Main.expertMode && this.justHit && Main.rand.Next(2) == 0)
                                    {
                                        this.localAI[3] = 1f;
                                    }
                                    if (this.localAI[1] > 80f)
                                    {
                                        this.localAI[1] = 0f;
                                        bool flag112 = Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height);
                                        if (this.localAI[3] > 0f)
                                        {
                                            flag112 = true;
                                            this.localAI[3] = 0f;
                                        }
                                        if (flag112)
                                        {
                                            Vector2 vector136 = new Vector2(base.Center.X, base.Center.Y);
                                            float num1184 = 15f;
                                            if (Main.expertMode)
                                            {
                                                num1184 = 17f;
                                            }
                                            float num1185 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector136.X;
                                            float num1186 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector136.Y;
                                            float num1187 = (float)Math.Sqrt((double)(num1185 * num1185 + num1186 * num1186));
                                            num1187 = num1184 / num1187;
                                            num1185 *= num1187;
                                            num1186 *= num1187;
                                            int num1188 = 22;
                                            int num1189 = 275;
                                            int maxValue8 = 4;
                                            int maxValue9 = 8;
                                            if (Main.expertMode)
                                            {
                                                maxValue8 = 2;
                                                maxValue9 = 6;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.8 && Main.rand.Next(maxValue8) == 0)
                                            {
                                                num1188 = 27;
                                                this.localAI[1] = -30f;
                                                num1189 = 276;
                                            }
                                            else if ((double)this.life < (double)this.lifeMax * 0.8 && Main.rand.Next(maxValue9) == 0)
                                            {
                                                num1188 = 31;
                                                this.localAI[1] = -120f;
                                                num1189 = 277;
                                            }
                                            if (flag110)
                                            {
                                                num1188 *= 2;
                                            }
                                            if (Main.expertMode)
                                            {
                                                num1188 = (int)((double)num1188 * 0.9);
                                            }
                                            vector136.X += num1185 * 3f;
                                            vector136.Y += num1186 * 3f;
                                            int num1190 = Projectile.NewProjectile(vector136.X, vector136.Y, num1185, num1186, num1189, num1188, 0f, Main.myPlayer, 0f, 0f);
                                            if (num1189 != 277)
                                            {
                                                Main.projectile[num1190].timeLeft = 300;
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                this.defense = 10;
                                this.damage = (int)(70f * Main.damageMultiplier);
                                if (flag110)
                                {
                                    this.defense *= 4;
                                    this.damage *= 2;
                                }
                                if (Main.netMode != 1)
                                {
                                    if (this.localAI[0] == 1f)
                                    {
                                        this.localAI[0] = 2f;
                                        for (int num1191 = 0; num1191 < 8; num1191++)
                                        {
                                            NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 264, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                        }
                                        if (Main.expertMode)
                                        {
                                            for (int num1192 = 0; num1192 < 200; num1192++)
                                            {
                                                if (Main.npc[num1192].active && Main.npc[num1192].aiStyle == 52)
                                                {
                                                    for (int num1193 = 0; num1193 < 3; num1193++)
                                                    {
                                                        int num1194 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 264, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num1194].ai[3] = (float)(num1192 + 1);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else if (Main.expertMode && Main.rand.Next(60) == 0)
                                    {
                                        int num1195 = 0;
                                        for (int num1196 = 0; num1196 < 200; num1196++)
                                        {
                                            if (Main.npc[num1196].active && Main.npc[num1196].type == NPCID.PlanterasTentacle && Main.npc[num1196].ai[3] == 0f)
                                            {
                                                num1195++;
                                            }
                                        }
                                        if (num1195 < 8 && Main.rand.Next((num1195 + 1) * 10) <= 1)
                                        {
                                            NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 264, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                        }
                                    }
                                }
                                if (this.localAI[2] == 0f)
                                {
                                    this.localAI[2] = 1f;
                                }
                                this.localAI[1] += 1f;
                                if ((double)this.life < (double)this.lifeMax * 0.4)
                                {
                                    this.localAI[1] += 1f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.3)
                                {
                                    this.localAI[1] += 1f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.2)
                                {
                                    this.localAI[1] += 1f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.1)
                                {
                                    this.localAI[1] += 1f;
                                }
                                if (this.localAI[1] >= 350f)
                                {
                                    float num1197 = 8f;
                                    Vector2 vector137 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                    float num1198 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector137.X + (float)Main.rand.Next(-10, 11);
                                    float num1199 = Math.Abs(num1198 * 0.2f);
                                    float num1200 = Main.player[this.target].position.Y + (float)Main.player[this.target].height * 0.5f - vector137.Y + (float)Main.rand.Next(-10, 11);
                                    if (num1200 > 0f)
                                    {
                                        num1199 = 0f;
                                    }
                                    num1200 -= num1199;
                                    float num1201 = (float)Math.Sqrt((double)(num1198 * num1198 + num1200 * num1200));
                                    num1201 = num1197 / num1201;
                                    num1198 *= num1201;
                                    num1200 *= num1201;
                                    int num1202 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 265, 0, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num1202].velocity.X = num1198;
                                    Main.npc[num1202].velocity.Y = num1200;
                                    Main.npc[num1202].netUpdate = true;
                                    this.localAI[1] = 0f;
                                    return;
                                }
                            }
                        }
                        else if (this.aiStyle == 52)
                        {
                            bool flag113 = false;
                            bool flag114 = false;
                            if (NPC.plantBoss < 0)
                            {
                                this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                                this.netUpdate = true;
                                return;
                            }
                            if (Main.player[Main.npc[NPC.plantBoss].target].dead)
                            {
                                flag114 = true;
                            }
                            if ((NPC.plantBoss != -1 && !Main.player[Main.npc[NPC.plantBoss].target].ZoneJungle) || (double)Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16.0 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > (float)((Main.maxTilesY - 200) * 16) || flag114)
                            {
                                this.localAI[0] -= 4f;
                                flag113 = true;
                            }
                            if (Main.netMode == 1)
                            {
                                if (this.ai[0] == 0f)
                                {
                                    this.ai[0] = (float)((int)(base.Center.X / 16f));
                                }
                                if (this.ai[1] == 0f)
                                {
                                    this.ai[1] = (float)((int)(base.Center.X / 16f));
                                }
                            }
                            if (Main.netMode != 1)
                            {
                                if (this.ai[0] == 0f || this.ai[1] == 0f)
                                {
                                    this.localAI[0] = 0f;
                                }
                                this.localAI[0] -= 1f;
                                if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2)
                                {
                                    this.localAI[0] -= 2f;
                                }
                                if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 4)
                                {
                                    this.localAI[0] -= 2f;
                                }
                                if (flag113)
                                {
                                    this.localAI[0] -= 6f;
                                }
                                if (!flag114 && this.localAI[0] <= 0f && this.ai[0] != 0f)
                                {
                                    for (int num1203 = 0; num1203 < 200; num1203++)
                                    {
                                        if (num1203 != this.whoAmI && Main.npc[num1203].active && Main.npc[num1203].type == this.type && (Main.npc[num1203].velocity.X != 0f || Main.npc[num1203].velocity.Y != 0f))
                                        {
                                            this.localAI[0] = (float)Main.rand.Next(60, 300);
                                        }
                                    }
                                }
                                if (this.localAI[0] <= 0f)
                                {
                                    this.localAI[0] = (float)Main.rand.Next(300, 600);
                                    bool flag115 = false;
                                    int num1204 = 0;
                                    while (!flag115 && num1204 <= 1000)
                                    {
                                        num1204++;
                                        int num1205 = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.X / 16f);
                                        int num1206 = (int)(Main.player[Main.npc[NPC.plantBoss].target].Center.Y / 16f);
                                        if (this.ai[0] == 0f)
                                        {
                                            num1205 = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.X + Main.npc[NPC.plantBoss].Center.X) / 32f);
                                            num1206 = (int)((Main.player[Main.npc[NPC.plantBoss].target].Center.Y + Main.npc[NPC.plantBoss].Center.Y) / 32f);
                                        }
                                        if (flag114)
                                        {
                                            num1205 = (int)Main.npc[NPC.plantBoss].position.X / 16;
                                            num1206 = (int)(Main.npc[NPC.plantBoss].position.Y + 400f) / 16;
                                        }
                                        int num1207 = 20;
                                        num1207 += (int)(100f * ((float)num1204 / 1000f));
                                        int num1208 = num1205 + Main.rand.Next(-num1207, num1207 + 1);
                                        int num1209 = num1206 + Main.rand.Next(-num1207, num1207 + 1);
                                        if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2 && Main.rand.Next(6) == 0)
                                        {
                                            this.TargetClosest(true);
                                            int num1210 = (int)(Main.player[this.target].Center.X / 16f);
                                            int num1211 = (int)(Main.player[this.target].Center.Y / 16f);
                                            if (Main.tile[num1210, num1211].wall > 0)
                                            {
                                                num1208 = num1210;
                                                num1209 = num1211;
                                            }
                                        }
                                        try
                                        {
                                            if (WorldGen.SolidTile(num1208, num1209) || (Main.tile[num1208, num1209].wall > 0 && (num1204 > 500 || Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2)))
                                            {
                                                flag115 = true;
                                                this.ai[0] = (float)num1208;
                                                this.ai[1] = (float)num1209;
                                                this.netUpdate = true;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                            if (this.ai[0] > 0f && this.ai[1] > 0f)
                            {
                                float num1212 = 6f;
                                if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2)
                                {
                                    num1212 = 8f;
                                }
                                if (Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 4)
                                {
                                    num1212 = 10f;
                                }
                                if (Main.expertMode)
                                {
                                    num1212 += 1f;
                                }
                                if (Main.expertMode && Main.npc[NPC.plantBoss].life < Main.npc[NPC.plantBoss].lifeMax / 2)
                                {
                                    num1212 += 1f;
                                }
                                if (flag113)
                                {
                                    num1212 *= 2f;
                                }
                                if (flag114)
                                {
                                    num1212 *= 2f;
                                }
                                Vector2 vector138 = new Vector2(base.Center.X, base.Center.Y);
                                float num1213 = this.ai[0] * 16f - 8f - vector138.X;
                                float num1214 = this.ai[1] * 16f - 8f - vector138.Y;
                                float num1215 = (float)Math.Sqrt((double)(num1213 * num1213 + num1214 * num1214));
                                if (num1215 < 12f + num1212)
                                {
                                    this.velocity.X = num1213;
                                    this.velocity.Y = num1214;
                                }
                                else
                                {
                                    num1215 = num1212 / num1215;
                                    this.velocity.X = num1213 * num1215;
                                    this.velocity.Y = num1214 * num1215;
                                }
                                Vector2 vector139 = new Vector2(base.Center.X, base.Center.Y);
                                float num1216 = Main.npc[NPC.plantBoss].Center.X - vector139.X;
                                float num1217 = Main.npc[NPC.plantBoss].Center.Y - vector139.Y;
                                this.rotation = (float)Math.Atan2((double)num1217, (double)num1216) - 1.57f;
                                return;
                            }
                        }
                        else if (this.aiStyle == 53)
                        {
                            if (NPC.plantBoss < 0)
                            {
                                this.StrikeNPCNoInteraction(9999, 0f, 0, false, false, false);
                                this.netUpdate = true;
                                return;
                            }
                            int num1218 = NPC.plantBoss;
                            if (this.ai[3] > 0f)
                            {
                                num1218 = (int)this.ai[3] - 1;
                            }
                            if (Main.netMode != 1)
                            {
                                this.localAI[0] -= 1f;
                                if (this.localAI[0] <= 0f)
                                {
                                    this.localAI[0] = (float)Main.rand.Next(120, 480);
                                    this.ai[0] = (float)Main.rand.Next(-100, 101);
                                    this.ai[1] = (float)Main.rand.Next(-100, 101);
                                    this.netUpdate = true;
                                }
                            }
                            this.TargetClosest(true);
                            float num1219 = 0.2f;
                            float num1220 = 200f;
                            if ((double)Main.npc[NPC.plantBoss].life < (double)Main.npc[NPC.plantBoss].lifeMax * 0.25)
                            {
                                num1220 += 100f;
                            }
                            if ((double)Main.npc[NPC.plantBoss].life < (double)Main.npc[NPC.plantBoss].lifeMax * 0.1)
                            {
                                num1220 += 100f;
                            }
                            if (Main.expertMode)
                            {
                                float num1221 = 1f - (float)this.life / (float)this.lifeMax;
                                num1220 += num1221 * 300f;
                                num1219 += 0.3f;
                            }
                            if (!Main.npc[num1218].active || NPC.plantBoss < 0)
                            {
                                this.active = false;
                                return;
                            }
                            float num1222 = Main.npc[num1218].position.X + (float)(Main.npc[num1218].width / 2);
                            float num1223 = Main.npc[num1218].position.Y + (float)(Main.npc[num1218].height / 2);
                            Vector2 vector140 = new Vector2(num1222, num1223);
                            float num1224 = num1222 + this.ai[0];
                            float num1225 = num1223 + this.ai[1];
                            float num1226 = num1224 - vector140.X;
                            float num1227 = num1225 - vector140.Y;
                            float num1228 = (float)Math.Sqrt((double)(num1226 * num1226 + num1227 * num1227));
                            num1228 = num1220 / num1228;
                            num1226 *= num1228;
                            num1227 *= num1228;
                            if (this.position.X < num1222 + num1226)
                            {
                                this.velocity.X = this.velocity.X + num1219;
                                if (this.velocity.X < 0f && num1226 > 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                            }
                            else if (this.position.X > num1222 + num1226)
                            {
                                this.velocity.X = this.velocity.X - num1219;
                                if (this.velocity.X > 0f && num1226 < 0f)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                }
                            }
                            if (this.position.Y < num1223 + num1227)
                            {
                                this.velocity.Y = this.velocity.Y + num1219;
                                if (this.velocity.Y < 0f && num1227 > 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                            }
                            else if (this.position.Y > num1223 + num1227)
                            {
                                this.velocity.Y = this.velocity.Y - num1219;
                                if (this.velocity.Y > 0f && num1227 < 0f)
                                {
                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                }
                            }
                            if (this.velocity.X > 8f)
                            {
                                this.velocity.X = 8f;
                            }
                            if (this.velocity.X < -8f)
                            {
                                this.velocity.X = -8f;
                            }
                            if (this.velocity.Y > 8f)
                            {
                                this.velocity.Y = 8f;
                            }
                            if (this.velocity.Y < -8f)
                            {
                                this.velocity.Y = -8f;
                            }
                            if (num1226 > 0f)
                            {
                                this.spriteDirection = 1;
                                this.rotation = (float)Math.Atan2((double)num1227, (double)num1226);
                            }
                            if (num1226 < 0f)
                            {
                                this.spriteDirection = -1;
                                this.rotation = (float)Math.Atan2((double)num1227, (double)num1226) + 3.14f;
                                return;
                            }
                        }
                        else if (this.aiStyle == 54)
                        {
                            NPC.crimsonBoss = this.whoAmI;
                            if (Main.netMode != 1 && this.localAI[0] == 0f)
                            {
                                this.localAI[0] = 1f;
                                for (int num1229 = 0; num1229 < 20; num1229++)
                                {
                                    float num1230 = base.Center.X;
                                    float num1231 = base.Center.Y;
                                    num1230 += (float)Main.rand.Next(-this.width, this.width);
                                    num1231 += (float)Main.rand.Next(-this.height, this.height);
                                    int num1232 = NPC.NewNPC((int)num1230, (int)num1231, 267, 0, 0f, 0f, 0f, 0f, 255);
                                    Main.npc[num1232].velocity = new Vector2((float)Main.rand.Next(-30, 31) * 0.1f, (float)Main.rand.Next(-30, 31) * 0.1f);
                                    Main.npc[num1232].netUpdate = true;
                                }
                            }
                            if (Main.netMode != 1)
                            {
                                this.TargetClosest(true);
                                int num1233 = 6000;
                                if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) + Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) > (float)num1233)
                                {
                                    this.active = false;
                                    this.life = 0;
                                    if (Main.netMode == 2)
                                    {
                                        NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                    }
                                }
                            }
                            if (this.ai[0] < 0f)
                            {
                                if (this.localAI[2] == 0f)
                                {
                                    this.localAI[2] = 1f;
                                }
                                this.dontTakeDamage = false;
                                this.knockBackResist = 0.5f;
                                if (Main.expertMode)
                                {
                                    this.knockBackResist *= Main.expertKnockBack;
                                }
                                this.TargetClosest(true);
                                Vector2 vector141 = new Vector2(base.Center.X, base.Center.Y);
                                float num1235 = Main.player[this.target].Center.X - vector141.X;
                                float num1236 = Main.player[this.target].Center.Y - vector141.Y;
                                float num1237 = (float)Math.Sqrt((double)(num1235 * num1235 + num1236 * num1236));
                                float num1238 = 8f;
                                num1237 = num1238 / num1237;
                                num1235 *= num1237;
                                num1236 *= num1237;
                                this.velocity.X = (this.velocity.X * 50f + num1235) / 51f;
                                this.velocity.Y = (this.velocity.Y * 50f + num1236) / 51f;
                                if (this.ai[0] == -1f)
                                {
                                    if (Main.netMode != 1)
                                    {
                                        this.localAI[1] += 1f;
                                        if (this.justHit)
                                        {
                                            this.localAI[1] -= (float)Main.rand.Next(5);
                                        }
                                        int num1239 = 60 + Main.rand.Next(120);
                                        if (Main.netMode != 0)
                                        {
                                            num1239 += Main.rand.Next(30, 90);
                                        }
                                        if (this.localAI[1] >= (float)num1239)
                                        {
                                            this.localAI[1] = 0f;
                                            this.TargetClosest(true);
                                            int num1240 = 0;
                                            int num1241;
                                            int num1242;
                                            while (true)
                                            {
                                                num1240++;
                                                num1241 = (int)Main.player[this.target].Center.X / 16;
                                                num1242 = (int)Main.player[this.target].Center.Y / 16;
                                                if (Main.rand.Next(2) == 0)
                                                {
                                                    num1241 += Main.rand.Next(7, 13);
                                                }
                                                else
                                                {
                                                    num1241 -= Main.rand.Next(7, 13);
                                                }
                                                if (Main.rand.Next(2) == 0)
                                                {
                                                    num1242 += Main.rand.Next(7, 13);
                                                }
                                                else
                                                {
                                                    num1242 -= Main.rand.Next(7, 13);
                                                }
                                                if (!WorldGen.SolidTile(num1241, num1242))
                                                {
                                                    break;
                                                }
                                                if (num1240 > 100)
                                                {
                                                    return;
                                                }
                                            }
                                            this.ai[3] = 0f;
                                            this.ai[0] = -2f;
                                            this.ai[1] = (float)num1241;
                                            this.ai[2] = (float)num1242;
                                            this.netUpdate = true;
                                            this.netSpam = 0;
                                            return;
                                        }
                                    }
                                }
                                else
                                {
                                    if (this.ai[0] == -2f)
                                    {
                                        this.velocity *= 0.9f;
                                        if (Main.netMode != 0)
                                        {
                                            this.ai[3] += 15f;
                                        }
                                        else
                                        {
                                            this.ai[3] += 25f;
                                        }
                                        if (this.ai[3] >= 255f)
                                        {
                                            this.ai[3] = 255f;
                                            this.position.X = this.ai[1] * 16f - (float)(this.width / 2);
                                            this.position.Y = this.ai[2] * 16f - (float)(this.height / 2);
                                            this.ai[0] = -3f;
                                            this.netUpdate = true;
                                            this.netSpam = 0;
                                        }
                                        this.alpha = (int)this.ai[3];
                                        return;
                                    }
                                    if (this.ai[0] == -3f)
                                    {
                                        if (Main.netMode != 0)
                                        {
                                            this.ai[3] -= 15f;
                                        }
                                        else
                                        {
                                            this.ai[3] -= 25f;
                                        }
                                        if (this.ai[3] <= 0f)
                                        {
                                            this.ai[3] = 0f;
                                            this.ai[0] = -1f;
                                            this.netUpdate = true;
                                            this.netSpam = 0;
                                        }
                                        this.alpha = (int)this.ai[3];
                                        return;
                                    }
                                }
                            }
                            else
                            {
                                this.TargetClosest(true);
                                Vector2 vector142 = new Vector2(base.Center.X, base.Center.Y);
                                float num1243 = Main.player[this.target].Center.X - vector142.X;
                                float num1244 = Main.player[this.target].Center.Y - vector142.Y;
                                float num1245 = (float)Math.Sqrt((double)(num1243 * num1243 + num1244 * num1244));
                                float num1246 = 1f;
                                if (num1245 < num1246)
                                {
                                    this.velocity.X = num1243;
                                    this.velocity.Y = num1244;
                                }
                                else
                                {
                                    num1245 = num1246 / num1245;
                                    this.velocity.X = num1243 * num1245;
                                    this.velocity.Y = num1244 * num1245;
                                }
                                if (this.ai[0] == 0f)
                                {
                                    if (Main.netMode != 1)
                                    {
                                        int num1247 = 0;
                                        for (int num1248 = 0; num1248 < 200; num1248++)
                                        {
                                            if (Main.npc[num1248].active && Main.npc[num1248].type == NPCID.Creeper)
                                            {
                                                num1247++;
                                            }
                                        }
                                        if (num1247 == 0)
                                        {
                                            this.ai[0] = -1f;
                                            this.localAI[1] = 0f;
                                            this.alpha = 0;
                                            this.netUpdate = true;
                                        }
                                        this.localAI[1] += 1f;
                                        if (this.localAI[1] >= (float)(120 + Main.rand.Next(300)))
                                        {
                                            this.localAI[1] = 0f;
                                            this.TargetClosest(true);
                                            int num1249 = 0;
                                            int num1250;
                                            int num1251;
                                            while (true)
                                            {
                                                num1249++;
                                                num1250 = (int)Main.player[this.target].Center.X / 16;
                                                num1251 = (int)Main.player[this.target].Center.Y / 16;
                                                num1250 += Main.rand.Next(-50, 51);
                                                num1251 += Main.rand.Next(-50, 51);
                                                if (!WorldGen.SolidTile(num1250, num1251) && Collision.CanHit(new Vector2((float)(num1250 * 16), (float)(num1251 * 16)), 1, 1, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                                {
                                                    break;
                                                }
                                                if (num1249 > 100)
                                                {
                                                    return;
                                                }
                                            }
                                            this.ai[0] = 1f;
                                            this.ai[1] = (float)num1250;
                                            this.ai[2] = (float)num1251;
                                            this.netUpdate = true;
                                            return;
                                        }
                                    }
                                }
                                else if (this.ai[0] == 1f)
                                {
                                    this.alpha += 5;
                                    if (this.alpha >= 255)
                                    {
                                        this.alpha = 255;
                                        this.position.X = this.ai[1] * 16f - (float)(this.width / 2);
                                        this.position.Y = this.ai[2] * 16f - (float)(this.height / 2);
                                        this.ai[0] = 2f;
                                        return;
                                    }
                                }
                                else if (this.ai[0] == 2f)
                                {
                                    this.alpha -= 5;
                                    if (this.alpha <= 0)
                                    {
                                        this.alpha = 0;
                                        this.ai[0] = 0f;
                                        return;
                                    }
                                }
                            }
                        }
                        else if (this.aiStyle == 55)
                        {
                            if (NPC.crimsonBoss < 0)
                            {
                                this.active = false;
                                this.netUpdate = true;
                                return;
                            }
                            if (this.ai[0] == 0f)
                            {
                                Vector2 vector143 = new Vector2(base.Center.X, base.Center.Y);
                                float num1252 = Main.npc[NPC.crimsonBoss].Center.X - vector143.X;
                                float num1253 = Main.npc[NPC.crimsonBoss].Center.Y - vector143.Y;
                                float num1254 = (float)Math.Sqrt((double)(num1252 * num1252 + num1253 * num1253));
                                if (num1254 > 90f)
                                {
                                    num1254 = 8f / num1254;
                                    num1252 *= num1254;
                                    num1253 *= num1254;
                                    this.velocity.X = (this.velocity.X * 15f + num1252) / 16f;
                                    this.velocity.Y = (this.velocity.Y * 15f + num1253) / 16f;
                                    return;
                                }
                                if (Math.Abs(this.velocity.X) + Math.Abs(this.velocity.Y) < 8f)
                                {
                                    this.velocity.Y = this.velocity.Y * 1.05f;
                                    this.velocity.X = this.velocity.X * 1.05f;
                                }
                                if (Main.netMode != 1 && ((Main.expertMode && Main.rand.Next(100) == 0) || Main.rand.Next(200) == 0))
                                {
                                    this.TargetClosest(true);
                                    vector143 = new Vector2(base.Center.X, base.Center.Y);
                                    num1252 = Main.player[this.target].Center.X - vector143.X;
                                    num1253 = Main.player[this.target].Center.Y - vector143.Y;
                                    num1254 = (float)Math.Sqrt((double)(num1252 * num1252 + num1253 * num1253));
                                    num1254 = 8f / num1254;
                                    this.velocity.X = num1252 * num1254;
                                    this.velocity.Y = num1253 * num1254;
                                    this.ai[0] = 1f;
                                    this.netUpdate = true;
                                    return;
                                }
                            }
                            else
                            {
                                if (Main.expertMode)
                                {
                                    Vector2 value15 = Main.player[this.target].Center - base.Center;
                                    value15.Normalize();
                                    value15 *= 9f;
                                    this.velocity = (this.velocity * 99f + value15) / 100f;
                                }
                                Vector2 vector144 = new Vector2(base.Center.X, base.Center.Y);
                                float num1255 = Main.npc[NPC.crimsonBoss].Center.X - vector144.X;
                                float num1256 = Main.npc[NPC.crimsonBoss].Center.Y - vector144.Y;
                                float num1257 = (float)Math.Sqrt((double)(num1255 * num1255 + num1256 * num1256));
                                if (num1257 > 700f || this.justHit)
                                {
                                    this.ai[0] = 0f;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (this.aiStyle == 56)
                            {
                                this.TargetClosest(true);
                                Vector2 vector145 = new Vector2(base.Center.X, base.Center.Y);
                                float num1258 = Main.player[this.target].Center.X - vector145.X;
                                float num1259 = Main.player[this.target].Center.Y - vector145.Y;
                                float num1260 = (float)Math.Sqrt((double)(num1258 * num1258 + num1259 * num1259));
                                float num1261 = 12f;
                                num1260 = num1261 / num1260;
                                num1258 *= num1260;
                                num1259 *= num1260;
                                this.velocity.X = (this.velocity.X * 100f + num1258) / 101f;
                                this.velocity.Y = (this.velocity.Y * 100f + num1259) / 101f;
                                this.rotation = (float)Math.Atan2((double)num1259, (double)num1258) - 1.57f;
                                return;
                            }
                            if (this.aiStyle == 57)
                            {
                                float num1263 = 2f;
                                this.noGravity = true;
                                this.noTileCollide = true;
                                if (!Main.dayTime)
                                {
                                    this.TargetClosest(true);
                                }
                                bool flag116 = false;
                                if ((double)this.life < (double)this.lifeMax * 0.75)
                                {
                                    num1263 = 3f;
                                }
                                if ((double)this.life < (double)this.lifeMax * 0.5)
                                {
                                    num1263 = 4f;
                                }
                                if (Main.dayTime)
                                {
                                    if (this.timeLeft > 10)
                                    {
                                        this.timeLeft = 10;
                                    }
                                    num1263 = 8f;
                                }
                                else if (this.ai[0] == 0f)
                                {
                                    this.ai[1] += 1f;
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        this.ai[1] += 1f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        this.ai[1] += 1f;
                                    }
                                    if (this.ai[1] >= 300f && Main.netMode != 1)
                                    {
                                        this.ai[1] = 0f;
                                        if ((double)this.life < (double)this.lifeMax * 0.25 && this.type != NPCID.Everscream)
                                        {
                                            this.ai[0] = (float)Main.rand.Next(3, 5);
                                        }
                                        else
                                        {
                                            this.ai[0] = (float)Main.rand.Next(1, 3);
                                        }
                                        this.netUpdate = true;
                                    }
                                }
                                else if (this.ai[0] == 1f)
                                {
                                    if (this.type == NPCID.Everscream)
                                    {
                                        flag116 = true;
                                        this.ai[1] += 1f;
                                        if (this.ai[1] % 5f == 0f)
                                        {
                                            Vector2 vector146 = new Vector2(this.position.X + 20f + (float)Main.rand.Next(this.width - 40), this.position.Y + 20f + (float)Main.rand.Next(this.height - 40));
                                            float num1264 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector146.X;
                                            float num1265 = Main.player[this.target].position.Y - vector146.Y;
                                            num1264 += (float)Main.rand.Next(-50, 51);
                                            num1265 += (float)Main.rand.Next(-50, 51);
                                            num1265 -= Math.Abs(num1264) * ((float)Main.rand.Next(0, 21) * 0.01f);
                                            float num1266 = (float)Math.Sqrt((double)(num1264 * num1264 + num1265 * num1265));
                                            float num1267 = 12.5f;
                                            num1266 = num1267 / num1266;
                                            num1264 *= num1266;
                                            num1265 *= num1266;
                                            num1264 *= 1f + (float)Main.rand.Next(-20, 21) * 0.02f;
                                            num1265 *= 1f + (float)Main.rand.Next(-20, 21) * 0.02f;
                                            Projectile.NewProjectile(vector146.X, vector146.Y, num1264, num1265, 345, 43, 0f, Main.myPlayer, (float)Main.rand.Next(0, 31), 0f);
                                        }
                                        if (this.ai[1] >= 180f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 0f;
                                        }
                                    }
                                    else
                                    {
                                        flag116 = true;
                                        this.ai[1] += 1f;
                                        if (this.ai[1] % 15f == 0f)
                                        {
                                            Vector2 vector147 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                            float num1268 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector147.X;
                                            float num1269 = Main.player[this.target].position.Y - vector147.Y;
                                            float num1270 = (float)Math.Sqrt((double)(num1268 * num1268 + num1269 * num1269));
                                            float num1271 = 10f;
                                            num1270 = num1271 / num1270;
                                            num1268 *= num1270;
                                            num1269 *= num1270;
                                            num1268 *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
                                            num1269 *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
                                            Projectile.NewProjectile(vector147.X, vector147.Y, num1268, num1269, 325, 50, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                        if (this.ai[1] >= 120f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 0f;
                                        }
                                    }
                                }
                                else if (this.ai[0] == 2f)
                                {
                                    if (this.type == NPCID.Everscream)
                                    {
                                        flag116 = true;
                                        this.ai[1] += 1f;
                                        if (this.ai[1] > 60f && this.ai[1] < 240f && this.ai[1] % 15f == 0f)
                                        {
                                            float num1272 = 4.5f;
                                            Vector2 vector148 = new Vector2(this.position.X + 20f + (float)Main.rand.Next(this.width - 40), this.position.Y + 60f + (float)Main.rand.Next(this.height - 80));
                                            float num1273 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector148.X;
                                            float num1274 = Main.player[this.target].position.Y - vector148.Y;
                                            num1274 -= Math.Abs(num1273) * 0.3f;
                                            num1272 += Math.Abs(num1273) * 0.004f;
                                            num1273 += (float)Main.rand.Next(-50, 51);
                                            num1274 -= (float)Main.rand.Next(50, 201);
                                            float num1275 = (float)Math.Sqrt((double)(num1273 * num1273 + num1274 * num1274));
                                            num1275 = num1272 / num1275;
                                            num1273 *= num1275;
                                            num1274 *= num1275;
                                            num1273 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                                            num1274 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                                            Projectile.NewProjectile(vector148.X, vector148.Y, num1273, num1274, 346, 57, 0f, Main.myPlayer, 0f, (float)Main.rand.Next(2));
                                        }
                                        if (this.ai[1] >= 300f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 0f;
                                        }
                                    }
                                    else
                                    {
                                        flag116 = true;
                                        this.ai[1] += 1f;
                                        if (this.ai[1] > 60f && this.ai[1] < 240f && this.ai[1] % 8f == 0f)
                                        {
                                            float num1276 = 10f;
                                            Vector2 vector149 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                            float num1277 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector149.X;
                                            float num1278 = Main.player[this.target].position.Y - vector149.Y;
                                            num1278 -= Math.Abs(num1277) * 0.3f;
                                            num1276 += Math.Abs(num1277) * 0.004f;
                                            if (num1276 > 14f)
                                            {
                                                num1276 = 14f;
                                            }
                                            num1277 += (float)Main.rand.Next(-50, 51);
                                            num1278 -= (float)Main.rand.Next(50, 201);
                                            float num1279 = (float)Math.Sqrt((double)(num1277 * num1277 + num1278 * num1278));
                                            num1279 = num1276 / num1279;
                                            num1277 *= num1279;
                                            num1278 *= num1279;
                                            num1277 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                                            num1278 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                                            Projectile.NewProjectile(vector149.X, vector149.Y, num1277, num1278, Main.rand.Next(326, 329), 40, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                        if (this.ai[1] >= 300f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 0f;
                                        }
                                    }
                                }
                                else if (this.ai[0] == 3f)
                                {
                                    num1263 = 4f;
                                    this.ai[1] += 1f;
                                    if (this.ai[1] % 30f == 0f)
                                    {
                                        Vector2 vector150 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                        float num1280 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector150.X;
                                        float num1281 = Main.player[this.target].position.Y - vector150.Y;
                                        float num1282 = (float)Math.Sqrt((double)(num1280 * num1280 + num1281 * num1281));
                                        float num1283 = 16f;
                                        num1282 = num1283 / num1282;
                                        num1280 *= num1282;
                                        num1281 *= num1282;
                                        num1280 *= 1f + (float)Main.rand.Next(-20, 21) * 0.001f;
                                        num1281 *= 1f + (float)Main.rand.Next(-20, 21) * 0.001f;
                                        Projectile.NewProjectile(vector150.X, vector150.Y, num1280, num1281, 325, 75, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                    if (this.ai[1] >= 120f)
                                    {
                                        this.ai[1] = 0f;
                                        this.ai[0] = 0f;
                                    }
                                }
                                else if (this.ai[0] == 4f)
                                {
                                    num1263 = 4f;
                                    this.ai[1] += 1f;
                                    if (this.ai[1] % 10f == 0f)
                                    {
                                        float num1284 = 12f;
                                        Vector2 vector151 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                        float num1285 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector151.X;
                                        float num1286 = Main.player[this.target].position.Y - vector151.Y;
                                        num1286 -= Math.Abs(num1285) * 0.2f;
                                        num1284 += Math.Abs(num1285) * 0.002f;
                                        if (num1284 > 16f)
                                        {
                                            num1284 = 16f;
                                        }
                                        num1285 += (float)Main.rand.Next(-50, 51);
                                        num1286 -= (float)Main.rand.Next(50, 201);
                                        float num1287 = (float)Math.Sqrt((double)(num1285 * num1285 + num1286 * num1286));
                                        num1287 = num1284 / num1287;
                                        num1285 *= num1287;
                                        num1286 *= num1287;
                                        num1285 *= 1f + (float)Main.rand.Next(-30, 31) * 0.005f;
                                        num1286 *= 1f + (float)Main.rand.Next(-30, 31) * 0.005f;
                                        Projectile.NewProjectile(vector151.X, vector151.Y, num1285, num1286, Main.rand.Next(326, 329), 50, 0f, Main.myPlayer, 0f, 0f);
                                    }
                                    if (this.ai[1] >= 240f)
                                    {
                                        this.ai[1] = 0f;
                                        this.ai[0] = 0f;
                                    }
                                }
                                if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 50f)
                                {
                                    flag116 = true;
                                }
                                if (flag116)
                                {
                                    this.velocity.X = this.velocity.X * 0.9f;
                                    if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                    {
                                        this.velocity.X = 0f;
                                    }
                                }
                                else
                                {
                                    if (this.direction > 0)
                                    {
                                        this.velocity.X = (this.velocity.X * 20f + num1263) / 21f;
                                    }
                                    if (this.direction < 0)
                                    {
                                        this.velocity.X = (this.velocity.X * 20f - num1263) / 21f;
                                    }
                                }
                                int num1288 = 80;
                                int num1289 = 20;
                                Vector2 position7 = new Vector2(base.Center.X - (float)(num1288 / 2), this.position.Y + (float)this.height - (float)num1289);
                                bool flag117 = false;
                                if (this.position.X < Main.player[this.target].position.X && this.position.X + (float)this.width > Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y + (float)this.height < Main.player[this.target].position.Y + (float)Main.player[this.target].height - 16f)
                                {
                                    flag117 = true;
                                }
                                if (flag117)
                                {
                                    this.velocity.Y = this.velocity.Y + 0.5f;
                                }
                                else if (Collision.SolidCollision(position7, num1288, num1289))
                                {
                                    if (this.velocity.Y > 0f)
                                    {
                                        this.velocity.Y = 0f;
                                    }
                                    if ((double)this.velocity.Y > -0.2)
                                    {
                                        this.velocity.Y = this.velocity.Y - 0.025f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y - 0.2f;
                                    }
                                    if (this.velocity.Y < -4f)
                                    {
                                        this.velocity.Y = -4f;
                                    }
                                }
                                else
                                {
                                    if (this.velocity.Y < 0f)
                                    {
                                        this.velocity.Y = 0f;
                                    }
                                    if ((double)this.velocity.Y < 0.1)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.025f;
                                    }
                                    else
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.5f;
                                    }
                                }
                                if (this.velocity.Y > 10f)
                                {
                                    this.velocity.Y = 10f;
                                    return;
                                }
                            }
                            else
                            {
                                if (this.aiStyle == 58)
                                {
                                    this.localAI[0] += 1f;
                                    if (this.localAI[0] > 6f)
                                    {
                                        this.localAI[0] = 0f;
                                        this.localAI[1] += 1f;
                                        if (this.localAI[1] > 4f)
                                        {
                                            this.localAI[1] = 0f;
                                        }
                                    }
                                    if (Main.netMode != 1)
                                    {
                                        this.localAI[2] += 1f;
                                        if (this.localAI[2] > 300f)
                                        {
                                            this.ai[3] = (float)Main.rand.Next(3);
                                            this.localAI[2] = 0f;
                                        }
                                        else if (this.ai[3] == 0f && this.localAI[2] % 30f == 0f && this.localAI[2] > 30f)
                                        {
                                            float num1290 = 5f;
                                            Vector2 vector152 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                            if (!WorldGen.SolidTile((int)vector152.X / 16, (int)vector152.Y / 16))
                                            {
                                                float num1291 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector152.X;
                                                float num1292 = Main.player[this.target].position.Y - vector152.Y;
                                                num1291 += (float)Main.rand.Next(-50, 51);
                                                num1292 += (float)Main.rand.Next(50, 201);
                                                num1292 *= 0.2f;
                                                float num1293 = (float)Math.Sqrt((double)(num1291 * num1291 + num1292 * num1292));
                                                num1293 = num1290 / num1293;
                                                num1291 *= num1293;
                                                num1292 *= num1293;
                                                num1291 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                                                num1292 *= 1f + (float)Main.rand.Next(-30, 31) * 0.01f;
                                                Projectile.NewProjectile(vector152.X, vector152.Y, num1291, num1292, Main.rand.Next(326, 329), 40, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                        }
                                    }
                                    if (this.ai[0] == 0f && Main.netMode != 1)
                                    {
                                        this.TargetClosest(true);
                                        this.ai[0] = 1f;
                                        int num1294 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 328, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                        Main.npc[num1294].ai[0] = -1f;
                                        Main.npc[num1294].ai[1] = (float)this.whoAmI;
                                        Main.npc[num1294].target = this.target;
                                        Main.npc[num1294].netUpdate = true;
                                        num1294 = NPC.NewNPC((int)(this.position.X + (float)(this.width / 2)), (int)this.position.Y + this.height / 2, 328, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                        Main.npc[num1294].ai[0] = 1f;
                                        Main.npc[num1294].ai[1] = (float)this.whoAmI;
                                        Main.npc[num1294].ai[3] = 150f;
                                        Main.npc[num1294].target = this.target;
                                        Main.npc[num1294].netUpdate = true;
                                    }
                                    if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                                    {
                                        this.TargetClosest(true);
                                        if (Main.player[this.target].dead || Math.Abs(this.position.X - Main.player[this.target].position.X) > 2000f || Math.Abs(this.position.Y - Main.player[this.target].position.Y) > 2000f)
                                        {
                                            this.ai[1] = 2f;
                                        }
                                    }
                                    if (Main.dayTime)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.3f;
                                        this.velocity.X = this.velocity.X * 0.9f;
                                    }
                                    else if (this.ai[1] == 0f)
                                    {
                                        this.ai[2] += 1f;
                                        if (this.ai[2] >= 300f)
                                        {
                                            if (this.ai[3] != 1f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                            }
                                            else
                                            {
                                                this.ai[2] = 0f;
                                                this.ai[1] = 1f;
                                                this.TargetClosest(true);
                                                this.netUpdate = true;
                                            }
                                        }
                                        Vector2 vector153 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num1295 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector153.X;
                                        float num1296 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - 200f - vector153.Y;
                                        float num1297 = (float)Math.Sqrt((double)(num1295 * num1295 + num1296 * num1296));
                                        float num1298 = 6f;
                                        if (this.ai[3] == 1f)
                                        {
                                            if (num1297 > 900f)
                                            {
                                                num1298 = 12f;
                                            }
                                            else if (num1297 > 600f)
                                            {
                                                num1298 = 10f;
                                            }
                                            else if (num1297 > 300f)
                                            {
                                                num1298 = 8f;
                                            }
                                        }
                                        if (num1297 > 50f)
                                        {
                                            num1297 = num1298 / num1297;
                                            this.velocity.X = (this.velocity.X * 14f + num1295 * num1297) / 15f;
                                            this.velocity.Y = (this.velocity.Y * 14f + num1296 * num1297) / 15f;
                                        }
                                    }
                                    else if (this.ai[1] == 1f)
                                    {
                                        this.ai[2] += 1f;
                                        if (this.ai[2] >= 600f || this.ai[3] != 1f)
                                        {
                                            this.ai[2] = 0f;
                                            this.ai[1] = 0f;
                                        }
                                        Vector2 vector154 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num1299 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector154.X;
                                        float num1300 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector154.Y;
                                        float num1301 = (float)Math.Sqrt((double)(num1299 * num1299 + num1300 * num1300));
                                        num1301 = 16f / num1301;
                                        this.velocity.X = (this.velocity.X * 49f + num1299 * num1301) / 50f;
                                        this.velocity.Y = (this.velocity.Y * 49f + num1300 * num1301) / 50f;
                                    }
                                    else if (this.ai[1] == 2f)
                                    {
                                        this.ai[1] = 3f;
                                        this.velocity.Y = this.velocity.Y + 0.1f;
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y * 0.95f;
                                        }
                                        this.velocity.X = this.velocity.X * 0.95f;
                                        if (this.timeLeft > 500)
                                        {
                                            this.timeLeft = 500;
                                        }
                                    }
                                    this.rotation = this.velocity.X * -0.02f;
                                    return;
                                }
                                if (this.aiStyle == 59)
                                {
                                    this.spriteDirection = -(int)this.ai[0];
                                    if (!Main.npc[(int)this.ai[1]].active || Main.npc[(int)this.ai[1]].aiStyle != 58)
                                    {
                                        this.ai[2] += 10f;
                                        if (this.ai[2] > 50f || Main.netMode != 2)
                                        {
                                            this.life = -1;
                                            this.HitEffect(0, 10.0);
                                            this.active = false;
                                        }
                                    }
                                    if (Main.netMode != 1 && Main.npc[(int)this.ai[1]].ai[3] == 2f)
                                    {
                                        this.localAI[1] += 1f;
                                        if (this.localAI[1] > 90f)
                                        {
                                            this.localAI[1] = 0f;
                                            float num1302 = 0.01f;
                                            Vector2 vector155 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f + 30f);
                                            float num1303 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector155.X;
                                            float num1304 = Main.player[this.target].position.Y - vector155.Y;
                                            float num1305 = (float)Math.Sqrt((double)(num1303 * num1303 + num1304 * num1304));
                                            num1305 = num1302 / num1305;
                                            num1303 *= num1305;
                                            num1304 *= num1305;
                                            Projectile.NewProjectile(base.Center.X, base.Center.Y, num1303, num1304, 329, 60, 0f, Main.myPlayer, this.rotation, (float)this.spriteDirection);
                                        }
                                    }
                                    if (Main.dayTime)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.3f;
                                        this.velocity.X = this.velocity.X * 0.9f;
                                        return;
                                    }
                                    if (this.ai[2] == 0f || this.ai[2] == 3f)
                                    {
                                        if (Main.npc[(int)this.ai[1]].ai[1] == 3f && this.timeLeft > 10)
                                        {
                                            this.timeLeft = 10;
                                        }
                                        this.ai[3] += 1f;
                                        if (this.ai[3] >= 180f)
                                        {
                                            this.ai[2] += 1f;
                                            this.ai[3] = 0f;
                                            this.netUpdate = true;
                                        }
                                        Vector2 vector156 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num1306 = (Main.player[this.target].Center.X + Main.npc[(int)this.ai[1]].Center.X) / 2f;
                                        float num1307 = (Main.player[this.target].Center.Y + Main.npc[(int)this.ai[1]].Center.Y) / 2f;
                                        num1306 += -170f * this.ai[0] - vector156.X;
                                        num1307 += 90f - vector156.Y;
                                        float num1308 = Math.Abs(Main.player[this.target].Center.X - Main.npc[(int)this.ai[1]].Center.X) + Math.Abs(Main.player[this.target].Center.Y - Main.npc[(int)this.ai[1]].Center.Y);
                                        if (num1308 > 700f)
                                        {
                                            num1306 = Main.npc[(int)this.ai[1]].Center.X - 170f * this.ai[0] - vector156.X;
                                            num1307 = Main.npc[(int)this.ai[1]].Center.Y + 90f - vector156.Y;
                                        }
                                        float num1309 = (float)Math.Sqrt((double)(num1306 * num1306 + num1307 * num1307));
                                        float num1310 = 6f;
                                        if (num1309 > 1000f)
                                        {
                                            num1310 = 21f;
                                        }
                                        else if (num1309 > 800f)
                                        {
                                            num1310 = 18f;
                                        }
                                        else if (num1309 > 600f)
                                        {
                                            num1310 = 15f;
                                        }
                                        else if (num1309 > 400f)
                                        {
                                            num1310 = 12f;
                                        }
                                        else if (num1309 > 200f)
                                        {
                                            num1310 = 9f;
                                        }
                                        if (this.ai[0] < 0f && base.Center.X > Main.npc[(int)this.ai[1]].Center.X)
                                        {
                                            num1306 -= 4f;
                                        }
                                        if (this.ai[0] > 0f && base.Center.X < Main.npc[(int)this.ai[1]].Center.X)
                                        {
                                            num1306 += 4f;
                                        }
                                        num1309 = num1310 / num1309;
                                        this.velocity.X = (this.velocity.X * 14f + num1306 * num1309) / 15f;
                                        this.velocity.Y = (this.velocity.Y * 14f + num1307 * num1309) / 15f;
                                        num1309 = (float)Math.Sqrt((double)(num1306 * num1306 + num1307 * num1307));
                                        if (num1309 > 20f)
                                        {
                                            this.rotation = (float)Math.Atan2((double)num1307, (double)num1306) + 1.57f;
                                            return;
                                        }
                                    }
                                    else if (this.ai[2] == 1f)
                                    {
                                        Vector2 vector157 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num1311 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector157.X;
                                        float num1312 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector157.Y;
                                        float num1313 = (float)Math.Sqrt((double)(num1311 * num1311 + num1312 * num1312));
                                        this.rotation = (float)Math.Atan2((double)num1312, (double)num1311) + 1.57f;
                                        this.velocity.X = this.velocity.X * 0.95f;
                                        this.velocity.Y = this.velocity.Y - 0.3f;
                                        if (this.velocity.Y < -14f)
                                        {
                                            this.velocity.Y = -14f;
                                        }
                                        if (this.position.Y < Main.npc[(int)this.ai[1]].position.Y - 200f)
                                        {
                                            this.TargetClosest(true);
                                            this.ai[2] = 2f;
                                            vector157 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            num1311 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector157.X;
                                            num1312 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector157.Y;
                                            num1313 = (float)Math.Sqrt((double)(num1311 * num1311 + num1312 * num1312));
                                            num1313 = 18f / num1313;
                                            this.velocity.X = num1311 * num1313;
                                            this.velocity.Y = num1312 * num1313;
                                            this.netUpdate = true;
                                            return;
                                        }
                                    }
                                    else if (this.ai[2] == 2f)
                                    {
                                        float num1314 = Math.Abs(base.Center.X - Main.npc[(int)this.ai[1]].Center.X) + Math.Abs(base.Center.Y - Main.npc[(int)this.ai[1]].Center.Y);
                                        if (this.position.Y > Main.player[this.target].position.Y || this.velocity.Y < 0f || num1314 > 800f)
                                        {
                                            this.ai[2] = 3f;
                                            return;
                                        }
                                    }
                                    else if (this.ai[2] == 4f)
                                    {
                                        Vector2 vector158 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                        float num1315 = Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 200f * this.ai[0] - vector158.X;
                                        float num1316 = Main.npc[(int)this.ai[1]].position.Y + 230f - vector158.Y;
                                        float num1317 = (float)Math.Sqrt((double)(num1315 * num1315 + num1316 * num1316));
                                        this.rotation = (float)Math.Atan2((double)num1316, (double)num1315) + 1.57f;
                                        this.velocity.Y = this.velocity.Y * 0.95f;
                                        this.velocity.X = this.velocity.X + 0.3f * -this.ai[0];
                                        if (this.velocity.X < -14f)
                                        {
                                            this.velocity.X = -14f;
                                        }
                                        if (this.velocity.X > 14f)
                                        {
                                            this.velocity.X = 14f;
                                        }
                                        if (this.position.X + (float)(this.width / 2) < Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) - 500f || this.position.X + (float)(this.width / 2) > Main.npc[(int)this.ai[1]].position.X + (float)(Main.npc[(int)this.ai[1]].width / 2) + 500f)
                                        {
                                            this.TargetClosest(true);
                                            this.ai[2] = 5f;
                                            vector158 = new Vector2(this.position.X + (float)this.width * 0.5f, this.position.Y + (float)this.height * 0.5f);
                                            num1315 = Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2) - vector158.X;
                                            num1316 = Main.player[this.target].position.Y + (float)(Main.player[this.target].height / 2) - vector158.Y;
                                            num1317 = (float)Math.Sqrt((double)(num1315 * num1315 + num1316 * num1316));
                                            num1317 = 17f / num1317;
                                            this.velocity.X = num1315 * num1317;
                                            this.velocity.Y = num1316 * num1317;
                                            this.netUpdate = true;
                                            return;
                                        }
                                    }
                                    else if (this.ai[2] == 5f)
                                    {
                                        float num1318 = Math.Abs(base.Center.X - Main.npc[(int)this.ai[1]].Center.X) + Math.Abs(base.Center.Y - Main.npc[(int)this.ai[1]].Center.Y);
                                        if ((this.velocity.X > 0f && this.position.X + (float)(this.width / 2) > Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)) || (this.velocity.X < 0f && this.position.X + (float)(this.width / 2) < Main.player[this.target].position.X + (float)(Main.player[this.target].width / 2)) || num1318 > 800f)
                                        {
                                            this.ai[2] = 0f;
                                            return;
                                        }
                                    }
                                }
                                else if (this.aiStyle == 60)
                                {
                                    if (Main.dayTime)
                                    {
                                        if (this.velocity.X > 0f)
                                        {
                                            this.velocity.X = this.velocity.X + 0.25f;
                                        }
                                        else
                                        {
                                            this.velocity.X = this.velocity.X - 0.25f;
                                        }
                                        this.velocity.Y = this.velocity.Y - 0.1f;
                                        this.rotation = this.velocity.X * 0.05f;
                                    }
                                    else if (this.ai[0] == 0f)
                                    {
                                        if (this.ai[2] == 0f)
                                        {
                                            this.TargetClosest(true);
                                            if (base.Center.X < Main.player[this.target].Center.X)
                                            {
                                                this.ai[2] = 1f;
                                            }
                                            else
                                            {
                                                this.ai[2] = -1f;
                                            }
                                        }
                                        this.TargetClosest(true);
                                        int num1319 = 800;
                                        float num1320 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                        if (base.Center.X < Main.player[this.target].Center.X && this.ai[2] < 0f && num1320 > (float)num1319)
                                        {
                                            this.ai[2] = 0f;
                                        }
                                        if (base.Center.X > Main.player[this.target].Center.X && this.ai[2] > 0f && num1320 > (float)num1319)
                                        {
                                            this.ai[2] = 0f;
                                        }
                                        float num1321 = 0.45f;
                                        float num1322 = 7f;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            num1321 = 0.55f;
                                            num1322 = 8f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            num1321 = 0.7f;
                                            num1322 = 10f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            num1321 = 0.8f;
                                            num1322 = 11f;
                                        }
                                        this.velocity.X = this.velocity.X + this.ai[2] * num1321;
                                        if (this.velocity.X > num1322)
                                        {
                                            this.velocity.X = num1322;
                                        }
                                        if (this.velocity.X < -num1322)
                                        {
                                            this.velocity.X = -num1322;
                                        }
                                        float num1323 = Main.player[this.target].position.Y - (this.position.Y + (float)this.height);
                                        if (num1323 < 150f)
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.2f;
                                        }
                                        if (num1323 > 200f)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.2f;
                                        }
                                        if (this.velocity.Y > 8f)
                                        {
                                            this.velocity.Y = 8f;
                                        }
                                        if (this.velocity.Y < -8f)
                                        {
                                            this.velocity.Y = -8f;
                                        }
                                        this.rotation = this.velocity.X * 0.05f;
                                        if ((num1320 < 500f || this.ai[3] < 0f) && this.position.Y < Main.player[this.target].position.Y)
                                        {
                                            this.ai[3] += 1f;
                                            int num1324 = 13;
                                            if ((double)this.life < (double)this.lifeMax * 0.75)
                                            {
                                                num1324 = 12;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.5)
                                            {
                                                num1324 = 11;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.25)
                                            {
                                                num1324 = 10;
                                            }
                                            num1324++;
                                            if (this.ai[3] > (float)num1324)
                                            {
                                                this.ai[3] = (float)(-(float)num1324);
                                            }
                                            if (this.ai[3] == 0f && Main.netMode != 1)
                                            {
                                                Vector2 vector159 = new Vector2(base.Center.X, base.Center.Y);
                                                vector159.X += this.velocity.X * 7f;
                                                float num1325 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector159.X;
                                                float num1326 = Main.player[this.target].Center.Y - vector159.Y;
                                                float num1327 = (float)Math.Sqrt((double)(num1325 * num1325 + num1326 * num1326));
                                                float num1328 = 6f;
                                                if ((double)this.life < (double)this.lifeMax * 0.75)
                                                {
                                                    num1328 = 7f;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.5)
                                                {
                                                    num1328 = 8f;
                                                }
                                                if ((double)this.life < (double)this.lifeMax * 0.25)
                                                {
                                                    num1328 = 9f;
                                                }
                                                num1327 = num1328 / num1327;
                                                num1325 *= num1327;
                                                num1326 *= num1327;
                                                Projectile.NewProjectile(vector159.X, vector159.Y, num1325, num1326, 348, 42, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                        }
                                        else if (this.ai[3] < 0f)
                                        {
                                            this.ai[3] += 1f;
                                        }
                                        if (Main.netMode != 1)
                                        {
                                            this.ai[1] += (float)Main.rand.Next(1, 4);
                                            if (this.ai[1] > 800f && num1320 < 600f)
                                            {
                                                this.ai[0] = -1f;
                                            }
                                        }
                                    }
                                    else if (this.ai[0] == 1f)
                                    {
                                        this.TargetClosest(true);
                                        float num1329 = 0.15f;
                                        float num1330 = 7f;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            num1329 = 0.17f;
                                            num1330 = 8f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            num1329 = 0.2f;
                                            num1330 = 9f;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            num1329 = 0.25f;
                                            num1330 = 10f;
                                        }
                                        num1329 -= 0.05f;
                                        num1330 -= 1f;
                                        if (base.Center.X < Main.player[this.target].Center.X)
                                        {
                                            this.velocity.X = this.velocity.X + num1329;
                                            if (this.velocity.X < 0f)
                                            {
                                                this.velocity.X = this.velocity.X * 0.98f;
                                            }
                                        }
                                        if (base.Center.X > Main.player[this.target].Center.X)
                                        {
                                            this.velocity.X = this.velocity.X - num1329;
                                            if (this.velocity.X > 0f)
                                            {
                                                this.velocity.X = this.velocity.X * 0.98f;
                                            }
                                        }
                                        if (this.velocity.X > num1330 || this.velocity.X < -num1330)
                                        {
                                            this.velocity.X = this.velocity.X * 0.95f;
                                        }
                                        float num1331 = Main.player[this.target].position.Y - (this.position.Y + (float)this.height);
                                        if (num1331 < 180f)
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.1f;
                                        }
                                        if (num1331 > 200f)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.1f;
                                        }
                                        if (this.velocity.Y > 6f)
                                        {
                                            this.velocity.Y = 6f;
                                        }
                                        if (this.velocity.Y < -6f)
                                        {
                                            this.velocity.Y = -6f;
                                        }
                                        this.rotation = this.velocity.X * 0.01f;
                                        if (Main.netMode != 1)
                                        {
                                            this.ai[3] += 1f;
                                            int num1332 = 15;
                                            if ((double)this.life < (double)this.lifeMax * 0.75)
                                            {
                                                num1332 = 14;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.5)
                                            {
                                                num1332 = 12;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.25)
                                            {
                                                num1332 = 10;
                                            }
                                            if ((double)this.life < (double)this.lifeMax * 0.1)
                                            {
                                                num1332 = 8;
                                            }
                                            num1332 += 3;
                                            if (this.ai[3] >= (float)num1332)
                                            {
                                                this.ai[3] = 0f;
                                                Vector2 vector160 = new Vector2(base.Center.X, this.position.Y + (float)this.height - 14f);
                                                int i2 = (int)(vector160.X / 16f);
                                                int j2 = (int)(vector160.Y / 16f);
                                                if (!WorldGen.SolidTile(i2, j2))
                                                {
                                                    float num1333 = this.velocity.Y;
                                                    if (num1333 < 0f)
                                                    {
                                                        num1333 = 0f;
                                                    }
                                                    num1333 += 3f;
                                                    float speedX2 = this.velocity.X * 0.25f;
                                                    Projectile.NewProjectile(vector160.X, vector160.Y, speedX2, num1333, 349, 37, 0f, Main.myPlayer, (float)Main.rand.Next(5), 0f);
                                                }
                                            }
                                        }
                                        if (Main.netMode != 1)
                                        {
                                            this.ai[1] += (float)Main.rand.Next(1, 4);
                                            if (this.ai[1] > 600f)
                                            {
                                                this.ai[0] = -1f;
                                            }
                                        }
                                    }
                                    else if (this.ai[0] == 2f)
                                    {
                                        this.TargetClosest(true);
                                        Vector2 vector161 = new Vector2(base.Center.X, base.Center.Y - 20f);
                                        float num1334 = (float)Main.rand.Next(-1000, 1001);
                                        float num1335 = (float)Main.rand.Next(-1000, 1001);
                                        float num1336 = (float)Math.Sqrt((double)(num1334 * num1334 + num1335 * num1335));
                                        float num1337 = 15f;
                                        this.velocity *= 0.95f;
                                        num1336 = num1337 / num1336;
                                        num1334 *= num1336;
                                        num1335 *= num1336;
                                        this.rotation += 0.2f;
                                        vector161.X += num1334 * 4f;
                                        vector161.Y += num1335 * 4f;
                                        this.ai[3] += 1f;
                                        int num1338 = 7;
                                        if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            num1338--;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            num1338 -= 2;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            num1338 -= 3;
                                        }
                                        if ((double)this.life < (double)this.lifeMax * 0.1)
                                        {
                                            num1338 -= 4;
                                        }
                                        if (this.ai[3] > (float)num1338)
                                        {
                                            this.ai[3] = 0f;
                                            Projectile.NewProjectile(vector161.X, vector161.Y, num1334, num1335, 349, 35, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                        if (Main.netMode != 1)
                                        {
                                            this.ai[1] += (float)Main.rand.Next(1, 4);
                                            if (this.ai[1] > 500f)
                                            {
                                                this.ai[0] = -1f;
                                            }
                                        }
                                    }
                                    if (this.ai[0] == -1f)
                                    {
                                        int num1339 = Main.rand.Next(3);
                                        this.TargetClosest(true);
                                        if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 1000f)
                                        {
                                            num1339 = 0;
                                        }
                                        this.ai[0] = (float)num1339;
                                        this.ai[1] = 0f;
                                        this.ai[2] = 0f;
                                        this.ai[3] = 0f;
                                        return;
                                    }
                                }
                                else if (this.aiStyle == 61)
                                {
                                    float num1340 = 2f;
                                    this.noGravity = true;
                                    this.noTileCollide = true;
                                    if (!Main.dayTime)
                                    {
                                        this.TargetClosest(true);
                                    }
                                    bool flag118 = false;
                                    if ((double)this.life < (double)this.lifeMax * 0.75)
                                    {
                                        num1340 = 3f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.5)
                                    {
                                        num1340 = 4f;
                                    }
                                    if ((double)this.life < (double)this.lifeMax * 0.25)
                                    {
                                        num1340 = 5f;
                                    }
                                    if (Main.dayTime)
                                    {
                                        if (this.timeLeft > 10)
                                        {
                                            this.timeLeft = 10;
                                        }
                                        num1340 = 8f;
                                        if (this.velocity.X == 0f)
                                        {
                                            this.velocity.X = 0.1f;
                                        }
                                    }
                                    else if (this.ai[0] == 0f)
                                    {
                                        this.ai[1] += 1f;
                                        if (this.ai[1] >= 300f && Main.netMode != 1)
                                        {
                                            this.TargetClosest(true);
                                            this.ai[1] = 0f;
                                            this.ai[0] = 1f;
                                            this.netUpdate = true;
                                        }
                                    }
                                    else if (this.ai[0] == 1f)
                                    {
                                        this.ai[1] += 1f;
                                        flag118 = true;
                                        int num1341 = 16;
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            num1341 = 8;
                                        }
                                        else if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            num1341 = 11;
                                        }
                                        else if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            num1341 = 14;
                                        }
                                        if (this.ai[1] % (float)num1341 == 0f)
                                        {
                                            Vector2 vector162 = new Vector2(base.Center.X + (float)(this.direction * 50), base.Center.Y + (float)Main.rand.Next(15, 36));
                                            float num1342 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector162.X;
                                            float num1343 = Main.player[this.target].Center.Y - vector162.Y;
                                            num1342 += (float)Main.rand.Next(-40, 41);
                                            num1343 += (float)Main.rand.Next(-40, 41);
                                            float num1344 = (float)Math.Sqrt((double)(num1342 * num1342 + num1343 * num1343));
                                            float num1345 = 15f;
                                            num1344 = num1345 / num1344;
                                            num1342 *= num1344;
                                            num1343 *= num1344;
                                            num1342 *= 1f + (float)Main.rand.Next(-20, 21) * 0.015f;
                                            num1343 *= 1f + (float)Main.rand.Next(-20, 21) * 0.015f;
                                            Projectile.NewProjectile(vector162.X, vector162.Y, num1342, num1343, 180, 36, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                        if (this.ai[1] > 240f)
                                        {
                                            this.ai[0] = 0f;
                                            this.ai[1] = 0f;
                                        }
                                    }
                                    if (Main.netMode != 1)
                                    {
                                        int num1346 = 600;
                                        int num1347 = 1200;
                                        int num1348 = 2700;
                                        if ((double)this.life < (double)this.lifeMax * 0.25)
                                        {
                                            num1346 = (int)((double)num1346 * 0.5);
                                            num1347 = (int)((double)num1347 * 0.5);
                                            num1348 = (int)((double)num1348 * 0.5);
                                        }
                                        else if ((double)this.life < (double)this.lifeMax * 0.5)
                                        {
                                            num1346 = (int)((double)num1346 * 0.75);
                                            num1347 = (int)((double)num1347 * 0.75);
                                            num1348 = (int)((double)num1348 * 0.75);
                                        }
                                        else if ((double)this.life < (double)this.lifeMax * 0.75)
                                        {
                                            num1346 = (int)((double)num1346 * 0.9);
                                            num1347 = (int)((double)num1347 * 0.9);
                                            num1348 = (int)((double)num1348 * 0.9);
                                        }
                                        if (Main.rand.Next(num1346) == 0)
                                        {
                                            Vector2 vector163 = new Vector2(base.Center.X - (float)(this.direction * 24), base.Center.Y - 64f);
                                            float num1349 = (float)(Main.rand.Next(1, 100) * this.direction);
                                            float num1350 = 1f;
                                            float num1351 = (float)Math.Sqrt((double)(num1349 * num1349 + num1350 * num1350));
                                            float num1352 = 1f;
                                            num1351 = num1352 / num1351;
                                            num1349 *= num1351;
                                            num1350 *= num1351;
                                            Projectile.NewProjectile(vector163.X, vector163.Y, num1349, num1350, 352, 80, 0f, Main.myPlayer, 0f, 0f);
                                        }
                                        if (Main.rand.Next(num1347) == 0)
                                        {
                                            this.localAI[1] = 1f;
                                        }
                                        if (this.localAI[1] >= 1f)
                                        {
                                            this.localAI[1] += 1f;
                                            int num1353 = 12;
                                            if (this.localAI[1] % (float)num1353 == 0f)
                                            {
                                                Vector2 vector164 = new Vector2(base.Center.X - (float)(this.direction * 24), base.Center.Y - 64f);
                                                float num1354 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector164.X;
                                                float num1355 = Main.player[this.target].Center.Y - vector164.Y;
                                                num1354 += (float)Main.rand.Next(-50, 51);
                                                num1355 += (float)Main.rand.Next(-50, 51);
                                                float num1356 = (float)Math.Sqrt((double)(num1354 * num1354 + num1355 * num1355));
                                                float num1357 = 12.5f;
                                                num1356 = num1357 / num1356;
                                                num1354 *= num1356;
                                                num1355 *= num1356;
                                                num1354 *= 1f + (float)Main.rand.Next(-20, 21) * 0.015f;
                                                num1355 *= 1f + (float)Main.rand.Next(-20, 21) * 0.015f;
                                                Projectile.NewProjectile(vector164.X, vector164.Y, num1354, num1355, 350, 42, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (this.localAI[1] >= 100f)
                                            {
                                                this.localAI[1] = 0f;
                                            }
                                        }
                                        if (Main.rand.Next(num1348) == 0)
                                        {
                                            this.localAI[2] = 2f;
                                        }
                                        if (this.localAI[2] > 0f)
                                        {
                                            this.localAI[2] += 1f;
                                            int num1358 = 9;
                                            if (this.localAI[2] % (float)num1358 == 0f)
                                            {
                                                Vector2 vector165 = new Vector2(base.Center.X - (float)(this.direction * 24), base.Center.Y - 64f);
                                                float num1359 = (float)Main.rand.Next(-100, 101);
                                                float num1360 = -300f;
                                                float num1361 = (float)Math.Sqrt((double)(num1359 * num1359 + num1360 * num1360));
                                                float num1362 = 11f;
                                                num1361 = num1362 / num1361;
                                                num1359 *= num1361;
                                                num1360 *= num1361;
                                                num1359 *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
                                                num1360 *= 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
                                                Projectile.NewProjectile(vector165.X, vector165.Y, num1359, num1360, 351, 50, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (this.localAI[2] >= 100f)
                                            {
                                                this.localAI[2] = 0f;
                                            }
                                        }
                                    }
                                    if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 50f)
                                    {
                                        flag118 = true;
                                    }
                                    if (flag118)
                                    {
                                        this.velocity.X = this.velocity.X * 0.9f;
                                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                        {
                                            this.velocity.X = 0f;
                                        }
                                    }
                                    else
                                    {
                                        if (this.direction > 0)
                                        {
                                            this.velocity.X = (this.velocity.X * 20f + num1340) / 21f;
                                        }
                                        if (this.direction < 0)
                                        {
                                            this.velocity.X = (this.velocity.X * 20f - num1340) / 21f;
                                        }
                                    }
                                    int num1363 = 80;
                                    int num1364 = 20;
                                    Vector2 position8 = new Vector2(base.Center.X - (float)(num1363 / 2), this.position.Y + (float)this.height - (float)num1364);
                                    bool flag119 = false;
                                    if (this.position.X < Main.player[this.target].position.X && this.position.X + (float)this.width > Main.player[this.target].position.X + (float)Main.player[this.target].width && this.position.Y + (float)this.height < Main.player[this.target].position.Y + (float)Main.player[this.target].height - 16f)
                                    {
                                        flag119 = true;
                                    }
                                    if (flag119)
                                    {
                                        this.velocity.Y = this.velocity.Y + 0.5f;
                                    }
                                    else if (Collision.SolidCollision(position8, num1363, num1364))
                                    {
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = 0f;
                                        }
                                        if ((double)this.velocity.Y > -0.2)
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.025f;
                                        }
                                        else
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.2f;
                                        }
                                        if (this.velocity.Y < -4f)
                                        {
                                            this.velocity.Y = -4f;
                                        }
                                    }
                                    else
                                    {
                                        if (this.velocity.Y < 0f)
                                        {
                                            this.velocity.Y = 0f;
                                        }
                                        if ((double)this.velocity.Y < 0.1)
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.025f;
                                        }
                                        else
                                        {
                                            this.velocity.Y = this.velocity.Y + 0.5f;
                                        }
                                    }
                                    if (this.velocity.Y > 10f)
                                    {
                                        this.velocity.Y = 10f;
                                        return;
                                    }
                                }
                                else if (this.aiStyle == 62)
                                {
                                    this.TargetClosest(true);
                                    this.rotation = Math.Abs(this.velocity.X) * (float)this.direction * 0.1f;
                                    this.spriteDirection = this.direction;
                                    float num1365 = 7f;
                                    Vector2 vector166 = new Vector2(base.Center.X + (float)(this.direction * 20), base.Center.Y + 6f);
                                    float num1366 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector166.X;
                                    float num1367 = Main.player[this.target].position.Y - vector166.Y;
                                    float num1368 = (float)Math.Sqrt((double)(num1366 * num1366 + num1367 * num1367));
                                    float num1369 = num1365 / num1368;
                                    num1366 *= num1369;
                                    num1367 *= num1369;
                                    bool flag120 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1);
                                    if (Main.dayTime)
                                    {
                                        int num1370 = 60;
                                        this.velocity.X = (this.velocity.X * (float)(num1370 - 1) - num1366) / (float)num1370;
                                        this.velocity.Y = (this.velocity.Y * (float)(num1370 - 1) - num1367) / (float)num1370;
                                        if (this.timeLeft > 10)
                                        {
                                            this.timeLeft = 10;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        if (num1368 > 600f || !flag120)
                                        {
                                            int num1371 = 60;
                                            this.velocity.X = (this.velocity.X * (float)(num1371 - 1) + num1366) / (float)num1371;
                                            this.velocity.Y = (this.velocity.Y * (float)(num1371 - 1) + num1367) / (float)num1371;
                                            return;
                                        }
                                        this.velocity *= 0.98f;
                                        if (Math.Abs(this.velocity.X) < 1f && Math.Abs(this.velocity.Y) < 1f && Main.netMode != 1)
                                        {
                                            this.localAI[0] += 1f;
                                            if (this.localAI[0] >= 15f)
                                            {
                                                this.localAI[0] = 0f;
                                                num1366 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector166.X;
                                                num1367 = Main.player[this.target].Center.Y - vector166.Y;
                                                num1366 += (float)Main.rand.Next(-35, 36);
                                                num1367 += (float)Main.rand.Next(-35, 36);
                                                num1366 *= 1f + (float)Main.rand.Next(-20, 21) * 0.015f;
                                                num1367 *= 1f + (float)Main.rand.Next(-20, 21) * 0.015f;
                                                num1368 = (float)Math.Sqrt((double)(num1366 * num1366 + num1367 * num1367));
                                                num1365 = 10f;
                                                num1369 = num1365 / num1368;
                                                num1366 *= num1369;
                                                num1367 *= num1369;
                                                num1366 *= 1f + (float)Main.rand.Next(-20, 21) * 0.0125f;
                                                num1367 *= 1f + (float)Main.rand.Next(-20, 21) * 0.0125f;
                                                Projectile.NewProjectile(vector166.X, vector166.Y, num1366, num1367, 180, 32, 0f, Main.myPlayer, 0f, 0f);
                                                return;
                                            }
                                        }
                                    }
                                }
                                else if (this.aiStyle == 63)
                                {
                                    this.TargetClosest(true);
                                    float num1372 = 11f;
                                    Vector2 vector167 = new Vector2(base.Center.X + (float)(this.direction * 20), base.Center.Y + 6f);
                                    float num1373 = Main.player[this.target].position.X + (float)Main.player[this.target].width * 0.5f - vector167.X;
                                    float num1374 = Main.player[this.target].Center.Y - vector167.Y;
                                    float num1375 = (float)Math.Sqrt((double)(num1373 * num1373 + num1374 * num1374));
                                    float num1376 = num1372 / num1375;
                                    num1373 *= num1376;
                                    num1374 *= num1376;
                                    if (Main.dayTime)
                                    {
                                        num1373 = -num1373;
                                        num1374 = -num1374;
                                    }
                                    this.ai[0] -= 1f;
                                    if (num1375 < 200f || this.ai[0] > 0f)
                                    {
                                        if (num1375 < 200f)
                                        {
                                            this.ai[0] = 20f;
                                        }
                                        if (this.velocity.X < 0f)
                                        {
                                            this.direction = -1;
                                        }
                                        else
                                        {
                                            this.direction = 1;
                                        }
                                        this.rotation += (float)this.direction * 0.3f;
                                        return;
                                    }
                                    this.velocity.X = (this.velocity.X * 50f + num1373) / 51f;
                                    this.velocity.Y = (this.velocity.Y * 50f + num1374) / 51f;
                                    if (num1375 < 350f)
                                    {
                                        this.velocity.X = (this.velocity.X * 10f + num1373) / 11f;
                                        this.velocity.Y = (this.velocity.Y * 10f + num1374) / 11f;
                                    }
                                    if (num1375 < 300f)
                                    {
                                        this.velocity.X = (this.velocity.X * 7f + num1373) / 8f;
                                        this.velocity.Y = (this.velocity.Y * 7f + num1374) / 8f;
                                    }
                                    this.rotation = this.velocity.X * 0.15f;
                                    return;
                                }
                                else
                                {
                                    if (this.aiStyle == 64)
                                    {
                                        float num1377 = this.ai[0];
                                        float num1378 = this.ai[1];
                                        if (Main.netMode != 1)
                                        {
                                            this.localAI[0] -= 1f;
                                            if (this.ai[3] == 0f)
                                            {
                                                this.ai[3] = (float)Main.rand.Next(75, 111) * 0.01f;
                                            }
                                            if (this.localAI[0] <= 0f)
                                            {
                                                this.TargetClosest(true);
                                                this.localAI[0] = (float)Main.rand.Next(60, 180);
                                                float num1379 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                                if (num1379 > 700f && this.localAI[3] == 0f)
                                                {
                                                    float num1380 = (float)Main.rand.Next(50, 151) * 0.01f;
                                                    if (num1379 > 1000f)
                                                    {
                                                        num1380 = (float)Main.rand.Next(150, 201) * 0.01f;
                                                    }
                                                    else if (num1379 > 850f)
                                                    {
                                                        num1380 = (float)Main.rand.Next(100, 151) * 0.01f;
                                                    }
                                                    int num1381 = this.direction * Main.rand.Next(100, 251);
                                                    int num1382 = Main.rand.Next(-50, 51);
                                                    if (this.position.Y > Main.player[this.target].position.Y - 100f)
                                                    {
                                                        num1382 -= Main.rand.Next(100, 251);
                                                    }
                                                    float num1383 = num1380 / (float)Math.Sqrt((double)(num1381 * num1381 + num1382 * num1382));
                                                    num1377 = (float)num1381 * num1383;
                                                    num1378 = (float)num1382 * num1383;
                                                }
                                                else
                                                {
                                                    this.localAI[3] = 1f;
                                                    float num1384 = (float)Main.rand.Next(5, 151) * 0.01f;
                                                    int num1385 = Main.rand.Next(-100, 101);
                                                    int num1386 = Main.rand.Next(-100, 101);
                                                    float num1387 = num1384 / (float)Math.Sqrt((double)(num1385 * num1385 + num1386 * num1386));
                                                    num1377 = (float)num1385 * num1387;
                                                    num1378 = (float)num1386 * num1387;
                                                }
                                                this.netUpdate = true;
                                            }
                                        }
                                        this.scale = this.ai[3];
                                        if (this.localAI[2] > 0f)
                                        {
                                            int i3 = (int)base.Center.X / 16;
                                            int j3 = (int)base.Center.Y / 16;
                                            this.localAI[2] -= 1f;
                                        }
                                        else if (this.localAI[1] > 0f)
                                        {
                                            this.localAI[1] -= 1f;
                                        }
                                        else
                                        {
                                            this.localAI[1] = (float)Main.rand.Next(30, 180);
                                            if (!Main.dayTime || (double)(this.position.Y / 16f) > Main.worldSurface + 10.0)
                                            {
                                                this.localAI[2] = (float)Main.rand.Next(10, 30);
                                            }
                                        }
                                        int num1388 = 80;
                                        this.velocity.X = (this.velocity.X * (float)(num1388 - 1) + num1377) / (float)num1388;
                                        this.velocity.Y = (this.velocity.Y * (float)(num1388 - 1) + num1378) / (float)num1388;
                                        if (this.velocity.Y > 0f)
                                        {
                                            int num1389 = 4;
                                            int num1390 = (int)base.Center.X / 16;
                                            int num1391 = (int)base.Center.Y / 16;
                                            for (int num1392 = num1391; num1392 < num1391 + num1389; num1392++)
                                            {
                                                if (Main.tile[num1390, num1392] != null && ((Main.tile[num1390, num1392].nactive() && Main.tileSolid[(int)Main.tile[num1390, num1392].type]) || Main.tile[num1390, num1392].liquid > 0))
                                                {
                                                    num1378 *= -1f;
                                                    if (this.velocity.Y > 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                                    }
                                                }
                                            }
                                        }
                                        if (this.velocity.Y < 0f)
                                        {
                                            int num1393 = 30;
                                            bool flag121 = false;
                                            int num1394 = (int)base.Center.X / 16;
                                            int num1395 = (int)base.Center.Y / 16;
                                            for (int num1396 = num1395; num1396 < num1395 + num1393; num1396++)
                                            {
                                                if (Main.tile[num1394, num1396] != null && Main.tile[num1394, num1396].nactive() && Main.tileSolid[(int)Main.tile[num1394, num1396].type])
                                                {
                                                    flag121 = true;
                                                }
                                            }
                                            if (!flag121)
                                            {
                                                num1378 *= -1f;
                                                if (this.velocity.Y < 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                                }
                                            }
                                        }
                                        if (this.collideX)
                                        {
                                            if (this.velocity.X < 0f)
                                            {
                                                num1377 = Math.Abs(num1377);
                                            }
                                            else
                                            {
                                                num1377 = -Math.Abs(num1377);
                                            }
                                            this.velocity.X = this.velocity.X * -0.2f;
                                        }
                                        if (this.velocity.X < 0f)
                                        {
                                            this.direction = -1;
                                        }
                                        if (this.velocity.X > 0f)
                                        {
                                            this.direction = 1;
                                        }
                                        this.ai[0] = num1377;
                                        this.ai[1] = num1378;
                                        return;
                                    }
                                    if (this.aiStyle == 65)
                                    {
                                        float num1397 = this.ai[0];
                                        float num1398 = this.ai[1];
                                        if (Main.netMode != 1)
                                        {
                                            if (this.ai[2] == 0f)
                                            {
                                                int num1399 = 0;
                                                int num1400 = 4;
                                                int num1401 = 6;
                                                int num1402 = 3;
                                                int num1403 = 7;
                                                int num1404 = 2;
                                                int num1405 = 1;
                                                int num1406 = 5;
                                                int num1407 = Main.rand.Next(100);
                                                if (num1407 == 0)
                                                {
                                                    num1407 = num1406;
                                                }
                                                else if (num1407 < 3)
                                                {
                                                    num1407 = num1405;
                                                }
                                                else if (num1407 < 9)
                                                {
                                                    num1407 = num1404;
                                                }
                                                else if (num1407 < 19)
                                                {
                                                    num1407 = num1403;
                                                }
                                                else if (num1407 < 34)
                                                {
                                                    num1407 = num1402;
                                                }
                                                else if (num1407 < 53)
                                                {
                                                    num1407 = num1401;
                                                }
                                                else if (num1407 < 75)
                                                {
                                                    num1407 = num1400;
                                                }
                                                else
                                                {
                                                    num1407 = num1399;
                                                }
                                                this.ai[2] = (float)(1 + num1407);
                                            }
                                            if (this.ai[3] == 0f)
                                            {
                                                this.ai[3] = (float)Main.rand.Next(75, 111) * 0.01f;
                                            }
                                            this.localAI[0] -= 1f;
                                            if (this.localAI[0] <= 0f)
                                            {
                                                this.TargetClosest(true);
                                                this.localAI[0] = (float)Main.rand.Next(90, 240);
                                                float num1408 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                                if (num1408 > 700f && this.localAI[3] == 0f)
                                                {
                                                    float num1409 = (float)Main.rand.Next(50, 151) * 0.01f;
                                                    if (num1408 > 1000f)
                                                    {
                                                        num1409 = (float)Main.rand.Next(150, 201) * 0.01f;
                                                    }
                                                    else if (num1408 > 850f)
                                                    {
                                                        num1409 = (float)Main.rand.Next(100, 151) * 0.01f;
                                                    }
                                                    int num1410 = this.direction * Main.rand.Next(100, 251);
                                                    int num1411 = Main.rand.Next(-50, 51);
                                                    if (this.position.Y > Main.player[this.target].position.Y - 100f)
                                                    {
                                                        num1411 -= Main.rand.Next(100, 251);
                                                    }
                                                    float num1412 = num1409 / (float)Math.Sqrt((double)(num1410 * num1410 + num1411 * num1411));
                                                    num1397 = (float)num1410 * num1412;
                                                    num1398 = (float)num1411 * num1412;
                                                }
                                                else
                                                {
                                                    this.localAI[3] = 1f;
                                                    float num1413 = (float)Main.rand.Next(26, 301) * 0.01f;
                                                    int num1414 = Main.rand.Next(-100, 101);
                                                    int num1415 = Main.rand.Next(-100, 101);
                                                    float num1416 = num1413 / (float)Math.Sqrt((double)(num1414 * num1414 + num1415 * num1415));
                                                    num1397 = (float)num1414 * num1416;
                                                    num1398 = (float)num1415 * num1416;
                                                }
                                                this.netUpdate = true;
                                            }
                                        }
                                        this.scale = this.ai[3];
                                        int num1417 = 60;
                                        this.velocity.X = (this.velocity.X * (float)(num1417 - 1) + num1397) / (float)num1417;
                                        this.velocity.Y = (this.velocity.Y * (float)(num1417 - 1) + num1398) / (float)num1417;
                                        if (this.velocity.Y > 0f)
                                        {
                                            int num1418 = 3;
                                            int num1419 = (int)base.Center.X / 16;
                                            int num1420 = (int)base.Center.Y / 16;
                                            for (int num1421 = num1420; num1421 < num1420 + num1418; num1421++)
                                            {
                                                if (Main.tile[num1419, num1421] != null && ((Main.tile[num1419, num1421].nactive() && Main.tileSolid[(int)Main.tile[num1419, num1421].type]) || Main.tile[num1419, num1421].liquid > 0))
                                                {
                                                    num1398 *= -1f;
                                                    if (this.velocity.Y > 0f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.9f;
                                                    }
                                                }
                                            }
                                        }
                                        if (this.velocity.Y < 0f)
                                        {
                                            int num1422 = 30;
                                            bool flag122 = false;
                                            int num1423 = (int)base.Center.X / 16;
                                            int num1424 = (int)base.Center.Y / 16;
                                            for (int num1425 = num1424; num1425 < num1424 + num1422; num1425++)
                                            {
                                                if (Main.tile[num1423, num1425] != null && Main.tile[num1423, num1425].nactive() && Main.tileSolid[(int)Main.tile[num1423, num1425].type])
                                                {
                                                    flag122 = true;
                                                }
                                            }
                                            if (!flag122)
                                            {
                                                num1398 *= -1f;
                                                if (this.velocity.Y < 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y * 0.9f;
                                                }
                                            }
                                        }
                                        if (this.collideX)
                                        {
                                            if (this.velocity.X < 0f)
                                            {
                                                num1397 = Math.Abs(num1397);
                                            }
                                            else
                                            {
                                                num1397 = -Math.Abs(num1397);
                                            }
                                            this.velocity.X = this.velocity.X * -0.2f;
                                        }
                                        if (this.velocity.X < 0f)
                                        {
                                            this.direction = -1;
                                        }
                                        if (this.velocity.X > 0f)
                                        {
                                            this.direction = 1;
                                        }
                                        this.ai[0] = num1397;
                                        this.ai[1] = num1398;
                                        if (this.type == NPCID.Butterfly)
                                        {
                                            this.catchItem = (short)(1994f + this.ai[2] - 1f);
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 66)
                                    {
                                        if (this.type == NPCID.EnchantedNightcrawler)
                                        {
                                            float num1426 = (float)Main.rand.Next(90, 111) * 0.01f;
                                            num1426 *= (Main.essScale + 0.5f) / 2f;
                                        }
                                        if (this.type == NPCID.Worm || this.type == NPCID.GoldWorm || (this.type >= NPCID.EnchantedNightcrawler && this.type <= NPCID.Buggy))
                                        {
                                            if (this.localAI[2] < 90f)
                                            {
                                                this.localAI[2] += 1f;
                                            }
                                            else
                                            {
                                                this.friendly = false;
                                            }
                                        }
                                        if (this.velocity.Y == 0f)
                                        {
                                            if (this.ai[0] == 1f)
                                            {
                                                if (this.direction == 0)
                                                {
                                                    this.TargetClosest(true);
                                                }
                                                if (this.collideX)
                                                {
                                                    this.direction *= -1;
                                                }
                                                float num1427 = 0.2f;
                                                if (this.type == NPCID.Grubby)
                                                {
                                                    num1427 = 0.25f;
                                                }
                                                if (this.type == NPCID.Sluggy)
                                                {
                                                    num1427 = 0.325f;
                                                }
                                                if (this.type == NPCID.Buggy)
                                                {
                                                    num1427 = 0.4f;
                                                }
                                                this.velocity.X = num1427 * (float)this.direction;
                                                if (this.type == NPCID.TruffleWorm)
                                                {
                                                    this.velocity.X = this.velocity.X * 3f;
                                                }
                                            }
                                            else
                                            {
                                                this.velocity.X = 0f;
                                            }
                                            if (Main.netMode != 1)
                                            {
                                                this.localAI[1] -= 1f;
                                                if (this.localAI[1] <= 0f)
                                                {
                                                    if (this.ai[0] == 1f)
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.localAI[1] = (float)Main.rand.Next(300, 900);
                                                    }
                                                    else
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.localAI[1] = (float)Main.rand.Next(600, 1800);
                                                    }
                                                    this.netUpdate = true;
                                                }
                                            }
                                        }
                                        if (this.type == NPCID.TruffleWorm)
                                        {
                                            this.spriteDirection = this.direction;
                                            bool flag123 = false;
                                            for (int num1428 = 0; num1428 < 255; num1428++)
                                            {
                                                Player player4 = Main.player[num1428];
                                                if (player4.active && !player4.dead && Vector2.Distance(player4.Center, base.Center) <= 160f)
                                                {
                                                    flag123 = true;
                                                    break;
                                                }
                                            }
                                            int num1429 = 90;
                                            if (flag123 && this.ai[1] < (float)num1429)
                                            {
                                                this.ai[1] += 1f;
                                            }
                                            if (this.ai[1] == (float)num1429 && Main.netMode != 1)
                                            {
                                                this.position.Y = this.position.Y + 16f;
                                                this.Transform(375);
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 67)
                                    {
                                        if (this.type == NPCID.Snail)
                                        {
                                            if (this.ai[3] != 0f)
                                            {
                                                this.scale = this.ai[3];
                                                int num1430 = (int)(12f * this.scale);
                                                int num1431 = (int)(12f * this.scale);
                                                if (num1430 != this.width)
                                                {
                                                    this.position.X = this.position.X + (float)(this.width / 2) - (float)num1430 - 2f;
                                                    this.width = num1430;
                                                }
                                                if (num1431 != this.height)
                                                {
                                                    this.position.Y = this.position.Y + (float)this.height - (float)num1431;
                                                    this.height = num1431;
                                                }
                                            }
                                            if (this.ai[3] == 0f && Main.netMode != 1)
                                            {
                                                this.ai[3] = (float)Main.rand.Next(80, 111) * 0.01f;
                                                this.netUpdate = true;
                                            }
                                        }
                                        float num1432 = 0.3f;
                                        if (this.type == NPCID.GlowingSnail)
                                        {
                                            num1432 = 0.6f;
                                        }
                                        if (this.ai[0] == 0f)
                                        {
                                            this.TargetClosest(true);
                                            this.directionY = 1;
                                            this.ai[0] = 1f;
                                            if (this.direction > 0)
                                            {
                                                this.spriteDirection = 1;
                                            }
                                        }
                                        bool flag124 = false;
                                        if (Main.netMode != 1)
                                        {
                                            if (this.ai[2] == 0f && Main.rand.Next(7200) == 0)
                                            {
                                                this.ai[2] = 2f;
                                                this.netUpdate = true;
                                            }
                                            if (!this.collideX && !this.collideY)
                                            {
                                                this.localAI[3] += 1f;
                                                if (this.localAI[3] > 5f)
                                                {
                                                    this.ai[2] = 2f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            else
                                            {
                                                this.localAI[3] = 0f;
                                            }
                                        }
                                        if (this.ai[2] > 0f)
                                        {
                                            this.ai[1] = 0f;
                                            this.ai[0] = 1f;
                                            this.directionY = 1;
                                            if (this.velocity.Y > num1432)
                                            {
                                                this.rotation += (float)this.direction * 0.1f;
                                            }
                                            else
                                            {
                                                this.rotation = 0f;
                                            }
                                            this.spriteDirection = this.direction;
                                            this.velocity.X = num1432 * (float)this.direction;
                                            this.noGravity = false;
                                            int num1433 = (int)(base.Center.X + (float)(this.width / 2 * -(float)this.direction)) / 16;
                                            int num1434 = (int)(this.position.Y + (float)this.height + 8f) / 16;
                                            if (Main.tile[num1433, num1434] != null && !Main.tile[num1433, num1434].topSlope() && this.collideY)
                                            {
                                                this.ai[2] -= 1f;
                                            }
                                            num1434 = (int)(this.position.Y + (float)this.height - 4f) / 16;
                                            num1433 = (int)(base.Center.X + (float)(this.width / 2 * this.direction)) / 16;
                                            if (Main.tile[num1433, num1434] != null && Main.tile[num1433, num1434].bottomSlope())
                                            {
                                                this.direction *= -1;
                                            }
                                            if (this.collideX && this.velocity.Y == 0f)
                                            {
                                                flag124 = true;
                                                this.ai[2] = 0f;
                                                this.directionY = -1;
                                                this.ai[1] = 1f;
                                            }
                                            if (this.velocity.Y == 0f)
                                            {
                                                if (this.localAI[1] == this.position.X)
                                                {
                                                    this.localAI[2] += 1f;
                                                    if (this.localAI[2] > 10f)
                                                    {
                                                        this.direction = 1;
                                                        this.velocity.X = (float)this.direction * num1432;
                                                        this.localAI[2] = 0f;
                                                    }
                                                }
                                                else
                                                {
                                                    this.localAI[2] = 0f;
                                                    this.localAI[1] = this.position.X;
                                                }
                                            }
                                        }
                                        if (this.ai[2] == 0f)
                                        {
                                            this.noGravity = true;
                                            if (this.ai[1] == 0f)
                                            {
                                                if (this.collideY)
                                                {
                                                    this.ai[0] = 2f;
                                                }
                                                if (!this.collideY && this.ai[0] == 2f)
                                                {
                                                    this.direction = -this.direction;
                                                    this.ai[1] = 1f;
                                                    this.ai[0] = 1f;
                                                }
                                                if (this.collideX)
                                                {
                                                    this.directionY = -this.directionY;
                                                    this.ai[1] = 1f;
                                                }
                                            }
                                            else
                                            {
                                                if (this.collideX)
                                                {
                                                    this.ai[0] = 2f;
                                                }
                                                if (!this.collideX && this.ai[0] == 2f)
                                                {
                                                    this.directionY = -this.directionY;
                                                    this.ai[1] = 0f;
                                                    this.ai[0] = 1f;
                                                }
                                                if (this.collideY)
                                                {
                                                    this.direction = -this.direction;
                                                    this.ai[1] = 0f;
                                                }
                                            }
                                            if (!flag124)
                                            {
                                                float num1435 = this.rotation;
                                                if (this.directionY < 0)
                                                {
                                                    if (this.direction < 0)
                                                    {
                                                        if (this.collideX)
                                                        {
                                                            this.rotation = 1.57f;
                                                            this.spriteDirection = -1;
                                                        }
                                                        else if (this.collideY)
                                                        {
                                                            this.rotation = 3.14f;
                                                            this.spriteDirection = 1;
                                                        }
                                                    }
                                                    else if (this.collideY)
                                                    {
                                                        this.rotation = 3.14f;
                                                        this.spriteDirection = -1;
                                                    }
                                                    else if (this.collideX)
                                                    {
                                                        this.rotation = 4.71f;
                                                        this.spriteDirection = 1;
                                                    }
                                                }
                                                else if (this.direction < 0)
                                                {
                                                    if (this.collideY)
                                                    {
                                                        this.rotation = 0f;
                                                        this.spriteDirection = -1;
                                                    }
                                                    else if (this.collideX)
                                                    {
                                                        this.rotation = 1.57f;
                                                        this.spriteDirection = 1;
                                                    }
                                                }
                                                else if (this.collideX)
                                                {
                                                    this.rotation = 4.71f;
                                                    this.spriteDirection = -1;
                                                }
                                                else if (this.collideY)
                                                {
                                                    this.rotation = 0f;
                                                    this.spriteDirection = 1;
                                                }
                                                float num1436 = this.rotation;
                                                this.rotation = num1435;
                                                if ((double)this.rotation > 6.28)
                                                {
                                                    this.rotation -= 6.28f;
                                                }
                                                if (this.rotation < 0f)
                                                {
                                                    this.rotation += 6.28f;
                                                }
                                                float num1437 = Math.Abs(this.rotation - num1436);
                                                float num1438 = 0.1f;
                                                if (this.rotation > num1436)
                                                {
                                                    if ((double)num1437 > 3.14)
                                                    {
                                                        this.rotation += num1438;
                                                    }
                                                    else
                                                    {
                                                        this.rotation -= num1438;
                                                        if (this.rotation < num1436)
                                                        {
                                                            this.rotation = num1436;
                                                        }
                                                    }
                                                }
                                                if (this.rotation < num1436)
                                                {
                                                    if ((double)num1437 > 3.14)
                                                    {
                                                        this.rotation -= num1438;
                                                    }
                                                    else
                                                    {
                                                        this.rotation += num1438;
                                                        if (this.rotation > num1436)
                                                        {
                                                            this.rotation = num1436;
                                                        }
                                                    }
                                                }
                                            }
                                            this.velocity.X = num1432 * (float)this.direction;
                                            this.velocity.Y = num1432 * (float)this.directionY;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 68)
                                    {
                                        this.noGravity = true;
                                        if (this.ai[0] == 0f)
                                        {
                                            this.noGravity = false;
                                            int direction6 = this.direction;
                                            int num1439 = this.target;
                                            this.TargetClosest(true);
                                            if (num1439 >= 0 && direction6 != 0)
                                            {
                                                this.direction = direction6;
                                            }
                                            if (this.wet)
                                            {
                                                float num1440 = 2f;
                                                this.velocity.X = (this.velocity.X * 19f + num1440 * (float)this.direction) / 20f;
                                                int num1441 = (int)(base.Center.X + (float)((this.width / 2 + 8) * this.direction)) / 16;
                                                int num1442 = (int)(base.Center.Y / 16f);
                                                int j4 = (int)(this.position.Y / 16f);
                                                int num1443 = (int)((this.position.Y + (float)this.height) / 16f);
                                                if (Main.tile[num1441, num1442] == null)
                                                {
                                                    Main.tile[num1441, num1442] = new Tile();
                                                }
                                                if (Main.tile[num1441, num1443] == null)
                                                {
                                                    Main.tile[num1441, num1443] = new Tile();
                                                }
                                                if (WorldGen.SolidTile(num1441, num1442) || WorldGen.SolidTile(num1441, j4) || WorldGen.SolidTile(num1441, num1443) || Main.tile[num1441, num1443].liquid == 0)
                                                {
                                                    this.direction *= -1;
                                                }
                                                this.spriteDirection = this.direction;
                                                if (this.velocity.Y > 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y * 0.5f;
                                                }
                                                this.noGravity = true;
                                                num1441 = (int)(base.Center.X / 16f);
                                                num1442 = (int)(base.Center.Y / 16f);
                                                float num1444 = this.position.Y + (float)this.height;
                                                if (Main.tile[num1441, num1442 - 1] == null)
                                                {
                                                    Main.tile[num1441, num1442 - 1] = new Tile();
                                                }
                                                if (Main.tile[num1441, num1442] == null)
                                                {
                                                    Main.tile[num1441, num1442] = new Tile();
                                                }
                                                if (Main.tile[num1441, num1442 + 1] == null)
                                                {
                                                    Main.tile[num1441, num1442 + 1] = new Tile();
                                                }
                                                if (Main.tile[num1441, num1442 - 1].liquid > 0)
                                                {
                                                    num1444 = (float)(num1442 * 16);
                                                    num1444 -= (float)(Main.tile[num1441, num1442 - 1].liquid / 16);
                                                }
                                                else if (Main.tile[num1441, num1442].liquid > 0)
                                                {
                                                    num1444 = (float)((num1442 + 1) * 16);
                                                    num1444 -= (float)(Main.tile[num1441, num1442].liquid / 16);
                                                }
                                                else if (Main.tile[num1441, num1442 + 1].liquid > 0)
                                                {
                                                    num1444 = (float)((num1442 + 2) * 16);
                                                    num1444 -= (float)(Main.tile[num1441, num1442 + 1].liquid / 16);
                                                }
                                                num1444 -= 6f;
                                                if (base.Center.Y > num1444)
                                                {
                                                    this.velocity.Y = this.velocity.Y - 0.1f;
                                                    if (this.velocity.Y < -8f)
                                                    {
                                                        this.velocity.Y = -8f;
                                                    }
                                                    if (base.Center.Y + this.velocity.Y < num1444)
                                                    {
                                                        this.velocity.Y = num1444 - base.Center.Y;
                                                    }
                                                }
                                                else
                                                {
                                                    this.velocity.Y = num1444 - base.Center.Y;
                                                }
                                            }
                                            if (Main.netMode != 1)
                                            {
                                                if (!this.wet)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.netUpdate = true;
                                                    this.direction = -this.direction;
                                                    return;
                                                }
                                                Rectangle rectangle14 = new Rectangle((int)Main.player[this.target].position.X, (int)Main.player[this.target].position.Y, Main.player[this.target].width, Main.player[this.target].height);
                                                Rectangle rectangle15 = new Rectangle((int)this.position.X - 100, (int)this.position.Y - 100, this.width + 200, this.height + 200);
                                                if (rectangle15.Intersects(rectangle14) || this.life < this.lifeMax)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.velocity.Y = this.velocity.Y - 6f;
                                                    this.netUpdate = true;
                                                    this.direction = -this.direction;
                                                    return;
                                                }
                                            }
                                        }
                                        else if (!Main.player[this.target].dead)
                                        {
                                            bool flag125 = false;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 300f)
                                            {
                                                flag125 = true;
                                            }
                                            if (flag125)
                                            {
                                                if (this.velocity.Y == 0f || this.collideY || this.wet)
                                                {
                                                    this.velocity.X = 0f;
                                                    this.velocity.Y = 0f;
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    if (Main.netMode != 1)
                                                    {
                                                        if ((this.type == NPCID.Duck2 || this.type == NPCID.DuckWhite2) && !this.wet)
                                                        {
                                                            int direction7 = this.direction;
                                                            this.Transform(this.type - 1);
                                                            this.TargetClosest(true);
                                                            this.direction = direction7;
                                                            this.ai[0] = 0f;
                                                            this.ai[1] = (float)(200 + Main.rand.Next(200));
                                                        }
                                                        this.netUpdate = true;
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    this.velocity.X = this.velocity.X * 0.98f;
                                                    this.velocity.Y = this.velocity.Y + 0.1f;
                                                    if (this.velocity.Y > 2f)
                                                    {
                                                        this.velocity.Y = 2f;
                                                        return;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (this.collideX)
                                                {
                                                    this.direction *= -1;
                                                    this.velocity.X = this.oldVelocity.X * -0.5f;
                                                    if (this.direction == -1 && this.velocity.X > 0f && this.velocity.X < 2f)
                                                    {
                                                        this.velocity.X = 2f;
                                                    }
                                                    if (this.direction == 1 && this.velocity.X < 0f && this.velocity.X > -2f)
                                                    {
                                                        this.velocity.X = -2f;
                                                    }
                                                }
                                                if (this.collideY)
                                                {
                                                    this.velocity.Y = this.oldVelocity.Y * -0.5f;
                                                    if (this.velocity.Y > 0f && this.velocity.Y < 1f)
                                                    {
                                                        this.velocity.Y = 1f;
                                                    }
                                                    if (this.velocity.Y < 0f && this.velocity.Y > -1f)
                                                    {
                                                        this.velocity.Y = -1f;
                                                    }
                                                }
                                                if (this.direction == -1 && this.velocity.X > -3f)
                                                {
                                                    this.velocity.X = this.velocity.X - 0.1f;
                                                    if (this.velocity.X > 3f)
                                                    {
                                                        this.velocity.X = this.velocity.X - 0.1f;
                                                    }
                                                    else if (this.velocity.X > 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X - 0.05f;
                                                    }
                                                    if (this.velocity.X < -3f)
                                                    {
                                                        this.velocity.X = -3f;
                                                    }
                                                }
                                                else if (this.direction == 1 && this.velocity.X < 3f)
                                                {
                                                    this.velocity.X = this.velocity.X + 0.1f;
                                                    if (this.velocity.X < -3f)
                                                    {
                                                        this.velocity.X = this.velocity.X + 0.1f;
                                                    }
                                                    else if (this.velocity.X < 0f)
                                                    {
                                                        this.velocity.X = this.velocity.X + 0.05f;
                                                    }
                                                    if (this.velocity.X > 3f)
                                                    {
                                                        this.velocity.X = 3f;
                                                    }
                                                }
                                                int num1445 = (int)((this.position.X + (float)(this.width / 2)) / 16f) + this.direction;
                                                int num1446 = (int)((this.position.Y + (float)this.height) / 16f);
                                                bool flag126 = true;
                                                int num1447 = 15;
                                                bool flag127 = false;
                                                for (int num1448 = num1446; num1448 < num1446 + num1447; num1448++)
                                                {
                                                    if (Main.tile[num1445, num1448] == null)
                                                    {
                                                        Main.tile[num1445, num1448] = new Tile();
                                                    }
                                                    if ((Main.tile[num1445, num1448].nactive() && Main.tileSolid[(int)Main.tile[num1445, num1448].type]) || Main.tile[num1445, num1448].liquid > 0)
                                                    {
                                                        if (num1448 < num1446 + 5)
                                                        {
                                                            flag127 = true;
                                                        }
                                                        flag126 = false;
                                                        break;
                                                    }
                                                }
                                                if (flag126)
                                                {
                                                    this.velocity.Y = this.velocity.Y + 0.1f;
                                                }
                                                else
                                                {
                                                    this.velocity.Y = this.velocity.Y - 0.1f;
                                                }
                                                if (flag127)
                                                {
                                                    this.velocity.Y = this.velocity.Y - 0.2f;
                                                }
                                                if (this.velocity.Y > 3f)
                                                {
                                                    this.velocity.Y = 3f;
                                                }
                                                if (this.velocity.Y < -4f)
                                                {
                                                    this.velocity.Y = -4f;
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 69)
                                    {
                                        bool expertMode = Main.expertMode;
                                        float num1449 = expertMode ? (0.6f * Main.damageMultiplier) : 1f;
                                        bool flag128 = (double)this.life <= (double)this.lifeMax * 0.5;
                                        bool flag129 = expertMode && (double)this.life <= (double)this.lifeMax * 0.15;
                                        bool flag130 = this.ai[0] > 4f;
                                        bool flag131 = this.ai[0] > 9f;
                                        bool flag132 = this.ai[3] < 10f;
                                        if (flag131)
                                        {
                                            this.damage = (int)((float)this.defDamage * 1.1f * num1449);
                                            this.defense = 0;
                                        }
                                        else if (flag130)
                                        {
                                            this.damage = (int)((float)this.defDamage * 1.2f * num1449);
                                            this.defense = (int)((float)this.defDefense * 0.8f);
                                        }
                                        else
                                        {
                                            this.damage = this.defDamage;
                                            this.defense = this.defDefense;
                                        }
                                        int num1450 = expertMode ? 40 : 60;
                                        float num1451 = expertMode ? 0.55f : 0.45f;
                                        float scaleFactor10 = expertMode ? 8.5f : 7.5f;
                                        if (flag131)
                                        {
                                            num1451 = 0.7f;
                                            scaleFactor10 = 12f;
                                            num1450 = 30;
                                        }
                                        else if (flag130 && flag132)
                                        {
                                            num1451 = (expertMode ? 0.6f : 0.5f);
                                            scaleFactor10 = (expertMode ? 10f : 8f);
                                            num1450 = (expertMode ? 40 : 20);
                                        }
                                        else if (flag132 && !flag130 && !flag131)
                                        {
                                            num1450 = 30;
                                        }
                                        int num1452 = expertMode ? 28 : 30;
                                        float num1453 = expertMode ? 17f : 16f;
                                        if (flag131)
                                        {
                                            num1452 = 25;
                                            num1453 = 27f;
                                        }
                                        else if (flag132 && flag130)
                                        {
                                            num1452 = (expertMode ? 27 : 30);
                                            if (expertMode)
                                            {
                                                num1453 = 21f;
                                            }
                                        }
                                        int num1454 = 80;
                                        int num1455 = 4;
                                        float num1456 = 0.3f;
                                        float scaleFactor11 = 5f;
                                        int num1457 = 90;
                                        int num1458 = 180;
                                        int num1459 = 180;
                                        int num1460 = 30;
                                        int num1461 = 120;
                                        int num1462 = 4;
                                        float scaleFactor12 = 6f;
                                        float scaleFactor13 = 20f;
                                        float num1463 = 6.28318548f / (float)(num1461 / 2);
                                        int num1464 = 75;
                                        Vector2 vector168 = base.Center;
                                        Player player5 = Main.player[this.target];
                                        if (this.target < 0 || this.target == 255 || player5.dead || !player5.active)
                                        {
                                            this.TargetClosest(true);
                                            player5 = Main.player[this.target];
                                            this.netUpdate = true;
                                        }
                                        if (player5.dead || Vector2.Distance(player5.Center, vector168) > 2400f)
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.4f;
                                            if (this.timeLeft > 10)
                                            {
                                                this.timeLeft = 10;
                                            }
                                            if (this.ai[0] > 4f)
                                            {
                                                this.ai[0] = 5f;
                                            }
                                            else
                                            {
                                                this.ai[0] = 0f;
                                            }
                                            this.ai[2] = 0f;
                                        }
                                        bool flag133 = player5.position.Y < 800f || (double)player5.position.Y > Main.worldSurface * 16.0 || (player5.position.X > 6400f && player5.position.X < (float)(Main.maxTilesX * 16 - 6400));
                                        if (flag133)
                                        {
                                            num1450 = 20;
                                            this.damage = this.defDamage * 2;
                                            this.defense = this.defDefense * 2;
                                            this.ai[3] = 0f;
                                            num1453 += 6f;
                                        }
                                        if (this.localAI[0] == 0f)
                                        {
                                            this.localAI[0] = 1f;
                                            this.alpha = 255;
                                            this.rotation = 0f;
                                            if (Main.netMode != 1)
                                            {
                                                this.ai[0] = -1f;
                                                this.netUpdate = true;
                                            }
                                        }
                                        float num1465 = (float)Math.Atan2((double)(player5.Center.Y - vector168.Y), (double)(player5.Center.X - vector168.X));
                                        if (this.spriteDirection == 1)
                                        {
                                            num1465 += 3.14159274f;
                                        }
                                        if (num1465 < 0f)
                                        {
                                            num1465 += 6.28318548f;
                                        }
                                        if (num1465 > 6.28318548f)
                                        {
                                            num1465 -= 6.28318548f;
                                        }
                                        if (this.ai[0] == -1f)
                                        {
                                            num1465 = 0f;
                                        }
                                        if (this.ai[0] == 3f)
                                        {
                                            num1465 = 0f;
                                        }
                                        if (this.ai[0] == 4f)
                                        {
                                            num1465 = 0f;
                                        }
                                        if (this.ai[0] == 8f)
                                        {
                                            num1465 = 0f;
                                        }
                                        float num1466 = 0.04f;
                                        if (this.ai[0] == 1f || this.ai[0] == 6f)
                                        {
                                            num1466 = 0f;
                                        }
                                        if (this.ai[0] == 7f)
                                        {
                                            num1466 = 0f;
                                        }
                                        if (this.ai[0] == 3f)
                                        {
                                            num1466 = 0.01f;
                                        }
                                        if (this.ai[0] == 4f)
                                        {
                                            num1466 = 0.01f;
                                        }
                                        if (this.ai[0] == 8f)
                                        {
                                            num1466 = 0.01f;
                                        }
                                        if (this.rotation < num1465)
                                        {
                                            if ((double)(num1465 - this.rotation) > 3.1415926535897931)
                                            {
                                                this.rotation -= num1466;
                                            }
                                            else
                                            {
                                                this.rotation += num1466;
                                            }
                                        }
                                        if (this.rotation > num1465)
                                        {
                                            if ((double)(this.rotation - num1465) > 3.1415926535897931)
                                            {
                                                this.rotation += num1466;
                                            }
                                            else
                                            {
                                                this.rotation -= num1466;
                                            }
                                        }
                                        if (this.rotation > num1465 - num1466 && this.rotation < num1465 + num1466)
                                        {
                                            this.rotation = num1465;
                                        }
                                        if (this.rotation < 0f)
                                        {
                                            this.rotation += 6.28318548f;
                                        }
                                        if (this.rotation > 6.28318548f)
                                        {
                                            this.rotation -= 6.28318548f;
                                        }
                                        if (this.rotation > num1465 - num1466 && this.rotation < num1465 + num1466)
                                        {
                                            this.rotation = num1465;
                                        }
                                        if (this.ai[0] != -1f && this.ai[0] < 9f)
                                        {
                                            bool flag134 = Collision.SolidCollision(this.position, this.width, this.height);
                                            if (flag134)
                                            {
                                                this.alpha += 15;
                                            }
                                            else
                                            {
                                                this.alpha -= 15;
                                            }
                                            if (this.alpha < 0)
                                            {
                                                this.alpha = 0;
                                            }
                                            if (this.alpha > 150)
                                            {
                                                this.alpha = 150;
                                            }
                                        }
                                        if (this.ai[0] == -1f)
                                        {
                                            this.velocity *= 0.98f;
                                            int num1467 = Math.Sign(player5.Center.X - vector168.X);
                                            if (num1467 != 0)
                                            {
                                                this.direction = num1467;
                                                this.spriteDirection = -this.direction;
                                            }
                                            if (this.ai[2] > 20f)
                                            {
                                                this.velocity.Y = -2f;
                                                this.alpha -= 5;
                                                bool flag135 = Collision.SolidCollision(this.position, this.width, this.height);
                                                if (flag135)
                                                {
                                                    this.alpha += 15;
                                                }
                                                if (this.alpha < 0)
                                                {
                                                    this.alpha = 0;
                                                }
                                                if (this.alpha > 150)
                                                {
                                                    this.alpha = 150;
                                                }
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1464)
                                            {
                                                this.ai[0] = 0f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 0f && !player5.dead)
                                        {
                                            if (this.ai[1] == 0f)
                                            {
                                                this.ai[1] = (float)(300 * Math.Sign((vector168 - player5.Center).X));
                                            }
                                            Vector2 value17 = player5.Center + new Vector2(this.ai[1], -200f) - vector168;
                                            Vector2 vector170 = Vector2.Normalize(value17 - this.velocity) * scaleFactor10;
                                            if (this.velocity.X < vector170.X)
                                            {
                                                this.velocity.X = this.velocity.X + num1451;
                                                if (this.velocity.X < 0f && vector170.X > 0f)
                                                {
                                                    this.velocity.X = this.velocity.X + num1451;
                                                }
                                            }
                                            else if (this.velocity.X > vector170.X)
                                            {
                                                this.velocity.X = this.velocity.X - num1451;
                                                if (this.velocity.X > 0f && vector170.X < 0f)
                                                {
                                                    this.velocity.X = this.velocity.X - num1451;
                                                }
                                            }
                                            if (this.velocity.Y < vector170.Y)
                                            {
                                                this.velocity.Y = this.velocity.Y + num1451;
                                                if (this.velocity.Y < 0f && vector170.Y > 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y + num1451;
                                                }
                                            }
                                            else if (this.velocity.Y > vector170.Y)
                                            {
                                                this.velocity.Y = this.velocity.Y - num1451;
                                                if (this.velocity.Y > 0f && vector170.Y < 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y - num1451;
                                                }
                                            }
                                            int num1471 = Math.Sign(player5.Center.X - vector168.X);
                                            if (num1471 != 0)
                                            {
                                                if (this.ai[2] == 0f && num1471 != this.direction)
                                                {
                                                    this.rotation += 3.14159274f;
                                                }
                                                this.direction = num1471;
                                                if (this.spriteDirection != -this.direction)
                                                {
                                                    this.rotation += 3.14159274f;
                                                }
                                                this.spriteDirection = -this.direction;
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1450)
                                            {
                                                int num1472 = 0;
                                                switch ((int)this.ai[3])
                                                {
                                                    case 0:
                                                    case 1:
                                                    case 2:
                                                    case 3:
                                                    case 4:
                                                    case 5:
                                                    case 6:
                                                    case 7:
                                                    case 8:
                                                    case 9:
                                                        num1472 = 1;
                                                        break;
                                                    case 10:
                                                        this.ai[3] = 1f;
                                                        num1472 = 2;
                                                        break;
                                                    case 11:
                                                        this.ai[3] = 0f;
                                                        num1472 = 3;
                                                        break;
                                                }
                                                if (flag128)
                                                {
                                                    num1472 = 4;
                                                }
                                                if (num1472 == 1)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.velocity = Vector2.Normalize(player5.Center - vector168) * num1453;
                                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                    if (num1471 != 0)
                                                    {
                                                        this.direction = num1471;
                                                        if (this.spriteDirection == 1)
                                                        {
                                                            this.rotation += 3.14159274f;
                                                        }
                                                        this.spriteDirection = -this.direction;
                                                    }
                                                }
                                                else if (num1472 == 2)
                                                {
                                                    this.ai[0] = 2f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                else if (num1472 == 3)
                                                {
                                                    this.ai[0] = 3f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                else if (num1472 == 4)
                                                {
                                                    this.ai[0] = 4f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1452)
                                            {
                                                this.ai[0] = 0f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] += 2f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 2f)
                                        {
                                            if (this.ai[1] == 0f)
                                            {
                                                this.ai[1] = (float)(300 * Math.Sign((vector168 - player5.Center).X));
                                            }
                                            Vector2 value19 = player5.Center + new Vector2(this.ai[1], -200f) - vector168;
                                            Vector2 vector172 = Vector2.Normalize(value19 - this.velocity) * scaleFactor11;
                                            if (this.velocity.X < vector172.X)
                                            {
                                                this.velocity.X = this.velocity.X + num1456;
                                                if (this.velocity.X < 0f && vector172.X > 0f)
                                                {
                                                    this.velocity.X = this.velocity.X + num1456;
                                                }
                                            }
                                            else if (this.velocity.X > vector172.X)
                                            {
                                                this.velocity.X = this.velocity.X - num1456;
                                                if (this.velocity.X > 0f && vector172.X < 0f)
                                                {
                                                    this.velocity.X = this.velocity.X - num1456;
                                                }
                                            }
                                            if (this.velocity.Y < vector172.Y)
                                            {
                                                this.velocity.Y = this.velocity.Y + num1456;
                                                if (this.velocity.Y < 0f && vector172.Y > 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y + num1456;
                                                }
                                            }
                                            else if (this.velocity.Y > vector172.Y)
                                            {
                                                this.velocity.Y = this.velocity.Y - num1456;
                                                if (this.velocity.Y > 0f && vector172.Y < 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y - num1456;
                                                }
                                            }
                                            if (this.ai[2] % (float)num1455 == 0f)
                                            {
                                                if (Main.netMode != 1)
                                                {
                                                    Vector2 vector173 = Vector2.Normalize(player5.Center - vector168) * (float)(this.width + 20) / 2f + vector168;
                                                    NPC.NewNPC((int)vector173.X, (int)vector173.Y + 45, 371, 0, 0f, 0f, 0f, 0f, 255);
                                                }
                                            }
                                            int num1476 = Math.Sign(player5.Center.X - vector168.X);
                                            if (num1476 != 0)
                                            {
                                                this.direction = num1476;
                                                if (this.spriteDirection != -this.direction)
                                                {
                                                    this.rotation += 3.14159274f;
                                                }
                                                this.spriteDirection = -this.direction;
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1454)
                                            {
                                                this.ai[0] = 0f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 3f)
                                        {
                                            this.velocity *= 0.98f;
                                            this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                            if (Main.netMode != 1 && this.ai[2] == (float)(num1457 - 30))
                                            {
                                                Vector2 vector174 = this.rotation.ToRotationVector2() * (Vector2.UnitX * (float)this.direction) * (float)(this.width + 20) / 2f + vector168;
                                                Projectile.NewProjectile(vector174.X, vector174.Y, (float)(this.direction * 2), 8f, 385, 0, 0f, Main.myPlayer, 0f, 0f);
                                                Projectile.NewProjectile(vector174.X, vector174.Y, (float)(-(float)this.direction * 2), 8f, 385, 0, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1457)
                                            {
                                                this.ai[0] = 0f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 4f)
                                        {
                                            this.velocity *= 0.98f;
                                            this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1458)
                                            {
                                                this.ai[0] = 5f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 5f && !player5.dead)
                                        {
                                            if (this.ai[1] == 0f)
                                            {
                                                this.ai[1] = (float)(300 * Math.Sign((vector168 - player5.Center).X));
                                            }
                                            Vector2 value20 = player5.Center + new Vector2(this.ai[1], -200f) - vector168;
                                            Vector2 vector175 = Vector2.Normalize(value20 - this.velocity) * scaleFactor10;
                                            if (this.velocity.X < vector175.X)
                                            {
                                                this.velocity.X = this.velocity.X + num1451;
                                                if (this.velocity.X < 0f && vector175.X > 0f)
                                                {
                                                    this.velocity.X = this.velocity.X + num1451;
                                                }
                                            }
                                            else if (this.velocity.X > vector175.X)
                                            {
                                                this.velocity.X = this.velocity.X - num1451;
                                                if (this.velocity.X > 0f && vector175.X < 0f)
                                                {
                                                    this.velocity.X = this.velocity.X - num1451;
                                                }
                                            }
                                            if (this.velocity.Y < vector175.Y)
                                            {
                                                this.velocity.Y = this.velocity.Y + num1451;
                                                if (this.velocity.Y < 0f && vector175.Y > 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y + num1451;
                                                }
                                            }
                                            else if (this.velocity.Y > vector175.Y)
                                            {
                                                this.velocity.Y = this.velocity.Y - num1451;
                                                if (this.velocity.Y > 0f && vector175.Y < 0f)
                                                {
                                                    this.velocity.Y = this.velocity.Y - num1451;
                                                }
                                            }
                                            int num1477 = Math.Sign(player5.Center.X - vector168.X);
                                            if (num1477 != 0)
                                            {
                                                if (this.ai[2] == 0f && num1477 != this.direction)
                                                {
                                                    this.rotation += 3.14159274f;
                                                }
                                                this.direction = num1477;
                                                if (this.spriteDirection != -this.direction)
                                                {
                                                    this.rotation += 3.14159274f;
                                                }
                                                this.spriteDirection = -this.direction;
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1450)
                                            {
                                                int num1478 = 0;
                                                switch ((int)this.ai[3])
                                                {
                                                    case 0:
                                                    case 1:
                                                    case 2:
                                                    case 3:
                                                    case 4:
                                                    case 5:
                                                        num1478 = 1;
                                                        break;
                                                    case 6:
                                                        this.ai[3] = 1f;
                                                        num1478 = 2;
                                                        break;
                                                    case 7:
                                                        this.ai[3] = 0f;
                                                        num1478 = 3;
                                                        break;
                                                }
                                                if (flag129)
                                                {
                                                    num1478 = 4;
                                                }
                                                if (num1478 == 1)
                                                {
                                                    this.ai[0] = 6f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.velocity = Vector2.Normalize(player5.Center - vector168) * num1453;
                                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                    if (num1477 != 0)
                                                    {
                                                        this.direction = num1477;
                                                        if (this.spriteDirection == 1)
                                                        {
                                                            this.rotation += 3.14159274f;
                                                        }
                                                        this.spriteDirection = -this.direction;
                                                    }
                                                }
                                                else if (num1478 == 2)
                                                {
                                                    this.velocity = Vector2.Normalize(player5.Center - vector168) * scaleFactor13;
                                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                    if (num1477 != 0)
                                                    {
                                                        this.direction = num1477;
                                                        if (this.spriteDirection == 1)
                                                        {
                                                            this.rotation += 3.14159274f;
                                                        }
                                                        this.spriteDirection = -this.direction;
                                                    }
                                                    this.ai[0] = 7f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                else if (num1478 == 3)
                                                {
                                                    this.ai[0] = 8f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                else if (num1478 == 4)
                                                {
                                                    this.ai[0] = 9f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 6f)
                                        {
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1452)
                                            {
                                                this.ai[0] = 5f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] += 2f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 7f)
                                        {
                                            if (this.ai[2] % (float)num1462 == 0f)
                                            {
                                                if (Main.netMode != 1)
                                                {
                                                    Vector2 vector177 = Vector2.Normalize(this.velocity) * (float)(this.width + 20) / 2f + vector168;
                                                    int num1482 = NPC.NewNPC((int)vector177.X, (int)vector177.Y + 45, 371, 0, 0f, 0f, 0f, 0f, 255);
                                                    Main.npc[num1482].target = this.target;
                                                    Main.npc[num1482].velocity = Vector2.Normalize(this.velocity).RotatedBy((double)(1.57079637f * (float)this.direction), default(Vector2)) * scaleFactor12;
                                                    Main.npc[num1482].netUpdate = true;
                                                    Main.npc[num1482].ai[3] = (float)Main.rand.Next(80, 121) / 100f;
                                                }
                                            }
                                            this.velocity = this.velocity.RotatedBy((double)(-(double)num1463 * (float)this.direction), default(Vector2));
                                            this.rotation -= num1463 * (float)this.direction;
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1461)
                                            {
                                                this.ai[0] = 5f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 8f)
                                        {
                                            this.velocity *= 0.98f;
                                            this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                            if (Main.netMode != 1 && this.ai[2] == (float)(num1457 - 30))
                                            {
                                                Projectile.NewProjectile(vector168.X, vector168.Y, 0f, 0f, 385, 0, 0f, Main.myPlayer, 1f, (float)(this.target + 1));
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1457)
                                            {
                                                this.ai[0] = 5f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 9f)
                                        {
                                            if (this.ai[2] < (float)(num1459 - 90))
                                            {
                                                bool flag136 = Collision.SolidCollision(this.position, this.width, this.height);
                                                if (flag136)
                                                {
                                                    this.alpha += 15;
                                                }
                                                else
                                                {
                                                    this.alpha -= 15;
                                                }
                                                if (this.alpha < 0)
                                                {
                                                    this.alpha = 0;
                                                }
                                                if (this.alpha > 150)
                                                {
                                                    this.alpha = 150;
                                                }
                                            }
                                            else if (this.alpha < 255)
                                            {
                                                this.alpha += 4;
                                                if (this.alpha > 255)
                                                {
                                                    this.alpha = 255;
                                                }
                                            }
                                            this.velocity *= 0.98f;
                                            this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1459)
                                            {
                                                this.ai[0] = 10f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 10f && !player5.dead)
                                        {
                                            this.dontTakeDamage = false;
                                            this.chaseable = false;
                                            if (this.alpha < 255)
                                            {
                                                this.alpha += 25;
                                                if (this.alpha > 255)
                                                {
                                                    this.alpha = 255;
                                                }
                                            }
                                            if (this.ai[1] == 0f)
                                            {
                                                this.ai[1] = (float)(360 * Math.Sign((vector168 - player5.Center).X));
                                            }
                                            Vector2 value22 = player5.Center + new Vector2(this.ai[1], -200f) - vector168;
                                            Vector2 desiredVelocity = Vector2.Normalize(value22 - this.velocity) * scaleFactor10;
                                            this.SimpleFlyMovement(desiredVelocity, num1451);
                                            int num1483 = Math.Sign(player5.Center.X - vector168.X);
                                            if (num1483 != 0)
                                            {
                                                if (this.ai[2] == 0f && num1483 != this.direction)
                                                {
                                                    this.rotation += 3.14159274f;
                                                    for (int num1484 = 0; num1484 < this.oldPos.Length; num1484++)
                                                    {
                                                        this.oldPos[num1484] = Vector2.Zero;
                                                    }
                                                }
                                                this.direction = num1483;
                                                if (this.spriteDirection != -this.direction)
                                                {
                                                    this.rotation += 3.14159274f;
                                                }
                                                this.spriteDirection = -this.direction;
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1450)
                                            {
                                                int num1485 = 0;
                                                switch ((int)this.ai[3])
                                                {
                                                    case 0:
                                                    case 2:
                                                    case 3:
                                                    case 5:
                                                    case 6:
                                                    case 7:
                                                        num1485 = 1;
                                                        break;
                                                    case 1:
                                                    case 4:
                                                    case 8:
                                                        num1485 = 2;
                                                        break;
                                                }
                                                if (num1485 == 1)
                                                {
                                                    this.ai[0] = 11f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.velocity = Vector2.Normalize(player5.Center - vector168) * num1453;
                                                    this.rotation = (float)Math.Atan2((double)this.velocity.Y, (double)this.velocity.X);
                                                    if (num1483 != 0)
                                                    {
                                                        this.direction = num1483;
                                                        if (this.spriteDirection == 1)
                                                        {
                                                            this.rotation += 3.14159274f;
                                                        }
                                                        this.spriteDirection = -this.direction;
                                                    }
                                                }
                                                else if (num1485 == 2)
                                                {
                                                    this.ai[0] = 12f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                else if (num1485 == 3)
                                                {
                                                    this.ai[0] = 13f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                }
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 11f)
                                        {
                                            this.dontTakeDamage = false;
                                            this.chaseable = true;
                                            this.alpha -= 25;
                                            if (this.alpha < 0)
                                            {
                                                this.alpha = 0;
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1452)
                                            {
                                                this.ai[0] = 10f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] += 1f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 12f)
                                        {
                                            this.dontTakeDamage = true;
                                            this.chaseable = false;
                                            if (this.alpha < 255)
                                            {
                                                this.alpha += 17;
                                                if (this.alpha > 255)
                                                {
                                                    this.alpha = 255;
                                                }
                                            }
                                            this.velocity *= 0.98f;
                                            this.velocity.Y = MathHelper.Lerp(this.velocity.Y, 0f, 0.02f);
                                            if (Main.netMode != 1 && this.ai[2] == (float)(num1460 / 2))
                                            {
                                                if (this.ai[1] == 0f)
                                                {
                                                    this.ai[1] = (float)(300 * Math.Sign((vector168 - player5.Center).X));
                                                }
                                                Vector2 center6 = player5.Center + new Vector2(-this.ai[1], -200f);
                                                vector168 = (base.Center = center6);
                                                int num1489 = Math.Sign(player5.Center.X - vector168.X);
                                                if (num1489 != 0)
                                                {
                                                    if (this.ai[2] == 0f && num1489 != this.direction)
                                                    {
                                                        this.rotation += 3.14159274f;
                                                        for (int num1490 = 0; num1490 < this.oldPos.Length; num1490++)
                                                        {
                                                            this.oldPos[num1490] = Vector2.Zero;
                                                        }
                                                    }
                                                    this.direction = num1489;
                                                    if (this.spriteDirection != -this.direction)
                                                    {
                                                        this.rotation += 3.14159274f;
                                                    }
                                                    this.spriteDirection = -this.direction;
                                                }
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1460)
                                            {
                                                this.ai[0] = 10f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] += 1f;
                                                if (this.ai[3] >= 9f)
                                                {
                                                    this.ai[3] = 0f;
                                                }
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 13f)
                                        {
                                            this.velocity = this.velocity.RotatedBy((double)(-(double)num1463 * (float)this.direction), default(Vector2));
                                            this.rotation -= num1463 * (float)this.direction;
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= (float)num1461)
                                            {
                                                this.ai[0] = 10f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] += 1f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 70)
                                    {
                                        if (this.target == 255)
                                        {
                                            this.TargetClosest(true);
                                            this.ai[3] = (float)Main.rand.Next(80, 121) / 100f;
                                            float scaleFactor14 = (float)Main.rand.Next(165, 265) / 15f;
                                            this.velocity = Vector2.Normalize(Main.player[this.target].Center - base.Center + new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101))) * scaleFactor14;
                                            this.netUpdate = true;
                                        }
                                        Vector2 vector179 = Vector2.Normalize(Main.player[this.target].Center - base.Center);
                                        this.velocity = (this.velocity * 40f + vector179 * 20f) / 41f;
                                        this.scale = this.ai[3];
                                        this.alpha -= 30;
                                        if (this.alpha < 50)
                                        {
                                            this.alpha = 50;
                                        }
                                        this.alpha = 50;
                                        this.velocity.X = (this.velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f;
                                        this.velocity.Y = (this.velocity.Y * 50f + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f;
                                        if (this.velocity.Y > 0f)
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.04f;
                                        }
                                        if (this.ai[0] == 0f)
                                        {
                                            int num1491 = 40;
                                            Rectangle rect = this.getRect();
                                            rect.X -= num1491 + this.width / 2;
                                            rect.Y -= num1491 + this.height / 2;
                                            rect.Width += num1491 * 2;
                                            rect.Height += num1491 * 2;
                                            for (int num1492 = 0; num1492 < 255; num1492++)
                                            {
                                                Player player6 = Main.player[num1492];
                                                if (player6.active && !player6.dead && rect.Intersects(player6.getRect()))
                                                {
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = 4f;
                                                    this.netUpdate = true;
                                                    break;
                                                }
                                            }
                                        }
                                        if (this.ai[0] == 0f)
                                        {
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 150f)
                                            {
                                                this.ai[0] = 1f;
                                                this.ai[1] = 4f;
                                            }
                                        }
                                        if (this.ai[0] == 1f)
                                        {
                                            this.ai[1] -= 1f;
                                            if (this.ai[1] <= 0f)
                                            {
                                                this.life = 0;
                                                this.HitEffect(0, 10.0);
                                                this.active = false;
                                                return;
                                            }
                                        }
                                        if (this.justHit || this.ai[0] == 1f)
                                        {
                                            this.dontTakeDamage = true;
                                            this.position = base.Center;
                                            this.width = (this.height = 100);
                                            this.position = new Vector2(this.position.X - (float)(this.width / 2), this.position.Y - (float)(this.height / 2));
                                            if (this.timeLeft > 3)
                                            {
                                                this.timeLeft = 3;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 71)
                                    {
                                        this.noTileCollide = true;
                                        int num1493 = 90;
                                        if (this.target < 0 || this.target == 255 || Main.player[this.target].dead)
                                        {
                                            this.TargetClosest(false);
                                            this.direction = 1;
                                            this.netUpdate = true;
                                        }
                                        if (this.ai[0] == 0f)
                                        {
                                            this.ai[1] += 1f;
                                            int arg_5028C_0 = this.type;
                                            this.noGravity = true;
                                            this.dontTakeDamage = true;
                                            this.velocity.Y = this.ai[3];
                                            if (this.type == NPCID.Sharkron2)
                                            {
                                                float num1494 = 0.104719758f;
                                                float num1495 = this.ai[2];
                                                float num1496 = (float)(Math.Cos((double)(num1494 * this.localAI[1])) - 0.5) * num1495;
                                                this.position.X = this.position.X - num1496 * (float)(-(float)this.direction);
                                                this.localAI[1] += 1f;
                                                num1496 = (float)(Math.Cos((double)(num1494 * this.localAI[1])) - 0.5) * num1495;
                                                this.position.X = this.position.X + num1496 * (float)(-(float)this.direction);
                                                if (Math.Abs(Math.Cos((double)(num1494 * this.localAI[1])) - 0.5) > 0.25)
                                                {
                                                    this.spriteDirection = ((Math.Cos((double)(num1494 * this.localAI[1])) - 0.5 >= 0.0) ? -1 : 1);
                                                }
                                                this.rotation = this.velocity.Y * (float)this.spriteDirection * 0.1f;
                                                if ((double)this.rotation < -0.2)
                                                {
                                                    this.rotation = -0.2f;
                                                }
                                                if ((double)this.rotation > 0.2)
                                                {
                                                    this.rotation = 0.2f;
                                                }
                                                this.alpha -= 6;
                                                if (this.alpha < 0)
                                                {
                                                    this.alpha = 0;
                                                }
                                            }
                                            if (this.ai[1] >= (float)num1493)
                                            {
                                                this.ai[0] = 1f;
                                                this.ai[1] = 0f;
                                                if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                {
                                                    this.ai[1] = 1f;
                                                }
                                                this.TargetClosest(true);
                                                this.spriteDirection = this.direction;
                                                Vector2 vector180 = Main.player[this.target].Center - base.Center;
                                                vector180.Normalize();
                                                this.velocity = vector180 * 16f;
                                                this.rotation = this.velocity.ToRotation();
                                                if (this.direction == -1)
                                                {
                                                    this.rotation += 3.14159274f;
                                                }
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            this.noGravity = true;
                                            if (!Collision.SolidCollision(this.position, this.width, this.height))
                                            {
                                                if (this.ai[1] < 1f)
                                                {
                                                    this.ai[1] = 1f;
                                                }
                                            }
                                            else
                                            {
                                                this.alpha -= 15;
                                                if (this.alpha < 150)
                                                {
                                                    this.alpha = 150;
                                                }
                                            }
                                            if (this.ai[1] >= 1f)
                                            {
                                                this.alpha -= 60;
                                                if (this.alpha < 0)
                                                {
                                                    this.alpha = 0;
                                                }
                                                this.dontTakeDamage = false;
                                                this.ai[1] += 1f;
                                                if (Collision.SolidCollision(this.position, this.width, this.height))
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10.0);
                                                    this.active = false;
                                                    return;
                                                }
                                            }
                                            if (this.ai[1] >= 60f)
                                            {
                                                this.noGravity = false;
                                            }
                                            this.rotation = this.velocity.ToRotation();
                                            if (this.direction == -1)
                                            {
                                                this.rotation += 3.14159274f;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 72)
                                    {
                                        if (this.type == NPCID.ForceBubble)
                                        {
                                            int num1497 = (int)this.ai[0];
                                            if (Main.npc[num1497].active && Main.npc[num1497].type == NPCID.MartianOfficer)
                                            {
                                                this.velocity = Vector2.Zero;
                                                this.position = Main.npc[num1497].Center;
                                                this.position.X = this.position.X - (float)(this.width / 2);
                                                this.position.Y = this.position.Y - (float)(this.height / 2);
                                                this.gfxOffY = Main.npc[num1497].gfxOffY;
                                                return;
                                            }
                                            this.life = 0;
                                            this.HitEffect(0, 10.0);
                                            this.active = false;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 73)
                                    {
                                        this.TargetClosest(false);
                                        this.spriteDirection = this.direction;
                                        this.velocity.X = this.velocity.X * 0.93f;
                                        if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                        {
                                            this.velocity.X = 0f;
                                        }
                                        if (this.type == NPCID.MartianTurret)
                                        {
                                            float num1498 = 120f;
                                            float num1499 = 60f;
                                            if (this.ai[1] < num1498)
                                            {
                                                this.ai[1] += 1f;
                                                if (this.ai[1] > 60f)
                                                {
                                                    float num1500 = (this.ai[1] - num1499) / (num1498 - num1499);
                                                    this.alpha = (int)((1f - num1500) * 255f);
                                                }
                                                else
                                                {
                                                    this.alpha = 255;
                                                }
                                                this.dontTakeDamage = true;
                                                this.frameCounter = 0.0;
                                                this.frame.Y = 0;
                                                float num1501 = this.ai[1] / num1499;
                                                return;
                                            }
                                            this.dontTakeDamage = false;
                                        }
                                        if (this.ai[0] < 60f)
                                        {
                                            this.ai[0] += 1f;
                                        }
                                        if (this.justHit)
                                        {
                                            this.ai[0] = -30f;
                                        }
                                        if (this.ai[0] == 60f)
                                        {
                                            this.ai[0] = -120f;
                                            Vector2 center7 = Main.player[this.target].Center;
                                            Vector2 value25 = base.Center - Vector2.UnitY * 10f;
                                            Vector2 vector181 = center7 - value25;
                                            vector181.X += (float)Main.rand.Next(-100, 101);
                                            vector181.Y += (float)Main.rand.Next(-100, 101);
                                            vector181.X *= (float)Main.rand.Next(70, 131) * 0.01f;
                                            vector181.Y *= (float)Main.rand.Next(70, 131) * 0.01f;
                                            vector181.Normalize();
                                            if (float.IsNaN(vector181.X) || float.IsNaN(vector181.Y))
                                            {
                                                vector181 = -Vector2.UnitY;
                                            }
                                            vector181 *= 14f;
                                            int num1504 = 35;
                                            if (Main.expertMode && this.type >= NPCID.BrainScrambler && this.type <= NPCID.MartianSaucer)
                                            {
                                                num1504 = (int)((double)num1504 * 0.8);
                                            }
                                            Projectile.NewProjectile(value25.X, value25.Y, vector181.X, vector181.Y, 435, num1504, 0f, Main.myPlayer, 0f, 0f);
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 74)
                                    {
                                        this.TargetClosest(false);
                                        this.rotation = this.velocity.ToRotation();
                                        if (Math.Sign(this.velocity.X) != 0)
                                        {
                                            this.spriteDirection = -Math.Sign(this.velocity.X);
                                        }
                                        if (this.rotation < -1.57079637f)
                                        {
                                            this.rotation += 3.14159274f;
                                        }
                                        if (this.rotation > 1.57079637f)
                                        {
                                            this.rotation -= 3.14159274f;
                                        }
                                        if (this.type == NPCID.SolarCorite)
                                        {
                                            this.spriteDirection = Math.Sign(this.velocity.X);
                                        }
                                        float num1505 = 0.4f;
                                        float num1506 = 10f;
                                        float scaleFactor16 = 200f;
                                        float num1507 = 750f;
                                        float num1508 = 30f;
                                        float num1509 = 30f;
                                        float scaleFactor17 = 0.95f;
                                        int num1510 = 50;
                                        float scaleFactor18 = 14f;
                                        float num1511 = 30f;
                                        float num1512 = 100f;
                                        float num1513 = 20f;
                                        float num1514 = 0f;
                                        float num1515 = 7f;
                                        bool flag137 = true;
                                        if (this.type == NPCID.SolarCorite)
                                        {
                                            num1505 = 0.3f;
                                            num1506 = 8f;
                                            scaleFactor16 = 300f;
                                            num1507 = 800f;
                                            num1508 = 60f;
                                            num1509 = 5f;
                                            scaleFactor17 = 0.8f;
                                            num1510 = 0;
                                            scaleFactor18 = 10f;
                                            num1511 = 30f;
                                            num1512 = 150f;
                                            num1513 = 60f;
                                            num1514 = 0.333333343f;
                                            num1515 = 8f;
                                            flag137 = false;
                                        }
                                        num1514 *= num1513;
                                        if (Main.expertMode)
                                        {
                                            num1505 *= Main.expertKnockBack;
                                        }
                                        if (this.ai[0] == 0f)
                                        {
                                            this.knockBackResist = num1505;
                                            float scaleFactor19 = num1506;
                                            Vector2 center8 = base.Center;
                                            Vector2 center9 = Main.player[this.target].Center;
                                            Vector2 vector183 = center9 - center8;
                                            Vector2 vector184 = vector183 - Vector2.UnitY * scaleFactor16;
                                            float num1521 = vector183.Length();
                                            vector183 = Vector2.Normalize(vector183) * scaleFactor19;
                                            vector184 = Vector2.Normalize(vector184) * scaleFactor19;
                                            bool flag138 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1);
                                            if (this.ai[3] >= 120f)
                                            {
                                                flag138 = true;
                                            }
                                            float num1522 = 8f;
                                            flag138 = (flag138 && vector183.ToRotation() > 3.14159274f / num1522 && vector183.ToRotation() < 3.14159274f - 3.14159274f / num1522);
                                            if (num1521 > num1507 || !flag138)
                                            {
                                                this.velocity.X = (this.velocity.X * (num1508 - 1f) + vector184.X) / num1508;
                                                this.velocity.Y = (this.velocity.Y * (num1508 - 1f) + vector184.Y) / num1508;
                                                if (!flag138)
                                                {
                                                    this.ai[3] += 1f;
                                                    if (this.ai[3] == 120f)
                                                    {
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else
                                                {
                                                    this.ai[3] = 0f;
                                                }
                                            }
                                            else
                                            {
                                                this.ai[0] = 1f;
                                                this.ai[2] = vector183.X;
                                                this.ai[3] = vector183.Y;
                                                this.netUpdate = true;
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            this.knockBackResist = 0f;
                                            this.velocity *= scaleFactor17;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= num1509)
                                            {
                                                this.ai[0] = 2f;
                                                this.ai[1] = 0f;
                                                this.netUpdate = true;
                                                Vector2 velocity2 = new Vector2(this.ai[2], this.ai[3]) + new Vector2((float)Main.rand.Next(-num1510, num1510 + 1), (float)Main.rand.Next(-num1510, num1510 + 1)) * 0.04f;
                                                velocity2.Normalize();
                                                velocity2 *= scaleFactor18;
                                                this.velocity = velocity2;
                                            }
                                        }
                                        else if (this.ai[0] == 2f)
                                        {
                                            this.knockBackResist = 0f;
                                            float num1524 = num1511;
                                            this.ai[1] += 1f;
                                            bool flag139 = Vector2.Distance(base.Center, Main.player[this.target].Center) > num1512 && base.Center.Y > Main.player[this.target].Center.Y;
                                            if ((this.ai[1] >= num1524 && flag139) || this.velocity.Length() < num1515)
                                            {
                                                this.ai[0] = 0f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] = 0f;
                                                this.velocity /= 2f;
                                                this.netUpdate = true;
                                                if (this.type == NPCID.SolarCorite)
                                                {
                                                    this.ai[1] = 45f;
                                                    this.ai[0] = 4f;
                                                }
                                            }
                                            else
                                            {
                                                Vector2 center10 = base.Center;
                                                Vector2 center11 = Main.player[this.target].Center;
                                                Vector2 vec4 = center11 - center10;
                                                vec4.Normalize();
                                                if (vec4.HasNaNs())
                                                {
                                                    vec4 = new Vector2((float)this.direction, 0f);
                                                }
                                                this.velocity = (this.velocity * (num1513 - 1f) + vec4 * (this.velocity.Length() + num1514)) / num1513;
                                            }
                                            if (flag137 && Collision.SolidCollision(this.position, this.width, this.height))
                                            {
                                                this.ai[0] = 3f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] = 0f;
                                                this.netUpdate = true;
                                            }
                                        }
                                        else if (this.ai[0] == 4f)
                                        {
                                            this.ai[1] -= 3f;
                                            if (this.ai[1] <= 0f)
                                            {
                                                this.ai[0] = 0f;
                                                this.ai[1] = 0f;
                                                this.netUpdate = true;
                                            }
                                            this.velocity *= 0.95f;
                                        }
                                        if (flag137 && this.ai[0] != 3f && Vector2.Distance(base.Center, Main.player[this.target].Center) < 64f)
                                        {
                                            this.ai[0] = 3f;
                                            this.ai[1] = 0f;
                                            this.ai[2] = 0f;
                                            this.ai[3] = 0f;
                                            this.netUpdate = true;
                                        }
                                        if (this.ai[0] == 3f)
                                        {
                                            this.position = base.Center;
                                            this.width = (this.height = 192);
                                            this.position.X = this.position.X - (float)(this.width / 2);
                                            this.position.Y = this.position.Y - (float)(this.height / 2);
                                            this.velocity = Vector2.Zero;
                                            this.damage = (int)(80f * Main.damageMultiplier);
                                            this.alpha = 255;

                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 3f)
                                            {
                                                this.life = 0;
                                                this.HitEffect(0, 10.0);
                                                this.active = false;
                                                return;
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 75)
                                    {
                                        int num1529 = -1;
                                        Vector2 vector185 = Vector2.Zero;
                                        int num1530 = 0;
                                        if (this.type == NPCID.ScutlixRider)
                                        {
                                            if (this.localAI[0] == 0f && Main.netMode != 1)
                                            {
                                                this.localAI[0] = 1f;
                                                int num1531 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 391, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                this.ai[0] = (float)num1531;
                                                this.netUpdate = true;
                                            }
                                            int num1532 = (int)this.ai[0];
                                            if (Main.npc[num1532].active && Main.npc[num1532].type == NPCID.Scutlix)
                                            {
                                                if (this.timeLeft < 60)
                                                {
                                                    this.timeLeft = 60;
                                                }
                                                num1529 = num1532;
                                                vector185 = Vector2.UnitY * -14f;
                                            }
                                        }
                                        if (this.type == NPCID.SolarDrakomireRider)
                                        {
                                            if (this.localAI[0] == 0f && Main.netMode != 1)
                                            {
                                                this.localAI[0] = 1f;
                                                int num1533 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 415, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                this.ai[0] = (float)num1533;
                                                this.netUpdate = true;
                                            }
                                            int num1534 = (int)this.ai[0];
                                            if (Main.npc[num1534].active && Main.npc[num1534].type == NPCID.SolarDrakomire)
                                            {
                                                if (this.timeLeft < 60)
                                                {
                                                    this.timeLeft = 60;
                                                }
                                                num1529 = num1534;
                                                vector185 = new Vector2((float)(-(float)Main.npc[num1534].spriteDirection * 10), -30f);
                                            }
                                        }
                                        else if (this.type == NPCID.MartianSaucer)
                                        {
                                            int num1535 = (int)this.ai[0];
                                            if (Main.npc[num1535].active && Main.npc[num1535].type == NPCID.MartianSaucerCore)
                                            {
                                                if (this.timeLeft < 60)
                                                {
                                                    this.timeLeft = 60;
                                                }
                                                num1529 = num1535;
                                                vector185 = Vector2.UnitY * 2f;
                                                vector185 *= Main.npc[num1535].scale;
                                                float num1536 = Main.npc[num1535].rotation;
                                                vector185 = vector185.RotatedBy((double)num1536, default(Vector2));
                                                this.rotation = num1536;
                                                if (Main.netMode != 1)
                                                {
                                                    bool flag140 = true;
                                                    if (Main.npc[num1535].ai[0] >= 1f || Main.npc[num1535].ai[0] < 0f)
                                                    {
                                                        flag140 = false;
                                                    }
                                                    if (flag140)
                                                    {
                                                        for (int num1537 = 0; num1537 < 2; num1537++)
                                                        {
                                                            if (Main.npc[(int)this.localAI[num1537]].active && Main.npc[(int)this.localAI[num1537]].type == 393)
                                                            {
                                                                flag140 = false;
                                                            }
                                                        }
                                                        for (int num1538 = 2; num1538 < 4; num1538++)
                                                        {
                                                            if (Main.npc[(int)this.localAI[num1538]].active && Main.npc[(int)this.localAI[num1538]].type == 394)
                                                            {
                                                                flag140 = false;
                                                            }
                                                        }
                                                    }
                                                    if (flag140)
                                                    {
                                                        Main.npc[num1535].ai[0] = 1f;
                                                        Main.npc[num1535].ai[1] = 0f;
                                                        Main.npc[num1535].ai[2] = 0f;
                                                        Main.npc[num1535].ai[3] = 0f;
                                                        Main.npc[num1535].netUpdate = true;
                                                    }
                                                }
                                            }
                                        }
                                        else if (this.type == NPCID.MartianSaucerTurret)
                                        {
                                            int num1539 = (int)this.ai[0];
                                            if (Main.npc[num1539].active && Main.npc[num1539].type == NPCID.MartianSaucerCore)
                                            {
                                                if (this.timeLeft < 60)
                                                {
                                                    this.timeLeft = 60;
                                                }
                                                num1529 = num1539;
                                                vector185 = Vector2.UnitY * 29f + ((this.ai[1] == 1f) ? Vector2.UnitX : (-Vector2.UnitX)) * 60f;
                                                vector185 *= Main.npc[num1539].scale;
                                                float num1540 = Main.npc[num1539].rotation;
                                                vector185 = vector185.RotatedBy((double)num1540, default(Vector2));
                                                this.rotation = num1540;
                                            }
                                        }
                                        else if (this.type == NPCID.MartianSaucerCannon)
                                        {
                                            int num1541 = (int)this.ai[0];
                                            if (Main.npc[num1541].active && Main.npc[num1541].type == NPCID.MartianSaucerCore)
                                            {
                                                if (this.timeLeft < 60)
                                                {
                                                    this.timeLeft = 60;
                                                }
                                                num1529 = num1541;
                                                vector185 = Vector2.UnitY * -13f + ((this.ai[1] == 1f) ? Vector2.UnitX : (-Vector2.UnitX)) * 49f;
                                                vector185 *= Main.npc[num1541].scale;
                                                float num1542 = Main.npc[num1541].rotation;
                                                vector185 = vector185.RotatedBy((double)num1542, default(Vector2));
                                                this.rotation = num1542;
                                                num1530 = ((this.ai[1] == 1f) ? 1 : -1);
                                            }
                                        }
                                        else if (this.type == NPCID.PirateShipCannon)
                                        {
                                            int num1543 = (int)this.ai[0];
                                            if (Main.npc[num1543].active && Main.npc[num1543].type == NPCID.PirateShip)
                                            {
                                                if (this.timeLeft < 60)
                                                {
                                                    this.timeLeft = 60;
                                                }
                                                num1529 = num1543;
                                                vector185 = new Vector2((-122f + 68f * this.ai[1]) * (float)((Main.npc[num1543].spriteDirection == 1) ? -1 : 1), -6f);
                                                vector185 *= Main.npc[num1543].scale;
                                                float num1544 = Main.npc[num1543].rotation;
                                                vector185 = vector185.RotatedBy((double)num1544, default(Vector2));
                                                this.rotation = num1544;
                                            }
                                        }
                                        if (num1529 != -1)
                                        {
                                            NPC nPC7 = Main.npc[num1529];
                                            this.velocity = Vector2.Zero;
                                            this.position = nPC7.Center;
                                            this.position.X = this.position.X - (float)(this.width / 2);
                                            this.position.Y = this.position.Y - (float)(this.height / 2);
                                            this.position += vector185;
                                            this.gfxOffY = nPC7.gfxOffY;
                                            this.direction = nPC7.direction;
                                            if (num1530 == 0)
                                            {
                                                this.spriteDirection = nPC7.spriteDirection;
                                            }
                                            else
                                            {
                                                this.spriteDirection = num1530;
                                            }
                                            if (this.type == NPCID.ScutlixRider)
                                            {
                                                this.timeLeft = nPC7.timeLeft;
                                                this.velocity = nPC7.velocity;
                                                this.target = nPC7.target;
                                                if (this.ai[1] < 60f)
                                                {
                                                    this.ai[1] += 1f;
                                                }
                                                if (this.justHit)
                                                {
                                                    this.ai[1] = -30f;
                                                }
                                                int num1545 = 438;
                                                int num1546 = 30;
                                                float scaleFactor20 = 7f;
                                                if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                                {
                                                    Vector2 vector186 = Main.player[this.target].Center - base.Center;
                                                    Vector2 vector187 = Vector2.Normalize(vector186);
                                                    float num1547 = vector186.Length();
                                                    float num1548 = 700f;
                                                    if (this.type == NPCID.PirateDeadeye)
                                                    {
                                                        num1548 = 550f;
                                                    }
                                                    if (this.type == NPCID.PirateCrossbower)
                                                    {
                                                        num1548 = 800f;
                                                    }
                                                    if (num1547 < num1548)
                                                    {
                                                        if (this.ai[1] == 60f && Math.Sign(vector186.X) == this.direction)
                                                        {
                                                            this.ai[1] = -60f;
                                                            Vector2 center12 = Main.player[this.target].Center;
                                                            Vector2 value26 = base.Center - Vector2.UnitY * 4f;
                                                            Vector2 vector188 = center12 - value26;
                                                            vector188.X += (float)Main.rand.Next(-50, 51);
                                                            vector188.Y += (float)Main.rand.Next(-50, 51);
                                                            vector188.X *= (float)Main.rand.Next(80, 121) * 0.01f;
                                                            vector188.Y *= (float)Main.rand.Next(80, 121) * 0.01f;
                                                            vector188.Normalize();
                                                            if (float.IsNaN(vector188.X) || float.IsNaN(vector188.Y))
                                                            {
                                                                vector188 = -Vector2.UnitY;
                                                            }
                                                            vector188 *= scaleFactor20;
                                                            Projectile.NewProjectile(value26.X, value26.Y, vector188.X, vector188.Y, num1545, num1546, 0f, Main.myPlayer, 0f, 0f);
                                                            this.netUpdate = true;
                                                        }
                                                        else
                                                        {
                                                            float num1549 = this.ai[2];
                                                            this.velocity.X = this.velocity.X * 0.5f;
                                                            this.ai[2] = 3f;
                                                            if (Math.Abs(vector187.Y) > Math.Abs(vector187.X) * 2f)
                                                            {
                                                                if (vector187.Y > 0f)
                                                                {
                                                                    this.ai[2] = 1f;
                                                                }
                                                                else
                                                                {
                                                                    this.ai[2] = 5f;
                                                                }
                                                            }
                                                            else if (Math.Abs(vector187.X) > Math.Abs(vector187.Y) * 2f)
                                                            {
                                                                this.ai[2] = 3f;
                                                            }
                                                            else if (vector187.Y > 0f)
                                                            {
                                                                this.ai[2] = 2f;
                                                            }
                                                            else
                                                            {
                                                                this.ai[2] = 4f;
                                                            }
                                                            if (this.ai[2] != num1549)
                                                            {
                                                                this.netUpdate = true;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.type == NPCID.PirateShipCannon)
                                            {
                                                this.timeLeft = nPC7.timeLeft;
                                                this.velocity = nPC7.velocity;
                                                if (this.ai[3] < 240f)
                                                {
                                                    this.ai[3] += 1f;
                                                }
                                                if (this.ai[3] == 2f)
                                                {
                                                    this.TargetClosest(false);
                                                }
                                                if (Collision.CanHit(this.position, this.width, this.height, Main.player[this.target].position, Main.player[this.target].width, Main.player[this.target].height))
                                                {
                                                    Vector2 vector189 = Main.player[this.target].Center - base.Center;
                                                    Vector2.Normalize(vector189);
                                                    if (this.ai[3] >= 240f)
                                                    {
                                                        this.ai[3] = 0f;
                                                        Vector2 center13 = Main.player[this.target].Center;
                                                        Vector2 center14 = base.Center;
                                                        Vector2 value27 = Vector2.Normalize(center13 - center14);
                                                        if (float.IsNaN(value27.X) || float.IsNaN(value27.Y))
                                                        {
                                                            value27 = Vector2.UnitY;
                                                        }
                                                        value27 *= 14f;
                                                        value27 += Vector2.UnitY * -5f;
                                                        if (Main.netMode != 1)
                                                        {
                                                            Projectile.NewProjectile(center14.X, center14.Y, value27.X, value27.Y, 240, 30, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                        this.netUpdate = true;
                                                    }
                                                    else
                                                    {
                                                        float num1550 = this.ai[2];
                                                        float[] array4 = new float[8];
                                                        for (int num1551 = 0; num1551 < array4.Length; num1551++)
                                                        {
                                                            array4[num1551] = Vector2.Distance(base.Center + Vector2.UnitY.RotatedBy((double)((float)num1551 * -0.7853982f), default(Vector2)) * 50f, Main.player[this.target].Center);
                                                        }
                                                        int num1552 = 0;
                                                        for (int num1553 = 1; num1553 < array4.Length; num1553++)
                                                        {
                                                            if (array4[num1552] > array4[num1553])
                                                            {
                                                                num1552 = num1553;
                                                            }
                                                        }
                                                        this.ai[2] = (float)(num1552 + 1);
                                                        if (this.spriteDirection == 1)
                                                        {
                                                            this.ai[2] = 9f - this.ai[2];
                                                        }
                                                        if (this.ai[2] != num1550)
                                                        {
                                                            this.netUpdate = true;
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.ai[2] != 0f)
                                                    {
                                                        this.netUpdate = true;
                                                    }
                                                    this.ai[2] = 0f;
                                                }
                                            }
                                            if (this.type == NPCID.MartianSaucerCannon)
                                            {
                                                this.timeLeft = nPC7.timeLeft;
                                                int num1554 = 50;
                                                if (Main.expertMode)
                                                {
                                                    num1554 = 37;
                                                }
                                                this.ai[3] = nPC7.ai[3];
                                                float num1555 = 440f;
                                                float num1556 = 140f;
                                                if (this.ai[3] >= num1555 && this.ai[3] < num1555 + num1556)
                                                {
                                                    float num1557 = this.ai[3] - num1555;
                                                    if (num1557 % 20f == 0f)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 spinningpoint2 = (float)num1530 * Vector2.UnitX;
                                                            spinningpoint2 = spinningpoint2.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331, default(Vector2));
                                                            spinningpoint2 *= 8f;
                                                            Vector2 vector190 = (float)num1530 * Vector2.UnitX * 36f + base.Center + Vector2.UnitY * 8f;
                                                            Projectile.NewProjectile(vector190.X, vector190.Y, spinningpoint2.X, spinningpoint2.Y, 448, num1554, 0f, Main.myPlayer, 0f, 20f);
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.type == NPCID.MartianSaucerTurret)
                                            {
                                                this.timeLeft = nPC7.timeLeft;
                                                int num1558 = 35;
                                                if (Main.expertMode)
                                                {
                                                    num1558 = 30;
                                                }
                                                this.ai[3] = nPC7.ai[3];
                                                float num1559 = 280f;
                                                float num1560 = 140f;
                                                bool flag141 = this.ai[3] >= num1559 && this.ai[3] < num1559 + num1560;
                                                if (!flag141)
                                                {
                                                    this.TargetClosest(false);
                                                    Player player7 = Main.player[this.target];
                                                    Vector2 v = player7.Center - base.Center;
                                                    if (v.Y < 0f)
                                                    {
                                                        v.Y = 0f;
                                                    }
                                                    v.Normalize();
                                                    if (float.IsNaN(v.X) || float.IsNaN(v.Y))
                                                    {
                                                        v = Vector2.UnitY;
                                                    }
                                                    this.ai[2] = v.ToRotation();
                                                }
                                                if (flag141)
                                                {
                                                    float num1561 = this.ai[3] - num1559;
                                                    if (num1561 % 6f == 0f)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 spinningpoint3 = this.ai[2].ToRotationVector2();
                                                            spinningpoint3 = spinningpoint3.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331 / 3.0, default(Vector2));
                                                            spinningpoint3 *= 16f;
                                                            Vector2 vector191 = base.Center + spinningpoint3 * 1f;
                                                            Projectile.NewProjectile(vector191.X, vector191.Y, spinningpoint3.X, spinningpoint3.Y, 449, num1558, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.type == NPCID.MartianSaucer)
                                            {
                                                this.timeLeft = nPC7.timeLeft;
                                                int num1562 = 70;
                                                if (Main.expertMode)
                                                {
                                                    num1562 = 50;
                                                }
                                                this.ai[3] = nPC7.ai[3];
                                                float num1563 = 20f;
                                                float num1564 = 240f;
                                                bool flag142 = this.ai[3] >= num1563 && this.ai[3] < num1563 + num1564 && nPC7.ai[0] == 0f;
                                                if (flag142)
                                                {
                                                    float num1565 = this.ai[3] - num1563;
                                                    if (num1565 == 0f)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 center15 = base.Center;
                                                            Projectile.NewProjectile(center15.X, center15.Y, 0f, 0f, 447, num1562, 0f, Main.myPlayer, (float)(this.whoAmI + 1), 0f);
                                                        }
                                                    }
                                                }
                                                flag142 = false;
                                                int maxValue10 = 1000;
                                                int maxValue11 = 1000;
                                                int num1566 = 450;
                                                int num1567 = 30;
                                                if (Main.expertMode)
                                                {
                                                    num1567 = 25;
                                                }
                                                if (nPC7.ai[0] == 2f)
                                                {
                                                    flag142 = true;
                                                    maxValue11 = 120;
                                                    maxValue10 = 120;
                                                }
                                                if (!flag142)
                                                {
                                                    num1563 = 280f;
                                                    num1564 = 120f;
                                                    flag142 = (flag142 || (this.ai[3] >= num1563 && this.ai[3] < num1563 + num1564));
                                                    if (flag142)
                                                    {
                                                        maxValue11 = 90;
                                                        maxValue10 = 60;
                                                    }
                                                }
                                                if (!flag142)
                                                {
                                                    num1563 = 440f;
                                                    num1564 = 140f;
                                                    flag142 = (flag142 || (this.ai[3] >= num1563 && this.ai[3] < num1563 + num1564));
                                                    if (flag142)
                                                    {
                                                        maxValue11 = 60;
                                                        maxValue10 = 90;
                                                    }
                                                }
                                                bool flag143 = true;
                                                bool flag144 = true;
                                                bool flag145 = true;
                                                bool flag146 = true;
                                                if (Main.npc[(int)this.localAI[0]].active && Main.npc[(int)this.localAI[0]].type == 393)
                                                {
                                                    flag143 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[1]].active && Main.npc[(int)this.localAI[1]].type == 393)
                                                {
                                                    flag144 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[2]].active && Main.npc[(int)this.localAI[2]].type == 394)
                                                {
                                                    flag145 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[3]].active && Main.npc[(int)this.localAI[3]].type == 394)
                                                {
                                                    flag146 = false;
                                                }
                                                if (flag142)
                                                {
                                                    bool flag147 = flag143;
                                                    if (flag147 && Main.rand.Next(maxValue10) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 spinningpoint4 = new Vector2(-1f * (float)Main.rand.NextDouble() * 3f, 1f);
                                                            spinningpoint4 = spinningpoint4.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331, default(Vector2));
                                                            spinningpoint4 *= 3f;
                                                            Vector2 vector192 = -1f * Vector2.UnitX * (float)Main.rand.Next(50, 70) + base.Center + Vector2.UnitY * (float)Main.rand.Next(30, 45);
                                                            Projectile.NewProjectile(vector192.X, vector192.Y, spinningpoint4.X, spinningpoint4.Y, num1566, num1567, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                    flag147 = flag144;
                                                    if (flag147 && Main.rand.Next(maxValue10) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 spinningpoint5 = new Vector2(1f * (float)Main.rand.NextDouble() * 3f, 1f);
                                                            spinningpoint5 = spinningpoint5.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331, default(Vector2));
                                                            spinningpoint5 *= 3f;
                                                            Vector2 vector193 = 1f * Vector2.UnitX * (float)Main.rand.Next(50, 70) + base.Center + Vector2.UnitY * (float)Main.rand.Next(30, 45);
                                                            Projectile.NewProjectile(vector193.X, vector193.Y, spinningpoint5.X, spinningpoint5.Y, num1566, num1567, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                }
                                                if (flag142)
                                                {
                                                    bool flag148 = flag145;
                                                    if (flag148 && Main.rand.Next(maxValue11) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 spinningpoint6 = new Vector2(-1f * (float)Main.rand.NextDouble() * 2f, -1f);
                                                            spinningpoint6 = spinningpoint6.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331, default(Vector2));
                                                            spinningpoint6 *= 3f;
                                                            Vector2 vector194 = -1f * Vector2.UnitX * (float)Main.rand.Next(30, 60) + base.Center + Vector2.UnitY * (float)Main.rand.Next(-30, -10);
                                                            Projectile.NewProjectile(vector194.X, vector194.Y, spinningpoint6.X, spinningpoint6.Y, num1566, num1567, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                    flag148 = flag146;
                                                    if (flag148 && Main.rand.Next(maxValue11) == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            Vector2 spinningpoint7 = new Vector2(1f * (float)Main.rand.NextDouble() * 2f, -1f);
                                                            spinningpoint7 = spinningpoint7.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331, default(Vector2));
                                                            spinningpoint7 *= 3f;
                                                            Vector2 vector195 = 1f * Vector2.UnitX * (float)Main.rand.Next(30, 60) + base.Center + Vector2.UnitY * (float)Main.rand.Next(-30, -10);
                                                            Projectile.NewProjectile(vector195.X, vector195.Y, spinningpoint7.X, spinningpoint7.Y, num1566, num1567, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                }
                                                if (flag146 && Main.rand.Next(8) == 0)
                                                {
                                                    return;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (this.type == NPCID.ScutlixRider)
                                            {
                                                this.Transform(382);
                                                return;
                                            }
                                            if (this.type == NPCID.SolarDrakomireRider)
                                            {
                                                this.Transform(518);
                                                return;
                                            }
                                            this.life = 0;
                                            this.HitEffect(0, 10.0);
                                            this.active = false;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 76)
                                    {
                                        if (this.localAI[3] == 0f && Main.netMode != 1 && this.type == NPCID.MartianSaucerCore)
                                        {
                                            this.localAI[3] = 1f;
                                            int[] array5 = new int[4];
                                            int num1572 = 0;
                                            for (int num1573 = 0; num1573 < 2; num1573++)
                                            {
                                                int num1574 = NPC.NewNPC((int)base.Center.X + num1573 * 300 - 150, (int)base.Center.Y, 393, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                Main.npc[num1574].ai[1] = (float)num1573;
                                                Main.npc[num1574].netUpdate = true;
                                                array5[num1572++] = num1574;
                                            }
                                            for (int num1575 = 0; num1575 < 2; num1575++)
                                            {
                                                int num1576 = NPC.NewNPC((int)base.Center.X + num1575 * 300 - 150, (int)base.Center.Y, 394, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                Main.npc[num1576].ai[1] = (float)num1575;
                                                Main.npc[num1576].netUpdate = true;
                                                array5[num1572++] = num1576;
                                            }
                                            int num1577 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y, 392, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                            Main.npc[num1577].ai[0] = (float)this.whoAmI;
                                            Main.npc[num1577].netUpdate = true;
                                            for (int num1578 = 0; num1578 < 4; num1578++)
                                            {
                                                Main.npc[array5[num1578]].ai[0] = (float)this.whoAmI;
                                            }
                                            for (int num1579 = 0; num1579 < 4; num1579++)
                                            {
                                                Main.npc[num1577].localAI[num1579] = (float)array5[num1579];
                                            }
                                        }
                                        Vector2 center16 = base.Center;
                                        Player player8 = Main.player[this.target];
                                        if (this.target < 0 || this.target == 255 || player8.dead || !player8.active)
                                        {
                                            this.TargetClosest(true);
                                            player8 = Main.player[this.target];
                                            this.netUpdate = true;
                                        }
                                        if ((player8.dead || Vector2.Distance(player8.Center, center16) > 3200f) && this.ai[0] != 1f)
                                        {
                                            if (this.ai[0] == 0f)
                                            {
                                                this.ai[0] = -1f;
                                            }
                                            if (this.ai[0] == 2f)
                                            {
                                                this.ai[0] = -2f;
                                            }
                                            this.netUpdate = true;
                                        }
                                        if (this.ai[0] == -1f || this.ai[0] == -2f)
                                        {
                                            this.velocity.Y = this.velocity.Y - 0.4f;
                                            if (this.timeLeft > 10)
                                            {
                                                this.timeLeft = 10;
                                            }
                                            if (!player8.dead)
                                            {
                                                this.timeLeft = 300;
                                                if (this.ai[0] == -2f)
                                                {
                                                    this.ai[0] = 2f;
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.ai[0] = 0f;
                                                }
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 0f)
                                        {
                                            int num1580 = 0;
                                            if (this.ai[3] >= 580f)
                                            {
                                                num1580 = 0;
                                            }
                                            else if (this.ai[3] >= 440f)
                                            {
                                                num1580 = 5;
                                            }
                                            else if (this.ai[3] >= 420f)
                                            {
                                                num1580 = 4;
                                            }
                                            else if (this.ai[3] >= 280f)
                                            {
                                                num1580 = 3;
                                            }
                                            else if (this.ai[3] >= 260f)
                                            {
                                                num1580 = 2;
                                            }
                                            else if (this.ai[3] >= 20f)
                                            {
                                                num1580 = 1;
                                            }
                                            this.ai[3] += 1f;
                                            if (this.ai[3] >= 600f)
                                            {
                                                this.ai[3] = 0f;
                                            }
                                            int num1581 = num1580;
                                            if (this.ai[3] >= 580f)
                                            {
                                                num1580 = 0;
                                            }
                                            else if (this.ai[3] >= 440f)
                                            {
                                                num1580 = 5;
                                            }
                                            else if (this.ai[3] >= 420f)
                                            {
                                                num1580 = 4;
                                            }
                                            else if (this.ai[3] >= 280f)
                                            {
                                                num1580 = 3;
                                            }
                                            else if (this.ai[3] >= 260f)
                                            {
                                                num1580 = 2;
                                            }
                                            else if (this.ai[3] >= 20f)
                                            {
                                                num1580 = 1;
                                            }
                                            if (num1580 != num1581)
                                            {
                                                if (num1580 == 0)
                                                {
                                                    this.ai[2] = 0f;
                                                }
                                                if (num1580 == 1)
                                                {
                                                    this.ai[2] = (float)((Math.Sign((player8.Center - center16).X) == 1) ? 1 : -1);
                                                }
                                                if (num1580 == 2)
                                                {
                                                    this.ai[2] = 0f;
                                                }
                                                this.netUpdate = true;
                                            }
                                            if (num1580 == 0)
                                            {
                                                if (this.ai[2] == 0f)
                                                {
                                                    this.ai[2] = (float)(-600 * Math.Sign((center16 - player8.Center).X));
                                                }
                                                Vector2 vector196 = player8.Center + new Vector2(this.ai[2], -250f) - center16;
                                                if (vector196.Length() < 50f)
                                                {
                                                    this.ai[3] = 19f;
                                                }
                                                else
                                                {
                                                    vector196.Normalize();
                                                    this.velocity = Vector2.Lerp(this.velocity, vector196 * 16f, 0.1f);
                                                }
                                            }
                                            if (num1580 == 1)
                                            {
                                                int num1582 = (int)base.Center.X / 16;
                                                int num1583 = (int)(this.position.Y + (float)this.height) / 16;
                                                int num1584 = 0;
                                                bool flag149 = Main.tile[num1582, num1583].nactive() && Main.tileSolid[(int)Main.tile[num1582, num1583].type] && !Main.tileSolidTop[(int)Main.tile[num1582, num1583].type];
                                                if (flag149)
                                                {
                                                    num1584 = 1;
                                                }
                                                else
                                                {
                                                    while (num1584 < 150 && num1583 + num1584 < Main.maxTilesY)
                                                    {
                                                        int num1585 = num1583 + num1584;
                                                        bool flag150 = Main.tile[num1582, num1585].nactive() && Main.tileSolid[(int)Main.tile[num1582, num1585].type] && !Main.tileSolidTop[(int)Main.tile[num1582, num1585].type];
                                                        if (flag150)
                                                        {
                                                            num1584--;
                                                            break;
                                                        }
                                                        num1584++;
                                                    }
                                                }
                                                float num1586 = (float)(num1584 * 16);
                                                float num1587 = 250f;
                                                if (num1586 < num1587)
                                                {
                                                    float num1588 = -4f;
                                                    if (-num1588 > num1586)
                                                    {
                                                        num1588 = -num1586;
                                                    }
                                                    this.velocity.Y = MathHelper.Lerp(this.velocity.Y, num1588, 0.05f);
                                                }
                                                else
                                                {
                                                    this.velocity.Y = this.velocity.Y * 0.95f;
                                                }
                                                this.velocity.X = 3.5f * this.ai[2];
                                            }
                                            if (num1580 == 2)
                                            {
                                                if (this.ai[2] == 0f)
                                                {
                                                    this.ai[2] = (float)(300 * Math.Sign((center16 - player8.Center).X));
                                                }
                                                Vector2 vector197 = player8.Center + new Vector2(this.ai[2], -170f) - center16;
                                                int num1589 = (int)base.Center.X / 16;
                                                int num1590 = (int)(this.position.Y + (float)this.height) / 16;
                                                int num1591 = 0;
                                                bool flag151 = Main.tile[num1589, num1590].nactive() && Main.tileSolid[(int)Main.tile[num1589, num1590].type] && !Main.tileSolidTop[(int)Main.tile[num1589, num1590].type];
                                                if (flag151)
                                                {
                                                    num1591 = 1;
                                                }
                                                else
                                                {
                                                    while (num1591 < 150 && num1590 + num1591 < Main.maxTilesY)
                                                    {
                                                        int num1592 = num1590 + num1591;
                                                        bool flag152 = Main.tile[num1589, num1592].nactive() && Main.tileSolid[(int)Main.tile[num1589, num1592].type] && !Main.tileSolidTop[(int)Main.tile[num1589, num1592].type];
                                                        if (flag152)
                                                        {
                                                            num1591--;
                                                            break;
                                                        }
                                                        num1591++;
                                                    }
                                                }
                                                float num1593 = (float)(num1591 * 16);
                                                float num1594 = 170f;
                                                if (num1593 < num1594)
                                                {
                                                    vector197.Y -= num1594 - num1593;
                                                }
                                                if (vector197.Length() < 70f)
                                                {
                                                    this.ai[3] = 279f;
                                                }
                                                else
                                                {
                                                    vector197.Normalize();
                                                    this.velocity = Vector2.Lerp(this.velocity, vector197 * 20f, 0.1f);
                                                }
                                            }
                                            else if (num1580 == 3)
                                            {
                                                float num1595 = 0.85f;
                                                int num1596 = (int)base.Center.X / 16;
                                                int num1597 = (int)(this.position.Y + (float)this.height) / 16;
                                                int num1598 = 0;
                                                bool flag153 = Main.tile[num1596, num1597].nactive() && Main.tileSolid[(int)Main.tile[num1596, num1597].type] && !Main.tileSolidTop[(int)Main.tile[num1596, num1597].type];
                                                if (flag153)
                                                {
                                                    num1598 = 1;
                                                }
                                                else
                                                {
                                                    while (num1598 < 150 && num1597 + num1598 < Main.maxTilesY)
                                                    {
                                                        int num1599 = num1597 + num1598;
                                                        bool flag154 = Main.tile[num1596, num1599].nactive() && Main.tileSolid[(int)Main.tile[num1596, num1599].type] && !Main.tileSolidTop[(int)Main.tile[num1596, num1599].type];
                                                        if (flag154)
                                                        {
                                                            num1598--;
                                                            break;
                                                        }
                                                        num1598++;
                                                    }
                                                }
                                                float num1600 = (float)(num1598 * 16);
                                                float num1601 = 170f;
                                                if (num1600 < num1601)
                                                {
                                                    float num1602 = -4f;
                                                    if (-num1602 > num1600)
                                                    {
                                                        num1602 = -num1600;
                                                    }
                                                    this.velocity.Y = MathHelper.Lerp(this.velocity.Y, num1602, 0.05f);
                                                }
                                                else
                                                {
                                                    this.velocity.Y = this.velocity.Y * num1595;
                                                }
                                                this.velocity.X = this.velocity.X * num1595;
                                            }
                                            if (num1580 == 4)
                                            {
                                                Vector2 vector198 = player8.Center + new Vector2(0f, -250f) - center16;
                                                if (vector198.Length() < 50f)
                                                {
                                                    this.ai[3] = 439f;
                                                    return;
                                                }
                                                vector198.Normalize();
                                                this.velocity = Vector2.Lerp(this.velocity, vector198 * 16f, 0.1f);
                                                return;
                                            }
                                            else if (num1580 == 5)
                                            {
                                                this.velocity *= 0.85f;
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            this.dontTakeDamage = false;
                                            this.velocity *= 0.96f;
                                            float num1603 = 150f;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= num1603)
                                            {
                                                this.ai[0] = 2f;
                                                this.ai[1] = 0f;
                                                this.rotation = 0f;
                                                this.netUpdate = true;
                                                return;
                                            }
                                            if (this.ai[1] < 40f)
                                            {
                                                this.rotation = Vector2.UnitY.RotatedBy((double)(this.ai[1] / 40f * 6.28318548f), default(Vector2)).Y * 0.2f;
                                                return;
                                            }
                                            if (this.ai[1] < 80f)
                                            {
                                                this.rotation = Vector2.UnitY.RotatedBy((double)(this.ai[1] / 20f * 6.28318548f), default(Vector2)).Y * 0.3f;
                                                return;
                                            }
                                            if (this.ai[1] < 120f)
                                            {
                                                this.rotation = Vector2.UnitY.RotatedBy((double)(this.ai[1] / 10f * 6.28318548f), default(Vector2)).Y * 0.4f;
                                                return;
                                            }
                                            this.rotation = (this.ai[1] - 120f) / 30f * 6.28318548f;
                                            return;
                                        }
                                        else if (this.ai[0] == 2f)
                                        {
                                            int num1604 = 100;
                                            float num1605 = 3600f;
                                            float num1606 = 120f;
                                            float num1607 = 60f;
                                            int num1608 = 0;
                                            if (this.ai[3] % num1606 >= num1607)
                                            {
                                                num1608 = 1;
                                            }
                                            int num1609 = num1608;
                                            num1608 = 0;
                                            this.ai[3] += 1f;
                                            if (this.ai[3] % num1606 >= num1607)
                                            {
                                                num1608 = 1;
                                            }
                                            if (num1608 != num1609)
                                            {
                                                if (num1608 == 1)
                                                {
                                                    this.ai[2] = (float)((Math.Sign((player8.Center - center16).X) == 1) ? 1 : -1);
                                                    if (Main.netMode != 1)
                                                    {
                                                        Vector2 center17 = base.Center;
                                                        Projectile.NewProjectile(center17.X, center17.Y, 0f, 0f, 447, num1604, 0f, Main.myPlayer, (float)(this.whoAmI + 1), 0f);
                                                    }
                                                }
                                                this.netUpdate = true;
                                            }
                                            if (this.ai[3] >= num1605)
                                            {
                                                this.ai[0] = 2f;
                                                this.ai[1] = 0f;
                                                this.ai[2] = 0f;
                                                this.ai[3] = 0f;
                                                this.netUpdate = true;
                                            }
                                            else if (num1608 == 0)
                                            {
                                                Vector2 vector199 = player8.Center + new Vector2(this.ai[2] * 350f, -250f) - center16;
                                                vector199.Normalize();
                                                this.velocity = Vector2.Lerp(this.velocity, vector199 * 16f, 0.1f);
                                            }
                                            else
                                            {
                                                int num1610 = (int)base.Center.X / 16;
                                                int num1611 = (int)(this.position.Y + (float)this.height) / 16;
                                                int num1612 = 0;
                                                bool flag155 = Main.tile[num1610, num1611].nactive() && Main.tileSolid[(int)Main.tile[num1610, num1611].type] && !Main.tileSolidTop[(int)Main.tile[num1610, num1611].type];
                                                if (flag155)
                                                {
                                                    num1612 = 1;
                                                }
                                                else
                                                {
                                                    while (num1612 < 150 && num1611 + num1612 < Main.maxTilesY)
                                                    {
                                                        int num1613 = num1611 + num1612;
                                                        bool flag156 = Main.tile[num1610, num1613].nactive() && Main.tileSolid[(int)Main.tile[num1610, num1613].type] && !Main.tileSolidTop[(int)Main.tile[num1610, num1613].type];
                                                        if (flag156)
                                                        {
                                                            num1612--;
                                                            break;
                                                        }
                                                        num1612++;
                                                    }
                                                }
                                                float num1614 = (float)(num1612 * 16);
                                                float num1615 = 250f;
                                                if (num1614 < num1615)
                                                {
                                                    float num1616 = -4f;
                                                    if (-num1616 > num1614)
                                                    {
                                                        num1616 = -num1614;
                                                    }
                                                    this.velocity.Y = MathHelper.Lerp(this.velocity.Y, num1616, 0.05f);
                                                }
                                                else
                                                {
                                                    this.velocity.Y = this.velocity.Y * 0.95f;
                                                }
                                                this.velocity.X = 8f * this.ai[2];
                                            }
                                            this.rotation = 0f;
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 77)
                                    {
                                        if (this.localAI[3] == 0f)
                                        {
                                            this.netUpdate = true;
                                            this.localAI[3] = 1f;
                                            this.ai[0] = -1f;
                                        }
                                        if (this.ai[0] == -2f)
                                        {
                                            this.dontTakeDamage = true;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] < 60f)
                                            {
                                                MoonlordDeathDrama.RequestLight(this.ai[1] / 30f, base.Center);
                                            }
                                            if (this.ai[1] == 60f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[0] = 0f;
                                                if (Main.netMode != 1 && this.type == NPCID.MoonLordCore)
                                                {
                                                    this.ai[2] = (float)Main.rand.Next(3);
                                                    this.ai[2] = 0f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                        }
                                        if (this.ai[0] == -1f)
                                        {
                                            this.dontTakeDamage = true;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] < 60f)
                                            {
                                                MoonlordDeathDrama.RequestLight(this.ai[1] / 30f, base.Center);
                                            }
                                            if (this.ai[1] == 60f)
                                            {
                                                this.ai[1] = 0f;
                                                this.ai[0] = 0f;
                                                if (Main.netMode != 1 && this.type == NPCID.MoonLordCore)
                                                {
                                                    this.ai[2] = (float)Main.rand.Next(3);
                                                    this.ai[2] = 0f;
                                                    this.netUpdate = true;
                                                    int[] array6 = new int[3];
                                                    int num1617 = 0;
                                                    for (int num1618 = 0; num1618 < 2; num1618++)
                                                    {
                                                        int num1619 = NPC.NewNPC((int)base.Center.X + num1618 * 800 - 400, (int)base.Center.Y - 100, 397, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num1619].ai[2] = (float)num1618;
                                                        Main.npc[num1619].netUpdate = true;
                                                        array6[num1617++] = num1619;
                                                    }
                                                    int num1620 = NPC.NewNPC((int)base.Center.X, (int)base.Center.Y - 400, 396, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                    Main.npc[num1620].netUpdate = true;
                                                    array6[num1617++] = num1620;
                                                    for (int num1621 = 0; num1621 < 3; num1621++)
                                                    {
                                                        Main.npc[array6[num1621]].ai[3] = (float)this.whoAmI;
                                                    }
                                                    for (int num1622 = 0; num1622 < 3; num1622++)
                                                    {
                                                        this.localAI[num1622] = (float)array6[num1622];
                                                    }
                                                }
                                            }
                                        }
                                        if (this.ai[0] == 0f)
                                        {
                                            this.dontTakeDamage = true;
                                            this.TargetClosest(false);
                                            Vector2 value28 = Main.player[this.target].Center - base.Center + new Vector2(0f, 130f);
                                            if (value28.Length() > 20f)
                                            {
                                                Vector2 desiredVelocity2 = Vector2.Normalize(value28 - this.velocity) * 8f;
                                                Vector2 velocity3 = this.velocity;
                                                this.SimpleFlyMovement(desiredVelocity2, 0.5f);
                                                this.velocity = Vector2.Lerp(this.velocity, velocity3, 0.5f);
                                            }
                                            if (Main.netMode != 1)
                                            {
                                                bool flag157 = false;
                                                if (this.localAI[0] < 0f || this.localAI[1] < 0f || this.localAI[2] < 0f)
                                                {
                                                    flag157 = true;
                                                }
                                                else if (!Main.npc[(int)this.localAI[0]].active || Main.npc[(int)this.localAI[0]].type != 397)
                                                {
                                                    flag157 = true;
                                                }
                                                else if (!Main.npc[(int)this.localAI[1]].active || Main.npc[(int)this.localAI[1]].type != 397)
                                                {
                                                    flag157 = true;
                                                }
                                                else if (!Main.npc[(int)this.localAI[2]].active || Main.npc[(int)this.localAI[2]].type != 396)
                                                {
                                                    flag157 = true;
                                                }
                                                if (flag157)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10.0);
                                                    this.active = false;
                                                }
                                                bool flag158 = true;
                                                if (Main.npc[(int)this.localAI[0]].ai[0] != -2f)
                                                {
                                                    flag158 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[1]].ai[0] != -2f)
                                                {
                                                    flag158 = false;
                                                }
                                                if (Main.npc[(int)this.localAI[2]].ai[0] != -2f)
                                                {
                                                    flag158 = false;
                                                }
                                                if (flag158)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.dontTakeDamage = false;
                                                    this.netUpdate = true;
                                                }
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            this.dontTakeDamage = false;
                                            this.TargetClosest(false);
                                            Vector2 value29 = Main.player[this.target].Center - base.Center + new Vector2(0f, 130f);
                                            if (value29.Length() > 20f)
                                            {
                                                Vector2 desiredVelocity3 = Vector2.Normalize(value29 - this.velocity) * 8f;
                                                Vector2 velocity4 = this.velocity;
                                                this.SimpleFlyMovement(desiredVelocity3, 0.5f);
                                                this.velocity = Vector2.Lerp(this.velocity, velocity4, 0.5f);
                                            }
                                        }
                                        else if (this.ai[0] == 2f)
                                        {
                                            this.dontTakeDamage = true;
                                            Vector2 value30 = new Vector2((float)this.direction, -0.5f);
                                            this.velocity = Vector2.Lerp(this.velocity, value30, 0.98f);
                                            this.ai[1] += 1f;
                                            if (this.ai[1] < 60f)
                                            {
                                                MoonlordDeathDrama.RequestLight(this.ai[1] / 60f, base.Center);
                                            }
                                            if (this.ai[1] == 60f)
                                            {
                                                for (int num1623 = 0; num1623 < 1000; num1623++)
                                                {
                                                    Projectile projectile = Main.projectile[num1623];
                                                    if (projectile.active && (projectile.type == ProjectileID.MoonLeech || projectile.type == ProjectileID.PhantasmalBolt || projectile.type == ProjectileID.PhantasmalDeathray || projectile.type == ProjectileID.PhantasmalEye || projectile.type == ProjectileID.PhantasmalSphere))
                                                    {
                                                        projectile.Kill();
                                                    }
                                                }
                                                for (int num1624 = 0; num1624 < 200; num1624++)
                                                {
                                                    NPC nPC8 = Main.npc[num1624];
                                                    if (nPC8.active && nPC8.type == 400)
                                                    {
                                                        nPC8.HitEffect(0, 9999.0);
                                                        nPC8.active = false;
                                                    }
                                                }
                                            }
                                            if (this.ai[1] % 3f == 0f && this.ai[1] < 580f && this.ai[1] > 60f)
                                            {
                                                Vector2 vector200 = Utils.RandomVector2(Main.rand, -1f, 1f);
                                                if (vector200 != Vector2.Zero)
                                                {
                                                    vector200.Normalize();
                                                }
                                                vector200 *= 20f + Main.rand.NextFloat() * 400f;
                                                bool flag159 = true;
                                                Vector2 vec5 = base.Center + vector200;
                                                Point point7 = vec5.ToTileCoordinates();
                                                if (!WorldGen.InWorld(point7.X, point7.Y, 0))
                                                {
                                                    flag159 = false;
                                                }
                                                if (!flag159 || WorldGen.SolidTile(point7.X, point7.Y))
                                                {
                                                }
                                                float num1625 = (float)Main.rand.Next(6, 19);
                                                float num1626 = 6.28318548f / num1625;
                                                float num1627 = 6.28318548f * Main.rand.NextFloat();
                                                float scaleFactor21 = 1f + Main.rand.NextFloat() * 2f;
                                                float num1628 = 1f + Main.rand.NextFloat();
                                                float fadeIn = 0.4f + Main.rand.NextFloat();
                                                int num1629 = Utils.SelectRandom<int>(Main.rand, new int[]
                                                {
                                                    31,
                                                    229
                                                });
                                                for (float num1630 = 0f; num1630 < this.ai[1] / 60f; num1630 += 1f)
                                                {
                                                    Vector2 vector201 = Utils.RandomVector2(Main.rand, -1f, 1f);
                                                    if (vector201 != Vector2.Zero)
                                                    {
                                                        vector201.Normalize();
                                                    }
                                                    vector201 *= 20f + Main.rand.NextFloat() * 800f;
                                                    Vector2 vector202 = base.Center + vector201;
                                                    Point point8 = vector202.ToTileCoordinates();
                                                    bool flag160 = true;
                                                    if (!WorldGen.InWorld(point8.X, point8.Y, 0))
                                                    {
                                                        flag160 = false;
                                                    }
                                                    if (flag160 && WorldGen.SolidTile(point8.X, point8.Y))
                                                    {
                                                        flag160 = false;
                                                    }
                                                }
                                            }
                                            if (this.ai[1] % 15f == 0f && this.ai[1] < 480f && this.ai[1] >= 90f && Main.netMode != 1)
                                            {
                                                Vector2 vector203 = Utils.RandomVector2(Main.rand, -1f, 1f);
                                                if (vector203 != Vector2.Zero)
                                                {
                                                    vector203.Normalize();
                                                }
                                                vector203 *= 20f + Main.rand.NextFloat() * 400f;
                                                bool flag161 = true;
                                                Vector2 vec6 = base.Center + vector203;
                                                Point point9 = vec6.ToTileCoordinates();
                                                if (!WorldGen.InWorld(point9.X, point9.Y, 0))
                                                {
                                                    flag161 = false;
                                                }
                                                if (flag161 && WorldGen.SolidTile(point9.X, point9.Y))
                                                {
                                                    flag161 = false;
                                                }
                                                if (flag161)
                                                {
                                                    float num1631 = (float)(Main.rand.Next(4) < 2).ToDirectionInt() * (0.3926991f + 0.7853982f * Main.rand.NextFloat());
                                                    Vector2 vector204 = new Vector2(0f, -Main.rand.NextFloat() * 0.5f - 0.5f).RotatedBy((double)num1631, default(Vector2)) * 6f;
                                                    Projectile.NewProjectile(vec6.X, vec6.Y, vector204.X, vector204.Y, 622, 0, 0f, Main.myPlayer, 0f, 0f);
                                                }
                                            }
                                            if (this.ai[1] >= 480f)
                                            {
                                                MoonlordDeathDrama.RequestLight((this.ai[1] - 480f) / 120f, base.Center);
                                            }
                                            if (this.ai[1] >= 600f)
                                            {
                                                this.life = 0;
                                                this.HitEffect(0, 1337.0);
                                                this.checkDead();
                                                return;
                                            }
                                        }
                                        else if (this.ai[0] == 3f)
                                        {
                                            this.dontTakeDamage = true;
                                            Vector2 value31 = new Vector2((float)this.direction, -0.5f);
                                            this.velocity = Vector2.Lerp(this.velocity, value31, 0.98f);
                                            this.ai[1] += 1f;
                                            if (this.ai[1] < 60f)
                                            {
                                                MoonlordDeathDrama.RequestLight(this.ai[1] / 40f, base.Center);
                                            }
                                            if (this.ai[1] == 40f)
                                            {
                                                for (int num1632 = 0; num1632 < 1000; num1632++)
                                                {
                                                    Projectile projectile2 = Main.projectile[num1632];
                                                    if (projectile2.active && (projectile2.type == 456 || projectile2.type == 462 || projectile2.type == 455 || projectile2.type == 452 || projectile2.type == 454))
                                                    {
                                                        projectile2.active = false;
                                                        if (Main.netMode != 1)
                                                        {
                                                            NetMessage.SendData((int)PacketTypes.ProjectileNew, -1, -1, "", num1632, 0f, 0f, 0f, 0, 0, 0);
                                                        }
                                                    }
                                                }
                                                for (int num1633 = 0; num1633 < 200; num1633++)
                                                {
                                                    NPC nPC9 = Main.npc[num1633];
                                                    if (nPC9.active && nPC9.type == 400)
                                                    {
                                                        nPC9.active = false;
                                                        if (Main.netMode != 1)
                                                        {
                                                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", nPC9.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                        }
                                                    }
                                                }
                                            }
                                            if (this.ai[1] >= 60f)
                                            {
                                                for (int num1635 = 0; num1635 < 200; num1635++)
                                                {
                                                    NPC nPC10 = Main.npc[num1635];
                                                    if (nPC10.active && (nPC10.type == 400 || nPC10.type == 397 || nPC10.type == 396))
                                                    {
                                                        nPC10.active = false;
                                                        if (Main.netMode != 1)
                                                        {
                                                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", nPC10.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                        }
                                                    }
                                                }
                                                this.active = false;
                                                if (Main.netMode != 1)
                                                {
                                                    NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                }
                                                NPC.LunarApocalypseIsUp = false;
                                                if (Main.netMode == 2)
                                                {
                                                    NetMessage.SendData((int)PacketTypes.WorldInfo, -1, -1, "", 0, 0f, 0f, 0f, 0, 0, 0);
                                                }
                                                return;
                                            }
                                        }
                                        bool flag162 = false;
                                        if (this.ai[0] == -2f || this.ai[0] == -1f || this.ai[0] == -2f || this.ai[0] == 3f)
                                        {
                                            flag162 = true;
                                        }
                                        if (Main.player[this.target].active && !Main.player[this.target].dead)
                                        {
                                            flag162 = true;
                                        }
                                        if (!flag162)
                                        {
                                            for (int num1636 = 0; num1636 < 255; num1636++)
                                            {
                                                if (Main.player[num1636].active && !Main.player[num1636].dead)
                                                {
                                                    flag162 = true;
                                                    break;
                                                }
                                            }
                                        }
                                        if (!flag162)
                                        {
                                            this.ai[0] = 3f;
                                            this.ai[1] = 0f;
                                            this.netUpdate = true;
                                        }
                                        if (this.ai[0] >= 0f && this.ai[0] < 2f && Main.netMode != 1 && base.Distance(Main.player[this.target].Center) > 2400f)
                                        {
                                            this.ai[0] = -2f;
                                            this.netUpdate = true;
                                            Vector2 value32 = Main.player[this.target].Center - Vector2.UnitY * 150f - base.Center;
                                            this.position += value32;
                                            if (Main.npc[(int)this.localAI[0]].active)
                                            {
                                                Main.npc[(int)this.localAI[0]].position += value32;
                                                Main.npc[(int)this.localAI[0]].netUpdate = true;
                                            }
                                            if (Main.npc[(int)this.localAI[1]].active)
                                            {
                                                Main.npc[(int)this.localAI[1]].position += value32;
                                                Main.npc[(int)this.localAI[1]].netUpdate = true;
                                            }
                                            if (Main.npc[(int)this.localAI[2]].active)
                                            {
                                                Main.npc[(int)this.localAI[2]].position += value32;
                                                Main.npc[(int)this.localAI[2]].netUpdate = true;
                                            }
                                            for (int num1637 = 0; num1637 < 200; num1637++)
                                            {
                                                NPC nPC11 = Main.npc[num1637];
                                                if (nPC11.active && nPC11.type == 400)
                                                {
                                                    nPC11.position += value32;
                                                    nPC11.netUpdate = true;
                                                }
                                            }
                                            return;
                                        }
                                    }
                                    else if (this.aiStyle == 78)
                                    {
                                        NPC.InitializeMoonLordAttacks();
                                        if (!Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 398)
                                        {
                                            this.life = 0;
                                            this.HitEffect(0, 10.0);
                                            this.active = false;
                                        }
                                        bool flag163 = this.ai[2] == 0f;
                                        float num1638 = (float)(-(float)flag163.ToDirectionInt());
                                        this.spriteDirection = (int)num1638;
                                        this.dontTakeDamage = (this.frameCounter >= 21.0);
                                        Vector2 vector205 = new Vector2(30f, 66f);
                                        float num1639 = 0f;
                                        float num1640 = 0f;
                                        bool flag164 = true;
                                        int num1641 = 0;
                                        if (this.ai[0] != -2f)
                                        {
                                            float num1642 = this.ai[0];
                                            this.ai[1] += 1f;
                                            int num1643 = (int)Main.npc[(int)this.ai[3]].ai[2];
                                            int num1644 = flag163 ? 0 : 1;
                                            int num1645 = 0;
                                            int num1646 = 0;
                                            while (num1645 < 5)
                                            {
                                                num1640 = (float)NPC.MoonLordAttacksArray[num1643, num1644, 1, num1645];
                                                if (num1640 + (float)num1646 > this.ai[1])
                                                {
                                                    break;
                                                }
                                                num1646 += (int)num1640;
                                                num1645++;
                                            }
                                            if (num1645 == 5)
                                            {
                                                num1645 = 0;
                                                this.ai[1] = 0f;
                                                num1640 = (float)NPC.MoonLordAttacksArray[num1643, num1644, 1, num1645];
                                                num1646 = 0;
                                            }
                                            this.ai[0] = (float)NPC.MoonLordAttacksArray[num1643, num1644, 0, num1645];
                                            num1639 = (float)((int)this.ai[1] - num1646);
                                            if (this.ai[0] != num1642)
                                            {
                                                this.netUpdate = true;
                                            }
                                        }
                                        if (this.ai[0] == -2f)
                                        {
                                            this.damage = 80;
                                            num1641 = 0;
                                            this.dontTakeDamage = true;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 32f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                            if (this.ai[1] < 0f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                            Vector2 center18 = Main.npc[(int)this.ai[3]].Center;
                                            Vector2 value33 = center18 + new Vector2(350f * num1638, -100f);
                                            Vector2 vector206 = value33 - base.Center;
                                            if (vector206.Length() > 20f)
                                            {
                                                vector206.Normalize();
                                                vector206 *= 6f;
                                                Vector2 velocity5 = this.velocity;
                                                if (vector206 != Vector2.Zero)
                                                {
                                                    this.SimpleFlyMovement(vector206, 0.3f);
                                                }
                                                this.velocity = Vector2.Lerp(velocity5, this.velocity, 0.5f);
                                            }
                                        }
                                        else if (this.ai[0] == 0f)
                                        {
                                            num1641 = 3;
                                            this.localAI[1] -= 0.05f;
                                            if (this.localAI[1] < 0f)
                                            {
                                                this.localAI[1] = 0f;
                                            }
                                            Vector2 center19 = Main.npc[(int)this.ai[3]].Center;
                                            Vector2 value34 = center19 + new Vector2(350f * num1638, -100f);
                                            Vector2 vector207 = value34 - base.Center;
                                            if (vector207.Length() > 20f)
                                            {
                                                vector207.Normalize();
                                                vector207 *= 6f;
                                                Vector2 velocity6 = this.velocity;
                                                if (vector207 != Vector2.Zero)
                                                {
                                                    this.SimpleFlyMovement(vector207, 0.3f);
                                                }
                                                this.velocity = Vector2.Lerp(velocity6, this.velocity, 0.5f);
                                            }
                                        }
                                        else if (this.ai[0] == 1f)
                                        {
                                            num1641 = 0;
                                            int num1647 = 7;
                                            int num1648 = 4;
                                            if (num1639 >= (float)(num1647 * num1648 * 2))
                                            {
                                                this.localAI[1] -= 0.07f;
                                                if (this.localAI[1] < 0f)
                                                {
                                                    this.localAI[1] = 0f;
                                                }
                                            }
                                            else if (num1639 >= (float)(num1647 * num1648))
                                            {
                                                this.localAI[1] += 0.05f;
                                                if (this.localAI[1] > 0.75f)
                                                {
                                                    this.localAI[1] = 0.75f;
                                                }
                                                float num1649 = 6.28318548f * (num1639 % (float)(num1647 * num1648)) / (float)(num1647 * num1648) - 1.57079637f;
                                                this.localAI[0] = new Vector2((float)Math.Cos((double)num1649) * vector205.X, (float)Math.Sin((double)num1649) * vector205.Y).ToRotation();
                                                if (num1639 % (float)num1648 == 0f)
                                                {
                                                    Vector2 value35 = new Vector2(1f * -num1638, 3f);
                                                    Vector2 vector208 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector205 * this.localAI[1]);
                                                    Vector2 vector209 = base.Center + Vector2.Normalize(vector208) * vector205.Length() * 0.4f + value35;
                                                    Vector2 vector210 = Vector2.Normalize(vector208) * 8f;
                                                    float ai = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * num1638;
                                                    Projectile.NewProjectile(vector209.X, vector209.Y, vector210.X, vector210.Y, 452, 30, 0f, Main.myPlayer, 0f, ai);
                                                }
                                            }
                                            else
                                            {
                                                this.localAI[1] += 0.02f;
                                                if (this.localAI[1] > 0.75f)
                                                {
                                                    this.localAI[1] = 0.75f;
                                                }
                                                float num1650 = 6.28318548f * (num1639 % (float)(num1647 * num1648)) / (float)(num1647 * num1648) - 1.57079637f;
                                                this.localAI[0] = new Vector2((float)Math.Cos((double)num1650) * vector205.X, (float)Math.Sin((double)num1650) * vector205.Y).ToRotation();
                                            }
                                        }
                                        else if (this.ai[0] == 2f)
                                        {
                                            this.localAI[1] -= 0.05f;
                                            if (this.localAI[1] < 0f)
                                            {
                                                this.localAI[1] = 0f;
                                            }
                                            Vector2 center20 = Main.npc[(int)this.ai[3]].Center;
                                            Vector2 value36 = new Vector2(220f * num1638, -60f) + center20;
                                            value36 += new Vector2(num1638 * 100f, -50f);
                                            Vector2 value37 = new Vector2(400f * num1638, -60f);
                                            if (num1639 < 30f)
                                            {
                                                Vector2 vector211 = value36 - base.Center;
                                                if (vector211 != Vector2.Zero)
                                                {
                                                    Vector2 vector212 = vector211;
                                                    vector212.Normalize();
                                                    this.velocity = Vector2.SmoothStep(this.velocity, vector212 * Math.Min(8f, vector211.Length()), 0.2f);
                                                }
                                            }
                                            else if (num1639 < 210f)
                                            {
                                                num1641 = 1;
                                                int num1651 = (int)num1639 - 30;
                                                if (num1651 % 30 == 0 && Main.netMode != 1)
                                                {
                                                    Vector2 vector213 = new Vector2(5f * num1638, -8f);
                                                    int num1652 = num1651 / 30;
                                                    vector213.X += ((float)num1652 - 3.5f) * num1638 * 3f;
                                                    vector213.Y += ((float)num1652 - 4.5f) * 1f;
                                                    vector213 *= 1.2f;
                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, vector213.X, vector213.Y, 454, 50, 1f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                }
                                                Vector2 vector214 = Vector2.SmoothStep(value36, value36 + value37, (num1639 - 30f) / 180f) - base.Center;
                                                if (vector214 != Vector2.Zero)
                                                {
                                                    Vector2 vector215 = vector214;
                                                    vector215.Normalize();
                                                    this.velocity = Vector2.Lerp(this.velocity, vector215 * Math.Min(20f, vector214.Length()), 0.5f);
                                                }
                                            }
                                            else if (num1639 < 282f)
                                            {
                                                num1641 = 0;
                                                this.velocity *= 0.9f;
                                            }
                                            else if (num1639 < 287f)
                                            {
                                                num1641 = 1;
                                                this.velocity *= 0.9f;
                                            }
                                            else if (num1639 < 292f)
                                            {
                                                num1641 = 2;
                                                this.velocity *= 0.9f;
                                            }
                                            else if (num1639 < 300f)
                                            {
                                                num1641 = 3;
                                                if (num1639 == 292f && Main.netMode != 1)
                                                {
                                                    int num1653 = (int)Player.FindClosest(this.position, this.width, this.height);
                                                    Vector2 velocity7 = Vector2.Normalize(Main.player[num1653].Center - (base.Center + Vector2.UnitY * -350f));
                                                    if (float.IsNaN(velocity7.X) || float.IsNaN(velocity7.Y))
                                                    {
                                                        velocity7 = Vector2.UnitY;
                                                    }
                                                    velocity7 *= 12f;
                                                    for (int num1654 = 0; num1654 < 1000; num1654++)
                                                    {
                                                        Projectile projectile3 = Main.projectile[num1654];
                                                        if (projectile3.active && projectile3.type == 454 && projectile3.ai[1] == (float)this.whoAmI && projectile3.ai[0] != -1f)
                                                        {
                                                            projectile3.ai[0] = -1f;
                                                            projectile3.velocity = velocity7;
                                                            projectile3.netUpdate = true;
                                                        }
                                                    }
                                                }
                                                Vector2 vector216 = Vector2.SmoothStep(value36, value36 + value37, 1f - (num1639 - 270f) / 30f) - base.Center;
                                                if (vector216 != Vector2.Zero)
                                                {
                                                    Vector2 vector217 = vector216;
                                                    vector217.Normalize();
                                                    this.velocity = Vector2.Lerp(this.velocity, vector217 * Math.Min(14f, vector216.Length()), 0.1f);
                                                }
                                            }
                                            else
                                            {
                                                num1641 = 3;
                                                Vector2 vector218 = value36 - base.Center;
                                                if (vector218 != Vector2.Zero)
                                                {
                                                    Vector2 vector219 = vector218;
                                                    vector219.Normalize();
                                                    this.velocity = Vector2.SmoothStep(this.velocity, vector219 * Math.Min(8f, vector218.Length()), 0.2f);
                                                }
                                            }
                                        }
                                        else if (this.ai[0] == 3f)
                                        {
                                            if (num1639 == 0f)
                                            {
                                                this.TargetClosest(false);
                                                this.netUpdate = true;
                                            }
                                            Vector2 v2 = Main.player[this.target].Center + Main.player[this.target].velocity * 20f - base.Center;
                                            this.localAI[0] = this.localAI[0].AngleLerp(v2.ToRotation(), 0.5f);
                                            this.localAI[1] += 0.05f;
                                            if (this.localAI[1] > 1f)
                                            {
                                                this.localAI[1] = 1f;
                                            }
                                            if ((num1639 == num1640 - 14f || num1639 == num1640 - 7f || num1639 == num1640) && Main.netMode != 1)
                                            {
                                                Vector2 vector220 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector205 * this.localAI[1]);
                                                Vector2 vector221 = Vector2.Normalize(v2) * 8f;
                                                Projectile.NewProjectile(base.Center.X + vector220.X, base.Center.Y + vector220.Y, vector221.X, vector221.Y, 462, 30, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                        }
                                        if (flag164)
                                        {
                                            Vector2 center21 = Main.npc[(int)this.ai[3]].Center;
                                            Vector2 value38 = new Vector2(220f * num1638, -60f) + center21;
                                            Vector2 vector222 = value38 + new Vector2(num1638 * 110f, -150f);
                                            Vector2 max = vector222 + new Vector2(num1638 * 370f, 150f);
                                            if (vector222.X > max.X)
                                            {
                                                Utils.Swap<float>(ref vector222.X, ref max.X);
                                            }
                                            if (vector222.Y > max.Y)
                                            {
                                                Utils.Swap<float>(ref vector222.Y, ref max.Y);
                                            }
                                            Vector2 value39 = Vector2.Clamp(base.Center + this.velocity, vector222, max);
                                            if (value39 != base.Center + this.velocity)
                                            {
                                                base.Center = value39 - this.velocity;
                                            }
                                        }
                                        int num1655 = num1641 * 7;
                                        if ((double)num1655 > this.frameCounter)
                                        {
                                            this.frameCounter += 1.0;
                                        }
                                        if ((double)num1655 < this.frameCounter)
                                        {
                                            this.frameCounter -= 1.0;
                                        }
                                        if (this.frameCounter < 0.0)
                                        {
                                            this.frameCounter = 0.0;
                                        }
                                        if (this.frameCounter > 21.0)
                                        {
                                            this.frameCounter = 21.0;
                                        }
                                        int num1656 = 0;
                                        if (flag163)
                                        {
                                            num1656 = 0;
                                        }
                                        if (num1656 == 0)
                                        {
                                            return;
                                        }
                                        if (num1656 == 1)
                                        {
                                            if (this.ai[0] == 0f)
                                            {
                                                if ((this.ai[1] += 1f) >= 20f)
                                                {
                                                    this.ai[1] = 0f;
                                                    this.ai[0] = 1f;
                                                    this.netUpdate = true;
                                                }
                                                this.velocity = Vector2.UnitX * 4f;
                                                return;
                                            }
                                            if (this.ai[0] == 1f)
                                            {
                                                if ((this.ai[1] += 1f) >= 20f)
                                                {
                                                    this.ai[1] = 0f;
                                                    this.ai[0] = 2f;
                                                    this.netUpdate = true;
                                                }
                                                this.velocity = Vector2.UnitX * -4f;
                                                return;
                                            }
                                            if (this.ai[0] == 2f || this.ai[0] == 4f)
                                            {
                                                if ((this.ai[1] += 1f) >= 20f)
                                                {
                                                    this.ai[1] = 0f;
                                                    this.ai[0] += 1f;
                                                    this.netUpdate = true;
                                                }
                                                this.velocity = Vector2.UnitY * -4f * (float)(flag163 ? 1 : -1);
                                                return;
                                            }
                                            if (this.ai[0] == 3f || this.ai[0] == 5f)
                                            {
                                                if ((this.ai[1] += 1f) >= 20f)
                                                {
                                                    this.ai[1] = 0f;
                                                    this.ai[0] += 1f;
                                                    if (this.ai[0] == 6f)
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                    this.netUpdate = true;
                                                }
                                                this.velocity = Vector2.UnitY * 4f * (float)(flag163 ? 1 : -1);
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            if (num1656 == 2)
                                            {
                                                new Vector2(30f, 66f);
                                                this.TargetClosest(false);
                                                Vector2 v3 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - base.Center;
                                                float num1657 = v3.Length() / 200f;
                                                if (num1657 > 1f)
                                                {
                                                    num1657 = 1f;
                                                }
                                                num1657 = 1f - num1657;
                                                num1657 *= 2f;
                                                if (num1657 > 1f)
                                                {
                                                    num1657 = 1f;
                                                }
                                                this.localAI[0] = v3.ToRotation();
                                                this.localAI[1] = num1657;
                                                this.localAI[1] = 1f;
                                                return;
                                            }
                                            if (num1656 == 3)
                                            {
                                                int num1658 = 7;
                                                int num1659 = 4;
                                                this.ai[1] += 1f;
                                                if (this.ai[1] >= (float)(num1658 * num1659 * 10))
                                                {
                                                    this.ai[1] = 0f;
                                                    return;
                                                }
                                                if (this.ai[1] >= (float)(num1658 * num1659))
                                                {
                                                    this.localAI[1] -= 0.07f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    this.localAI[1] += 0.05f;
                                                    if (this.localAI[1] > 0.75f)
                                                    {
                                                        this.localAI[1] = 0.75f;
                                                    }
                                                    float num1660 = 6.28318548f * (this.ai[1] % (float)(num1658 * num1659)) / (float)(num1658 * num1659) - 1.57079637f;
                                                    this.localAI[0] = new Vector2((float)Math.Cos((double)num1660) * vector205.X, (float)Math.Sin((double)num1660) * vector205.Y).ToRotation();
                                                    if (this.ai[1] % (float)num1659 == 0f)
                                                    {
                                                        Vector2 value40 = new Vector2(1f * -num1638, 3f);
                                                        Vector2 vector223 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), vector205 * this.localAI[1]);
                                                        Vector2 vector224 = base.Center + Vector2.Normalize(vector223) * vector205.Length() * 0.4f + value40;
                                                        Vector2 vector225 = Vector2.Normalize(vector223) * 8f;
                                                        float ai2 = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * num1638;
                                                        Projectile.NewProjectile(vector224.X, vector224.Y, vector225.X, vector225.Y, 452, 5, 0f, Main.myPlayer, 0f, ai2);
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (num1656 == 4)
                                            {
                                                Vector2 center22 = Main.npc[(int)this.ai[3]].Center;
                                                Vector2 value41 = new Vector2(220f * num1638, -60f) + center22;
                                                value41 += new Vector2(num1638 * 100f, -50f);
                                                Vector2 value42 = new Vector2(400f * num1638, -60f);
                                                this.ai[1] += 1f;
                                                if (this.ai[1] < 30f)
                                                {
                                                    Vector2 vector226 = value41 - base.Center;
                                                    if (vector226 != Vector2.Zero)
                                                    {
                                                        Vector2 vector227 = vector226;
                                                        vector227.Normalize();
                                                        this.velocity = Vector2.SmoothStep(this.velocity, vector227 * Math.Min(8f, vector226.Length()), 0.2f);
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[1] < 210f)
                                                {
                                                    int num1661 = (int)this.ai[1] - 30;
                                                    if (num1661 % 30 == 0 && Main.netMode != 1)
                                                    {
                                                        Vector2 vector228 = new Vector2(5f * num1638, -8f);
                                                        int num1662 = num1661 / 30;
                                                        vector228.X += ((float)num1662 - 3.5f) * num1638 * 3f;
                                                        vector228.Y += ((float)num1662 - 4.5f) * 1f;
                                                        vector228 *= 1.2f;
                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, vector228.X, vector228.Y, 454, 1, 1f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                    }
                                                    Vector2 vector229 = Vector2.SmoothStep(value41, value41 + value42, (this.ai[1] - 30f) / 180f) - base.Center;
                                                    if (vector229 != Vector2.Zero)
                                                    {
                                                        Vector2 vector230 = vector229;
                                                        vector230.Normalize();
                                                        this.velocity = Vector2.Lerp(this.velocity, vector230 * Math.Min(4f, vector229.Length()), 0.1f);
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.ai[1] < 270f)
                                                    {
                                                        this.velocity *= 0.9f;
                                                        return;
                                                    }
                                                    if (this.ai[1] >= 300f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        return;
                                                    }
                                                    if (this.ai[1] == 270f && Main.netMode != 1)
                                                    {
                                                        int num1663 = (int)Player.FindClosest(this.position, this.width, this.height);
                                                        Vector2 velocity8 = Vector2.Normalize(Main.player[num1663].Center - (base.Center + Vector2.UnitY * -350f));
                                                        if (float.IsNaN(velocity8.X) || float.IsNaN(velocity8.Y))
                                                        {
                                                            velocity8 = Vector2.UnitY;
                                                        }
                                                        velocity8 *= 12f;
                                                        for (int num1664 = 0; num1664 < 1000; num1664++)
                                                        {
                                                            Projectile projectile4 = Main.projectile[num1664];
                                                            if (projectile4.active && projectile4.type == 454 && projectile4.ai[1] == (float)this.whoAmI && projectile4.ai[0] != -1f)
                                                            {
                                                                projectile4.ai[0] = -1f;
                                                                projectile4.velocity = velocity8;
                                                                projectile4.netUpdate = true;
                                                            }
                                                        }
                                                    }
                                                    Vector2 vector231 = Vector2.SmoothStep(value41, value41 + value42, 1f - (this.ai[1] - 270f) / 30f) - base.Center;
                                                    if (vector231 != Vector2.Zero)
                                                    {
                                                        Vector2 vector232 = vector231;
                                                        vector232.Normalize();
                                                        this.velocity = Vector2.Lerp(this.velocity, vector232 * Math.Min(14f, vector231.Length()), 0.1f);
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (num1656 == 5)
                                            {
                                                this.dontTakeDamage = true;
                                                this.ai[1] += 1f;
                                                if (this.ai[1] >= 40f)
                                                {
                                                    this.ai[1] = 0f;
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    else if (this.aiStyle == 79)
                                    {
                                        if (!Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 398)
                                        {
                                            this.life = 0;
                                            this.HitEffect(0, 10.0);
                                            this.active = false;
                                        }
                                        this.dontTakeDamage = (this.localAI[3] >= 15f);
                                        this.velocity = Vector2.Zero;
                                        base.Center = Main.npc[(int)this.ai[3]].Center + new Vector2(0f, -400f);
                                        Vector2 value43 = new Vector2(27f, 59f);
                                        float num1665 = 0f;
                                        float num1666 = 0f;
                                        int num1667 = 0;
                                        int num1668 = 0;
                                        if (this.ai[0] >= 0f)
                                        {
                                            float num1669 = this.ai[0];
                                            this.ai[1] += 1f;
                                            int num1670 = (int)Main.npc[(int)this.ai[3]].ai[2];
                                            int num1671 = 2;
                                            int num1672 = 0;
                                            int num1673 = 0;
                                            while (num1672 < 5)
                                            {
                                                num1666 = (float)NPC.MoonLordAttacksArray[num1670, num1671, 1, num1672];
                                                if (num1666 + (float)num1673 > this.ai[1])
                                                {
                                                    break;
                                                }
                                                num1673 += (int)num1666;
                                                num1672++;
                                            }
                                            if (num1672 == 5)
                                            {
                                                num1672 = 0;
                                                this.ai[1] = 0f;
                                                num1666 = (float)NPC.MoonLordAttacksArray[num1670, num1671, 1, num1672];
                                                num1673 = 0;
                                            }
                                            this.ai[0] = (float)NPC.MoonLordAttacksArray[num1670, num1671, 0, num1672];
                                            num1665 = (float)((int)this.ai[1] - num1673);
                                            if (this.ai[0] != num1669)
                                            {
                                                this.netUpdate = true;
                                            }
                                        }
                                        if (this.ai[0] == -3f)
                                        {
                                            this.damage = 0;
                                            this.dontTakeDamage = true;
                                            this.rotation = MathHelper.Lerp(this.rotation, 0.2617994f, 0.07f);
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 32f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                            if (this.ai[1] < 0f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                            if (this.localAI[2] < 14f)
                                            {
                                                this.localAI[2] += 1f;
                                            }
                                        }
                                        else if (this.ai[0] == -2f)
                                        {
                                            if (Main.npc[(int)this.ai[3]].ai[0] == 2f)
                                            {
                                                this.ai[0] = -3f;
                                                return;
                                            }
                                            this.damage = 80;
                                            this.dontTakeDamage = true;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 32f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                            if (this.ai[1] < 0f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= 555f)
                                            {
                                                this.ai[2] = 0f;
                                            }
                                            if (this.ai[2] >= 120f)
                                            {
                                                num1665 = this.ai[2] - 120f;
                                                num1666 = 555f;
                                                num1667 = 2;
                                                Vector2 value44 = new Vector2(0f, 216f);
                                                if (num1665 == 0f && Main.netMode != 1)
                                                {
                                                    Vector2 value45 = base.Center + value44;
                                                    for (int num1674 = 0; num1674 < 255; num1674++)
                                                    {
                                                        Player player9 = Main.player[num1674];
                                                        if (player9.active && !player9.dead && Vector2.Distance(player9.Center, value45) <= 3000f)
                                                        {
                                                            Vector2 value46 = Main.player[this.target].Center - value45;
                                                            if (value46 != Vector2.Zero)
                                                            {
                                                                value46.Normalize();
                                                            }
                                                            Projectile.NewProjectile(value45.X, value45.Y, value46.X, value46.Y, 456, 0, 0f, Main.myPlayer, (float)(this.whoAmI + 1), (float)num1674);
                                                        }
                                                    }
                                                }
                                                if ((num1665 == 120f || num1665 == 180f || num1665 == 240f) && Main.netMode != 1)
                                                {
                                                    for (int num1675 = 0; num1675 < 1000; num1675++)
                                                    {
                                                        Projectile projectile5 = Main.projectile[num1675];
                                                        if (projectile5.active && projectile5.type == 456 && Main.player[(int)projectile5.ai[1]].HasBuff(BuffID.MoonLeech) != -1)
                                                        {
                                                            Vector2 center23 = Main.player[this.target].Center;
                                                            int num1676 = NPC.NewNPC((int)center23.X, (int)center23.Y, 401, 0, 0f, 0f, 0f, 0f, 255);
                                                            Main.npc[num1676].netUpdate = true;
                                                            Main.npc[num1676].ai[0] = (float)(this.whoAmI + 1);
                                                            Main.npc[num1676].ai[1] = (float)num1675;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else if (this.ai[0] == 0f)
                                        {
                                            num1668 = 3;
                                            this.TargetClosest(false);
                                            Vector2 v4 = Main.player[this.target].Center - base.Center - new Vector2(0f, -22f);
                                            float num1677 = v4.Length() / 500f;
                                            if (num1677 > 1f)
                                            {
                                                num1677 = 1f;
                                            }
                                            num1677 = 1f - num1677;
                                            num1677 *= 2f;
                                            if (num1677 > 1f)
                                            {
                                                num1677 = 1f;
                                            }
                                            this.localAI[0] = v4.ToRotation();
                                            this.localAI[1] = num1677;
                                            this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                        }
                                        if (this.ai[0] == 1f)
                                        {
                                            if (num1665 < 180f)
                                            {
                                                this.localAI[1] -= 0.05f;
                                                if (this.localAI[1] < 0f)
                                                {
                                                    this.localAI[1] = 0f;
                                                }
                                            }
                                            else if (num1665 < num1666 - 15f)
                                            {
                                                if (num1665 == 180f && Main.netMode != 1)
                                                {
                                                    this.TargetClosest(false);
                                                    Vector2 vector234 = Main.player[this.target].Center - base.Center;
                                                    vector234.Normalize();
                                                    float num1683 = -1f;
                                                    if (vector234.X < 0f)
                                                    {
                                                        num1683 = 1f;
                                                    }
                                                    vector234 = vector234.RotatedBy((double)(-(double)num1683 * 6.28318548f / 6f), default(Vector2));
                                                    Projectile.NewProjectile(base.Center.X, base.Center.Y, vector234.X, vector234.Y, 455, 75, 0f, Main.myPlayer, num1683 * 6.28318548f / 540f, (float)this.whoAmI);
                                                    this.ai[2] = (vector234.ToRotation() + 9.424778f) * num1683;
                                                    this.netUpdate = true;
                                                }
                                                this.localAI[1] += 0.05f;
                                                if (this.localAI[1] > 1f)
                                                {
                                                    this.localAI[1] = 1f;
                                                }
                                                float num1684 = (float)(this.ai[2] >= 0f).ToDirectionInt();
                                                float num1685 = this.ai[2];
                                                if (num1685 < 0f)
                                                {
                                                    num1685 *= -1f;
                                                }
                                                num1685 += -9.424778f;
                                                num1685 += num1684 * 6.28318548f / 540f;
                                                this.localAI[0] = num1685;
                                                this.ai[2] = (num1685 + 9.424778f) * num1684;
                                            }
                                            else
                                            {
                                                this.localAI[1] -= 0.07f;
                                                if (this.localAI[1] < 0f)
                                                {
                                                    this.localAI[1] = 0f;
                                                }
                                                num1668 = 3;
                                            }
                                        }
                                        else if (this.ai[0] == 2f)
                                        {
                                            num1667 = 2;
                                            num1668 = 3;
                                            Vector2 value47 = new Vector2(0f, 216f);
                                            if (num1665 == 0f && Main.netMode != 1)
                                            {
                                                Vector2 value48 = base.Center + value47;
                                                for (int num1686 = 0; num1686 < 255; num1686++)
                                                {
                                                    Player player10 = Main.player[num1686];
                                                    if (player10.active && !player10.dead && Vector2.Distance(player10.Center, value48) <= 3000f)
                                                    {
                                                        Vector2 value49 = Main.player[this.target].Center - value48;
                                                        if (value49 != Vector2.Zero)
                                                        {
                                                            value49.Normalize();
                                                        }
                                                        Projectile.NewProjectile(value48.X, value48.Y, value49.X, value49.Y, 456, 0, 0f, Main.myPlayer, (float)(this.whoAmI + 1), (float)num1686);
                                                    }
                                                }
                                            }
                                            if ((num1665 == 120f || num1665 == 180f || num1665 == 240f) && Main.netMode != 1)
                                            {
                                                for (int num1687 = 0; num1687 < 1000; num1687++)
                                                {
                                                    Projectile projectile6 = Main.projectile[num1687];
                                                    if (projectile6.active && projectile6.type == 456 && Main.player[(int)projectile6.ai[1]].HasBuff(BuffID.MoonLeech) != -1)
                                                    {
                                                        Vector2 center25 = Main.player[this.target].Center;
                                                        int num1688 = NPC.NewNPC((int)center25.X, (int)center25.Y, 401, 0, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num1688].netUpdate = true;
                                                        Main.npc[num1688].ai[0] = (float)(this.whoAmI + 1);
                                                        Main.npc[num1688].ai[1] = (float)num1687;
                                                    }
                                                }
                                            }
                                        }
                                        else if (this.ai[0] == 3f)
                                        {
                                            if (num1665 == 0f)
                                            {
                                                this.TargetClosest(false);
                                                this.netUpdate = true;
                                            }
                                            Vector2 v5 = Main.player[this.target].Center + Main.player[this.target].velocity * 20f - base.Center;
                                            this.localAI[0] = this.localAI[0].AngleLerp(v5.ToRotation(), 0.5f);
                                            this.localAI[1] += 0.05f;
                                            if (this.localAI[1] > 1f)
                                            {
                                                this.localAI[1] = 1f;
                                            }
                                            if ((num1665 == num1666 - 14f || num1665 == num1666 - 7f || num1665 == num1666) && Main.netMode != 1)
                                            {
                                                Vector2 vector235 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), value43 * this.localAI[1]);
                                                Vector2 vector236 = Vector2.Normalize(v5) * 8f;
                                                Projectile.NewProjectile(base.Center.X + vector235.X, base.Center.Y + vector235.Y, vector236.X, vector236.Y, 462, 30, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                        }
                                        int num1689 = num1667 * 7;
                                        if ((float)num1689 > this.localAI[2])
                                        {
                                            this.localAI[2] += 1f;
                                        }
                                        if ((float)num1689 < this.localAI[2])
                                        {
                                            this.localAI[2] -= 1f;
                                        }
                                        if (this.localAI[2] < 0f)
                                        {
                                            this.localAI[2] = 0f;
                                        }
                                        if (this.localAI[2] > 14f)
                                        {
                                            this.localAI[2] = 14f;
                                        }
                                        int num1690 = num1668 * 5;
                                        if ((float)num1690 > this.localAI[3])
                                        {
                                            this.localAI[3] += 1f;
                                        }
                                        if ((float)num1690 < this.localAI[3])
                                        {
                                            this.localAI[3] -= 1f;
                                        }
                                        if (this.localAI[3] < 0f)
                                        {
                                            this.localAI[2] = 0f;
                                        }
                                        if (this.localAI[3] > 15f)
                                        {
                                            this.localAI[2] = 15f;
                                        }
                                        int num1691 = 0;
                                        if (num1691 == 1)
                                        {
                                            new Vector2(27f, 59f);
                                            this.TargetClosest(false);
                                            Vector2 v6 = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - base.Center;
                                            float num1692 = v6.Length() / 200f;
                                            if (num1692 > 1f)
                                            {
                                                num1692 = 1f;
                                            }
                                            num1692 = 1f - num1692;
                                            num1692 *= 2f;
                                            if (num1692 > 1f)
                                            {
                                                num1692 = 1f;
                                            }
                                            this.localAI[0] = v6.ToRotation();
                                            this.localAI[1] = num1692;
                                            this.localAI[1] = 1f;
                                        }
                                        if (num1691 == 2)
                                        {
                                            Vector2 vector237 = new Vector2(27f, 59f);
                                            float num1693 = 6.28318548f * ((float)Main.time % 600f) / 600f;
                                            this.localAI[0] = new Vector2((float)Math.Cos((double)num1693) * vector237.X, (float)Math.Sin((double)num1693) * vector237.Y).ToRotation();
                                            this.localAI[1] = 0.75f;
                                            if (this.ai[1] == 0f)
                                            {
                                                Vector2 vector238 = num1693.ToRotationVector2();
                                                vector238 = Vector2.One;
                                                Projectile.NewProjectile(base.Center.X, base.Center.Y, vector238.X, vector238.Y, 455, 1, 0f, Main.myPlayer, 0.0104719754f, (float)this.whoAmI);
                                            }
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 600f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                        }
                                        if (num1691 == 3)
                                        {
                                            Vector2 vector239 = new Vector2(0f, 216f);
                                            if (this.ai[1] == 0f)
                                            {
                                                this.TargetClosest(false);
                                                Vector2 vector240 = Main.player[this.target].Center - base.Center;
                                                vector240.Normalize();
                                                Projectile.NewProjectile(base.Center.X + vector239.X, base.Center.Y + vector239.Y, vector240.X, vector240.Y, 456, 0, 0f, Main.myPlayer, (float)(this.whoAmI + 1), (float)this.target);
                                            }
                                            this.ai[1] += 1f;
                                            if (this.ai[1] >= 600f)
                                            {
                                                this.ai[1] = 0f;
                                            }
                                        }
                                        if (num1691 == 4)
                                        {
                                            new Vector2(27f, 59f);
                                            this.TargetClosest(false);
                                            Vector2 v7 = Main.player[this.target].Center + Main.player[this.target].velocity * 20f - base.Center;
                                            this.localAI[0] = this.localAI[0].AngleLerp(v7.ToRotation(), 0.5f);
                                            this.localAI[1] = 1f;
                                            this.ai[1] += 1f;
                                            if (this.ai[1] == 76f || this.ai[1] == 83f || this.ai[1] == 90f)
                                            {
                                                value43 = new Vector2(27f, 59f);
                                                Vector2 vector241 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), value43 * this.localAI[1]);
                                                Vector2 vector242 = Vector2.Normalize(v7) * 8f;
                                                Projectile.NewProjectile(base.Center.X + vector241.X, base.Center.Y + vector241.Y, vector242.X, vector242.Y, 462, 5, 0f, Main.myPlayer, 0f, 0f);
                                            }
                                            if (this.ai[1] >= 90f)
                                            {
                                                this.ai[1] = 0f;
                                                return;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (this.aiStyle == 80)
                                        {
                                            if (this.ai[0] == 0f)
                                            {
                                                if (this.collideX)
                                                {
                                                    this.direction = 1 - this.direction;
                                                }
                                                this.velocity.X = 3f * (float)((this.direction == 0) ? -1 : 1);
                                                Vector2 center26 = base.Center;
                                                Point point10 = center26.ToTileCoordinates();
                                                int num1694 = 30;
                                                if (WorldGen.InWorld(point10.X, point10.Y, 30))
                                                {
                                                    for (int num1695 = 0; num1695 < 30; num1695++)
                                                    {
                                                        if (WorldGen.SolidTile(point10.X, point10.Y + num1695))
                                                        {
                                                            num1694 = num1695;
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (num1694 < 15)
                                                {
                                                    this.velocity.Y = Math.Max(this.velocity.Y - 0.05f, -3.5f);
                                                }
                                                else if (num1694 < 20)
                                                {
                                                    this.velocity.Y = this.velocity.Y * 0.95f;
                                                }
                                                else
                                                {
                                                    this.velocity.Y = Math.Min(this.velocity.Y + 0.05f, 1.5f);
                                                }
                                                float num1697;
                                                int num1696 = this.FindClosestPlayer(out num1697);
                                                if (num1696 == -1 || Main.player[num1696].dead)
                                                {
                                                    return;
                                                }
                                                if (num1697 < 352f && Main.player[num1696].Center.Y > base.Center.Y)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = 0f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            else if (this.ai[0] == 1f)
                                            {
                                                this.ai[1] += 1f;
                                                this.velocity *= 0.95f;
                                                if (this.ai[1] >= 60f)
                                                {
                                                    this.ai[1] = 0f;
                                                    this.ai[0] = 2f;
                                                    int num1698 = this.FindClosestPlayer();
                                                    if (num1698 != -1)
                                                    {
                                                        this.ai[3] = ((Main.player[num1698].Center.X > base.Center.X) ? -1f : 1f);
                                                    }
                                                    else
                                                    {
                                                        this.ai[3] = 1f;
                                                    }
                                                    this.netUpdate = true;
                                                }
                                            }
                                            else if (this.ai[0] == 2f)
                                            {
                                                this.noTileCollide = true;
                                                this.ai[1] += 1f;
                                                this.velocity.Y = Math.Max(this.velocity.Y - 0.1f, -10f);
                                                this.velocity.X = Math.Min(this.velocity.X + this.ai[3] * 0.05f, 4f);
                                                if (this.position.Y < (float)(-(float)this.height) || this.ai[1] >= 180f)
                                                {
                                                    if (Main.netMode != 1)
                                                    {
                                                        Main.StartInvasion(4);
                                                    }
                                                    this.active = false;
                                                    this.ai[0] = 3f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            return;
                                        }
                                        if (this.aiStyle == 81)
                                        {
                                            Vector2 value50 = new Vector2(30f);
                                            if (!Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 398)
                                            {
                                                this.life = 0;
                                                this.HitEffect(0, 10.0);
                                                this.active = false;
                                            }
                                            float num1699 = 0f;
                                            float num1700 = this.ai[0];
                                            this.ai[1] += 1f;
                                            int num1701 = 0;
                                            int num1702 = 0;
                                            while (num1701 < 10)
                                            {
                                                num1699 = (float)NPC.MoonLordAttacksArray2[1, num1701];
                                                if (num1699 + (float)num1702 > this.ai[1])
                                                {
                                                    break;
                                                }
                                                num1702 += (int)num1699;
                                                num1701++;
                                            }
                                            if (num1701 == 10)
                                            {
                                                num1701 = 0;
                                                this.ai[1] = 0f;
                                                num1699 = (float)NPC.MoonLordAttacksArray2[1, num1701];
                                                num1702 = 0;
                                            }
                                            this.ai[0] = (float)NPC.MoonLordAttacksArray2[0, num1701];
                                            float num1703 = (float)((int)this.ai[1] - num1702);
                                            if (this.ai[0] != num1700)
                                            {
                                                this.netUpdate = true;
                                            }
                                            if (this.ai[0] == -1f)
                                            {
                                                this.ai[1] += 1f;
                                                if (this.ai[1] > 180f)
                                                {
                                                    this.ai[1] = 0f;
                                                }
                                                float value51;
                                                if (this.ai[1] < 60f)
                                                {
                                                    value51 = 0.75f;
                                                    this.localAI[0] = 0f;
                                                    this.localAI[1] = (float)Math.Sin((double)(this.ai[1] * 6.28318548f / 15f)) * 0.35f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[0] = 3.14159274f;
                                                    }
                                                }
                                                else if (this.ai[1] < 120f)
                                                {
                                                    value51 = 1f;
                                                    if (this.localAI[1] < 0.5f)
                                                    {
                                                        this.localAI[1] += 0.025f;
                                                    }
                                                    this.localAI[0] += 0.209439516f;
                                                }
                                                else
                                                {
                                                    value51 = 1.15f;
                                                    this.localAI[1] -= 0.05f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                }
                                                this.localAI[2] = MathHelper.Lerp(this.localAI[2], value51, 0.3f);
                                            }
                                            if (this.ai[0] == 0f)
                                            {
                                                this.TargetClosest(false);
                                                Vector2 v8 = Main.player[this.target].Center + Main.player[this.target].velocity * 20f - base.Center;
                                                this.localAI[0] = this.localAI[0].AngleLerp(v8.ToRotation(), 0.5f);
                                                this.localAI[1] += 0.05f;
                                                if (this.localAI[1] > 0.7f)
                                                {
                                                    this.localAI[1] = 0.7f;
                                                }
                                                this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                                float scaleFactor22 = 24f;
                                                Vector2 center27 = base.Center;
                                                Vector2 center28 = Main.player[this.target].Center;
                                                Vector2 value52 = center28 - center27;
                                                Vector2 vector243 = value52 - Vector2.UnitY * 200f;
                                                vector243 = Vector2.Normalize(vector243) * scaleFactor22;
                                                int num1704 = 30;
                                                this.velocity.X = (this.velocity.X * (float)(num1704 - 1) + vector243.X) / (float)num1704;
                                                this.velocity.Y = (this.velocity.Y * (float)(num1704 - 1) + vector243.Y) / (float)num1704;
                                                float num1705 = 0.25f;
                                                for (int num1706 = 0; num1706 < 200; num1706++)
                                                {
                                                    if (num1706 != this.whoAmI && Main.npc[num1706].active && Main.npc[num1706].type == NPCID.MoonLordFreeEye && Vector2.Distance(base.Center, Main.npc[num1706].Center) < 150f)
                                                    {
                                                        if (this.position.X < Main.npc[num1706].position.X)
                                                        {
                                                            this.velocity.X = this.velocity.X - num1705;
                                                        }
                                                        else
                                                        {
                                                            this.velocity.X = this.velocity.X + num1705;
                                                        }
                                                        if (this.position.Y < Main.npc[num1706].position.Y)
                                                        {
                                                            this.velocity.Y = this.velocity.Y - num1705;
                                                        }
                                                        else
                                                        {
                                                            this.velocity.Y = this.velocity.Y + num1705;
                                                        }
                                                    }
                                                }
                                                return;
                                            }
                                            if (this.ai[0] == 1f)
                                            {
                                                if (num1703 == 0f)
                                                {
                                                    this.TargetClosest(false);
                                                    this.netUpdate = true;
                                                }
                                                this.velocity *= 0.95f;
                                                if (this.velocity.Length() < 1f)
                                                {
                                                    this.velocity = Vector2.Zero;
                                                }
                                                Vector2 v9 = Main.player[this.target].Center + Main.player[this.target].velocity * 20f - base.Center;
                                                this.localAI[0] = this.localAI[0].AngleLerp(v9.ToRotation(), 0.5f);
                                                this.localAI[1] += 0.05f;
                                                if (this.localAI[1] > 1f)
                                                {
                                                    this.localAI[1] = 1f;
                                                }
                                                if (num1703 < 20f)
                                                {
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1.1f, 0.2f);
                                                }
                                                else
                                                {
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.4f, 0.2f);
                                                }
                                                if ((num1703 == num1699 - 14f || num1703 == num1699 - 7f || num1703 == num1699) && Main.netMode != 1)
                                                {
                                                    Vector2 vector244 = Utils.Vector2FromElipse(this.localAI[0].ToRotationVector2(), value50 * this.localAI[1]);
                                                    Vector2 vector245 = Vector2.Normalize(v9) * 8f;
                                                    Projectile.NewProjectile(base.Center.X + vector244.X, base.Center.Y + vector244.Y, vector245.X, vector245.Y, 462, 35, 0f, Main.myPlayer, 0f, 0f);
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 2f)
                                            {
                                                if (num1703 < 15f)
                                                {
                                                    this.localAI[1] -= 0.07f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.4f, 0.2f);
                                                    this.velocity *= 0.8f;
                                                    if (this.velocity.Length() < 1f)
                                                    {
                                                        this.velocity = Vector2.Zero;
                                                        return;
                                                    }
                                                }
                                                else if (num1703 < 75f)
                                                {
                                                    float num1707 = (num1703 - 15f) / 10f;
                                                    int num1708 = 0;
                                                    int num1709 = 0;
                                                    switch ((int)num1707)
                                                    {
                                                        case 0:
                                                            num1708 = 0;
                                                            num1709 = 2;
                                                            break;
                                                        case 1:
                                                            num1708 = 2;
                                                            num1709 = 5;
                                                            break;
                                                        case 2:
                                                            num1708 = 5;
                                                            num1709 = 3;
                                                            break;
                                                        case 3:
                                                            num1708 = 3;
                                                            num1709 = 1;
                                                            break;
                                                        case 4:
                                                            num1708 = 1;
                                                            num1709 = 4;
                                                            break;
                                                        case 5:
                                                            num1708 = 4;
                                                            num1709 = 0;
                                                            break;
                                                    }
                                                    Vector2 spinningpoint8 = Vector2.UnitY * -30f;
                                                    Vector2 value53 = spinningpoint8.RotatedBy((double)((float)num1708 * 6.28318548f / 6f), default(Vector2));
                                                    Vector2 value54 = spinningpoint8.RotatedBy((double)((float)num1709 * 6.28318548f / 6f), default(Vector2));
                                                    Vector2 vector246 = Vector2.Lerp(value53, value54, num1707 - (float)((int)num1707));
                                                    float value55 = vector246.Length() / 30f;
                                                    this.localAI[0] = vector246.ToRotation();
                                                    this.localAI[1] = MathHelper.Lerp(this.localAI[1], value55, 0.5f);
                                                    if ((num1703 - 15f) % 10f == 0f && Main.netMode != 1)
                                                    {
                                                        Vector2 vec7 = Vector2.Normalize(vector246);
                                                        if (vec7.HasNaNs())
                                                        {
                                                            vec7 = Vector2.UnitY * -1f;
                                                        }
                                                        vec7 *= 4f;
                                                        Projectile.NewProjectile(base.Center.X + vector246.X, base.Center.Y + vector246.Y, vec7.X, vec7.Y, 454, 55, 0f, Main.myPlayer, 30f, (float)this.whoAmI);
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    if (num1703 < 105f)
                                                    {
                                                        this.localAI[0] = this.localAI[0].AngleLerp(this.ai[2] - 1.57079637f, 0.2f);
                                                        this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.75f, 0.2f);
                                                        if (num1703 == 75f)
                                                        {
                                                            this.TargetClosest(false);
                                                            this.netUpdate = true;
                                                            this.velocity = Vector2.UnitY * -7f;
                                                            for (int num1712 = 0; num1712 < 1000; num1712++)
                                                            {
                                                                Projectile projectile7 = Main.projectile[num1712];
                                                                if (projectile7.active && projectile7.type == 454 && projectile7.ai[1] == (float)this.whoAmI && projectile7.ai[0] != -1f)
                                                                {
                                                                    projectile7.velocity += this.velocity;
                                                                    projectile7.netUpdate = true;
                                                                }
                                                            }
                                                        }
                                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                                        this.ai[2] = (Main.player[this.target].Center - base.Center).ToRotation() + 1.57079637f;
                                                        this.rotation = this.rotation.AngleTowards(this.ai[2], 0.104719758f);
                                                        return;
                                                    }
                                                    if (num1703 < 120f)
                                                    {
                                                        if (num1703 == 105f)
                                                        {
                                                            this.netUpdate = true;
                                                        }
                                                        Vector2 velocity9 = (this.ai[2] - 1.57079637f).ToRotationVector2() * 12f;
                                                        this.velocity = velocity9 * 2f;
                                                        for (int num1713 = 0; num1713 < 1000; num1713++)
                                                        {
                                                            Projectile projectile8 = Main.projectile[num1713];
                                                            if (projectile8.active && projectile8.type == 454 && projectile8.ai[1] == (float)this.whoAmI && projectile8.ai[0] != -1f)
                                                            {
                                                                projectile8.ai[0] = -1f;
                                                                projectile8.velocity = velocity9;
                                                                projectile8.netUpdate = true;
                                                            }
                                                        }
                                                        return;
                                                    }
                                                    this.velocity *= 0.92f;
                                                    this.rotation = this.rotation.AngleLerp(0f, 0.2f);
                                                    return;
                                                }
                                            }
                                            else if (this.ai[0] == 3f)
                                            {
                                                if (num1703 < 15f)
                                                {
                                                    this.localAI[1] -= 0.07f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], 0.4f, 0.2f);
                                                    this.velocity *= 0.9f;
                                                    if (this.velocity.Length() < 1f)
                                                    {
                                                        this.velocity = Vector2.Zero;
                                                        return;
                                                    }
                                                }
                                                else if (num1703 < 45f)
                                                {
                                                    this.localAI[0] = 0f;
                                                    this.localAI[1] = (float)Math.Sin((double)((num1703 - 15f) * 6.28318548f / 15f)) * 0.5f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[0] = 3.14159274f;
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    if (num1703 >= 185f)
                                                    {
                                                        this.velocity *= 0.88f;
                                                        this.rotation = this.rotation.AngleLerp(0f, 0.2f);
                                                        this.localAI[1] -= 0.07f;
                                                        if (this.localAI[1] < 0f)
                                                        {
                                                            this.localAI[1] = 0f;
                                                        }
                                                        this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                                        return;
                                                    }
                                                    if (num1703 == 45f)
                                                    {
                                                        this.ai[2] = (float)(Main.rand.Next(2) == 0).ToDirectionInt() * 6.28318548f / 40f;
                                                        this.netUpdate = true;
                                                    }
                                                    if ((num1703 - 15f - 30f) % 40f == 0f)
                                                    {
                                                        this.ai[2] *= 0.95f;
                                                    }
                                                    this.localAI[0] += this.ai[2];
                                                    this.localAI[1] += 0.05f;
                                                    if (this.localAI[1] > 1f)
                                                    {
                                                        this.localAI[1] = 1f;
                                                    }
                                                    Vector2 vector247 = this.localAI[0].ToRotationVector2() * value50 * this.localAI[1];
                                                    float scaleFactor23 = MathHelper.Lerp(8f, 20f, (num1703 - 15f - 30f) / 140f);
                                                    this.velocity = Vector2.Normalize(vector247) * scaleFactor23;
                                                    this.rotation = this.rotation.AngleLerp(this.velocity.ToRotation() + 1.57079637f, 0.2f);
                                                    if ((num1703 - 15f - 30f) % 10f == 0f && Main.netMode != 1)
                                                    {
                                                        Vector2 vector248 = base.Center + Vector2.Normalize(vector247) * value50.Length() * 0.4f;
                                                        Vector2 vector249 = Vector2.Normalize(vector247) * 8f;
                                                        float ai3 = (6.28318548f * (float)Main.rand.NextDouble() - 3.14159274f) / 30f + 0.0174532924f * this.ai[2];
                                                        Projectile.NewProjectile(vector248.X, vector248.Y, vector249.X, vector249.Y, 452, 35, 0f, Main.myPlayer, 0f, ai3);
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (this.ai[0] == 4f)
                                            {
                                                if (num1703 == 0f)
                                                {
                                                    this.TargetClosest(false);
                                                    this.netUpdate = true;
                                                }
                                                if (num1703 < 180f)
                                                {
                                                    this.localAI[2] = MathHelper.Lerp(this.localAI[2], 1f, 0.2f);
                                                    this.localAI[1] -= 0.05f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                    }
                                                    this.velocity *= 0.95f;
                                                    if (this.velocity.Length() < 1f)
                                                    {
                                                        this.velocity = Vector2.Zero;
                                                    }
                                                    if (num1703 >= 60f)
                                                    {
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    if (num1703 < num1699 - 15f)
                                                    {
                                                        if (num1703 == 180f && Main.netMode != 1)
                                                        {
                                                            this.TargetClosest(false);
                                                            Vector2 vector251 = Main.player[this.target].Center - base.Center;
                                                            vector251.Normalize();
                                                            float num1719 = -1f;
                                                            if (vector251.X < 0f)
                                                            {
                                                                num1719 = 1f;
                                                            }
                                                            vector251 = vector251.RotatedBy((double)(-(double)num1719 * 6.28318548f / 6f), default(Vector2));
                                                            Projectile.NewProjectile(base.Center.X, base.Center.Y, vector251.X, vector251.Y, 455, 50, 0f, Main.myPlayer, num1719 * 6.28318548f / 540f, (float)this.whoAmI);
                                                            this.ai[2] = (vector251.ToRotation() + 9.424778f) * num1719;
                                                            this.netUpdate = true;
                                                        }
                                                        this.localAI[1] += 0.05f;
                                                        if (this.localAI[1] > 1f)
                                                        {
                                                            this.localAI[1] = 1f;
                                                        }
                                                        float num1720 = (float)(this.ai[2] >= 0f).ToDirectionInt();
                                                        float num1721 = this.ai[2];
                                                        if (num1721 < 0f)
                                                        {
                                                            num1721 *= -1f;
                                                        }
                                                        num1721 += -9.424778f;
                                                        num1721 += num1720 * 6.28318548f / 540f;
                                                        this.localAI[0] = num1721;
                                                        this.ai[2] = (num1721 + 9.424778f) * num1720;
                                                        return;
                                                    }
                                                    this.localAI[1] -= 0.07f;
                                                    if (this.localAI[1] < 0f)
                                                    {
                                                        this.localAI[1] = 0f;
                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                        else if (this.aiStyle == 82)
                                        {
                                            float num1722 = 90f;
                                            Vector2 value56 = new Vector2(0f, 216f);
                                            int num1723 = (int)Math.Abs(this.ai[0]) - 1;
                                            int num1724 = (int)this.ai[1];
                                            if (!Main.npc[num1723].active || Main.npc[num1723].type != NPCID.MoonLordHead)
                                            {
                                                this.life = 0;
                                                this.HitEffect(0, 10.0);
                                                this.active = false;
                                                return;
                                            }
                                            this.ai[2] += 1f;
                                            if (this.ai[2] >= num1722)
                                            {
                                                if (Main.netMode != 1)
                                                {
                                                    int num1725 = (int)Main.npc[num1723].ai[3];
                                                    int num1726 = -1;
                                                    int num1727 = -1;
                                                    int num1728 = num1723;
                                                    for (int num1729 = 0; num1729 < 200; num1729++)
                                                    {
                                                        if (Main.npc[num1729].active && Main.npc[num1729].ai[3] == (float)num1725)
                                                        {
                                                            if (num1726 == -1 && Main.npc[num1729].type == NPCID.MoonLordHand && Main.npc[num1729].ai[2] == 0f)
                                                            {
                                                                num1726 = num1729;
                                                            }
                                                            if (num1727 == -1 && Main.npc[num1729].type == NPCID.MoonLordHand && Main.npc[num1729].ai[2] == 1f)
                                                            {
                                                                num1727 = num1729;
                                                            }
                                                            if (num1726 != -1 && num1727 != -1 && num1728 != -1)
                                                            {
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    int num1730 = 1000;
                                                    int num1731 = Main.npc[num1725].lifeMax - Main.npc[num1725].life;
                                                    int num1732 = Main.npc[num1726].lifeMax - Main.npc[num1726].life;
                                                    int num1733 = Main.npc[num1727].lifeMax - Main.npc[num1727].life;
                                                    int num1734 = Main.npc[num1728].lifeMax - Main.npc[num1728].life;
                                                    if (num1734 > 0 && num1730 > 0)
                                                    {
                                                        int num1735 = num1734 - num1730;
                                                        if (num1735 > 0)
                                                        {
                                                            num1735 = 0;
                                                        }
                                                        int num1736 = num1730 + num1735;
                                                        num1730 -= num1736;
                                                        Main.npc[num1728].life += num1736;
                                                        NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1728].Center, new Vector2(50f)), num1736, true);
                                                    }
                                                    if (num1731 > 0 && num1730 > 0)
                                                    {
                                                        int num1737 = num1731 - num1730;
                                                        if (num1737 > 0)
                                                        {
                                                            num1737 = 0;
                                                        }
                                                        int num1738 = num1730 + num1737;
                                                        num1730 -= num1738;
                                                        Main.npc[num1725].life += num1738;
                                                        NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1725].Center, new Vector2(50f)), num1738, true);
                                                    }
                                                    if (num1732 > 0 && num1730 > 0)
                                                    {
                                                        int num1739 = num1732 - num1730;
                                                        if (num1739 > 0)
                                                        {
                                                            num1739 = 0;
                                                        }
                                                        int num1740 = num1730 + num1739;
                                                        num1730 -= num1740;
                                                        Main.npc[num1726].life += num1740;
                                                        NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1726].Center, new Vector2(50f)), num1740, true);
                                                    }
                                                    if (num1733 > 0 && num1730 > 0)
                                                    {
                                                        int num1741 = num1733 - num1730;
                                                        if (num1741 > 0)
                                                        {
                                                            num1741 = 0;
                                                        }
                                                        int num1742 = num1730 + num1741;
                                                        num1730 -= num1742;
                                                        Main.npc[num1727].life += num1742;
                                                        NPC.HealEffect(Utils.CenteredRectangle(Main.npc[num1727].Center, new Vector2(50f)), num1742, true);
                                                    }
                                                }
                                                this.life = 0;
                                                this.HitEffect(0, 10.0);
                                                this.active = false;
                                                return;
                                            }
                                            this.velocity = Vector2.Zero;
                                            base.Center = Vector2.Lerp(Main.projectile[num1724].Center, Main.npc[(int)Math.Abs(this.ai[0]) - 1].Center + value56, this.ai[2] / num1722);
                                            return;
                                        }
                                        else if (this.aiStyle == 83)
                                        {
                                            if (this.type == NPCID.CultistTablet)
                                            {
                                                if (this.localAI[3] == 0f && Main.netMode != 1)
                                                {
                                                    this.localAI[3] = 1f;
                                                    this.netUpdate = true;
                                                    Point[] array7 = null;
                                                    if (!CultistRitual.CheckFloor(base.Center, out array7))
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 10.0);
                                                        this.active = false;
                                                        return;
                                                    }
                                                    int num1747 = 0;
                                                    int num1748 = 1;
                                                    for (int num1749 = 0; num1749 < 4; num1749++)
                                                    {
                                                        bool flag165 = num1749 == 1 || num1749 == 2;
                                                        int num1750;
                                                        if (flag165)
                                                        {
                                                            num1750 = 438;
                                                        }
                                                        else
                                                        {
                                                            num1750 = 379;
                                                        }
                                                        int num1751 = NPC.NewNPC(array7[num1749].X * 16 + 8, array7[num1749].Y * 16 - 48, num1750, 0, 0f, 0f, 0f, 0f, 255);
                                                        if (flag165)
                                                        {
                                                            this.localAI[num1748++] = (float)(num1751 + 1);
                                                            Main.npc[num1751].ai[3] = (float)(-(float)(this.whoAmI + 1));
                                                        }
                                                        else
                                                        {
                                                            this.ai[num1747++] = (float)(num1751 + 1);
                                                            Main.npc[num1751].ai[3] = (float)(-(float)(this.whoAmI + 1));
                                                        }
                                                        Main.npc[num1751].netUpdate = true;
                                                    }
                                                }
                                                if (this.localAI[0] == 1f && Main.netMode != 1)
                                                {
                                                    this.localAI[0] = 2f;
                                                    for (int num1752 = 0; num1752 < 2; num1752++)
                                                    {
                                                        Main.npc[(int)this.localAI[num1752 + 1] - 1].ai[1] = 1f;
                                                        Main.npc[(int)this.localAI[num1752 + 1] - 1].netUpdate = true;
                                                        Main.npc[(int)this.ai[num1752] - 1].ai[3] = 0f;
                                                        Main.npc[(int)this.ai[num1752] - 1].TargetClosest(true);
                                                        Main.npc[(int)this.ai[num1752] - 1].netUpdate = true;
                                                    }
                                                }
                                                if (this.ai[0] != -1f && Main.netMode != 1)
                                                {
                                                    bool flag166 = true;
                                                    for (int num1753 = 0; num1753 < 2; num1753++)
                                                    {
                                                        if (Main.npc[(int)this.localAI[num1753 + 1] - 1].active && Main.npc[(int)this.localAI[num1753 + 1] - 1].type == 438)
                                                        {
                                                            flag166 = false;
                                                        }
                                                        if (Main.npc[(int)this.ai[num1753] - 1].active && Main.npc[(int)this.ai[num1753] - 1].type == 379)
                                                        {
                                                            flag166 = false;
                                                        }
                                                    }
                                                    if (flag166)
                                                    {
                                                        this.ai[0] = -1f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] = 0f;
                                                        int num1754 = (int)base.Center.X / 16 + 11 * (Main.rand.Next(2) == 0).ToDirectionInt();
                                                        int num1755 = 0;
                                                        for (int num1756 = -5; num1756 < 12; num1756++)
                                                        {
                                                            int num1757 = num1754;
                                                            int num1758 = (int)base.Center.Y / 16 + num1756;
                                                            if (WorldGen.SolidTile(num1757, num1758) && !Collision.SolidTiles(num1757 - 1, num1757 + 1, num1758 - 3, num1758 - 1))
                                                            {
                                                                num1755 = num1758;
                                                                break;
                                                            }
                                                            if (num1756 == 11)
                                                            {
                                                                num1755 = num1758;
                                                            }
                                                        }
                                                        int num1759 = NPC.NewNPC(num1754 * 16 + 10, num1755 * 16 - 2, 439, 0, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num1759].direction = (Main.npc[num1759].spriteDirection = Math.Sign(base.Center.X - (float)(num1754 * 16) - 10f));
                                                        this.ai[2] = (float)num1759;
                                                        this.netUpdate = true;
                                                        CultistRitual.TabletDestroyed();
                                                    }
                                                }
                                                if (this.ai[0] == -1f)
                                                {
                                                    this.ai[3] += 1f;
                                                    if (this.ai[3] > 300f)
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 9999.0);
                                                        this.active = false;
                                                        if (Main.netMode != 1)
                                                        {
                                                            for (int num1760 = 0; num1760 < 6; num1760++)
                                                            {
                                                                float num1761 = 3f + Main.rand.NextFloat() * 6f;
                                                                Vector2 vector252 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
                                                                Vector2 value57 = base.Center;
                                                                value57 += vector252 * 30f;
                                                                Projectile.NewProjectile(value57.X, value57.Y, vector252.X * num1761, vector252.Y * num1761, 526, 0, 0f, Main.myPlayer, Main.npc[(int)this.ai[2]].Center.X, Main.npc[(int)this.ai[2]].Center.Y);
                                                            }
                                                            for (int num1762 = 0; num1762 < 20; num1762++)
                                                            {
                                                                if (Main.rand.Next(2) != 0)
                                                                {
                                                                    float num1763 = 3f + Main.rand.NextFloat() * 6f;
                                                                    Vector2 vector253 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
                                                                    Vector2 value58 = base.Center;
                                                                    value58 += vector253 * 30f;
                                                                    Vector2 vector254 = base.Center + vector253 * (Main.rand.NextFloat() * 45f + 45f) + Vector2.UnitY * 20f;
                                                                    Projectile.NewProjectile(value58.X, value58.Y, vector253.X * num1763, -20f, 526, 0, 0f, Main.myPlayer, vector254.X, vector254.Y);
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else if (this.ai[3] % 10f == 1f && this.ai[3] > 120f && Main.netMode != 1)
                                                    {
                                                        float num1764 = 3f + Main.rand.NextFloat() * 6f;
                                                        Vector2 vector255 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
                                                        Vector2 value59 = base.Center;
                                                        value59 += vector255 * 25f;
                                                        Projectile.NewProjectile(value59.X, value59.Y, vector255.X * num1764, vector255.Y * num1764, 526, 0, 0f, Main.myPlayer, Main.npc[(int)this.ai[2]].Center.X, Main.npc[(int)this.ai[2]].Center.Y);
                                                    }
                                                }
                                            }
                                            if (this.type == NPCID.CultistDevote)
                                            {
                                                this.velocity.X = this.velocity.X * 0.93f;
                                                if ((double)this.velocity.X > -0.1 && (double)this.velocity.X < 0.1)
                                                {
                                                    this.velocity.X = 0f;
                                                }
                                                int num1765 = (int)(-this.ai[3] - 1f);
                                                if (num1765 == -1)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10.0);
                                                    this.active = false;
                                                    return;
                                                }
                                                int num1766 = Math.Sign(Main.npc[num1765].Center.X - base.Center.X);
                                                if (num1766 != this.direction)
                                                {
                                                    this.velocity.X = 0f;
                                                    this.direction = (this.spriteDirection = num1766);
                                                    this.netUpdate = true;
                                                }
                                                if (this.justHit && Main.netMode != 1 && Main.npc[num1765].localAI[0] == 0f)
                                                {
                                                    Main.npc[num1765].localAI[0] = 1f;
                                                }
                                                if ((this.ai[0] += 1f) >= 300f)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.netUpdate = true;
                                                }
                                            }
                                            if (this.type == NPCID.CultistTablet)
                                            {
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            if (this.aiStyle == 84)
                                            {
                                                bool expertMode2 = Main.expertMode;
                                                bool flag167 = this.life <= this.lifeMax / 2;
                                                int num1767 = 120;
                                                int num1768 = 35;
                                                if (expertMode2)
                                                {
                                                    num1767 = 90;
                                                    num1768 = 25;
                                                }
                                                int num1769 = 18;
                                                int num1770 = 3;
                                                int num1771 = 30;
                                                if (expertMode2)
                                                {
                                                    num1769 = 12;
                                                    num1770 = 4;
                                                    num1771 = 20;
                                                }
                                                int num1772 = 80;
                                                int num1773 = 45;
                                                if (expertMode2)
                                                {
                                                    num1772 = 40;
                                                    num1773 = 30;
                                                }
                                                int num1774 = 20;
                                                int num1775 = 2;
                                                if (expertMode2)
                                                {
                                                    num1774 = 30;
                                                    num1775 = 2;
                                                }
                                                int num1776 = 20;
                                                int num1777 = 3;
                                                bool flag168 = this.type == NPCID.CultistBoss;
                                                bool flag169 = false;
                                                bool flag170 = false;
                                                if (flag167)
                                                {
                                                    this.defense = (int)((float)this.defDefense * 0.65f);
                                                }
                                                if (!flag168)
                                                {
                                                    bool flag171 = this.ai[3] < 0f || !Main.npc[(int)this.ai[3]].active || Main.npc[(int)this.ai[3]].type != 439;
                                                    if (flag171)
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 10.0);
                                                        this.active = false;
                                                        return;
                                                    }
                                                    this.ai[0] = Main.npc[(int)this.ai[3]].ai[0];
                                                    this.ai[1] = Main.npc[(int)this.ai[3]].ai[1];
                                                    if (this.ai[0] == 5f)
                                                    {
                                                        if (this.justHit)
                                                        {
                                                            this.life = 0;
                                                            this.HitEffect(0, 10.0);
                                                            this.active = false;
                                                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", this.whoAmI, 0f, 0f, 0f, 0, 0, 0);
                                                            NPC nPC12 = Main.npc[(int)this.ai[3]];
                                                            nPC12.ai[0] = 6f;
                                                            nPC12.ai[1] = 0f;
                                                            nPC12.netUpdate = true;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        flag169 = true;
                                                        flag170 = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 5f && this.ai[1] >= 120f && this.ai[1] < 420f && this.justHit)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.ai[1] = 0f;
                                                    this.ai[3] += 1f;
                                                    this.velocity = Vector2.Zero;
                                                    this.netUpdate = true;
                                                    List<int> list = new List<int>();
                                                    for (int num1778 = 0; num1778 < 200; num1778++)
                                                    {
                                                        if (Main.npc[num1778].active && Main.npc[num1778].type == NPCID.CultistBossClone && Main.npc[num1778].ai[3] == (float)this.whoAmI)
                                                        {
                                                            list.Add(num1778);
                                                        }
                                                    }
                                                    int num1779 = 10;
                                                    if (Main.expertMode)
                                                    {
                                                        num1779 = 3;
                                                    }
                                                    foreach (int current in list)
                                                    {
                                                        NPC nPC13 = Main.npc[current];
                                                        if (nPC13.localAI[1] == this.localAI[1] && num1779 > 0)
                                                        {
                                                            num1779--;
                                                            nPC13.life = 0;
                                                            nPC13.HitEffect(0, 10.0);
                                                            nPC13.active = false;
                                                            NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", current, 0f, 0f, 0f, 0, 0, 0);
                                                        }
                                                        else if (num1779 > 0)
                                                        {
                                                            num1779--;
                                                            nPC13.life = 0;
                                                            nPC13.HitEffect(0, 10.0);
                                                            nPC13.active = false;
                                                        }
                                                    }
                                                    Main.projectile[(int)this.ai[2]].ai[1] = -1f;
                                                    Main.projectile[(int)this.ai[2]].netUpdate = true;
                                                }
                                                Vector2 center30 = base.Center;
                                                Player player11 = Main.player[this.target];
                                                if (this.target < 0 || this.target == 255 || player11.dead || !player11.active)
                                                {
                                                    this.TargetClosest(false);
                                                    player11 = Main.player[this.target];
                                                    this.netUpdate = true;
                                                }
                                                if (player11.dead || Vector2.Distance(player11.Center, center30) > 5600f)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(0, 10.0);
                                                    this.active = false;
                                                    NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                                                    List<int> list2 = new List<int>();
                                                    list2.Add(this.whoAmI);
                                                    for (int num1780 = 0; num1780 < 200; num1780++)
                                                    {
                                                        if (Main.npc[num1780].active && Main.npc[num1780].type == NPCID.CultistBossClone && Main.npc[num1780].ai[3] == (float)this.whoAmI)
                                                        {
                                                            Main.npc[num1780].life = 0;
                                                            Main.npc[num1780].HitEffect(0, 10.0);
                                                            Main.npc[num1780].active = false;
                                                            NetMessage.SendData((int)PacketTypes.NpcStrike, -1, -1, "", this.whoAmI, -1f, 0f, 0f, 0, 0, 0);
                                                        }
                                                    }
                                                }
                                                float num1781 = this.ai[3];
                                                if (this.localAI[0] == 0f)
                                                {
                                                    this.localAI[0] = 1f;
                                                    this.alpha = 255;
                                                    this.rotation = 0f;
                                                    if (Main.netMode != 1)
                                                    {
                                                        this.ai[0] = -1f;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                if (this.ai[0] == -1f)
                                                {
                                                    this.alpha -= 5;
                                                    if (this.alpha < 0)
                                                    {
                                                        this.alpha = 0;
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 420f)
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.netUpdate = true;
                                                    }
                                                    else if (this.ai[1] > 360f)
                                                    {
                                                        this.velocity *= 0.95f;
                                                        this.localAI[2] = 13f;
                                                    }
                                                    else if (this.ai[1] > 300f)
                                                    {
                                                        this.velocity = -Vector2.UnitY;
                                                        this.localAI[2] = 10f;
                                                    }
                                                    else if (this.ai[1] > 120f)
                                                    {
                                                        this.localAI[2] = 1f;
                                                    }
                                                    else
                                                    {
                                                        this.localAI[2] = 0f;
                                                    }
                                                    flag169 = true;
                                                    flag170 = true;
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    if (this.ai[1] == 0f)
                                                    {
                                                        this.TargetClosest(false);
                                                    }
                                                    this.localAI[2] = 10f;
                                                    int num1782 = Math.Sign(player11.Center.X - center30.X);
                                                    if (num1782 != 0)
                                                    {
                                                        this.direction = (this.spriteDirection = num1782);
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 40f && flag168)
                                                    {
                                                        int num1783 = 0;
                                                        if (flag167)
                                                        {
                                                            switch ((int)this.ai[3])
                                                            {
                                                                case 0:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 1:
                                                                    num1783 = 1;
                                                                    break;
                                                                case 2:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 3:
                                                                    num1783 = 5;
                                                                    break;
                                                                case 4:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 5:
                                                                    num1783 = 3;
                                                                    break;
                                                                case 6:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 7:
                                                                    num1783 = 5;
                                                                    break;
                                                                case 8:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 9:
                                                                    num1783 = 2;
                                                                    break;
                                                                case 10:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 11:
                                                                    num1783 = 3;
                                                                    break;
                                                                case 12:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 13:
                                                                    num1783 = 4;
                                                                    this.ai[3] = -1f;
                                                                    break;
                                                                default:
                                                                    this.ai[3] = -1f;
                                                                    break;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            switch ((int)this.ai[3])
                                                            {
                                                                case 0:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 1:
                                                                    num1783 = 1;
                                                                    break;
                                                                case 2:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 3:
                                                                    num1783 = 2;
                                                                    break;
                                                                case 4:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 5:
                                                                    num1783 = 3;
                                                                    break;
                                                                case 6:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 7:
                                                                    num1783 = 1;
                                                                    break;
                                                                case 8:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 9:
                                                                    num1783 = 2;
                                                                    break;
                                                                case 10:
                                                                    num1783 = 0;
                                                                    break;
                                                                case 11:
                                                                    num1783 = 4;
                                                                    this.ai[3] = -1f;
                                                                    break;
                                                                default:
                                                                    this.ai[3] = -1f;
                                                                    break;
                                                            }
                                                        }
                                                        int maxValue12 = 6;
                                                        if (this.life < this.lifeMax / 3)
                                                        {
                                                            maxValue12 = 4;
                                                        }
                                                        if (this.life < this.lifeMax / 4)
                                                        {
                                                            maxValue12 = 3;
                                                        }
                                                        if (expertMode2 && flag167 && Main.rand.Next(maxValue12) == 0 && num1783 != 0 && num1783 != 4 && num1783 != 5 && NPC.CountNPCS(523) < 10)
                                                        {
                                                            num1783 = 6;
                                                        }
                                                        if (num1783 == 0)
                                                        {
                                                            float num1784 = (float)Math.Ceiling((double)((player11.Center + new Vector2(0f, -100f) - center30).Length() / 50f));
                                                            if (num1784 == 0f)
                                                            {
                                                                num1784 = 1f;
                                                            }
                                                            List<int> list3 = new List<int>();
                                                            int num1785 = 0;
                                                            list3.Add(this.whoAmI);
                                                            for (int num1786 = 0; num1786 < 200; num1786++)
                                                            {
                                                                if (Main.npc[num1786].active && Main.npc[num1786].type == NPCID.CultistBossClone && Main.npc[num1786].ai[3] == (float)this.whoAmI)
                                                                {
                                                                    list3.Add(num1786);
                                                                }
                                                            }
                                                            bool flag172 = list3.Count % 2 == 0;
                                                            foreach (int current2 in list3)
                                                            {
                                                                NPC nPC14 = Main.npc[current2];
                                                                Vector2 center31 = nPC14.Center;
                                                                float num1787 = (float)((num1785 + flag172.ToInt() + 1) / 2) * 6.28318548f * 0.4f / (float)list3.Count;
                                                                if (num1785 % 2 == 1)
                                                                {
                                                                    num1787 *= -1f;
                                                                }
                                                                if (list3.Count == 1)
                                                                {
                                                                    num1787 = 0f;
                                                                }
                                                                Vector2 value60 = new Vector2(0f, -1f).RotatedBy((double)num1787, default(Vector2)) * new Vector2(300f, 200f);
                                                                Vector2 value61 = player11.Center + value60 - center31;
                                                                nPC14.ai[0] = 1f;
                                                                nPC14.ai[1] = num1784 * 2f;
                                                                nPC14.velocity = value61 / num1784;
                                                                if (this.whoAmI >= nPC14.whoAmI)
                                                                {
                                                                    nPC14.position -= nPC14.velocity;
                                                                }
                                                                nPC14.netUpdate = true;
                                                                num1785++;
                                                            }
                                                        }
                                                        if (num1783 == 1)
                                                        {
                                                            this.ai[0] = 3f;
                                                            this.ai[1] = 0f;
                                                        }
                                                        else if (num1783 == 2)
                                                        {
                                                            this.ai[0] = 2f;
                                                            this.ai[1] = 0f;
                                                        }
                                                        else if (num1783 == 3)
                                                        {
                                                            this.ai[0] = 4f;
                                                            this.ai[1] = 0f;
                                                        }
                                                        else if (num1783 == 4)
                                                        {
                                                            this.ai[0] = 5f;
                                                            this.ai[1] = 0f;
                                                        }
                                                        if (num1783 == 5)
                                                        {
                                                            this.ai[0] = 7f;
                                                            this.ai[1] = 0f;
                                                        }
                                                        if (num1783 == 6)
                                                        {
                                                            this.ai[0] = 8f;
                                                            this.ai[1] = 0f;
                                                        }
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 1f)
                                                {
                                                    flag169 = true;
                                                    this.localAI[2] = 10f;
                                                    if ((float)((int)this.ai[1]) % 2f != 0f && this.ai[1] != 1f)
                                                    {
                                                        this.position -= this.velocity;
                                                    }
                                                    this.ai[1] -= 1f;
                                                    if (this.ai[1] <= 0f)
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    this.localAI[2] = 11f;
                                                    Vector2 vec8 = Vector2.Normalize(player11.Center - center30);
                                                    if (vec8.HasNaNs())
                                                    {
                                                        vec8 = new Vector2((float)this.direction, 0f);
                                                    }
                                                    if (this.ai[1] >= 4f && flag168 && (int)(this.ai[1] - 4f) % num1767 == 0)
                                                    {
                                                        if (Main.netMode != 1)
                                                        {
                                                            List<int> list4 = new List<int>();
                                                            for (int num1788 = 0; num1788 < 200; num1788++)
                                                            {
                                                                if (Main.npc[num1788].active && Main.npc[num1788].type == NPCID.CultistBossClone && Main.npc[num1788].ai[3] == (float)this.whoAmI)
                                                                {
                                                                    list4.Add(num1788);
                                                                }
                                                            }
                                                            foreach (int current3 in list4)
                                                            {
                                                                NPC nPC15 = Main.npc[current3];
                                                                Vector2 center32 = nPC15.Center;
                                                                int num1789 = Math.Sign(player11.Center.X - center32.X);
                                                                if (num1789 != 0)
                                                                {
                                                                    nPC15.direction = (nPC15.spriteDirection = num1789);
                                                                }
                                                                vec8 = Vector2.Normalize(player11.Center - center32 + player11.velocity * 20f);
                                                                if (vec8.HasNaNs())
                                                                {
                                                                    vec8 = new Vector2((float)this.direction, 0f);
                                                                }
                                                                Vector2 vector256 = center32 + new Vector2((float)(this.direction * 30), 12f);
                                                                for (int num1790 = 0; num1790 < 1; num1790++)
                                                                {
                                                                    Vector2 spinninpoint = vec8 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                    spinninpoint = spinninpoint.RotatedByRandom(0.52359879016876221);
                                                                    Projectile.NewProjectile(vector256.X, vector256.Y, spinninpoint.X, spinninpoint.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                }
                                                            }
                                                        }
                                                        if (Main.netMode != 1)
                                                        {
                                                            vec8 = Vector2.Normalize(player11.Center - center30 + player11.velocity * 20f);
                                                            if (vec8.HasNaNs())
                                                            {
                                                                vec8 = new Vector2((float)this.direction, 0f);
                                                            }
                                                            Vector2 vector257 = base.Center + new Vector2((float)(this.direction * 30), 12f);
                                                            for (int num1791 = 0; num1791 < 1; num1791++)
                                                            {
                                                                Vector2 vector258 = vec8 * 4f;
                                                                Projectile.NewProjectile(vector257.X, vector257.Y, vector258.X, vector258.Y, 464, num1768, 0f, Main.myPlayer, 0f, 1f);
                                                            }
                                                        }
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= (float)(4 + num1767))
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 3f)
                                                {
                                                    this.localAI[2] = 11f;
                                                    Vector2 vec9 = Vector2.Normalize(player11.Center - center30);
                                                    if (vec9.HasNaNs())
                                                    {
                                                        vec9 = new Vector2((float)this.direction, 0f);
                                                    }
                                                    if (this.ai[1] >= 4f && flag168 && (int)(this.ai[1] - 4f) % num1769 == 0)
                                                    {
                                                        int num1792 = (int)(this.ai[1] - 4f) / num1769;
                                                        if (num1792 == 2)
                                                        {
                                                            List<int> list5 = new List<int>();
                                                            for (int num1793 = 0; num1793 < 200; num1793++)
                                                            {
                                                                if (Main.npc[num1793].active && Main.npc[num1793].type == NPCID.CultistBossClone && Main.npc[num1793].ai[3] == (float)this.whoAmI)
                                                                {
                                                                    list5.Add(num1793);
                                                                }
                                                            }
                                                            if (Main.netMode != 1)
                                                            {
                                                                foreach (int current4 in list5)
                                                                {
                                                                    NPC nPC16 = Main.npc[current4];
                                                                    Vector2 center33 = nPC16.Center;
                                                                    int num1794 = Math.Sign(player11.Center.X - center33.X);
                                                                    if (num1794 != 0)
                                                                    {
                                                                        nPC16.direction = (nPC16.spriteDirection = num1794);
                                                                    }
                                                                    vec9 = Vector2.Normalize(player11.Center - center33 + player11.velocity * 20f);
                                                                    if (vec9.HasNaNs())
                                                                    {
                                                                        vec9 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    Vector2 vector259 = center33 + new Vector2((float)(this.direction * 30), 12f);
                                                                    for (int num1795 = 0; num1795 < 1; num1795++)
                                                                    {
                                                                        Vector2 spinninpoint2 = vec9 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                        spinninpoint2 = spinninpoint2.RotatedByRandom(0.52359879016876221);
                                                                        Projectile.NewProjectile(vector259.X, vector259.Y, spinninpoint2.X, spinninpoint2.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        int num1796 = Math.Sign(player11.Center.X - center30.X);
                                                        if (num1796 != 0)
                                                        {
                                                            this.direction = (this.spriteDirection = num1796);
                                                        }
                                                        if (Main.netMode != 1)
                                                        {
                                                            vec9 = Vector2.Normalize(player11.Center - center30 + player11.velocity * 20f);
                                                            if (vec9.HasNaNs())
                                                            {
                                                                vec9 = new Vector2((float)this.direction, 0f);
                                                            }
                                                            Vector2 vector260 = base.Center + new Vector2((float)(this.direction * 30), 12f);
                                                            for (int num1797 = 0; num1797 < 1; num1797++)
                                                            {
                                                                Vector2 spinninpoint3 = vec9 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                spinninpoint3 = spinninpoint3.RotatedByRandom(0.52359879016876221);
                                                                Projectile.NewProjectile(vector260.X, vector260.Y, spinninpoint3.X, spinninpoint3.Y, 467, num1771, 0f, Main.myPlayer, 0f, 0f);
                                                            }
                                                        }
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= (float)(4 + num1769 * num1770))
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 4f)
                                                {
                                                    if (flag168)
                                                    {
                                                        this.localAI[2] = 12f;
                                                    }
                                                    else
                                                    {
                                                        this.localAI[2] = 11f;
                                                    }
                                                    if (this.ai[1] == 20f && flag168 && Main.netMode != 1)
                                                    {
                                                        List<int> list6 = new List<int>();
                                                        for (int num1798 = 0; num1798 < 200; num1798++)
                                                        {
                                                            if (Main.npc[num1798].active && Main.npc[num1798].type == NPCID.CultistBossClone && Main.npc[num1798].ai[3] == (float)this.whoAmI)
                                                            {
                                                                list6.Add(num1798);
                                                            }
                                                        }
                                                        foreach (int current5 in list6)
                                                        {
                                                            NPC nPC17 = Main.npc[current5];
                                                            Vector2 center34 = nPC17.Center;
                                                            int num1799 = Math.Sign(player11.Center.X - center34.X);
                                                            if (num1799 != 0)
                                                            {
                                                                nPC17.direction = (nPC17.spriteDirection = num1799);
                                                            }
                                                            if (Main.netMode != 1)
                                                            {
                                                                Vector2 vec10 = Vector2.Normalize(player11.Center - center34 + player11.velocity * 20f);
                                                                if (vec10.HasNaNs())
                                                                {
                                                                    vec10 = new Vector2((float)this.direction, 0f);
                                                                }
                                                                Vector2 vector261 = center34 + new Vector2((float)(this.direction * 30), 12f);
                                                                for (int num1800 = 0; num1800 < 1; num1800++)
                                                                {
                                                                    Vector2 spinninpoint4 = vec10 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                    spinninpoint4 = spinninpoint4.RotatedByRandom(0.52359879016876221);
                                                                    Projectile.NewProjectile(vector261.X, vector261.Y, spinninpoint4.X, spinninpoint4.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                }
                                                            }
                                                        }
                                                        if ((int)(this.ai[1] - 20f) % num1772 == 0)
                                                        {
                                                            Projectile.NewProjectile(base.Center.X, base.Center.Y - 100f, 0f, 0f, 465, num1773, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= (float)(20 + num1772))
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 5f)
                                                {
                                                    this.localAI[2] = 10f;
                                                    Vector2 vec11 = Vector2.Normalize(player11.Center - center30);
                                                    if (vec11.HasNaNs())
                                                    {
                                                        vec11 = new Vector2((float)this.direction, 0f);
                                                    }
                                                    if (this.ai[1] >= 0f && this.ai[1] < 30f)
                                                    {
                                                        flag169 = true;
                                                        flag170 = true;
                                                        float num1801 = (this.ai[1] - 0f) / 30f;
                                                        this.alpha = (int)(num1801 * 255f);
                                                    }
                                                    else if (this.ai[1] >= 30f && this.ai[1] < 90f)
                                                    {
                                                        if (this.ai[1] == 30f && Main.netMode != 1 && flag168)
                                                        {
                                                            this.localAI[1] += 1f;
                                                            Vector2 spinningpoint10 = new Vector2(180f, 0f);
                                                            List<int> list7 = new List<int>();
                                                            for (int num1802 = 0; num1802 < 200; num1802++)
                                                            {
                                                                if (Main.npc[num1802].active && Main.npc[num1802].type == NPCID.CultistBossClone && Main.npc[num1802].ai[3] == (float)this.whoAmI)
                                                                {
                                                                    list7.Add(num1802);
                                                                }
                                                            }
                                                            int num1803 = 6 - list7.Count;
                                                            if (num1803 > 2)
                                                            {
                                                                num1803 = 2;
                                                            }
                                                            int num1804 = list7.Count + num1803 + 1;
                                                            float[] array8 = new float[num1804];
                                                            for (int num1805 = 0; num1805 < array8.Length; num1805++)
                                                            {
                                                                array8[num1805] = Vector2.Distance(base.Center + spinningpoint10.RotatedBy((double)((float)num1805 * 6.28318548f / (float)num1804 - 1.57079637f), default(Vector2)), player11.Center);
                                                            }
                                                            int num1806 = 0;
                                                            for (int num1807 = 1; num1807 < array8.Length; num1807++)
                                                            {
                                                                if (array8[num1806] > array8[num1807])
                                                                {
                                                                    num1806 = num1807;
                                                                }
                                                            }
                                                            if (num1806 < num1804 / 2)
                                                            {
                                                                num1806 += num1804 / 2;
                                                            }
                                                            else
                                                            {
                                                                num1806 -= num1804 / 2;
                                                            }
                                                            int num1808 = num1803;
                                                            for (int num1809 = 0; num1809 < array8.Length; num1809++)
                                                            {
                                                                if (num1806 != num1809)
                                                                {
                                                                    Vector2 center35 = base.Center + spinningpoint10.RotatedBy((double)((float)num1809 * 6.28318548f / (float)num1804 - 1.57079637f), default(Vector2));
                                                                    if (num1808-- > 0)
                                                                    {
                                                                        int num1810 = NPC.NewNPC((int)center35.X, (int)center35.Y + this.height / 2, 440, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                                        Main.npc[num1810].ai[3] = (float)this.whoAmI;
                                                                        Main.npc[num1810].netUpdate = true;
                                                                        Main.npc[num1810].localAI[1] = this.localAI[1];
                                                                    }
                                                                    else
                                                                    {
                                                                        int num1811 = list7[-num1808 - 1];
                                                                        Main.npc[num1811].Center = center35;
                                                                        NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, "", num1811, 0f, 0f, 0f, 0, 0, 0);
                                                                    }
                                                                }
                                                            }
                                                            this.ai[2] = (float)Projectile.NewProjectile(base.Center.X, base.Center.Y, 0f, 0f, 490, 0, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                            base.Center += spinningpoint10.RotatedBy((double)((float)num1806 * 6.28318548f / (float)num1804 - 1.57079637f), default(Vector2));
                                                            this.netUpdate = true;
                                                            list7.Clear();
                                                        }
                                                        flag169 = true;
                                                        flag170 = true;
                                                        this.alpha = 255;
                                                        if (flag168)
                                                        {
                                                            Vector2 value62 = Main.projectile[(int)this.ai[2]].Center;
                                                            value62 -= base.Center;
                                                            if (value62 == Vector2.Zero)
                                                            {
                                                                value62 = -Vector2.UnitY;
                                                            }
                                                            value62.Normalize();
                                                            if (Math.Abs(value62.Y) < 0.77f)
                                                            {
                                                                this.localAI[2] = 11f;
                                                            }
                                                            else if (value62.Y < 0f)
                                                            {
                                                                this.localAI[2] = 12f;
                                                            }
                                                            else
                                                            {
                                                                this.localAI[2] = 10f;
                                                            }
                                                            int num1812 = Math.Sign(value62.X);
                                                            if (num1812 != 0)
                                                            {
                                                                this.direction = (this.spriteDirection = num1812);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Vector2 value63 = Main.projectile[(int)Main.npc[(int)this.ai[3]].ai[2]].Center;
                                                            value63 -= base.Center;
                                                            if (value63 == Vector2.Zero)
                                                            {
                                                                value63 = -Vector2.UnitY;
                                                            }
                                                            value63.Normalize();
                                                            if (Math.Abs(value63.Y) < 0.77f)
                                                            {
                                                                this.localAI[2] = 11f;
                                                            }
                                                            else if (value63.Y < 0f)
                                                            {
                                                                this.localAI[2] = 12f;
                                                            }
                                                            else
                                                            {
                                                                this.localAI[2] = 10f;
                                                            }
                                                            int num1813 = Math.Sign(value63.X);
                                                            if (num1813 != 0)
                                                            {
                                                                this.direction = (this.spriteDirection = num1813);
                                                            }
                                                        }
                                                    }
                                                    else if (this.ai[1] >= 90f && this.ai[1] < 120f)
                                                    {
                                                        flag169 = true;
                                                        flag170 = true;
                                                        float num1814 = (this.ai[1] - 90f) / 30f;
                                                        this.alpha = 255 - (int)(num1814 * 255f);
                                                    }
                                                    else if (this.ai[1] >= 120f && this.ai[1] < 420f)
                                                    {
                                                        flag170 = true;
                                                        this.alpha = 0;
                                                        if (flag168)
                                                        {
                                                            Vector2 value64 = Main.projectile[(int)this.ai[2]].Center;
                                                            value64 -= base.Center;
                                                            if (value64 == Vector2.Zero)
                                                            {
                                                                value64 = -Vector2.UnitY;
                                                            }
                                                            value64.Normalize();
                                                            if (Math.Abs(value64.Y) < 0.77f)
                                                            {
                                                                this.localAI[2] = 11f;
                                                            }
                                                            else if (value64.Y < 0f)
                                                            {
                                                                this.localAI[2] = 12f;
                                                            }
                                                            else
                                                            {
                                                                this.localAI[2] = 10f;
                                                            }
                                                            int num1815 = Math.Sign(value64.X);
                                                            if (num1815 != 0)
                                                            {
                                                                this.direction = (this.spriteDirection = num1815);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Vector2 value65 = Main.projectile[(int)Main.npc[(int)this.ai[3]].ai[2]].Center;
                                                            value65 -= base.Center;
                                                            if (value65 == Vector2.Zero)
                                                            {
                                                                value65 = -Vector2.UnitY;
                                                            }
                                                            value65.Normalize();
                                                            if (Math.Abs(value65.Y) < 0.77f)
                                                            {
                                                                this.localAI[2] = 11f;
                                                            }
                                                            else if (value65.Y < 0f)
                                                            {
                                                                this.localAI[2] = 12f;
                                                            }
                                                            else
                                                            {
                                                                this.localAI[2] = 10f;
                                                            }
                                                            int num1816 = Math.Sign(value65.X);
                                                            if (num1816 != 0)
                                                            {
                                                                this.direction = (this.spriteDirection = num1816);
                                                            }
                                                        }
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 420f)
                                                    {
                                                        flag170 = true;
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 6f)
                                                {
                                                    this.localAI[2] = 13f;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 120f)
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 7f)
                                                {
                                                    this.localAI[2] = 11f;
                                                    Vector2 vec12 = Vector2.Normalize(player11.Center - center30);
                                                    if (vec12.HasNaNs())
                                                    {
                                                        vec12 = new Vector2((float)this.direction, 0f);
                                                    }
                                                    if (this.ai[1] >= 4f && flag168 && (int)(this.ai[1] - 4f) % num1774 == 0)
                                                    {
                                                        int num1817 = (int)(this.ai[1] - 4f) / num1774;
                                                        if (num1817 == 2)
                                                        {
                                                            List<int> list8 = new List<int>();
                                                            for (int num1818 = 0; num1818 < 200; num1818++)
                                                            {
                                                                if (Main.npc[num1818].active && Main.npc[num1818].type == NPCID.CultistBossClone && Main.npc[num1818].ai[3] == (float)this.whoAmI)
                                                                {
                                                                    list8.Add(num1818);
                                                                }
                                                            }
                                                            foreach (int current6 in list8)
                                                            {
                                                                NPC nPC18 = Main.npc[current6];
                                                                Vector2 center36 = nPC18.Center;
                                                                int num1819 = Math.Sign(player11.Center.X - center36.X);
                                                                if (num1819 != 0)
                                                                {
                                                                    nPC18.direction = (nPC18.spriteDirection = num1819);
                                                                }
                                                                if (Main.netMode != 1)
                                                                {
                                                                    vec12 = Vector2.Normalize(player11.Center - center36 + player11.velocity * 20f);
                                                                    if (vec12.HasNaNs())
                                                                    {
                                                                        vec12 = new Vector2((float)this.direction, 0f);
                                                                    }
                                                                    Vector2 vector262 = center36 + new Vector2((float)(this.direction * 30), 12f);
                                                                    int num1820 = 0;
                                                                    while ((float)num1820 < 5f)
                                                                    {
                                                                        Vector2 spinninpoint5 = vec12 * (6f + (float)Main.rand.NextDouble() * 4f);
                                                                        spinninpoint5 = spinninpoint5.RotatedByRandom(1.2566370964050293);
                                                                        Projectile.NewProjectile(vector262.X, vector262.Y, spinninpoint5.X, spinninpoint5.Y, 468, 18, 0f, Main.myPlayer, 0f, 0f);
                                                                        num1820++;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        int num1821 = Math.Sign(player11.Center.X - center30.X);
                                                        if (num1821 != 0)
                                                        {
                                                            this.direction = (this.spriteDirection = num1821);
                                                        }
                                                        if (Main.netMode != 1)
                                                        {
                                                            vec12 = Vector2.Normalize(player11.Center - center30 + player11.velocity * 20f);
                                                            if (vec12.HasNaNs())
                                                            {
                                                                vec12 = new Vector2((float)this.direction, 0f);
                                                            }
                                                            Vector2 vector263 = base.Center + new Vector2((float)(this.direction * 30), 12f);
                                                            float scaleFactor24 = 8f;
                                                            float num1822 = 0.251327425f;
                                                            int num1823 = 0;
                                                            while ((float)num1823 < 5f)
                                                            {
                                                                Vector2 vector264 = vec12 * scaleFactor24;
                                                                vector264 = vector264.RotatedBy((double)(num1822 * (float)num1823 - (1.2566371f - num1822) / 2f), default(Vector2));
                                                                float ai4 = (Main.rand.NextFloat() - 0.5f) * 0.3f * 6.28318548f / 60f;
                                                                int num1824 = NPC.NewNPC((int)vector263.X, (int)vector263.Y + 7, 522, 0, 0f, ai4, vector264.X, vector264.Y, 255);
                                                                Main.npc[num1824].velocity = vector264;
                                                                num1823++;
                                                            }
                                                        }
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= (float)(4 + num1774 * num1775))
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                else if (this.ai[0] == 8f)
                                                {
                                                    this.localAI[2] = 13f;
                                                    if (this.ai[1] >= 4f && flag168 && (int)(this.ai[1] - 4f) % num1776 == 0)
                                                    {
                                                        List<int> list9 = new List<int>();
                                                        for (int num1825 = 0; num1825 < 200; num1825++)
                                                        {
                                                            if (Main.npc[num1825].active && Main.npc[num1825].type == NPCID.CultistBossClone && Main.npc[num1825].ai[3] == (float)this.whoAmI)
                                                            {
                                                                list9.Add(num1825);
                                                            }
                                                        }
                                                        int num1826 = list9.Count + 1;
                                                        if (num1826 > 3)
                                                        {
                                                            num1826 = 3;
                                                        }
                                                        int num1827 = Math.Sign(player11.Center.X - center30.X);
                                                        if (num1827 != 0)
                                                        {
                                                            this.direction = (this.spriteDirection = num1827);
                                                        }
                                                        if (Main.netMode != 1)
                                                        {
                                                            for (int num1828 = 0; num1828 < num1826; num1828++)
                                                            {
                                                                Point point11 = base.Center.ToTileCoordinates();
                                                                Point point12 = Main.player[this.target].Center.ToTileCoordinates();
                                                                Vector2 vector265 = Main.player[this.target].Center - base.Center;
                                                                int num1829 = 20;
                                                                int num1830 = 3;
                                                                int num1831 = 7;
                                                                int num1832 = 2;
                                                                int num1833 = 0;
                                                                bool flag173 = false;
                                                                if (vector265.Length() > 2000f)
                                                                {
                                                                    flag173 = true;
                                                                }
                                                                while (!flag173 && num1833 < 100)
                                                                {
                                                                    num1833++;
                                                                    int num1834 = Main.rand.Next(point12.X - num1829, point12.X + num1829 + 1);
                                                                    int num1835 = Main.rand.Next(point12.Y - num1829, point12.Y + num1829 + 1);
                                                                    if ((num1835 < point12.Y - num1831 || num1835 > point12.Y + num1831 || num1834 < point12.X - num1831 || num1834 > point12.X + num1831) && (num1835 < point11.Y - num1830 || num1835 > point11.Y + num1830 || num1834 < point11.X - num1830 || num1834 > point11.X + num1830) && !Main.tile[num1834, num1835].nactive())
                                                                    {
                                                                        bool flag174 = true;
                                                                        if (flag174 && Collision.SolidTiles(num1834 - num1832, num1834 + num1832, num1835 - num1832, num1835 + num1832))
                                                                        {
                                                                            flag174 = false;
                                                                        }
                                                                        if (flag174)
                                                                        {
                                                                            NPC.NewNPC(num1834 * 16 + 8, num1835 * 16 + 8, 523, 0, (float)this.whoAmI, 0f, 0f, 0f, 255);
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= (float)(4 + num1776 * num1777))
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.ai[3] += 1f;
                                                        this.velocity = Vector2.Zero;
                                                        this.netUpdate = true;
                                                    }
                                                }
                                                if (!flag168)
                                                {
                                                    this.ai[3] = num1781;
                                                }
                                                this.dontTakeDamage = flag169;
                                                this.chaseable = !flag170;
                                                return;
                                            }
                                            if (this.aiStyle == 85)
                                            {
                                                this.noTileCollide = false;
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 1f;
                                                    }
                                                    else
                                                    {
                                                        Vector2 value66 = Main.player[this.target].Center - base.Center;
                                                        value66.Y -= (float)(Main.player[this.target].height / 4);
                                                        float num1836 = value66.Length();
                                                        if (num1836 > 800f)
                                                        {
                                                            this.ai[0] = 2f;
                                                        }
                                                        else
                                                        {
                                                            Vector2 center37 = base.Center;
                                                            center37.X = Main.player[this.target].Center.X;
                                                            Vector2 vector266 = center37 - base.Center;
                                                            if (vector266.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center37, 1, 1))
                                                            {
                                                                this.ai[0] = 3f;
                                                                this.ai[1] = center37.X;
                                                                this.ai[2] = center37.Y;
                                                                Vector2 center38 = base.Center;
                                                                center38.Y = Main.player[this.target].Center.Y;
                                                                if (vector266.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center38, 1, 1) && Collision.CanHit(center38, 1, 1, Main.player[this.target].position, 1, 1))
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = center38.X;
                                                                    this.ai[2] = center38.Y;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                center37 = base.Center;
                                                                center37.Y = Main.player[this.target].Center.Y;
                                                                if ((center37 - base.Center).Length() > 8f && Collision.CanHit(base.Center, 1, 1, center37, 1, 1))
                                                                {
                                                                    this.ai[0] = 3f;
                                                                    this.ai[1] = center37.X;
                                                                    this.ai[2] = center37.Y;
                                                                }
                                                            }
                                                            if (this.ai[0] == 0f)
                                                            {
                                                                this.localAI[0] = 0f;
                                                                value66.Normalize();
                                                                value66 *= 0.5f;
                                                                this.velocity += value66;
                                                                this.ai[0] = 4f;
                                                                this.ai[1] = 0f;
                                                            }
                                                        }
                                                    }
                                                }
                                                else if (this.ai[0] == 1f)
                                                {
                                                    this.rotation += (float)this.direction * 0.3f;
                                                    Vector2 value67 = Main.player[this.target].Center - base.Center;
                                                    if (this.type == NPCID.NebulaHeadcrab)
                                                    {
                                                        value67 = Main.player[this.target].Top - base.Center;
                                                    }
                                                    float num1837 = value67.Length();
                                                    float num1838 = 5.5f;
                                                    num1838 += num1837 / 100f;
                                                    int num1839 = 50;
                                                    value67.Normalize();
                                                    value67 *= num1838;
                                                    this.velocity = (this.velocity * (float)(num1839 - 1) + value67) / (float)num1839;
                                                    if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                    }
                                                    if (this.type == NPCID.NebulaHeadcrab && num1837 < 40f && Main.player[this.target].active && !Main.player[this.target].dead)
                                                    {
                                                        bool flag175 = true;
                                                        for (int num1840 = 0; num1840 < 200; num1840++)
                                                        {
                                                            NPC nPC19 = Main.npc[num1840];
                                                            if (nPC19.active && nPC19.type == this.type && nPC19.ai[0] == 5f && nPC19.target == this.target)
                                                            {
                                                                flag175 = false;
                                                                break;
                                                            }
                                                        }
                                                        if (flag175)
                                                        {
                                                            base.Center = Main.player[this.target].Top;
                                                            this.velocity = Vector2.Zero;
                                                            this.ai[0] = 5f;
                                                            this.ai[1] = 0f;
                                                            this.netUpdate = true;
                                                        }
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    this.rotation = this.velocity.X * 0.1f;
                                                    this.noTileCollide = true;
                                                    Vector2 value68 = Main.player[this.target].Center - base.Center;
                                                    float num1841 = value68.Length();
                                                    float scaleFactor25 = 3f;
                                                    int num1842 = 3;
                                                    value68.Normalize();
                                                    value68 *= scaleFactor25;
                                                    this.velocity = (this.velocity * (float)(num1842 - 1) + value68) / (float)num1842;
                                                    if (num1841 < 600f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                }
                                                else if (this.ai[0] == 3f)
                                                {
                                                    this.rotation = this.velocity.X * 0.1f;
                                                    Vector2 value69 = new Vector2(this.ai[1], this.ai[2]);
                                                    Vector2 value70 = value69 - base.Center;
                                                    float num1843 = value70.Length();
                                                    float num1844 = 2f;
                                                    float num1845 = 3f;
                                                    value70.Normalize();
                                                    value70 *= num1844;
                                                    this.velocity = (this.velocity * (num1845 - 1f) + value70) / num1845;
                                                    if (this.collideX || this.collideY)
                                                    {
                                                        this.ai[0] = 4f;
                                                        this.ai[1] = 0f;
                                                    }
                                                    if (num1843 < num1844 || num1843 > 800f || Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                }
                                                else if (this.ai[0] == 4f)
                                                {
                                                    this.rotation = this.velocity.X * 0.1f;
                                                    if (this.collideX)
                                                    {
                                                        this.velocity.X = this.velocity.X * -0.8f;
                                                    }
                                                    if (this.collideY)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * -0.8f;
                                                    }
                                                    Vector2 value71;
                                                    if (this.velocity.X == 0f && this.velocity.Y == 0f)
                                                    {
                                                        value71 = Main.player[this.target].Center - base.Center;
                                                        value71.Y -= (float)(Main.player[this.target].height / 4);
                                                        value71.Normalize();
                                                        this.velocity = value71 * 0.1f;
                                                    }
                                                    float scaleFactor26 = 2f;
                                                    float num1846 = 20f;
                                                    value71 = this.velocity;
                                                    value71.Normalize();
                                                    value71 *= scaleFactor26;
                                                    this.velocity = (this.velocity * (num1846 - 1f) + value71) / num1846;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] > 180f)
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                    }
                                                    if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                    this.localAI[0] += 1f;
                                                    if (this.localAI[0] >= 5f && !Collision.SolidCollision(this.position - new Vector2(10f, 10f), this.width + 20, this.height + 20))
                                                    {
                                                        this.localAI[0] = 0f;
                                                        Vector2 center39 = base.Center;
                                                        center39.X = Main.player[this.target].Center.X;
                                                        if (Collision.CanHit(base.Center, 1, 1, center39, 1, 1) && Collision.CanHit(base.Center, 1, 1, center39, 1, 1) && Collision.CanHit(Main.player[this.target].Center, 1, 1, center39, 1, 1))
                                                        {
                                                            this.ai[0] = 3f;
                                                            this.ai[1] = center39.X;
                                                            this.ai[2] = center39.Y;
                                                        }
                                                        else
                                                        {
                                                            center39 = base.Center;
                                                            center39.Y = Main.player[this.target].Center.Y;
                                                            if (Collision.CanHit(base.Center, 1, 1, center39, 1, 1) && Collision.CanHit(Main.player[this.target].Center, 1, 1, center39, 1, 1))
                                                            {
                                                                this.ai[0] = 3f;
                                                                this.ai[1] = center39.X;
                                                                this.ai[2] = center39.Y;
                                                            }
                                                        }
                                                    }
                                                }
                                                else if (this.ai[0] == 5f)
                                                {
                                                    Player player12 = Main.player[this.target];
                                                    if (!player12.active || player12.dead)
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        this.netUpdate = true;
                                                    }
                                                    else
                                                    {
                                                        base.Center = ((player12.gravDir == 1f) ? player12.Top : player12.Bottom) + new Vector2((float)(player12.direction * 4), 0f);
                                                        this.gfxOffY = player12.gfxOffY;
                                                        this.velocity = Vector2.Zero;
                                                        player12.AddBuff(BuffID.Obstructed, 59, true);
                                                    }
                                                }
                                                if (this.type == NPCID.StardustCellBig)
                                                {
                                                    this.rotation = 0f;
                                                    for (int num1847 = 0; num1847 < 200; num1847++)
                                                    {
                                                        if (num1847 != this.whoAmI && Main.npc[num1847].active && Main.npc[num1847].type == this.type && Math.Abs(this.position.X - Main.npc[num1847].position.X) + Math.Abs(this.position.Y - Main.npc[num1847].position.Y) < (float)this.width)
                                                        {
                                                            if (this.position.X < Main.npc[num1847].position.X)
                                                            {
                                                                this.velocity.X = this.velocity.X - 0.05f;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X + 0.05f;
                                                            }
                                                            if (this.position.Y < Main.npc[num1847].position.Y)
                                                            {
                                                                this.velocity.Y = this.velocity.Y - 0.05f;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.Y = this.velocity.Y + 0.05f;
                                                            }
                                                        }
                                                    }
                                                    return;
                                                }
                                                if (this.type == NPCID.NebulaHeadcrab)
                                                {
                                                    this.hide = (this.ai[0] == 5f);
                                                    this.rotation = this.velocity.X * 0.1f;
                                                    for (int num1848 = 0; num1848 < 200; num1848++)
                                                    {
                                                        if (num1848 != this.whoAmI && Main.npc[num1848].active && Main.npc[num1848].type == this.type && Math.Abs(this.position.X - Main.npc[num1848].position.X) + Math.Abs(this.position.Y - Main.npc[num1848].position.Y) < (float)this.width)
                                                        {
                                                            if (this.position.X < Main.npc[num1848].position.X)
                                                            {
                                                                this.velocity.X = this.velocity.X - 0.05f;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X + 0.05f;
                                                            }
                                                            if (this.position.Y < Main.npc[num1848].position.Y)
                                                            {
                                                                this.velocity.Y = this.velocity.Y - 0.05f;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.Y = this.velocity.Y + 0.05f;
                                                            }
                                                        }
                                                    }
                                                    return;
                                                }
                                            }
                                            else if (this.aiStyle == 86)
                                            {
                                                if (this.alpha > 0)
                                                {
                                                    this.alpha -= 30;
                                                    if (this.alpha < 0)
                                                    {
                                                        this.alpha = 0;
                                                    }
                                                }
                                                this.noGravity = true;
                                                this.noTileCollide = true;
                                                this.knockBackResist = 0f;
                                                for (int num1849 = 0; num1849 < 200; num1849++)
                                                {
                                                    if (num1849 != this.whoAmI && Main.npc[num1849].active && Main.npc[num1849].type == this.type)
                                                    {
                                                        Vector2 value72 = Main.npc[num1849].Center - base.Center;
                                                        if (value72.Length() < 50f)
                                                        {
                                                            value72.Normalize();
                                                            if (value72.X == 0f && value72.Y == 0f)
                                                            {
                                                                if (num1849 > this.whoAmI)
                                                                {
                                                                    value72.X = 1f;
                                                                }
                                                                else
                                                                {
                                                                    value72.X = -1f;
                                                                }
                                                            }
                                                            value72 *= 0.4f;
                                                            this.velocity -= value72;
                                                            Main.npc[num1849].velocity += value72;
                                                        }
                                                    }
                                                }
                                                if (this.type == NPCID.ShadowFlameApparition)
                                                {
                                                    float num1850 = 120f;
                                                    if (this.localAI[0] < num1850)
                                                    {
                                                        if (this.localAI[0] == 0f)
                                                        {
                                                            this.TargetClosest(true);
                                                            if (this.direction > 0)
                                                            {
                                                                this.velocity.X = this.velocity.X + 2f;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X - 2f;
                                                            }
                                                        }
                                                        this.localAI[0] += 1f;
                                                    }
                                                }
                                                if (this.type == NPCID.AncientCultistSquidhead)
                                                {
                                                    float num1857 = 120f;
                                                    if (this.localAI[0] < num1857)
                                                    {
                                                        if (this.localAI[0] == 0f)
                                                        {
                                                            this.TargetClosest(true);
                                                            if (this.direction > 0)
                                                            {
                                                                this.velocity.X = this.velocity.X + 2f;
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X - 2f;
                                                            }
                                                        }
                                                        this.localAI[0] += 1f;
                                                    }
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = (float)this.direction;
                                                }
                                                else if (this.ai[0] == 1f)
                                                {
                                                    this.TargetClosest(true);
                                                    float num1861 = 0.3f;
                                                    float num1862 = 7f;
                                                    float num1863 = 4f;
                                                    float num1864 = 660f;
                                                    float num1865 = 4f;
                                                    if (this.type == NPCID.AncientCultistSquidhead)
                                                    {
                                                        num1861 = 0.7f;
                                                        num1862 = 14f;
                                                        num1864 = 500f;
                                                        num1863 = 6f;
                                                        num1865 = 3f;
                                                    }
                                                    this.velocity.X = this.velocity.X + this.ai[1] * num1861;
                                                    if (this.velocity.X > num1862)
                                                    {
                                                        this.velocity.X = num1862;
                                                    }
                                                    if (this.velocity.X < -num1862)
                                                    {
                                                        this.velocity.X = -num1862;
                                                    }
                                                    float num1866 = Main.player[this.target].Center.Y - base.Center.Y;
                                                    if (Math.Abs(num1866) > num1863)
                                                    {
                                                        num1865 = 15f;
                                                    }
                                                    if (num1866 > num1863)
                                                    {
                                                        num1866 = num1863;
                                                    }
                                                    else if (num1866 < -num1863)
                                                    {
                                                        num1866 = -num1863;
                                                    }
                                                    this.velocity.Y = (this.velocity.Y * (num1865 - 1f) + num1866) / num1865;
                                                    if ((this.ai[1] > 0f && Main.player[this.target].Center.X - base.Center.X < -num1864) || (this.ai[1] < 0f && Main.player[this.target].Center.X - base.Center.X > num1864))
                                                    {
                                                        this.ai[0] = 2f;
                                                        this.ai[1] = 0f;
                                                        if (base.Center.Y + 20f > Main.player[this.target].Center.Y)
                                                        {
                                                            this.ai[1] = -1f;
                                                        }
                                                        else
                                                        {
                                                            this.ai[1] = 1f;
                                                        }
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    float num1867 = 0.4f;
                                                    float scaleFactor27 = 0.95f;
                                                    float num1868 = 5f;
                                                    if (this.type == NPCID.AncientCultistSquidhead)
                                                    {
                                                        num1867 = 0.3f;
                                                        num1868 = 7f;
                                                        scaleFactor27 = 0.9f;
                                                    }
                                                    this.velocity.Y = this.velocity.Y + this.ai[1] * num1867;
                                                    if (this.velocity.Length() > num1868)
                                                    {
                                                        this.velocity *= scaleFactor27;
                                                    }
                                                    if (this.velocity.X > -1f && this.velocity.X < 1f)
                                                    {
                                                        this.TargetClosest(true);
                                                        this.ai[0] = 3f;
                                                        this.ai[1] = (float)this.direction;
                                                    }
                                                }
                                                else if (this.ai[0] == 3f)
                                                {
                                                    float num1869 = 0.4f;
                                                    float num1870 = 0.2f;
                                                    float num1871 = 5f;
                                                    float scaleFactor28 = 0.95f;
                                                    if (this.type == NPCID.AncientCultistSquidhead)
                                                    {
                                                        num1869 = 0.6f;
                                                        num1870 = 0.3f;
                                                        num1871 = 7f;
                                                        scaleFactor28 = 0.9f;
                                                    }
                                                    this.velocity.X = this.velocity.X + this.ai[1] * num1869;
                                                    if (base.Center.Y > Main.player[this.target].Center.Y)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - num1870;
                                                    }
                                                    else
                                                    {
                                                        this.velocity.Y = this.velocity.Y + num1870;
                                                    }
                                                    if (this.velocity.Length() > num1871)
                                                    {
                                                        this.velocity *= scaleFactor28;
                                                    }
                                                    if (this.velocity.Y > -1f && this.velocity.Y < 1f)
                                                    {
                                                        this.TargetClosest(true);
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = (float)this.direction;
                                                    }
                                                }
                                                if (this.type == NPCID.AncientCultistSquidhead)
                                                {
                                                    return;
                                                }
                                            }
                                            else if (this.aiStyle == 87)
                                            {
                                                this.knockBackResist = 0.2f * Main.knockBackMultiplier;
                                                this.dontTakeDamage = false;
                                                this.noTileCollide = false;
                                                this.noGravity = false;
                                                this.reflectingProjectiles = false;
                                                if (this.ai[0] != 7f && Main.player[this.target].dead)
                                                {
                                                    this.TargetClosest(true);
                                                    if (Main.player[this.target].dead)
                                                    {
                                                        this.ai[0] = 7f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                    }
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    Vector2 vector268 = Main.player[this.target].Center - base.Center;
                                                    if (this.velocity.X != 0f || this.velocity.Y > 100f || this.justHit || vector268.Length() < 80f)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.ai[1] = 0f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 1f)
                                                {
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] > 36f)
                                                    {
                                                        this.ai[0] = 2f;
                                                        this.ai[1] = 0f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    if ((Main.player[this.target].Center - base.Center).Length() > 600f)
                                                    {
                                                        this.ai[0] = 5f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                    }
                                                    if (this.velocity.Y == 0f)
                                                    {
                                                        this.TargetClosest(true);
                                                        this.velocity.X = this.velocity.X * 0.85f;
                                                        this.ai[1] += 1f;
                                                        float num1875 = 15f + 30f * ((float)this.life / (float)this.lifeMax);
                                                        float num1876 = 3f + 4f * (1f - (float)this.life / (float)this.lifeMax);
                                                        float num1877 = 4f;
                                                        if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                        {
                                                            num1877 += 2f;
                                                        }
                                                        if (this.ai[1] > num1875)
                                                        {
                                                            this.ai[3] += 1f;
                                                            if (this.ai[3] >= 3f)
                                                            {
                                                                this.ai[3] = 0f;
                                                                num1877 *= 2f;
                                                                num1876 /= 2f;
                                                            }
                                                            this.ai[1] = 0f;
                                                            this.velocity.Y = this.velocity.Y - num1877;
                                                            this.velocity.X = num1876 * (float)this.direction;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.knockBackResist = 0f;
                                                        this.velocity.X = this.velocity.X * 0.99f;
                                                        if (this.direction < 0 && this.velocity.X > -1f)
                                                        {
                                                            this.velocity.X = -1f;
                                                        }
                                                        if (this.direction > 0 && this.velocity.X < 1f)
                                                        {
                                                            this.velocity.X = 1f;
                                                        }
                                                    }
                                                    this.ai[2] += 1f;
                                                    if ((double)this.ai[2] > 210.0 && this.velocity.Y == 0f && Main.netMode != 1)
                                                    {
                                                        int num1878 = Main.rand.Next(3);
                                                        if (num1878 == 0)
                                                        {
                                                            this.ai[0] = 3f;
                                                        }
                                                        else if (num1878 == 1)
                                                        {
                                                            this.ai[0] = 4f;
                                                            this.noTileCollide = true;
                                                            this.velocity.Y = -8f;
                                                        }
                                                        else if (num1878 == 2)
                                                        {
                                                            this.ai[0] = 6f;
                                                        }
                                                        else
                                                        {
                                                            this.ai[0] = 2f;
                                                        }
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 3f)
                                                {
                                                    this.velocity.X = this.velocity.X * 0.85f;
                                                    this.dontTakeDamage = true;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 180f)
                                                    {
                                                        this.ai[0] = 2f;
                                                        this.ai[1] = 0f;
                                                    }
                                                    if (Main.expertMode)
                                                    {
                                                        this.ReflectProjectiles(base.Hitbox);
                                                        this.reflectingProjectiles = true;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 4f)
                                                {
                                                    this.noTileCollide = true;
                                                    this.noGravity = true;
                                                    this.knockBackResist = 0f;
                                                    if (this.velocity.X < 0f)
                                                    {
                                                        this.direction = -1;
                                                    }
                                                    else
                                                    {
                                                        this.direction = 1;
                                                    }
                                                    this.spriteDirection = this.direction;
                                                    this.TargetClosest(true);
                                                    Vector2 center40 = Main.player[this.target].Center;
                                                    center40.Y -= 350f;
                                                    Vector2 vector269 = center40 - base.Center;
                                                    if (this.ai[2] == 1f)
                                                    {
                                                        this.ai[1] += 1f;
                                                        vector269 = Main.player[this.target].Center - base.Center;
                                                        vector269.Normalize();
                                                        vector269 *= 8f;
                                                        this.velocity = (this.velocity * 4f + vector269) / 5f;
                                                        if (this.ai[1] > 6f)
                                                        {
                                                            this.ai[1] = 0f;
                                                            this.ai[0] = 4.1f;
                                                            this.ai[2] = 0f;
                                                            this.velocity = vector269;
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) < 40f && base.Center.Y < Main.player[this.target].Center.Y - 300f)
                                                        {
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 1f;
                                                            return;
                                                        }
                                                        vector269.Normalize();
                                                        vector269 *= 12f;
                                                        this.velocity = (this.velocity * 5f + vector269) / 6f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 4.1f)
                                                {
                                                    this.knockBackResist = 0f;
                                                    if (this.ai[2] == 0f && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1) && !Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        this.ai[2] = 1f;
                                                    }
                                                    if (this.position.Y + (float)this.height >= Main.player[this.target].position.Y || this.velocity.Y <= 0f)
                                                    {
                                                        this.ai[1] += 1f;
                                                        if (this.ai[1] > 10f)
                                                        {
                                                            this.ai[0] = 2f;
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 0f;
                                                            this.ai[3] = 0f;
                                                            if (Collision.SolidCollision(this.position, this.width, this.height))
                                                            {
                                                                this.ai[0] = 5f;
                                                            }
                                                        }
                                                    }
                                                    else if (this.ai[2] == 0f)
                                                    {
                                                        this.noTileCollide = true;
                                                        this.noGravity = true;
                                                        this.knockBackResist = 0f;
                                                    }
                                                    this.velocity.Y = this.velocity.Y + 0.2f;
                                                    if (this.velocity.Y > 16f)
                                                    {
                                                        this.velocity.Y = 16f;
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.ai[0] == 5f)
                                                    {
                                                        if (this.velocity.X > 0f)
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        else
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        this.noTileCollide = true;
                                                        this.noGravity = true;
                                                        this.knockBackResist = 0f;
                                                        Vector2 value74 = Main.player[this.target].Center - base.Center;
                                                        value74.Y -= 4f;
                                                        if (value74.Length() < 200f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                        {
                                                            this.ai[0] = 2f;
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 0f;
                                                            this.ai[3] = 0f;
                                                        }
                                                        if (value74.Length() > 10f)
                                                        {
                                                            value74.Normalize();
                                                            value74 *= 10f;
                                                        }
                                                        this.velocity = (this.velocity * 4f + value74) / 5f;
                                                        return;
                                                    }
                                                    if (this.ai[0] == 6f)
                                                    {
                                                        this.knockBackResist = 0f;
                                                        if (this.velocity.Y == 0f)
                                                        {
                                                            this.TargetClosest(true);
                                                            this.velocity.X = this.velocity.X * 0.8f;
                                                            this.ai[1] += 1f;
                                                            if (this.ai[1] > 5f)
                                                            {
                                                                this.ai[1] = 0f;
                                                                this.velocity.Y = this.velocity.Y - 4f;
                                                                if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 1.25f;
                                                                }
                                                                if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 40f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 1.5f;
                                                                }
                                                                if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 80f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 1.75f;
                                                                }
                                                                if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 120f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 2f;
                                                                }
                                                                if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 160f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 2.25f;
                                                                }
                                                                if (Main.player[this.target].position.Y + (float)Main.player[this.target].height < base.Center.Y - 200f)
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 2.5f;
                                                                }
                                                                if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                                {
                                                                    this.velocity.Y = this.velocity.Y - 2f;
                                                                }
                                                                this.velocity.X = (float)(12 * this.direction);
                                                                this.ai[2] += 1f;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            this.velocity.X = this.velocity.X * 0.98f;
                                                            if (this.direction < 0 && this.velocity.X > -8f)
                                                            {
                                                                this.velocity.X = -8f;
                                                            }
                                                            if (this.direction > 0 && this.velocity.X < 8f)
                                                            {
                                                                this.velocity.X = 8f;
                                                            }
                                                        }
                                                        if (this.ai[2] >= 3f && this.velocity.Y == 0f)
                                                        {
                                                            this.ai[0] = 2f;
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 0f;
                                                            this.ai[3] = 0f;
                                                            return;
                                                        }
                                                    }
                                                    else if (this.ai[0] == 7f)
                                                    {
                                                        this.damage = 0;
                                                        this.life = this.lifeMax;
                                                        this.defense = 9999;
                                                        this.noTileCollide = true;
                                                        this.alpha += 7;
                                                        if (this.alpha > 255)
                                                        {
                                                            this.alpha = 255;
                                                        }
                                                        this.velocity.X = this.velocity.X * 0.98f;
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 88)
                                            {
                                                int num1879 = 7;
                                                this.noTileCollide = false;
                                                this.noGravity = true;
                                                this.knockBackResist = 0.2f * Main.expertKnockBack;
                                                this.damage = this.defDamage;
                                                if (!Main.eclipse)
                                                {
                                                    this.ai[0] = -1f;
                                                }
                                                else if (this.target < 0 || Main.player[this.target].dead || !Main.player[this.target].active)
                                                {
                                                    this.TargetClosest(true);
                                                    Vector2 vector270 = Main.player[this.target].Center - base.Center;
                                                    if (Main.player[this.target].dead || vector270.Length() > 3000f)
                                                    {
                                                        this.ai[0] = -1f;
                                                    }
                                                }
                                                else
                                                {
                                                    Vector2 vector271 = Main.player[this.target].Center - base.Center;
                                                    if (this.ai[0] > 1f && vector271.Length() > 1000f)
                                                    {
                                                        this.ai[0] = 1f;
                                                    }
                                                }
                                                if (this.ai[0] == -1f)
                                                {
                                                    Vector2 value75 = new Vector2(0f, -8f);
                                                    this.velocity = (this.velocity * 9f + value75) / 10f;
                                                    this.noTileCollide = true;
                                                    this.dontTakeDamage = true;
                                                    return;
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    if (base.Center.X < Main.player[this.target].Center.X - 2f)
                                                    {
                                                        this.direction = 1;
                                                    }
                                                    if (base.Center.X > Main.player[this.target].Center.X + 2f)
                                                    {
                                                        this.direction = -1;
                                                    }
                                                    this.spriteDirection = this.direction;
                                                    this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                    if (this.collideX)
                                                    {
                                                        this.velocity.X = this.velocity.X * (-this.oldVelocity.X * 0.5f);
                                                        if (this.velocity.X > 4f)
                                                        {
                                                            this.velocity.X = 4f;
                                                        }
                                                        if (this.velocity.X < -4f)
                                                        {
                                                            this.velocity.X = -4f;
                                                        }
                                                    }
                                                    if (this.collideY)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * (-this.oldVelocity.Y * 0.5f);
                                                        if (this.velocity.Y > 4f)
                                                        {
                                                            this.velocity.Y = 4f;
                                                        }
                                                        if (this.velocity.Y < -4f)
                                                        {
                                                            this.velocity.Y = -4f;
                                                        }
                                                    }
                                                    Vector2 value76 = Main.player[this.target].Center - base.Center;
                                                    value76.Y -= 200f;
                                                    if (value76.Length() > 800f)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                    }
                                                    else if (value76.Length() > 80f)
                                                    {
                                                        float scaleFactor29 = 6f;
                                                        float num1880 = 30f;
                                                        value76.Normalize();
                                                        value76 *= scaleFactor29;
                                                        this.velocity = (this.velocity * (num1880 - 1f) + value76) / num1880;
                                                    }
                                                    else if (this.velocity.Length() > 2f)
                                                    {
                                                        this.velocity *= 0.95f;
                                                    }
                                                    else if (this.velocity.Length() < 1f)
                                                    {
                                                        this.velocity *= 1.05f;
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.justHit)
                                                    {
                                                        this.ai[1] += (float)Main.rand.Next(10, 30);
                                                    }
                                                    if (this.ai[1] >= 180f && Main.netMode != 1)
                                                    {
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                        this.netUpdate = true;
                                                        while (this.ai[0] == 0f)
                                                        {
                                                            int num1881 = Main.rand.Next(3);
                                                            if (num1881 == 0 && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                            {
                                                                this.ai[0] = 2f;
                                                            }
                                                            else if (num1881 == 1)
                                                            {
                                                                this.ai[0] = 3f;
                                                            }
                                                            else if (num1881 == 2 && NPC.CountNPCS(478) + NPC.CountNPCS(479) < num1879)
                                                            {
                                                                this.ai[0] = 4f;
                                                            }
                                                        }
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.ai[0] == 1f)
                                                    {
                                                        this.collideX = false;
                                                        this.collideY = false;
                                                        this.noTileCollide = true;
                                                        this.knockBackResist = 0f;
                                                        if (this.target < 0 || !Main.player[this.target].active || Main.player[this.target].dead)
                                                        {
                                                            this.TargetClosest(true);
                                                        }
                                                        if (this.velocity.X < 0f)
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        else if (this.velocity.X > 0f)
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        this.rotation = (this.rotation * 9f + this.velocity.X * 0.08f) / 10f;
                                                        Vector2 value77 = Main.player[this.target].Center - base.Center;
                                                        if (value77.Length() < 300f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                        {
                                                            this.ai[0] = 0f;
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 0f;
                                                            this.ai[3] = 0f;
                                                        }
                                                        float scaleFactor30 = 7f + value77.Length() / 100f;
                                                        float num1882 = 25f;
                                                        value77.Normalize();
                                                        value77 *= scaleFactor30;
                                                        this.velocity = (this.velocity * (num1882 - 1f) + value77) / num1882;
                                                        return;
                                                    }
                                                    if (this.ai[0] == 2f)
                                                    {
                                                        this.damage = (int)((double)this.defDamage * 0.5);
                                                        this.knockBackResist = 0f;
                                                        if (this.target < 0 || !Main.player[this.target].active || Main.player[this.target].dead)
                                                        {
                                                            this.TargetClosest(true);
                                                            this.ai[0] = 0f;
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 0f;
                                                            this.ai[3] = 0f;
                                                        }
                                                        if (Main.player[this.target].Center.X - 10f < base.Center.X)
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        else if (Main.player[this.target].Center.X + 10f > base.Center.X)
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        this.rotation = (this.rotation * 4f + this.velocity.X * 0.1f) / 5f;
                                                        if (this.collideX)
                                                        {
                                                            this.velocity.X = this.velocity.X * (-this.oldVelocity.X * 0.5f);
                                                            if (this.velocity.X > 4f)
                                                            {
                                                                this.velocity.X = 4f;
                                                            }
                                                            if (this.velocity.X < -4f)
                                                            {
                                                                this.velocity.X = -4f;
                                                            }
                                                        }
                                                        if (this.collideY)
                                                        {
                                                            this.velocity.Y = this.velocity.Y * (-this.oldVelocity.Y * 0.5f);
                                                            if (this.velocity.Y > 4f)
                                                            {
                                                                this.velocity.Y = 4f;
                                                            }
                                                            if (this.velocity.Y < -4f)
                                                            {
                                                                this.velocity.Y = -4f;
                                                            }
                                                        }
                                                        Vector2 value78 = Main.player[this.target].Center - base.Center;
                                                        value78.Y -= 20f;
                                                        this.ai[2] += 0.0222222228f;
                                                        if (Main.expertMode)
                                                        {
                                                            this.ai[2] += 0.0166666675f;
                                                        }
                                                        float scaleFactor31 = 4f + this.ai[2] + value78.Length() / 120f;
                                                        float num1883 = 20f;
                                                        value78.Normalize();
                                                        value78 *= scaleFactor31;
                                                        this.velocity = (this.velocity * (num1883 - 1f) + value78) / num1883;
                                                        this.ai[1] += 1f;
                                                        if (this.ai[1] > 240f || !Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                        {
                                                            this.ai[0] = 0f;
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 0f;
                                                            this.ai[3] = 0f;
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (this.ai[0] == 3f)
                                                        {
                                                            this.knockBackResist = 0f;
                                                            this.noTileCollide = true;
                                                            if (this.velocity.X < 0f)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            else
                                                            {
                                                                this.direction = 1;
                                                            }
                                                            this.spriteDirection = this.direction;
                                                            this.rotation = (this.rotation * 4f + this.velocity.X * 0.07f) / 5f;
                                                            Vector2 value79 = Main.player[this.target].Center - base.Center;
                                                            value79.Y -= 12f;
                                                            if (base.Center.X > Main.player[this.target].Center.X)
                                                            {
                                                                value79.X += 400f;
                                                            }
                                                            else
                                                            {
                                                                value79.X -= 400f;
                                                            }
                                                            if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 350f && Math.Abs(base.Center.Y - Main.player[this.target].Center.Y) < 20f)
                                                            {
                                                                this.ai[0] = 3.1f;
                                                                this.ai[1] = 0f;
                                                            }
                                                            this.ai[1] += 0.0333333351f;
                                                            float scaleFactor32 = 8f + this.ai[1];
                                                            float num1884 = 4f;
                                                            value79.Normalize();
                                                            value79 *= scaleFactor32;
                                                            this.velocity = (this.velocity * (num1884 - 1f) + value79) / num1884;
                                                            return;
                                                        }
                                                        if (this.ai[0] == 3.1f)
                                                        {
                                                            this.knockBackResist = 0f;
                                                            this.noTileCollide = true;
                                                            this.rotation = (this.rotation * 4f + this.velocity.X * 0.07f) / 5f;
                                                            Vector2 vector272 = Main.player[this.target].Center - base.Center;
                                                            vector272.Y -= 12f;
                                                            float scaleFactor33 = 16f;
                                                            float num1885 = 8f;
                                                            vector272.Normalize();
                                                            vector272 *= scaleFactor33;
                                                            this.velocity = (this.velocity * (num1885 - 1f) + vector272) / num1885;
                                                            if (this.velocity.X < 0f)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            else
                                                            {
                                                                this.direction = 1;
                                                            }
                                                            this.spriteDirection = this.direction;
                                                            this.ai[1] += 1f;
                                                            if (this.ai[1] > 10f)
                                                            {
                                                                this.velocity = vector272;
                                                                if (this.velocity.X < 0f)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.ai[0] = 3.2f;
                                                                this.ai[1] = 0f;
                                                                this.ai[1] = (float)this.direction;
                                                                return;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (this.ai[0] == 3.2f)
                                                            {
                                                                this.damage = (int)((double)this.defDamage * 1.3);
                                                                this.collideX = false;
                                                                this.collideY = false;
                                                                this.knockBackResist = 0f;
                                                                this.noTileCollide = true;
                                                                this.ai[2] += 0.0333333351f;
                                                                this.velocity.X = (16f + this.ai[2]) * this.ai[1];
                                                                if ((this.ai[1] > 0f && base.Center.X > Main.player[this.target].Center.X + 260f) || (this.ai[1] < 0f && base.Center.X < Main.player[this.target].Center.X - 260f))
                                                                {
                                                                    if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                                    {
                                                                        this.ai[0] = 0f;
                                                                        this.ai[1] = 0f;
                                                                        this.ai[2] = 0f;
                                                                        this.ai[3] = 0f;
                                                                    }
                                                                    else if (Math.Abs(base.Center.X - Main.player[this.target].Center.X) > 800f)
                                                                    {
                                                                        this.ai[0] = 1f;
                                                                        this.ai[1] = 0f;
                                                                        this.ai[2] = 0f;
                                                                        this.ai[3] = 0f;
                                                                    }
                                                                }
                                                                this.rotation = (this.rotation * 4f + this.velocity.X * 0.07f) / 5f;
                                                                return;
                                                            }
                                                            if (this.ai[0] == 4f)
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.TargetClosest(true);
                                                                if (Main.netMode != 1)
                                                                {
                                                                    this.ai[1] = -1f;
                                                                    this.ai[2] = -1f;
                                                                    for (int num1886 = 0; num1886 < 1000; num1886++)
                                                                    {
                                                                        int num1887 = (int)Main.player[this.target].Center.X / 16;
                                                                        int num1888 = (int)Main.player[this.target].Center.Y / 16;
                                                                        int num1889 = 30 + num1886 / 50;
                                                                        int num1890 = 20 + num1886 / 75;
                                                                        num1887 += Main.rand.Next(-num1889, num1889 + 1);
                                                                        num1888 += Main.rand.Next(-num1890, num1890 + 1);
                                                                        if (!WorldGen.SolidTile(num1887, num1888))
                                                                        {
                                                                            while (!WorldGen.SolidTile(num1887, num1888) && (double)num1888 < Main.worldSurface)
                                                                            {
                                                                                num1888++;
                                                                            }
                                                                            if ((new Vector2((float)(num1887 * 16 + 8), (float)(num1888 * 16 + 8)) - Main.player[this.target].Center).Length() < 600f)
                                                                            {
                                                                                this.ai[0] = 4.1f;
                                                                                this.ai[1] = (float)num1887;
                                                                                this.ai[2] = (float)num1888;
                                                                                break;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                this.netUpdate = true;
                                                                return;
                                                            }
                                                            if (this.ai[0] == 4.1f)
                                                            {
                                                                if (this.velocity.X < -2f)
                                                                {
                                                                    this.direction = -1;
                                                                }
                                                                else if (this.velocity.X > 2f)
                                                                {
                                                                    this.direction = 1;
                                                                }
                                                                this.spriteDirection = this.direction;
                                                                this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                                this.noTileCollide = true;
                                                                int num1891 = (int)this.ai[1];
                                                                int num1892 = (int)this.ai[2];
                                                                float x2 = (float)(num1891 * 16 + 8);
                                                                float y2 = (float)(num1892 * 16 - 20);
                                                                Vector2 vector273 = new Vector2(x2, y2);
                                                                vector273 -= base.Center;
                                                                float num1893 = 6f + vector273.Length() / 150f;
                                                                if (num1893 > 10f)
                                                                {
                                                                    num1893 = 10f;
                                                                }
                                                                float num1894 = 10f;
                                                                if (vector273.Length() < 10f)
                                                                {
                                                                    this.ai[0] = 4.2f;
                                                                }
                                                                vector273.Normalize();
                                                                vector273 *= num1893;
                                                                this.velocity = (this.velocity * (num1894 - 1f) + vector273) / num1894;
                                                                return;
                                                            }
                                                            if (this.ai[0] == 4.2f)
                                                            {
                                                                this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                                this.knockBackResist = 0f;
                                                                this.noTileCollide = true;
                                                                int num1895 = (int)this.ai[1];
                                                                int num1896 = (int)this.ai[2];
                                                                float x3 = (float)(num1895 * 16 + 8);
                                                                float y3 = (float)(num1896 * 16 - 20);
                                                                Vector2 vector274 = new Vector2(x3, y3);
                                                                vector274 -= base.Center;
                                                                float num1897 = 4f;
                                                                float num1898 = 2f;
                                                                if (Main.netMode != 1 && vector274.Length() < 4f)
                                                                {
                                                                    int num1899 = 70;
                                                                    if (Main.expertMode)
                                                                    {
                                                                        num1899 = (int)((double)num1899 * 0.75);
                                                                    }
                                                                    this.ai[3] += 1f;
                                                                    if (this.ai[3] == (float)num1899)
                                                                    {
                                                                        NPC.NewNPC(num1895 * 16 + 8, num1896 * 16, 478, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                                    }
                                                                    else if (this.ai[3] == (float)(num1899 * 2))
                                                                    {
                                                                        this.ai[0] = 0f;
                                                                        this.ai[1] = 0f;
                                                                        this.ai[2] = 0f;
                                                                        this.ai[3] = 0f;
                                                                        if (NPC.CountNPCS(478) + NPC.CountNPCS(479) < num1879 && Main.rand.Next(3) != 0)
                                                                        {
                                                                            this.ai[0] = 4f;
                                                                        }
                                                                        else if (Collision.SolidCollision(this.position, this.width, this.height))
                                                                        {
                                                                            this.ai[0] = 1f;
                                                                        }
                                                                    }
                                                                }
                                                                if (vector274.Length() > num1897)
                                                                {
                                                                    vector274.Normalize();
                                                                    vector274 *= num1897;
                                                                }
                                                                this.velocity = (this.velocity * (num1898 - 1f) + vector274) / num1898;
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 89)
                                            {
                                                if (this.velocity.Y == 0f)
                                                {
                                                    this.velocity.X = this.velocity.X * 0.9f;
                                                    this.rotation += this.velocity.X * 0.02f;
                                                }
                                                else
                                                {
                                                    this.velocity.X = this.velocity.X * 0.99f;
                                                    this.rotation += this.velocity.X * 0.04f;
                                                }
                                                int num1900 = 900;
                                                if (Main.expertMode)
                                                {
                                                    num1900 = 600;
                                                }
                                                if (this.justHit)
                                                {
                                                    this.ai[0] -= (float)Main.rand.Next(10, 21);
                                                    if (!Main.expertMode)
                                                    {
                                                        this.ai[0] -= (float)Main.rand.Next(10, 21);
                                                    }
                                                }
                                                this.ai[0] += 1f;
                                                if (this.ai[0] >= (float)num1900)
                                                {
                                                    this.Transform(479);
                                                }
                                                if (Main.netMode != 1 && this.velocity.Y == 0f && (double)Math.Abs(this.velocity.X) < 0.2 && (double)this.ai[0] >= (double)num1900 * 0.75)
                                                {
                                                    float num1901 = this.ai[0] - (float)num1900 * 0.75f;
                                                    num1901 /= (float)num1900 * 0.25f;
                                                    if ((float)Main.rand.Next(-10, 120) < num1901 * 100f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - (float)Main.rand.Next(20, 40) * 0.025f;
                                                        this.velocity.X = this.velocity.X + (float)Main.rand.Next(-20, 20) * 0.025f;
                                                        this.velocity *= 1f + num1901 * 2f;
                                                        this.netUpdate = true;
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 90)
                                            {
                                                this.noTileCollide = false;
                                                this.knockBackResist = 0.4f * Main.knockBackMultiplier;
                                                this.noGravity = true;
                                                this.rotation = (this.rotation * 9f + this.velocity.X * 0.1f) / 10f;
                                                if (!Main.eclipse)
                                                {
                                                    if (this.timeLeft > 5)
                                                    {
                                                        this.timeLeft = 5;
                                                    }
                                                    this.velocity.Y = this.velocity.Y - 0.2f;
                                                    if (this.velocity.Y < -8f)
                                                    {
                                                        this.velocity.Y = -8f;
                                                    }
                                                    this.noTileCollide = true;
                                                    return;
                                                }
                                                if (this.ai[0] == 0f || this.ai[0] == 1f)
                                                {
                                                    for (int num1902 = 0; num1902 < 200; num1902++)
                                                    {
                                                        if (num1902 != this.whoAmI && Main.npc[num1902].active && Main.npc[num1902].type == this.type)
                                                        {
                                                            Vector2 value80 = Main.npc[num1902].Center - base.Center;
                                                            if (value80.Length() < (float)(this.width + this.height))
                                                            {
                                                                value80.Normalize();
                                                                value80 *= -0.1f;
                                                                this.velocity += value80;
                                                                Main.npc[num1902].velocity -= value80;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (this.target < 0 || Main.player[this.target].dead || !Main.player[this.target].active)
                                                {
                                                    this.TargetClosest(true);
                                                    Vector2 vector275 = Main.player[this.target].Center - base.Center;
                                                    if (Main.player[this.target].dead || vector275.Length() > 3000f)
                                                    {
                                                        this.ai[0] = -1f;
                                                    }
                                                }
                                                else
                                                {
                                                    Vector2 vector276 = Main.player[this.target].Center - base.Center;
                                                    if (this.ai[0] > 1f && vector276.Length() > 1000f)
                                                    {
                                                        this.ai[0] = 1f;
                                                    }
                                                }
                                                if (this.ai[0] == -1f)
                                                {
                                                    Vector2 value81 = new Vector2(0f, -8f);
                                                    this.velocity = (this.velocity * 9f + value81) / 10f;
                                                    this.noTileCollide = true;
                                                    this.dontTakeDamage = true;
                                                    return;
                                                }
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    this.spriteDirection = this.direction;
                                                    if (this.collideX)
                                                    {
                                                        this.velocity.X = this.velocity.X * (-this.oldVelocity.X * 0.5f);
                                                        if (this.velocity.X > 4f)
                                                        {
                                                            this.velocity.X = 4f;
                                                        }
                                                        if (this.velocity.X < -4f)
                                                        {
                                                            this.velocity.X = -4f;
                                                        }
                                                    }
                                                    if (this.collideY)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * (-this.oldVelocity.Y * 0.5f);
                                                        if (this.velocity.Y > 4f)
                                                        {
                                                            this.velocity.Y = 4f;
                                                        }
                                                        if (this.velocity.Y < -4f)
                                                        {
                                                            this.velocity.Y = -4f;
                                                        }
                                                    }
                                                    Vector2 value82 = Main.player[this.target].Center - base.Center;
                                                    if (value82.Length() > 800f)
                                                    {
                                                        this.ai[0] = 1f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                    }
                                                    else if (value82.Length() > 200f)
                                                    {
                                                        float scaleFactor34 = 5.5f + value82.Length() / 100f + this.ai[1] / 15f;
                                                        float num1903 = 40f;
                                                        value82.Normalize();
                                                        value82 *= scaleFactor34;
                                                        this.velocity = (this.velocity * (num1903 - 1f) + value82) / num1903;
                                                    }
                                                    else if (this.velocity.Length() > 2f)
                                                    {
                                                        this.velocity *= 0.95f;
                                                    }
                                                    else if (this.velocity.Length() < 1f)
                                                    {
                                                        this.velocity *= 1.05f;
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 90f)
                                                    {
                                                        this.ai[1] = 0f;
                                                        this.ai[0] = 2f;
                                                        return;
                                                    }
                                                }
                                                else
                                                {
                                                    if (this.ai[0] == 1f)
                                                    {
                                                        this.collideX = false;
                                                        this.collideY = false;
                                                        this.noTileCollide = true;
                                                        this.knockBackResist = 0f;
                                                        if (this.target < 0 || !Main.player[this.target].active || Main.player[this.target].dead)
                                                        {
                                                            this.TargetClosest(true);
                                                        }
                                                        if (this.velocity.X < 0f)
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        else if (this.velocity.X > 0f)
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        this.rotation = (this.rotation * 9f + this.velocity.X * 0.08f) / 10f;
                                                        Vector2 value83 = Main.player[this.target].Center - base.Center;
                                                        if (value83.Length() < 300f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                        {
                                                            this.ai[0] = 0f;
                                                            this.ai[1] = 0f;
                                                            this.ai[2] = 0f;
                                                            this.ai[3] = 0f;
                                                        }
                                                        this.ai[2] += 0.0166666675f;
                                                        float scaleFactor35 = 5.5f + this.ai[2] + value83.Length() / 150f;
                                                        float num1904 = 35f;
                                                        value83.Normalize();
                                                        value83 *= scaleFactor35;
                                                        this.velocity = (this.velocity * (num1904 - 1f) + value83) / num1904;
                                                        return;
                                                    }
                                                    if (this.ai[0] == 2f)
                                                    {
                                                        if (this.velocity.X < 0f)
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        else if (this.velocity.X > 0f)
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        this.rotation = (this.rotation * 7f + this.velocity.X * 0.1f) / 8f;
                                                        this.knockBackResist = 0f;
                                                        this.noTileCollide = true;
                                                        Vector2 vector277 = Main.player[this.target].Center - base.Center;
                                                        vector277.Y -= 8f;
                                                        float scaleFactor36 = 9f;
                                                        float num1905 = 8f;
                                                        vector277.Normalize();
                                                        vector277 *= scaleFactor36;
                                                        this.velocity = (this.velocity * (num1905 - 1f) + vector277) / num1905;
                                                        if (this.velocity.X < 0f)
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        else
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        this.ai[1] += 1f;
                                                        if (this.ai[1] > 10f)
                                                        {
                                                            this.velocity = vector277;
                                                            if (this.velocity.X < 0f)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            else
                                                            {
                                                                this.direction = 1;
                                                            }
                                                            this.ai[0] = 2.1f;
                                                            this.ai[1] = 0f;
                                                            return;
                                                        }
                                                    }
                                                    else if (this.ai[0] == 2.1f)
                                                    {
                                                        if (this.velocity.X < 0f)
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        else if (this.velocity.X > 0f)
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                        this.velocity *= 1.01f;
                                                        this.knockBackResist = 0f;
                                                        this.noTileCollide = true;
                                                        this.ai[1] += 1f;
                                                        int num1906 = 45;
                                                        if (this.ai[1] > (float)num1906)
                                                        {
                                                            if (!Collision.SolidCollision(this.position, this.width, this.height))
                                                            {
                                                                this.ai[0] = 0f;
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                return;
                                                            }
                                                            if (this.ai[1] > (float)(num1906 * 2))
                                                            {
                                                                this.ai[0] = 1f;
                                                                this.ai[1] = 0f;
                                                                this.ai[2] = 0f;
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 91)
                                            {
                                                this.noGravity = true;
                                                this.noTileCollide = false;
                                                this.dontTakeDamage = false;
                                                if (this.justHit && Main.netMode != 1 && Main.expertMode && Main.rand.Next(6) == 0)
                                                {
                                                    this.netUpdate = true;
                                                    this.ai[0] = -1f;
                                                    this.ai[1] = 0f;
                                                }
                                                if (this.ai[0] == -1f)
                                                {
                                                    this.dontTakeDamage = true;
                                                    this.noGravity = false;
                                                    this.velocity.X = this.velocity.X * 0.98f;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 120f)
                                                    {
                                                        this.ai[0] = (this.ai[1] = (this.ai[2] = (this.ai[3] = 0f)));
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 1f;
                                                        return;
                                                    }
                                                    Vector2 value84 = Main.player[this.target].Center - base.Center;
                                                    value84.Y -= (float)(Main.player[this.target].height / 4);
                                                    float num1907 = value84.Length();
                                                    if (num1907 > 800f)
                                                    {
                                                        this.ai[0] = 2f;
                                                        return;
                                                    }
                                                    Vector2 center41 = base.Center;
                                                    center41.X = Main.player[this.target].Center.X;
                                                    Vector2 vector278 = center41 - base.Center;
                                                    if (vector278.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center41, 1, 1))
                                                    {
                                                        this.ai[0] = 3f;
                                                        this.ai[1] = center41.X;
                                                        this.ai[2] = center41.Y;
                                                        Vector2 center42 = base.Center;
                                                        center42.Y = Main.player[this.target].Center.Y;
                                                        if (vector278.Length() > 8f && Collision.CanHit(base.Center, 1, 1, center42, 1, 1) && Collision.CanHit(center42, 1, 1, Main.player[this.target].position, 1, 1))
                                                        {
                                                            this.ai[0] = 3f;
                                                            this.ai[1] = center42.X;
                                                            this.ai[2] = center42.Y;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        center41 = base.Center;
                                                        center41.Y = Main.player[this.target].Center.Y;
                                                        if ((center41 - base.Center).Length() > 8f && Collision.CanHit(base.Center, 1, 1, center41, 1, 1))
                                                        {
                                                            this.ai[0] = 3f;
                                                            this.ai[1] = center41.X;
                                                            this.ai[2] = center41.Y;
                                                        }
                                                    }
                                                    if (this.ai[0] == 0f)
                                                    {
                                                        this.localAI[0] = 0f;
                                                        value84.Normalize();
                                                        value84 *= 0.5f;
                                                        this.velocity += value84;
                                                        this.ai[0] = 4f;
                                                        this.ai[1] = 0f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 1f)
                                                {
                                                    Vector2 value85 = Main.player[this.target].Center - base.Center;
                                                    float num1908 = value85.Length();
                                                    float num1909 = 2f;
                                                    num1909 += num1908 / 200f;
                                                    int num1910 = 50;
                                                    value85.Normalize();
                                                    value85 *= num1909;
                                                    this.velocity = (this.velocity * (float)(num1910 - 1) + value85) / (float)num1910;
                                                    if (!Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    this.noTileCollide = true;
                                                    Vector2 value86 = Main.player[this.target].Center - base.Center;
                                                    float num1911 = value86.Length();
                                                    float scaleFactor37 = 2f;
                                                    int num1912 = 4;
                                                    value86.Normalize();
                                                    value86 *= scaleFactor37;
                                                    this.velocity = (this.velocity * (float)(num1912 - 1) + value86) / (float)num1912;
                                                    if (num1911 < 600f && !Collision.SolidCollision(this.position, this.width, this.height))
                                                    {
                                                        this.ai[0] = 0f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 3f)
                                                {
                                                    Vector2 value87 = new Vector2(this.ai[1], this.ai[2]);
                                                    Vector2 value88 = value87 - base.Center;
                                                    float num1913 = value88.Length();
                                                    float num1914 = 1f;
                                                    float num1915 = 3f;
                                                    value88.Normalize();
                                                    value88 *= num1914;
                                                    this.velocity = (this.velocity * (num1915 - 1f) + value88) / num1915;
                                                    if (this.collideX || this.collideY)
                                                    {
                                                        this.ai[0] = 4f;
                                                        this.ai[1] = 0f;
                                                    }
                                                    if (num1913 < num1914 || num1913 > 800f || Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 0f;
                                                        return;
                                                    }
                                                }
                                                else if (this.ai[0] == 4f)
                                                {
                                                    if (this.collideX)
                                                    {
                                                        this.velocity.X = this.velocity.X * -0.8f;
                                                    }
                                                    if (this.collideY)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * -0.8f;
                                                    }
                                                    Vector2 value89;
                                                    if (this.velocity.X == 0f && this.velocity.Y == 0f)
                                                    {
                                                        value89 = Main.player[this.target].Center - base.Center;
                                                        value89.Y -= (float)(Main.player[this.target].height / 4);
                                                        value89.Normalize();
                                                        this.velocity = value89 * 0.1f;
                                                    }
                                                    float scaleFactor38 = 1.5f;
                                                    float num1916 = 20f;
                                                    value89 = this.velocity;
                                                    value89.Normalize();
                                                    value89 *= scaleFactor38;
                                                    this.velocity = (this.velocity * (num1916 - 1f) + value89) / num1916;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] > 180f)
                                                    {
                                                        this.ai[0] = 0f;
                                                        this.ai[1] = 0f;
                                                    }
                                                    if (Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1))
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                    this.localAI[0] += 1f;
                                                    if (this.localAI[0] >= 5f && !Collision.SolidCollision(this.position - new Vector2(10f, 10f), this.width + 20, this.height + 20))
                                                    {
                                                        this.localAI[0] = 0f;
                                                        Vector2 center43 = base.Center;
                                                        center43.X = Main.player[this.target].Center.X;
                                                        if (Collision.CanHit(base.Center, 1, 1, center43, 1, 1) && Collision.CanHit(base.Center, 1, 1, center43, 1, 1) && Collision.CanHit(Main.player[this.target].Center, 1, 1, center43, 1, 1))
                                                        {
                                                            this.ai[0] = 3f;
                                                            this.ai[1] = center43.X;
                                                            this.ai[2] = center43.Y;
                                                            return;
                                                        }
                                                        center43 = base.Center;
                                                        center43.Y = Main.player[this.target].Center.Y;
                                                        if (Collision.CanHit(base.Center, 1, 1, center43, 1, 1) && Collision.CanHit(Main.player[this.target].Center, 1, 1, center43, 1, 1))
                                                        {
                                                            this.ai[0] = 3f;
                                                            this.ai[1] = center43.X;
                                                            this.ai[2] = center43.Y;
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 92)
                                            {
                                                if (Main.rand.Next(20) == 0)
                                                {
                                                    this.soundHit = Main.rand.Next(15, 18);
                                                }
                                                if (Main.netMode != 1)
                                                {
                                                    bool flag176 = false;
                                                    int num1917 = (int)this.ai[0];
                                                    int num1918 = (int)this.ai[1];
                                                    if (!flag176 && (!Main.tile[num1917, num1918].active() || Main.tile[num1917, num1918].type != TileID.TargetDummy))
                                                    {
                                                        flag176 = true;
                                                    }
                                                    if (!flag176 && (this.target == 255 || Main.player[this.target].dead || Vector2.Distance(base.Center, Main.player[this.target].Center) > 160000f))
                                                    {
                                                        this.TargetClosest(false);
                                                        if (this.target == 255 || Main.player[this.target].dead || Vector2.Distance(base.Center, Main.player[this.target].Center) > 160000f)
                                                        {
                                                            flag176 = true;
                                                        }
                                                    }
                                                    if (flag176)
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 10.0);
                                                        this.active = false;
                                                        int num1919 = TETrainingDummy.Find((int)this.ai[0], (int)this.ai[1]);
                                                        if (num1919 != -1)
                                                        {
                                                            ((TETrainingDummy)TileEntity.ByID[num1919]).Deactivate();
                                                        }
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 93)
                                            {
                                                if (this.localAI[0] == 0f)
                                                {
                                                    this.localAI[0] = 1f;
                                                    for (int num1920 = 0; num1920 < 4; num1920++)
                                                    {
                                                        int num1921 = NPC.NewNPC((int)base.Center.X + num1920 * 40 - 150, (int)base.Center.Y, 492, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num1921].netUpdate = true;
                                                        Main.npc[num1921].ai[0] = (float)this.whoAmI;
                                                        Main.npc[num1921].ai[1] = (float)num1920;
                                                        Main.npc[num1921].ai[3] = (float)(60 * num1920);
                                                        Main.npc[num1921].TargetClosest(false);
                                                        Main.npc[num1921].timeLeft = 600;
                                                        this.ai[num1920] = (float)num1921;
                                                    }
                                                }
                                                bool flag177 = true;
                                                for (int num1922 = 0; num1922 < 4; num1922++)
                                                {
                                                    if (this.ai[num1922] >= 0f && (!Main.npc[(int)this.ai[num1922]].active || Main.npc[(int)this.ai[num1922]].type != 492))
                                                    {
                                                        this.ai[num1922] = -1f;
                                                        this.netUpdate = true;
                                                    }
                                                    else if (this.ai[num1922] >= 0f)
                                                    {
                                                        flag177 = false;
                                                    }
                                                }
                                                if (flag177)
                                                {
                                                    this.life = 0;
                                                    this.HitEffect(9999, 10.0);
                                                    this.checkDead();
                                                    return;
                                                }
                                                if (Main.netMode != 1 && Main.rand.Next(300) == 0)
                                                {
                                                    Vector2 value90 = new Vector2((Main.rand.NextFloat() - 0.5f) * (float)(this.width - 70), (Main.rand.NextFloat() - 0.5f) * 20f - (float)(this.height / 2) - 20f).RotatedBy((double)this.rotation, default(Vector2));
                                                    value90 += base.Center;
                                                    int num1923 = NPC.NewNPC((int)value90.X, (int)value90.Y, Utils.SelectRandom<int>(Main.rand, new int[]
                                                    {
                                                        213,
                                                        215,
                                                        214,
                                                        212
                                                    }), 0, 0f, 0f, 0f, 0f, 255);
                                                    Main.npc[num1923].velocity = new Vector2((Main.rand.NextFloat() - 0.5f) * 5f, -8.01f) + this.velocity;
                                                    Main.npc[num1923].netUpdate = true;
                                                    Main.npc[num1923].timeLeft = 600;
                                                }
                                                if ((this.localAI[3] += 1f) >= 64f)
                                                {
                                                    this.localAI[3] = 0f;
                                                }
                                                this.TargetClosest(true);
                                                int num1924 = (int)base.Center.X / 16 + Math.Sign(this.velocity.X) * 10;
                                                int num1925 = (int)(this.position.Y + (float)this.height) / 16;
                                                int num1926 = 0;
                                                bool flag178 = Main.tile[num1924, num1925].nactive() && Main.tileSolid[(int)Main.tile[num1924, num1925].type] && !Main.tileSolidTop[(int)Main.tile[num1924, num1925].type];
                                                if (flag178)
                                                {
                                                    num1926 = 1;
                                                }
                                                else
                                                {
                                                    while (num1926 < 150 && num1925 + num1926 < Main.maxTilesY)
                                                    {
                                                        int num1927 = num1925 + num1926;
                                                        bool flag179 = Main.tile[num1924, num1927].nactive() && Main.tileSolid[(int)Main.tile[num1924, num1927].type] && !Main.tileSolidTop[(int)Main.tile[num1924, num1927].type];
                                                        if (flag179)
                                                        {
                                                            num1926--;
                                                            break;
                                                        }
                                                        num1926++;
                                                    }
                                                }
                                                float num1928 = (float)(num1926 * 16);
                                                if (num1928 < 350f)
                                                {
                                                    float num1929 = num1928 - 350f;
                                                    if (num1929 < -4f)
                                                    {
                                                        num1929 = -4f;
                                                    }
                                                    this.velocity.Y = MathHelper.Lerp(this.velocity.Y, num1929, 0.05f);
                                                }
                                                else if (num1928 > 450f)
                                                {
                                                    float num1930 = num1928 - 350f;
                                                    if (num1930 > 4f)
                                                    {
                                                        num1930 = 4f;
                                                    }
                                                    this.velocity.Y = MathHelper.Lerp(this.velocity.Y, num1930, 0.05f);
                                                }
                                                else
                                                {
                                                    this.velocity.Y = this.velocity.Y * 0.95f;
                                                }
                                                float num1931 = Main.player[this.target].Center.X - base.Center.X;
                                                if (Math.Abs(num1931) >= 300f && (Math.Abs(this.velocity.X) < 6f || Math.Sign(this.velocity.X) != this.direction))
                                                {
                                                    this.velocity.X = this.velocity.X + (float)this.direction * 0.06f;
                                                }
                                                this.rotation = this.velocity.X * 0.025f;
                                                this.spriteDirection = -Math.Sign(this.velocity.X);
                                                return;
                                            }
                                            else if (this.aiStyle == 94)
                                            {
                                                int num75;
                                                if (this.ai[2] == 1f)
                                                {
                                                    this.velocity = Vector2.UnitY * this.velocity.Length();
                                                    if (this.velocity.Y < 0.25f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y + 0.02f;
                                                    }
                                                    if (this.velocity.Y > 0.25f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y - 0.02f;
                                                    }
                                                    this.dontTakeDamage = true;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] > 120f)
                                                    {
                                                        this.Opacity = 1f - (this.ai[1] - 120f) / 60f;
                                                    }
                                                    num75 = this.type;
                                                    if (this.ai[1] >= 180f)
                                                    {
                                                        this.life = 0;
                                                        this.HitEffect(0, 1337.0);
                                                        this.checkDead();
                                                    }
                                                    return;
                                                }
                                                if (this.ai[3] > 0f)
                                                {
                                                    bool flag180 = this.dontTakeDamage;
                                                    num75 = this.type;
                                                    if (num75 <= 493)
                                                    {
                                                        if (num75 != 422)
                                                        {
                                                            if (num75 == 493)
                                                            {
                                                                flag180 = (NPC.ShieldStrengthTowerStardust != 0);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            flag180 = (NPC.ShieldStrengthTowerVortex != 0);
                                                        }
                                                    }
                                                    else if (num75 != 507)
                                                    {
                                                        if (num75 == 517)
                                                        {
                                                            flag180 = (NPC.ShieldStrengthTowerSolar != 0);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        flag180 = (NPC.ShieldStrengthTowerNebula != 0);
                                                    }
                                                    this.ai[3] += 1f;
                                                    if (this.ai[3] > 120f)
                                                    {
                                                        this.ai[3] = 0f;
                                                    }
                                                }
                                                num75 = this.type;
                                                if (num75 <= 493)
                                                {
                                                    if (num75 != 422)
                                                    {
                                                        if (num75 == 493)
                                                        {
                                                            this.dontTakeDamage = (NPC.ShieldStrengthTowerStardust != 0);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.dontTakeDamage = (NPC.ShieldStrengthTowerVortex != 0);
                                                    }
                                                }
                                                else if (num75 != 507)
                                                {
                                                    if (num75 == 517)
                                                    {
                                                        this.dontTakeDamage = (NPC.ShieldStrengthTowerSolar != 0);
                                                    }
                                                }
                                                else
                                                {
                                                    this.dontTakeDamage = (NPC.ShieldStrengthTowerNebula != 0);
                                                }
                                                this.TargetClosest(false);
                                                if (Main.player[this.target].Distance(base.Center) > 2000f)
                                                {
                                                    this.localAI[0] += 1f;
                                                }
                                                if (this.localAI[0] >= 60f && Main.netMode != 1)
                                                {
                                                    this.localAI[0] = 0f;
                                                    this.netUpdate = true;
                                                    this.life = (int)MathHelper.Clamp((float)(this.life + 200), 0f, (float)this.lifeMax);
                                                }
                                                else
                                                {
                                                    this.localAI[0] = 0f;
                                                }
                                                this.velocity = new Vector2(0f, (float)Math.Sin((double)(6.28318548f * this.ai[0] / 300f)) * 0.5f);
                                                this.ai[0] += 1f;
                                                if (this.ai[0] >= 300f)
                                                {
                                                    this.ai[0] = 0f;
                                                    this.netUpdate = true;
                                                }
                                                if (this.type == NPCID.LunarTowerStardust)
                                                {
                                                    if (this.ai[1] > 0f)
                                                    {
                                                        this.ai[1] -= 1f;
                                                    }
                                                    if (Main.netMode != 1 && this.ai[1] <= 0f && Main.player[this.target].active && !Main.player[this.target].dead && base.Distance(Main.player[this.target].Center) < 1080f && Main.player[this.target].position.Y - this.position.Y < 400f)
                                                    {
                                                        List<int> list10 = new List<int>();
                                                        if (NPC.CountNPCS(405) + NPC.CountNPCS(406) < 2)
                                                        {
                                                            list10.Add(405);
                                                        }
                                                        if (NPC.CountNPCS(402) < 2)
                                                        {
                                                            list10.Add(402);
                                                        }
                                                        if (NPC.CountNPCS(407) < 1)
                                                        {
                                                            list10.Add(407);
                                                        }
                                                        if (list10.Count > 0)
                                                        {
                                                            int num1940 = Utils.SelectRandom<int>(Main.rand, list10.ToArray());
                                                            this.ai[1] = (float)(30 * Main.rand.Next(5, 16));
                                                            int num1941 = Main.rand.Next(3, 6);
                                                            int num1942 = Main.rand.Next(0, 4);
                                                            int num1943 = 0;
                                                            List<Tuple<Vector2, int, int>> list11 = new List<Tuple<Vector2, int, int>>();
                                                            List<Vector2> list12 = new List<Vector2>();
                                                            list11.Add(Tuple.Create<Vector2, int, int>(base.Top - Vector2.UnitY * 120f, num1941, 0));
                                                            int num1944 = 0;
                                                            int num1945 = list11.Count;
                                                            while (list11.Count > 0)
                                                            {
                                                                Vector2 item = list11[0].Item1;
                                                                int num1946 = 1;
                                                                int num1947 = 1;
                                                                if (num1944 > 0 && num1942 > 0 && (Main.rand.Next(3) != 0 || num1944 == 1))
                                                                {
                                                                    num1947 = Main.rand.Next(Math.Max(1, list11[0].Item2));
                                                                    num1946++;
                                                                    num1942--;
                                                                }
                                                                for (int num1948 = 0; num1948 < num1946; num1948++)
                                                                {
                                                                    int num1949 = list11[0].Item3;
                                                                    if (num1944 == 0)
                                                                    {
                                                                        num1949 = Utils.SelectRandom<int>(Main.rand, new int[]
                                                                        {
                                                                            -1,
                                                                            1
                                                                        });
                                                                    }
                                                                    else if (num1948 == 1)
                                                                    {
                                                                        num1949 *= -1;
                                                                    }
                                                                    float num1950 = ((num1944 % 2 == 0) ? 0f : 3.14159274f) + (0.5f - Main.rand.NextFloat()) * 0.7853982f + (float)num1949 * 0.7853982f * (float)(num1944 % 2 == 0).ToDirectionInt();
                                                                    float scaleFactor39 = 100f + 50f * Main.rand.NextFloat();
                                                                    int num1951 = list11[0].Item2;
                                                                    if (num1948 != 0)
                                                                    {
                                                                        num1951 = num1947;
                                                                    }
                                                                    if (num1944 == 0)
                                                                    {
                                                                        num1950 = (0.5f - Main.rand.NextFloat()) * 0.7853982f;
                                                                        scaleFactor39 = 100f + 100f * Main.rand.NextFloat();
                                                                    }
                                                                    Vector2 value92 = (-Vector2.UnitY).RotatedBy((double)num1950, default(Vector2)) * scaleFactor39;
                                                                    if (num1951 - 1 < 0)
                                                                    {
                                                                        value92 = Vector2.Zero;
                                                                    }
                                                                    num1943 = Projectile.NewProjectile(item.X, item.Y, value92.X, value92.Y, 540, 0, 0f, Main.myPlayer, (float)(-(float)num1944) * 10f, 0.5f + Main.rand.NextFloat() * 0.5f);
                                                                    list12.Add(item + value92);
                                                                    if (num1944 < num1941 && list11[0].Item2 > 0)
                                                                    {
                                                                        list11.Add(Tuple.Create<Vector2, int, int>(item + value92, num1951 - 1, num1949));
                                                                    }
                                                                }
                                                                list11.Remove(list11[0]);
                                                                if (--num1945 == 0)
                                                                {
                                                                    num1945 = list11.Count;
                                                                    num1944++;
                                                                }
                                                            }
                                                            Main.projectile[num1943].localAI[0] = (float)num1940;
                                                        }
                                                        else
                                                        {
                                                            this.ai[1] = 30f;
                                                        }
                                                    }
                                                }
                                                if (this.type == NPCID.LunarTowerVortex)
                                                {
                                                    if (this.ai[1] > 0f)
                                                    {
                                                        this.ai[1] -= 1f;
                                                    }
                                                    if (Main.netMode != 1 && this.ai[1] <= 0f && Main.player[this.target].active && !Main.player[this.target].dead && base.Distance(Main.player[this.target].Center) < 3240f && !Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                                                    {
                                                        this.ai[1] = (float)(60 + Main.rand.Next(120));
                                                        Point point13 = Main.player[this.target].Top.ToTileCoordinates();
                                                        bool flag181 = NPC.CountNPCS(427) + NPC.CountNPCS(426) < 14;
                                                        int num1954 = 0;
                                                        while (num1954 < 10 && !WorldGen.SolidTile(point13.X, point13.Y) && point13.Y > 10)
                                                        {
                                                            point13.Y--;
                                                            num1954++;
                                                        }
                                                        if (flag181)
                                                        {
                                                            Projectile.NewProjectile((float)(point13.X * 16 + 8), (float)(point13.Y * 16 + 24), 0f, 0f, 579, 0, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                        else
                                                        {
                                                            Projectile.NewProjectile((float)(point13.X * 16 + 8), (float)(point13.Y * 16 + 17), 0f, 0f, 578, 0, 1f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                    if (Main.netMode != 1 && this.ai[1] <= 0f && Main.player[this.target].active && !Main.player[this.target].dead && base.Distance(Main.player[this.target].Center) < 1080f && Main.player[this.target].position.Y - this.position.Y < 400f)
                                                    {
                                                        bool flag182 = NPC.CountNPCS(427) + NPC.CountNPCS(426) * 3 + NPC.CountNPCS(428) < 20;
                                                        if (flag182)
                                                        {
                                                            this.ai[1] = (float)(420 + Main.rand.Next(360));
                                                            Point point14 = base.Center.ToTileCoordinates();
                                                            Point point15 = Main.player[this.target].Center.ToTileCoordinates();
                                                            Vector2 vector279 = Main.player[this.target].Center - base.Center;
                                                            int num1955 = 20;
                                                            int num1956 = 3;
                                                            int num1957 = 8;
                                                            int num1958 = 2;
                                                            int num1959 = 0;
                                                            bool flag183 = false;
                                                            if (vector279.Length() > 2000f)
                                                            {
                                                                flag183 = true;
                                                            }
                                                            while (!flag183 && num1959 < 100)
                                                            {
                                                                num1959++;
                                                                int num1960 = Main.rand.Next(point15.X - num1955, point15.X + num1955 + 1);
                                                                int num1961 = Main.rand.Next(point15.Y - num1955, point15.Y + num1955 + 1);
                                                                if ((num1961 < point15.Y - num1957 || num1961 > point15.Y + num1957 || num1960 < point15.X - num1957 || num1960 > point15.X + num1957) && (num1961 < point14.Y - num1956 || num1961 > point14.Y + num1956 || num1960 < point14.X - num1956 || num1960 > point14.X + num1956) && !Main.tile[num1960, num1961].nactive())
                                                                {
                                                                    bool flag184 = true;
                                                                    if (flag184 && Main.tile[num1960, num1961].lava())
                                                                    {
                                                                        flag184 = false;
                                                                    }
                                                                    if (flag184 && Collision.SolidTiles(num1960 - num1958, num1960 + num1958, num1961 - num1958, num1961 + num1958))
                                                                    {
                                                                        flag184 = false;
                                                                    }
                                                                    if (flag184 && !Collision.CanHitLine(base.Center, 0, 0, Main.player[this.target].Center, 0, 0))
                                                                    {
                                                                        flag184 = false;
                                                                    }
                                                                    if (flag184)
                                                                    {
                                                                        Projectile.NewProjectile((float)(num1960 * 16 + 8), (float)(num1961 * 16 + 8), 0f, 0f, 579, 0, 0f, Main.myPlayer, 0f, 0f);
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                if (this.type == NPCID.LunarTowerSolar)
                                                {
                                                    if (this.ai[1] > 0f)
                                                    {
                                                        this.ai[1] -= 1f;
                                                    }
                                                    if (Main.netMode != 1 && this.ai[1] <= 0f && Main.player[this.target].active && !Main.player[this.target].dead && base.Distance(Main.player[this.target].Center) < 1080f && Main.player[this.target].position.Y - this.position.Y < 700f)
                                                    {
                                                        Vector2 vector280 = base.Top + new Vector2((float)(-(float)this.width) * 0.33f, -20f) + new Vector2((float)this.width * 0.66f, 20f) * Utils.RandomVector2(Main.rand, 0f, 1f);
                                                        Vector2 velocity10 = -Vector2.UnitY.RotatedByRandom(0.78539818525314331) * (7f + Main.rand.NextFloat() * 5f);
                                                        int num1963 = NPC.NewNPC((int)vector280.X, (int)vector280.Y, 519, this.whoAmI, 0f, 0f, 0f, 0f, 255);
                                                        Main.npc[num1963].velocity = velocity10;
                                                        Main.npc[num1963].netUpdate = true;
                                                        this.ai[1] = 60f;
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 95)
                                            {
                                                float num1964 = 300f;
                                                if (this.velocity.Length() > 4f)
                                                {
                                                    this.velocity *= 0.95f;
                                                }
                                                this.velocity *= 0.99f;
                                                this.ai[0] += 1f;
                                                this.scale = 1f + 0.3f * (this.ai[0] / num1964);
                                                if (this.ai[0] >= num1964)
                                                {
                                                    if (Main.netMode != 1)
                                                    {
                                                        this.Transform(405);
                                                    }
                                                    return;
                                                }
                                                this.rotation += this.velocity.X * 0.1f;
                                                if (this.ai[0] > 20f)
                                                {
                                                    return;
                                                }
                                            }
                                            else if (this.aiStyle == 96)
                                            {
                                                float num1970 = 5f;
                                                float moveSpeed = 0.15f;
                                                this.TargetClosest(true);
                                                Vector2 desiredVelocity4 = Main.player[this.target].Center - base.Center + new Vector2(0f, -250f);
                                                float num1971 = desiredVelocity4.Length();
                                                if (num1971 < 20f)
                                                {
                                                    desiredVelocity4 = this.velocity;
                                                }
                                                else if (num1971 < 40f)
                                                {
                                                    desiredVelocity4.Normalize();
                                                    desiredVelocity4 *= num1970 * 0.35f;
                                                }
                                                else if (num1971 < 80f)
                                                {
                                                    desiredVelocity4.Normalize();
                                                    desiredVelocity4 *= num1970 * 0.65f;
                                                }
                                                else
                                                {
                                                    desiredVelocity4.Normalize();
                                                    desiredVelocity4 *= num1970;
                                                }
                                                this.SimpleFlyMovement(desiredVelocity4, moveSpeed);
                                                this.rotation = this.velocity.X * 0.1f;
                                                if ((this.ai[0] += 1f) >= 70f)
                                                {
                                                    this.ai[0] = 0f;
                                                    if (Main.netMode != 1)
                                                    {
                                                        Vector2 vector282 = Vector2.Zero;
                                                        while (Math.Abs(vector282.X) < 1.5f)
                                                        {
                                                            vector282 = Vector2.UnitY.RotatedByRandom(1.5707963705062866) * new Vector2(5f, 3f);
                                                        }
                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, vector282.X, vector282.Y, 539, 60, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 97)
                                            {
                                                float num1972 = 7f;
                                                int num1973 = 480;
                                                if (this.localAI[2] < 180f)
                                                {
                                                    this.localAI[2] += 1f;
                                                    if (Main.netMode != 1 && this.localAI[2] % 60f == 0f)
                                                    {
                                                        Vector2 vector283 = Vector2.Zero;
                                                        while (Math.Abs(vector283.X) < 1.5f)
                                                        {
                                                            vector283 = Vector2.UnitY.RotatedByRandom(1.5707963705062866) * new Vector2(4f, 2.5f);
                                                        }
                                                        Projectile.NewProjectile(base.Center.X, base.Center.Y, vector283.X, vector283.Y, 574, 0, 0f, Main.myPlayer, 0f, (float)this.whoAmI);
                                                    }
                                                }
                                                if (this.localAI[1] == 1f)
                                                {
                                                    this.localAI[1] = 0f;
                                                    if (Main.rand.Next(4) == 0)
                                                    {
                                                        this.ai[0] = (float)num1973;
                                                    }
                                                }
                                                this.TargetClosest(true);
                                                this.rotation = Math.Abs(this.velocity.X) * (float)this.direction * 0.1f;
                                                this.spriteDirection = -this.direction;
                                                Vector2 value93 = base.Center + new Vector2((float)(this.direction * 20), 6f);
                                                Vector2 vector284 = Main.player[this.target].Center - value93;
                                                bool flag185 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].Center, 1, 1);
                                                bool flag186 = false;
                                                if (vector284.Length() > 400f || !flag185)
                                                {
                                                    Vector2 value94 = vector284;
                                                    if (value94.Length() > num1972)
                                                    {
                                                        value94.Normalize();
                                                        value94 *= num1972;
                                                    }
                                                    int num1974 = 30;
                                                    this.velocity = (this.velocity * (float)(num1974 - 1) + value94) / (float)num1974;
                                                }
                                                else
                                                {
                                                    this.velocity *= 0.98f;
                                                    flag186 = true;
                                                }
                                                if (this.ai[2] != 0f && this.ai[3] != 0f)
                                                {
                                                    base.Center = new Vector2(this.ai[2] * 16f, this.ai[3] * 16f);
                                                    this.velocity = Vector2.Zero;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = 0f;
                                                }
                                                this.ai[0] += 1f;
                                                if (this.ai[0] >= (float)num1973 && Main.netMode != 1)
                                                {
                                                    this.ai[0] = 0f;
                                                    Point point16 = base.Center.ToTileCoordinates();
                                                    Point point17 = Main.player[this.target].Center.ToTileCoordinates();
                                                    int num1979 = 20;
                                                    int num1980 = 3;
                                                    int num1981 = 10;
                                                    int num1982 = 1;
                                                    int num1983 = 0;
                                                    bool flag187 = false;
                                                    if (vector284.Length() > 2000f)
                                                    {
                                                        flag187 = true;
                                                    }
                                                    while (!flag187 && num1983 < 100)
                                                    {
                                                        num1983++;
                                                        int num1984 = Main.rand.Next(point17.X - num1979, point17.X + num1979 + 1);
                                                        int num1985 = Main.rand.Next(point17.Y - num1979, point17.Y + num1979 + 1);
                                                        if ((num1985 < point17.Y - num1981 || num1985 > point17.Y + num1981 || num1984 < point17.X - num1981 || num1984 > point17.X + num1981) && (num1985 < point16.Y - num1980 || num1985 > point16.Y + num1980 || num1984 < point16.X - num1980 || num1984 > point16.X + num1980) && !Main.tile[num1984, num1985].nactive())
                                                        {
                                                            bool flag188 = true;
                                                            if (flag188 && Main.tile[num1984, num1985].lava())
                                                            {
                                                                flag188 = false;
                                                            }
                                                            if (flag188 && Collision.SolidTiles(num1984 - num1982, num1984 + num1982, num1985 - num1982, num1985 + num1982))
                                                            {
                                                                flag188 = false;
                                                            }
                                                            if (flag188)
                                                            {
                                                                this.ai[1] = 20f;
                                                                this.ai[2] = (float)num1984;
                                                                this.ai[3] = (float)num1985;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    this.netUpdate = true;
                                                }
                                                if (flag186 && this.velocity.Length() < 2f && Main.netMode != 1)
                                                {
                                                    this.localAI[0] += 1f;
                                                    if (this.localAI[0] >= 13f)
                                                    {
                                                        return;
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 98)
                                            {
                                                this.noTileCollide = false;
                                                if (this.ai[0] == 0f)
                                                {
                                                    this.TargetClosest(true);
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = 0f;
                                                    this.ai[2] = 0f;
                                                    this.ai[3] = 0f;
                                                }
                                                bool flag189 = Collision.CanHit(base.Center, 1, 1, Main.player[this.target].position, 1, 1);
                                                bool flag190 = true;
                                                if (!flag189 || Main.player[this.target].dead)
                                                {
                                                    flag190 = false;
                                                }
                                                else
                                                {
                                                    int num1986 = (int)(Main.player[this.target].Center.X / 16f);
                                                    int num1987 = (int)(Main.player[this.target].Center.Y / 16f);
                                                    for (int num1988 = num1986 - 2; num1988 <= num1986 + 2; num1988++)
                                                    {
                                                        for (int num1989 = num1987; num1989 <= num1987 + 25; num1989++)
                                                        {
                                                            if (WorldGen.SolidTile2(num1988, num1989))
                                                            {
                                                                flag190 = false;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (this.ai[0] < 0f)
                                                {
                                                    Vector2 vector285 = Main.player[this.target].Center - base.Center;
                                                    float num1990 = vector285.Length();
                                                    if (this.ai[0] == -1f)
                                                    {
                                                        vector285.Normalize();
                                                        if (vector285.HasNaNs())
                                                        {
                                                            vector285 = new Vector2((float)this.direction, 0f);
                                                        }
                                                        float num1991 = 8f + num1990 / 100f;
                                                        float num1992 = 12f;
                                                        if (Main.player[this.target].velocity.Length() > num1992)
                                                        {
                                                            num1992 = Main.player[this.target].velocity.Length();
                                                        }
                                                        if (num1991 > num1992)
                                                        {
                                                            num1991 = num1992;
                                                        }
                                                        vector285 *= num1991;
                                                        float num1993 = 10f;
                                                        this.velocity = (this.velocity * (num1993 - 1f) + vector285) / num1993;
                                                        for (int num1994 = 0; num1994 < 200; num1994++)
                                                        {
                                                            if (Main.npc[num1994].active && Main.npc[num1994].type == this.type && num1994 != this.whoAmI)
                                                            {
                                                                Vector2 value95 = Main.npc[num1994].Center - base.Center;
                                                                if (value95.Length() < 40f)
                                                                {
                                                                    value95.Normalize();
                                                                    value95 *= 1f;
                                                                    this.velocity -= value95;
                                                                }
                                                            }
                                                        }
                                                        this.rotation += this.velocity.X * 0.03f;
                                                        if ((double)this.rotation < -6.2831)
                                                        {
                                                            this.rotation += 6.2831f;
                                                        }
                                                        if ((double)this.rotation > 6.2831)
                                                        {
                                                            this.rotation -= 6.2831f;
                                                        }
                                                        if (this.velocity.X > 0f)
                                                        {
                                                            this.direction = 1;
                                                        }
                                                        else if (this.velocity.X < 0f)
                                                        {
                                                            this.direction = -1;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                    }
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 60f && !flag190)
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                }
                                                else if (this.ai[0] == 2f)
                                                {
                                                    this.rotation *= 0.92f;
                                                    if ((double)Math.Abs(this.rotation) < 0.02)
                                                    {
                                                        this.rotation = 0f;
                                                    }
                                                    int num1995 = 300;
                                                    float num1996 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                                    if (num1996 < (float)num1995 && Collision.CanHit(base.Center, 1, 1, Main.player[this.target].position, 1, 1))
                                                    {
                                                        this.velocity.X = this.velocity.X * 0.96f;
                                                        this.velocity.Y = this.velocity.Y * 0.96f;
                                                        this.ai[1] += 1f;
                                                        if (this.ai[1] == 20f)
                                                        {
                                                            if (Main.netMode != 1)
                                                            {
                                                                NPC.NewNPC((int)base.Center.X, (int)base.Center.Y + 26, 516, 0, 0f, 0f, 0f, 0f, this.target);
                                                            }
                                                        }
                                                        else if (this.ai[1] >= 30f)
                                                        {
                                                            this.ai[1] = 0f;
                                                        }
                                                        for (int num1997 = 0; num1997 < 200; num1997++)
                                                        {
                                                            if (Main.npc[num1997].active && Main.npc[num1997].type == this.type && num1997 != this.whoAmI)
                                                            {
                                                                Vector2 value96 = Main.npc[num1997].Center - base.Center;
                                                                if (value96.Length() < 100f)
                                                                {
                                                                    value96.Normalize();
                                                                    value96 *= 0.1f;
                                                                    this.velocity -= value96;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.ai[0] = 0f;
                                                    }
                                                    if (Main.player[this.target].Center.X < base.Center.X)
                                                    {
                                                        this.direction = -1;
                                                    }
                                                    else if (Main.player[this.target].Center.X > base.Center.X)
                                                    {
                                                        this.direction = 1;
                                                    }
                                                    this.spriteDirection = this.direction;
                                                }
                                                if (this.ai[0] == 1f)
                                                {
                                                    this.rotation *= 0.92f;
                                                    if ((double)Math.Abs(this.rotation) < 0.02)
                                                    {
                                                        this.rotation = 0f;
                                                    }
                                                    if (flag190)
                                                    {
                                                        this.ai[0] = -1f;
                                                        this.ai[1] = 0f;
                                                        this.ai[2] = 0f;
                                                        this.ai[3] = 0f;
                                                    }
                                                    int num1998 = 300;
                                                    for (int num1999 = 0; num1999 < 200; num1999++)
                                                    {
                                                        if (Main.npc[num1999].active && Main.npc[num1999].type == this.type && num1999 != this.whoAmI)
                                                        {
                                                            Vector2 value97 = Main.npc[num1999].Center - base.Center;
                                                            if (value97.Length() < 50f)
                                                            {
                                                                value97.Normalize();
                                                                value97 *= 0.1f;
                                                                this.velocity -= value97;
                                                                this.velocity.X = this.velocity.X - value97.X * 1f;
                                                            }
                                                        }
                                                    }
                                                    int num2000 = 800;
                                                    float num2001 = Math.Abs(base.Center.X - Main.player[this.target].Center.X);
                                                    if (num2001 < (float)num1998 && flag189)
                                                    {
                                                        this.ai[0] = 2f;
                                                        this.ai[1] = 0f;
                                                    }
                                                    else
                                                    {
                                                        if (this.collideX)
                                                        {
                                                            this.velocity.X = this.velocity.X * -0.5f;
                                                            this.ai[1] = 60f;
                                                            this.direction *= -1;
                                                        }
                                                        if (this.ai[1] > 0f)
                                                        {
                                                            this.ai[1] -= 1f;
                                                        }
                                                        else if (flag189)
                                                        {
                                                            if (base.Center.X > Main.player[this.target].Center.X)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            else
                                                            {
                                                                this.direction = 1;
                                                            }
                                                        }
                                                        else if (num2001 > (float)num2000)
                                                        {
                                                            if (base.Center.X > Main.player[this.target].Center.X)
                                                            {
                                                                this.direction = -1;
                                                            }
                                                            else
                                                            {
                                                                this.direction = 1;
                                                            }
                                                        }
                                                        float num2002 = 2f;
                                                        float num2003 = 0.1f;
                                                        if (this.velocity.X > num2002 || this.velocity.X < -num2002)
                                                        {
                                                            if (Math.Abs(this.velocity.X) < num2002 + num2003 * 2f)
                                                            {
                                                                if (this.velocity.X < 0f)
                                                                {
                                                                    this.velocity.X = -num2002;
                                                                }
                                                                else
                                                                {
                                                                    this.velocity.X = num2002;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                this.velocity.X = this.velocity.X * 0.99f;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            this.velocity.X = this.velocity.X + (float)this.direction * num2003;
                                                        }
                                                        this.spriteDirection = this.direction;
                                                    }
                                                    if (this.collideY)
                                                    {
                                                        this.ai[2] = 60f;
                                                        this.directionY *= -1;
                                                        this.velocity.Y = this.velocity.Y * -0.5f;
                                                    }
                                                    if (this.ai[2] > 0f)
                                                    {
                                                        this.ai[2] -= 1f;
                                                    }
                                                    else
                                                    {
                                                        int num2004 = (int)(base.Center.Y / 16f);
                                                        int num2005 = (int)((base.Center.X - 8f) / 16f);
                                                        int num2006 = 30;
                                                        int num2007 = 15;
                                                        int num2008 = 0;
                                                        for (int num2009 = num2004; num2009 < num2004 + num2006; num2009++)
                                                        {
                                                            for (int num2010 = num2005; num2010 <= num2005 + 1; num2010++)
                                                            {
                                                                if (WorldGen.SolidTile(num2010, num2009) || Main.tile[num2010, num2009].liquid > 0)
                                                                {
                                                                    num2008 = num2009 - num2004;
                                                                    break;
                                                                }
                                                            }
                                                            if (num2008 != 0)
                                                            {
                                                                break;
                                                            }
                                                        }
                                                        if (num2008 == 0)
                                                        {
                                                            this.directionY = 1;
                                                        }
                                                        else if (num2008 < num2007)
                                                        {
                                                            this.directionY = -1;
                                                        }
                                                    }
                                                    float num2011 = 2f;
                                                    float num2012 = 0.1f;
                                                    if (this.velocity.Y <= num2011 && this.velocity.Y >= -num2011)
                                                    {
                                                        this.velocity.Y = this.velocity.Y + (float)this.directionY * num2012;
                                                        return;
                                                    }
                                                    if (Math.Abs(this.velocity.Y) >= num2011 + num2012 * 2f)
                                                    {
                                                        this.velocity.Y = this.velocity.Y * 0.99f;
                                                        return;
                                                    }
                                                    if (this.velocity.Y < 0f)
                                                    {
                                                        this.velocity.Y = -num2011;
                                                        return;
                                                    }
                                                    this.velocity.Y = num2011;
                                                    return;
                                                }
                                            }
                                            else if (this.aiStyle == 99)
                                            {
                                                if (this.velocity.Y == 0f && this.ai[0] == 0f)
                                                {
                                                    this.ai[0] = 1f;
                                                    this.ai[1] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                                if (this.ai[0] == 1f)
                                                {
                                                    this.velocity = Vector2.Zero;
                                                    this.position = this.oldPosition;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 5f)
                                                    {
                                                        this.HitEffect(0, 9999.0);
                                                        this.active = false;
                                                    }
                                                    return;
                                                }
                                                this.velocity.Y = this.velocity.Y + 0.2f;
                                                if (this.velocity.Y > 12f)
                                                {
                                                    this.velocity.Y = 12f;
                                                }
                                                this.rotation = this.velocity.ToRotation() - 1.57079637f;
                                                if (this.type == NPCID.SolarGoop)
                                                {
                                                    if (this.localAI[0] == 0f)
                                                    {
                                                        this.localAI[0] = 1f;
                                                    }
                                                    return;
                                                }
                                            }
                                            else if (this.aiStyle == 100)
                                            {
                                                if (this.velocity.Y == 0f && this.ai[0] >= 0f)
                                                {
                                                    this.ai[0] = -1f;
                                                    this.ai[1] = 0f;
                                                    this.netUpdate = true;
                                                    return;
                                                }
                                                if (this.ai[0] == -1f)
                                                {
                                                    this.velocity = Vector2.Zero;
                                                    this.position = this.oldPosition;
                                                    this.ai[1] += 1f;
                                                    if (this.ai[1] >= 5f)
                                                    {
                                                        this.HitEffect(0, 9999.0);
                                                        this.active = false;
                                                    }
                                                    return;
                                                }
                                                this.rotation = this.velocity.ToRotation() - 1.57079637f;
                                                if (this.type == NPCID.AncientLight)
                                                {
                                                    if (this.localAI[0] == 0f)
                                                    {
                                                        this.localAI[0] = 1f;
                                                        this.velocity.X = this.ai[2];
                                                        this.velocity.Y = this.ai[3];
                                                    }
                                                    this.dontTakeDamage = (this.ai[0] >= 0f && this.ai[0] <= 20f);
                                                    if (this.ai[0] >= 0f)
                                                    {
                                                        this.ai[0] += 1f;
                                                        if (this.ai[0] > 60f)
                                                        {
                                                            this.velocity = this.velocity.RotatedBy((double)this.ai[1], default(Vector2));
                                                        }
                                                        if (this.ai[0] > 120f)
                                                        {
                                                            this.velocity *= 0.98f;
                                                        }
                                                        if (this.velocity.Length() < 0.2f)
                                                        {
                                                            this.velocity = Vector2.Zero;
                                                            return;
                                                        }
                                                    }
                                                }
                                            }
                                            else if (this.aiStyle == 101)
                                            {
                                                float num2021 = 420f;
                                                float num2022 = 120f;
                                                int num2023 = 1;
                                                float value98 = 0f;
                                                float value99 = 1f;
                                                float num2024 = 4f;
                                                bool flag191 = this.ai[1] < 0f || !Main.npc[(int)this.ai[0]].active;
                                                if (Main.npc[(int)this.ai[0]].type == 439)
                                                {
                                                    if (Main.npc[(int)this.ai[0]].life < Main.npc[(int)this.ai[0]].lifeMax / 2)
                                                    {
                                                        num2023 = 2;
                                                    }
                                                    if (Main.npc[(int)this.ai[0]].life < Main.npc[(int)this.ai[0]].lifeMax / 4)
                                                    {
                                                        num2023 = 3;
                                                    }
                                                }
                                                else
                                                {
                                                    flag191 = true;
                                                }
                                                this.ai[1] += (float)num2023;
                                                float num2025 = this.ai[1] / num2022;
                                                num2025 = MathHelper.Clamp(num2025, 0f, 1f);
                                                this.position = base.Center;
                                                this.scale = MathHelper.Lerp(value98, value99, num2025);
                                                base.Center = this.position;
                                                this.alpha = (int)(255f - num2025 * 255f);

                                                this.localAI[0] += 0.05235988f;
                                                this.localAI[1] = 0.25f + Vector2.UnitY.RotatedBy((double)(this.ai[1] * 6.28318548f / 60f), default(Vector2)).Y * 0.25f;
                                                if (this.ai[1] >= num2021)
                                                {
                                                    flag191 = true;
                                                    if (Main.netMode != 1)
                                                    {
                                                        for (int num2026 = 0; num2026 < 4; num2026++)
                                                        {
                                                            Vector2 vector287 = new Vector2(0f, -num2024).RotatedBy((double)(1.57079637f * (float)num2026), default(Vector2));
                                                            Projectile.NewProjectile(base.Center.X, base.Center.Y, vector287.X, vector287.Y, 593, this.damage, 0f, Main.myPlayer, 0f, 0f);
                                                        }
                                                    }
                                                }
                                                if (flag191)
                                                {
                                                    this.HitEffect(0, 9999.0);
                                                    this.active = false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#60
0
        public override void AI()
        {
            NPC npc = FargoSoulsUtil.NPCExists(projectile.ai[0], ModContent.NPCType <NPCs.AbomBoss.AbomBoss>());

            if (npc == null)
            {
                projectile.Kill();
                return;
            }

            Vector2 target = npc.Center;

            target.X += (npc.localAI[3] > 1 ? 1200 : 2000) * (float)Math.Sin(2 * Math.PI / 720 * projectile.ai[1]++);
            target.Y -= 1100;

            Vector2 distance = target - projectile.Center;
            float   length   = distance.Length();

            if (length > 100f)
            {
                distance           /= 8f;
                projectile.velocity = (projectile.velocity * 23f + distance) / 24f;
            }
            else
            {
                if (projectile.velocity.Length() < 12f)
                {
                    projectile.velocity *= 1.05f;
                }
            }

            /*projectile.localAI[0]++;
             * if (projectile.localAI[0] > 45)
             * {
             *  projectile.localAI[0] = 0f;
             *  if (projectile.owner == Main.myPlayer)
             *  {
             *      Vector2 vel = distance;
             *      vel.Normalize();
             *      vel *= 9f;
             *      Projectile.NewProjectile(projectile.Center, vel, ModContent.ProjectileType<FrostWave>(),
             *          projectile.damage, projectile.knockBack, projectile.owner);
             *  }
             * }*/

            if (++projectile.localAI[0] > 90 && ++projectile.localAI[1] > (npc.localAI[3] > 1 ? 4 : 2)) //spray shards
            {
                Main.PlaySound(SoundID.Item27, projectile.position);
                projectile.localAI[1] = 0f;
                if (Main.netMode != NetmodeID.MultiplayerClient)
                {
                    if (Math.Abs(npc.Center.X - projectile.Center.X) > 400)
                    {
                        for (int i = 0; i < 2; i++)
                        {
                            Vector2 speed = new Vector2(Main.rand.Next(-1000, 1001), Main.rand.Next(-1000, 1001));
                            speed.Normalize();
                            speed *= 8f;
                            Projectile.NewProjectile(projectile.Center + speed * 4f, speed, ModContent.ProjectileType <AbomFrostShard>(), projectile.damage, projectile.knockBack, projectile.owner);
                        }
                    }
                    if (Main.player[npc.target].active && !Main.player[npc.target].dead && Main.player[npc.target].Center.Y < projectile.Center.Y)
                    {
                        Main.PlaySound(SoundID.Item120, projectile.position);
                        if (Main.netMode != NetmodeID.MultiplayerClient)
                        {
                            Vector2 vel = projectile.DirectionTo(Main.player[npc.target].Center + new Vector2(Main.rand.Next(-200, 201), Main.rand.Next(-200, 201))) * 12f;
                            Projectile.NewProjectile(projectile.Center, vel, ModContent.ProjectileType <AbomFrostWave>(), projectile.damage, projectile.knockBack, projectile.owner);
                        }
                    }
                }
            }

            projectile.rotation += projectile.velocity.Length() / 12f * (projectile.velocity.X > 0 ? -0.2f : 0.2f);
            if (++projectile.frameCounter > 3)
            {
                if (++projectile.frame >= 6)
                {
                    projectile.frame = 0;
                }
                projectile.frameCounter = 0;
            }
        }