float num741 = 1f;
bool flag95 = false;
bool flag103 = false;
aiAction = 0;
if (this.ai[3] == 0f && life > 0)
{
this.ai[3] = lifeMax;
}
if (localAI[3] == 0f && Main.netMode != 1)
{
this.ai[0] = -100f;
localAI[3] = 1f;
TargetClosest();
netUpdate = true;
}
if (Main.player[target].dead)
{
TargetClosest();
if (Main.player[target].dead)
{
timeLeft = 0;
if (Main.player[target].Center.X < base.Center.X)
{
base.direction = 1;
}
else
{
base.direction = -1;
}
}
}
if (!Main.player[target].dead && this.ai[2] >= 300f && this.ai[1] < 5f && velocity.Y == 0f)
{
this.ai[2] = 0f;
this.ai[0] = 0f;
this.ai[1] = 5f;
if (Main.netMode != 1)
{
TargetClosest(faceTarget: false);
Point point8 = base.Center.ToTileCoordinates();
Point point9 = Main.player[target].Center.ToTileCoordinates();
Vector2 vector165 = Main.player[target].Center - base.Center;
int num744 = 10;
int num745 = 0;
int num746 = 7;
int num747 = 0;
bool flag2 = false;
if (vector165.Length() > 2000f)
{
flag2 = true;
num747 = 100;
}
while (!flag2 && num747 < 100)
{
num747++;
int num748 = Main.rand.Next(point9.X - num744, point9.X + num744 + 1);
int num749 = Main.rand.Next(point9.Y - num744, point9.Y + 1);
if ((num749 >= point9.Y - num746 && num749 <= point9.Y + num746 && num748 >= point9.X - num746 && num748 <= point9.X + num746) || (num749 >= point8.Y - num745 && num749 <= point8.Y + num745 && num748 >= point8.X - num745 && num748 <= point8.X + num745) || Main.tile[num748, num749].nactive())
{
continue;
}
int num751 = num749;
int num752 = 0;
if (Main.tile[num748, num751].nactive() && Main.tileSolid[Main.tile[num748, num751].type] && !Main.tileSolidTop[Main.tile[num748, num751].type])
{
num752 = 1;
}
else
{
for (; num752 < 150 && num751 + num752 < Main.maxTilesY; num752++)
{
int num753 = num751 + num752;
if (Main.tile[num748, num753].nactive() && Main.tileSolid[Main.tile[num748, num753].type] && !Main.tileSolidTop[Main.tile[num748, num753].type])
{
num752--;
break;
}
}
}
num749 += num752;
bool flag28 = true;
if (flag28 && Main.tile[num748, num749].lava())
{
flag28 = false;
}
if (flag28 && !Collision.CanHitLine(base.Center, 0, 0, Main.player[target].Center, 0, 0))
{
flag28 = false;
}
if (flag28)
{
localAI[1] = num748 * 16 + 8;
localAI[2] = num749 * 16 + 16;
break;
}
}
if (num747 >= 100)
{
Vector2 bottom = Main.player[Player.FindClosest(base.position, width, height)].Bottom;
localAI[1] = bottom.X;
localAI[2] = bottom.Y;
}
}
}
if (!Collision.CanHitLine(base.Center, 0, 0, Main.player[target].Center, 0, 0))
{
this.ai[2] += 1f;
}
if (Math.Abs(base.Top.Y - Main.player[target].Bottom.Y) > 320f)
{
this.ai[2] += 1f;
}
Dust dust24;
if (this.ai[1] == 5f)
{
flag95 = true;
aiAction = 1;
this.ai[0] += 1f;
num741 = MathHelper.Clamp((60f - this.ai[0]) / 60f, 0f, 1f);
num741 = 0.5f + num741 * 0.5f;
if (this.ai[0] >= 60f)
{
flag103 = true;
}
if (this.ai[0] == 60f)
{
Gore.NewGore(base.Center + new Vector2(-40f, (0f - (float)height) / 2f), velocity, 734);
}
if (this.ai[0] >= 60f && Main.netMode != 1)
{
base.Bottom = new Vector2(localAI[1], localAI[2]);
this.ai[1] = 6f;
this.ai[0] = 0f;
netUpdate = true;
}
if (Main.netMode == 1 && this.ai[0] >= 120f)
{
this.ai[1] = 6f;
this.ai[0] = 0f;
}
if (!flag103)
{
for (int num755 = 0; num755 < 10; num755++)
{
int num756 = Dust.NewDust(base.position + Vector2.UnitX * -20f, width + 40, height, 4, velocity.X, velocity.Y, 150, new Color(78, 136, 255, 80), 2f);
Main.dust[num756].noGravity = true;
dust24 = Main.dust[num756];
dust24.velocity *= 0.5f;
}
}
}
else if (this.ai[1] == 6f)
{
flag95 = true;
aiAction = 0;
this.ai[0] += 1f;
num741 = MathHelper.Clamp(this.ai[0] / 30f, 0f, 1f);
num741 = 0.5f + num741 * 0.5f;
if (this.ai[0] >= 30f && Main.netMode != 1)
{
this.ai[1] = 0f;
this.ai[0] = 0f;
netUpdate = true;
TargetClosest();
}
if (Main.netMode == 1 && this.ai[0] >= 60f)
{
this.ai[1] = 0f;
this.ai[0] = 0f;
TargetClosest();
}
for (int num757 = 0; num757 < 10; num757++)
{
int num758 = Dust.NewDust(base.position + Vector2.UnitX * -20f, width + 40, height, 4, velocity.X, velocity.Y, 150, new Color(78, 136, 255, 80), 2f);
Main.dust[num758].noGravity = true;
dust24 = Main.dust[num758];
dust24.velocity *= 2f;
}
}
dontTakeDamage = (hide = flag103);
if (velocity.Y == 0f)
{
velocity.X *= 0.8f;
if ((double)velocity.X > -0.1 && (double)velocity.X < 0.1)
{
velocity.X = 0f;
}
if (!flag95)
{
this.ai[0] += 2f;
if ((double)life < (double)lifeMax * 0.8)
{
this.ai[0] += 1f;
}
if ((double)life < (double)lifeMax * 0.6)
{
this.ai[0] += 1f;
}
if ((double)life < (double)lifeMax * 0.4)
{
this.ai[0] += 2f;
}
if ((double)life < (double)lifeMax * 0.2)
{
this.ai[0] += 3f;
}
if ((double)life < (double)lifeMax * 0.1)
{
this.ai[0] += 4f;
}
if (this.ai[0] >= 0f)
{
netUpdate = true;
TargetClosest();
if (this.ai[1] == 3f)
{
velocity.Y = -13f;
velocity.X += 3.5f * (float)base.direction;
this.ai[0] = -200f;
this.ai[1] = 0f;
}
else if (this.ai[1] == 2f)
{
velocity.Y = -6f;
velocity.X += 4.5f * (float)base.direction;
this.ai[0] = -120f;
this.ai[1] += 1f;
}
else
{
velocity.Y = -8f;
velocity.X += 4f * (float)base.direction;
this.ai[0] = -120f;
this.ai[1] += 1f;
}
}
else if (this.ai[0] >= -30f)
{
aiAction = 1;
}
}
}
else if (target < 255 && ((base.direction == 1 && velocity.X < 3f) || (base.direction == -1 && velocity.X > -3f)))
{
if ((base.direction == -1 && (double)velocity.X < 0.1) || (base.direction == 1 && (double)velocity.X > -0.1))
{
velocity.X += 0.2f * (float)base.direction;
}
else
{
velocity.X *= 0.93f;
}
}
int num759 = Dust.NewDust(base.position, width, height, 4, velocity.X, velocity.Y, 255, new Color(0, 80, 255, 80), scale * 1.2f);
Main.dust[num759].noGravity = true;
dust24 = Main.dust[num759];
dust24.velocity *= 0.5f;
if (life <= 0)
{
return;
}
float num760 = (float)life / (float)lifeMax;
num760 = num760 * 0.5f + 0.75f;
num760 *= num741;
if (num760 != scale)
{
base.position.X = base.position.X + (float)(width / 2);
base.position.Y = base.position.Y + (float)height;
scale = num760;
width = (int)(98f * scale);
height = (int)(92f * scale);
base.position.X = base.position.X - (float)(width / 2);
base.position.Y = base.position.Y - (float)height;
}
if (Main.netMode == 1)
{
return;
}
int num763 = (int)((double)lifeMax * 0.05);
if (!((float)(life + num763) < this.ai[3]))
{
return;
}
this.ai[3] = life;
int num764 = Main.rand.Next(1, 4);
for (int num765 = 0; num765 < num764; num765++)
{
int x = (int)(base.position.X + (float)Main.rand.Next(width - 32));
int y = (int)(base.position.Y + (float)Main.rand.Next(height - 32));
int num766 = 1;
if (Main.expertMode && Main.rand.Next(4) == 0)
{
num766 = 535;
}
int num768 = NewNPC(x, y, num766);
Main.npc[num768].SetDefaults(num766);
Main.npc[num768].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f;
Main.npc[num768].velocity.Y = (float)Main.rand.Next(-30, 1) * 0.1f;
Main.npc[num768].ai[0] = -1000 * Main.rand.Next(3);
Main.npc[num768].ai[1] = 0f;
if (Main.netMode == 2 && num768 < 200)
{
NetMessage.SendData(23, -1, -1, null, num768);
}