Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Terraria;
- using Terraria.ID;
- using Terraria.ModLoader;
- using Microsoft.Xna.Framework;
- using System.Collections.Generic;
- using Terraria.Audio;
- using Terraria.DataStructures;
- using Terraria.Utilities;
- namespace TheDonald.NPCs.HostileNPCs
- {
- class FBI : ModNPC
- {
- public override void SetStaticDefaults()
- {
- DisplayName.SetDefault("FBI Agent");
- Main.npcFrameCount[npc.type] = Main.npcFrameCount[NPCID.PirateCrossbower];
- }
- public override void SetDefaults()
- {
- npc.CloneDefaults(215);
- npc.aiStyle = 0;
- animationType = 215;
- banner = Item.NPCtoBanner(NPCID.Zombie);
- bannerItem = Item.BannerToItem(banner);
- }
- public override float SpawnChance(NPCSpawnInfo spawnInfo)
- {
- if (spawnInfo.player.GetModPlayer<TheDonaldPlayer>().ZoneIndustrialBiome);
- return Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY].type == mod.TileType("ConcreteTile") ? 100f : 0f; //100f is the spown rate so If you want your NPC to be rarer just change that value less the 100f or something.
- }
- public override void NPCLoot()
- {
- if (Main.rand.Next(3) == 0)
- {
- Item.NewItem(npc.getRect(), mod.ItemType("SpikyBracelet"));
- }
- }
- public override void AI()
- {
- if (npc.type == 466)
- {
- int num = 200;
- if (npc.ai[2] == 0f)
- {
- npc.alpha = num;
- npc.TargetClosest(true);
- if (!Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() < 170f)
- {
- npc.ai[2] = -16f;
- }
- if (npc.velocity.X != 0f || npc.velocity.Y < 0f || npc.velocity.Y > 2f || npc.justHit)
- {
- npc.ai[2] = -16f;
- }
- return;
- }
- if (npc.ai[2] < 0f)
- {
- if (npc.alpha > 0)
- {
- npc.alpha -= num / 16;
- if (npc.alpha < 0)
- {
- npc.alpha = 0;
- }
- }
- npc.ai[2] += 1f;
- if (npc.ai[2] == 0f)
- {
- npc.ai[2] = 1f;
- npc.velocity.X = (float)(npc.direction * 2);
- }
- return;
- }
- npc.alpha = 0;
- }
- if (npc.type == 166)
- {
- if (Main.netMode != 1 && Main.rand.Next(240) == 0)
- {
- npc.ai[2] = (float)Main.rand.Next(-480, -60);
- npc.netUpdate = true;
- }
- if (npc.ai[2] < 0f)
- {
- npc.TargetClosest(true);
- if (npc.justHit)
- {
- npc.ai[2] = 0f;
- }
- if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
- {
- npc.ai[2] = 0f;
- }
- }
- if (npc.ai[2] < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1)
- {
- npc.velocity.X = 0f;
- }
- npc.ai[2] += 1f;
- if (npc.ai[2] == 0f)
- {
- npc.velocity.X = (float)npc.direction * 0.1f;
- }
- return;
- }
- }
- if (npc.type == 461)
- {
- if (npc.wet)
- {
- npc.knockBackResist = 0f;
- npc.ai[3] = -0.10101f;
- npc.noGravity = true;
- Vector2 center = npc.Center;
- npc.width = 34;
- npc.height = 24;
- npc.position.X = center.X - (float)(npc.width / 2);
- npc.position.Y = center.Y - (float)(npc.height / 2);
- npc.TargetClosest(true);
- if (npc.collideX)
- {
- npc.velocity.X = -npc.oldVelocity.X;
- }
- if (npc.velocity.X < 0f)
- {
- npc.direction = -1;
- }
- if (npc.velocity.X > 0f)
- {
- npc.direction = 1;
- }
- if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1))
- {
- Vector2 value = Main.player[npc.target].Center - npc.Center;
- value.Normalize();
- value *= 5f;
- npc.velocity = (npc.velocity * 19f + value) / 20f;
- return;
- }
- float num2 = 5f;
- if (npc.velocity.Y > 0f)
- {
- num2 = 3f;
- }
- if (npc.velocity.Y < 0f)
- {
- num2 = 8f;
- }
- Vector2 value2 = new Vector2((float)npc.direction, -1f);
- value2.Normalize();
- value2 *= num2;
- if (num2 < 5f)
- {
- npc.velocity = (npc.velocity * 24f + value2) / 25f;
- return;
- }
- npc.velocity = (npc.velocity * 9f + value2) / 10f;
- return;
- }
- else
- {
- npc.knockBackResist = 0.4f * Main.knockBackMultiplier;
- npc.noGravity = false;
- Vector2 center2 = npc.Center;
- npc.width = 18;
- npc.height = 40;
- npc.position.X = center2.X - (float)(npc.width / 2);
- npc.position.Y = center2.Y - (float)(npc.height / 2);
- if (npc.ai[3] == -0.10101f)
- {
- npc.ai[3] = 0f;
- float num3 = npc.velocity.Length();
- num3 *= 2f;
- if (num3 > 10f)
- {
- num3 = 10f;
- }
- npc.velocity.Normalize();
- npc.velocity *= num3;
- if (npc.velocity.X < 0f)
- {
- npc.direction = -1;
- }
- if (npc.velocity.X > 0f)
- {
- npc.direction = 1;
- }
- npc.spriteDirection = npc.direction;
- }
- }
- }
- if (npc.type == 379 || npc.type == 380)
- {
- if (npc.ai[3] < 0f)
- {
- npc.damage = 0;
- npc.velocity.X = npc.velocity.X * 0.93f;
- if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1)
- {
- npc.velocity.X = 0f;
- }
- int num4 = (int)(-npc.ai[3] - 1f);
- int num5 = Math.Sign(Main.npc[num4].Center.X - npc.Center.X);
- if (num5 != npc.direction)
- {
- npc.velocity.X = 0f;
- npc.direction = num5;
- npc.netUpdate = true;
- }
- if (npc.justHit && Main.netMode != 1 && Main.npc[num4].localAI[0] == 0f)
- {
- Main.npc[num4].localAI[0] = 1f;
- }
- if (npc.ai[0] < 1000f)
- {
- npc.ai[0] = 1000f;
- }
- if ((npc.ai[0] += 1f) >= 1300f)
- {
- npc.ai[0] = 1000f;
- npc.netUpdate = true;
- }
- return;
- }
- if (npc.ai[0] >= 1000f)
- {
- npc.ai[0] = 0f;
- }
- npc.damage = npc.defDamage;
- }
- if (npc.type == 383 && npc.ai[2] == 0f && npc.localAI[0] == 0f && Main.netMode != 1)
- {
- int num6 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 384, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
- npc.ai[2] = (float)(num6 + 1);
- npc.localAI[0] = -1f;
- npc.netUpdate = true;
- Main.npc[num6].ai[0] = (float)npc.whoAmI;
- Main.npc[num6].netUpdate = true;
- }
- if (npc.type == 383)
- {
- int num7 = (int)npc.ai[2] - 1;
- if (num7 != -1 && Main.npc[num7].active && Main.npc[num7].type == 384)
- {
- npc.dontTakeDamage = true;
- }
- else
- {
- npc.dontTakeDamage = false;
- npc.ai[2] = 0f;
- if (npc.localAI[0] == -1f)
- {
- npc.localAI[0] = 180f;
- }
- if (npc.localAI[0] > 0f)
- {
- npc.localAI[0] -= 1f;
- }
- }
- }
- if (npc.type == 482)
- {
- int num8 = 300;
- int num9 = 120;
- npc.dontTakeDamage = false;
- if (npc.ai[2] < 0f)
- {
- npc.dontTakeDamage = true;
- npc.ai[2] += 1f;
- npc.velocity.X = npc.velocity.X * 0.9f;
- if ((double)Math.Abs(npc.velocity.X) < 0.001)
- {
- npc.velocity.X = 0.001f * (float)npc.direction;
- }
- if (Math.Abs(npc.velocity.Y) > 1f)
- {
- npc.ai[2] += 10f;
- }
- if (npc.ai[2] >= 0f)
- {
- npc.netUpdate = true;
- npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.3f;
- }
- return;
- }
- if (npc.ai[2] < (float)num8)
- {
- if (npc.justHit)
- {
- npc.ai[2] += 15f;
- }
- npc.ai[2] += 1f;
- }
- else if (npc.velocity.Y == 0f)
- {
- npc.ai[2] = -(float)num9;
- npc.netUpdate = true;
- }
- }
- if (npc.type == 480)
- {
- int num10 = 180;
- int num11 = 300;
- int num12 = 180;
- int num13 = 60;
- int num14 = 20;
- if (npc.life < npc.lifeMax / 3)
- {
- num10 = 120;
- num11 = 240;
- num12 = 240;
- num13 = 90;
- }
- if (npc.ai[2] > 0f)
- {
- npc.ai[2] -= 1f;
- }
- else if (npc.ai[2] == 0f)
- {
- if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && npc.velocity.Y == 0f && npc.Distance(Main.player[npc.target].Center) < 900f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
- {
- npc.ai[2] = -(float)num12 - (float)num14;
- npc.netUpdate = true;
- }
- }
- else
- {
- if (npc.ai[2] < 0f && npc.ai[2] < -(float)num12)
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit)
- {
- npc.ai[2] = (float)num10;
- }
- else
- {
- npc.ai[2] += 1f;
- if (npc.ai[2] == 0f)
- {
- npc.ai[2] = (float)num11;
- }
- }
- float num15 = npc.ai[2] + (float)num12 + (float)num14;
- if (num15 == 1f)
- {
- Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 17, 1f, 0f);
- }
- if (num15 < (float)num14)
- {
- Vector2 vector = npc.Top + new Vector2((float)(npc.spriteDirection * 6), 6f);
- float scaleFactor = MathHelper.Lerp(20f, 30f, (num15 * 3f + 50f) / 182f);
- Main.rand.NextFloat();
- for (float num16 = 0f; num16 < 2f; num16 += 1f)
- {
- Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f);
- Dust expr_D5F = Main.dust[Dust.NewDust(vector, 0, 0, 228, 0f, 0f, 0, default(Color), 1f)];
- expr_D5F.position = vector + vector2 * scaleFactor;
- expr_D5F.noGravity = true;
- expr_D5F.velocity = vector2 * 2f;
- expr_D5F.scale = 0.5f + Main.rand.NextFloat() * 0.5f;
- }
- }
- Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f);
- return;
- }
- if (npc.ai[2] < 0f && npc.ai[2] >= -(float)num12)
- {
- Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f);
- npc.velocity.X = npc.velocity.X * 0.9f;
- if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit)
- {
- npc.ai[2] = (float)num10;
- }
- else
- {
- npc.ai[2] += 1f;
- if (npc.ai[2] == 0f)
- {
- npc.ai[2] = (float)num11;
- }
- }
- float num17 = npc.ai[2] + (float)num12;
- if (num17 < 180f && (Main.rand.Next(3) == 0 || npc.ai[2] % 3f == 0f))
- {
- Vector2 vector3 = npc.Top + new Vector2((float)(npc.spriteDirection * 10), 10f);
- float scaleFactor2 = MathHelper.Lerp(20f, 30f, (num17 * 3f + 50f) / 182f);
- Main.rand.NextFloat();
- for (float num18 = 0f; num18 < 1f; num18 += 1f)
- {
- Vector2 vector4 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f);
- Dust expr_F96 = Main.dust[Dust.NewDust(vector3, 0, 0, 228, 0f, 0f, 0, default(Color), 1f)];
- expr_F96.position = vector3 + vector4 * scaleFactor2;
- expr_F96.noGravity = true;
- expr_F96.velocity = vector4 * 4f;
- expr_F96.scale = 0.5f + Main.rand.NextFloat();
- }
- }
- if (Main.netMode != 2)
- {
- Player player = Main.player[Main.myPlayer];
- int arg_100D_0 = Main.myPlayer;
- if (!player.dead && player.active && player.FindBuffIndex(156) == -1)
- {
- Vector2 vector5 = player.Center - npc.Center;
- if (vector5.Length() < 700f)
- {
- bool flag = vector5.Length() < 30f;
- if (!flag)
- {
- float x = 0.7853982f.ToRotationVector2().X;
- Vector2 vector6 = Vector2.Normalize(vector5);
- if (vector6.X > x || vector6.X < -x)
- {
- flag = true;
- }
- }
- if ((((player.Center.X < npc.Center.X && npc.direction < 0 && player.direction > 0) || (player.Center.X > npc.Center.X && npc.direction > 0 && player.direction < 0)) & flag) && (Collision.CanHitLine(npc.Center, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center - Vector2.UnitY * 16f, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center + Vector2.UnitY * 8f, 1, 1, player.Center, 1, 1)))
- {
- player.AddBuff(156, num13 + (int)npc.ai[2] * -1, true);
- }
- }
- }
- }
- return;
- }
- }
- }
- if (npc.type == 471)
- {
- if (npc.ai[3] < 0f)
- {
- npc.knockBackResist = 0f;
- npc.defense = (int)((double)npc.defDefense * 1.1);
- npc.noGravity = true;
- npc.noTileCollide = true;
- if (npc.velocity.X < 0f)
- {
- npc.direction = -1;
- }
- else if (npc.velocity.X > 0f)
- {
- npc.direction = 1;
- }
- npc.rotation = npc.velocity.X * 0.1f;
- if (Main.netMode != 1)
- {
- npc.localAI[3] += 1f;
- if (npc.localAI[3] > (float)Main.rand.Next(20, 180))
- {
- npc.localAI[3] = 0f;
- Vector2 vector7 = npc.Center;
- vector7 += npc.velocity;
- NPC.NewNPC((int)vector7.X, (int)vector7.Y, 30, 0, 0f, 0f, 0f, 0f, 255);
- }
- }
- }
- else
- {
- npc.localAI[3] = 0f;
- npc.knockBackResist = 0.35f * Main.knockBackMultiplier;
- npc.rotation *= 0.9f;
- npc.defense = npc.defDefense;
- npc.noGravity = false;
- npc.noTileCollide = false;
- }
- if (npc.ai[3] == 1f)
- {
- npc.knockBackResist = 0f;
- npc.defense += 10;
- }
- if (npc.ai[3] == -1f)
- {
- npc.TargetClosest(true);
- float num19 = 8f;
- float num20 = 40f;
- Vector2 value3 = Main.player[npc.target].Center - npc.Center;
- float num21 = value3.Length();
- num19 += num21 / 200f;
- value3.Normalize();
- value3 *= num19;
- npc.velocity = (npc.velocity * (num20 - 1f) + value3) / num20;
- if (num21 < 500f && !Collision.SolidCollision(npc.position, npc.width, npc.height))
- {
- npc.ai[3] = 0f;
- npc.ai[2] = 0f;
- }
- return;
- }
- if (npc.ai[3] == -2f)
- {
- npc.velocity.Y = npc.velocity.Y - 0.2f;
- if (npc.velocity.Y < -10f)
- {
- npc.velocity.Y = -10f;
- }
- if (Main.player[npc.target].Center.Y - npc.Center.Y > 200f)
- {
- npc.TargetClosest(true);
- npc.ai[3] = -3f;
- if (Main.player[npc.target].Center.X > npc.Center.X)
- {
- npc.ai[2] = 1f;
- }
- else
- {
- npc.ai[2] = -1f;
- }
- }
- npc.velocity.X = npc.velocity.X * 0.99f;
- return;
- }
- if (npc.ai[3] == -3f)
- {
- if (npc.direction == 0)
- {
- npc.TargetClosest(true);
- }
- if (npc.ai[2] == 0f)
- {
- npc.ai[2] = (float)npc.direction;
- }
- npc.velocity.Y = npc.velocity.Y * 0.9f;
- npc.velocity.X = npc.velocity.X + npc.ai[2] * 0.3f;
- if (npc.velocity.X > 10f)
- {
- npc.velocity.X = 10f;
- }
- if (npc.velocity.X < -10f)
- {
- npc.velocity.X = -10f;
- }
- float num22 = Main.player[npc.target].Center.X - npc.Center.X;
- if ((npc.ai[2] < 0f && num22 > 300f) || (npc.ai[2] > 0f && num22 < -300f))
- {
- npc.ai[3] = -4f;
- npc.ai[2] = 0f;
- return;
- }
- if (Math.Abs(num22) > 800f)
- {
- npc.ai[3] = -1f;
- npc.ai[2] = 0f;
- }
- return;
- }
- else
- {
- if (npc.ai[3] == -4f)
- {
- npc.ai[2] += 1f;
- npc.velocity.Y = npc.velocity.Y + 0.1f;
- if (npc.velocity.Length() > 4f)
- {
- npc.velocity *= 0.9f;
- }
- int num23 = (int)npc.Center.X / 16;
- int num24 = (int)(npc.position.Y + (float)npc.height + 12f) / 16;
- bool flag2 = false;
- for (int i = num23 - 1; i <= num23 + 1; i++)
- {
- if (Main.tile[i, num24] == null)
- {
- Main.tile[num23, num24] = new Tile();
- }
- if (Main.tile[i, num24].active() && Main.tileSolid[(int)Main.tile[i, num24].type])
- {
- flag2 = true;
- }
- }
- if (flag2 && !Collision.SolidCollision(npc.position, npc.width, npc.height))
- {
- npc.ai[3] = 0f;
- npc.ai[2] = 0f;
- }
- else if (npc.ai[2] > 300f || npc.Center.Y > Main.player[npc.target].Center.Y + 200f)
- {
- npc.ai[3] = -1f;
- npc.ai[2] = 0f;
- }
- }
- else
- {
- if (npc.ai[3] == 1f)
- {
- Vector2 center3 = npc.Center;
- center3.Y -= 70f;
- npc.velocity.X = npc.velocity.X * 0.8f;
- npc.ai[2] += 1f;
- if (npc.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 (npc.ai[2] >= 90f)
- {
- npc.ai[3] = -2f;
- npc.ai[2] = 0f;
- }
- for (int j = 0; j < 2; j++)
- {
- Vector2 arg_1922_0 = center3;
- Vector2 value4 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
- value4.Normalize();
- value4 *= (float)Main.rand.Next(0, 100) * 0.1f;
- Vector2 arg_196A_0 = arg_1922_0 + value4;
- value4.Normalize();
- value4 *= (float)Main.rand.Next(50, 90) * 0.1f;
- int num25 = Dust.NewDust(arg_196A_0, 1, 1, 27, 0f, 0f, 0, default(Color), 1f);
- Main.dust[num25].velocity = -value4 * 0.3f;
- Main.dust[num25].alpha = 100;
- if (Main.rand.Next(2) == 0)
- {
- Main.dust[num25].noGravity = true;
- Main.dust[num25].scale += 0.3f;
- }
- }
- return;
- }
- npc.ai[2] += 1f;
- int num26 = 10;
- if (npc.velocity.Y == 0f && NPC.CountNPCS(472) < num26)
- {
- if (npc.ai[2] >= 180f)
- {
- npc.ai[2] = 0f;
- npc.ai[3] = 1f;
- }
- }
- else
- {
- if (NPC.CountNPCS(472) >= num26)
- {
- npc.ai[2] += 1f;
- }
- if (npc.ai[2] >= 360f)
- {
- npc.ai[2] = 0f;
- npc.ai[3] = -2f;
- npc.velocity.Y = npc.velocity.Y - 3f;
- }
- }
- if (npc.target >= 0 && !Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() > 800f)
- {
- npc.ai[3] = -1f;
- npc.ai[2] = 0f;
- }
- }
- if (Main.player[npc.target].dead)
- {
- npc.TargetClosest(true);
- if (Main.player[npc.target].dead && npc.timeLeft > 1)
- {
- npc.timeLeft = 1;
- }
- }
- }
- }
- if (npc.type == 419)
- {
- npc.reflectingProjectiles = false;
- npc.takenDamageMultiplier = 1f;
- int num27 = 6;
- int num28 = 10;
- float scaleFactor3 = 16f;
- if (npc.ai[2] > 0f)
- {
- npc.ai[2] -= 1f;
- }
- if (npc.ai[2] == 0f)
- {
- if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
- {
- npc.ai[2] = -1f;
- npc.netUpdate = true;
- npc.TargetClosest(true);
- }
- }
- else
- {
- if (npc.ai[2] < 0f && npc.ai[2] > -(float)num27)
- {
- npc.ai[2] -= 1f;
- npc.velocity.X = npc.velocity.X * 0.9f;
- return;
- }
- if (npc.ai[2] == -(float)num27)
- {
- npc.ai[2] -= 1f;
- npc.TargetClosest(true);
- Vector2 vec = npc.DirectionTo(Main.player[npc.target].Top + new Vector2(0f, -30f));
- if (vec.HasNaNs())
- {
- vec = Vector2.Normalize(new Vector2((float)npc.spriteDirection, -1f));
- }
- npc.velocity = vec * scaleFactor3;
- npc.netUpdate = true;
- return;
- }
- if (npc.ai[2] < -(float)num27)
- {
- npc.ai[2] -= 1f;
- if (npc.velocity.Y == 0f)
- {
- npc.ai[2] = 60f;
- }
- else if (npc.ai[2] < -(float)num27 - (float)num28)
- {
- npc.velocity.Y = npc.velocity.Y + 0.15f;
- if (npc.velocity.Y > 24f)
- {
- npc.velocity.Y = 24f;
- }
- }
- npc.reflectingProjectiles = true;
- npc.takenDamageMultiplier = 3f;
- if (npc.justHit)
- {
- npc.ai[2] = 60f;
- npc.netUpdate = true;
- }
- return;
- }
- }
- }
- if (npc.type == 415)
- {
- int num29 = 42;
- int num30 = 18;
- if (npc.justHit)
- {
- npc.ai[2] = 120f;
- npc.netUpdate = true;
- }
- if (npc.ai[2] > 0f)
- {
- npc.ai[2] -= 1f;
- }
- if (npc.ai[2] == 0f)
- {
- int num31 = 0;
- for (int k = 0; k < 200; k++)
- {
- if (Main.npc[k].active && Main.npc[k].type == 516)
- {
- num31++;
- }
- }
- if (num31 > 6)
- {
- npc.ai[2] = 90f;
- }
- else if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
- {
- npc.ai[2] = -1f;
- npc.netUpdate = true;
- npc.TargetClosest(true);
- }
- }
- else if (npc.ai[2] < 0f && npc.ai[2] > -(float)num29)
- {
- npc.ai[2] -= 1f;
- if (npc.ai[2] == -(float)num29)
- {
- npc.ai[2] = (float)(180 + 30 * Main.rand.Next(10));
- }
- npc.velocity.X = npc.velocity.X * 0.8f;
- if (npc.ai[2] == -(float)num30 || npc.ai[2] == -(float)num30 - 8f || npc.ai[2] == -(float)num30 - 16f)
- {
- for (int l = 0; l < 20; l++)
- {
- Vector2 vector8 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * 40f;
- Dust arg_2098_0 = Main.dust[Dust.NewDust(vector8, 0, 0, 259, 0f, 0f, 0, default(Color), 1f)];
- Vector2 vector9 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
- arg_2098_0.position = vector8 + vector9 * 4f;
- arg_2098_0.velocity = vector9 * 2f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * 3f;
- arg_2098_0.scale = 0.3f + vector9.X * -(float)npc.spriteDirection;
- arg_2098_0.fadeIn = 0.7f;
- arg_2098_0.noGravity = true;
- }
- if (npc.velocity.X > -0.5f && npc.velocity.X < 0.5f)
- {
- npc.velocity.X = 0f;
- }
- if (Main.netMode != 1)
- {
- NPC.NewNPC((int)npc.Center.X + npc.spriteDirection * 45, (int)npc.Center.Y + 8, 516, 0, 0f, 0f, 0f, 0f, npc.target);
- }
- }
- return;
- }
- }
- if (npc.type == 428)
- {
- npc.localAI[0] += 1f;
- if (npc.localAI[0] >= 300f)
- {
- int arg_220E_0 = (int)npc.Center.X / 16 - 1;
- int num32 = (int)npc.Center.Y / 16 - 1;
- if (!Collision.SolidTiles(arg_220E_0, arg_220E_0 + 2, num32, num32 + 1) && Main.netMode != 1)
- {
- npc.Transform(427);
- npc.life = npc.lifeMax;
- npc.localAI[0] = 0f;
- return;
- }
- }
- int maxValue;
- if (npc.localAI[0] < 60f)
- {
- maxValue = 16;
- }
- else if (npc.localAI[0] < 120f)
- {
- maxValue = 8;
- }
- else if (npc.localAI[0] < 180f)
- {
- maxValue = 4;
- }
- else if (npc.localAI[0] < 240f)
- {
- maxValue = 2;
- }
- else if (npc.localAI[0] < 300f)
- {
- maxValue = 1;
- }
- else
- {
- maxValue = 1;
- }
- if (Main.rand.Next(maxValue) == 0)
- {
- Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1f)];
- dust.noGravity = true;
- dust.scale = 1f;
- dust.noLight = true;
- dust.velocity = npc.DirectionFrom(dust.position) * dust.velocity.Length();
- dust.position -= dust.velocity * 5f;
- Dust dust2 = dust;
- dust2.position.X = dust2.position.X + (float)(npc.direction * 6);
- Dust dust3 = dust;
- dust3.position.Y = dust3.position.Y + 4f;
- }
- }
- if (npc.type == 427)
- {
- npc.localAI[0] += 1f;
- npc.localAI[0] += Math.Abs(npc.velocity.X) / 2f;
- if (npc.localAI[0] >= 1200f && Main.netMode != 1)
- {
- int arg_2434_0 = (int)npc.Center.X / 16 - 2;
- int num33 = (int)npc.Center.Y / 16 - 3;
- if (!Collision.SolidTiles(arg_2434_0, arg_2434_0 + 4, num33, num33 + 4))
- {
- npc.Transform(426);
- npc.life = npc.lifeMax;
- npc.localAI[0] = 0f;
- return;
- }
- }
- int maxValue2;
- if (npc.localAI[0] < 360f)
- {
- maxValue2 = 32;
- }
- else if (npc.localAI[0] < 720f)
- {
- maxValue2 = 16;
- }
- else if (npc.localAI[0] < 1080f)
- {
- maxValue2 = 6;
- }
- else if (npc.localAI[0] < 1440f)
- {
- maxValue2 = 2;
- }
- else if (npc.localAI[0] < 1800f)
- {
- maxValue2 = 1;
- }
- else
- {
- maxValue2 = 1;
- }
- if (Main.rand.Next(maxValue2) == 0)
- {
- Dust expr_251C = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1f)];
- expr_251C.noGravity = true;
- expr_251C.scale = 1f;
- expr_251C.noLight = true;
- }
- }
- bool flag3 = false;
- if (npc.velocity.X == 0f)
- {
- flag3 = true;
- }
- if (npc.justHit)
- {
- flag3 = false;
- }
- if (Main.netMode != 1 && npc.type == 198 && (double)npc.life <= (double)npc.lifeMax * 0.55)
- {
- npc.Transform(199);
- }
- if (Main.netMode != 1 && npc.type == 348 && (double)npc.life <= (double)npc.lifeMax * 0.55)
- {
- npc.Transform(349);
- }
- int num34 = 60;
- if (npc.type == 120)
- {
- num34 = 180;
- if (npc.ai[3] == -120f)
- {
- npc.velocity *= 0f;
- npc.ai[3] = 0f;
- Main.PlaySound(SoundID.Item8, npc.position);
- Vector2 vector10 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
- float num35 = npc.oldPos[2].X + (float)npc.width * 0.5f - vector10.X;
- float num36 = npc.oldPos[2].Y + (float)npc.height * 0.5f - vector10.Y;
- float num37 = (float)Math.Sqrt((double)(num35 * num35 + num36 * num36));
- num37 = 2f / num37;
- num35 *= num37;
- num36 *= num37;
- for (int m = 0; m < 20; m++)
- {
- int num38 = Dust.NewDust(npc.position, npc.width, npc.height, 71, num35, num36, 200, default(Color), 2f);
- Main.dust[num38].noGravity = true;
- Dust dust4 = Main.dust[num38];
- dust4.velocity.X = dust4.velocity.X * 2f;
- }
- for (int n = 0; n < 20; n++)
- {
- int num39 = Dust.NewDust(npc.oldPos[2], npc.width, npc.height, 71, -num35, -num36, 200, default(Color), 2f);
- Main.dust[num39].noGravity = true;
- Dust dust5 = Main.dust[num39];
- dust5.velocity.X = dust5.velocity.X * 2f;
- }
- }
- }
- bool flag4 = false;
- bool flag5 = true;
- if (npc.type == 343 || npc.type == 47 || npc.type == 67 || npc.type == 109 || npc.type == 110 || (npc.type == 111 || true) || npc.type == 120 || npc.type == 163 || npc.type == 164 || npc.type == 239 || npc.type == 168 || npc.type == 199 || npc.type == 206 || npc.type == 214 || npc.type == 215 || npc.type == 216 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 220 || npc.type == 226 || npc.type == 243 || npc.type == 251 || npc.type == 257 || npc.type == 258 || npc.type == 290 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 305 || npc.type == 306 || npc.type == 307 || npc.type == 308 || npc.type == 309 || npc.type == 348 || npc.type == 349 || npc.type == 350 || npc.type == 351 || npc.type == 379 || (npc.type >= 430 && npc.type <= 436) || (npc.type == 380 || npc.type == 381 || npc.type == 382 || npc.type == 383 || npc.type == 386 || npc.type == 391 || (npc.type >= 449 && npc.type <= 452)) || (npc.type == 466 || npc.type == 464 || npc.type == 166 || npc.type == 469 || npc.type == 468 || npc.type == 471 || npc.type == 470 || npc.type == 480 || npc.type == 481 || npc.type == 482 || npc.type == 411 || npc.type == 424 || npc.type == 409 || (npc.type >= 494 && npc.type <= 506)) || (npc.type == 425 || npc.type == 427 || npc.type == 426 || npc.type == 428 || npc.type == 508 || npc.type == 415 || npc.type == 419 || npc.type == 520 || (npc.type >= 524 && npc.type <= 527)) || npc.type == 528 || npc.type == 529 || npc.type == 530 || npc.type == 532)
- {
- flag5 = false;
- }
- bool flag6 = false;
- int num40 = npc.type;
- if (num40 == 425 || num40 == 471)
- {
- flag6 = true;
- }
- bool flag7 = true;
- num40 = npc.type;
- if (num40 <= 350)
- {
- if (num40 <= 206)
- {
- if (num40 - 110 > 1 && num40 != 206)
- {
- goto IL_2D75;
- }
- }
- else if (num40 - 214 > 2 && num40 - 291 > 2 && num40 != 350)
- {
- goto IL_2D75;
- }
- }
- else if (num40 <= 426)
- {
- if (num40 - 379 > 3)
- {
- switch (num40)
- {
- case 409:
- case 411:
- break;
- case 410:
- goto IL_2D75;
- default:
- switch (num40)
- {
- case 424:
- case 426:
- break;
- case 425:
- goto IL_2D75;
- default:
- goto IL_2D75;
- }
- break;
- }
- }
- }
- else if (num40 != 466 && num40 - 498 > 8 && num40 != 520)
- {
- goto IL_2D75;
- }
- if (npc.ai[2] > 0f)
- {
- flag7 = false;
- }
- IL_2D75:
- if (!flag6 & flag7)
- {
- if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0)))
- {
- flag4 = true;
- }
- if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num34) | flag4)
- {
- npc.ai[3] += 1f;
- }
- else if ((double)Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f)
- {
- npc.ai[3] -= 1f;
- }
- if (npc.ai[3] > (float)(num34 * 10))
- {
- npc.ai[3] = 0f;
- }
- if (npc.justHit)
- {
- npc.ai[3] = 0f;
- }
- if (npc.ai[3] == (float)num34)
- {
- npc.netUpdate = true;
- }
- }
- if (npc.type == 463 && Main.netMode != 1)
- {
- if (npc.localAI[3] > 0f)
- {
- npc.localAI[3] -= 1f;
- }
- if (npc.justHit && npc.localAI[3] <= 0f && Main.rand.Next(3) == 0)
- {
- npc.localAI[3] = 30f;
- int num41 = Main.rand.Next(3, 6);
- int[] array = new int[num41];
- int num42 = 0;
- for (int num43 = 0; num43 < 255; num43++)
- {
- if (Main.player[num43].active && !Main.player[num43].dead && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[num43].position, Main.player[num43].width, Main.player[num43].height))
- {
- array[num42] = num43;
- num42++;
- if (num42 == num41)
- {
- break;
- }
- }
- }
- if (num42 > 1)
- {
- for (int num44 = 0; num44 < 100; num44++)
- {
- int num45 = Main.rand.Next(num42);
- int num46;
- for (num46 = num45; num46 == num45; num46 = Main.rand.Next(num42))
- {
- }
- int num47 = array[num45];
- array[num45] = array[num46];
- array[num46] = num47;
- }
- }
- Vector2 vector11 = new Vector2(-1f, -1f);
- for (int num48 = 0; num48 < num42; num48++)
- {
- Vector2 value5 = Main.npc[array[num48]].Center - npc.Center;
- value5.Normalize();
- vector11 += value5;
- }
- vector11.Normalize();
- for (int num49 = 0; num49 < num41; num49++)
- {
- float scaleFactor4 = (float)Main.rand.Next(8, 13);
- Vector2 vector12 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101));
- vector12.Normalize();
- if (num42 > 0)
- {
- vector12 += vector11;
- vector12.Normalize();
- }
- vector12 *= scaleFactor4;
- if (num42 > 0)
- {
- num42--;
- vector12 = Main.player[array[num42]].Center - npc.Center;
- vector12.Normalize();
- vector12 *= scaleFactor4;
- }
- Projectile.NewProjectile(npc.Center.X, npc.position.Y + (float)(npc.width / 4), vector12.X, vector12.Y, 498, (int)((double)npc.damage * 0.15), 1f, 255, 0f, 0f);
- }
- }
- }
- if (npc.type == 460)
- {
- if (npc.velocity.Y < -0.3f || npc.velocity.Y > 0.3f)
- {
- npc.knockBackResist = 0f;
- }
- else
- {
- npc.knockBackResist = 0.25f * Main.knockBackMultiplier;
- }
- }
- if (npc.type == 469)
- {
- npc.knockBackResist = 0.45f * Main.knockBackMultiplier;
- if (npc.ai[2] == 1f)
- {
- npc.knockBackResist = 0f;
- }
- bool flag8 = false;
- int num50 = (int)npc.Center.X / 16;
- int num51 = (int)npc.Center.Y / 16;
- for (int num52 = num50 - 1; num52 <= num50 + 1; num52++)
- {
- for (int num53 = num51 - 1; num53 <= num51 + 1; num53++)
- {
- if (Main.tile[num52, num53] != null && Main.tile[num52, num53].wall > 0)
- {
- flag8 = true;
- break;
- }
- }
- if (flag8)
- {
- break;
- }
- }
- if (npc.ai[2] == 0f & flag8)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity.Y = -4.6f;
- npc.velocity.X = npc.velocity.X * 1.3f;
- }
- else if (npc.velocity.Y > 0f)
- {
- npc.ai[2] = 1f;
- }
- }
- if (flag8 && npc.ai[2] == 1f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
- {
- Vector2 value6 = Main.player[npc.target].Center - npc.Center;
- float num54 = value6.Length();
- value6.Normalize();
- value6 *= 4.5f + num54 / 300f;
- npc.velocity = (npc.velocity * 29f + value6) / 30f;
- npc.noGravity = true;
- npc.ai[2] = 1f;
- return;
- }
- npc.noGravity = false;
- npc.ai[2] = 0f;
- }
- if (npc.type == 462 && npc.velocity.Y == 0f && (Main.player[npc.target].Center - npc.Center).Length() < 150f && Math.Abs(npc.velocity.X) > 3f && ((npc.velocity.X < 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X > 0f && npc.Center.X < Main.player[npc.target].Center.X)))
- {
- npc.velocity.X = npc.velocity.X * 1.75f;
- npc.velocity.Y = npc.velocity.Y - 4.5f;
- if (npc.Center.Y - Main.player[npc.target].Center.Y > 20f)
- {
- npc.velocity.Y = npc.velocity.Y - 0.5f;
- }
- if (npc.Center.Y - Main.player[npc.target].Center.Y > 40f)
- {
- npc.velocity.Y = npc.velocity.Y - 1f;
- }
- if (npc.Center.Y - Main.player[npc.target].Center.Y > 80f)
- {
- npc.velocity.Y = npc.velocity.Y - 1.5f;
- }
- if (npc.Center.Y - Main.player[npc.target].Center.Y > 100f)
- {
- npc.velocity.Y = npc.velocity.Y - 1.5f;
- }
- if (Math.Abs(npc.velocity.X) > 7f)
- {
- if (npc.velocity.X < 0f)
- {
- npc.velocity.X = -7f;
- }
- else
- {
- npc.velocity.X = 7f;
- }
- }
- }
- if (npc.ai[3] < (float)num34 && (Main.eclipse || !Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0 || (Main.invasionType == 1 && (npc.type == 343 || npc.type == 350)) || (Main.invasionType == 1 && (npc.type == 26 || npc.type == 27 || npc.type == 28 || (npc.type == 111 || true) || npc.type == 471)) || (npc.type == 73 || (Main.invasionType == 3 && npc.type >= 212 && npc.type <= 216)) || (Main.invasionType == 4 && (npc.type == 381 || npc.type == 382 || npc.type == 383 || npc.type == 385 || npc.type == 386 || npc.type == 389 || npc.type == 391 || npc.type == 520)) || (npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 67 || npc.type == 77 || npc.type == 78 || npc.type == 79 || npc.type == 80 || npc.type == 110 || npc.type == 120 || npc.type == 168 || npc.type == 181 || npc.type == 185 || npc.type == 198 || npc.type == 199 || npc.type == 206 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 220 || npc.type == 239 || npc.type == 243 || npc.type == 254 || npc.type == 255 || npc.type == 257 || npc.type == 258 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 379 || npc.type == 380 || npc.type == 464 || npc.type == 470 || npc.type == 424 || (npc.type == 411 && (npc.ai[1] >= 180f || npc.ai[1] < 90f))) || (npc.type == 409 || npc.type == 425 || npc.type == 429 || npc.type == 427 || npc.type == 428 || npc.type == 508 || npc.type == 415 || npc.type == 419 || (npc.type >= 524 && npc.type <= 527)) || npc.type == 528 || npc.type == 529 || npc.type == 530 || npc.type == 532))
- {
- if ((npc.type == 3 || npc.type == 331 || npc.type == 332 || npc.type == 21 || (npc.type >= 449 && npc.type <= 452) || npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 77 || npc.type == 110 || npc.type == 132 || npc.type == 167 || npc.type == 161 || npc.type == 162 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 197 || npc.type == 200 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 223 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 320 || npc.type == 321 || npc.type == 319 || npc.type == 481) && Main.rand.Next(1000) == 0)
- {
- Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f);
- }
- if (npc.type == 489 && Main.rand.Next(800) == 0)
- {
- Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, npc.type, 1f, 0f);
- }
- if ((npc.type == 78 || npc.type == 79 || npc.type == 80) && Main.rand.Next(500) == 0)
- {
- Main.PlaySound(26, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f);
- }
- if (npc.type == 159 && Main.rand.Next(500) == 0)
- {
- Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 7, 1f, 0f);
- }
- if (npc.type == 162 && Main.rand.Next(500) == 0)
- {
- Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 6, 1f, 0f);
- }
- if (npc.type == 181 && Main.rand.Next(500) == 0)
- {
- Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 8, 1f, 0f);
- }
- if (npc.type >= 269 && npc.type <= 280 && Main.rand.Next(1000) == 0)
- {
- Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f);
- }
- npc.TargetClosest(true);
- }
- else if (npc.ai[2] <= 0f || (npc.type != 110 && (npc.type != 111 || false) && npc.type != 206 && npc.type != 216 && npc.type != 214 && npc.type != 215 && npc.type != 291 && npc.type != 292 && npc.type != 293 && npc.type != 350 && npc.type != 381 && npc.type != 382 && npc.type != 383 && npc.type != 385 && npc.type != 386 && npc.type != 389 && npc.type != 391 && npc.type != 469 && npc.type != 166 && npc.type != 466 && npc.type != 471 && npc.type != 411 && npc.type != 409 && npc.type != 424 && npc.type != 425 && npc.type != 426 && npc.type != 415 && npc.type != 419 && npc.type != 520))
- {
- if (Main.dayTime && (double)(npc.position.Y / 16f) < Main.worldSurface && npc.timeLeft > 10)
- {
- npc.timeLeft = 10;
- }
- if (npc.velocity.X == 0f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.ai[0] += 1f;
- if (npc.ai[0] >= 2f)
- {
- npc.direction *= -1;
- npc.spriteDirection = npc.direction;
- npc.ai[0] = 0f;
- }
- }
- }
- else
- {
- npc.ai[0] = 0f;
- }
- if (npc.direction == 0)
- {
- npc.direction = 1;
- }
- }
- if (npc.type == 159 || npc.type == 349)
- {
- if (npc.type == 159 && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0)))
- {
- npc.velocity.X = npc.velocity.X * 0.95f;
- }
- if (npc.velocity.X < -6f || npc.velocity.X > 6f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < 6f && npc.direction == 1)
- {
- if (npc.velocity.Y == 0f && npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.99f;
- }
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > 6f)
- {
- npc.velocity.X = 6f;
- }
- }
- else if (npc.velocity.X > -6f && npc.direction == -1)
- {
- if (npc.velocity.Y == 0f && npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.99f;
- }
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -6f)
- {
- npc.velocity.X = -6f;
- }
- }
- }
- else if (npc.type == 199)
- {
- if (npc.velocity.X < -4f || npc.velocity.X > 4f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < 4f && npc.direction == 1)
- {
- if (npc.velocity.Y == 0f && npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.8f;
- }
- npc.velocity.X = npc.velocity.X + 0.1f;
- if (npc.velocity.X > 4f)
- {
- npc.velocity.X = 4f;
- }
- }
- else if (npc.velocity.X > -4f && npc.direction == -1)
- {
- if (npc.velocity.Y == 0f && npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.8f;
- }
- npc.velocity.X = npc.velocity.X - 0.1f;
- if (npc.velocity.X < -4f)
- {
- npc.velocity.X = -4f;
- }
- }
- }
- else if (npc.type == 120 || npc.type == 166 || npc.type == 213 || npc.type == 258 || npc.type == 528 || npc.type == 529)
- {
- if (npc.velocity.X < -3f || npc.velocity.X > 3f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < 3f && npc.direction == 1)
- {
- if (npc.velocity.Y == 0f && npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.99f;
- }
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > 3f)
- {
- npc.velocity.X = 3f;
- }
- }
- else if (npc.velocity.X > -3f && npc.direction == -1)
- {
- if (npc.velocity.Y == 0f && npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.99f;
- }
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -3f)
- {
- npc.velocity.X = -3f;
- }
- }
- }
- else if (npc.type == 461 || npc.type == 27 || npc.type == 77 || npc.type == 104 || npc.type == 163 || npc.type == 162 || npc.type == 196 || npc.type == 197 || npc.type == 212 || npc.type == 257 || npc.type == 326 || npc.type == 343 || npc.type == 348 || npc.type == 351 || (npc.type >= 524 && npc.type <= 527) || npc.type == 530)
- {
- if (npc.velocity.X < -2f || npc.velocity.X > 2f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < 2f && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > 2f)
- {
- npc.velocity.X = 2f;
- }
- }
- else if (npc.velocity.X > -2f && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -2f)
- {
- npc.velocity.X = -2f;
- }
- }
- }
- else if (npc.type == 109)
- {
- if (npc.velocity.X < -2f || npc.velocity.X > 2f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < 2f && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + 0.04f;
- if (npc.velocity.X > 2f)
- {
- npc.velocity.X = 2f;
- }
- }
- else if (npc.velocity.X > -2f && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - 0.04f;
- if (npc.velocity.X < -2f)
- {
- npc.velocity.X = -2f;
- }
- }
- }
- else if (npc.type == 21 || npc.type == 26 || npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 73 || npc.type == 140 || npc.type == 164 || npc.type == 239 || npc.type == 167 || npc.type == 168 || npc.type == 185 || npc.type == 198 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 226 || npc.type == 181 || npc.type == 254 || npc.type == 338 || npc.type == 339 || npc.type == 340 || npc.type == 342 || npc.type == 385 || npc.type == 389 || npc.type == 462 || npc.type == 463 || npc.type == 466 || npc.type == 464 || npc.type == 469 || npc.type == 470 || npc.type == 480 || npc.type == 482 || npc.type == 425 || npc.type == 429)
- {
- float num55 = 1.5f;
- if (npc.type == 294)
- {
- num55 = 2f;
- }
- else if (npc.type == 295)
- {
- num55 = 1.75f;
- }
- else if (npc.type == 296)
- {
- num55 = 1.25f;
- }
- else if (npc.type == 201)
- {
- num55 = 1.1f;
- }
- else if (npc.type == 202)
- {
- num55 = 0.9f;
- }
- else if (npc.type == 203)
- {
- num55 = 1.2f;
- }
- else if (npc.type == 338)
- {
- num55 = 1.75f;
- }
- else if (npc.type == 339)
- {
- num55 = 1.25f;
- }
- else if (npc.type == 340)
- {
- num55 = 2f;
- }
- else if (npc.type == 385)
- {
- num55 = 1.8f;
- }
- else if (npc.type == 389)
- {
- num55 = 2.25f;
- }
- else if (npc.type == 462)
- {
- num55 = 4f;
- }
- else if (npc.type == 463)
- {
- num55 = 0.75f;
- }
- else if (npc.type == 466)
- {
- num55 = 3.75f;
- }
- else if (npc.type == 469)
- {
- num55 = 3.25f;
- }
- else if (npc.type == 480)
- {
- num55 = 1.5f + (1f - (float)npc.life / (float)npc.lifeMax) * 2f;
- }
- else if (npc.type == 425)
- {
- num55 = 6f;
- }
- else if (npc.type == 429)
- {
- num55 = 4f;
- }
- if (npc.type == 21 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 342)
- {
- num55 *= 1f + (1f - npc.scale);
- }
- if (npc.velocity.X < -num55 || npc.velocity.X > num55)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < num55 && npc.direction == 1)
- {
- if (npc.type == 466 && npc.velocity.X < -2f)
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- }
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > num55)
- {
- npc.velocity.X = num55;
- }
- }
- else if (npc.velocity.X > -num55 && npc.direction == -1)
- {
- if (npc.type == 466 && npc.velocity.X > 2f)
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- }
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -num55)
- {
- npc.velocity.X = -num55;
- }
- }
- if (npc.velocity.Y == 0f && npc.type == 462 && ((npc.direction > 0 && npc.velocity.X < 0f) || (npc.direction < 0 && npc.velocity.X > 0f)))
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- }
- }
- else if (npc.type >= 269 && npc.type <= 280)
- {
- float num56 = 1.5f;
- if (npc.type == 269)
- {
- num56 = 2f;
- }
- if (npc.type == 270)
- {
- num56 = 1f;
- }
- if (npc.type == 271)
- {
- num56 = 1.5f;
- }
- if (npc.type == 272)
- {
- num56 = 3f;
- }
- if (npc.type == 273)
- {
- num56 = 1.25f;
- }
- if (npc.type == 274)
- {
- num56 = 3f;
- }
- if (npc.type == 275)
- {
- num56 = 3.25f;
- }
- if (npc.type == 276)
- {
- num56 = 2f;
- }
- if (npc.type == 277)
- {
- num56 = 2.75f;
- }
- if (npc.type == 278)
- {
- num56 = 1.8f;
- }
- if (npc.type == 279)
- {
- num56 = 1.3f;
- }
- if (npc.type == 280)
- {
- num56 = 2.5f;
- }
- num56 *= 1f + (1f - npc.scale);
- if (npc.velocity.X < -num56 || npc.velocity.X > num56)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < num56 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > num56)
- {
- npc.velocity.X = num56;
- }
- }
- else if (npc.velocity.X > -num56 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -num56)
- {
- npc.velocity.X = -num56;
- }
- }
- }
- else if (npc.type >= 305 && npc.type <= 314)
- {
- float num57 = 1.5f;
- if (npc.type == 305 || npc.type == 310)
- {
- num57 = 2f;
- }
- if (npc.type == 306 || npc.type == 311)
- {
- num57 = 1.25f;
- }
- if (npc.type == 307 || npc.type == 312)
- {
- num57 = 2.25f;
- }
- if (npc.type == 308 || npc.type == 313)
- {
- num57 = 1.5f;
- }
- if (npc.type == 309 || npc.type == 314)
- {
- num57 = 1f;
- }
- if (npc.type < 310)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.85f;
- if ((double)npc.velocity.X > -0.3 && (double)npc.velocity.X < 0.3)
- {
- npc.velocity.Y = -7f;
- npc.velocity.X = num57 * (float)npc.direction;
- }
- }
- else if (npc.spriteDirection == npc.direction)
- {
- npc.velocity.X = (npc.velocity.X * 10f + num57 * (float)npc.direction) / 11f;
- }
- }
- else if (npc.velocity.X < -num57 || npc.velocity.X > num57)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < num57 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > num57)
- {
- npc.velocity.X = num57;
- }
- }
- else if (npc.velocity.X > -num57 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -num57)
- {
- npc.velocity.X = -num57;
- }
- }
- }
- else if (npc.type == 67 || npc.type == 220 || npc.type == 428)
- {
- if (npc.velocity.X < -0.5f || npc.velocity.X > 0.5f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.7f;
- }
- }
- else if (npc.velocity.X < 0.5f && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + 0.03f;
- if (npc.velocity.X > 0.5f)
- {
- npc.velocity.X = 0.5f;
- }
- }
- else if (npc.velocity.X > -0.5f && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - 0.03f;
- if (npc.velocity.X < -0.5f)
- {
- npc.velocity.X = -0.5f;
- }
- }
- }
- else if (npc.type == 78 || npc.type == 79 || npc.type == 80)
- {
- float num58 = 1f;
- float num59 = 0.05f;
- if (npc.life < npc.lifeMax / 2)
- {
- num58 = 2f;
- num59 = 0.1f;
- }
- if (npc.type == 79)
- {
- num58 *= 1.5f;
- }
- if (npc.velocity.X < -num58 || npc.velocity.X > num58)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.7f;
- }
- }
- else if (npc.velocity.X < num58 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + num59;
- if (npc.velocity.X > num58)
- {
- npc.velocity.X = num58;
- }
- }
- else if (npc.velocity.X > -num58 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - num59;
- if (npc.velocity.X < -num58)
- {
- npc.velocity.X = -num58;
- }
- }
- }
- else if (npc.type == 287)
- {
- float num60 = 5f;
- float num61 = 0.2f;
- if (npc.velocity.X < -num60 || npc.velocity.X > num60)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.7f;
- }
- }
- else if (npc.velocity.X < num60 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + num61;
- if (npc.velocity.X > num60)
- {
- npc.velocity.X = num60;
- }
- }
- else if (npc.velocity.X > -num60 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - num61;
- if (npc.velocity.X < -num60)
- {
- npc.velocity.X = -num60;
- }
- }
- }
- else if (npc.type == 243)
- {
- float num62 = 1f;
- float num63 = 0.07f;
- num62 += (1f - (float)npc.life / (float)npc.lifeMax) * 1.5f;
- num63 += (1f - (float)npc.life / (float)npc.lifeMax) * 0.15f;
- if (npc.velocity.X < -num62 || npc.velocity.X > num62)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.7f;
- }
- }
- else if (npc.velocity.X < num62 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + num63;
- if (npc.velocity.X > num62)
- {
- npc.velocity.X = num62;
- }
- }
- else if (npc.velocity.X > -num62 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - num63;
- if (npc.velocity.X < -num62)
- {
- npc.velocity.X = -num62;
- }
- }
- }
- else if (npc.type == 251)
- {
- float num64 = 1f;
- float num65 = 0.08f;
- num64 += (1f - (float)npc.life / (float)npc.lifeMax) * 2f;
- num65 += (1f - (float)npc.life / (float)npc.lifeMax) * 0.2f;
- if (npc.velocity.X < -num64 || npc.velocity.X > num64)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.7f;
- }
- }
- else if (npc.velocity.X < num64 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + num65;
- if (npc.velocity.X > num64)
- {
- npc.velocity.X = num64;
- }
- }
- else if (npc.velocity.X > -num64 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - num65;
- if (npc.velocity.X < -num64)
- {
- npc.velocity.X = -num64;
- }
- }
- }
- else if (npc.type == 386)
- {
- if (npc.ai[2] > 0f)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.8f;
- }
- }
- else
- {
- float num66 = 0.15f;
- float num67 = 1.5f;
- if (npc.velocity.X < -num67 || npc.velocity.X > num67)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.7f;
- }
- }
- else if (npc.velocity.X < num67 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + num66;
- if (npc.velocity.X > num67)
- {
- npc.velocity.X = num67;
- }
- }
- else if (npc.velocity.X > -num67 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - num66;
- if (npc.velocity.X < -num67)
- {
- npc.velocity.X = -num67;
- }
- }
- }
- }
- else if (npc.type == 460)
- {
- float num68 = 3f;
- float num69 = 0.1f;
- if (Math.Abs(npc.velocity.X) > 2f)
- {
- num69 *= 0.8f;
- }
- if ((double)Math.Abs(npc.velocity.X) > 2.5)
- {
- num69 *= 0.8f;
- }
- if (Math.Abs(npc.velocity.X) > 3f)
- {
- num69 *= 0.8f;
- }
- if ((double)Math.Abs(npc.velocity.X) > 3.5)
- {
- num69 *= 0.8f;
- }
- if (Math.Abs(npc.velocity.X) > 4f)
- {
- num69 *= 0.8f;
- }
- if ((double)Math.Abs(npc.velocity.X) > 4.5)
- {
- num69 *= 0.8f;
- }
- if (Math.Abs(npc.velocity.X) > 5f)
- {
- num69 *= 0.8f;
- }
- if ((double)Math.Abs(npc.velocity.X) > 5.5)
- {
- num69 *= 0.8f;
- }
- num68 += (1f - (float)npc.life / (float)npc.lifeMax) * 3f;
- if (npc.velocity.X < -num68 || npc.velocity.X > num68)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.7f;
- }
- }
- else if (npc.velocity.X < num68 && npc.direction == 1)
- {
- if (npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.93f;
- }
- npc.velocity.X = npc.velocity.X + num69;
- if (npc.velocity.X > num68)
- {
- npc.velocity.X = num68;
- }
- }
- else if (npc.velocity.X > -num68 && npc.direction == -1)
- {
- if (npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.93f;
- }
- npc.velocity.X = npc.velocity.X - num69;
- if (npc.velocity.X < -num68)
- {
- npc.velocity.X = -num68;
- }
- }
- }
- else if (npc.type == 508)
- {
- float num70 = 2.5f;
- float num71 = 40f;
- float num72 = Math.Abs(npc.velocity.X);
- if (num72 > 2.75f)
- {
- num70 = 3.5f;
- num71 += 80f;
- }
- else if ((double)num72 > 2.25)
- {
- num70 = 3f;
- num71 += 60f;
- }
- if ((double)Math.Abs(npc.velocity.Y) < 0.5)
- {
- if (npc.velocity.X > 0f && npc.direction < 0)
- {
- npc.velocity *= 0.9f;
- }
- if (npc.velocity.X < 0f && npc.direction > 0)
- {
- npc.velocity *= 0.9f;
- }
- }
- if (Math.Abs(npc.velocity.Y) > 0.3f)
- {
- num71 *= 3f;
- }
- if (npc.velocity.X <= 0f && npc.direction < 0)
- {
- npc.velocity.X = (npc.velocity.X * num71 - num70) / (num71 + 1f);
- }
- else if (npc.velocity.X >= 0f && npc.direction > 0)
- {
- npc.velocity.X = (npc.velocity.X * num71 + num70) / (num71 + 1f);
- }
- else if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 20f && Math.Abs(npc.velocity.Y) <= 0.3f)
- {
- npc.velocity.X = npc.velocity.X * 0.99f;
- npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.025f;
- }
- }
- else if (npc.type == 391 || npc.type == 427 || npc.type == 415 || npc.type == 419 || npc.type == 518 || npc.type == 532)
- {
- float num73 = 5f;
- float num74 = 0.25f;
- float scaleFactor5 = 0.7f;
- if (npc.type == 427)
- {
- num73 = 6f;
- num74 = 0.2f;
- scaleFactor5 = 0.8f;
- }
- else if (npc.type == 415)
- {
- num73 = 4f;
- num74 = 0.1f;
- scaleFactor5 = 0.95f;
- }
- else if (npc.type == 419)
- {
- num73 = 6f;
- num74 = 0.15f;
- scaleFactor5 = 0.85f;
- }
- else if (npc.type == 518)
- {
- num73 = 5f;
- num74 = 0.1f;
- scaleFactor5 = 0.95f;
- }
- else if (npc.type == 532)
- {
- num73 = 5f;
- num74 = 0.15f;
- scaleFactor5 = 0.98f;
- }
- if (npc.velocity.X < -num73 || npc.velocity.X > num73)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= scaleFactor5;
- }
- }
- else if (npc.velocity.X < num73 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + num74;
- if (npc.velocity.X > num73)
- {
- npc.velocity.X = num73;
- }
- }
- else if (npc.velocity.X > -num73 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - num74;
- if (npc.velocity.X < -num73)
- {
- npc.velocity.X = -num73;
- }
- }
- }
- else if ((npc.type >= 430 && npc.type <= 436) || npc.type == 494 || npc.type == 495)
- {
- if (npc.ai[2] == 0f)
- {
- npc.damage = npc.defDamage;
- float num75 = 1f;
- num75 *= 1f + (1f - npc.scale);
- if (npc.velocity.X < -num75 || npc.velocity.X > num75)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < num75 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > num75)
- {
- npc.velocity.X = num75;
- }
- }
- else if (npc.velocity.X > -num75 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -num75)
- {
- npc.velocity.X = -num75;
- }
- }
- if (npc.velocity.Y == 0f && (!Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0) && !Main.player[npc.target].dead)
- {
- Vector2 vector13 = npc.Center - Main.player[npc.target].Center;
- int num76 = 50;
- if (npc.type >= 494 && npc.type <= 495)
- {
- num76 = 42;
- }
- if (vector13.Length() < (float)num76 && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
- {
- npc.velocity.X = npc.velocity.X * 0.7f;
- npc.ai[2] = 1f;
- }
- }
- }
- else
- {
- npc.damage = (int)((double)npc.defDamage * 1.5);
- npc.ai[3] = 1f;
- npc.velocity.X = npc.velocity.X * 0.9f;
- if ((double)Math.Abs(npc.velocity.X) < 0.1)
- {
- npc.velocity.X = 0f;
- }
- npc.ai[2] += 1f;
- if (npc.ai[2] >= 20f || npc.velocity.Y != 0f || (Main.dayTime && (double)npc.position.Y < Main.worldSurface * 16.0))
- {
- npc.ai[2] = 0f;
- }
- }
- }
- else if (npc.type != 110 && (npc.type != 111 || false) && npc.type != 206 && npc.type != 214 && npc.type != 215 && npc.type != 216 && npc.type != 290 && npc.type != 291 && npc.type != 292 && npc.type != 293 && npc.type != 350 && npc.type != 379 && npc.type != 380 && npc.type != 381 && npc.type != 382 && (npc.type < 449 || npc.type > 452) && npc.type != 468 && npc.type != 481 && npc.type != 411 && npc.type != 409 && (npc.type < 498 || npc.type > 506) && npc.type != 424 && npc.type != 426 && npc.type != 520)
- {
- float num77 = 1f;
- if (npc.type == 186)
- {
- num77 = 1.1f;
- }
- if (npc.type == 187)
- {
- num77 = 0.9f;
- }
- if (npc.type == 188)
- {
- num77 = 1.2f;
- }
- if (npc.type == 189)
- {
- num77 = 0.8f;
- }
- if (npc.type == 132)
- {
- num77 = 0.95f;
- }
- if (npc.type == 200)
- {
- num77 = 0.87f;
- }
- if (npc.type == 223)
- {
- num77 = 1.05f;
- }
- if (npc.type == 489)
- {
- float num78 = (Main.player[npc.target].Center - npc.Center).Length();
- num78 *= 0.0025f;
- if ((double)num78 > 1.5)
- {
- num78 = 1.5f;
- }
- if (Main.expertMode)
- {
- num77 = 3f - num78;
- }
- else
- {
- num77 = 2.5f - num78;
- }
- num77 *= 0.8f;
- }
- if (npc.type == 489 || npc.type == 3 || npc.type == 132 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 200 || npc.type == 223 || npc.type == 331 || npc.type == 332)
- {
- num77 *= 1f + (1f - npc.scale);
- }
- if (npc.velocity.X < -num77 || npc.velocity.X > num77)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= 0.8f;
- }
- }
- else if (npc.velocity.X < num77 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + 0.07f;
- if (npc.velocity.X > num77)
- {
- npc.velocity.X = num77;
- }
- }
- else if (npc.velocity.X > -num77 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - 0.07f;
- if (npc.velocity.X < -num77)
- {
- npc.velocity.X = -num77;
- }
- }
- }
- if (npc.type >= 277 && npc.type <= 280)
- {
- Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.2f, 0.1f, 0f);
- }
- else if (npc.type == 520)
- {
- Lighting.AddLight(npc.Top + new Vector2(0f, 20f), 0.3f, 0.3f, 0.7f);
- }
- else if (npc.type == 525)
- {
- Vector3 rgb = new Vector3(0.7f, 1f, 0.2f) * 0.5f;
- Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb);
- }
- else if (npc.type == 526)
- {
- Vector3 rgb2 = new Vector3(1f, 1f, 0.5f) * 0.4f;
- Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb2);
- }
- else if (npc.type == 527)
- {
- Vector3 rgb3 = new Vector3(0.6f, 0.3f, 1f) * 0.4f;
- Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb3);
- }
- else if (npc.type == 415)
- {
- npc.hide = false;
- for (int num79 = 0; num79 < 200; num79++)
- {
- if (Main.npc[num79].active && Main.npc[num79].type == 416 && Main.npc[num79].ai[0] == (float)npc.whoAmI)
- {
- npc.hide = true;
- break;
- }
- }
- }
- else if (npc.type == 258)
- {
- if (npc.velocity.Y != 0f)
- {
- npc.TargetClosest(true);
- npc.spriteDirection = npc.direction;
- if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.95f;
- }
- else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.95f;
- }
- if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > -5f)
- {
- npc.velocity.X = npc.velocity.X - 0.1f;
- }
- else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 5f)
- {
- npc.velocity.X = npc.velocity.X + 0.1f;
- }
- }
- else if (Main.player[npc.target].Center.Y + 50f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
- {
- npc.velocity.Y = -7f;
- }
- }
- else if (npc.type == 425)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.ai[2] = 0f;
- }
- if (npc.velocity.Y != 0f && npc.ai[2] == 1f)
- {
- npc.TargetClosest(true);
- npc.spriteDirection = -npc.direction;
- if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
- {
- float num80 = Main.player[npc.target].Center.X - (float)(npc.direction * 400) - npc.Center.X;
- float num81 = Main.player[npc.target].Bottom.Y - npc.Bottom.Y;
- if (num80 < 0f && npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- }
- else if (num80 > 0f && npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- }
- if (num80 < 0f && npc.velocity.X > -5f)
- {
- npc.velocity.X = npc.velocity.X - 0.1f;
- }
- else if (num80 > 0f && npc.velocity.X < 5f)
- {
- npc.velocity.X = npc.velocity.X + 0.1f;
- }
- if (npc.velocity.X > 6f)
- {
- npc.velocity.X = 6f;
- }
- if (npc.velocity.X < -6f)
- {
- npc.velocity.X = -6f;
- }
- if (num81 < -20f && npc.velocity.Y > 0f)
- {
- npc.velocity.Y = npc.velocity.Y * 0.8f;
- }
- else if (num81 > 20f && npc.velocity.Y < 0f)
- {
- npc.velocity.Y = npc.velocity.Y * 0.8f;
- }
- if (num81 < -20f && npc.velocity.Y > -5f)
- {
- npc.velocity.Y = npc.velocity.Y - 0.3f;
- }
- else if (num81 > 20f && npc.velocity.Y < 5f)
- {
- npc.velocity.Y = npc.velocity.Y + 0.3f;
- }
- }
- if (Main.rand.Next(3) == 0)
- {
- Vector2 position = npc.Center + new Vector2((float)(npc.direction * -14), -8f) - Vector2.One * 4f;
- Vector2 vector14 = new Vector2((float)(npc.direction * -6), 12f) * 0.2f + Utils.RandomVector2(Main.rand, -1f, 1f) * 0.1f;
- Dust expr_73D5 = Main.dust[Dust.NewDust(position, 8, 8, 229, vector14.X, vector14.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 0.5f)];
- expr_73D5.noGravity = true;
- expr_73D5.velocity = vector14;
- expr_73D5.customData = this;
- }
- for (int num82 = 0; num82 < 200; num82++)
- {
- if (num82 != npc.whoAmI && Main.npc[num82].active && Main.npc[num82].type == npc.type && Math.Abs(npc.position.X - Main.npc[num82].position.X) + Math.Abs(npc.position.Y - Main.npc[num82].position.Y) < (float)npc.width)
- {
- if (npc.position.X < Main.npc[num82].position.X)
- {
- npc.velocity.X = npc.velocity.X - 0.05f;
- }
- else
- {
- npc.velocity.X = npc.velocity.X + 0.05f;
- }
- if (npc.position.Y < Main.npc[num82].position.Y)
- {
- npc.velocity.Y = npc.velocity.Y - 0.05f;
- }
- else
- {
- npc.velocity.Y = npc.velocity.Y + 0.05f;
- }
- }
- }
- }
- else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
- {
- npc.velocity.Y = -5f;
- npc.ai[2] = 1f;
- }
- if (Main.netMode != 1)
- {
- npc.localAI[2] += 1f;
- if (npc.localAI[2] >= (float)(360 + Main.rand.Next(360)) && npc.Distance(Main.player[npc.target].Center) < 400f && Math.Abs(npc.DirectionTo(Main.player[npc.target].Center).Y) < 0.5f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
- {
- npc.localAI[2] = 0f;
- Vector2 vector15 = npc.Center + new Vector2((float)(npc.direction * 30), 2f);
- Vector2 vector16 = npc.DirectionTo(Main.player[npc.target].Center) * 7f;
- if (vector16.HasNaNs())
- {
- vector16 = new Vector2((float)(npc.direction * 8), 0f);
- }
- int num83 = Main.expertMode ? 50 : 75;
- for (int num84 = 0; num84 < 4; num84++)
- {
- Vector2 vector17 = vector16 + Utils.RandomVector2(Main.rand, -0.8f, 0.8f);
- Projectile.NewProjectile(vector15.X, vector15.Y, vector17.X, vector17.Y, 577, num83, 1f, Main.myPlayer, 0f, 0f);
- }
- }
- }
- }
- else if (npc.type == 427)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.ai[2] = 0f;
- npc.rotation = 0f;
- }
- else
- {
- npc.rotation = npc.velocity.X * 0.1f;
- }
- if (npc.velocity.Y != 0f && npc.ai[2] == 1f)
- {
- npc.TargetClosest(true);
- npc.spriteDirection = -npc.direction;
- if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
- {
- float num85 = Main.player[npc.target].Center.X - npc.Center.X;
- float num86 = Main.player[npc.target].Center.Y - npc.Center.Y;
- if (num85 < 0f && npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.98f;
- }
- else if (num85 > 0f && npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.98f;
- }
- if (num85 < -20f && npc.velocity.X > -6f)
- {
- npc.velocity.X = npc.velocity.X - 0.015f;
- }
- else if (num85 > 20f && npc.velocity.X < 6f)
- {
- npc.velocity.X = npc.velocity.X + 0.015f;
- }
- if (npc.velocity.X > 6f)
- {
- npc.velocity.X = 6f;
- }
- if (npc.velocity.X < -6f)
- {
- npc.velocity.X = -6f;
- }
- if (num86 < -20f && npc.velocity.Y > 0f)
- {
- npc.velocity.Y = npc.velocity.Y * 0.98f;
- }
- else if (num86 > 20f && npc.velocity.Y < 0f)
- {
- npc.velocity.Y = npc.velocity.Y * 0.98f;
- }
- if (num86 < -20f && npc.velocity.Y > -6f)
- {
- npc.velocity.Y = npc.velocity.Y - 0.15f;
- }
- else if (num86 > 20f && npc.velocity.Y < 6f)
- {
- npc.velocity.Y = npc.velocity.Y + 0.15f;
- }
- }
- for (int num87 = 0; num87 < 200; num87++)
- {
- if (num87 != npc.whoAmI && Main.npc[num87].active && Main.npc[num87].type == npc.type && Math.Abs(npc.position.X - Main.npc[num87].position.X) + Math.Abs(npc.position.Y - Main.npc[num87].position.Y) < (float)npc.width)
- {
- if (npc.position.X < Main.npc[num87].position.X)
- {
- npc.velocity.X = npc.velocity.X - 0.05f;
- }
- else
- {
- npc.velocity.X = npc.velocity.X + 0.05f;
- }
- if (npc.position.Y < Main.npc[num87].position.Y)
- {
- npc.velocity.Y = npc.velocity.Y - 0.05f;
- }
- else
- {
- npc.velocity.Y = npc.velocity.Y + 0.05f;
- }
- }
- }
- }
- else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
- {
- npc.velocity.Y = -5f;
- npc.ai[2] = 1f;
- }
- }
- else if (npc.type == 426)
- {
- if (npc.ai[1] > 0f && npc.velocity.Y > 0f)
- {
- npc.velocity.Y = npc.velocity.Y * 0.85f;
- if (npc.velocity.Y == 0f)
- {
- npc.velocity.Y = -0.4f;
- }
- }
- if (npc.velocity.Y != 0f)
- {
- npc.TargetClosest(true);
- npc.spriteDirection = npc.direction;
- if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
- {
- float num88 = Main.player[npc.target].Center.X - (float)(npc.direction * 300) - npc.Center.X;
- if (num88 < 40f && npc.velocity.X > 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.98f;
- }
- else if (num88 > 40f && npc.velocity.X < 0f)
- {
- npc.velocity.X = npc.velocity.X * 0.98f;
- }
- if (num88 < 40f && npc.velocity.X > -5f)
- {
- npc.velocity.X = npc.velocity.X - 0.2f;
- }
- else if (num88 > 40f && npc.velocity.X < 5f)
- {
- npc.velocity.X = npc.velocity.X + 0.2f;
- }
- if (npc.velocity.X > 6f)
- {
- npc.velocity.X = 6f;
- }
- if (npc.velocity.X < -6f)
- {
- npc.velocity.X = -6f;
- }
- }
- }
- else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
- {
- npc.velocity.Y = -6f;
- }
- for (int num89 = 0; num89 < 200; num89++)
- {
- if (num89 != npc.whoAmI && Main.npc[num89].active && Main.npc[num89].type == npc.type && Math.Abs(npc.position.X - Main.npc[num89].position.X) + Math.Abs(npc.position.Y - Main.npc[num89].position.Y) < (float)npc.width)
- {
- if (npc.position.X < Main.npc[num89].position.X)
- {
- npc.velocity.X = npc.velocity.X - 0.1f;
- }
- else
- {
- npc.velocity.X = npc.velocity.X + 0.1f;
- }
- if (npc.position.Y < Main.npc[num89].position.Y)
- {
- npc.velocity.Y = npc.velocity.Y - 0.1f;
- }
- else
- {
- npc.velocity.Y = npc.velocity.Y + 0.1f;
- }
- }
- }
- if (Main.rand.Next(6) == 0 && npc.ai[1] <= 20f)
- {
- Dust expr_80E3 = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, 229, npc.velocity.X, npc.velocity.Y, 100, default(Color), 1f)];
- expr_80E3.velocity = expr_80E3.velocity / 4f + npc.velocity / 2f;
- expr_80E3.scale = 0.6f;
- expr_80E3.noLight = true;
- }
- if (npc.ai[1] >= 57f)
- {
- int num90 = Utils.SelectRandom<int>(Main.rand, new int[]
- {
- 161,
- 229
- });
- Dust expr_81AD = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, num90, npc.velocity.X, npc.velocity.Y, 100, default(Color), 1f)];
- expr_81AD.velocity = expr_81AD.velocity / 4f + npc.DirectionTo(Main.player[npc.target].Top);
- expr_81AD.scale = 1.2f;
- expr_81AD.noLight = true;
- }
- if (Main.rand.Next(6) == 0)
- {
- Dust dust6 = Main.dust[Dust.NewDust(npc.Center, 2, 2, 229, 0f, 0f, 0, default(Color), 1f)];
- dust6.position = npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 26 : -26), 24f);
- dust6.velocity.X = 0f;
- if (dust6.velocity.Y < 0f)
- {
- dust6.velocity.Y = 0f;
- }
- dust6.noGravity = true;
- dust6.scale = 1f;
- dust6.noLight = true;
- }
- }
- else if (npc.type == 185)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.rotation = 0f;
- npc.localAI[0] = 0f;
- }
- else if (npc.localAI[0] == 1f)
- {
- npc.rotation += npc.velocity.X * 0.05f;
- }
- }
- else if (npc.type == 428)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.rotation = 0f;
- }
- else
- {
- npc.rotation += npc.velocity.X * 0.08f;
- }
- }
- if (npc.type == 159 && Main.netMode != 1)
- {
- Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
- float arg_842C_0 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector18.X;
- float num91 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector18.Y;
- if ((float)Math.Sqrt((double)(arg_842C_0 * arg_842C_0 + num91 * num91)) > 300f)
- {
- npc.Transform(158);
- }
- }
- if (npc.type == 164 && Main.netMode != 1 && npc.velocity.Y == 0f)
- {
- int num92 = (int)npc.Center.X / 16;
- int num93 = (int)npc.Center.Y / 16;
- bool flag9 = false;
- for (int num94 = num92 - 1; num94 <= num92 + 1; num94++)
- {
- for (int num95 = num93 - 1; num95 <= num93 + 1; num95++)
- {
- if (Main.tile[num94, num95].wall > 0)
- {
- flag9 = true;
- }
- }
- }
- if (flag9)
- {
- npc.Transform(165);
- }
- }
- if (npc.type == 239 && Main.netMode != 1 && npc.velocity.Y == 0f)
- {
- int num96 = (int)npc.Center.X / 16;
- int num97 = (int)npc.Center.Y / 16;
- bool flag10 = false;
- for (int num98 = num96 - 1; num98 <= num96 + 1; num98++)
- {
- for (int num99 = num97 - 1; num99 <= num97 + 1; num99++)
- {
- if (Main.tile[num98, num99].wall > 0)
- {
- flag10 = true;
- }
- }
- }
- if (flag10)
- {
- npc.Transform(240);
- }
- }
- if (npc.type == 530 && Main.netMode != 1 && npc.velocity.Y == 0f)
- {
- int num100 = (int)npc.Center.X / 16;
- int num101 = (int)npc.Center.Y / 16;
- bool flag11 = false;
- for (int num102 = num100 - 1; num102 <= num100 + 1; num102++)
- {
- for (int num103 = num101 - 1; num103 <= num101 + 1; num103++)
- {
- if (Main.tile[num102, num103].wall > 0)
- {
- flag11 = true;
- }
- }
- }
- if (flag11)
- {
- npc.Transform(531);
- }
- }
- if (Main.netMode != 1 && Main.expertMode && npc.target >= 0 && (npc.type == 163 || npc.type == 238) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1))
- {
- npc.localAI[0] += 1f;
- if (npc.justHit)
- {
- npc.localAI[0] -= (float)Main.rand.Next(20, 60);
- if (npc.localAI[0] < 0f)
- {
- npc.localAI[0] = 0f;
- }
- }
- if (npc.localAI[0] > (float)Main.rand.Next(180, 900))
- {
- npc.localAI[0] = 0f;
- Vector2 vector19 = Main.player[npc.target].Center - npc.Center;
- vector19.Normalize();
- vector19 *= 8f;
- Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector19.X, vector19.Y, 472, 18, 0f, Main.myPlayer, 0f, 0f);
- }
- }
- if (npc.type == 163 && Main.netMode != 1 && npc.velocity.Y == 0f)
- {
- int num104 = (int)npc.Center.X / 16;
- int num105 = (int)npc.Center.Y / 16;
- bool flag12 = false;
- for (int num106 = num104 - 1; num106 <= num104 + 1; num106++)
- {
- for (int num107 = num105 - 1; num107 <= num105 + 1; num107++)
- {
- if (Main.tile[num106, num107].wall > 0)
- {
- flag12 = true;
- }
- }
- }
- if (flag12)
- {
- npc.Transform(238);
- }
- }
- if (npc.type == 236 && Main.netMode != 1 && npc.velocity.Y == 0f)
- {
- int num108 = (int)npc.Center.X / 16;
- int num109 = (int)npc.Center.Y / 16;
- bool flag13 = false;
- for (int num110 = num108 - 1; num110 <= num108 + 1; num110++)
- {
- for (int num111 = num109 - 1; num111 <= num109 + 1; num111++)
- {
- if (Main.tile[num110, num111].wall > 0)
- {
- flag13 = true;
- }
- }
- }
- if (flag13)
- {
- npc.Transform(237);
- }
- }
- if (npc.type == 243)
- {
- if (npc.justHit && Main.rand.Next(3) == 0)
- {
- npc.ai[2] -= (float)Main.rand.Next(30);
- }
- if (npc.ai[2] < 0f)
- {
- npc.ai[2] = 0f;
- }
- if (npc.confused)
- {
- npc.ai[2] = 0f;
- }
- npc.ai[2] += 1f;
- float num112 = (float)Main.rand.Next(30, 900);
- num112 *= (float)npc.life / (float)npc.lifeMax;
- num112 += 30f;
- if (Main.netMode != 1 && npc.ai[2] >= num112 && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
- {
- float arg_8BB1_0 = 15f;
- Vector2 vector20 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + 20f);
- vector20.X += (float)(10 * npc.direction);
- float num113 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector20.X;
- float num114 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector20.Y;
- num113 += (float)Main.rand.Next(-40, 41);
- num114 += (float)Main.rand.Next(-40, 41);
- float num115 = (float)Math.Sqrt((double)(num113 * num113 + num114 * num114));
- npc.netUpdate = true;
- num115 = arg_8BB1_0 / num115;
- num113 *= num115;
- num114 *= num115;
- int num116 = 32;
- int num117 = 257;
- vector20.X += num113 * 3f;
- vector20.Y += num114 * 3f;
- Projectile.NewProjectile(vector20.X, vector20.Y, num113, num114, num117, num116, 0f, Main.myPlayer, 0f, 0f);
- npc.ai[2] = 0f;
- }
- }
- if (npc.type == 251)
- {
- if (npc.justHit)
- {
- npc.ai[2] -= (float)Main.rand.Next(30);
- }
- if (npc.ai[2] < 0f)
- {
- npc.ai[2] = 0f;
- }
- if (npc.confused)
- {
- npc.ai[2] = 0f;
- }
- npc.ai[2] += 1f;
- float num118 = (float)Main.rand.Next(60, 1800);
- num118 *= (float)npc.life / (float)npc.lifeMax;
- num118 += 15f;
- if (Main.netMode != 1 && npc.ai[2] >= num118 && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height))
- {
- float arg_8EE5_0 = 15f;
- Vector2 vector21 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + 12f);
- vector21.X += (float)(6 * npc.direction);
- float num119 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector21.X;
- float num120 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector21.Y;
- num119 += (float)Main.rand.Next(-40, 41);
- num120 += (float)Main.rand.Next(-30, 0);
- float num121 = (float)Math.Sqrt((double)(num119 * num119 + num120 * num120));
- npc.netUpdate = true;
- num121 = arg_8EE5_0 / num121;
- num119 *= num121;
- num120 *= num121;
- int num122 = 30;
- int num123 = 83;
- vector21.X += num119 * 3f;
- vector21.Y += num120 * 3f;
- Projectile.NewProjectile(vector21.X, vector21.Y, num119, num120, num123, num122, 0f, Main.myPlayer, 0f, 0f);
- npc.ai[2] = 0f;
- }
- }
- if (npc.type == 386)
- {
- if (npc.confused)
- {
- npc.ai[2] = -60f;
- }
- else
- {
- if (npc.ai[2] < 60f)
- {
- npc.ai[2] += 1f;
- }
- if (npc.ai[2] > 0f && NPC.CountNPCS(387) >= 4 * NPC.CountNPCS(386))
- {
- npc.ai[2] = 0f;
- }
- if (npc.justHit)
- {
- npc.ai[2] = -30f;
- }
- if (npc.ai[2] == 30f)
- {
- int num124 = (int)npc.position.X / 16;
- int num125 = (int)npc.position.Y / 16;
- int num126 = (int)npc.position.X / 16;
- int num127 = (int)npc.position.Y / 16;
- int num128 = 5;
- int num129 = 0;
- bool flag14 = false;
- int num130 = 2;
- int num131 = 0;
- while (!flag14 && num129 < 100)
- {
- num129++;
- int num132 = Main.rand.Next(num124 - num128, num124 + num128);
- for (int num133 = Main.rand.Next(num125 - num128, num125 + num128); num133 < num125 + num128; num133++)
- {
- if ((num133 < num125 - num130 || num133 > num125 + num130 || num132 < num124 - num130 || num132 > num124 + num130) && (num133 < num127 - num131 || num133 > num127 + num131 || num132 < num126 - num131 || num132 > num126 + num131) && Main.tile[num132, num133].nactive())
- {
- bool flag15 = true;
- if (Main.tile[num132, num133 - 1].lava())
- {
- flag15 = false;
- }
- if (flag15 && Main.tileSolid[(int)Main.tile[num132, num133].type] && !Collision.SolidTiles(num132 - 1, num132 + 1, num133 - 4, num133 - 1))
- {
- int num134 = NPC.NewNPC(num132 * 16 - npc.width / 2, num133 * 16, 387, 0, 0f, 0f, 0f, 0f, 255);
- Main.npc[num134].position.Y = (float)(num133 * 16 - Main.npc[num134].height);
- flag14 = true;
- npc.netUpdate = true;
- break;
- }
- }
- }
- }
- }
- if (npc.ai[2] == 60f)
- {
- npc.ai[2] = -120f;
- }
- }
- }
- if (npc.type == 389)
- {
- if (npc.confused)
- {
- npc.ai[2] = -60f;
- }
- else
- {
- if (npc.ai[2] < 20f)
- {
- npc.ai[2] += 1f;
- }
- if (npc.justHit)
- {
- npc.ai[2] = -30f;
- }
- if (npc.ai[2] == 20f && Main.netMode != 1)
- {
- npc.ai[2] = (float)(-10 + Main.rand.Next(3) * -10);
- Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 8f, (float)(npc.direction * 6), 0f, 437, 25, 1f, Main.myPlayer, 0f, 0f);
- }
- }
- }
- if (npc.type == 110 || (npc.type == 111 || true) || npc.type == 206 || npc.type == 214 || npc.type == 215 || npc.type == 216 || npc.type == 290 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 350 || npc.type == 379 || npc.type == 380 || npc.type == 381 || npc.type == 382 || (npc.type >= 449 && npc.type <= 452) || (npc.type == 468 || npc.type == 481 || npc.type == 411 || npc.type == 409 || (npc.type >= 498 && npc.type <= 506)) || npc.type == 424 || npc.type == 426 || npc.type == 520)
- {
- bool flag16 = npc.type == 381 || npc.type == 382 || npc.type == 520;
- bool flag17 = npc.type == 426;
- bool flag18 = true;
- int num135 = -1;
- int num136 = -1;
- if (npc.type == 411)
- {
- flag16 = true;
- num135 = 90;
- num136 = 90;
- if (npc.ai[1] <= 150f)
- {
- flag18 = false;
- }
- }
- if (npc.confused)
- {
- npc.ai[2] = 0f;
- }
- else
- {
- if (npc.ai[1] > 0f)
- {
- npc.ai[1] -= 1f;
- }
- if (npc.justHit)
- {
- npc.ai[1] = 30f;
- npc.ai[2] = 0f;
- }
- int num137 = 70;
- if (npc.type == 379 || npc.type == 380)
- {
- num137 = 80;
- }
- if (npc.type == 381 || npc.type == 382)
- {
- num137 = 80;
- }
- if (npc.type == 520)
- {
- num137 = 15;
- }
- if (npc.type == 350)
- {
- num137 = 110;
- }
- if (npc.type == 291)
- {
- num137 = 200;
- }
- if (npc.type == 292)
- {
- num137 = 120;
- }
- if (npc.type == 293)
- {
- num137 = 90;
- }
- if (npc.type == 111 || true)
- {
- num137 = 180;
- }
- if (npc.type == 206)
- {
- num137 = 50;
- }
- if (npc.type == 481)
- {
- num137 = 100;
- }
- if (npc.type == 214)
- {
- num137 = 40;
- }
- if (npc.type == 215)
- {
- num137 = 80;
- }
- if (npc.type == 290)
- {
- num137 = 30;
- }
- if (npc.type == 411)
- {
- num137 = 300;
- }
- if (npc.type == 409)
- {
- num137 = 60;
- }
- if (npc.type == 424)
- {
- num137 = 180;
- }
- if (npc.type == 426)
- {
- num137 = 60;
- }
- bool flag19 = false;
- if (npc.type == 216)
- {
- if (npc.localAI[2] >= 20f)
- {
- flag19 = true;
- }
- if (flag19)
- {
- num137 = 60;
- }
- else
- {
- num137 = 8;
- }
- }
- int num138 = num137 / 2;
- if (npc.type == 424)
- {
- num138 = num137 - 1;
- }
- if (npc.type == 426)
- {
- num138 = num137 - 1;
- }
- if (npc.ai[2] > 0f)
- {
- if (flag18)
- {
- npc.TargetClosest(true);
- }
- if (npc.ai[1] == (float)num138)
- {
- if (npc.type == 216)
- {
- npc.localAI[2] += 1f;
- }
- float num139 = 11f;
- if (npc.type == 111 || true)
- {
- num139 = 9f;
- }
- if (npc.type == 206)
- {
- num139 = 7f;
- }
- if (npc.type == 290)
- {
- num139 = 9f;
- }
- if (npc.type == 293)
- {
- num139 = 4f;
- }
- if (npc.type == 214)
- {
- num139 = 14f;
- }
- if (npc.type == 215)
- {
- num139 = 50f;
- }
- if (npc.type == 382)
- {
- num139 = 7f;
- }
- if (npc.type == 520)
- {
- num139 = 8f;
- }
- if (npc.type == 409)
- {
- num139 = 4f;
- }
- if (npc.type >= 449 && npc.type <= 452)
- {
- num139 = 7f;
- }
- if (npc.type == 481)
- {
- num139 = 8f;
- }
- if (npc.type == 468)
- {
- num139 = 7.5f;
- }
- if (npc.type == 411)
- {
- num139 = 1f;
- }
- if (npc.type >= 498 && npc.type <= 506)
- {
- num139 = 7f;
- }
- Vector2 vector22 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
- if (npc.type == 481)
- {
- vector22.Y -= 14f;
- }
- if (npc.type == 206)
- {
- vector22.Y -= 10f;
- }
- if (npc.type == 290)
- {
- vector22.Y -= 10f;
- }
- if (npc.type == 381 || npc.type == 382)
- {
- vector22.Y += 6f;
- }
- if (npc.type == 520)
- {
- vector22.Y = npc.position.Y + 20f;
- }
- if (npc.type >= 498 && npc.type <= 506)
- {
- vector22.Y -= 8f;
- }
- if (npc.type == 426)
- {
- vector22 += new Vector2((float)(npc.spriteDirection * 2), -12f);
- }
- float num140 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * .5f - vector22.X;
- float num141 = Math.Abs(num140) * 0.1f;
- if (npc.type == 291 || npc.type == 292)
- {
- num141 = 0f;
- }
- if (npc.type == 215)
- {
- num141 = Math.Abs(num140) * .5f;
- }
- if (npc.type == 214 || (npc.type == 216 && !flag19))
- {
- num141 = 0f;
- }
- if (npc.type == 381 || npc.type == 382 || npc.type == 520)
- {
- num141 = 0f;
- }
- if (npc.type >= 449 && npc.type <= 452)
- {
- num141 = Math.Abs(num140) * (float)Main.rand.Next(10, 50) * 0.01f;
- }
- if (npc.type == 468)
- {
- num141 = Math.Abs(num140) * (float)Main.rand.Next(10, 50) * 0.01f;
- }
- if (npc.type == 481)
- {
- num141 = Math.Abs(num140) * (float)Main.rand.Next(-10, 11) * 0.0035f;
- }
- if (npc.type >= 498 && npc.type <= 506)
- {
- num141 = Math.Abs(num140) * (float)Main.rand.Next(1, 11) * 0.0025f;
- }
- float num142 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector22.Y - num141;
- if (npc.type == 291)
- {
- num140 += (float)Main.rand.Next(-40, 41) * 0.2f;
- num142 += (float)Main.rand.Next(-40, 41) * 0.2f;
- }
- else if (npc.type == 381 || npc.type == 382 || npc.type == 520)
- {
- num140 += (float)Main.rand.Next(-100, 101) * 0.4f;
- num142 += (float)Main.rand.Next(-100, 101) * 0.4f;
- num140 *= (float)Main.rand.Next(85, 116) * 0.01f;
- num142 *= (float)Main.rand.Next(85, 116) * 0.01f;
- if (npc.type == 520)
- {
- num140 += (float)Main.rand.Next(-100, 101) * 0.6f;
- num142 += (float)Main.rand.Next(-100, 101) * 0.6f;
- num140 *= (float)Main.rand.Next(85, 116) * 0.015f;
- num142 *= (float)Main.rand.Next(85, 116) * 0.015f;
- }
- }
- else if (npc.type == 481)
- {
- num140 += (float)Main.rand.Next(-40, 41) * 0.4f;
- num142 += (float)Main.rand.Next(-40, 41) * 0.4f;
- }
- else if (npc.type >= 498 && npc.type <= 506)
- {
- num140 += (float)Main.rand.Next(-40, 41) * 0.3f;
- num142 += (float)Main.rand.Next(-40, 41) * 0.3f;
- }
- else if (npc.type != 292)
- {
- num140 += (float)Main.rand.Next(-40, 41);
- num142 += (float)Main.rand.Next(-40, 41);
- }
- float num143 = (float)Math.Sqrt((double)(num140 * num140 + num142 * num142));
- npc.netUpdate = true;
- num143 = num139 / num143;
- num140 *= num143;
- num142 *= num143;
- int num144 = 35;
- int num145 = 82;
- if (npc.type == 111 || true)
- {
- num144 = 11;
- }
- if (npc.type == 206)
- {
- num144 = 37;
- }
- if (npc.type == 379 || npc.type == 380)
- {
- num144 = 40;
- }
- if (npc.type == 350)
- {
- num144 = 45;
- }
- if (npc.type == 468)
- {
- num144 = 50;
- }
- if (npc.type == 111 || true)
- {
- num145 = mod.ProjectileType("FBIbullet");
- }
- if (npc.type == 379 || npc.type == 380)
- {
- num145 = 81;
- }
- if (npc.type == 381)
- {
- num145 = 436;
- num144 = 24;
- }
- if (npc.type == 382)
- {
- num145 = 438;
- num144 = 30;
- }
- if (npc.type == 520)
- {
- num145 = 592;
- num144 = 35;
- }
- if (npc.type >= 449 && npc.type <= 452)
- {
- num145 = 471;
- num144 = 20;
- }
- if (npc.type >= 498 && npc.type <= 506)
- {
- num145 = 572;
- num144 = 14;
- }
- if (npc.type == 481)
- {
- num145 = 508;
- num144 = 18;
- }
- if (npc.type == 206)
- {
- num145 = 177;
- }
- if (npc.type == 468)
- {
- num145 = 501;
- }
- if (npc.type == 411)
- {
- num145 = 537;
- num144 = (Main.expertMode ? 45 : 60);
- }
- if (npc.type == 424)
- {
- num145 = 573;
- num144 = (Main.expertMode ? 45 : 60);
- }
- if (npc.type == 426)
- {
- num145 = 581;
- num144 = (Main.expertMode ? 45 : 60);
- }
- if (npc.type == 291)
- {
- num145 = 302;
- num144 = 100;
- }
- if (npc.type == 290)
- {
- num145 = 300;
- num144 = 60;
- }
- if (npc.type == 293)
- {
- num145 = 303;
- num144 = 60;
- }
- if (npc.type == 214)
- {
- num145 = 180;
- num144 = 25;
- }
- if (npc.type == 215)
- {
- num145 = mod.ProjectileType("FBIbullet");
- num144 = 40;
- }
- if (npc.type == 292)
- {
- num144 = 50;
- num145 = 180;
- }
- if (npc.type == 216)
- {
- num145 = 180;
- num144 = 30;
- if (flag19)
- {
- num144 = 100;
- num145 = 240;
- npc.localAI[2] = 0f;
- }
- }
- vector22.X += num140;
- vector22.Y += num142;
- if (Main.expertMode && npc.type == 290)
- {
- num144 = (int)((double)num144 * 0.75);
- }
- if (Main.expertMode && npc.type >= 381 && npc.type <= 392)
- {
- num144 = (int)((double)num144 * 0.8);
- }
- if (Main.netMode != 1)
- {
- if (npc.type == 292)
- {
- for (int num146 = 0; num146 < 4; num146++)
- {
- num140 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector22.X;
- num142 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector22.Y;
- num143 = (float)Math.Sqrt((double)(num140 * num140 + num142 * num142));
- num143 = 12f / num143;
- num140 += (float)Main.rand.Next(-40, 41);
- num142 += (float)Main.rand.Next(-40, 41);
- num140 *= num143;
- num142 *= num143;
- Projectile.NewProjectile(vector22.X, vector22.Y, num140, num142, num145, num144, 0f, Main.myPlayer, 0f, 0f);
- }
- }
- else if (npc.type == 411)
- {
- Projectile.NewProjectile(vector22.X, vector22.Y, num140, num142, num145, num144, 0f, Main.myPlayer, 0f, (float)npc.whoAmI);
- }
- else if (npc.type == 424)
- {
- for (int num147 = 0; num147 < 4; num147++)
- {
- Projectile.NewProjectile(npc.Center.X - (float)(npc.spriteDirection * 4), npc.Center.Y + 6f, (float)(-3 + 2 * num147) * 0.15f, -(float)Main.rand.Next(0, 3) * 0.2f - 0.1f, num145, num144, 0f, Main.myPlayer, 0f, (float)npc.whoAmI);
- }
- }
- else if (npc.type == 409)
- {
- int num148 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 410, npc.whoAmI, 0f, 0f, 0f, 0f, 255);
- Main.npc[num148].velocity = new Vector2(num140, -6f + num142);
- }
- else
- {
- Projectile.NewProjectile(vector22.X, vector22.Y, num140, num142, num145, num144, 0f, Main.myPlayer, 0f, 0f);
- }
- }
- if (Math.Abs(num142) > Math.Abs(num140) * 2f)
- {
- if (num142 > 0f)
- {
- npc.ai[2] = 1f;
- }
- else
- {
- npc.ai[2] = 5f;
- }
- }
- else if (Math.Abs(num140) > Math.Abs(num142) * 2f)
- {
- npc.ai[2] = 3f;
- }
- else if (num142 > 0f)
- {
- npc.ai[2] = 2f;
- }
- else
- {
- npc.ai[2] = 4f;
- }
- }
- if ((npc.velocity.Y != 0f && !flag17) || npc.ai[1] <= 0f)
- {
- npc.ai[2] = 0f;
- npc.ai[1] = 0f;
- }
- else if (!flag16 || (num135 != -1 && npc.ai[1] >= (float)num135 && npc.ai[1] < (float)(num135 + num136) && (!flag17 || npc.velocity.Y == 0f)))
- {
- npc.velocity.X = npc.velocity.X * 0.9f;
- npc.spriteDirection = npc.direction;
- }
- }
- if (npc.type == 468 && !Main.eclipse)
- {
- flag16 = true;
- }
- else if ((npc.ai[2] <= 0f | flag16) && (npc.velocity.Y == 0f | flag17) && npc.ai[1] <= 0f && !Main.player[npc.target].dead)
- {
- bool flag20 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height);
- if (npc.type == 520)
- {
- flag20 = Collision.CanHitLine(npc.Top + new Vector2(0f, 20f), 0, 0, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height);
- }
- if (Main.player[npc.target].stealth == 0f && Main.player[npc.target].itemAnimation == 0)
- {
- flag20 = false;
- }
- if (flag20)
- {
- float num149 = 10f;
- Vector2 vector23 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f);
- float num150 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector23.X;
- float num151 = Math.Abs(num150) * 0.1f;
- float num152 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector23.Y - num151;
- num150 += (float)Main.rand.Next(-40, 41);
- num152 += (float)Main.rand.Next(-40, 41);
- float num153 = (float)Math.Sqrt((double)(num150 * num150 + num152 * num152));
- float num154 = 700f;
- if (npc.type == 214)
- {
- num154 = 550f;
- }
- if (npc.type == 215)
- {
- num154 = 1500f;
- }
- if (npc.type >= 498 && npc.type <= 506)
- {
- num154 = 190f;
- }
- if (npc.type >= 449 && npc.type <= 452)
- {
- num154 = 200f;
- }
- if (npc.type == 481)
- {
- num154 = 400f;
- }
- if (npc.type == 468)
- {
- num154 = 400f;
- }
- if (num153 < num154)
- {
- npc.netUpdate = true;
- npc.velocity.X = npc.velocity.X * 0.5f;
- num153 = num149 / num153;
- num150 *= num153;
- num152 *= num153;
- npc.ai[2] = 3f;
- npc.ai[1] = (float)num137;
- if (Math.Abs(num152) > Math.Abs(num150) * 2f)
- {
- if (num152 > 0f)
- {
- npc.ai[2] = 1f;
- }
- else
- {
- npc.ai[2] = 5f;
- }
- }
- else if (Math.Abs(num150) > Math.Abs(num152) * 2f)
- {
- npc.ai[2] = 3f;
- }
- else if (num152 > 0f)
- {
- npc.ai[2] = 2f;
- }
- else
- {
- npc.ai[2] = 4f;
- }
- }
- }
- }
- if (npc.ai[2] <= 0f || (flag16 && (num135 == -1 || npc.ai[1] < (float)num135 || npc.ai[1] >= (float)(num135 + num136))))
- {
- float num155 = 1f;
- float num156 = 0.07f;
- float scaleFactor6 = 0.8f;
- if (npc.type == 214)
- {
- num155 = 2f;
- num156 = 0.09f;
- }
- else if (npc.type == 215)
- {
- num155 = 1f;
- num156 = 1f;
- }
- else if (npc.type == 381 || npc.type == 382)
- {
- num155 = 2f;
- num156 = 0.5f;
- }
- else if (npc.type == 520)
- {
- num155 = 4f;
- num156 = 1f;
- scaleFactor6 = 0.7f;
- }
- else if (npc.type == 411)
- {
- num155 = 2f;
- num156 = 0.5f;
- }
- else if (npc.type == 409)
- {
- num155 = 2f;
- num156 = 0.5f;
- }
- bool flag21 = false;
- if ((npc.type == 381 || npc.type == 382) && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 300f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
- {
- flag21 = true;
- npc.ai[3] = 0f;
- }
- if (npc.type == 520 && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 400f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0))
- {
- flag21 = true;
- npc.ai[3] = 0f;
- }
- if ((npc.velocity.X < -num155 || npc.velocity.X > num155) | flag21)
- {
- if (npc.velocity.Y == 0f)
- {
- npc.velocity *= scaleFactor6;
- }
- }
- else if (npc.velocity.X < num155 && npc.direction == 1)
- {
- npc.velocity.X = npc.velocity.X + num156;
- if (npc.velocity.X > num155)
- {
- npc.velocity.X = num155;
- }
- }
- else if (npc.velocity.X > -num155 && npc.direction == -1)
- {
- npc.velocity.X = npc.velocity.X - num156;
- if (npc.velocity.X < -num155)
- {
- npc.velocity.X = -num155;
- }
- }
- }
- if (npc.type == 520)
- {
- npc.localAI[2] += 1f;
- if (npc.localAI[2] >= 6f)
- {
- npc.localAI[2] = 0f;
- npc.localAI[3] = Main.player[npc.target].DirectionFrom(npc.Top + new Vector2(0f, 20f)).ToRotation();
- }
- }
- }
- }
- if (npc.type == 109 && Main.netMode != 1 && !Main.player[npc.target].dead)
- {
- if (npc.justHit)
- {
- npc.ai[2] = 0f;
- }
- npc.ai[2] += 1f;
- if (npc.ai[2] > 450f)
- {
- Vector2 vector24 = new Vector2(npc.position.X + (float)npc.width * 0.5f - (float)(npc.direction * 24), npc.position.Y + 4f);
- int num157 = 3 * npc.direction;
- int num158 = -5;
- int num159 = Projectile.NewProjectile(vector24.X, vector24.Y, (float)num157, (float)num158, 75, 0, 0f, Main.myPlayer, 0f, 0f);
- Main.projectile[num159].timeLeft = 300;
- npc.ai[2] = 0f;
- }
- }
- bool flag22 = false;
- if (npc.velocity.Y == 0f)
- {
- int num160 = (int)(npc.position.Y + (float)npc.height + 7f) / 16;
- int arg_AD06_0 = (int)npc.position.X / 16;
- int num161 = (int)(npc.position.X + (float)npc.width) / 16;
- for (int num162 = arg_AD06_0; num162 <= num161; num162++)
- {
- if (Main.tile[num162, num160] == null)
- {
- return;
- }
- if (Main.tile[num162, num160].nactive() && Main.tileSolid[(int)Main.tile[num162, num160].type])
- {
- flag22 = true;
- break;
- }
- }
- }
- if (npc.type == 428)
- {
- flag22 = false;
- }
- if (npc.velocity.Y >= 0f)
- {
- int num163 = 0;
- if (npc.velocity.X < 0f)
- {
- num163 = -1;
- }
- if (npc.velocity.X > 0f)
- {
- num163 = 1;
- }
- Vector2 position2 = npc.position;
- position2.X += npc.velocity.X;
- int num164 = (int)((position2.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num163)) / 16f);
- int num165 = (int)((position2.Y + (float)npc.height - 1f) / 16f);
- if (Main.tile[num164, num165] == null)
- {
- Main.tile[num164, num165] = new Tile();
- }
- if (Main.tile[num164, num165 - 1] == null)
- {
- Main.tile[num164, num165 - 1] = new Tile();
- }
- if (Main.tile[num164, num165 - 2] == null)
- {
- Main.tile[num164, num165 - 2] = new Tile();
- }
- if (Main.tile[num164, num165 - 3] == null)
- {
- Main.tile[num164, num165 - 3] = new Tile();
- }
- if (Main.tile[num164, num165 + 1] == null)
- {
- Main.tile[num164, num165 + 1] = new Tile();
- }
- if (Main.tile[num164 - num163, num165 - 3] == null)
- {
- Main.tile[num164 - num163, num165 - 3] = new Tile();
- }
- if ((float)(num164 * 16) < position2.X + (float)npc.width && (float)(num164 * 16 + 16) > position2.X && ((Main.tile[num164, num165].nactive() && !Main.tile[num164, num165].topSlope() && !Main.tile[num164, num165 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num164, num165].type] && !Main.tileSolidTop[(int)Main.tile[num164, num165].type]) || (Main.tile[num164, num165 - 1].halfBrick() && Main.tile[num164, num165 - 1].nactive())) && (!Main.tile[num164, num165 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 1].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 1].type] || (Main.tile[num164, num165 - 1].halfBrick() && (!Main.tile[num164, num165 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 4].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 4].type]))) && (!Main.tile[num164, num165 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 2].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 2].type]) && (!Main.tile[num164, num165 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num164, num165 - 3].type] || Main.tileSolidTop[(int)Main.tile[num164, num165 - 3].type]) && (!Main.tile[num164 - num163, num165 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num164 - num163, num165 - 3].type]))
- {
- float num166 = (float)(num165 * 16);
- if (Main.tile[num164, num165].halfBrick())
- {
- num166 += 8f;
- }
- if (Main.tile[num164, num165 - 1].halfBrick())
- {
- num166 -= 8f;
- }
- if (num166 < position2.Y + (float)npc.height)
- {
- float num167 = position2.Y + (float)npc.height - num166;
- float num168 = 16.1f;
- if (npc.type == 163 || npc.type == 164 || npc.type == 236 || npc.type == 239 || npc.type == 530)
- {
- num168 += 8f;
- }
- if (num167 <= num168)
- {
- npc.gfxOffY += npc.position.Y + (float)npc.height - num166;
- npc.position.Y = num166 - (float)npc.height;
- if (num167 < 9f)
- {
- npc.stepSpeed = 4f;
- }
- else
- {
- npc.stepSpeed = 4f;
- }
- }
- }
- }
- }
- if (flag22)
- {
- int num169 = (int)((npc.position.X + (float)(npc.width / 2) + (float)(15 * npc.direction)) / 16f);
- int num170 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f);
- if (npc.type == 109 || npc.type == 163 || npc.type == 164 || npc.type == 199 || npc.type == 236 || npc.type == 239 || npc.type == 257 || npc.type == 258 || npc.type == 290 || npc.type == 391 || npc.type == 425 || npc.type == 427 || npc.type == 426 || npc.type == 508 || npc.type == 415 || npc.type == 530 || npc.type == 532)
- {
- num169 = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 16) * npc.direction)) / 16f);
- }
- if (Main.tile[num169, num170] == null)
- {
- Main.tile[num169, num170] = new Tile();
- }
- if (Main.tile[num169, num170 - 1] == null)
- {
- Main.tile[num169, num170 - 1] = new Tile();
- }
- if (Main.tile[num169, num170 - 2] == null)
- {
- Main.tile[num169, num170 - 2] = new Tile();
- }
- if (Main.tile[num169, num170 - 3] == null)
- {
- Main.tile[num169, num170 - 3] = new Tile();
- }
- if (Main.tile[num169, num170 + 1] == null)
- {
- Main.tile[num169, num170 + 1] = new Tile();
- }
- if (Main.tile[num169 + npc.direction, num170 - 1] == null)
- {
- Main.tile[num169 + npc.direction, num170 - 1] = new Tile();
- }
- if (Main.tile[num169 + npc.direction, num170 + 1] == null)
- {
- Main.tile[num169 + npc.direction, num170 + 1] = new Tile();
- }
- if (Main.tile[num169 - npc.direction, num170 + 1] == null)
- {
- Main.tile[num169 - npc.direction, num170 + 1] = new Tile();
- }
- Main.tile[num169, num170 + 1].halfBrick();
- if ((Main.tile[num169, num170 - 1].nactive() && (TileLoader.IsClosedDoor(Main.tile[num169, num170 - 1]) || Main.tile[num169, num170 - 1].type == 388)) & flag5)
- {
- npc.ai[2] += 1f;
- npc.ai[3] = 0f;
- if (npc.ai[2] >= 60f)
- {
- if (!Main.bloodMoon && (npc.type == 3 || npc.type == 331 || npc.type == 332 || npc.type == 132 || npc.type == 161 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 200 || npc.type == 223 || npc.type == 320 || npc.type == 321 || npc.type == 319))
- {
- npc.ai[1] = 0f;
- }
- npc.velocity.X = 0.5f * -(float)npc.direction;
- int num171 = 5;
- if (Main.tile[num169, num170 - 1].type == 388)
- {
- num171 = 2;
- }
- npc.ai[1] += (float)num171;
- if (npc.type == 27)
- {
- npc.ai[1] += 1f;
- }
- if (npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296)
- {
- npc.ai[1] += 6f;
- }
- npc.ai[2] = 0f;
- bool flag23 = false;
- if (npc.ai[1] >= 10f)
- {
- flag23 = true;
- npc.ai[1] = 10f;
- }
- if (npc.type == 460)
- {
- flag23 = true;
- }
- WorldGen.KillTile(num169, num170 - 1, true, false, false);
- if (((Main.netMode != 1 || !flag23) & flag23) && Main.netMode != 1)
- {
- if (npc.type == 26)
- {
- WorldGen.KillTile(num169, num170 - 1, false, false, false);
- if (Main.netMode == 2)
- {
- NetMessage.SendData(17, -1, -1, null, 0, (float)num169, (float)(num170 - 1), 0f, 0, 0, 0);
- }
- }
- else
- {
- if (TileLoader.OpenDoorID(Main.tile[num169, num170 - 1]) >= 0)
- {
- bool flag24 = WorldGen.OpenDoor(num169, num170 - 1, npc.direction);
- if (!flag24)
- {
- npc.ai[3] = (float)num34;
- npc.netUpdate = true;
- }
- if (Main.netMode == 2 & flag24)
- {
- NetMessage.SendData(19, -1, -1, null, 0, (float)num169, (float)(num170 - 1), (float)npc.direction, 0, 0, 0);
- }
- }
- if (Main.tile[num169, num170 - 1].type == 388)
- {
- bool flag25 = WorldGen.ShiftTallGate(num169, num170 - 1, false);
- if (!flag25)
- {
- npc.ai[3] = (float)num34;
- npc.netUpdate = true;
- }
- if (Main.netMode == 2 & flag25)
- {
- NetMessage.SendData(19, -1, -1, null, 4, (float)num169, (float)(num170 - 1), 0f, 0, 0, 0);
- }
- }
- }
- }
- }
- }
- else
- {
- int num172 = npc.spriteDirection;
- if (npc.type == 425)
- {
- num172 *= -1;
- }
- if ((npc.velocity.X < 0f && num172 == -1) || (npc.velocity.X > 0f && num172 == 1))
- {
- if (npc.height >= 32 && Main.tile[num169, num170 - 2].nactive() && Main.tileSolid[(int)Main.tile[num169, num170 - 2].type])
- {
- if (Main.tile[num169, num170 - 3].nactive() && Main.tileSolid[(int)Main.tile[num169, num170 - 3].type])
- {
- npc.velocity.Y = -8f;
- npc.netUpdate = true;
- }
- else
- {
- npc.velocity.Y = -7f;
- npc.netUpdate = true;
- }
- }
- else if (Main.tile[num169, num170 - 1].nactive() && Main.tileSolid[(int)Main.tile[num169, num170 - 1].type])
- {
- npc.velocity.Y = -6f;
- npc.netUpdate = true;
- }
- else if (npc.position.Y + (float)npc.height - (float)(num170 * 16) > 20f && Main.tile[num169, num170].nactive() && !Main.tile[num169, num170].topSlope() && Main.tileSolid[(int)Main.tile[num169, num170].type])
- {
- npc.velocity.Y = -5f;
- npc.netUpdate = true;
- }
- else if (npc.directionY < 0 && npc.type != 67 && (!Main.tile[num169, num170 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num169, num170 + 1].type]) && (!Main.tile[num169 + npc.direction, num170 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num169 + npc.direction, num170 + 1].type]))
- {
- npc.velocity.Y = -8f;
- npc.velocity.X = npc.velocity.X * 1.5f;
- npc.netUpdate = true;
- }
- else if (flag5)
- {
- npc.ai[1] = 0f;
- npc.ai[2] = 0f;
- }
- if ((npc.velocity.Y == 0f & flag3) && npc.ai[3] == 1f)
- {
- npc.velocity.Y = -5f;
- }
- }
- if ((npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 77 || npc.type == 104 || npc.type == 168 || npc.type == 196 || npc.type == 385 || npc.type == 389 || npc.type == 464 || npc.type == 470 || (npc.type >= 524 && npc.type <= 527)) && npc.velocity.Y == 0f && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 100f && Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f)))
- {
- npc.velocity.X = npc.velocity.X * 2f;
- if (npc.velocity.X > 3f)
- {
- npc.velocity.X = 3f;
- }
- if (npc.velocity.X < -3f)
- {
- npc.velocity.X = -3f;
- }
- npc.velocity.Y = -4f;
- npc.netUpdate = true;
- }
- if (npc.type == 120 && npc.velocity.Y < 0f)
- {
- npc.velocity.Y = npc.velocity.Y * 1.1f;
- }
- if (npc.type == 287 && npc.velocity.Y == 0f && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 150f && Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f)))
- {
- npc.velocity.X = (float)(8 * npc.direction);
- npc.velocity.Y = -4f;
- npc.netUpdate = true;
- }
- if (npc.type == 287 && npc.velocity.Y < 0f)
- {
- npc.velocity.X = npc.velocity.X * 1.2f;
- npc.velocity.Y = npc.velocity.Y * 1.1f;
- }
- if (npc.type == 460 && npc.velocity.Y < 0f)
- {
- npc.velocity.X = npc.velocity.X * 1.3f;
- npc.velocity.Y = npc.velocity.Y * 1.1f;
- }
- }
- }
- else if (flag5)
- {
- npc.ai[1] = 0f;
- npc.ai[2] = 0f;
- }
- if (Main.netMode != 1 && npc.type == 120 && npc.ai[3] >= (float)num34)
- {
- int num173 = (int)Main.player[npc.target].position.X / 16;
- int num174 = (int)Main.player[npc.target].position.Y / 16;
- int num175 = (int)npc.position.X / 16;
- int num176 = (int)npc.position.Y / 16;
- int num177 = 20;
- int num178 = 0;
- bool flag26 = false;
- if (Math.Abs(npc.position.X - Main.player[npc.target].position.X) + Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f)
- {
- num178 = 100;
- flag26 = true;
- }
- while (!flag26 && num178 < 100)
- {
- num178++;
- int num179 = Main.rand.Next(num173 - num177, num173 + num177);
- for (int num180 = Main.rand.Next(num174 - num177, num174 + num177); num180 < num174 + num177; num180++)
- {
- if ((num180 < num174 - 4 || num180 > num174 + 4 || num179 < num173 - 4 || num179 > num173 + 4) && (num180 < num176 - 1 || num180 > num176 + 1 || num179 < num175 - 1 || num179 > num175 + 1) && Main.tile[num179, num180].nactive())
- {
- bool flag27 = true;
- if (npc.type == 32 && Main.tile[num179, num180 - 1].wall == 0)
- {
- flag27 = false;
- }
- else if (Main.tile[num179, num180 - 1].lava())
- {
- flag27 = false;
- }
- if (flag27 && Main.tileSolid[(int)Main.tile[num179, num180].type] && !Collision.SolidTiles(num179 - 1, num179 + 1, num180 - 4, num180 - 1))
- {
- npc.position.X = (float)(num179 * 16 - npc.width / 2);
- npc.position.Y = (float)(num180 * 16 - npc.height);
- npc.netUpdate = true;
- npc.ai[3] = -120f;
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement