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

◆ AI_047_MagnetSphere_TryAttacking()

void Terraria.Projectile.AI_047_MagnetSphere_TryAttacking ( )
inlineprivate

Definition at line 42516 of file Projectile.cs.

42517 {
42518 //IL_00c5: Unknown result type (might be due to invalid IL or missing references)
42519 //IL_00d4: Unknown result type (might be due to invalid IL or missing references)
42520 //IL_01e8: Unknown result type (might be due to invalid IL or missing references)
42521 //IL_01eb: Unknown result type (might be due to invalid IL or missing references)
42522 //IL_01f5: Unknown result type (might be due to invalid IL or missing references)
42523 //IL_01fa: Unknown result type (might be due to invalid IL or missing references)
42524 //IL_01ff: Unknown result type (might be due to invalid IL or missing references)
42525 //IL_0203: Unknown result type (might be due to invalid IL or missing references)
42526 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
42527 //IL_024b: Unknown result type (might be due to invalid IL or missing references)
42528 //IL_0252: Unknown result type (might be due to invalid IL or missing references)
42529 int[] array = new int[20];
42530 int num = 0;
42531 float num3 = 300f;
42532 bool flag = false;
42533 float num4 = 0f;
42534 float num5 = 0f;
42535 for (int i = 0; i < 200; i++)
42536 {
42537 if (!Main.npc[i].CanBeChasedBy(this))
42538 {
42539 continue;
42540 }
42541 float num6 = Main.npc[i].position.X + (float)(Main.npc[i].width / 2);
42542 float num7 = Main.npc[i].position.Y + (float)(Main.npc[i].height / 2);
42543 if (Math.Abs(position.X + (float)(width / 2) - num6) + Math.Abs(position.Y + (float)(height / 2) - num7) < num3 && Collision.CanHit(base.Center, 1, 1, Main.npc[i].Center, 1, 1))
42544 {
42545 if (num < 20)
42546 {
42547 array[num] = i;
42548 num++;
42549 num4 = num6;
42550 num5 = num7;
42551 }
42552 flag = true;
42553 }
42554 }
42555 if (timeLeft < 30)
42556 {
42557 flag = false;
42558 }
42559 if (flag)
42560 {
42561 int num8 = Main.rand.Next(num);
42562 num8 = array[num8];
42563 num4 = Main.npc[num8].position.X + (float)(Main.npc[num8].width / 2);
42564 num5 = Main.npc[num8].position.Y + (float)(Main.npc[num8].height / 2);
42565 localAI[0] += 1f;
42566 if (localAI[0] > 8f)
42567 {
42568 localAI[0] = 0f;
42569 Vector2 vector = default(Vector2);
42570 ((Vector2)(ref vector))._002Ector(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
42571 vector += velocity * 4f;
42572 float num9 = num4 - vector.X;
42573 float num10 = num5 - vector.Y;
42574 float num2 = (float)Math.Sqrt(num9 * num9 + num10 * num10);
42575 num2 = 6f / num2;
42576 num9 *= num2;
42577 num10 *= num2;
42579 }
42580 }
42581 }
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
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...
IEntitySource GetProjectileSource_FromThis()
float[] localAI
Acts like F:Terraria.Projectile.ai, but does not sync to the server. Many vanilla T:Terraria....
float knockBack
This will always be set in Projectile.NewProjectile based on the weapons knockback and player stat mo...
int timeLeft
Time in ticks before this projectile will naturally despawn. Each update timeLeft is decreased by 1...
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.Collision.CanHit(), Terraria.Main.npc, and Terraria.Main.rand.

+ Here is the call graph for this function: