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

◆ Damage()

void Terraria.Projectile.Damage ( )
inline

Definition at line 11037 of file Projectile.cs.

11038 {
11039 if (type == 18 || type == 72 || type == 86 || type == 87 || aiStyle == 31 || aiStyle == 32 || type == 226 || type == 378 || type == 613 || type == 650 || type == 882 || type == 888 || type == 895 || type == 896 || (type == 434 && localAI[0] != 0f) || type == 439 || type == 444 || (type == 451 && ((int)(ai[0] - 1f) / penetrate == 0 || ai[1] < 5f) && ai[0] != 0f) || type == 500 || type == 653 || type == 1018 || type == 460 || type == 633 || type == 600 || type == 601 || type == 602 || type == 535 || (type == 631 && localAI[1] == 0f) || (type == 537 && localAI[0] <= 30f) || type == 651 || (type == 188 && localAI[0] < 5f) || (aiStyle == 137 && ai[0] != 0f) || aiStyle == 138 || (type == 261 && velocity.Length() < 1.5f) || (type == 818 && ai[0] < 1f) || type == 831 || type == 970 || (type == 833 && ai[0] == 4f) || (type == 834 && ai[0] == 4f) || (type == 835 && ai[0] == 4f) || (type == 281 && ai[0] == -3f) || ((type == 598 || type == 636 || type == 614 || type == 971 || type == 975) && ai[0] == 1f) || (type == 923 && localAI[0] <= 60f) || (type == 919 && localAI[0] <= 60f) || (aiStyle == 15 && ai[0] == 0f && localAI[1] <= 12f) || type == 861 || (type >= 511 && type <= 513 && ai[1] >= 1f) || type == 1007 || (aiStyle == 93 && ai[0] != 0f && ai[0] != 2f) || (aiStyle == 10 && localAI[1] == -1f) || (type == 85 && localAI[0] >= 54f) || (Main.projPet[type] && type != 266 && type != 407 && type != 317 && (type != 388 || ai[0] != 2f) && (type < 390 || type > 392) && (type < 393 || type > 395) && (type != 533 || !(ai[0] >= 6f) || !(ai[0] <= 8f)) && (type < 625 || type > 628) && (type != 755 || ai[0] == 0f) && (type != 946 || ai[0] == 0f) && type != 758 && type != 951 && type != 963 && (type != 759 || frame == Main.projFrames[type] - 1) && type != 833 && type != 834 && type != 835 && type != 864 && (type != 623 || ai[0] != 2f)))
11040 {
11041 return;
11042 }
11044 if (friendly && Main.getGoodWorld && aiStyle == 16 && Main.netMode == 1 && owner != Main.myPlayer && !npcProj)
11045 {
11046 BombsHurtPlayers(rectangle, Main.myPlayer);
11047 return;
11048 }
11049 if (friendly && owner == Main.myPlayer && !npcProj)
11050 {
11052 if (!minion)
11053 {
11054 CutTiles();
11055 }
11056 }
11057 if (owner == Main.myPlayer)
11058 {
11059 float num = 1f;
11061 {
11062 num *= 2f;
11063 }
11065 {
11066 num *= 3f;
11067 }
11068 if (type == 34 && penetrate == 1)
11069 {
11070 num *= 1f;
11071 }
11072 if (aiStyle == 15 && ai[0] == 0f)
11073 {
11074 num *= 1.2f;
11075 }
11076 if (aiStyle == 15 && (ai[0] == 1f || ai[0] == 2f))
11077 {
11078 num *= 2f;
11079 }
11080 if (type == 877 || type == 879 || type == 878)
11081 {
11082 num = 0.1f + Main.player[owner].velocity.Length() / 7f * 0.9f;
11083 }
11084 if (type == 968)
11085 {
11086 num = 1f;
11087 switch ((int)ai[1])
11088 {
11089 case 0:
11090 num = 1.5f;
11091 break;
11092 case 1:
11093 num = 1f;
11094 break;
11095 case 2:
11096 num = 1.5f;
11097 break;
11098 case 3:
11099 num = 0.1f;
11100 break;
11101 case 4:
11102 num = 1f;
11103 break;
11104 case 5:
11105 num = 1f;
11106 break;
11107 case 6:
11108 num = 1f;
11109 break;
11110 case 7:
11111 num = 0.25f;
11112 break;
11113 case 8:
11114 num = 1f;
11115 break;
11116 case 9:
11117 num = 0.75f;
11118 break;
11119 case 10:
11120 num = 0.5f;
11121 break;
11122 case 11:
11123 num = 0.5f;
11124 break;
11125 case 12:
11126 num = 0.5f;
11127 break;
11128 case 13:
11129 num = 0.5f;
11130 break;
11131 case 14:
11132 num = 0.5f;
11133 break;
11134 case 15:
11135 num = 0.5f;
11136 break;
11137 case 16:
11138 num = 0.5f;
11139 break;
11140 case 17:
11141 num = 1.5f;
11142 break;
11143 case 18:
11144 num = 1.6f;
11145 break;
11146 case 19:
11147 num = 1.8f;
11148 break;
11149 case 20:
11150 num = 1.9f;
11151 break;
11152 case 21:
11153 num = 1.7f;
11154 break;
11155 case 22:
11156 num = 2f;
11157 break;
11158 case 23:
11159 num = 1.9f;
11160 break;
11161 }
11162 }
11163 if (type == 533 && localAI[2] >= 40f)
11164 {
11165 num *= 0.5f;
11166 }
11167 bool flag = !npcProj && !trap;
11168 bool flag2 = usesOwnerMeleeHitCD && flag && owner < 255;
11169 bool flag3 = damage > 0;
11170 if (flag3)
11171 {
11172 int[] array = localNPCImmunity;
11173 if (type == 626 || type == 627 || type == 628)
11174 {
11175 Projectile projectile = FindStardustDragonHeadOfOwner();
11176 if (projectile != null)
11177 {
11178 array = projectile.localNPCImmunity;
11179 }
11180 }
11181 bool flag4 = true;
11182 for (int i = 0; i < 200 && flag4; i++)
11183 {
11184 if (!Main.npc[i].active)
11185 {
11186 continue;
11187 }
11189 if (flag2 && !Main.player[owner].CanHitNPCWithMeleeHit(i))
11190 {
11191 flag5 = false;
11192 }
11193 if (!((!Main.npc[i].dontTakeDamage || NPCID.Sets.ZappingJellyfish[Main.npc[i].type]) && flag5) || (Main.npc[i].aiStyle == 112 && Main.npc[i].ai[2] > 1f))
11194 {
11195 continue;
11196 }
11197 Main.npc[i].position += Main.npc[i].netOffset;
11198 bool flag6 = !Main.npc[i].friendly;
11199 flag6 |= type == 318;
11200 flag6 |= Main.npc[i].type == 22 && owner < 255 && Main.player[owner].killGuide;
11201 flag6 |= Main.npc[i].type == 54 && owner < 255 && Main.player[owner].killClothier;
11202 if (owner < 255 && !Main.player[owner].CanNPCBeHitByPlayerOrPlayerProjectile(Main.npc[i], this))
11203 {
11204 flag6 = false;
11205 }
11206 bool flag7 = Main.npc[i].friendly && !Main.npc[i].dontTakeDamageFromHostiles;
11207 if ((friendly && (flag6 || NPCID.Sets.ZappingJellyfish[Main.npc[i].type])) || (hostile && flag7))
11208 {
11210 if (owner < 0 || Main.npc[i].immune[owner] == 0 || flag8)
11211 {
11212 bool flag9 = false;
11213 if (type == 11 && (Main.npc[i].type == 47 || Main.npc[i].type == 57))
11214 {
11215 flag9 = true;
11216 }
11217 else if (type == 31 && Main.npc[i].type == 69)
11218 {
11219 flag9 = true;
11220 }
11221 else if (Main.npc[i].trapImmune && trap)
11222 {
11223 flag9 = true;
11224 }
11225 else if (Main.npc[i].immortal && npcProj)
11226 {
11227 flag9 = true;
11228 }
11229 if (!flag9 && (Main.npc[i].noTileCollide || !ownerHitCheck || CanHitWithMeleeWeapon(Main.npc[i])))
11230 {
11231 bool flag10 = false;
11232 if (Main.npc[i].type == 414)
11233 {
11234 Rectangle rect = Main.npc[i].getRect();
11235 int num2 = 8;
11236 rect.X -= num2;
11237 rect.Y -= num2;
11238 rect.Width += num2 * 2;
11239 rect.Height += num2 * 2;
11241 }
11242 else
11243 {
11244 flag10 = Colliding(rectangle, Main.npc[i].getRect());
11245 }
11246 if (flag10)
11247 {
11248 NPC nPC = Main.npc[i];
11249 if (NPCID.Sets.ZappingJellyfish[nPC.type])
11250 {
11251 if ((nPC.dontTakeDamage || !Main.player[owner].CanNPCBeHitByPlayerOrPlayerProjectile(nPC, this)) && (aiStyle == 19 || aiStyle == 161 || aiStyle == 75 || aiStyle == 140 || ProjectileID.Sets.IsAWhip[type] || ProjectileID.Sets.AllowsContactDamageFromJellyfish[type]))
11252 {
11253 Main.player[owner].TakeDamageFromJellyfish(i);
11254 }
11255 if (nPC.dontTakeDamage || !flag6)
11256 {
11257 continue;
11258 }
11259 }
11260 if (type == 876)
11261 {
11263 if (Main.rand.Next(20) == 0)
11264 {
11265 tileCollide = false;
11266 position.X += Main.rand.Next(-256, 257);
11267 }
11268 if (Main.rand.Next(20) == 0)
11269 {
11270 tileCollide = false;
11271 position.Y += Main.rand.Next(-256, 257);
11272 }
11273 if (Main.rand.Next(2) == 0)
11274 {
11275 tileCollide = false;
11276 }
11277 if (Main.rand.Next(3) != 0)
11278 {
11279 vector = position;
11280 position -= velocity * Main.rand.Next(0, 40);
11281 if (tileCollide && Collision.SolidTiles(position, width, height))
11282 {
11283 position = vector;
11284 position -= velocity * Main.rand.Next(0, 40);
11285 if (tileCollide && Collision.SolidTiles(position, width, height))
11286 {
11287 position = vector;
11288 }
11289 }
11290 }
11291 velocity *= 0.6f;
11292 if (Main.rand.Next(7) == 0)
11293 {
11294 velocity.X += (float)Main.rand.Next(30, 31) * 0.01f;
11295 }
11296 if (Main.rand.Next(7) == 0)
11297 {
11298 velocity.Y += (float)Main.rand.Next(30, 31) * 0.01f;
11299 }
11300 damage = (int)((double)damage * 0.9);
11301 knockBack *= 0.9f;
11302 if (Main.rand.Next(20) == 0)
11303 {
11304 knockBack *= 10f;
11305 }
11306 if (Main.rand.Next(50) == 0)
11307 {
11308 damage *= 10;
11309 }
11310 if (Main.rand.Next(7) == 0)
11311 {
11312 vector = position;
11313 position.X += Main.rand.Next(-64, 65);
11314 if (tileCollide && Collision.SolidTiles(position, width, height))
11315 {
11316 position = vector;
11317 }
11318 }
11319 if (Main.rand.Next(7) == 0)
11320 {
11321 vector = position;
11322 position.Y += Main.rand.Next(-64, 65);
11323 if (tileCollide && Collision.SolidTiles(position, width, height))
11324 {
11325 position = vector;
11326 }
11327 }
11328 if (Main.rand.Next(14) == 0)
11329 {
11330 velocity.X *= -1f;
11331 }
11332 if (Main.rand.Next(14) == 0)
11333 {
11334 velocity.Y *= -1f;
11335 }
11336 if (Main.rand.Next(10) == 0)
11337 {
11338 velocity *= (float)Main.rand.Next(1, 201) * 0.0005f;
11339 }
11340 if (tileCollide)
11341 {
11342 ai[1] = 0f;
11343 }
11344 else
11345 {
11346 ai[1] = 1f;
11347 }
11348 netUpdate = true;
11349 }
11350 bool flag11 = nPC.reflectsProjectiles;
11351 if (Main.getGoodWorld && NPCID.Sets.ReflectStarShotsInForTheWorthy[Main.npc[i].type] && (type == 955 || type == 728))
11352 {
11353 flag11 = true;
11354 }
11355 if (flag11 && CanBeReflected() && nPC.CanReflectProjectile(this))
11356 {
11357 nPC.ReflectProjectile(this);
11358 Main.npc[i].position -= Main.npc[i].netOffset;
11359 return;
11360 }
11361 if (type == 604)
11362 {
11363 Main.player[owner].Counterweight(nPC.Center, damage, knockBack);
11364 }
11365 float num3 = knockBack;
11366 bool flag12 = false;
11367 int num4 = Main.player[owner].armorPenetration;
11368 float armorPenetrationPercent = 0f;
11369 bool flag13 = false;
11370 switch (type)
11371 {
11372 case 442:
11373 flag13 = true;
11374 break;
11375 case 410:
11376 if (Main.remixWorld)
11377 {
11378 num4 += 20;
11379 }
11380 break;
11381 case 864:
11382 num4 += 25;
11383 break;
11384 case 916:
11385 num4 += 50;
11386 break;
11387 case 917:
11388 num4 += 30;
11389 break;
11390 case 595:
11391 num4 += 20;
11392 break;
11393 case 493:
11394 case 494:
11395 num4 += 10;
11396 break;
11397 case 150:
11398 case 151:
11399 case 152:
11400 num4 += 10;
11401 break;
11402 case 189:
11403 num4 += 10;
11404 if (flag && Main.player[owner].strongBees)
11405 {
11406 num4 += 5;
11407 }
11408 break;
11409 case 723:
11410 case 724:
11411 case 725:
11412 case 726:
11413 num4 += 25;
11414 break;
11415 case 532:
11416 num4 += 25;
11417 break;
11418 case 964:
11419 num4 += 20;
11420 break;
11421 case 969:
11422 num4 += 10;
11423 break;
11424 case 85:
11425 num4 += 15;
11426 break;
11427 case 877:
11428 case 878:
11429 case 879:
11430 num3 *= Main.player[owner].velocity.Length() / 7f;
11431 break;
11432 case 963:
11433 num3 *= 0.25f;
11434 break;
11435 case 976:
11436 num4 += 20;
11437 break;
11438 case 974:
11439 num4 += 5;
11440 break;
11441 case 977:
11442 num4 += 5;
11443 break;
11444 }
11445 if (flag13)
11446 {
11447 Kill();
11448 return;
11449 }
11450 int num5 = (int)((float)damage * num);
11451 int num6 = 0;
11453 {
11454 float value = (scale - 1f) * 100f;
11455 value = Utils.Clamp(value, 0f, 50f);
11456 num5 = (int)((float)num5 * (1f + value * 0.23f));
11457 }
11459 {
11460 int num7 = Math.Max(0, Main.player[owner].ownedProjectileCounts[831] - 1);
11461 num5 = (int)((float)num5 * (1f + (float)num7 * 0.4f));
11462 }
11463 if (type == 818)
11464 {
11465 int num8 = Math.Max(0, Main.player[owner].ownedProjectileCounts[831] - 1);
11466 num5 = (int)((float)num5 * (1.5f + (float)num8 * 0.4f));
11467 }
11468 if (type == 963)
11469 {
11470 int num9 = Math.Max(0, Main.player[owner].ownedProjectileCounts[970] - 1);
11471 int num10 = 3 + num9 / 2;
11473 {
11474 return;
11475 }
11476 float num11 = 0.55f;
11477 if (Main.hardMode)
11478 {
11479 num11 = 1.3f;
11480 }
11481 num5 = (int)((float)num5 * (1f + (float)num9 * num11));
11482 }
11483 if (flag && type == 189 && Main.player[owner].strongBees)
11484 {
11485 num5 += 5;
11486 }
11487 if (flag)
11488 {
11489 if (melee && Main.rand.Next(1, 101) <= Main.player[owner].meleeCrit)
11490 {
11491 flag12 = true;
11492 }
11493 if (ranged && Main.rand.Next(1, 101) <= Main.player[owner].rangedCrit)
11494 {
11495 flag12 = true;
11496 }
11497 if (magic && Main.rand.Next(1, 101) <= Main.player[owner].magicCrit)
11498 {
11499 flag12 = true;
11500 }
11501 int num12 = type;
11502 if ((uint)(num12 - 688) <= 2u)
11503 {
11504 if (Main.player[owner].setMonkT3)
11505 {
11506 if (Main.rand.Next(4) == 0)
11507 {
11508 flag12 = true;
11509 }
11510 }
11511 else if (Main.player[owner].setMonkT2 && Main.rand.Next(6) == 0)
11512 {
11513 flag12 = true;
11514 }
11515 }
11516 }
11517 float num13 = 1f;
11518 if (type == 864)
11519 {
11520 num13 = 0.75f;
11521 }
11522 if (type == 688 || type == 689 || type == 690)
11523 {
11524 num13 /= 2f;
11525 }
11527 {
11528 bool flag14 = false;
11529 bool flag15 = false;
11530 bool flag16 = false;
11531 bool flag17 = false;
11532 bool flag18 = false;
11533 bool flag19 = false;
11534 bool flag20 = false;
11535 bool flag21 = false;
11536 bool flag22 = false;
11537 for (int j = 0; j < NPC.maxBuffs; j++)
11538 {
11539 if (nPC.buffTime[j] >= 1)
11540 {
11541 switch (nPC.buffType[j])
11542 {
11543 case 307:
11544 flag14 = true;
11545 break;
11546 case 309:
11547 flag15 = true;
11548 break;
11549 case 313:
11550 flag16 = true;
11551 break;
11552 case 310:
11553 flag17 = true;
11554 break;
11555 case 315:
11556 flag18 = true;
11557 break;
11558 case 326:
11559 flag19 = true;
11560 break;
11561 case 319:
11562 flag21 = true;
11563 break;
11564 case 316:
11565 flag22 = true;
11566 break;
11567 case 340:
11568 flag20 = true;
11569 break;
11570 }
11571 }
11572 }
11573 if (flag14)
11574 {
11575 num6 += 4;
11576 }
11577 if (flag18)
11578 {
11579 num6 += 6;
11580 }
11581 if (flag19)
11582 {
11583 num6 += 7;
11584 }
11585 if (flag20)
11586 {
11587 num6 += 6;
11588 }
11589 if (flag15)
11590 {
11591 num6 += 9;
11592 }
11593 if (flag21)
11594 {
11595 num6 += 8;
11596 if (Main.rand.Next(100) < 12)
11597 {
11598 flag12 = true;
11599 }
11600 }
11601 if (flag17)
11602 {
11603 int num14 = 10;
11604 num6 += num14;
11605 int num15 = NewProjectile(GetProjectileSource_FromThis(), nPC.Center, Vector2.Zero, 916, (int)((float)num14 * num13), 0f, owner);
11606 Main.projectile[num15].localNPCImmunity[i] = -1;
11608 }
11609 if (flag22)
11610 {
11611 int num16 = 20;
11612 num6 += num16;
11613 if (Main.rand.Next(10) == 0)
11614 {
11615 flag12 = true;
11616 }
11618 {
11619 PositionInWorld = base.Center
11620 });
11621 }
11622 if (flag16)
11623 {
11624 nPC.RequestBuffRemoval(313);
11625 int num17 = (int)((float)num5 * 1.75f);
11627 Main.projectile[num18].localNPCImmunity[i] = -1;
11628 num6 += num17;
11629 }
11630 }
11631 num6 = (int)((float)num6 * num13);
11632 num5 += num6;
11633 int num19 = ((!flag) ? Main.DamageVar(num5) : Main.DamageVar(num5, Main.player[owner].luck));
11634 if (type == 1002)
11635 {
11636 num19 /= 2;
11637 }
11639 {
11640 num19 /= 2;
11641 }
11642 if (type == 482 && (nPC.aiStyle == 6 || nPC.aiStyle == 37))
11643 {
11644 num19 /= 2;
11645 }
11646 if (flag)
11647 {
11648 Vector2 positionInWorld = Main.rand.NextVector2FromRectangle(nPC.Hitbox);
11650 particleOrchestraSettings.PositionInWorld = positionInWorld;
11652 switch (type)
11653 {
11654 case 972:
11656 break;
11657 case 973:
11659 break;
11660 case 984:
11661 case 985:
11662 settings.MovementVector = velocity;
11664 break;
11665 case 982:
11667 break;
11668 case 983:
11670 break;
11671 }
11672 }
11673 if (type == 604)
11674 {
11675 friendly = false;
11676 ai[1] = 1000f;
11677 }
11678 if ((type == 400 || type == 401 || type == 402) && nPC.type >= 13 && nPC.type <= 15)
11679 {
11680 num19 = (int)((double)num19 * 0.65);
11681 if (penetrate > 1)
11682 {
11683 penetrate--;
11684 }
11685 }
11686 if (type == 710 && !WorldUtils.Find(base.Center.ToTileCoordinates(), Searches.Chain(new Searches.Down(12), _cachedConditions_notNull, _cachedConditions_solid), out var _))
11687 {
11688 num19 = (int)((float)num19 * 1.5f);
11689 }
11690 if (type == 504 || type == 954 || type == 979)
11691 {
11692 float num20 = (60f - ai[0]) / 2f;
11693 ai[0] += num20;
11694 }
11695 if (aiStyle == 3 && type != 301 && type != 866 && type != 902)
11696 {
11697 if (ai[0] == 0f)
11698 {
11699 if (type == 106)
11700 {
11701 LightDisc_Bounce(base.Center + velocity.SafeNormalize(Vector2.UnitX) * 8f, (-velocity).SafeNormalize(Vector2.UnitX));
11702 }
11703 velocity.X = 0f - velocity.X;
11704 velocity.Y = 0f - velocity.Y;
11705 netUpdate = true;
11706 }
11707 ai[0] = 1f;
11708 }
11709 else if (type == 951)
11710 {
11711 Vector2 vector2 = (nPC.Center - base.Center).SafeNormalize(Vector2.Zero);
11712 vector2.X += (-0.5f + Main.rand.NextFloat()) * 13f;
11713 vector2.Y = -5f;
11714 velocity.X = vector2.X;
11715 velocity.Y = vector2.Y;
11716 netUpdate = true;
11717 }
11718 else if (type == 582 || type == 902)
11719 {
11720 if (ai[0] != 0f)
11721 {
11722 direction *= -1;
11723 }
11724 }
11725 else if (type == 612 || type == 953 || type == 978)
11726 {
11727 direction = Main.player[owner].direction;
11728 }
11729 else if (type == 624)
11730 {
11731 float num21 = 1f;
11732 if (nPC.knockBackResist > 0f)
11733 {
11734 num21 = 1f / nPC.knockBackResist;
11735 }
11736 knockBack = 4f * num21;
11737 num3 = knockBack;
11738 if (nPC.Center.X < base.Center.X)
11739 {
11740 direction = 1;
11741 }
11742 else
11743 {
11744 direction = -1;
11745 }
11746 }
11747 else if (aiStyle == 16)
11748 {
11749 if (timeLeft > 3)
11750 {
11751 timeLeft = 3;
11752 }
11753 if (nPC.position.X + (float)(nPC.width / 2) < position.X + (float)(width / 2))
11754 {
11755 direction = -1;
11756 }
11757 else
11758 {
11759 direction = 1;
11760 }
11761 }
11762 else if (aiStyle == 68)
11763 {
11764 if (timeLeft > 3)
11765 {
11766 timeLeft = 3;
11767 }
11768 if (nPC.position.X + (float)(nPC.width / 2) < position.X + (float)(width / 2))
11769 {
11770 direction = -1;
11771 }
11772 else
11773 {
11774 direction = 1;
11775 }
11776 }
11777 else if (aiStyle == 50)
11778 {
11779 if (nPC.position.X + (float)(nPC.width / 2) < position.X + (float)(width / 2))
11780 {
11781 direction = -1;
11782 }
11783 else
11784 {
11785 direction = 1;
11786 }
11787 }
11788 else if (type == 908)
11789 {
11790 if (nPC.position.X + (float)(nPC.width / 2) < position.X + (float)(width / 2))
11791 {
11792 direction = -1;
11793 }
11794 else
11795 {
11796 direction = 1;
11797 }
11798 }
11799 if (type == 509)
11800 {
11801 int num22 = Main.rand.Next(2, 6);
11802 for (int k = 0; k < num22; k++)
11803 {
11804 Vector2 vector3 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
11805 vector3 += velocity * 3f;
11806 vector3.Normalize();
11807 vector3 *= (float)Main.rand.Next(35, 81) * 0.1f;
11808 int num23 = (int)((double)damage * 0.5);
11809 NewProjectile(GetProjectileSource_FromThis(), base.Center.X, base.Center.Y, vector3.X, vector3.Y, 504, num23, knockBack * 0.2f, owner);
11810 }
11811 }
11812 if ((type == 476 || type == 950) && !npcProj)
11813 {
11814 float x = Main.player[owner].Center.X;
11815 if (nPC.Center.X < x)
11816 {
11817 direction = -1;
11818 }
11819 else
11820 {
11821 direction = 1;
11822 }
11823 }
11824 if (type == 598 || type == 636 || type == 614 || type == 971 || type == 975)
11825 {
11826 ai[0] = 1f;
11827 ai[1] = i;
11828 velocity = (nPC.Center - base.Center) * 0.75f;
11829 netUpdate = true;
11830 }
11831 if (type >= 511 && type <= 513)
11832 {
11833 ai[1] += 1f;
11834 netUpdate = true;
11835 }
11836 if (type == 659)
11837 {
11838 timeLeft = 0;
11839 }
11840 if (type == 524)
11841 {
11842 netUpdate = true;
11843 ai[0] += 50f;
11844 }
11845 if ((type == 688 || type == 689 || type == 690) && nPC.type != 68 && nPC.defense < 999)
11846 {
11848 }
11849 if (aiStyle == 39)
11850 {
11851 if (ai[1] == 0f)
11852 {
11853 ai[1] = i + 1;
11854 netUpdate = true;
11855 }
11856 if (Main.player[owner].position.X + (float)(Main.player[owner].width / 2) < position.X + (float)(width / 2))
11857 {
11858 direction = 1;
11859 }
11860 else
11861 {
11862 direction = -1;
11863 }
11864 }
11865 if (type == 41 && timeLeft > 1)
11866 {
11867 timeLeft = 1;
11868 }
11869 if (aiStyle == 99)
11870 {
11871 Main.player[owner].Counterweight(nPC.Center, damage, knockBack);
11872 if (nPC.Center.X < Main.player[owner].Center.X)
11873 {
11874 direction = -1;
11875 }
11876 else
11877 {
11878 direction = 1;
11879 }
11880 if (ai[0] >= 0f)
11881 {
11882 Vector2 vector4 = base.Center - nPC.Center;
11883 vector4.Normalize();
11884 float num24 = 16f;
11885 velocity *= -0.5f;
11886 velocity += vector4 * num24;
11887 netUpdate = true;
11888 localAI[0] += 20f;
11889 if (!Collision.CanHit(position, width, height, Main.player[owner].position, Main.player[owner].width, Main.player[owner].height))
11890 {
11891 localAI[0] += 40f;
11892 num19 = (int)((double)num19 * 0.75);
11893 }
11894 }
11895 }
11896 if (type == 856 && !Collision.CanHit(position, width, height, Main.player[owner].position, Main.player[owner].width, Main.player[owner].height))
11897 {
11898 num19 = (int)((double)num19 * 0.75);
11899 }
11900 if (aiStyle == 93)
11901 {
11902 if (ai[0] == 0f)
11903 {
11904 ai[1] = 0f;
11905 int num25 = -i - 1;
11906 ai[0] = num25;
11907 velocity = nPC.Center - base.Center;
11908 }
11909 num19 = ((ai[0] != 2f) ? ((int)((double)num19 * 0.15)) : ((int)((double)num19 * 1.35)));
11910 }
11911 if (flag)
11912 {
11913 int num26 = Item.NPCtoBanner(nPC.BannerID());
11914 if (num26 >= 0)
11915 {
11916 Main.player[Main.myPlayer].lastCreatureHit = num26;
11917 }
11918 }
11919 if (Main.netMode != 2 && flag)
11920 {
11921 int num27 = Item.NPCtoBanner(nPC.BannerID());
11922 if (num27 > 0 && Main.player[owner].HasNPCBannerBuff(num27))
11923 {
11924 num19 = ((!Main.expertMode) ? ((int)((float)num19 * ItemID.Sets.BannerStrength[Item.BannerToItem(num27)].NormalDamageDealt)) : ((int)((float)num19 * ItemID.Sets.BannerStrength[Item.BannerToItem(num27)].ExpertDamageDealt)));
11925 }
11926 }
11927 if (Main.expertMode)
11928 {
11929 if ((type == 30 || type == 397 || type == 517 || type == 28 || type == 37 || type == 516 || type == 29 || type == 470 || type == 637 || type == 108 || type == 281 || type == 588 || type == 519 || type == 773 || type == 183 || type == 181 || type == 566 || type == 1002) && nPC.type >= 13 && nPC.type <= 15)
11930 {
11931 num19 /= 5;
11932 }
11933 if (type == 280 && ((nPC.type >= 134 && nPC.type <= 136) || nPC.type == 139))
11934 {
11935 num19 = (int)((double)num19 * 0.75);
11936 }
11937 }
11938 if (Main.netMode != 2 && nPC.type == 439 && type >= 0 && type <= ProjectileID.Count && ProjectileID.Sets.CultistIsResistantTo[type])
11939 {
11940 num19 = (int)((float)num19 * 0.75f);
11941 }
11942 if (type == 497 && penetrate != 1)
11943 {
11944 ai[0] = 25f;
11945 float num28 = velocity.Length();
11946 Vector2 vector5 = nPC.Center - base.Center;
11947 vector5.Normalize();
11948 vector5 *= num28;
11949 velocity = -vector5 * 0.9f;
11950 netUpdate = true;
11951 }
11952 if (type == 323 && (nPC.type == 159 || nPC.type == 158))
11953 {
11954 num19 *= 10;
11955 }
11956 if (type == 981 && nPC.type == 104)
11957 {
11958 num19 *= 3;
11959 }
11960 if (type == 294)
11961 {
11962 damage = (int)((double)damage * 0.9);
11963 }
11964 if (type == 265)
11965 {
11966 damage = (int)((double)damage * 0.75);
11967 }
11968 if (type == 355)
11969 {
11970 damage = (int)((double)damage * 0.75);
11971 }
11972 if (type == 114)
11973 {
11974 damage = (int)((double)damage * 0.9);
11975 }
11976 if (type == 76 || type == 78 || type == 77)
11977 {
11978 damage = (int)((double)damage * 0.95);
11979 }
11980 if (type == 85)
11981 {
11982 damage = (int)((double)damage * 0.85);
11983 }
11984 if (type == 866)
11985 {
11986 damage = (int)((double)damage * 0.8);
11987 }
11988 if (type == 841)
11989 {
11990 damage = (int)((double)damage * 0.5);
11991 }
11992 if (type == 914)
11993 {
11994 damage = (int)((double)damage * 0.6);
11995 }
11996 if (type == 952)
11997 {
11998 damage = (int)((double)damage * 0.9);
11999 }
12000 if (type == 913)
12001 {
12002 damage = (int)((double)damage * 0.66);
12003 }
12004 if (type == 912)
12005 {
12006 damage = (int)((double)damage * 0.7);
12007 }
12008 if (type == 847)
12009 {
12010 damage = (int)((double)damage * 0.8);
12011 }
12012 if (type == 848)
12013 {
12014 damage = (int)((double)damage * 0.95);
12015 }
12016 if (type == 849)
12017 {
12018 damage = (int)((double)damage * 0.9);
12019 }
12020 if (type == 915)
12021 {
12022 damage = (int)((double)damage * 0.9);
12023 }
12024 if (type == 931)
12025 {
12026 damage = (int)((double)damage * 0.8);
12027 }
12028 if (type == 242)
12029 {
12030 damage = (int)((double)damage * 0.85);
12031 }
12032 if (type == 323)
12033 {
12034 damage = (int)((double)damage * 0.9);
12035 }
12036 if (type == 5)
12037 {
12038 damage = (int)((double)damage * 0.9);
12039 }
12040 if (type == 4)
12041 {
12042 damage = (int)((double)damage * 0.95);
12043 }
12044 if (type == 309)
12045 {
12046 damage = (int)((double)damage * 0.85);
12047 }
12048 if (type == 132)
12049 {
12050 damage = (int)((double)damage * 0.85);
12051 }
12052 if (type == 985)
12053 {
12054 damage = (int)((double)damage * 0.75);
12055 }
12056 if (type == 950)
12057 {
12058 damage = (int)((double)damage * 0.98);
12059 }
12060 if (type == 964)
12061 {
12062 damage = (int)((double)damage * 0.85);
12063 }
12064 if (type == 477 && penetrate > 1)
12065 {
12066 int[] array2 = new int[10];
12067 int num29 = 0;
12068 int num30 = 700;
12069 int num31 = 20;
12070 for (int l = 0; l < 200; l++)
12071 {
12072 if (l == i || !Main.npc[l].CanBeChasedBy(this))
12073 {
12074 continue;
12075 }
12076 float num32 = (base.Center - Main.npc[l].Center).Length();
12077 if (num32 > (float)num31 && num32 < (float)num30 && Collision.CanHitLine(base.Center, 1, 1, Main.npc[l].Center, 1, 1))
12078 {
12079 array2[num29] = l;
12080 num29++;
12081 if (num29 >= 9)
12082 {
12083 break;
12084 }
12085 }
12086 }
12087 if (num29 > 0)
12088 {
12089 num29 = Main.rand.Next(num29);
12090 Vector2 vector6 = Main.npc[array2[num29]].Center - base.Center;
12091 float num33 = velocity.Length();
12092 vector6.Normalize();
12094 netUpdate = true;
12095 }
12096 }
12097 if (type == 261 && velocity.Length() < 3.5f)
12098 {
12099 num19 /= 2;
12100 num3 /= 2f;
12101 }
12102 if (flag && melee && Main.player[owner].parryDamageBuff && !ProjectileID.Sets.DontApplyParryDamageBuff[type])
12103 {
12104 num19 *= 5;
12105 Main.player[owner].parryDamageBuff = false;
12106 Main.player[owner].ClearBuff(198);
12107 }
12108 StatusNPC(i);
12109 if (flag && nPC.life > 5)
12110 {
12112 }
12114 {
12115 nPC.UpdateNPC_BuffSetFlags(lowerBuffTime: false);
12116 }
12117 if (type == 317)
12118 {
12119 ai[1] = -1f;
12120 netUpdate = true;
12121 }
12122 int num34 = direction;
12123 switch (type)
12124 {
12125 case 697:
12126 case 699:
12127 case 707:
12128 case 708:
12129 case 759:
12130 num34 = ((Main.player[owner].Center.X < nPC.Center.X) ? 1 : (-1));
12131 break;
12132 }
12133 if (aiStyle == 188 || aiStyle == 189 || aiStyle == 190 || aiStyle == 191)
12134 {
12135 num34 = ((Main.player[owner].Center.X < nPC.Center.X) ? 1 : (-1));
12136 }
12137 if (aiStyle == 15)
12138 {
12139 num34 = ((Main.player[owner].Center.X < nPC.Center.X) ? 1 : (-1));
12140 if (ai[0] == 0f)
12141 {
12142 num3 *= 0.35f;
12143 }
12144 if (ai[0] == 6f)
12145 {
12146 num3 *= 0.5f;
12147 }
12148 }
12149 if (flag && !hostile)
12150 {
12151 num19 += nPC.checkArmorPenetration(num4, armorPenetrationPercent);
12152 }
12154 int num35 = ((!flag) ? ((int)nPC.StrikeNPCNoInteraction(num19, num3, num34, flag12)) : ((int)nPC.StrikeNPC(num19, num3, num34, flag12)));
12155 if (flag && attempt.DidNPCDie())
12156 {
12157 Main.player[owner].OnKillNPC(ref attempt, this);
12158 }
12159 if (flag && Main.player[owner].accDreamCatcher)
12160 {
12161 Main.player[owner].addDPS(num35);
12162 }
12163 bool flag23 = !nPC.immortal;
12164 bool flag24 = num35 > 0 && nPC.lifeMax > 5 && friendly && !hostile && aiStyle != 59;
12165 bool flag25 = false;
12166 if (flag23 && active && timeLeft > 10 && nPC.active && nPC.type == 676 && CanBeReflected())
12167 {
12168 nPC.ReflectProjectile(this);
12169 penetrate++;
12170 }
12171 if (flag && flag23)
12172 {
12173 if (type == 997 && (!nPC.immortal || flag25) && !nPC.SpawnedFromStatue && !NPCID.Sets.CountsAsCritter[nPC.type])
12174 {
12175 Main.player[owner].HorsemansBlade_SpawnPumpkin(i, (int)((float)damage * 1f), knockBack);
12176 }
12177 if (type == 756 && penetrate == 1)
12178 {
12179 damage = 0;
12180 penetrate = -1;
12181 flag4 = false;
12182 }
12183 if ((flag25 || nPC.value > 0f) && Main.player[owner].hasLuckyCoin && Main.rand.Next(5) == 0)
12184 {
12185 int num36 = 71;
12186 if (Main.rand.Next(10) == 0)
12187 {
12188 num36 = 72;
12189 }
12190 if (Main.rand.Next(100) == 0)
12191 {
12192 num36 = 73;
12193 }
12194 int num37 = Item.NewItem(GetItemSource_OnHit(nPC, 2), (int)nPC.position.X, (int)nPC.position.Y, nPC.width, nPC.height, num36);
12195 Main.item[num37].stack = Main.rand.Next(1, 11);
12196 Main.item[num37].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
12197 Main.item[num37].velocity.X = (float)Main.rand.Next(10, 31) * 0.2f * (float)num34;
12198 Main.item[num37].timeLeftInWhichTheItemCannotBeTakenByEnemies = 60;
12199 if (Main.netMode == 1)
12200 {
12201 NetMessage.SendData(148, -1, -1, null, num37);
12202 }
12203 }
12204 if (type == 999 && owner == Main.myPlayer && Main.rand.Next(3) == 0)
12205 {
12206 Player player = Main.player[owner];
12207 Vector2 vector7 = (base.Center - nPC.Center).SafeNormalize(Vector2.Zero) * 0.25f;
12208 int dmg = damage / 2;
12209 float kB = knockBack;
12210 int num38 = NewProjectile(GetProjectileSource_FromThis(), base.Center.X, base.Center.Y, vector7.X, vector7.Y, player.beeType(), player.beeDamage(dmg), player.beeKB(kB), owner);
12211 Main.projectile[num38].melee = true;
12212 }
12213 if (flag24)
12214 {
12215 if (type == 304 && !Main.player[owner].moonLeech)
12216 {
12217 vampireHeal(num35, new Vector2(nPC.Center.X, nPC.Center.Y), nPC);
12218 }
12219 if (nPC.canGhostHeal || flag25)
12220 {
12221 if (Main.player[owner].ghostHeal && !Main.player[owner].moonLeech)
12222 {
12223 ghostHeal(num35, new Vector2(nPC.Center.X, nPC.Center.Y), nPC);
12224 }
12225 if (Main.player[owner].ghostHurt)
12226 {
12227 ghostHurt(num35, new Vector2(nPC.Center.X, nPC.Center.Y), nPC);
12228 }
12229 if (magic && Main.player[owner].setNebula && Main.player[owner].nebulaCD == 0 && Main.rand.Next(3) == 0)
12230 {
12231 Main.player[owner].nebulaCD = 30;
12232 int num39 = Utils.SelectRandom<int>(Main.rand, 3453, 3454, 3455);
12233 int num40 = Item.NewItem(GetItemSource_OnHit(nPC, 1), (int)nPC.position.X, (int)nPC.position.Y, nPC.width, nPC.height, num39);
12234 Main.item[num40].velocity.Y = (float)Main.rand.Next(-20, 1) * 0.2f;
12235 Main.item[num40].velocity.X = (float)Main.rand.Next(10, 31) * 0.2f * (float)num34;
12236 if (Main.netMode == 1)
12237 {
12238 NetMessage.SendData(21, -1, -1, null, num40);
12239 }
12240 }
12241 }
12242 if (melee && Main.player[owner].beetleOffense && (!nPC.immortal || flag25))
12243 {
12244 if (Main.player[owner].beetleOrbs == 0)
12245 {
12246 Main.player[owner].beetleCounter += num35 * 3;
12247 }
12248 else if (Main.player[owner].beetleOrbs == 1)
12249 {
12250 Main.player[owner].beetleCounter += num35 * 2;
12251 }
12252 else
12253 {
12254 Main.player[owner].beetleCounter += num35;
12255 }
12256 Main.player[owner].beetleCountdown = 0;
12257 }
12258 if (arrow && type != 631 && Main.player[owner].phantasmTime > 0)
12259 {
12260 Vector2 source = Main.player[owner].position + Main.player[owner].Size * Utils.RandomVector2(Main.rand, 0f, 1f);
12261 Vector2 vector8 = nPC.DirectionFrom(source) * 6f;
12262 int num41 = (int)((float)damage * 0.3f);
12266 }
12267 Player player2 = Main.player[owner];
12268 switch (type)
12269 {
12270 case 914:
12271 player2.AddBuff(314, 180);
12272 break;
12273 case 847:
12274 player2.AddBuff(308, 180);
12275 break;
12276 case 849:
12277 player2.AddBuff(311, 180);
12278 break;
12279 case 912:
12280 {
12281 int num42 = 15;
12282 if (!player2.coolWhipBuff)
12283 {
12285 player2.coolWhipBuff = true;
12286 }
12287 player2.AddBuff(312, 180);
12288 break;
12289 }
12290 }
12291 }
12292 }
12293 if (flag && (melee || ProjectileID.Sets.IsAWhip[type]) && Main.player[owner].meleeEnchant == 7)
12294 {
12295 NewProjectile(GetProjectileSource_FromThis(), nPC.Center.X, nPC.Center.Y, nPC.velocity.X, nPC.velocity.Y, 289, 0, 0f, owner);
12296 }
12297 if (flag && type == 913)
12298 {
12299 localAI[0] = 1f;
12300 }
12301 if (Main.netMode != 0)
12302 {
12303 if (flag12)
12304 {
12305 NetMessage.SendData(28, -1, -1, null, i, num19, num3, num34, 1);
12306 }
12307 else
12308 {
12309 NetMessage.SendData(28, -1, -1, null, i, num19, num3, num34);
12310 }
12311 }
12312 if (type == 916)
12313 {
12315 }
12316 if (type >= 390 && type <= 392)
12317 {
12318 localAI[1] = 20f;
12319 }
12321 {
12323 {
12324 nPC.immune[owner] = 0;
12325 perIDStaticNPCImmunity[type][i] = Main.GameUpdateCount + (uint)idStaticNPCHitCooldown;
12326 }
12327 }
12328 else if (type == 434)
12329 {
12330 numUpdates = 0;
12331 }
12332 else if (type == 598 || type == 636 || type == 614)
12333 {
12335 if (type == 636)
12336 {
12338 }
12339 if (type == 614)
12340 {
12342 }
12344 }
12345 else if (type == 632)
12346 {
12347 nPC.immune[owner] = 5;
12348 }
12349 else if (type == 514)
12350 {
12351 nPC.immune[owner] = 1;
12352 }
12353 else if (type == 611)
12354 {
12355 if (localAI[1] <= 0f)
12356 {
12357 NewProjectile(GetProjectileSource_FromThis(), nPC.Center.X, nPC.Center.Y, 0f, 0f, 612, damage, 10f, owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f);
12358 }
12359 localAI[1] = 4f;
12360 }
12361 else if (type == 595 || type == 735)
12362 {
12363 nPC.immune[owner] = 5;
12364 }
12365 else if (type == 927)
12366 {
12367 nPC.immune[owner] = 4;
12368 }
12369 else if (type == 286)
12370 {
12371 nPC.immune[owner] = 5;
12372 }
12373 else if (type == 443)
12374 {
12375 nPC.immune[owner] = 8;
12376 }
12377 else if (type >= 424 && type <= 426)
12378 {
12379 nPC.immune[owner] = 5;
12380 }
12381 else if (type == 634 || type == 635)
12382 {
12383 nPC.immune[owner] = 5;
12384 }
12385 else if (type == 659)
12386 {
12387 nPC.immune[owner] = 5;
12388 }
12389 else if (type == 246)
12390 {
12391 nPC.immune[owner] = 7;
12392 }
12393 else if (type == 249)
12394 {
12395 nPC.immune[owner] = 7;
12396 }
12397 else if (type == 16)
12398 {
12399 nPC.immune[owner] = 8;
12400 }
12401 else if (type == 409)
12402 {
12403 nPC.immune[owner] = 6;
12404 }
12405 else if (type == 311)
12406 {
12407 nPC.immune[owner] = 7;
12408 }
12409 else if (type == 582 || type == 902)
12410 {
12411 nPC.immune[owner] = 7;
12412 if (ai[0] != 1f)
12413 {
12414 ai[0] = 1f;
12415 netUpdate = true;
12416 }
12417 }
12418 else
12419 {
12420 if (type == 451)
12421 {
12422 if (ai[0] == 0f)
12423 {
12424 ai[0] += penetrate;
12425 }
12426 else
12427 {
12428 ai[0] -= penetrate + 1;
12429 }
12430 ai[1] = 0f;
12431 netUpdate = true;
12432 Main.npc[i].position -= Main.npc[i].netOffset;
12433 break;
12434 }
12435 if (type == 864)
12436 {
12437 array[i] = 10;
12438 nPC.immune[owner] = 0;
12439 if (ai[0] > 0f)
12440 {
12441 ai[0] = -1f;
12442 ai[1] = 0f;
12443 netUpdate = true;
12444 }
12445 }
12446 else if (type == 661 || type == 856)
12447 {
12448 array[i] = 8;
12449 nPC.immune[owner] = 0;
12450 }
12451 else if (type == 866)
12452 {
12453 array[i] = -1;
12454 nPC.immune[owner] = 0;
12455 penetrate--;
12456 if (penetrate == 0)
12457 {
12458 penetrate = 1;
12459 damage = 0;
12460 ai[1] = -1f;
12461 netUpdate = true;
12462 Main.npc[i].position -= Main.npc[i].netOffset;
12463 break;
12464 }
12465 if (owner == Main.myPlayer)
12466 {
12468 float num44 = ai[1];
12469 ai[1] = num43;
12470 if (ai[1] != num44)
12471 {
12472 netUpdate = true;
12473 }
12474 if (num43 != -1)
12475 {
12476 velocity = velocity.Length() * DirectionTo(Main.npc[num43].Center);
12477 }
12478 }
12479 }
12480 else if (usesLocalNPCImmunity && localNPCHitCooldown != -2)
12481 {
12482 nPC.immune[owner] = 0;
12484 }
12486 {
12487 nPC.immune[owner] = 10;
12488 }
12489 }
12490 if (type == 710)
12491 {
12492 BetsySharpnel(i);
12493 }
12494 if (penetrate > 0 && type != 317 && type != 866)
12495 {
12496 if (type == 357)
12497 {
12498 damage = (int)((double)damage * 0.8);
12499 }
12500 penetrate--;
12501 if (penetrate == 0)
12502 {
12503 Main.npc[i].position -= Main.npc[i].netOffset;
12505 {
12506 penetrate = -1;
12507 damage = 0;
12508 }
12509 flag4 = false;
12510 }
12511 }
12512 if (aiStyle == 7)
12513 {
12514 ai[0] = 1f;
12515 damage = 0;
12516 netUpdate = true;
12517 }
12518 else if (aiStyle == 13)
12519 {
12520 ai[0] = 1f;
12521 netUpdate = true;
12522 }
12523 else if (aiStyle == 69)
12524 {
12525 ai[0] = 1f;
12526 netUpdate = true;
12527 }
12528 else if (type == 607)
12529 {
12530 ai[0] = 1f;
12531 netUpdate = true;
12532 friendly = false;
12533 }
12534 else if (type == 638 || type == 639 || type == 640)
12535 {
12536 array[i] = -1;
12537 nPC.immune[owner] = 0;
12538 damage = (int)((double)damage * 0.96);
12539 }
12540 else if (type == 617)
12541 {
12542 array[i] = 8;
12543 nPC.immune[owner] = 0;
12544 }
12545 else if (type == 656)
12546 {
12547 array[i] = 8;
12548 nPC.immune[owner] = 0;
12549 localAI[0] += 1f;
12550 }
12551 else if (type == 618)
12552 {
12553 array[i] = 20;
12554 nPC.immune[owner] = 0;
12555 }
12556 else if (type == 642)
12557 {
12558 array[i] = 10;
12559 nPC.immune[owner] = 0;
12560 }
12561 else if (type == 857)
12562 {
12563 array[i] = 10;
12564 nPC.immune[owner] = 0;
12565 }
12566 else if (type == 611 || type == 612)
12567 {
12568 array[i] = 6;
12569 nPC.immune[owner] = 4;
12570 }
12571 else if (type == 645)
12572 {
12573 array[i] = -1;
12574 nPC.immune[owner] = 0;
12575 if (ai[1] != -1f)
12576 {
12577 ai[0] = 0f;
12578 ai[1] = -1f;
12579 netUpdate = true;
12580 }
12581 }
12582 numHits++;
12583 if (type == 697)
12584 {
12585 if (ai[0] >= 42f)
12586 {
12587 localAI[1] = 1f;
12588 }
12589 }
12590 else if (type == 699)
12591 {
12593 }
12594 else if (type == 706)
12595 {
12596 damage = (int)((float)damage * 0.95f);
12597 }
12598 else if (type == 728)
12599 {
12600 SummonSuperStarSlash(nPC.Center);
12601 }
12602 else if (type == 34)
12603 {
12604 if (ai[0] == -1f)
12605 {
12606 ai[1] = -1f;
12607 netUpdate = true;
12608 }
12609 }
12610 else if (type == 79)
12611 {
12612 if (ai[0] == -1f)
12613 {
12614 ai[1] = -1f;
12615 netUpdate = true;
12616 }
12618 {
12619 PositionInWorld = nPC.Center,
12620 MovementVector = velocity
12621 });
12622 }
12623 else if (type == 931)
12624 {
12626 if (num45 != -1)
12627 {
12628 ai[0] = num45;
12629 netUpdate = true;
12630 }
12631 }
12632 else if (aiStyle == 165)
12633 {
12634 if (nPC.active)
12635 {
12636 Main.player[owner].MinionAttackTargetNPC = i;
12637 }
12638 }
12639 else if (type == 623)
12640 {
12642 {
12643 PositionInWorld = Vector2.Lerp(base.Center, nPC.Hitbox.ClosestPointInRect(base.Center), 0.5f) + new Vector2(0f, Main.rand.NextFloatDirection() * 10f),
12644 MovementVector = new Vector2(direction, Main.rand.NextFloatDirection() * 0.5f) * (3f + 3f * Main.rand.NextFloat())
12645 });
12646 }
12647 if (flag2)
12648 {
12649 Main.player[owner].SetMeleeHitCooldown(i, Main.player[owner].itemAnimation);
12650 }
12651 }
12652 }
12653 }
12654 }
12655 Main.npc[i].position -= Main.npc[i].netOffset;
12656 }
12657 }
12658 if (flag3 && Main.player[Main.myPlayer].hostile)
12659 {
12660 for (int m = 0; m < 255; m++)
12661 {
12662 if (m == owner)
12663 {
12664 continue;
12665 }
12666 Player player3 = Main.player[m];
12667 if (!player3.active || player3.dead || player3.immune || !player3.hostile || playerImmune[m] > 0 || (Main.player[Main.myPlayer].team != 0 && Main.player[Main.myPlayer].team == player3.team))
12668 {
12669 continue;
12670 }
12671 bool flag26 = !ownerHitCheck;
12672 if (ownerHitCheck)
12673 {
12675 }
12676 if (!flag26 || !Colliding(rectangle, player3.getRect()))
12677 {
12678 continue;
12679 }
12680 if (aiStyle == 3)
12681 {
12682 if (ai[0] == 0f)
12683 {
12684 velocity.X = 0f - velocity.X;
12685 velocity.Y = 0f - velocity.Y;
12686 netUpdate = true;
12687 }
12688 ai[0] = 1f;
12689 }
12690 else if (aiStyle == 16)
12691 {
12692 if (timeLeft > 3)
12693 {
12694 timeLeft = 3;
12695 }
12696 if (player3.position.X + (float)(player3.width / 2) < position.X + (float)(width / 2))
12697 {
12698 direction = -1;
12699 }
12700 else
12701 {
12702 direction = 1;
12703 }
12704 }
12705 else if (aiStyle == 68)
12706 {
12707 if (timeLeft > 3)
12708 {
12709 timeLeft = 3;
12710 }
12711 if (player3.position.X + (float)(player3.width / 2) < position.X + (float)(width / 2))
12712 {
12713 direction = -1;
12714 }
12715 else
12716 {
12717 direction = 1;
12718 }
12719 }
12720 int playerIndex = owner;
12722 {
12723 playerIndex = (int)ai[0];
12724 }
12726 if (type == 41 && timeLeft > 1)
12727 {
12728 timeLeft = 1;
12729 }
12730 bool flag27 = false;
12731 if (melee && Main.rand.Next(1, 101) <= Main.player[owner].meleeCrit)
12732 {
12733 flag27 = true;
12734 }
12735 int num46 = Main.DamageVar((int)((float)damage * num), Main.player[owner].luck);
12736 bool dodgeable = IsDamageDodgable();
12737 if (!player3.immune)
12738 {
12739 StatusPvP(m);
12740 }
12743 if (num47 > 0 && Main.player[owner].ghostHeal && friendly && !hostile)
12744 {
12745 ghostHeal(num47, new Vector2(player3.Center.X, player3.Center.Y), player3);
12746 }
12747 if (type == 304 && num47 > 0)
12748 {
12749 vampireHeal(num47, new Vector2(player3.Center.X, player3.Center.Y), player3);
12750 }
12751 if ((melee || ProjectileID.Sets.IsAWhip[type]) && Main.player[owner].meleeEnchant == 7)
12752 {
12753 NewProjectile(GetProjectileSource_FromThis(), player3.Center.X, player3.Center.Y, player3.velocity.X, player3.velocity.Y, 289, 0, 0f, owner);
12754 }
12755 if (Main.netMode != 0)
12756 {
12757 NetMessage.SendPlayerHurt(m, playerDeathReason, num46, direction, flag27, pvp: true, -1);
12758 }
12759 playerImmune[m] = 40;
12760 if (penetrate > 0)
12761 {
12762 penetrate--;
12763 if (penetrate == 0)
12764 {
12765 break;
12766 }
12767 }
12768 if (aiStyle == 7)
12769 {
12770 ai[0] = 1f;
12771 damage = 0;
12772 netUpdate = true;
12773 }
12774 else if (aiStyle == 13)
12775 {
12776 ai[0] = 1f;
12777 netUpdate = true;
12778 }
12779 else if (aiStyle == 69)
12780 {
12781 ai[0] = 1f;
12782 netUpdate = true;
12783 }
12784 }
12785 }
12786 }
12787 if (type == 10 && Main.netMode != 1)
12788 {
12789 for (int n = 0; n < 200; n++)
12790 {
12791 NPC nPC2 = Main.npc[n];
12792 if (!nPC2.active)
12793 {
12794 continue;
12795 }
12796 if (nPC2.type == 534)
12797 {
12798 if (rectangle.Intersects(nPC2.Hitbox))
12799 {
12800 nPC2.Transform(441);
12801 }
12802 }
12803 else
12804 {
12805 if (nPC2.type != 687 || !rectangle.Intersects(nPC2.Hitbox))
12806 {
12807 continue;
12808 }
12809 nPC2.Transform(683);
12810 Vector2 vector9 = nPC2.Center - new Vector2(20f);
12811 Utils.PoofOfSmoke(vector9);
12812 if (Main.netMode == 2)
12813 {
12814 NetMessage.SendData(106, -1, -1, null, (int)vector9.X, vector9.Y);
12815 }
12816 if (!NPC.unlockedSlimeYellowSpawn)
12817 {
12818 NPC.unlockedSlimeYellowSpawn = true;
12819 if (Main.netMode == 2)
12820 {
12821 NetMessage.SendData(7);
12822 }
12823 }
12824 }
12825 }
12826 }
12827 if ((type == 11 || type == 463) && Main.netMode != 1)
12828 {
12829 bool crimson = type == 463;
12830 for (int num48 = 0; num48 < 200; num48++)
12831 {
12832 if (Main.npc[num48].active)
12833 {
12834 Rectangle value2 = new Rectangle((int)Main.npc[num48].position.X, (int)Main.npc[num48].position.Y, Main.npc[num48].width, Main.npc[num48].height);
12835 if (rectangle.Intersects(value2))
12836 {
12837 Main.npc[num48].AttemptToConvertNPCToEvil(crimson);
12838 }
12839 }
12840 }
12841 }
12842 if (Main.netMode == 2 || !hostile || Main.myPlayer >= 255 || damage <= 0)
12843 {
12844 return;
12845 }
12846 int num49 = -1;
12847 switch (type)
12848 {
12849 case 452:
12850 case 454:
12851 case 455:
12852 case 462:
12853 num49 = 1;
12854 break;
12855 case 871:
12856 case 872:
12857 case 873:
12858 case 874:
12859 case 919:
12860 case 923:
12861 case 924:
12862 num49 = 1;
12863 break;
12864 }
12865 int myPlayer = Main.myPlayer;
12866 bool flag28 = Main.player[myPlayer].active && !Main.player[myPlayer].dead && (!Main.player[myPlayer].immune || num49 != -1);
12867 if (flag28 && type == 281)
12868 {
12869 flag28 = ai[1] - 1f == (float)myPlayer;
12870 }
12871 if (Main.getGoodWorld && type == 281)
12872 {
12873 flag28 = true;
12874 }
12875 if (!flag28 || !Colliding(rectangle, Main.player[myPlayer].getRect()))
12876 {
12877 return;
12878 }
12879 int num50 = direction;
12880 num50 = ((!(Main.player[myPlayer].position.X + (float)(Main.player[myPlayer].width / 2) < position.X + (float)(width / 2))) ? 1 : (-1));
12881 if (!Main.player[myPlayer].CanParryAgainst(Main.player[myPlayer].Hitbox, base.Hitbox, velocity))
12882 {
12883 int num51 = Main.DamageVar(damage, 0f - Main.player[owner].luck);
12885 if (num52 > 0 && Main.player[myPlayer].HasNPCBannerBuff(num52))
12886 {
12888 num51 = ((!Main.expertMode) ? ((int)((float)num51 * bannerEffect.NormalDamageReceived)) : ((int)((float)num51 * bannerEffect.ExpertDamageReceived)));
12889 }
12890 if (Main.player[myPlayer].resistCold && coldDamage)
12891 {
12892 num51 = (int)((float)num51 * 0.7f);
12893 }
12894 if (!reflected)
12895 {
12896 float num53 = Main.GameModeInfo.EnemyDamageMultiplier;
12897 if (Main.GameModeInfo.IsJourneyMode)
12898 {
12900 if (power.GetIsUnlocked())
12901 {
12902 num53 = power.StrengthMultiplierToGiveNPCs;
12903 }
12904 }
12905 num51 = (int)((float)num51 * num53);
12906 }
12907 int num54 = num51 * 2;
12908 if (type == 961)
12909 {
12910 if (penetrate == 1)
12911 {
12912 damage = 0;
12913 penetrate = -1;
12914 }
12915 else
12916 {
12917 damage = (int)((double)damage * 0.7);
12918 }
12919 }
12921 int playerIndex2 = -1;
12923 {
12924 playerIndex2 = (int)ai[0];
12925 }
12926 if (Main.player[myPlayer].Hurt(PlayerDeathReason.ByProjectile(playerIndex2, whoAmI), num54, num50, pvp: false, quiet: false, Crit: false, num49, dodgeable2) > 0.0 && !Main.player[myPlayer].dead)
12927 {
12928 StatusPlayer(myPlayer);
12929 }
12930 if (trap)
12931 {
12932 Main.player[myPlayer].trapDebuffSource = true;
12933 if (Main.player[myPlayer].dead)
12934 {
12935 AchievementsHelper.HandleSpecialEvent(Main.player[myPlayer], 4);
12936 }
12937 }
12938 }
12939 if (true)
12940 {
12941 if (type == 435 || type == 682)
12942 {
12943 penetrate--;
12944 }
12945 if (type == 436)
12946 {
12947 penetrate--;
12948 }
12949 if (type == 681)
12950 {
12951 timeLeft = 0;
12952 }
12953 if (type == 437)
12954 {
12955 penetrate--;
12956 }
12957 }
12958 }
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static PlayerDeathReason ByProjectile(int playerIndex, int projectileIndex)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
static void HandleSpecialEvent(Player player, int eventID)
static void RequestParticleSpawn(bool clientOnly, ParticleOrchestraType type, ParticleOrchestraSettings settings, int? overrideInvokingPlayerIndex=null)
static BannerEffect[] BannerStrength
Definition ItemID.cs:1018
static bool[] CountsAsCritter
Definition NPCID.cs:4202
static bool[] ReflectStarShotsInForTheWorthy
Definition NPCID.cs:4097
static bool[] BelongsToInvasionOldOnesArmy
Definition NPCID.cs:4166
static bool[] ZappingJellyfish
Definition NPCID.cs:4111
static bool[] ImmediatelyUpdatesNPCBuffFlags
static bool[] AllowsContactDamageFromJellyfish
static bool[] DontApplyParryDamageBuff
static bool[] IsARocketThatDealsDoubleDamageToPrimaryEnemy
static bool[] IsAMineThatDealsTripleDamageWhenStationary
static readonly short Count
Projectile FindStardustDragonHeadOfOwner()
static void KillOldestJavelin(int protectedProjectileIndex, int projectileType, int targetNPCIndex, Point[] bufferForScan)
void ghostHeal(int dmg, Vector2 Position, Entity victim)
static Conditions.NotNull _cachedConditions_notNull
IEntitySource GetItemSource_OnHit(Entity victim, int itemSourceId)
IEntitySource GetProjectileSource_FromThis()
bool stopsDealingDamageAfterPenetrateHits
int CountEnemiesWhoAreImmuneToMeRightNow(int cap)
int FindTargetWithLineOfSight(float maxRange=800f)
static Point[] _javelinsMax8
void BombsHurtPlayers(Rectangle projRectangle, int j)
void SummonSuperStarSlash(Vector2 target)
void vampireHeal(int dmg, Vector2 Position, Entity victim)
void TryDoingOnHitEffects(Entity entity)
static Conditions.IsSolid _cachedConditions_solid
void BetsySharpnel(int npcIndex)
static Point[] _javelinsMax6
bool appliesImmunityTimeOnSingleHits
static void EmitBlackLightningParticles(NPC targetNPC)
void ghostHurt(int dmg, Vector2 Position, Entity victim)
void StatusPlayer(int i)
static Point[] _javelinsMax10
bool CanHitWithMeleeWeapon(Entity ent)
static bool IsNPCIndexImmuneToProjectileType(int projectileType, int npcIndex)
bool Colliding(Rectangle myRect, Rectangle targetRect)
void LightDisc_Bounce(Vector2 hitPoint, Vector2 normal)
void StatusPvP(int i)
void StatusNPC(int i)
static uint[][] perIDStaticNPCImmunity
Definition Projectile.cs:82
Rectangle Damage_GetHitbox()
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 GenSearch Chain(GenSearch search, params GenCondition[] conditions)
Definition Searches.cs:123
static bool Find(Point origin, GenSearch search, out Point result)
Definition WorldUtils.cs:27
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227

References Terraria.Projectile._cachedConditions_notNull, Terraria.Projectile._cachedConditions_solid, Terraria.Projectile._javelinsMax10, Terraria.Projectile._javelinsMax6, Terraria.Projectile._javelinsMax8, Terraria.Entity.active, Terraria.Projectile.ai, Terraria.Projectile.aiStyle, Terraria.ID.ProjectileID.Sets.AllowsContactDamageFromJellyfish, Terraria.Projectile.appliesImmunityTimeOnSingleHits, System.array, Terraria.Projectile.arrow, Terraria.Projectile.bannerIdToRespondTo, Terraria.ID.ItemID.Sets.BannerStrength, Terraria.Item.BannerToItem(), Terraria.Player.beeDamage(), Terraria.Player.beeKB(), Terraria.Player.beeType(), Terraria.ID.NPCID.Sets.BelongsToInvasionOldOnesArmy, Terraria.Projectile.BetsySharpnel(), Terraria.Projectile.BombsHurtPlayers(), Terraria.DataStructures.PlayerDeathReason.ByProjectile(), Terraria.Projectile.CanBeReflected(), Terraria.Collision.CanHit(), Terraria.Collision.CanHitLine(), Terraria.Projectile.CanHitWithMeleeWeapon(), Terraria.WorldBuilding.Searches.Chain(), Terraria.Projectile.coldDamage, Terraria.Projectile.Colliding(), Terraria.ID.ProjectileID.Count, Terraria.Projectile.CountEnemiesWhoAreImmuneToMeRightNow(), Terraria.ID.NPCID.Sets.CountsAsCritter, Terraria.ID.ProjectileID.Sets.CultistIsResistantTo, Terraria.Projectile.CutTiles(), Terraria.Projectile.damage, Terraria.Projectile.Damage_GetHitbox(), Terraria.Main.DamageVar(), Terraria.Entity.direction, Terraria.Entity.DirectionTo(), Terraria.ID.ProjectileID.Sets.DontApplyParryDamageBuff, Terraria.Projectile.EmitBlackLightningParticles(), Terraria.Main.expertMode, Terraria.WorldBuilding.WorldUtils.Find(), Terraria.Projectile.FindStardustDragonHeadOfOwner(), Terraria.Projectile.FindTargetWithLineOfSight(), Terraria.Projectile.frame, Terraria.Projectile.friendly, Terraria.Main.GameModeInfo, Terraria.Main.getGoodWorld, Terraria.Projectile.GetItemSource_OnHit(), Terraria.Projectile.GetProjectileSource_FromThis(), Terraria.Projectile.ghostHeal(), Terraria.Projectile.ghostHurt(), Terraria.GameContent.Achievements.AchievementsHelper.HandleSpecialEvent(), Terraria.Main.hardMode, Terraria.Entity.height, Terraria.Projectile.hostile, Terraria.Projectile.idStaticNPCHitCooldown, Terraria.ID.ProjectileID.Sets.ImmediatelyUpdatesNPCBuffFlags, Terraria.GameContent.Creative.CreativePowerManager.Instance, Terraria.ID.ProjectileID.Sets.IsAGravestone, Terraria.ID.ProjectileID.Sets.IsAMineThatDealsTripleDamageWhenStationary, Terraria.ID.ProjectileID.Sets.IsARocketThatDealsDoubleDamageToPrimaryEnemy, Terraria.ID.ProjectileID.Sets.IsAWhip, Terraria.Projectile.IsDamageDodgable(), Terraria.Projectile.IsNPCIndexImmuneToProjectileType(), Terraria.Main.item, Terraria.Projectile.Kill(), Terraria.Projectile.KillOldestJavelin(), Terraria.Projectile.knockBack, Microsoft.Xna.Framework.Vector2.Length(), Microsoft.Xna.Framework.Vector2.Lerp(), Terraria.Projectile.LightDisc_Bounce(), Terraria.Projectile.localAI, Terraria.Projectile.localNPCHitCooldown, Terraria.Projectile.localNPCImmunity, Terraria.Projectile.magic, System.Math.Max(), Terraria.NPC.maxBuffs, Terraria.Projectile.maxPenetrate, Terraria.Projectile.melee, Terraria.Projectile.minion, Terraria.ID.ProjectileID.Sets.MinionShot, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Projectile.netUpdate, Terraria.Item.NewItem(), Terraria.Projectile.NewProjectile(), Terraria.Main.npc, Terraria.Projectile.npcProj, Terraria.Item.NPCtoBanner(), Terraria.Projectile.numHits, Terraria.Projectile.numUpdates, Terraria.Projectile.owner, Terraria.Projectile.ownerHitCheck, Terraria.Projectile.penetrate, Terraria.Projectile.perIDStaticNPCImmunity, Terraria.Main.player, Terraria.Projectile.playerImmune, Terraria.Utils.PoofOfSmoke(), Terraria.Entity.position, Terraria.Main.projectile, Terraria.Main.projFrames, Terraria.Main.projPet, Terraria.Main.rand, Terraria.Utils.RandomVector2(), Terraria.Projectile.ranged, Terraria.Projectile.reflected, Terraria.ID.NPCID.Sets.ReflectStarShotsInForTheWorthy, Terraria.Main.remixWorld, Terraria.GameContent.Drawing.ParticleOrchestrator.RequestParticleSpawn(), Terraria.Projectile.scale, Terraria.NetMessage.SendData(), Terraria.NetMessage.SendPlayerHurt(), Terraria.Projectile.sentry, Terraria.ID.ProjectileID.Sets.SentryShot, Terraria.Collision.SolidTiles(), System.source, Terraria.ID.ProjectileID.Sets.StardustDragon, Terraria.Projectile.StatusNPC(), Terraria.Projectile.StatusPlayer(), Terraria.Projectile.StatusPvP(), Terraria.Projectile.stopsDealingDamageAfterPenetrateHits, Terraria.ID.ProjectileID.Sets.StormTiger, Terraria.Projectile.SummonMonkGhast(), Terraria.Projectile.SummonSuperStarSlash(), Terraria.Projectile.tileCollide, Terraria.Projectile.timeLeft, Terraria.Projectile.trap, Terraria.Projectile.TryDoingOnHitEffects(), Terraria.Projectile.type, Microsoft.Xna.Framework.Vector2.UnitX, Terraria.NPC.unlockedSlimeYellowSpawn, Terraria.Projectile.usesIDStaticNPCImmunity, Terraria.Projectile.usesLocalNPCImmunity, Terraria.Projectile.usesOwnerMeleeHitCD, System.value, Terraria.Projectile.vampireHeal(), Terraria.Entity.velocity, Terraria.Entity.whoAmI, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, Terraria.ID.NPCID.Sets.ZappingJellyfish, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.Projectile.HandleMovement(), Terraria.Projectile.NewProjectile(), Terraria.Projectile.NewProjectile(), and Terraria.Projectile.Update().