Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ HandleMovement()

void Terraria.Projectile.HandleMovement ( Vector2 wetVelocity,
out int overrideWidth,
out int overrideHeight )
inlineprivate

Definition at line 15044 of file Projectile.cs.

15045 {
15046 bool flag = false;
15047 overrideWidth = -1;
15048 overrideHeight = -1;
15049 bool flag2 = false;
15051 bool flag4 = flag3.HasValue && !flag3.Value;
15052 bool flag5 = flag3.HasValue && flag3.Value;
15053 if (tileCollide)
15054 {
15056 bool flag6 = true;
15057 Vector2? vector = null;
15058 if (Main.projPet[type])
15059 {
15060 flag6 = false;
15061 if (Main.player[owner].position.Y + (float)Main.player[owner].height - 12f > position.Y + (float)height)
15062 {
15063 flag6 = true;
15064 }
15065 }
15066 if (type == 500)
15067 {
15068 flag6 = false;
15069 if (Main.player[owner].Bottom.Y > base.Bottom.Y + 4f)
15070 {
15071 flag6 = true;
15072 }
15073 }
15074 if (type == 653 || type == 668)
15075 {
15076 flag6 = false;
15077 if (Main.player[owner].Bottom.Y > base.Bottom.Y + 4f)
15078 {
15079 flag6 = true;
15080 }
15081 }
15082 if (aiStyle == 62)
15083 {
15084 flag6 = true;
15085 }
15086 if (aiStyle == 66)
15087 {
15088 flag6 = true;
15089 }
15090 if (type == 317)
15091 {
15092 flag6 = true;
15093 }
15094 if (type == 373)
15095 {
15096 flag6 = true;
15097 }
15098 if (aiStyle == 53)
15099 {
15100 flag6 = false;
15101 }
15102 if (type == 9 || type == 12 || type == 15 || type == 13)
15103 {
15104 flag6 = false;
15105 }
15107 {
15108 flag6 = false;
15109 }
15110 if (type == 24)
15111 {
15112 flag6 = false;
15113 }
15114 switch (type)
15115 {
15116 case 663:
15117 case 665:
15118 case 667:
15119 case 677:
15120 case 678:
15121 case 679:
15122 case 688:
15123 case 689:
15124 case 690:
15125 case 691:
15126 case 692:
15127 case 693:
15128 flag6 = false;
15129 break;
15130 case 759:
15131 flag6 = true;
15132 break;
15133 case 1020:
15134 {
15135 float num = MathHelper.WrapAngle(rotation);
15136 flag6 = num >= (float)Math.PI / 2f || num < -(float)Math.PI / 2f;
15137 break;
15138 }
15139 }
15141 {
15143 }
15144 if (type == 771 || type == 822 || type == 823 || type == 843 || type == 846 || type == 845 || type == 852)
15145 {
15147 overrideHeight = 34;
15148 vector = new Vector2(0.75f, 0.75f);
15149 }
15150 if (type == 969)
15151 {
15152 overrideWidth = 18;
15153 overrideHeight = 32;
15154 }
15155 if (type == 824 || type == 839 || type == 840 || type == 850 || type == 853)
15156 {
15158 overrideHeight = 58;
15159 vector = new Vector2(0.75f, 0.75f);
15160 }
15161 if (type == 826 || type == 830 || type == 838)
15162 {
15164 overrideHeight = 38;
15165 vector = new Vector2(0.75f, 0.75f);
15166 }
15167 if (type == 828 || type == 829 || type == 827 || type == 844)
15168 {
15170 overrideHeight = 22;
15171 vector = new Vector2(0.75f, 0.75f);
15172 }
15173 if (aiStyle == 29 || type == 28 || aiStyle == 49 || type == 906 || type == 903 || type == 904 || type == 910)
15174 {
15175 overrideWidth = width - 8;
15176 overrideHeight = height - 8;
15177 }
15178 else if (type == 250 || type == 267 || type == 297 || type == 323 || type == 3 || type == 711)
15179 {
15180 overrideWidth = 6;
15181 overrideHeight = 6;
15182 }
15183 else if (type == 308)
15184 {
15185 overrideWidth = 26;
15187 }
15188 else if (type == 663 || type == 665 || type == 667 || type == 677 || type == 678 || type == 679 || type == 691 || type == 692 || type == 693)
15189 {
15190 overrideWidth = 16;
15192 }
15193 else if (type == 688 || type == 689 || type == 690)
15194 {
15195 overrideWidth = 16;
15197 vector = new Vector2(0.5f, 1f);
15198 }
15199 else if (type == 669 || type == 706)
15200 {
15201 overrideWidth = 10;
15202 overrideHeight = 10;
15203 }
15204 else if (type == 261 || type == 277)
15205 {
15206 overrideWidth = 26;
15207 overrideHeight = 26;
15208 }
15209 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 == 52 || type == 520 || type == 523 || type == 585 || type == 598 || type == 599 || type == 636 || type == 837 || type == 861 || type == 867 || type == 971 || type == 975 || type == 1000)
15210 {
15211 overrideWidth = 10;
15212 overrideHeight = 10;
15213 }
15214 else if (type == 514)
15215 {
15216 overrideWidth = 4;
15217 overrideHeight = 4;
15218 }
15219 else if (type == 248 || type == 247 || type == 507 || type == 508 || type == 662 || type == 680 || type == 685 || type == 757 || type == 928)
15220 {
15221 overrideWidth = width - 12;
15222 overrideHeight = height - 12;
15223 }
15224 else if (aiStyle == 18 || type == 254)
15225 {
15226 overrideWidth = width - 36;
15227 overrideHeight = height - 36;
15228 }
15229 else if (type == 182 || type == 190 || type == 33 || type == 229 || type == 237 || type == 243 || type == 866)
15230 {
15231 overrideWidth = width - 20;
15232 overrideHeight = height - 20;
15233 }
15234 else if (aiStyle == 27)
15235 {
15236 overrideWidth = width - 12;
15237 overrideHeight = height - 12;
15238 }
15239 else if (type == 533 && ai[0] >= 6f)
15240 {
15241 overrideWidth = width + 6;
15242 overrideHeight = height + 6;
15243 }
15244 else if (type == 755 && ai[0] >= 0f)
15245 {
15246 overrideWidth = width + 6;
15247 overrideHeight = height + 6;
15248 }
15249 else if (type == 759)
15250 {
15251 if (velocity.X != lastVelocity.X)
15252 {
15253 velocity.X = 0f - lastVelocity.X;
15254 }
15255 if (velocity.Y != lastVelocity.Y)
15256 {
15257 velocity.Y = 0f - lastVelocity.Y;
15258 }
15259 }
15260 else if (type == 582 || type == 634 || type == 635 || type == 902)
15261 {
15262 overrideWidth = 8;
15263 overrideHeight = 8;
15264 }
15265 else if (type == 617)
15266 {
15267 overrideWidth = (int)(20f * scale);
15268 overrideHeight = (int)(20f * scale);
15269 }
15270 else if (type == 304)
15271 {
15272 overrideWidth = 4;
15273 overrideHeight = 4;
15274 }
15275 else if (aiStyle == 9)
15276 {
15277 overrideWidth = 4;
15278 overrideHeight = 4;
15279 }
15280 else if (type == 931)
15281 {
15282 overrideWidth = 4;
15283 overrideHeight = 4;
15284 }
15285 if (((type != 440 && type != 449 && type != 606) || ai[1] != 1f) && (type != 466 || localAI[1] != 1f) && (type != 580 || !(localAI[1] > 0f)) && (type != 640 || !(localAI[1] > 0f)))
15286 {
15287 if (aiStyle == 10)
15288 {
15289 if (type >= 736 && type <= 738)
15290 {
15291 velocity = Collision.TileCollision(position, velocity, width, height, flag6, flag6);
15292 }
15293 else if (type == 411 || type == 412 || type == 413 || type == 414)
15294 {
15295 velocity = Collision.TileCollision(position, velocity, width, height, flag6, flag6);
15296 velocity = Collision.AnyCollisionWithSpecificTiles(position, velocity, width, height, TileID.Sets.Falling, evenActuated: true);
15297 }
15298 else if (type == 42 || type == 65 || type == 68 || type == 354 || (type == 31 && ai[0] == 2f))
15299 {
15300 velocity = Collision.TileCollision(position, velocity, width, height, flag6, flag6);
15301 }
15302 else
15303 {
15304 velocity = Collision.TileCollision(position, velocity, width, height, flag6, flag6);
15305 }
15306 }
15307 else
15308 {
15310 int num2 = ((overrideWidth != -1) ? overrideWidth : width);
15311 int num3 = ((overrideHeight != -1) ? overrideHeight : height);
15312 if (overrideHeight != -1 || overrideWidth != -1)
15313 {
15314 vector2 = ((!vector.HasValue) ? new Vector2(position.X + (float)(width / 2) - (float)(num2 / 2), position.Y + (float)(height / 2) - (float)(num3 / 2)) : (base.Center - new Vector2(num2, num3) * vector.Value));
15315 }
15316 if (wet)
15317 {
15318 if (shimmerWet)
15319 {
15321 velocity = Collision.TileCollision(vector2, velocity, num2, num3, flag6, flag6);
15322 wetVelocity = velocity * 0.375f;
15323 if (velocity.X != vector3.X)
15324 {
15325 wetVelocity.X = velocity.X;
15326 }
15327 if (velocity.Y != vector3.Y)
15328 {
15329 wetVelocity.Y = velocity.Y;
15330 }
15331 }
15332 else if (honeyWet)
15333 {
15335 velocity = Collision.TileCollision(vector2, velocity, num2, num3, flag6, flag6);
15336 wetVelocity = velocity * 0.25f;
15337 if (velocity.X != vector4.X)
15338 {
15339 wetVelocity.X = velocity.X;
15340 }
15341 if (velocity.Y != vector4.Y)
15342 {
15343 wetVelocity.Y = velocity.Y;
15344 }
15345 }
15346 else
15347 {
15349 velocity = Collision.TileCollision(vector2, velocity, num2, num3, flag6, flag6);
15350 wetVelocity = velocity * 0.5f;
15351 if (velocity.X != vector5.X)
15352 {
15353 wetVelocity.X = velocity.X;
15354 }
15355 if (velocity.Y != vector5.Y)
15356 {
15357 wetVelocity.Y = velocity.Y;
15358 }
15359 }
15360 if (!Main.projPet[type])
15361 {
15362 Vector4 vector6 = Collision.SlopeCollision(vector2, velocity, num2, num3, 0f, fall: true);
15364 if (aiStyle == 137)
15365 {
15366 if (vector2.Y != vector6.Y)
15367 {
15368 flag = true;
15369 }
15370 if (velocity.Y != vector6.W)
15371 {
15372 flag = true;
15373 }
15374 vector2.Y = vector6.Y;
15375 position.Y = vector2.Y + vector7.Y;
15376 velocity.Y = vector6.W;
15377 }
15378 else
15379 {
15380 if (vector2.X != vector6.X)
15381 {
15382 flag = true;
15383 }
15384 if (vector2.Y != vector6.Y)
15385 {
15386 flag = true;
15387 }
15388 if (velocity.X != vector6.Z)
15389 {
15390 flag = true;
15391 }
15392 if (velocity.Y != vector6.W)
15393 {
15394 flag = true;
15395 }
15396 vector2.X = vector6.X;
15397 vector2.Y = vector6.Y;
15399 velocity.X = vector6.Z;
15400 velocity.Y = vector6.W;
15401 }
15402 }
15403 }
15404 else
15405 {
15406 int num4 = Math.Min(num2, num3);
15407 if (num4 < 3)
15408 {
15409 num4 = 3;
15410 }
15411 if (num4 > 16)
15412 {
15413 num4 = 16;
15414 }
15415 if (velocity.Length() > (float)num4)
15416 {
15417 Vector2 vector8 = Collision.TileCollision(vector2, velocity, num2, num3, flag6, flag6);
15418 float num5 = velocity.Length();
15419 float num6 = num4;
15420 Vector2 vector9 = velocity.SafeNormalize(Vector2.Zero);
15421 if (vector8.Y == 0f)
15422 {
15423 vector9.Y = 0f;
15424 }
15426 _ = Vector2.Zero;
15427 _ = Vector2.Zero;
15429 int num7 = 0;
15430 while (num5 > 0f)
15431 {
15432 num7++;
15433 if (num7 > 300)
15434 {
15435 break;
15436 }
15437 vector10 = vector2;
15438 float num8 = num5;
15439 if (num8 > num6)
15440 {
15441 num8 = num6;
15442 }
15443 num5 -= num8;
15445 Vector2 vector12 = Collision.TileCollision(vector2, vector11, num2, num3, flag6, flag6);
15446 vector2 += vector12;
15448 if (!Main.projPet[type])
15449 {
15450 Vector4 vector13 = Collision.SlopeCollision(vector2, velocity, num2, num3, 0f, fall: true);
15452 if (aiStyle == 137)
15453 {
15454 if (vector2.Y != vector13.Y)
15455 {
15456 flag = true;
15457 }
15458 if (velocity.Y != vector13.W)
15459 {
15460 flag = true;
15461 }
15462 vector2.Y = vector13.Y;
15463 position.Y = vector2.Y + vector14.Y;
15464 velocity.Y = vector13.W;
15465 }
15466 else
15467 {
15468 if (vector2.X != vector13.X)
15469 {
15470 flag = true;
15471 }
15472 if (vector2.Y != vector13.Y)
15473 {
15474 flag = true;
15475 }
15476 if (velocity.X != vector13.Z)
15477 {
15478 flag = true;
15479 }
15480 if (velocity.Y != vector13.W)
15481 {
15482 flag = true;
15483 }
15484 vector2.X = vector13.X;
15485 vector2.Y = vector13.Y;
15487 velocity.X = vector13.Z;
15488 velocity.Y = vector13.W;
15489 }
15490 }
15491 flag2 = true;
15492 if (owner == Main.myPlayer && vector2 != vector10 && !flag4)
15493 {
15494 Collision.SwitchTiles(vector2, num2, num3, vector10, 4);
15495 }
15497 zero += vector12;
15498 }
15499 velocity = zero;
15500 if (Math.Abs(velocity.X - lastVelocity.X) < 0.0001f)
15501 {
15502 velocity.X = lastVelocity.X;
15503 }
15504 if (Math.Abs(velocity.Y - lastVelocity.Y) < 0.0001f)
15505 {
15506 velocity.Y = lastVelocity.Y;
15507 }
15508 if (!Main.projPet[type])
15509 {
15510 Vector4 vector15 = Collision.SlopeCollision(vector2, velocity, num2, num3, 0f, fall: true);
15512 if (aiStyle == 137)
15513 {
15514 if (vector2.Y != vector15.Y)
15515 {
15516 flag = true;
15517 }
15518 if (velocity.Y != vector15.W)
15519 {
15520 flag = true;
15521 }
15522 vector2.Y = vector15.Y;
15523 position.Y = vector2.Y + vector16.Y;
15524 velocity.Y = vector15.W;
15525 }
15526 else
15527 {
15528 if (vector2.X != vector15.X)
15529 {
15530 flag = true;
15531 }
15532 if (vector2.Y != vector15.Y)
15533 {
15534 flag = true;
15535 }
15536 if (velocity.X != vector15.Z)
15537 {
15538 flag = true;
15539 }
15540 if (velocity.Y != vector15.W)
15541 {
15542 flag = true;
15543 }
15544 vector2.X = vector15.X;
15545 vector2.Y = vector15.Y;
15547 velocity.X = vector15.Z;
15548 velocity.Y = vector15.W;
15549 }
15550 }
15551 }
15552 else
15553 {
15554 velocity = Collision.TileCollision(vector2, velocity, num2, num3, flag6, flag6);
15555 if (!Main.projPet[type])
15556 {
15557 Vector4 vector17 = Collision.SlopeCollision(vector2, velocity, num2, num3, 0f, fall: true);
15559 if (aiStyle == 137)
15560 {
15561 if (vector2.Y != vector17.Y)
15562 {
15563 flag = true;
15564 }
15565 if (velocity.Y != vector17.W)
15566 {
15567 flag = true;
15568 }
15569 vector2.Y = vector17.Y;
15570 position.Y = vector2.Y + vector18.Y;
15571 velocity.Y = vector17.W;
15572 }
15573 else
15574 {
15575 if (vector2.X != vector17.X)
15576 {
15577 flag = true;
15578 }
15579 if (vector2.Y != vector17.Y)
15580 {
15581 flag = true;
15582 }
15583 if (velocity.X != vector17.Z)
15584 {
15585 flag = true;
15586 }
15587 if (velocity.Y != vector17.W)
15588 {
15589 flag = true;
15590 }
15591 vector2.X = vector17.X;
15592 vector2.Y = vector17.Y;
15594 velocity.X = vector17.Z;
15595 velocity.Y = vector17.W;
15596 }
15597 }
15598 }
15599 }
15600 }
15601 }
15602 if (lastVelocity != velocity)
15603 {
15604 flag = true;
15605 }
15606 if (flag)
15607 {
15608 if (owner == Main.myPlayer && CanCutTiles() && (friendly || hostile) && damage > 0)
15609 {
15610 int num9 = (int)(position.X + velocity.X - 1f) / 16;
15611 int num10 = (int)((position.X + (float)width + velocity.X + 1f) / 16f) + 1;
15612 int num11 = (int)(position.Y + velocity.Y - 1f) / 16;
15613 int num12 = (int)((position.Y + (float)height + velocity.Y + 1f) / 16f) + 1;
15614 if (num9 < 0)
15615 {
15616 num9 = 0;
15617 }
15618 if (num10 > Main.maxTilesX)
15619 {
15620 num10 = Main.maxTilesX;
15621 }
15622 if (num11 < 0)
15623 {
15624 num11 = 0;
15625 }
15626 if (num12 > Main.maxTilesY)
15627 {
15628 num12 = Main.maxTilesY;
15629 }
15630 bool[] tileCutIgnorance = Main.player[owner].GetTileCutIgnorance(allowRegrowth: false, trap);
15631 for (int i = num9; i < num10; i++)
15632 {
15633 for (int j = num11; j < num12; j++)
15634 {
15635 if (Main.tile[i, j] != null && !tileCutIgnorance[Main.tile[i, j].type] && Main.tile[i, j].type == 484 && WorldGen.CanCutTile(i, j, TileCuttingContext.AttackProjectile))
15636 {
15637 WorldGen.KillTile(i, j);
15638 if (Main.netMode != 0)
15639 {
15640 NetMessage.SendData(17, -1, -1, null, 0, i, j);
15641 }
15642 }
15643 }
15644 }
15645 }
15646 if (Main.rand.Next(3) == 0 && owner == Main.myPlayer && CanCutTiles() && (friendly || hostile) && damage > 0)
15647 {
15648 int num13 = (int)(position.X + velocity.X - 1f) / 16;
15649 int num14 = (int)((position.X + (float)width + velocity.X + 1f) / 16f) + 1;
15650 int num15 = (int)(position.Y + velocity.Y - 1f) / 16;
15651 int num16 = (int)((position.Y + (float)height + velocity.Y + 1f) / 16f) + 1;
15652 if (num13 < 0)
15653 {
15654 num13 = 0;
15655 }
15656 if (num14 > Main.maxTilesX)
15657 {
15658 num14 = Main.maxTilesX;
15659 }
15660 if (num15 < 0)
15661 {
15662 num15 = 0;
15663 }
15664 if (num16 > Main.maxTilesY)
15665 {
15666 num16 = Main.maxTilesY;
15667 }
15668 bool[] tileCutIgnorance2 = Main.player[owner].GetTileCutIgnorance(allowRegrowth: false, trap);
15669 for (int k = num13; k < num14; k++)
15670 {
15671 for (int l = num15; l < num16; l++)
15672 {
15673 if (Main.tile[k, l] != null && !tileCutIgnorance2[Main.tile[k, l].type] && TileID.Sets.CrackedBricks[Main.tile[k, l].type] && WorldGen.CanCutTile(k, l, TileCuttingContext.AttackProjectile))
15674 {
15675 WorldGen.KillTile(k, l);
15676 if (Main.netMode != 0)
15677 {
15678 NetMessage.SendData(17, -1, -1, null, 0, k, l);
15679 }
15680 }
15681 }
15682 }
15683 }
15684 if (type == 663 || type == 665 || type == 667 || type == 677 || type == 678 || type == 679 || type == 691 || type == 692 || type == 693 || type == 688 || type == 689 || type == 690)
15685 {
15686 position += velocity;
15688 }
15689 else if (type == 434)
15690 {
15691 position += velocity;
15692 numUpdates = 0;
15693 }
15694 else if (type == 1020)
15695 {
15696 if (velocity.X != lastVelocity.X && Math.Abs(lastVelocity.X) > 1f)
15697 {
15698 velocity.X = (0f - lastVelocity.X) * 0.25f;
15699 }
15700 if (velocity.Y != lastVelocity.Y && Math.Abs(lastVelocity.Y) > 1f)
15701 {
15702 velocity.Y = (0f - lastVelocity.Y) * 0.25f;
15703 }
15704 }
15705 else if (type == 601)
15706 {
15707 if (Main.netMode != 2 && alpha > 0)
15708 {
15709 if (ai[1] != 0f)
15710 {
15712 }
15713 else
15714 {
15716 }
15717 }
15718 if (owner == Main.myPlayer)
15719 {
15721 }
15722 position += velocity;
15723 Kill();
15724 }
15725 else if (type == 985)
15726 {
15727 position += velocity;
15729 velocity *= 0.01f;
15730 localAI[1] = 1f;
15731 }
15732 else if (type == 451)
15733 {
15734 ai[0] = 1f;
15735 ai[1] = 0f;
15736 netUpdate = true;
15737 velocity = lastVelocity / 2f;
15738 }
15739 else if (type == 645)
15740 {
15741 ai[0] = 0f;
15742 ai[1] = -1f;
15743 netUpdate = true;
15744 }
15745 else if (type == 584)
15746 {
15747 bool flag7 = false;
15748 if (velocity.X != lastVelocity.X)
15749 {
15750 velocity.X = lastVelocity.X * -0.75f;
15751 flag7 = true;
15752 }
15753 if ((velocity.Y != lastVelocity.Y && lastVelocity.Y > 2f) || velocity.Y == 0f)
15754 {
15755 velocity.Y = lastVelocity.Y * -0.75f;
15756 flag7 = true;
15757 }
15758 if (flag7)
15759 {
15760 float num17 = lastVelocity.Length() / velocity.Length();
15761 if (num17 == 0f)
15762 {
15763 num17 = 1f;
15764 }
15765 velocity /= num17;
15766 penetrate--;
15767 }
15768 }
15769 else if (type == 532)
15770 {
15771 bool flag8 = false;
15772 if (velocity.X != lastVelocity.X)
15773 {
15774 velocity.X = lastVelocity.X * -0.75f;
15775 flag8 = true;
15776 }
15777 if ((velocity.Y != lastVelocity.Y && lastVelocity.Y > 2f) || velocity.Y == 0f)
15778 {
15779 velocity.Y = lastVelocity.Y * -0.75f;
15780 flag8 = true;
15781 }
15782 if (flag8)
15783 {
15784 float num18 = lastVelocity.Length() / velocity.Length();
15785 if (num18 == 0f)
15786 {
15787 num18 = 1f;
15788 }
15789 velocity /= num18;
15790 penetrate--;
15791 Collision.HitTiles(position, lastVelocity, width, height);
15792 }
15793 }
15794 else if (type == 533)
15795 {
15796 float num19 = 1f;
15797 bool flag9 = false;
15798 if (velocity.X != lastVelocity.X)
15799 {
15800 velocity.X = lastVelocity.X * (0f - num19);
15801 flag9 = true;
15802 }
15803 if (velocity.Y != lastVelocity.Y || velocity.Y == 0f)
15804 {
15805 velocity.Y = lastVelocity.Y * (0f - num19) * 0.5f;
15806 flag9 = true;
15807 }
15808 if (flag9)
15809 {
15810 float num20 = lastVelocity.Length() / velocity.Length();
15811 if (num20 == 0f)
15812 {
15813 num20 = 1f;
15814 }
15815 velocity /= num20;
15816 if (ai[0] == 7f && (double)velocity.Y < -0.1)
15817 {
15818 velocity.Y += 0.1f;
15819 }
15820 if (ai[0] >= 6f && ai[0] < 9f)
15821 {
15822 Collision.HitTiles(position, lastVelocity, width, height);
15823 }
15824 localAI[2] += 30f;
15825 }
15826 }
15827 else if (type == 502)
15828 {
15829 ai[0] += 1f;
15830 SoundEngine.PlaySound(37, (int)position.X, (int)position.Y, 5 + (int)ai[0]);
15831 if (ai[0] >= 5f)
15832 {
15833 position += velocity;
15834 Kill();
15835 }
15836 else
15837 {
15838 if (velocity.Y != lastVelocity.Y)
15839 {
15840 velocity.Y = 0f - lastVelocity.Y;
15841 }
15842 if (velocity.X != lastVelocity.X)
15843 {
15844 velocity.X = 0f - lastVelocity.X;
15845 }
15846 }
15847 Vector2 spinningpoint = new Vector2(0f, -3f - ai[0]).RotatedByRandom(3.1415927410125732);
15848 float num21 = 10f + ai[0] * 4f;
15849 Vector2 vector19 = new Vector2(1.05f, 1f);
15850 for (float num22 = 0f; num22 < num21; num22 += 1f)
15851 {
15852 int num23 = Dust.NewDust(base.Center, 0, 0, 66, 0f, 0f, 0, Color.Transparent);
15853 Main.dust[num23].position = base.Center;
15854 Main.dust[num23].velocity = spinningpoint.RotatedBy((float)Math.PI * 2f * num22 / num21) * vector19 * (0.8f + Main.rand.NextFloat() * 0.4f);
15855 Main.dust[num23].color = Main.hslToRgb(num22 / num21, 1f, 0.5f);
15856 Main.dust[num23].noGravity = true;
15857 Main.dust[num23].scale = 1f + ai[0] / 3f;
15858 }
15859 if (Main.myPlayer == owner)
15860 {
15861 int num24 = width;
15862 int num25 = height;
15863 int num26 = penetrate;
15864 position = base.Center;
15865 width = (height = 40 + 8 * (int)ai[0]);
15866 base.Center = position;
15867 penetrate = -1;
15868 Damage();
15869 penetrate = num26;
15870 position = base.Center;
15871 width = num24;
15872 height = num25;
15873 base.Center = position;
15874 }
15875 }
15876 else if (type == 444)
15877 {
15878 if (velocity.X != lastVelocity.X)
15879 {
15880 velocity.X = 0f - lastVelocity.X;
15881 }
15882 if (velocity.Y != lastVelocity.Y)
15883 {
15884 velocity.Y = 0f - lastVelocity.Y;
15885 }
15886 ai[0] = velocity.ToRotation();
15887 }
15888 else if (type == 617)
15889 {
15890 if (velocity.X != lastVelocity.X)
15891 {
15892 velocity.X = (0f - lastVelocity.X) * 0.35f;
15893 }
15894 if (velocity.Y != lastVelocity.Y)
15895 {
15896 velocity.Y = (0f - lastVelocity.Y) * 0.35f;
15897 }
15898 }
15899 else if (type == 440 || type == 449 || type == 606)
15900 {
15901 if (ai[1] != 1f)
15902 {
15903 ai[1] = 1f;
15904 position += velocity;
15906 }
15907 }
15908 else if (type == 85)
15909 {
15910 velocity = lastVelocity * 0.95f;
15911 position -= velocity;
15912 }
15913 else if (type == 466 || type == 580 || type == 640)
15914 {
15915 if (localAI[1] < 1f)
15916 {
15917 localAI[1] += 2f;
15918 position += velocity;
15920 }
15921 }
15922 else if (type == 851)
15923 {
15924 if (velocity.X != lastVelocity.X)
15925 {
15926 velocity.X = (0f - lastVelocity.X) * 0.8f;
15927 }
15928 if (velocity.Y != lastVelocity.Y)
15929 {
15930 velocity.Y = (0f - lastVelocity.Y) * 0.5f;
15931 }
15932 }
15933 else if (type == 855)
15934 {
15935 if (velocity.X != lastVelocity.X)
15936 {
15937 velocity.X = 0f - lastVelocity.X;
15938 }
15939 if (velocity.Y != lastVelocity.Y)
15940 {
15941 velocity.Y = 0f - lastVelocity.Y;
15942 if (lastVelocity.Y < 0f)
15943 {
15944 velocity.Y *= 0.25f;
15945 }
15946 }
15947 }
15948 else if (aiStyle == 54)
15949 {
15950 if (velocity.X != lastVelocity.X)
15951 {
15952 velocity.X = lastVelocity.X * -0.6f;
15953 }
15954 if (velocity.Y != lastVelocity.Y)
15955 {
15956 velocity.Y = lastVelocity.Y * -0.6f;
15957 }
15958 }
15959 else if (type == 861)
15960 {
15961 float num27 = -1f;
15962 if (ai[1] == 1f)
15963 {
15964 num27 = -0.6f;
15965 }
15966 if (velocity.X != lastVelocity.X)
15967 {
15968 velocity.X = lastVelocity.X * num27;
15969 }
15970 if (velocity.Y != lastVelocity.Y && (double)lastVelocity.Y > 0.7)
15971 {
15972 velocity.Y = lastVelocity.Y * num27;
15973 }
15974 if (Math.Abs(velocity.Y) < 0.5f)
15975 {
15976 velocity.Y = 0f;
15977 }
15978 if (ai[1] != 1f)
15979 {
15980 netUpdate = true;
15981 }
15982 ai[1] = 1f;
15983 }
15984 else if (!Main.projPet[type] && type != 500 && type != 820 && aiStyle != 160 && type != 650 && type != 882 && type != 888 && type != 894 && type != 895 && type != 898 && type != 901 && type != 957)
15985 {
15986 if (aiStyle == 99)
15987 {
15988 if (type >= 556 && type <= 561)
15989 {
15990 bool flag10 = false;
15991 if (velocity.X != lastVelocity.X)
15992 {
15993 flag10 = true;
15994 velocity.X = lastVelocity.X * -1f;
15995 }
15996 if (velocity.Y != lastVelocity.Y)
15997 {
15998 flag10 = true;
15999 velocity.Y = lastVelocity.Y * -1f;
16000 }
16001 if (flag10)
16002 {
16003 Vector2 vector20 = Main.player[owner].Center - base.Center;
16004 vector20.Normalize();
16006 vector20 *= 0.25f;
16007 velocity *= 0.75f;
16008 velocity += vector20;
16009 if (velocity.Length() > 6f)
16010 {
16011 velocity *= 0.5f;
16012 }
16013 }
16014 }
16015 }
16016 else if (type == 604)
16017 {
16018 if (velocity.X != lastVelocity.X)
16019 {
16020 velocity.X = 0f - lastVelocity.X;
16021 }
16022 if (velocity.Y != lastVelocity.Y)
16023 {
16024 velocity.Y = 0f - lastVelocity.Y;
16025 }
16026 }
16027 else if (type == 379)
16028 {
16029 if (velocity.X != lastVelocity.X)
16030 {
16031 velocity.X = lastVelocity.X * -0.6f;
16032 }
16033 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 2f)
16034 {
16035 velocity.Y = lastVelocity.Y * -0.6f;
16036 }
16037 }
16038 else if (type == 491)
16039 {
16040 if (ai[0] <= 0f)
16041 {
16042 ai[0] = -10f;
16043 }
16044 if (velocity.X != lastVelocity.X && Math.Abs(lastVelocity.X) > 0f)
16045 {
16046 velocity.X = lastVelocity.X * -1f;
16047 }
16048 if (velocity.Y != lastVelocity.Y && Math.Abs(lastVelocity.Y) > 0f)
16049 {
16050 velocity.Y = lastVelocity.Y * -1f;
16051 }
16052 }
16053 else if ((type >= 515 && type <= 517) || type == 637)
16054 {
16055 if (velocity.X != lastVelocity.X && Math.Abs(lastVelocity.X) > 1f)
16056 {
16057 velocity.X = lastVelocity.X * -0.9f;
16058 }
16059 if (velocity.Y != lastVelocity.Y && Math.Abs(lastVelocity.Y) > 1f)
16060 {
16061 velocity.Y = lastVelocity.Y * -0.9f;
16062 }
16063 }
16064 else if (type == 921 || type == 926 || type == 937)
16065 {
16066 if (velocity.X != lastVelocity.X && Math.Abs(lastVelocity.X) > 1f)
16067 {
16068 velocity.X = lastVelocity.X * -0.4f;
16069 }
16070 if (velocity.Y != lastVelocity.Y && Math.Abs(lastVelocity.Y) > 1f)
16071 {
16072 velocity.Y = lastVelocity.Y * -0.95f;
16073 }
16074 penetrate--;
16075 }
16076 else if (type == 969)
16077 {
16078 if (velocity.X != lastVelocity.X && Math.Abs(lastVelocity.X) > 1f)
16079 {
16080 velocity.X = lastVelocity.X * -0.75f;
16081 }
16082 if (velocity.Y != lastVelocity.Y && Math.Abs(lastVelocity.Y) > 1f)
16083 {
16084 velocity.Y = lastVelocity.Y * -0.75f;
16085 }
16086 }
16087 else if (type == 681)
16088 {
16089 timeLeft = 4;
16090 }
16091 else if (type == 409)
16092 {
16093 if (velocity.X != lastVelocity.X)
16094 {
16095 velocity.X = lastVelocity.X * -1f;
16096 }
16097 if (velocity.Y != lastVelocity.Y)
16098 {
16099 velocity.Y = lastVelocity.Y * -1f;
16100 }
16101 }
16102 else if (type == 254)
16103 {
16104 if (velocity.X != lastVelocity.X)
16105 {
16106 velocity.X = lastVelocity.X * -1f;
16107 }
16108 if (velocity.Y != lastVelocity.Y)
16109 {
16110 velocity.Y = lastVelocity.Y * -1f;
16111 }
16112 }
16113 else if (type == 225)
16114 {
16115 ai[1] += 1f;
16116 if (ai[1] == 1f)
16117 {
16118 damage = (int)((float)damage * 0.66f);
16119 }
16120 if (ai[1] >= 4f)
16121 {
16122 Kill();
16123 return;
16124 }
16125 velocity.X = 0f - lastVelocity.X;
16126 velocity.Y = 0f - lastVelocity.Y;
16128 if (num28 != -1)
16129 {
16130 NPC nPC = Main.npc[num28];
16131 float t = Distance(nPC.Center);
16132 Vector2 vector21 = -Vector2.UnitY * MathHelper.Lerp((float)nPC.height * 0.1f, (float)nPC.height * 0.5f, Utils.GetLerpValue(0f, 300f, t));
16133 velocity = DirectionTo(nPC.Center + vector21).SafeNormalize(-Vector2.UnitY) * velocity.Length();
16134 netUpdate = true;
16135 }
16136 }
16137 else if (type == 285)
16138 {
16139 ai[1] += 1f;
16140 if (ai[1] == 1f)
16141 {
16142 damage = (int)((float)damage * 0.66f);
16143 }
16144 if (ai[1] >= 2f)
16145 {
16146 Kill();
16147 return;
16148 }
16149 if (velocity.X != lastVelocity.X)
16150 {
16151 velocity.X = lastVelocity.X * -1f;
16152 }
16153 if (velocity.Y != lastVelocity.Y)
16154 {
16155 velocity.Y = lastVelocity.Y * -1f;
16156 }
16158 if (num29 != -1)
16159 {
16160 NPC nPC2 = Main.npc[num29];
16161 Distance(nPC2.Center);
16162 velocity = DirectionTo(nPC2.Center).SafeNormalize(-Vector2.UnitY) * velocity.Length();
16163 netUpdate = true;
16164 }
16165 }
16166 else if (type == 931)
16167 {
16168 if (velocity.X != lastVelocity.X)
16169 {
16170 velocity.X = lastVelocity.X * -1f;
16171 }
16172 if (velocity.Y != lastVelocity.Y)
16173 {
16174 velocity.Y = lastVelocity.Y * -1f;
16175 }
16176 }
16177 else if (type == 155)
16178 {
16179 if (ai[1] > 10f)
16180 {
16181 NetworkText networkText = NetworkText.FromKey("Game.BallBounceResult", NetworkText.FromKey(Lang.GetProjectileName(type).Key), ai[1]);
16182 if (Main.netMode == 0)
16183 {
16184 Main.NewText(networkText.ToString(), byte.MaxValue, 240, 20);
16185 }
16186 else if (Main.netMode == 2)
16187 {
16189 }
16190 }
16191 ai[1] = 0f;
16192 if (velocity.X != lastVelocity.X)
16193 {
16194 velocity.X = lastVelocity.X * -0.6f;
16195 }
16196 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 2f)
16197 {
16198 velocity.Y = lastVelocity.Y * -0.6f;
16199 }
16200 }
16201 else if (aiStyle == 33)
16202 {
16203 if (localAI[0] == 0f)
16204 {
16205 if (wet)
16206 {
16207 position += lastVelocity / 2f;
16208 }
16209 else
16210 {
16212 }
16213 velocity *= 0f;
16214 localAI[0] = 1f;
16215 }
16216 }
16217 else if (type != 308 && type != 377 && type != 966)
16218 {
16219 if (type == 477)
16220 {
16221 if (velocity.Y != lastVelocity.Y || velocity.X != lastVelocity.X)
16222 {
16223 penetrate--;
16224 if (penetrate <= 0)
16225 {
16226 Kill();
16227 }
16228 if (velocity.X != lastVelocity.X)
16229 {
16230 velocity.X = 0f - lastVelocity.X;
16231 }
16232 if (velocity.Y != lastVelocity.Y)
16233 {
16234 velocity.Y = 0f - lastVelocity.Y;
16235 }
16236 }
16237 if (penetrate > 0 && owner == Main.myPlayer)
16238 {
16239 int[] array = new int[10];
16240 int num30 = 0;
16241 int num31 = 700;
16242 int num32 = 20;
16243 for (int m = 0; m < 200; m++)
16244 {
16245 if (!Main.npc[m].CanBeChasedBy(this))
16246 {
16247 continue;
16248 }
16249 float num33 = (base.Center - Main.npc[m].Center).Length();
16250 if (num33 > (float)num32 && num33 < (float)num31 && Collision.CanHitLine(base.Center, 1, 1, Main.npc[m].Center, 1, 1))
16251 {
16252 array[num30] = m;
16253 num30++;
16254 if (num30 >= 9)
16255 {
16256 break;
16257 }
16258 }
16259 }
16260 if (num30 > 0)
16261 {
16262 num30 = Main.rand.Next(num30);
16263 Vector2 vector22 = Main.npc[array[num30]].Center - base.Center;
16264 float num34 = velocity.Length();
16265 vector22.Normalize();
16267 netUpdate = true;
16268 }
16269 }
16270 }
16271 else if (type == 94)
16272 {
16273 if (velocity.X != lastVelocity.X)
16274 {
16275 velocity.X = 0f - lastVelocity.X;
16276 }
16277 if (velocity.Y != lastVelocity.Y)
16278 {
16279 velocity.Y = 0f - lastVelocity.Y;
16280 }
16281 }
16282 else if (type == 496)
16283 {
16284 if (velocity.X != lastVelocity.X)
16285 {
16286 if (Math.Abs(velocity.X) < 1f)
16287 {
16288 velocity.X = 0f - lastVelocity.X;
16289 }
16290 else
16291 {
16292 Kill();
16293 }
16294 }
16295 if (velocity.Y != lastVelocity.Y)
16296 {
16297 if (Math.Abs(velocity.Y) < 1f)
16298 {
16299 velocity.Y = 0f - lastVelocity.Y;
16300 }
16301 else
16302 {
16303 Kill();
16304 }
16305 }
16306 }
16307 else if (type == 311)
16308 {
16309 if (velocity.X != lastVelocity.X)
16310 {
16311 velocity.X = 0f - lastVelocity.X;
16312 ai[1] += 1f;
16313 }
16314 if (velocity.Y != lastVelocity.Y)
16315 {
16316 velocity.Y = 0f - lastVelocity.Y;
16317 ai[1] += 1f;
16318 }
16319 if (ai[1] > 4f)
16320 {
16321 Kill();
16322 }
16323 }
16324 else if (type == 312)
16325 {
16326 if (velocity.X != lastVelocity.X)
16327 {
16328 velocity.X = 0f - lastVelocity.X;
16329 ai[1] += 1f;
16330 }
16331 if (velocity.Y != lastVelocity.Y)
16332 {
16333 velocity.Y = 0f - lastVelocity.Y;
16334 ai[1] += 1f;
16335 }
16336 }
16337 else if (type == 522 || type == 620)
16338 {
16339 if (velocity.X != lastVelocity.X)
16340 {
16341 velocity.X = 0f - lastVelocity.X;
16342 }
16343 if (velocity.Y != lastVelocity.Y)
16344 {
16345 velocity.Y = 0f - lastVelocity.Y;
16346 }
16347 }
16348 else if (type == 524)
16349 {
16350 ai[0] += 100f;
16351 if (velocity.X != lastVelocity.X)
16352 {
16353 velocity.X = 0f - lastVelocity.X;
16354 }
16355 if (velocity.Y != lastVelocity.Y)
16356 {
16357 velocity.Y = 0f - lastVelocity.Y;
16358 }
16359 }
16360 else if (aiStyle == 93)
16361 {
16362 if (velocity != lastVelocity)
16363 {
16364 ai[1] = 0f;
16365 ai[0] = 1f;
16366 netUpdate = true;
16367 tileCollide = false;
16368 position += velocity;
16371 velocity *= 3f;
16372 }
16373 }
16374 else if (type == 281)
16375 {
16376 bool flag11 = Math.Abs(velocity.X) + Math.Abs(velocity.Y) < 2f || ai[0] == -1f;
16377 if (ai[0] == -2f || ai[0] == -3f)
16378 {
16379 flag11 = false;
16380 }
16381 if (flag11)
16382 {
16383 if (Main.myPlayer == owner)
16384 {
16385 int num35 = ((velocity.X > 0f) ? 1 : 2);
16386 if (damage == 0)
16387 {
16388 num35 += 2;
16389 }
16390 NPC.ReleaseNPC((int)base.Center.X, (int)base.Bottom.Y - 4, 614, num35, owner);
16391 ai[0] = -3f;
16392 netUpdate = true;
16393 }
16394 }
16395 else
16396 {
16397 if (velocity.X != lastVelocity.X)
16398 {
16399 velocity.X = (0f - lastVelocity.X) * 0.5f;
16400 }
16401 if (velocity.Y != lastVelocity.Y)
16402 {
16403 velocity.Y = (0f - lastVelocity.Y) * 0.5f;
16404 }
16405 }
16406 }
16407 else if (type == 290 || type == 294)
16408 {
16409 if (velocity.X != lastVelocity.X)
16410 {
16411 position.X += velocity.X;
16412 velocity.X = 0f - lastVelocity.X;
16413 }
16414 if (velocity.Y != lastVelocity.Y)
16415 {
16416 position.Y += velocity.Y;
16417 velocity.Y = 0f - lastVelocity.Y;
16418 }
16419 }
16420 else if ((type == 181 || type == 189 || type == 357 || type == 566) && penetrate > 0)
16421 {
16422 if (type == 357)
16423 {
16424 damage = (int)((double)damage * 0.9);
16425 }
16426 penetrate--;
16427 if (velocity.X != lastVelocity.X)
16428 {
16429 velocity.X = 0f - lastVelocity.X;
16430 }
16431 if (velocity.Y != lastVelocity.Y)
16432 {
16433 velocity.Y = 0f - lastVelocity.Y;
16434 }
16435 }
16436 else if (type == 307 && ai[1] < 5f)
16437 {
16438 ai[1] += 1f;
16439 if (velocity.X != lastVelocity.X)
16440 {
16441 velocity.X = 0f - lastVelocity.X;
16442 }
16443 if (velocity.Y != lastVelocity.Y)
16444 {
16445 velocity.Y = 0f - lastVelocity.Y;
16446 }
16447 }
16448 else if (type == 99 || type == 1005 || type == 1014)
16449 {
16450 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 5f)
16451 {
16452 Collision.HitTiles(position, velocity, width, height);
16453 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
16454 velocity.Y = (0f - lastVelocity.Y) * 0.2f;
16455 }
16456 if (velocity.X != lastVelocity.X)
16457 {
16458 Kill();
16459 }
16460 }
16461 else if (type == 1021)
16462 {
16463 if (velocity.Y != lastVelocity.Y)
16464 {
16465 if (lastVelocity.Y > 4f)
16466 {
16467 Collision.HitTiles(position, velocity, width, height);
16468 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
16469 velocity.Y = (0f - lastVelocity.Y) * 0.9f;
16470 }
16471 else if (lastVelocity.Y > 0f)
16472 {
16473 localAI[1] = 999f;
16474 }
16475 }
16476 if (velocity.X != lastVelocity.X)
16477 {
16478 if (localAI[1] <= 3f)
16479 {
16480 velocity.X = lastVelocity.X * -0.75f;
16481 localAI[1] += 1f;
16482 }
16483 else
16484 {
16485 Kill();
16486 }
16487 }
16488 }
16489 else if (type == 1013)
16490 {
16491 float num36 = Math.Abs(lastVelocity.X);
16492 float num37 = Math.Abs(lastVelocity.Y);
16493 float num38 = 0.95f;
16494 float num39 = 0.95f;
16495 if (num36 < 0.5f)
16496 {
16497 num38 = 0.1f;
16498 }
16499 else if (num36 < 0.75f)
16500 {
16501 num38 = 0.25f;
16502 }
16503 else if (num36 < 1f)
16504 {
16505 num38 = 0.5f;
16506 }
16507 if (num37 < 0.5f)
16508 {
16509 num39 = 0.1f;
16510 }
16511 else if (num37 < 0.75f)
16512 {
16513 num39 = 0.25f;
16514 }
16515 else if (num37 < 1f)
16516 {
16517 num39 = 0.5f;
16518 }
16519 bool flag12 = false;
16520 if (velocity.Y != lastVelocity.Y)
16521 {
16522 if (Math.Abs(lastVelocity.Y) > 5f)
16523 {
16524 flag12 = true;
16525 }
16526 velocity.Y = (0f - lastVelocity.Y) * num39;
16527 }
16528 if (velocity.X != lastVelocity.X)
16529 {
16530 if (Math.Abs(lastVelocity.X) > 5f)
16531 {
16532 flag12 = true;
16533 }
16534 velocity.X = (0f - lastVelocity.X) * num38;
16535 }
16536 if (flag12)
16537 {
16538 localAI[1] += 1f;
16539 Collision.HitTiles(position, velocity, width, height);
16540 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
16541 }
16542 if (velocity.Length() < 0.1f && localAI[0] > 50f)
16543 {
16544 Kill();
16545 }
16546 if (localAI[1] > 20f)
16547 {
16548 Kill();
16549 }
16550 }
16551 else if (type == 727)
16552 {
16553 int num40 = 30;
16554 float num41 = 2f;
16555 float num42 = 2f;
16556 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 5f)
16557 {
16558 Collision.HitTiles(position, velocity, width, height);
16559 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
16560 velocity.Y = (0f - lastVelocity.Y) * 0.65f;
16561 if (owner == Main.myPlayer)
16562 {
16563 int num43 = Main.rand.Next(3, 6);
16564 float num44 = Main.rand.NextFloat();
16565 for (float num45 = 0f; num45 < 1f; num45 += 1f / (float)num43)
16566 {
16567 Vector2 vector23 = ((num44 + num45) * ((float)Math.PI * 2f)).ToRotationVector2() * num42;
16568 if (vector23.Y > 0f)
16569 {
16570 vector23 *= -0.7f;
16571 }
16572 NewProjectile(GetProjectileSource_FromThis(), base.Center, vector23, 763, num40, num41, Main.myPlayer);
16573 }
16574 }
16575 }
16576 if (velocity.X != lastVelocity.X)
16577 {
16578 Kill();
16579 if (owner == Main.myPlayer)
16580 {
16581 int num46 = Main.rand.Next(3, 6);
16582 float num47 = Main.rand.NextFloat();
16583 for (float num48 = 0f; num48 < 1f; num48 += 1f / (float)num46)
16584 {
16585 Vector2 vector24 = ((num47 + num48) * ((float)Math.PI * 2f)).ToRotationVector2() * num42;
16586 if (vector24.Y > 0f)
16587 {
16588 vector24 *= -0.7f;
16589 }
16590 NewProjectile(GetProjectileSource_FromThis(), base.Center, vector24, 763, num40, num41, Main.myPlayer);
16591 }
16592 }
16593 }
16594 }
16595 else if (type == 655)
16596 {
16597 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 5f)
16598 {
16599 Collision.HitTiles(position, velocity, width, height);
16600 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
16601 velocity.Y = (0f - lastVelocity.Y) * 0.2f;
16602 }
16603 if (velocity.X != lastVelocity.X)
16604 {
16605 Kill();
16606 }
16607 }
16608 else if (type == 36)
16609 {
16610 if (penetrate > 1)
16611 {
16612 Collision.HitTiles(position, velocity, width, height);
16614 penetrate--;
16615 if (velocity.X != lastVelocity.X)
16616 {
16617 velocity.X = 0f - lastVelocity.X;
16618 }
16619 if (velocity.Y != lastVelocity.Y)
16620 {
16621 velocity.Y = 0f - lastVelocity.Y;
16622 }
16623 }
16624 else
16625 {
16626 Kill();
16627 }
16628 }
16629 else if (aiStyle == 21)
16630 {
16631 if (velocity.X != lastVelocity.X)
16632 {
16633 velocity.X = 0f - lastVelocity.X;
16634 }
16635 if (velocity.Y != lastVelocity.Y)
16636 {
16637 velocity.Y = 0f - lastVelocity.Y;
16638 }
16639 }
16640 else if (aiStyle == 17)
16641 {
16642 if (velocity.X != lastVelocity.X)
16643 {
16644 velocity.X = lastVelocity.X * -0.75f;
16645 }
16646 if (velocity.Y != lastVelocity.Y && (double)lastVelocity.Y > 1.5)
16647 {
16648 velocity.Y = lastVelocity.Y * -0.7f;
16649 }
16650 }
16651 else if (aiStyle == 15)
16652 {
16654 }
16655 else if (aiStyle == 9)
16656 {
16657 bool flag13 = owner == Main.myPlayer;
16658 if (type == 79)
16659 {
16660 bool flag14 = ai[0] >= 0f;
16661 flag13 = flag13 && !flag14;
16662 if (flag14)
16663 {
16664 if (velocity.X != lastVelocity.X)
16665 {
16666 velocity.X *= 0.1f;
16667 }
16668 if (velocity.Y != lastVelocity.Y)
16669 {
16670 velocity.Y *= 0.1f;
16671 }
16672 }
16673 }
16674 if (flag13)
16675 {
16676 Kill();
16677 }
16678 }
16679 else if (aiStyle == 39)
16680 {
16681 Collision.HitTiles(position, velocity, width, height);
16682 if (type == 33 || type == 106)
16683 {
16684 if (velocity.X != lastVelocity.X)
16685 {
16686 velocity.X = 0f - lastVelocity.X;
16687 }
16688 if (velocity.Y != lastVelocity.Y)
16689 {
16690 velocity.Y = 0f - lastVelocity.Y;
16691 }
16692 }
16693 else
16694 {
16695 ai[0] = 1f;
16696 if (aiStyle == 3)
16697 {
16698 velocity.X = 0f - lastVelocity.X;
16699 velocity.Y = 0f - lastVelocity.Y;
16700 }
16701 }
16702 netUpdate = true;
16703 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
16704 }
16705 else if (aiStyle == 3 || aiStyle == 13 || aiStyle == 69 || aiStyle == 109)
16706 {
16707 if (type == 106)
16708 {
16709 Vector2 hitPoint = base.Center + velocity.SafeNormalize(Vector2.UnitX) * 8f * scale;
16712 }
16713 Collision.HitTiles(position, velocity, width, height);
16714 if (type == 33 || type == 106 || type == 866)
16715 {
16716 if (velocity.X != lastVelocity.X)
16717 {
16718 velocity.X = 0f - lastVelocity.X;
16719 }
16720 if (velocity.Y != lastVelocity.Y)
16721 {
16722 velocity.Y = 0f - lastVelocity.Y;
16723 }
16724 }
16725 else
16726 {
16727 ai[0] = 1f;
16728 if ((aiStyle == 3 || aiStyle == 109) && type != 383)
16729 {
16730 velocity.X = 0f - lastVelocity.X;
16731 velocity.Y = 0f - lastVelocity.Y;
16732 }
16733 }
16734 netUpdate = true;
16735 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
16736 }
16737 else if (aiStyle == 8 && type != 96)
16738 {
16740 ai[0] += 1f;
16741 int num49 = 5;
16742 switch (type)
16743 {
16744 case 15:
16745 num49 = 6;
16746 break;
16747 case 253:
16748 num49 = 8;
16749 break;
16750 }
16751 if (ai[0] >= (float)num49)
16752 {
16753 position += velocity;
16754 Kill();
16755 }
16756 else
16757 {
16758 if (type == 15 && velocity.Y > 4f)
16759 {
16760 if (velocity.Y != lastVelocity.Y)
16761 {
16762 velocity.Y = (0f - lastVelocity.Y) * 0.8f;
16763 }
16764 }
16765 else if (velocity.Y != lastVelocity.Y)
16766 {
16767 velocity.Y = 0f - lastVelocity.Y;
16768 }
16769 if (velocity.X != lastVelocity.X)
16770 {
16771 velocity.X = 0f - lastVelocity.X;
16772 }
16773 }
16774 }
16775 else if (aiStyle == 61)
16776 {
16777 if (velocity.X != lastVelocity.X)
16778 {
16779 velocity.X = lastVelocity.X * -0.3f;
16780 }
16781 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 1f)
16782 {
16783 velocity.Y = lastVelocity.Y * -0.3f;
16784 }
16785 }
16786 else if (aiStyle == 14)
16787 {
16788 if (type == 928)
16789 {
16790 int num50 = 0;
16791 for (int num51 = 1000; num51 >= 0; num51--)
16792 {
16793 if (num51 != whoAmI && Main.projectile[num51].active && Main.projectile[num51].owner == owner && Main.projectile[num51].type == type)
16794 {
16795 num50++;
16796 if (num50 >= 2 && timeLeft > Main.projectile[num51].timeLeft && Main.projectile[num51].timeLeft > 30)
16797 {
16798 Main.projectile[num51].timeLeft = 2;
16799 }
16800 }
16801 }
16802 }
16803 if (type == 261 && ((velocity.X != lastVelocity.X && (lastVelocity.X < -3f || lastVelocity.X > 3f)) || (velocity.Y != lastVelocity.Y && (lastVelocity.Y < -3f || lastVelocity.Y > 3f))))
16804 {
16805 for (int n = 0; n < 10; n++)
16806 {
16807 Collision.HitTiles(position, velocity, width, height);
16808 }
16809 SoundEngine.PlaySound(0, (int)base.Center.X, (int)base.Center.Y);
16811 }
16812 if (type >= 326 && type <= 328 && velocity.X != lastVelocity.X)
16813 {
16814 velocity.X = lastVelocity.X * -0.1f;
16815 }
16816 if (type >= 400 && type <= 402)
16817 {
16818 if (velocity.X != lastVelocity.X)
16819 {
16820 velocity.X = lastVelocity.X * -0.1f;
16821 }
16822 }
16823 else if (type == 870 && ai[1] == 0f)
16824 {
16825 if (velocity.X != lastVelocity.X || velocity.Y != lastVelocity.Y)
16826 {
16828 ai[1] = 1f;
16829 }
16830 }
16831 else if (type == 50)
16832 {
16833 if (velocity.X != lastVelocity.X)
16834 {
16835 velocity.X = lastVelocity.X * -0.2f;
16836 }
16837 if (velocity.Y != lastVelocity.Y && (double)lastVelocity.Y > 1.5)
16838 {
16839 velocity.Y = lastVelocity.Y * -0.2f;
16840 }
16841 }
16842 else if (type == 185)
16843 {
16844 if (velocity.X != lastVelocity.X)
16845 {
16846 velocity.X = lastVelocity.X * -0.9f;
16847 }
16848 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 1f)
16849 {
16850 velocity.Y = lastVelocity.Y * -0.9f;
16851 }
16852 }
16853 else if (type == 277)
16854 {
16855 if (velocity.X != lastVelocity.X)
16856 {
16857 velocity.X = lastVelocity.X * -0.9f;
16858 }
16859 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 3f)
16860 {
16861 velocity.Y = lastVelocity.Y * -0.9f;
16862 }
16863 }
16864 else if (type != 480)
16865 {
16866 if (type == 450)
16867 {
16868 if (velocity.X != lastVelocity.X)
16869 {
16870 velocity.X = lastVelocity.X * -0.1f;
16871 }
16872 }
16873 else
16874 {
16875 if (velocity.X != lastVelocity.X)
16876 {
16877 velocity.X = lastVelocity.X * -0.5f;
16878 }
16879 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 1f)
16880 {
16881 velocity.Y = lastVelocity.Y * -0.5f;
16882 }
16883 }
16884 }
16885 }
16886 else if (aiStyle == 16)
16887 {
16888 if (velocity.X != lastVelocity.X)
16889 {
16890 velocity.X = lastVelocity.X * -0.4f;
16891 if (type == 29)
16892 {
16893 velocity.X *= 0.8f;
16894 }
16895 }
16896 if (velocity.Y != lastVelocity.Y && (double)lastVelocity.Y > 0.7 && type != 102)
16897 {
16898 velocity.Y = lastVelocity.Y * -0.4f;
16899 if (type == 29)
16900 {
16901 velocity.Y *= 0.8f;
16902 }
16903 }
16904 if (type == 134 || type == 137 || type == 140 || type == 143 || type == 303 || (type >= 338 && type <= 341) || type == 776 || type == 780 || type == 793 || type == 796 || type == 799 || type == 784 || type == 787 || type == 790 || type == 803 || type == 804 || type == 808 || type == 809 || type == 810 || type == 805 || type == 806 || type == 807 || type == 930)
16905 {
16906 velocity *= 0f;
16907 alpha = 255;
16908 timeLeft = 3;
16909 }
16910 }
16911 else if (aiStyle == 68)
16912 {
16913 velocity *= 0f;
16914 alpha = 255;
16915 timeLeft = 3;
16916 netUpdate = true;
16917 }
16918 else if (type == 870)
16919 {
16920 if (velocity.X != lastVelocity.X)
16921 {
16922 velocity.X = lastVelocity.X * -0.2f;
16923 }
16924 if (velocity.Y != lastVelocity.Y && lastVelocity.Y > 0f)
16925 {
16926 velocity.Y = lastVelocity.Y * -0.2f;
16927 }
16928 }
16929 else
16930 {
16931 position += velocity;
16932 Kill();
16933 }
16934 }
16935 }
16936 }
16937 }
16939 if (!flag2 && !flag4 && owner == Main.myPlayer && (tileCollide || flag5) && position != oldPosition)
16940 {
16943 int num52 = ((overrideWidth != -1) ? overrideWidth : width);
16944 int num53 = ((overrideHeight != -1) ? overrideHeight : height);
16945 if (overrideHeight != -1 || overrideWidth != -1)
16946 {
16947 vector25 = new Vector2(position.X + (float)(width / 2) - (float)(num52 / 2), position.Y + (float)(height / 2) - (float)(num53 / 2));
16948 vector26 = new Vector2(oldPosition.X + (float)(width / 2) - (float)(num52 / 2), oldPosition.Y + (float)(height / 2) - (float)(num53 / 2));
16949 }
16950 Collision.SwitchTiles(vector25, num52, num53, vector26, 4);
16951 }
16952 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static float WrapAngle(float angle)
Definition MathHelper.cs:87
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Abs(double value)
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static void PlaySound(int type, Vector2 position, int style=1)
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:46
Vector2 oldPosition
Definition Entity.cs:18
bool honeyWet
Definition Entity.cs:34
bool shimmerWet
Definition Entity.cs:32
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
static int TryPlacingPortal(Projectile theBolt, Vector2 velocity, Vector2 theCrashVelocity)
static ? bool[] ForcePlateDetection
static bool[] FallingBlockDoesNotFallThroughPlatforms
static readonly LegacySoundStyle Item10
Definition SoundID.cs:434
static readonly LegacySoundStyle Item115
Definition SoundID.cs:644
static readonly LegacySoundStyle Item114
Definition SoundID.cs:642
static bool[] CrackedBricks
Definition TileID.cs:113
static bool[] Falling
Definition TileID.cs:289
static NetworkText FromKey(string key, params object[] substitutions)
void UpdatePosition(Vector2 wetVelocity)
IEntitySource GetProjectileSource_FromThis()
int FindTargetWithLineOfSight(float maxRange=800f)
void MakeBoulderOfEarthExplosion()
void LightDisc_Bounce(Vector2 hitPoint, Vector2 normal)
void AI_015_HandleMovementCollision(ref Vector2 wetVelocity, ref Vector2 lastVelocity)
static int NewProjectile(IEntitySource spawnSource, Vector2 position, Vector2 velocity, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)
static Color Transparent
Definition Color.cs:76

References System.Math.Abs(), Terraria.Projectile.ai, Terraria.Projectile.AI_015_HandleMovementCollision(), Terraria.Projectile.aiStyle, Terraria.Projectile.alpha, Terraria.Collision.AnyCollisionWithSpecificTiles(), System.array, Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.WorldGen.CanCutTile(), Terraria.Projectile.CanCutTiles(), Terraria.Collision.CanHitLine(), Terraria.ID.TileID.Sets.CrackedBricks, Terraria.Projectile.damage, Terraria.Projectile.Damage(), Terraria.Projectile.decidesManualFallThrough, Terraria.Entity.DirectionTo(), Terraria.Entity.Distance(), Terraria.Main.dust, Terraria.ID.TileID.Sets.Falling, Terraria.ID.ProjectileID.Sets.FallingBlockDoesNotFallThroughPlatforms, Terraria.Projectile.FindTargetWithLineOfSight(), Terraria.ID.ProjectileID.Sets.ForcePlateDetection, Terraria.Projectile.friendly, Terraria.Localization.NetworkText.FromKey(), Terraria.Utils.GetLerpValue(), Terraria.Lang.GetProjectileName(), Terraria.Projectile.GetProjectileSource_FromThis(), Terraria.Entity.height, Terraria.Collision.HitTiles(), Terraria.Entity.honeyWet, Terraria.Projectile.hostile, Terraria.Main.hslToRgb(), Terraria.ID.SoundID.Item10, Terraria.ID.SoundID.Item114, Terraria.ID.SoundID.Item115, Terraria.Projectile.Kill(), Terraria.WorldGen.KillTile(), Microsoft.Xna.Framework.Vector2.Length(), Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Projectile.LightDisc_Bounce(), Terraria.Projectile.localAI, Terraria.Projectile.MakeBoulderOfEarthExplosion(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, System.Math.Min(), Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Projectile.netUpdate, Terraria.Dust.NewDust(), Terraria.Projectile.NewProjectile(), Terraria.Main.NewText(), Microsoft.Xna.Framework.Vector2.Normalize(), Terraria.Main.npc, Terraria.Projectile.numUpdates, Terraria.Entity.oldPosition, Terraria.Projectile.owner, Terraria.Projectile.penetrate, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.projectile, Terraria.Main.projPet, Terraria.Main.rand, Terraria.NPC.ReleaseNPC(), Terraria.Projectile.rotation, Terraria.Projectile.scale, Terraria.NetMessage.SendData(), Terraria.Entity.shimmerWet, Terraria.Projectile.shouldFallThrough, System.Math.Sign(), Terraria.Collision.SlopeCollision(), Terraria.Collision.SwitchTiles(), Terraria.Main.tile, Terraria.Projectile.tileCollide, Terraria.Collision.TileCollision(), Terraria.Projectile.timeLeft, Microsoft.Xna.Framework.Color.Transparent, Terraria.Projectile.trap, Terraria.GameContent.PortalHelper.TryPlacingPortal(), Terraria.Projectile.type, Microsoft.Xna.Framework.Vector2.UnitX, Microsoft.Xna.Framework.Vector2.UnitY, Terraria.Projectile.UpdatePosition(), Terraria.Entity.velocity, Terraria.Entity.wet, Terraria.Entity.whoAmI, Terraria.Entity.width, Microsoft.Xna.Framework.MathHelper.WrapAngle(), Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.Projectile.Update().