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

◆ AI_100_Medusa()

void Terraria.Projectile.AI_100_Medusa ( )
inlineprivate

Definition at line 36459 of file Projectile.cs.

36460 {
36461 Player player = Main.player[owner];
36463 if (type == 535)
36464 {
36465 zero.X = (float)player.direction * 6f;
36466 zero.Y = player.gravDir * -14f;
36467 bool flag = true;
36468 bool flag2 = ai[0] > 0f;
36469 if (!player.dead)
36470 {
36471 timeLeft = 3;
36472 }
36473 if (ai[0] > 0f)
36474 {
36475 ai[0] -= 1f;
36476 }
36477 if (flag2)
36478 {
36479 if (frame < 8)
36480 {
36481 frame = 8;
36482 }
36483 if (frame >= 12)
36484 {
36485 frame = 8;
36486 }
36487 frameCounter++;
36488 if (++frameCounter >= 5)
36489 {
36490 frameCounter = 0;
36491 if (++frame >= 12)
36492 {
36493 frame = 8;
36494 }
36495 }
36496 }
36497 else if (++frameCounter >= 5)
36498 {
36499 frameCounter = 0;
36500 if (++frame >= 8)
36501 {
36502 frame = 0;
36503 }
36504 }
36505 Vector2 center = player.Center;
36506 Vector2 vector = Main.screenPosition + new Vector2(Main.mouseX, Main.mouseY) - center;
36507 if (player.gravDir == -1f)
36508 {
36509 vector.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - center.Y;
36510 }
36511 Vector2 vector2 = new Vector2(Math.Sign((vector.X == 0f) ? ((float)player.direction) : vector.X), 0f);
36512 if (vector2.X != velocity.X || vector2.Y != velocity.Y)
36513 {
36514 netUpdate = true;
36515 }
36516 velocity = vector2;
36517 if (flag2 && soundDelay == 0)
36518 {
36519 SoundEngine.PlaySound(4, (int)base.position.X, (int)base.position.Y, 17);
36520 }
36521 soundDelay = (flag2 ? 4 : 0);
36522 if (Main.myPlayer == owner)
36523 {
36524 Vector2 position = player.Center + new Vector2(player.direction * 4, player.gravDir * 2f);
36525 if (!player.channel)
36526 {
36527 Kill();
36528 return;
36529 }
36530 if (!flag2 || ai[0] % 15f == 0f)
36531 {
36532 bool flag3 = false;
36533 for (int i = 0; i < 200; i++)
36534 {
36535 NPC nPC = Main.npc[i];
36536 if (nPC.active && Distance(nPC.Center) < 320f && nPC.CanBeChasedBy(this) && Collision.CanHitLine(nPC.position, nPC.width, nPC.height, position, 0, 0))
36537 {
36538 flag3 = true;
36539 break;
36540 }
36541 }
36542 if (flag3)
36543 {
36544 bool flag4 = false;
36545 if (!flag || player.CheckMana(player.inventory[player.selectedItem].mana, pay: true))
36546 {
36547 int num = damage;
36548 position = base.Center;
36549 int num2 = 0;
36550 float num3 = 0f;
36551 _medusaHeadTargetList.Clear();
36552 for (int j = 0; j < 200; j++)
36553 {
36554 NPC nPC2 = Main.npc[j];
36555 float num4 = Distance(nPC2.Center);
36556 if (nPC2.active && num4 < 320f && nPC2.CanBeChasedBy(this) && Collision.CanHitLine(nPC2.position, nPC2.width, nPC2.height, position, 0, 0))
36557 {
36558 _medusaHeadTargetList.Add(Tuple.Create(j, num4));
36559 }
36560 }
36562 for (int k = 0; k < _medusaHeadTargetList.Count && k < 3; k++)
36563 {
36565 NPC nPC3 = Main.npc[tuple.Item1];
36566 Vector2 v = nPC3.Center - position;
36567 num3 += v.ToRotation();
36568 num2++;
36570 Main.projectile[num5].Center = nPC3.Center;
36571 Main.projectile[num5].damage = num;
36572 Main.projectile[num5].Damage();
36573 Main.projectile[num5].damage = 0;
36574 Main.projectile[num5].Center = position;
36575 ai[0] = 180f;
36576 }
36577 num3 = ((num2 == 0) ? ((player.direction == 1) ? 0f : ((float)Math.PI)) : (num3 / (float)num2));
36578 for (int l = 0; l < 4; l++)
36579 {
36581 zero2 = ((Main.rand.Next(4) == 0) ? (Vector2.UnitX.RotatedByRandom(6.2831854820251465) * new Vector2(200f, 50f) * (Main.rand.NextFloat() * 0.7f + 0.3f)) : (Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy(num3) * new Vector2(200f, 50f) * (Main.rand.NextFloat() * 0.7f + 0.3f)));
36583 }
36584 ai[0] = 60f;
36585 netUpdate = true;
36586 }
36587 }
36588 }
36589 }
36590 Lighting.AddLight(base.Center, 0.9f, 0.75f, 0.1f);
36591 }
36592 rotation = ((player.gravDir == 1f) ? 0f : ((float)Math.PI));
36594 timeLeft = 2;
36595 Vector2 vector3 = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f;
36596 if (player.direction != 1)
36597 {
36598 vector3.X = (float)player.bodyFrame.Width - vector3.X;
36599 }
36600 vector3 -= (player.bodyFrame.Size() - new Vector2(player.width, 42f)) / 2f;
36601 base.Center = (player.position + vector3 + zero - velocity).Floor();
36602 player.ChangeDir(direction);
36603 player.heldProj = whoAmI;
36604 player.SetDummyItemTime(2);
36605 }
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)
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
static List< Tuple< int, float > > _medusaHeadTargetList
static NPCDistanceByIndexComparator _medusaTargetComparer
IEntitySource GetProjectileSource_FromThis()
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)

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), Terraria.Lighting.AddLight(), Terraria.Player.bodyFrame, Terraria.Collision.CanHitLine(), Terraria.Entity.Center, Terraria.Player.ChangeDir(), Terraria.Player.channel, Terraria.Player.CheckMana(), System.Collections.Generic.Dictionary< TKey, TValue >.Clear(), Terraria.Player.dead, Terraria.Entity.direction, Terraria.Player.gravDir, Terraria.Player.inventory, Terraria.Item.mana, Terraria.Main.mouseX, Terraria.Main.mouseY, Terraria.Main.myPlayer, Terraria.Main.npc, Terraria.Main.OffsetsPlayerOnhand, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.projectile, Terraria.Main.rand, Terraria.Main.screenHeight, Terraria.Player.selectedItem, Terraria.Player.SetDummyItemTime(), System.Math.Sign(), System.type, Microsoft.Xna.Framework.Vector2.UnitX, Microsoft.Xna.Framework.Rectangle.Width, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.