private void AI_099_2()
{
bool flag1 = false;
for (int index = 0; index < whoAmI; ++index)
{
if (Main.projectile[index].active && Main.projectile[index].owner == owner && Main.projectile[index].type == type)
flag1 = true;
}
if (owner == Main.myPlayer)
{
++localAI[0];
if (flag1)
localAI[0] += Main.rand.Next(10, 31) * 0.1f;
float num = localAI[0] / 60f / (float)((1.0 + Main.player[owner].meleeSpeed) / 2.0);
if (type == 541 && num > 3.0)
ai[0] = -1f;
if (type == 548 && num > 5.0)
ai[0] = -1f;
if (type == 542 && num > 7.0)
ai[0] = -1f;
if (type == 543 && num > 6.0)
ai[0] = -1f;
if (type == 544 && num > 8.0)
ai[0] = -1f;
if (type == 534 && num > 9.0)
ai[0] = -1f;
if (type == 564 && num > 11.0)
ai[0] = -1f;
if (type == 545 && num > 13.0)
ai[0] = -1f;
if (type == 563 && num > 10.0)
ai[0] = -1f;
if (type == 562 && num > 8.0)
ai[0] = -1f;
if (type == 553 && num > 12.0)
ai[0] = -1f;
if (type == 546 && num > 16.0)
ai[0] = -1f;
if (type == 552 && num > 15.0)
ai[0] = -1f;
if (type == 549 && num > 14.0)
ai[0] = -1f;
}
if (type == 603 && owner == Main.myPlayer)
{
++localAI[1];
if (localAI[1] >= 6.0)
{
float num1 = 400f;
Vector2 vector2_1 = velocity;
Vector2 vector2_2 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
vector2_2.Normalize();
Vector2 vector2_3 = vector2_2 * (Main.rand.Next(10, 41) * 0.1f);
if (Main.rand.Next(3) == 0)
vector2_3 *= 2f;
Vector2 vector2_4 = vector2_1 * 0.25f + vector2_3;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].CanBeChasedBy(this, false))
{
float num2 = Main.npc[index].position.X + (float)(Main.npc[index].width / 2);
float num3 = Main.npc[index].position.Y + (float)(Main.npc[index].height / 2);
float num4 = Math.Abs(position.X + (width / 2) - num2) + Math.Abs(position.Y + (height / 2) - num3);
if (num4 < num1 && Collision.CanHit(position, width, height, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height))
{
num1 = num4;
vector2_4.X = num2;
vector2_4.Y = num3;
Vector2 vector2_5 = vector2_4 - Center;
vector2_5.Normalize();
vector2_4 = vector2_5 * 8f;
}
}
}
Vector2 vector2_6 = vector2_4 * 0.8f;
NewProjectile(Center.X, Center.Y, vector2_6.X, vector2_6.Y, 604, damage, knockBack, owner, 0.0f, 0.0f);
localAI[1] = 0.0f;
}
}
bool flag2 = false;
if (type >= 556 && type <= 561)
flag2 = true;
if (Main.player[owner].dead)
{
Kill();
}
else
{
if (!flag2 && !flag1)
{
Main.player[owner].heldProj = whoAmI;
Main.player[owner].itemAnimation = 2;
Main.player[owner].itemTime = 2;
if (position.X + (width / 2) > Main.player[owner].position.X + (Main.player[owner].width / 2))
{
Main.player[owner].ChangeDir(1);
direction = 1;
}
else
{
Main.player[owner].ChangeDir(-1);
direction = -1;
}
}
if (Utils.HasNaNs(velocity))
Kill();
timeLeft = 6;
float num1 = 10f;
float num2 = 200f;
if (type == 541)
{
num2 = 130f;
num1 = 9f;
}
else if (type == 548)
{
num2 = 170f;
num1 = 11f;
}
else if (type == 542)
{
num2 = 195f;
num1 = 12.5f;
}
else if (type == 543)
{
num2 = 207f;
num1 = 12f;
}
else if (type == 544)
{
num2 = 215f;
num1 = 13f;
}
else if (type == 534)
{
num2 = 220f;
num1 = 13f;
}
else if (type == 564)
{
num2 = 225f;
num1 = 14f;
}
else if (type == 545)
{
if (Main.rand.Next(6) == 0)
{
int index = Dust.NewDust(position, width, height, 6, 0.0f, 0.0f, 0, new Color(), 1f);
Main.dust[index].noGravity = true;
}
num2 = 235f;
num1 = 14f;
}
else if (type == 562)
{
num2 = 235f;
num1 = 15f;
}
else if (type == 563)
{
num2 = 250f;
num1 = 12f;
}
else if (type == 546)
{
num2 = 275f;
num1 = 17f;
}
else if (type == 552)
{
num2 = 270f;
num1 = 14f;
}
else if (type == 553)
{
if (Main.rand.Next(2) == 0)
{
int index = Dust.NewDust(position, width, height, 6, 0.0f, 0.0f, 0, new Color(), 1f);
Main.dust[index].noGravity = true;
Main.dust[index].scale = 1.6f;
}
num2 = 275f;
num1 = 15f;
}
else if (type == 547)
{
num2 = 280f;
num1 = 17f;
}
else if (type == 549)
{
num2 = 290f;
num1 = 16f;
}
else if (type == 554)
{
num2 = 340f;
num1 = 16f;
}
else if (type == 550 || type == 551)
{
num2 = 370f;
num1 = 16f;
}
else if (type == 555)
{
num2 = 360f;
num1 = 16.5f;
}
else if (type == 603)
{
num2 = 400f;
num1 = 17.5f;
}
if (Main.player[owner].yoyoString)
num2 = (float)(num2 * 1.25 + 30.0);
float num3 = num2 / (float)((1.0 + Main.player[owner].meleeSpeed * 3.0) / 4.0);
float num4 = num1 / (float)((1.0 + Main.player[owner].meleeSpeed * 3.0) / 4.0);
float num5 = (float)(14.0 - num4 / 2.0);
float num6 = (float)(5.0 + num4 / 2.0);
if (flag1)
num6 += 20f;
if (ai[0] >= 0.0)
{
if (velocity.Length() > num4)
{
Projectile projectile = this;
Vector2 vector2 = projectile.velocity * 0.98f;
projectile.velocity = vector2;
}
bool flag3 = false;
bool flag4 = false;
Vector2 vector2_1 = Main.player[owner].Center - Center;
if ((double)vector2_1.Length() > num3)
{
flag3 = true;
if ((double)vector2_1.Length() > num3 * 1.3)
flag4 = true;
}
if (owner == Main.myPlayer)
{
if (!Main.player[owner].channel || Main.player[owner].stoned || Main.player[owner].frozen)
{
ai[0] = -1f;
ai[1] = 0.0f;
netUpdate = true;
}
else
{
Vector2 vector2_2 = Main.ReverseGravitySupport(Main.MouseScreen, 0.0f) + Main.screenPosition;
float x = vector2_2.X;
float y = vector2_2.Y;
Vector2 vector2_3 = new Vector2(x, y) - Main.player[owner].Center;
if (vector2_3.Length() > num3)
{
vector2_3.Normalize();
Vector2 vector2_4 = vector2_3 * num3;
Vector2 vector2_5 = Main.player[owner].Center + vector2_4;
x = vector2_5.X;
y = vector2_5.Y;
}
if (ai[0] != (double)x || ai[1] != (double)y)
{
Vector2 vector2_4 = new Vector2(x, y) - Main.player[owner].Center;
if (vector2_4.Length() > num3 - 1.0)
{
vector2_4.Normalize();
Vector2 vector2_5 = vector2_4 * (num3 - 1f);
Vector2 vector2_6 = Main.player[owner].Center + vector2_5;
x = vector2_6.X;
y = vector2_6.Y;
}
ai[0] = x;
ai[1] = y;
netUpdate = true;
}
}
}
if (flag4 && owner == Main.myPlayer)
{
ai[0] = -1f;
netUpdate = true;
}
if (ai[0] >= 0.0)
{
if (flag3)
{
num5 /= 2f;
num4 *= 2f;
if (Center.X > Main.player[owner].Center.X && velocity.X > 0.0)
velocity.X *= 0.5f;
if (Center.Y > Main.player[owner].Center.Y && velocity.Y > 0.0)
velocity.Y *= 0.5f;
if (Center.X < Main.player[owner].Center.X && velocity.X > 0.0)
velocity.X *= 0.5f;
if (Center.Y < Main.player[owner].Center.Y && velocity.Y > 0.0)
velocity.Y *= 0.5f;
}
Vector2 vector2_2 = new Vector2(ai[0], ai[1]) - Center;
double num7 = velocity.Length();
if (vector2_2.Length() > num6)
{
vector2_2.Normalize();
vector2_2 *= num4;
velocity = (velocity * (num5 - 1f) + vector2_2) / num5;
}
else if (flag1)
{
if (velocity.Length() < num4 * 0.6)
{
vector2_2 = velocity;
vector2_2.Normalize();
vector2_2 *= num4 * 0.6f;
velocity = (velocity * (num5 - 1f) + vector2_2) / num5;
}
}
else
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.velocity * 0.8f;
projectile.velocity = vector2_3;
}
if (flag1 && !flag3 && velocity.Length() < num4 * 0.6)
{
velocity.Normalize();
Projectile projectile = this;
Vector2 vector2_3 = projectile.velocity * (num4 * 0.6f);
projectile.velocity = vector2_3;
}
}
}
else
{
float num7 = (float)(int)(num5 * 0.8);
float num8 = num4 * 1.5f;
tileCollide = false;
Vector2 vector2 = Main.player[owner].position - Center;
float num9 = vector2.Length();
if (num9 < num8 + 10.0 || num9 == 0.0)
{
Kill();
}
else
{
vector2.Normalize();
vector2 *= num8;
velocity = (velocity * (num7 - 1f) + vector2) / num7;
}
}
rotation += 0.45f;
}
}