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

◆ AI_100_Medusa()

void Terraria.Projectile.AI_100_Medusa ( )
inlineprivate

Definition at line 46478 of file Projectile.cs.

46479 {
46480 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
46481 //IL_0012: Unknown result type (might be due to invalid IL or missing references)
46482 //IL_069a: Unknown result type (might be due to invalid IL or missing references)
46483 //IL_06a4: Unknown result type (might be due to invalid IL or missing references)
46484 //IL_06a9: Unknown result type (might be due to invalid IL or missing references)
46485 //IL_06cd: Unknown result type (might be due to invalid IL or missing references)
46486 //IL_06cf: Unknown result type (might be due to invalid IL or missing references)
46487 //IL_06d4: Unknown result type (might be due to invalid IL or missing references)
46488 //IL_06e5: Unknown result type (might be due to invalid IL or missing references)
46489 //IL_06ea: Unknown result type (might be due to invalid IL or missing references)
46490 //IL_06f4: Unknown result type (might be due to invalid IL or missing references)
46491 //IL_06f9: Unknown result type (might be due to invalid IL or missing references)
46492 //IL_06fe: Unknown result type (might be due to invalid IL or missing references)
46493 //IL_0701: Unknown result type (might be due to invalid IL or missing references)
46494 //IL_0706: Unknown result type (might be due to invalid IL or missing references)
46495 //IL_0707: Unknown result type (might be due to invalid IL or missing references)
46496 //IL_070c: Unknown result type (might be due to invalid IL or missing references)
46497 //IL_070d: Unknown result type (might be due to invalid IL or missing references)
46498 //IL_0713: Unknown result type (might be due to invalid IL or missing references)
46499 //IL_0718: Unknown result type (might be due to invalid IL or missing references)
46500 //IL_071d: Unknown result type (might be due to invalid IL or missing references)
46501 //IL_06c1: Unknown result type (might be due to invalid IL or missing references)
46502 //IL_013f: Unknown result type (might be due to invalid IL or missing references)
46503 //IL_0144: Unknown result type (might be due to invalid IL or missing references)
46504 //IL_0146: Unknown result type (might be due to invalid IL or missing references)
46505 //IL_0157: Unknown result type (might be due to invalid IL or missing references)
46506 //IL_015c: Unknown result type (might be due to invalid IL or missing references)
46507 //IL_0161: Unknown result type (might be due to invalid IL or missing references)
46508 //IL_0163: Unknown result type (might be due to invalid IL or missing references)
46509 //IL_0168: Unknown result type (might be due to invalid IL or missing references)
46510 //IL_019f: Unknown result type (might be due to invalid IL or missing references)
46511 //IL_0190: Unknown result type (might be due to invalid IL or missing references)
46512 //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
46513 //IL_01cd: Unknown result type (might be due to invalid IL or missing references)
46514 //IL_01e1: Unknown result type (might be due to invalid IL or missing references)
46515 //IL_01fd: Unknown result type (might be due to invalid IL or missing references)
46516 //IL_01ff: Unknown result type (might be due to invalid IL or missing references)
46517 //IL_063c: Unknown result type (might be due to invalid IL or missing references)
46518 //IL_025a: Unknown result type (might be due to invalid IL or missing references)
46519 //IL_0274: Unknown result type (might be due to invalid IL or missing references)
46520 //IL_0279: Unknown result type (might be due to invalid IL or missing references)
46521 //IL_027e: Unknown result type (might be due to invalid IL or missing references)
46522 //IL_02c9: Unknown result type (might be due to invalid IL or missing references)
46523 //IL_0347: Unknown result type (might be due to invalid IL or missing references)
46524 //IL_034c: Unknown result type (might be due to invalid IL or missing references)
46525 //IL_02e7: Unknown result type (might be due to invalid IL or missing references)
46526 //IL_02fa: Unknown result type (might be due to invalid IL or missing references)
46527 //IL_0374: Unknown result type (might be due to invalid IL or missing references)
46528 //IL_039f: Unknown result type (might be due to invalid IL or missing references)
46529 //IL_03b2: Unknown result type (might be due to invalid IL or missing references)
46530 //IL_0415: Unknown result type (might be due to invalid IL or missing references)
46531 //IL_041a: Unknown result type (might be due to invalid IL or missing references)
46532 //IL_041c: Unknown result type (might be due to invalid IL or missing references)
46533 //IL_0421: Unknown result type (might be due to invalid IL or missing references)
46534 //IL_0425: Unknown result type (might be due to invalid IL or missing references)
46535 //IL_043b: Unknown result type (might be due to invalid IL or missing references)
46536 //IL_0442: Unknown result type (might be due to invalid IL or missing references)
46537 //IL_0449: Unknown result type (might be due to invalid IL or missing references)
46538 //IL_0450: Unknown result type (might be due to invalid IL or missing references)
46539 //IL_048a: Unknown result type (might be due to invalid IL or missing references)
46540 //IL_04c6: Unknown result type (might be due to invalid IL or missing references)
46541 //IL_0521: Unknown result type (might be due to invalid IL or missing references)
46542 //IL_0526: Unknown result type (might be due to invalid IL or missing references)
46543 //IL_058b: Unknown result type (might be due to invalid IL or missing references)
46544 //IL_0599: Unknown result type (might be due to invalid IL or missing references)
46545 //IL_05a8: Unknown result type (might be due to invalid IL or missing references)
46546 //IL_05ad: Unknown result type (might be due to invalid IL or missing references)
46547 //IL_05c8: Unknown result type (might be due to invalid IL or missing references)
46548 //IL_0535: Unknown result type (might be due to invalid IL or missing references)
46549 //IL_0543: Unknown result type (might be due to invalid IL or missing references)
46550 //IL_054d: Unknown result type (might be due to invalid IL or missing references)
46551 //IL_0553: Unknown result type (might be due to invalid IL or missing references)
46552 //IL_0555: Unknown result type (might be due to invalid IL or missing references)
46553 //IL_0564: Unknown result type (might be due to invalid IL or missing references)
46554 //IL_0569: Unknown result type (might be due to invalid IL or missing references)
46555 //IL_0584: Unknown result type (might be due to invalid IL or missing references)
46556 //IL_05cd: Unknown result type (might be due to invalid IL or missing references)
46557 //IL_05d5: Unknown result type (might be due to invalid IL or missing references)
46558 //IL_05dc: Unknown result type (might be due to invalid IL or missing references)
46559 //IL_05e3: Unknown result type (might be due to invalid IL or missing references)
46560 //IL_05ea: Unknown result type (might be due to invalid IL or missing references)
46561 Player player = Main.player[owner];
46562 Vector2 zero = Vector2.Zero;
46563 if (type == 535)
46564 {
46565 zero.X = (float)player.direction * 6f;
46566 zero.Y = player.gravDir * -14f;
46567 bool flag = true;
46568 bool flag2 = ai[0] > 0f;
46569 if (!player.dead)
46570 {
46571 timeLeft = 3;
46572 }
46573 if (ai[0] > 0f)
46574 {
46575 ai[0] -= 1f;
46576 }
46577 if (flag2)
46578 {
46579 if (frame < 8)
46580 {
46581 frame = 8;
46582 }
46583 if (frame >= 12)
46584 {
46585 frame = 8;
46586 }
46587 frameCounter++;
46588 if (++frameCounter >= 5)
46589 {
46590 frameCounter = 0;
46591 if (++frame >= 12)
46592 {
46593 frame = 8;
46594 }
46595 }
46596 }
46597 else if (++frameCounter >= 5)
46598 {
46599 frameCounter = 0;
46600 if (++frame >= 8)
46601 {
46602 frame = 0;
46603 }
46604 }
46605 Vector2 center = player.Center;
46606 Vector2 vector = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY) - center;
46607 if (player.gravDir == -1f)
46608 {
46609 vector.Y = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - center.Y;
46610 }
46611 Vector2 vector2 = default(Vector2);
46612 ((Vector2)(ref vector2))._002Ector((float)Math.Sign((vector.X == 0f) ? ((float)player.direction) : vector.X), 0f);
46613 if (vector2.X != velocity.X || vector2.Y != velocity.Y)
46614 {
46615 netUpdate = true;
46616 }
46617 velocity = vector2;
46618 if (flag2 && soundDelay == 0)
46619 {
46620 SoundEngine.PlaySound(4, (int)base.position.X, (int)base.position.Y, 17);
46621 }
46622 soundDelay = (flag2 ? 4 : 0);
46623 if (Main.myPlayer == owner)
46624 {
46625 Vector2 position = player.Center + new Vector2((float)(player.direction * 4), player.gravDir * 2f);
46626 if (!player.channel)
46627 {
46628 Kill();
46629 return;
46630 }
46631 if (!flag2 || ai[0] % 15f == 0f)
46632 {
46633 bool flag3 = false;
46634 for (int i = 0; i < 200; i++)
46635 {
46636 NPC nPC = Main.npc[i];
46637 if (nPC.active && Distance(nPC.Center) < 320f && nPC.CanBeChasedBy(this) && Collision.CanHitLine(nPC.position, nPC.width, nPC.height, position, 0, 0))
46638 {
46639 flag3 = true;
46640 break;
46641 }
46642 }
46643 if (flag3 && (!flag || player.CheckMana(player.inventory[player.selectedItem], -1, pay: true)))
46644 {
46645 int num = damage;
46646 position = base.Center;
46647 int num2 = 0;
46648 float num3 = 0f;
46649 _medusaHeadTargetList.Clear();
46650 for (int j = 0; j < 200; j++)
46651 {
46652 NPC nPC2 = Main.npc[j];
46653 float num4 = Distance(nPC2.Center);
46654 if (nPC2.active && num4 < 320f && nPC2.CanBeChasedBy(this) && Collision.CanHitLine(nPC2.position, nPC2.width, nPC2.height, position, 0, 0))
46655 {
46656 _medusaHeadTargetList.Add(Tuple.Create(j, num4));
46657 }
46658 }
46660 for (int k = 0; k < _medusaHeadTargetList.Count && k < 3; k++)
46661 {
46663 NPC nPC3 = Main.npc[tuple.Item1];
46664 Vector2 v = nPC3.Center - position;
46665 num3 += v.ToRotation();
46666 num2++;
46667 int num5 = NewProjectile(GetProjectileSource_FromThis(), position.X, position.Y, v.X, v.Y, 536, 0, 0f, owner, whoAmI);
46668 Main.projectile[num5].Center = nPC3.Center;
46669 Main.projectile[num5].damage = num;
46670 Main.projectile[num5].Damage();
46671 Main.projectile[num5].damage = 0;
46672 Main.projectile[num5].Center = position;
46673 ai[0] = 180f;
46674 }
46675 num3 = ((num2 != 0) ? (num3 / (float)num2) : ((player.direction == 1) ? 0f : ((float)Math.PI)));
46676 for (int l = 0; l < 4; l++)
46677 {
46678 Vector2 zero2 = Vector2.Zero;
46679 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)));
46681 }
46682 ai[0] = 60f;
46683 netUpdate = true;
46684 }
46685 }
46686 }
46687 Lighting.AddLight(base.Center, 0.9f, 0.75f, 0.1f);
46688 }
46689 rotation = ((player.gravDir == 1f) ? 0f : ((float)Math.PI));
46691 timeLeft = 2;
46692 Vector2 vector3 = Main.OffsetsPlayerOnhand[player.bodyFrame.Y / 56] * 2f;
46693 if (player.direction != 1)
46694 {
46695 vector3.X = (float)player.bodyFrame.Width - vector3.X;
46696 }
46697 vector3 -= (player.bodyFrame.Size() - new Vector2((float)player.width, 42f)) / 2f;
46698 base.Center = (player.position + vector3 + zero - velocity).Floor();
46699 player.ChangeDir(direction);
46700 player.heldProj = whoAmI;
46701 player.SetDummyItemTime(2);
46702 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
float Distance(Vector2 Other)
Definition Entity.cs:275
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...
int damage
This will always be set in Projectile.NewProjectile based on the weapons damage and player stat modif...
static List< Tuple< int, float > > _medusaHeadTargetList
float[] ai
An array with 3 slots used for any sort of data storage, which is occasionally synced to the server....
bool netUpdate
Set manually to true in M:Terraria.ModLoader.ModProjectile.AI once to make it sync its current F:Terr...
static NPCDistanceByIndexComparator _medusaTargetComparer
IEntitySource GetProjectileSource_FromThis()
int frame
The frame number in the spritesheet that this projectile will be drawn with. Assign in M:Terraria....
int type
The Projectile ID of this projectile. The Projectile ID is a unique number assigned to each Projectil...
int timeLeft
Time in ticks before this projectile will naturally despawn. Each update timeLeft is decreased by 1...
float rotation
Rotation of the projectile. Radians not Degrees. Use T:Microsoft.Xna.Framework.MathHelper if you want...
int frameCounter
Used as a timer to decide when to change F:Terraria.Projectile.frame. Defaults to 0.
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)
This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position and...

References Terraria.Lighting.AddLight(), Terraria.Player.bodyFrame, Terraria.Collision.CanHitLine(), Terraria.Entity.Center, Terraria.Player.ChangeDir(), Terraria.Player.channel, Terraria.Player.CheckMana(), Terraria.Player.dead, Terraria.Entity.direction, Terraria.Player.gravDir, Terraria.Player.inventory, Terraria.Main.mouseX, Terraria.Main.mouseY, Terraria.Main.myPlayer, Terraria.Main.npc, Terraria.Main.OffsetsPlayerOnhand, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.projectile, Terraria.Main.rand, Terraria.Main.screenHeight, Terraria.Player.selectedItem, Terraria.Player.SetDummyItemTime(), and Terraria.Entity.width.

+ Here is the call graph for this function: