public void Update(int i)
{
if (!active)
return;
numUpdates = extraUpdates;
while (numUpdates >= 0)
{
--numUpdates;
if (type == 640 && ai[1] > 0.0)
{
--ai[1];
}
else
{
if (position.X <= Main.leftWorld || position.X + width >= Main.rightWorld || (position.Y <= Main.topWorld || position.Y + height >= Main.bottomWorld))
{
active = false;
return;
}
if (type != 344 && !npcProj)
{
if (Main.player[owner].frostBurn && (melee || ranged) && (friendly && !hostile && (!noEnchantments && Main.rand.Next(2 * (1 + extraUpdates)) == 0)))
{
int index = Dust.NewDust(position, width, height, 135, velocity.X * 0.2f + (direction * 3), velocity.Y * 0.2f, 100, new Color(), 2f);
Main.dust[index].noGravity = true;
Main.dust[index].velocity *= 0.7f;
Main.dust[index].velocity.Y -= 0.5f;
}
if (melee && Main.player[owner].meleeEnchant > 0 && !noEnchantments)
{
if (Main.player[owner].meleeEnchant == 1 && Main.rand.Next(3) == 0)
{
int index = Dust.NewDust(position, width, height, 171, 0.0f, 0.0f, 100, new Color(), 1f);
Main.dust[index].noGravity = true;
Main.dust[index].fadeIn = 1.5f;
Main.dust[index].velocity *= 0.25f;
}
if (Main.player[owner].meleeEnchant == 1)
{
if (Main.rand.Next(3) == 0)
{
int index = Dust.NewDust(position, width, height, 171, 0.0f, 0.0f, 100, new Color(), 1f);
Main.dust[index].noGravity = true;
Main.dust[index].fadeIn = 1.5f;
Main.dust[index].velocity *= 0.25f;
}
}
else if (Main.player[owner].meleeEnchant == 2)
{
if (Main.rand.Next(2) == 0)
{
int index = Dust.NewDust(position, width, height, 75, velocity.X * 0.2f + (direction * 3), velocity.Y * 0.2f, 100, new Color(), 2.5f);
Main.dust[index].noGravity = true;
Main.dust[index].velocity *= 0.7f;
Main.dust[index].velocity.Y -= 0.5f;
}
}
else if (Main.player[owner].meleeEnchant == 3)
{
if (Main.rand.Next(2) == 0)
{
int index = Dust.NewDust(position, width, height, 6, velocity.X * 0.2f + (direction * 3), velocity.Y * 0.2f, 100, new Color(), 2.5f);
Main.dust[index].noGravity = true;
Main.dust[index].velocity *= 0.7f;
Main.dust[index].velocity.Y -= 0.5f;
}
}
else if (Main.player[owner].meleeEnchant == 4)
{
if (Main.rand.Next(2) == 0)
{
int index = Dust.NewDust(position, width, height, 57, velocity.X * 0.2f + (direction * 3), velocity.Y * 0.2f, 100, new Color(), 1.1f);
Main.dust[index].noGravity = true;
Main.dust[index].velocity.X /= 2f;
Main.dust[index].velocity.Y /= 2f;
}
}
else if (Main.player[owner].meleeEnchant == 5)
{
if (Main.rand.Next(2) == 0)
{
int index = Dust.NewDust(position, width, height, 169, 0.0f, 0.0f, 100, new Color(), 1f);
Main.dust[index].velocity.X += direction;
Main.dust[index].velocity.Y += 0.2f;
Main.dust[index].noGravity = true;
}
}
else if (Main.player[owner].meleeEnchant == 6)
{
if (Main.rand.Next(2) == 0)
{
int index = Dust.NewDust(position, width, height, 135, 0.0f, 0.0f, 100, new Color(), 1f);
Main.dust[index].velocity.X += direction;
Main.dust[index].velocity.Y += 0.2f;
Main.dust[index].noGravity = true;
}
}
else if (Main.player[owner].meleeEnchant == 7)
{
if (Main.rand.Next(20) == 0)
{
int index = Dust.NewDust(position, width, height, Main.rand.Next(139, 143), velocity.X, velocity.Y, 0, new Color(), 1.2f);
Main.dust[index].velocity.X *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.00999999977648258);
Main.dust[index].velocity.Y *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.00999999977648258);
Main.dust[index].velocity.X += Main.rand.Next(-50, 51) * 0.05f;
Main.dust[index].velocity.Y += Main.rand.Next(-50, 51) * 0.05f;
Main.dust[index].scale *= (float)(1.0 + Main.rand.Next(-30, 31) * 0.00999999977648258);
}
if (Main.rand.Next(40) == 0)
{
int index = Gore.NewGore(position, velocity, Main.rand.Next(276, 283), 1f);
Main.gore[index].velocity.X *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.00999999977648258);
Main.gore[index].velocity.Y *= (float)(1.0 + Main.rand.Next(-50, 51) * 0.00999999977648258);
Main.gore[index].scale *= (float)(1.0 + Main.rand.Next(-20, 21) * 0.00999999977648258);
Main.gore[index].velocity.X += Main.rand.Next(-50, 51) * 0.05f;
Main.gore[index].velocity.Y += Main.rand.Next(-50, 51) * 0.05f;
}
}
else if (Main.player[owner].meleeEnchant == 8 && Main.rand.Next(4) == 0)
{
int index = Dust.NewDust(position, width, height, 46, 0.0f, 0.0f, 100, new Color(), 1f);
Main.dust[index].noGravity = true;
Main.dust[index].fadeIn = 1.5f;
Main.dust[index].velocity *= 0.25f;
}
}
if (melee && Main.player[owner].magmaStone && (!noEnchantments && Main.rand.Next(3) != 0))
{
int index = Dust.NewDust(new Vector2(position.X - 4f, position.Y - 4f), width + 8, height + 8, 6, velocity.X * 0.2f, velocity.Y * 0.2f, 100, new Color(), 2f);
if (Main.rand.Next(2) == 0)
Main.dust[index].scale = 1.5f;
Main.dust[index].noGravity = true;
Main.dust[index].velocity.X *= 2f;
Main.dust[index].velocity.Y *= 2f;
}
}
if (minion && numUpdates == -1 && (type != 625 && type != 628))
{
minionPos = Main.player[owner].numMinions;
if (Main.player[owner].slotsMinions + minionSlots > Main.player[owner].maxMinions && owner == Main.myPlayer)
{
if (type == 627 || type == 626)
{
Projectile projectile1 = Main.projectile[(int)ai[0]];
if (projectile1.type != 625)
projectile1.localAI[1] = localAI[1];
Projectile projectile2 = Main.projectile[(int)localAI[1]];
projectile2.ai[0] = ai[0];
projectile2.ai[1] = 1f;
projectile2.netUpdate = true;
}
Kill();
}
else
{
++Main.player[owner].numMinions;
Main.player[owner].slotsMinions += minionSlots;
}
}
float num1 = (float)(1.0 + Math.Abs(velocity.X) / 3.0);
if (gfxOffY > 0.0)
{
gfxOffY -= num1 * stepSpeed;
if (gfxOffY < 0.0)
gfxOffY = 0.0f;
}
else if (gfxOffY < 0.0)
{
gfxOffY += num1 * stepSpeed;
if (gfxOffY > 0.0)
gfxOffY = 0.0f;
}
if (gfxOffY > 16.0)
gfxOffY = 16f;
if (gfxOffY < -16.0)
gfxOffY = -16f;
Vector2 vector2_1 = velocity;
oldVelocity = velocity;
whoAmI = i;
if (soundDelay > 0)
--soundDelay;
netUpdate = false;
for (int index = 0; index < 255; ++index)
{
if (playerImmune[index] > 0)
--playerImmune[index];
}
if (updatedNPCImmunity)
{
for (int index = 0; index < 200; ++index)
{
if (npcImmune[index] > 0)
--npcImmune[index];
}
}
AI();
if (owner < 255 && !Main.player[owner].active)
Kill();
if (type == 242 || type == 302 || type == 638)
wet = false;
if (!ignoreWater)
{
bool flag1;
bool flag2;
try
{
flag1 = Collision.LavaCollision(position, width, height);
flag2 = Collision.WetCollision(position, width, height);
if (flag1)
lavaWet = true;
if (Collision.honey)
honeyWet = true;
}
catch
{
active = false;
return;
}
if (wet && !lavaWet)
{
if (type == 85 || type == 15 || (type == 34 || type == 188))
Kill();
if (type == 2)
{
type = 1;
light = 0.0f;
}
}
if (type == 80)
{
flag2 = false;
wet = false;
if (flag1 && ai[0] >= 0.0)
Kill();
}
if (flag2)
{
if (type != 155 && wetCount == 0 && !wet)
{
if (!flag1)
{
if (honeyWet)
{
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(new Vector2(position.X - 6f, (float)(position.Y + (height / 2) - 8.0)), width + 12, 24, 152, 0.0f, 0.0f, 0, new Color(), 1f);
--Main.dust[index2].velocity.Y;
Main.dust[index2].velocity.X *= 2.5f;
Main.dust[index2].scale = 1.3f;
Main.dust[index2].alpha = 100;
Main.dust[index2].noGravity = true;
}
Main.PlaySound(19, (int)position.X, (int)position.Y, 1);
}
else
{
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(new Vector2(position.X - 6f, (float)(position.Y + (height / 2) - 8.0)), width + 12, 24, Dust.dustWater(), 0.0f, 0.0f, 0, new Color(), 1f);
Main.dust[index2].velocity.Y -= 4f;
Main.dust[index2].velocity.X *= 2.5f;
Main.dust[index2].scale = 1.3f;
Main.dust[index2].alpha = 100;
Main.dust[index2].noGravity = true;
}
Main.PlaySound(19, (int)position.X, (int)position.Y, 1);
}
}
else
{
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(new Vector2(position.X - 6f, (float)(position.Y + (height / 2) - 8.0)), width + 12, 24, 35, 0.0f, 0.0f, 0, new Color(), 1f);
Main.dust[index2].velocity.Y -= 1.5f;
Main.dust[index2].velocity.X *= 2.5f;
Main.dust[index2].scale = 1.3f;
Main.dust[index2].alpha = 100;
Main.dust[index2].noGravity = true;
}
Main.PlaySound(19, (int)position.X, (int)position.Y, 1);
}
}
wet = true;
}
else if (wet)
{
wet = false;
if (type == 155)
velocity.Y *= 0.5f;
else if (wetCount == 0)
{
wetCount = 10;
if (!lavaWet)
{
if (honeyWet)
{
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(new Vector2(position.X - 6f, (float)(position.Y + (height / 2) - 8.0)), width + 12, 24, 152, 0.0f, 0.0f, 0, new Color(), 1f);
--Main.dust[index2].velocity.Y;
Main.dust[index2].velocity.X *= 2.5f;
Main.dust[index2].scale = 1.3f;
Main.dust[index2].alpha = 100;
Main.dust[index2].noGravity = true;
}
Main.PlaySound(19, (int)position.X, (int)position.Y, 1);
}
else
{
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(new Vector2(position.X - 6f, position.Y + (height / 2)), width + 12, 24, Dust.dustWater(), 0.0f, 0.0f, 0, new Color(), 1f);
Main.dust[index2].velocity.Y -= 4f;
Main.dust[index2].velocity.X *= 2.5f;
Main.dust[index2].scale = 1.3f;
Main.dust[index2].alpha = 100;
Main.dust[index2].noGravity = true;
}
Main.PlaySound(19, (int)position.X, (int)position.Y, 1);
}
}
else
{
for (int index1 = 0; index1 < 10; ++index1)
{
int index2 = Dust.NewDust(new Vector2(position.X - 6f, (float)(position.Y + (height / 2) - 8.0)), width + 12, 24, 35, 0.0f, 0.0f, 0, new Color(), 1f);
Main.dust[index2].velocity.Y -= 1.5f;
Main.dust[index2].velocity.X *= 2.5f;
Main.dust[index2].scale = 1.3f;
Main.dust[index2].alpha = 100;
Main.dust[index2].noGravity = true;
}
Main.PlaySound(19, (int)position.X, (int)position.Y, 1);
}
}
}
if (!wet)
{
lavaWet = false;
honeyWet = false;
}
if (wetCount > 0)
--wetCount;
}
oldPosition = position;
oldDirection = direction;
bool flag3 = false;
if (tileCollide)
{
Vector2 vector2_2 = velocity;
bool flag1 = true;
int num2 = -1;
int num3 = -1;
if (Main.projPet[type])
{
flag1 = false;
if (Main.player[owner].position.Y + Main.player[owner].height - 12.0 > position.Y + height)
flag1 = true;
}
if (type == 500)
{
flag1 = false;
if (Main.player[owner].Bottom.Y > Bottom.Y + 4.0)
flag1 = true;
}
if (aiStyle == 62)
flag1 = true;
if (aiStyle == 66)
flag1 = true;
if (type == 317)
flag1 = true;
if (type == 373)
flag1 = true;
if (aiStyle == 53)
flag1 = false;
if (type == 9 || type == 12 || (type == 15 || type == 13) || (type == 31 || type == 39 || type == 40))
flag1 = false;
if (type == 24)
flag1 = false;
if (aiStyle == 29 || type == 28 || aiStyle == 49)
{
num2 = width - 8;
num3 = height - 8;
}
else if (type == 250 || type == 267 || (type == 297 || type == 323) || type == 3)
{
num2 = 6;
num3 = 6;
}
else if (type == 308)
{
num2 = 26;
num3 = height;
}
else if (type == 261 || type == 277)
{
num2 = 26;
num3 = 26;
}
else if (type == 481 || type == 491 || (type == 106 || type == 262) || (type == 271 || type == 270 || (type == 272 || type == 273)) || (type == 274 || type == 280 || (type == 288 || type == 301) || (type == 320 || type == 333 || (type == 335 || type == 343))) || (type == 344 || type == 497 || (type == 496 || type == 6) || (type == 19 || type == 113 || (type == 520 || type == 523)) || (type == 585 || type == 598 || (type == 599 || type == 636))))
{
num2 = 10;
num3 = 10;
}
else if (type == 514)
{
num2 = 4;
num3 = 4;
}
else if (type == 248 || type == 247 || (type == 507 || type == 508))
{
num2 = width - 12;
num3 = height - 12;
}
else if (aiStyle == 18 || type == 254)
{
num2 = width - 36;
num3 = height - 36;
}
else if (type == 182 || type == 190 || (type == 33 || type == 229) || (type == 237 || type == 243))
{
num2 = width - 20;
num3 = height - 20;
}
else if (aiStyle == 27)
{
num2 = width - 12;
num3 = height - 12;
}
else if (type == 533 && ai[0] >= 6.0)
{
num2 = width + 6;
num3 = height + 6;
}
else if (type == 582 || type == 634 || type == 635)
{
num2 = 8;
num3 = 8;
}
else if (type == 617)
{
num2 = (int)(20.0 * scale);
num3 = (int)(20.0 * scale);
}
if ((type != 440 && type != 449 && type != 606 || ai[1] != 1.0) && ((type != 466 || localAI[1] != 1.0) && (type != 580 || localAI[1] <= 0.0) && (type != 640 || localAI[1] <= 0.0)))
{
if (aiStyle == 10)
{
if (type == 42 || type == 65 || (type == 68 || type == 354) || type == 31 && ai[0] == 2.0)
velocity = Collision.TileCollision(position, velocity, width, height, flag1, flag1, 1);
else
velocity = Collision.AnyCollision(position, velocity, width, height);
}
else
{
Vector2 Position = position;
int Width = num2 != -1 ? num2 : width;
int Height = num3 != -1 ? num3 : height;
if (num3 != -1 || num2 != -1)
Position = new Vector2(position.X + (width / 2) - (Width / 2), position.Y + (height / 2) - (Height / 2));
if (wet)
{
if (honeyWet)
{
Vector2 vector2_3 = velocity;
velocity = Collision.TileCollision(Position, velocity, Width, Height, flag1, flag1, 1);
vector2_1 = velocity * 0.25f;
if (velocity.X != vector2_3.X)
vector2_1.X = velocity.X;
if (velocity.Y != vector2_3.Y)
vector2_1.Y = velocity.Y;
}
else
{
Vector2 vector2_3 = velocity;
velocity = Collision.TileCollision(Position, velocity, Width, Height, flag1, flag1, 1);
vector2_1 = velocity * 0.5f;
if (velocity.X != vector2_3.X)
vector2_1.X = velocity.X;
if (velocity.Y != vector2_3.Y)
vector2_1.Y = velocity.Y;
}
}
else
{
velocity = Collision.TileCollision(Position, velocity, Width, Height, flag1, flag1, 1);
if (!Main.projPet[type])
{
Vector4 vector4 = Collision.SlopeCollision(Position, velocity, Width, Height, 0.0f, true);
Vector2 vector2_3 = position - Position;
if (Position.X != vector4.X)
flag3 = true;
if (Position.Y != vector4.Y)
flag3 = true;
if (velocity.X != vector4.Z)
flag3 = true;
if (velocity.Y != vector4.W)
flag3 = true;
Position.X = vector4.X;
Position.Y = vector4.Y;
position = Position + vector2_3;
velocity.X = vector4.Z;
velocity.Y = vector4.W;
}
}
}
}
if (vector2_2 != velocity)
flag3 = true;
if (flag3)
{
if (type == 434)
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + velocity;
projectile.position = vector2_3;
numUpdates = 0;
}
else if (type == 601)
{
if (owner == Main.myPlayer)
PortalHelper.TryPlacingPortal(this, vector2_2, velocity);
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + velocity;
projectile.position = vector2_3;
Kill();
}
else if (type == 451)
{
ai[0] = 1f;
ai[1] = 0.0f;
netUpdate = true;
velocity = vector2_2 / 2f;
}
else if (type == 645)
{
ai[0] = 0.0f;
ai[1] = -1f;
netUpdate = true;
}
else if (type == 584)
{
bool flag2 = false;
if (velocity.X != vector2_2.X)
{
velocity.X = vector2_2.X * -0.75f;
flag2 = true;
}
if (velocity.Y != vector2_2.Y && vector2_2.Y > 2.0 || velocity.Y == 0.0)
{
velocity.Y = vector2_2.Y * -0.75f;
flag2 = true;
}
if (flag2)
{
float num4 = vector2_2.Length() / velocity.Length();
if (num4 == 0.0)
num4 = 1f;
Projectile projectile = this;
Vector2 vector2_3 = projectile.velocity / num4;
projectile.velocity = vector2_3;
--penetrate;
}
}
else if (type == 532)
{
bool flag2 = false;
if (velocity.X != vector2_2.X)
{
velocity.X = vector2_2.X * -0.75f;
flag2 = true;
}
if (velocity.Y != vector2_2.Y && vector2_2.Y > 2.0 || velocity.Y == 0.0)
{
velocity.Y = vector2_2.Y * -0.75f;
flag2 = true;
}
if (flag2)
{
float num4 = vector2_2.Length() / velocity.Length();
if (num4 == 0.0)
num4 = 1f;
Projectile projectile = this;
Vector2 vector2_3 = projectile.velocity / num4;
projectile.velocity = vector2_3;
--penetrate;
Collision.HitTiles(position, vector2_2, width, height);
}
}
else if (type == 533)
{
float num4 = 1f;
bool flag2 = false;
if (velocity.X != vector2_2.X)
{
velocity.X = vector2_2.X * -num4;
flag2 = true;
}
if (velocity.Y != vector2_2.Y || velocity.Y == 0.0)
{
velocity.Y = (float)(vector2_2.Y * -num4 * 0.5);
flag2 = true;
}
if (flag2)
{
float num5 = vector2_2.Length() / velocity.Length();
if (num5 == 0.0)
num5 = 1f;
Projectile projectile = this;
Vector2 vector2_3 = projectile.velocity / num5;
projectile.velocity = vector2_3;
if (ai[0] == 7.0 && velocity.Y < -0.1)
velocity.Y += 0.1f;
if (ai[0] >= 6.0 && ai[0] < 9.0)
Collision.HitTiles(position, vector2_2, width, height);
}
}
else if (type == 502)
{
++ai[0];
Main.PlaySound(37, (int)position.X, (int)position.Y, 5 + (int)ai[0]);
if (ai[0] >= 5.0)
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + velocity;
projectile.position = vector2_3;
Kill();
}
else
{
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
}
Vector2 spinningpoint = Utils.RotatedByRandom(new Vector2(0.0f, -3f - ai[0]), 3.14159274101257);
float num4 = (float)(10.0 + ai[0] * 4.0);
Vector2 vector2_4 = new Vector2(1.05f, 1f);
for (float num5 = 0.0f; num5 < num4; ++num5)
{
int index = Dust.NewDust(Center, 0, 0, 66, 0.0f, 0.0f, 0, Color.Transparent, 1f);
Main.dust[index].position = Center;
Main.dust[index].velocity = Utils.RotatedBy(spinningpoint, 6.28318548202515 * num5 / num4, new Vector2()) * vector2_4 * (float)(0.800000011920929 + Utils.NextFloat(Main.rand) * 0.400000005960464);
Main.dust[index].color = Main.hslToRgb(num5 / num4, 1f, 0.5f);
Main.dust[index].noGravity = true;
Main.dust[index].scale = (float)(1.0 + ai[0] / 3.0);
}
if (Main.myPlayer == owner)
{
int num5 = width;
int num6 = height;
int num7 = penetrate;
position = Center;
width = height = 40 + 8 * (int)ai[0];
Center = position;
penetrate = -1;
Damage();
penetrate = num7;
position = Center;
width = num5;
height = num6;
Center = position;
}
}
else if (type == 444)
{
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
ai[0] = Utils.ToRotation(velocity);
}
else if (type == 617)
{
if (velocity.X != vector2_2.X)
velocity.X = (float)(-vector2_2.X * 0.349999994039536);
if (velocity.Y != vector2_2.Y)
velocity.Y = (float)(-vector2_2.Y * 0.349999994039536);
}
else if (type == 440 || type == 449 || type == 606)
{
if (ai[1] != 1.0)
{
ai[1] = 1f;
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + velocity;
projectile.position = vector2_3;
velocity = vector2_2;
}
}
else if (type == 466 || type == 580 || type == 640)
{
if (localAI[1] < 1.0)
{
localAI[1] += 2f;
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + velocity;
projectile.position = vector2_3;
velocity = Vector2.Zero;
}
}
else if (aiStyle == 54)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.6f;
if (velocity.Y != vector2_2.Y)
velocity.Y = vector2_2.Y * -0.6f;
}
else if (!Main.projPet[type] && type != 500 && type != 650)
{
if (aiStyle == 99)
{
if (type >= 556 && type <= 561)
{
bool flag2 = false;
if (velocity.X != (double)oldVelocity.X)
{
flag2 = true;
velocity.X = oldVelocity.X * -1f;
}
if (velocity.Y != (double)oldVelocity.Y)
{
flag2 = true;
velocity.Y = oldVelocity.Y * -1f;
}
if (flag2)
{
Vector2 vector2_3 = Main.player[owner].Center - Center;
vector2_3.Normalize();
Vector2 vector2_4 = vector2_3 * velocity.Length() * 0.25f;
Projectile projectile1 = this;
Vector2 vector2_5 = projectile1.velocity * 0.75f;
projectile1.velocity = vector2_5;
Projectile projectile2 = this;
Vector2 vector2_6 = projectile2.velocity + vector2_4;
projectile2.velocity = vector2_6;
if (velocity.Length() > 6.0)
{
Projectile projectile3 = this;
Vector2 vector2_7 = projectile3.velocity * 0.5f;
projectile3.velocity = vector2_7;
}
}
}
}
else if (type == 604)
{
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else if (type == 379)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.6f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 2.0)
velocity.Y = vector2_2.Y * -0.6f;
}
else if (type == 491)
{
if (ai[0] <= 0.0)
ai[0] = -10f;
if (velocity.X != vector2_2.X && Math.Abs(vector2_2.X) > 0.0)
velocity.X = vector2_2.X * -1f;
if (velocity.Y != vector2_2.Y && Math.Abs(vector2_2.Y) > 0.0)
velocity.Y = vector2_2.Y * -1f;
}
else if (type >= 515 && type <= 517 || type == 637)
{
if (velocity.X != vector2_2.X && Math.Abs(vector2_2.X) > 1.0)
velocity.X = vector2_2.X * -0.9f;
if (velocity.Y != vector2_2.Y && Math.Abs(vector2_2.Y) > 1.0)
velocity.Y = vector2_2.Y * -0.9f;
}
else if (type == 409)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -1f;
if (velocity.Y != vector2_2.Y)
velocity.Y = vector2_2.Y * -1f;
}
else if (type == 254)
{
tileCollide = false;
velocity = vector2_2;
if (timeLeft > 30)
timeLeft = 30;
}
else if (type == 225 && penetrate > 0)
{
velocity.X = -vector2_2.X;
velocity.Y = -vector2_2.Y;
--penetrate;
}
else if (type == 155)
{
if (ai[1] > 10.0)
{
string str = string.Concat(new object[4]
{
name,
" was hit ",
ai[1],
" times before touching the ground!"
});
if (Main.netMode == 0)
Main.NewText(str, byte.MaxValue, 240, 20, false);
else if (Main.netMode == 2)
NetMessage.SendData(25, -1, -1, str, 255, 255, 240f, 20f, 0, 0, 0);
}
ai[1] = 0.0f;
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.6f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 2.0)
velocity.Y = vector2_2.Y * -0.6f;
}
else if (aiStyle == 33)
{
if (localAI[0] == 0.0)
{
if (wet)
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + vector2_2 / 2f;
projectile.position = vector2_3;
}
else
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + vector2_2;
projectile.position = vector2_3;
}
Projectile projectile1 = this;
Vector2 vector2_4 = projectile1.velocity * 0.0f;
projectile1.velocity = vector2_4;
localAI[0] = 1f;
}
}
else if (type != 308)
{
if (type == 477)
{
if (velocity.Y != vector2_2.Y || velocity.X != vector2_2.X)
{
--penetrate;
if (penetrate <= 0)
Kill();
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
if (penetrate > 0 && owner == Main.myPlayer)
{
int[] numArray = new int[10];
int maxValue = 0;
int num4 = 700;
int num5 = 20;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].CanBeChasedBy(this, false))
{
float num6 = (Center - Main.npc[index].Center).Length();
if (num6 > num5 && num6 < num4 && Collision.CanHitLine(Center, 1, 1, Main.npc[index].Center, 1, 1))
{
numArray[maxValue] = index;
++maxValue;
if (maxValue >= 9)
break;
}
}
}
if (maxValue > 0)
{
int index = Main.rand.Next(maxValue);
Vector2 vector2_3 = Main.npc[numArray[index]].Center - Center;
float num6 = velocity.Length();
vector2_3.Normalize();
velocity = vector2_3 * num6;
netUpdate = true;
}
}
}
else if (type == 94 || type == 496)
{
if (velocity.X != vector2_2.X)
{
if (Math.Abs(velocity.X) < 1.0)
velocity.X = -vector2_2.X;
else
Kill();
}
if (velocity.Y != vector2_2.Y)
{
if (Math.Abs(velocity.Y) < 1.0)
velocity.Y = -vector2_2.Y;
else
Kill();
}
}
else if (type == 311)
{
if (velocity.X != vector2_2.X)
{
velocity.X = -vector2_2.X;
++ai[1];
}
if (velocity.Y != vector2_2.Y)
{
velocity.Y = -vector2_2.Y;
++ai[1];
}
if (ai[1] > 4.0)
Kill();
}
else if (type == 312)
{
if (velocity.X != vector2_2.X)
{
velocity.X = -vector2_2.X;
++ai[1];
}
if (velocity.Y != vector2_2.Y)
{
velocity.Y = -vector2_2.Y;
++ai[1];
}
}
else if (type == 522 || type == 620)
{
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else if (type == 524)
{
ai[0] += 100f;
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else if (aiStyle == 93)
{
if (velocity != vector2_2)
{
ai[1] = 0.0f;
ai[0] = 1f;
netUpdate = true;
tileCollide = false;
Projectile projectile1 = this;
Vector2 vector2_3 = projectile1.position + velocity;
projectile1.position = vector2_3;
velocity = vector2_2;
velocity.Normalize();
Projectile projectile2 = this;
Vector2 vector2_4 = projectile2.velocity * 3f;
projectile2.velocity = vector2_4;
}
}
else if (type == 281)
{
if ((Math.Abs(velocity.X) + Math.Abs(velocity.Y)) < 2.0 || ai[1] == 2.0)
{
ai[1] = 2f;
}
else
{
if (velocity.X != vector2_2.X)
velocity.X = (float)(-vector2_2.X * 0.5);
if (velocity.Y != vector2_2.Y)
velocity.Y = (float)(-vector2_2.Y * 0.5);
}
}
else if (type == 290 || type == 294)
{
if (velocity.X != vector2_2.X)
{
position.X += velocity.X;
velocity.X = -vector2_2.X;
}
if (velocity.Y != vector2_2.Y)
{
position.Y += velocity.Y;
velocity.Y = -vector2_2.Y;
}
}
else if ((type == 181 || type == 189 || (type == 357 || type == 566)) && penetrate > 0)
{
if (type == 357)
damage = (int)(damage * 0.9);
--penetrate;
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else if (type == 307 && ai[1] < 5.0)
{
++ai[1];
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else if (type == 99)
{
if (velocity.Y != vector2_2.Y && vector2_2.Y > 5.0)
{
Collision.HitTiles(position, velocity, width, height);
Main.PlaySound(0, (int)position.X, (int)position.Y, 1);
velocity.Y = (float)(-vector2_2.Y * 0.200000002980232);
}
if (velocity.X != vector2_2.X)
Kill();
}
else if (type == 36)
{
if (penetrate > 1)
{
Collision.HitTiles(position, velocity, width, height);
Main.PlaySound(2, (int)position.X, (int)position.Y, 10);
--penetrate;
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else
Kill();
}
else if (aiStyle == 21)
{
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else if (aiStyle == 17)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.75f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 1.5)
velocity.Y = vector2_2.Y * -0.7f;
}
else if (aiStyle == 15)
{
bool flag2 = false;
if (vector2_2.X != velocity.X)
{
if (Math.Abs(vector2_2.X) > 4.0)
flag2 = true;
position.X += velocity.X;
velocity.X = (float)(-vector2_2.X * 0.200000002980232);
}
if (vector2_2.Y != velocity.Y)
{
if (Math.Abs(vector2_2.Y) > 4.0)
flag2 = true;
position.Y += velocity.Y;
velocity.Y = (float)(-vector2_2.Y * 0.200000002980232);
}
ai[0] = 1f;
if (flag2)
{
netUpdate = true;
Collision.HitTiles(position, velocity, width, height);
Main.PlaySound(0, (int)position.X, (int)position.Y, 1);
}
if (wet)
vector2_1 = velocity;
}
else if (aiStyle == 39)
{
Collision.HitTiles(position, velocity, width, height);
if (type == 33 || type == 106)
{
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else
{
ai[0] = 1f;
if (aiStyle == 3)
{
velocity.X = -vector2_2.X;
velocity.Y = -vector2_2.Y;
}
}
netUpdate = true;
Main.PlaySound(0, (int)position.X, (int)position.Y, 1);
}
else if (aiStyle == 3 || aiStyle == 13 || (aiStyle == 69 || aiStyle == 109))
{
Collision.HitTiles(position, velocity, width, height);
if (type == 33 || type == 106)
{
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
}
else
{
ai[0] = 1f;
if ((aiStyle == 3 || aiStyle == 109) && type != 383)
{
velocity.X = -vector2_2.X;
velocity.Y = -vector2_2.Y;
}
}
netUpdate = true;
Main.PlaySound(0, (int)position.X, (int)position.Y, 1);
}
else if (aiStyle == 8 && type != 96)
{
Main.PlaySound(2, (int)position.X, (int)position.Y, 10);
++ai[0];
if (ai[0] >= 5.0 && type != 253 || type == 253 && ai[0] >= 8.0)
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + velocity;
projectile.position = vector2_3;
Kill();
}
else
{
if (type == 15 && velocity.Y > 4.0)
{
if (velocity.Y != vector2_2.Y)
velocity.Y = (float)(-vector2_2.Y * 0.800000011920929);
}
else if (velocity.Y != vector2_2.Y)
velocity.Y = -vector2_2.Y;
if (velocity.X != vector2_2.X)
velocity.X = -vector2_2.X;
}
}
else if (aiStyle == 61)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.3f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 1.0)
velocity.Y = vector2_2.Y * -0.3f;
}
else if (aiStyle == 14)
{
if (type == 261 && (velocity.X != vector2_2.X && (vector2_2.X < -3.0 || vector2_2.X > 3.0) || velocity.Y != vector2_2.Y && (vector2_2.Y < -3.0 || vector2_2.Y > 3.0)))
{
Collision.HitTiles(position, velocity, width, height);
Main.PlaySound(0, (int)Center.X, (int)Center.Y, 1);
}
if (type >= 326 && type <= 328 && velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.1f;
if (type >= 400 && type <= 402)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.1f;
}
else if (type == 50)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.2f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 1.5)
velocity.Y = vector2_2.Y * -0.2f;
}
else if (type == 185)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.9f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 1.0)
velocity.Y = vector2_2.Y * -0.9f;
}
else if (type == 277)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.9f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 3.0)
velocity.Y = vector2_2.Y * -0.9f;
}
else if (type != 480)
{
if (type == 450)
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.1f;
}
else
{
if (velocity.X != vector2_2.X)
velocity.X = vector2_2.X * -0.5f;
if (velocity.Y != vector2_2.Y && vector2_2.Y > 1.0)
velocity.Y = vector2_2.Y * -0.5f;
}
}
}
else if (aiStyle == 16)
{
if (velocity.X != vector2_2.X)
{
velocity.X = vector2_2.X * -0.4f;
if (type == 29)
velocity.X = velocity.X * 0.8f;
}
if (velocity.Y != vector2_2.Y && vector2_2.Y > 0.7 && type != 102)
{
velocity.Y = vector2_2.Y * -0.4f;
if (type == 29)
velocity.Y = velocity.Y * 0.8f;
}
if (type == 134 || type == 137 || (type == 140 || type == 143) || (type == 303 || type >= 338 && type <= 341))
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.velocity * 0.0f;
projectile.velocity = vector2_3;
alpha = 255;
timeLeft = 3;
}
}
else if (aiStyle == 68)
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.velocity * 0.0f;
projectile.velocity = vector2_3;
alpha = 255;
timeLeft = 3;
}
else if (aiStyle != 9 || owner == Main.myPlayer)
{
Projectile projectile = this;
Vector2 vector2_3 = projectile.position + velocity;
projectile.position = vector2_3;
Kill();
}
}
}
}
}
if (aiStyle != 4 && aiStyle != 38 && aiStyle != 84 && (aiStyle != 7 || ai[0] != 2.0) && (type != 440 && type != 449 && type != 606 || ai[1] != 1.0) && ((aiStyle != 93 || ai[0] >= 0.0) && type != 540))
{
if (wet)
{
Projectile projectile = this;
Vector2 vector2_2 = projectile.position + vector2_1;
projectile.position = vector2_2;
}
else
{
Projectile projectile = this;
Vector2 vector2_2 = projectile.position + velocity;
projectile.position = vector2_2;
}
if (Main.projPet[type] && tileCollide)
{
Vector4 vector4 = Collision.SlopeCollision(position, velocity, width, height, 0.0f, false);
position.X = vector4.X;
position.Y = vector4.Y;
velocity.X = vector4.Z;
velocity.Y = vector4.W;
}
}
if ((aiStyle != 3 || ai[0] != 1.0) && (aiStyle != 7 || ai[0] != 1.0) && ((aiStyle != 13 || ai[0] != 1.0) && (aiStyle != 65 && aiStyle != 69)) && (aiStyle != 114 && aiStyle != 123 && (aiStyle != 112 && !manualDirectionChange) && (aiStyle != 67 && aiStyle != 26 && aiStyle != 15)))
{
if (velocity.X < 0.0)
direction = -1;
else
direction = 1;
}
if (!active)
return;
ProjLight();
if (!npcProj && friendly && (Main.player[owner].magicQuiver && extraUpdates < 1) && arrow)
extraUpdates = 1;
if (type == 2 || type == 82)
Dust.NewDust(new Vector2(position.X, position.Y), width, height, 6, 0.0f, 0.0f, 100, new Color(), 1f);
else if (type == 172)
Dust.NewDust(new Vector2(position.X, position.Y), width, height, 135, 0.0f, 0.0f, 100, new Color(), 1f);
else if (type == 103)
{
int index = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 75, 0.0f, 0.0f, 100, new Color(), 1f);
if (Main.rand.Next(2) == 0)
{
Main.dust[index].noGravity = true;
Main.dust[index].scale *= 2f;
}
}
else if (type == 278)
{
int index = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 169, 0.0f, 0.0f, 100, new Color(), 1f);
if (Main.rand.Next(2) == 0)
{
Main.dust[index].noGravity = true;
Main.dust[index].scale *= 1.5f;
}
}
else if (type == 4)
{
if (Main.rand.Next(5) == 0)
Dust.NewDust(new Vector2(position.X, position.Y), width, height, 14, 0.0f, 0.0f, 150, new Color(), 1.1f);
}
else if (type == 5)
{
int Type;
switch (Main.rand.Next(3))
{
case 0:
Type = 15;
break;
case 1:
Type = 57;
break;
default:
Type = 58;
break;
}
Dust.NewDust(position, width, height, Type, velocity.X * 0.5f, velocity.Y * 0.5f, 150, new Color(), 1.2f);
}
Damage();
if (type == 434 && localAI[0] == 0.0 && numUpdates == 0)
{
extraUpdates = 1;
velocity = Vector2.Zero;
localAI[0] = 1f;
localAI[1] = 0.9999f;
netUpdate = true;
}
if (Main.netMode != 1 && type == 99)
Collision.SwitchTiles(position, width, height, oldPosition, 3);
if (ProjectileID.Sets.TrailingMode[type] == 0)
{
for (int index = oldPos.Length - 1; index > 0; --index)
oldPos[index] = oldPos[index - 1];
oldPos[0] = position;
}
else if (ProjectileID.Sets.TrailingMode[type] == 1)
{
if (frameCounter == 0 || oldPos[0] == Vector2.Zero)
{
for (int index = oldPos.Length - 1; index > 0; --index)
oldPos[index] = oldPos[index - 1];
oldPos[0] = position;
if (velocity == Vector2.Zero && type == 466)
{
float num2 = (float)(rotation + 1.57079637050629 + (Main.rand.Next(2) == 1 ? -1.0 : 1.0) * 1.57079637050629);
float num3 = (float)(Main.rand.NextDouble() * 2.0 + 2.0);
Vector2 vector2_2 = new Vector2((float)Math.Cos(num2) * num3, (float)Math.Sin(num2) * num3);
int index = Dust.NewDust(oldPos[oldPos.Length - 1], 0, 0, 229, vector2_2.X, vector2_2.Y, 0, new Color(), 1f);
Main.dust[index].noGravity = true;
Main.dust[index].scale = 1.7f;
}
if (velocity == Vector2.Zero && type == 580)
{
float num2 = (float)(rotation + 1.57079637050629 + (Main.rand.Next(2) == 1 ? -1.0 : 1.0) * 1.57079637050629);
float num3 = (float)(Main.rand.NextDouble() * 2.0 + 2.0);
Vector2 vector2_2 = new Vector2((float)Math.Cos(num2) * num3, (float)Math.Sin(num2) * num3);
int index = Dust.NewDust(oldPos[oldPos.Length - 1], 0, 0, 229, vector2_2.X, vector2_2.Y, 0, new Color(), 1f);
Main.dust[index].noGravity = true;
Main.dust[index].scale = 1.7f;
}
}
}
else if (ProjectileID.Sets.TrailingMode[type] == 2)
{
for (int index = oldPos.Length - 1; index > 0; --index)
{
oldPos[index] = oldPos[index - 1];
oldRot[index] = oldRot[index - 1];
oldSpriteDirection[index] = oldSpriteDirection[index - 1];
}
oldPos[0] = position;
oldRot[0] = rotation;
oldSpriteDirection[0] = spriteDirection;
}
--timeLeft;
if (timeLeft <= 0)
Kill();
if (penetrate == 0)
Kill();
if (active && owner == Main.myPlayer)
{
if (netUpdate2)
netUpdate = true;
if (!active)
netSpam = 0;
if (netUpdate)
{
if (netSpam < 60)
{
netSpam += 5;
NetMessage.SendData(27, -1, -1, "", i, 0.0f, 0.0f, 0.0f, 0, 0, 0);
netUpdate2 = false;
}
else
netUpdate2 = true;
}
if (netSpam > 0)
--netSpam;
}
}
}
netUpdate = false;
}