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

◆ TryTrackingTarget()

void Terraria.NPC.TryTrackingTarget ( ref float distance,
ref float realDist,
ref bool t,
ref int tankTarget,
int j )
inlineprivate

Definition at line 83279 of file NPC.cs.

83280 {
83281 //IL_021c: Unknown result type (might be due to invalid IL or missing references)
83282 //IL_022a: Unknown result type (might be due to invalid IL or missing references)
83283 float num = Math.Abs(Main.player[j].position.X + (float)(Main.player[j].width / 2) - position.X + (float)(width / 2)) + Math.Abs(Main.player[j].position.Y + (float)(Main.player[j].height / 2) - position.Y + (float)(height / 2));
83284 num -= (float)Main.player[j].aggro;
83285 if (Main.player[j].npcTypeNoAggro[type] && direction != 0)
83286 {
83287 num += 1000f;
83288 }
83289 if (!t || num < distance)
83290 {
83291 t = true;
83292 tankTarget = -1;
83293 realDist = Math.Abs(Main.player[j].position.X + (float)(Main.player[j].width / 2) - position.X + (float)(width / 2)) + Math.Abs(Main.player[j].position.Y + (float)(Main.player[j].height / 2) - position.Y + (float)(height / 2));
83294 distance = num;
83295 target = j;
83296 }
83297 if (Main.player[j].tankPet >= 0 && !Main.player[j].npcTypeNoAggro[type])
83298 {
83299 int tankPet = Main.player[j].tankPet;
83300 float num2 = Math.Abs(Main.projectile[tankPet].position.X + (float)(Main.projectile[tankPet].width / 2) - position.X + (float)(width / 2)) + Math.Abs(Main.projectile[tankPet].position.Y + (float)(Main.projectile[tankPet].height / 2) - position.Y + (float)(height / 2));
83301 num2 -= 200f;
83302 if (num2 < distance && num2 < 200f && Collision.CanHit(base.Center, 1, 1, Main.projectile[tankPet].Center, 1, 1))
83303 {
83304 tankTarget = tankPet;
83305 }
83306 }
83307 }
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 type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990
int target
Definition NPC.cs:1019

References Terraria.Collision.CanHit(), Terraria.Entity.direction, Terraria.Entity.height, Terraria.Main.player, Terraria.Entity.position, Terraria.Main.projectile, Terraria.NPC.target, Terraria.NPC.type, and Terraria.Entity.width.

Referenced by Terraria.NPC.TargetClosest(), and Terraria.NPC.TargetClosest_WOF().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: