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

◆ SetTargetTrackingValues()

void Terraria.NPC.SetTargetTrackingValues ( bool faceTarget,
float realDist,
int tankTarget )
inlineprivate

Definition at line 83309 of file NPC.cs.

83310 {
83311 //IL_0044: Unknown result type (might be due to invalid IL or missing references)
83312 //IL_0049: Unknown result type (might be due to invalid IL or missing references)
83313 //IL_0142: Unknown result type (might be due to invalid IL or missing references)
83314 //IL_0147: Unknown result type (might be due to invalid IL or missing references)
83315 if (tankTarget >= 0)
83316 {
83317 targetRect = new Rectangle((int)Main.projectile[tankTarget].position.X, (int)Main.projectile[tankTarget].position.Y, Main.projectile[tankTarget].width, Main.projectile[tankTarget].height);
83318 direction = 1;
83319 if ((float)(targetRect.X + targetRect.Width / 2) < position.X + (float)(width / 2))
83320 {
83321 direction = -1;
83322 }
83323 directionY = 1;
83324 if ((float)(targetRect.Y + targetRect.Height / 2) < position.Y + (float)(height / 2))
83325 {
83326 directionY = -1;
83327 }
83328 }
83329 else
83330 {
83331 if (target < 0 || target >= 255)
83332 {
83333 target = 0;
83334 }
83335 targetRect = new Rectangle((int)Main.player[target].position.X, (int)Main.player[target].position.Y, Main.player[target].width, Main.player[target].height);
83336 if (Main.player[target].dead)
83337 {
83338 faceTarget = false;
83339 }
83340 if (Main.player[target].npcTypeNoAggro[type] && direction != 0)
83341 {
83342 faceTarget = false;
83343 }
83344 if (faceTarget)
83345 {
83346 _ = Main.player[target].aggro;
83347 _ = (Main.player[target].height + Main.player[target].width + height + width) / 4;
83348 bool flag = oldTarget >= 0 && oldTarget <= 254;
83349 bool num = Main.player[target].itemAnimation == 0 && Main.player[target].aggro < 0;
83350 bool flag2 = !boss;
83351 if (!(num && flag && flag2))
83352 {
83353 direction = 1;
83354 if ((float)(targetRect.X + targetRect.Width / 2) < position.X + (float)(width / 2))
83355 {
83356 direction = -1;
83357 }
83358 directionY = 1;
83359 if ((float)(targetRect.Y + targetRect.Height / 2) < position.Y + (float)(height / 2))
83360 {
83361 directionY = -1;
83362 }
83363 }
83364 }
83365 }
83366 if (confused)
83367 {
83368 direction *= -1;
83369 }
83371 {
83372 netUpdate = true;
83373 }
83374 }
int oldDirection
Definition Entity.cs:39
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
bool boss
Set to true if the NPC is a boss. Prevents off-screen despawn. Bosses also need [AutoloadBossHead] an...
Definition NPC.cs:1141
int oldTarget
Definition NPC.cs:1114
bool confused
Definition NPC.cs:692
int oldDirectionY
Definition NPC.cs:1112
Rectangle targetRect
Definition NPC.cs:1079
bool collideX
Definition NPC.cs:1134
bool collideY
Definition NPC.cs:1136
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 directionY
Definition NPC.cs:983
bool netUpdate
Definition NPC.cs:1130
int target
Definition NPC.cs:1019

References Terraria.NPC.boss, Terraria.NPC.collideX, Terraria.NPC.collideY, Terraria.NPC.confused, Terraria.Entity.direction, Terraria.NPC.directionY, Terraria.Entity.height, Terraria.NPC.netUpdate, Terraria.Entity.oldDirection, Terraria.NPC.oldDirectionY, Terraria.NPC.oldTarget, Terraria.Main.player, Terraria.Entity.position, Terraria.Main.projectile, Terraria.NPC.target, Terraria.NPC.targetRect, Terraria.NPC.type, and Terraria.Entity.width.

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

+ Here is the caller graph for this function: