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

◆ TargetClosestUpgraded()

void Terraria.NPC.TargetClosestUpgraded ( bool faceTarget = true,
Vector2? checkPosition = null )
inline

Definition at line 83116 of file NPC.cs.

83117 {
83118 //IL_0007: Unknown result type (might be due to invalid IL or missing references)
83119 //IL_000c: Unknown result type (might be due to invalid IL or missing references)
83120 //IL_0018: Unknown result type (might be due to invalid IL or missing references)
83121 //IL_001d: Unknown result type (might be due to invalid IL or missing references)
83122 //IL_0066: Unknown result type (might be due to invalid IL or missing references)
83123 //IL_0069: Unknown result type (might be due to invalid IL or missing references)
83124 //IL_015b: Unknown result type (might be due to invalid IL or missing references)
83125 //IL_015e: Unknown result type (might be due to invalid IL or missing references)
83126 //IL_01b2: Unknown result type (might be due to invalid IL or missing references)
83127 //IL_01b7: Unknown result type (might be due to invalid IL or missing references)
83128 //IL_01c3: Unknown result type (might be due to invalid IL or missing references)
83129 //IL_01cf: Unknown result type (might be due to invalid IL or missing references)
83130 //IL_022b: Unknown result type (might be due to invalid IL or missing references)
83131 //IL_0230: Unknown result type (might be due to invalid IL or missing references)
83132 //IL_023c: Unknown result type (might be due to invalid IL or missing references)
83133 //IL_0248: Unknown result type (might be due to invalid IL or missing references)
83134 //IL_01eb: Unknown result type (might be due to invalid IL or missing references)
83135 //IL_01f7: Unknown result type (might be due to invalid IL or missing references)
83136 //IL_00c1: Unknown result type (might be due to invalid IL or missing references)
83137 //IL_00cf: Unknown result type (might be due to invalid IL or missing references)
83138 //IL_02a0: Unknown result type (might be due to invalid IL or missing references)
83139 //IL_02a5: Unknown result type (might be due to invalid IL or missing references)
83140 //IL_0264: Unknown result type (might be due to invalid IL or missing references)
83141 //IL_0270: Unknown result type (might be due to invalid IL or missing references)
83142 //IL_00f5: Unknown result type (might be due to invalid IL or missing references)
83143 //IL_0109: Unknown result type (might be due to invalid IL or missing references)
83144 //IL_0346: Unknown result type (might be due to invalid IL or missing references)
83145 //IL_0352: Unknown result type (might be due to invalid IL or missing references)
83146 //IL_036e: Unknown result type (might be due to invalid IL or missing references)
83147 //IL_037a: Unknown result type (might be due to invalid IL or missing references)
83148 int num = -1;
83149 int num2 = -1;
83150 int num3 = -1;
83151 Vector2 center = base.Center;
83152 if (checkPosition.HasValue)
83153 {
83154 center = checkPosition.Value;
83155 }
83156 bool flag = direction == 0;
83157 float num4 = 9999999f;
83158 for (int i = 0; i < 255; i++)
83159 {
83160 Player player = Main.player[i];
83161 if (!player.active || player.dead || player.ghost)
83162 {
83163 continue;
83164 }
83165 float num5 = Vector2.Distance(center, player.Center);
83166 num5 -= (float)player.aggro;
83167 bool flag2 = player.npcTypeNoAggro[type];
83168 if (flag2 && !flag)
83169 {
83170 num5 += 1000f;
83171 }
83172 if (num5 < num4)
83173 {
83174 num = i;
83175 num2 = -1;
83176 num4 = num5;
83177 }
83178 if (player.tankPet >= 0 && !flag2)
83179 {
83180 num5 = Vector2.Distance(center, Main.projectile[player.tankPet].Center);
83181 num5 -= 200f;
83182 if (num5 < num4 && num5 < 200f && Collision.CanHit(base.Center, 0, 0, Main.projectile[player.tankPet].Center, 0, 0))
83183 {
83184 num2 = player.tankPet;
83185 num4 = num5;
83186 }
83187 }
83188 }
83189 for (int j = 0; j < 200; j++)
83190 {
83191 NPC nPC = Main.npc[j];
83192 if (nPC.active && nPC.type == 548)
83193 {
83194 float num6 = Vector2.Distance(center, nPC.Center);
83195 if (num4 > num6)
83196 {
83197 num3 = j;
83198 num = -1;
83199 num2 = -1;
83200 num4 = num6;
83201 }
83202 }
83203 }
83204 if (num4 == 9999999f)
83205 {
83206 return;
83207 }
83208 if (num3 >= 0)
83209 {
83210 target = Main.npc[num3].WhoAmIToTargettingIndex;
83211 targetRect = Main.npc[num3].Hitbox;
83212 direction = ((!((float)((Rectangle)(ref targetRect)).Center.X < base.Center.X)) ? 1 : (-1));
83213 directionY = ((!((float)((Rectangle)(ref targetRect)).Center.Y < base.Center.Y)) ? 1 : (-1));
83214 return;
83215 }
83216 if (num2 >= 0)
83217 {
83218 target = Main.projectile[num2].owner;
83219 targetRect = Main.projectile[num2].Hitbox;
83220 direction = ((!((float)((Rectangle)(ref targetRect)).Center.X < base.Center.X)) ? 1 : (-1));
83221 directionY = ((!((float)((Rectangle)(ref targetRect)).Center.Y < base.Center.Y)) ? 1 : (-1));
83222 return;
83223 }
83224 if (num < 0 || num >= 255)
83225 {
83226 num = 0;
83227 }
83228 Player player2 = Main.player[num];
83229 targetRect = player2.Hitbox;
83230 target = num;
83231 if (player2.dead || (player2.npcTypeNoAggro[type] && !flag))
83232 {
83233 faceTarget = false;
83234 }
83235 if (faceTarget)
83236 {
83237 float num7 = (float)(player2.width + player2.height + width + height) / 4f + 800f;
83238 float num8 = num4 - (float)player2.aggro;
83239 if (player2.itemAnimation != 0 || player2.aggro >= 0 || !(num8 > num7) || oldTarget < 0 || oldTarget >= 255)
83240 {
83241 direction = ((!((float)((Rectangle)(ref targetRect)).Center.X < base.Center.X)) ? 1 : (-1));
83242 directionY = ((!((float)((Rectangle)(ref targetRect)).Center.Y < base.Center.Y)) ? 1 : (-1));
83243 }
83244 }
83245 }
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
Rectangle targetRect
Definition NPC.cs:1079
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
int target
Definition NPC.cs:1019

References Terraria.Entity.active, Terraria.Player.aggro, Terraria.Collision.CanHit(), Terraria.Entity.Center, Terraria.Player.dead, Terraria.Entity.direction, Terraria.NPC.directionY, Terraria.Player.ghost, Terraria.Entity.height, Terraria.Main.npc, Terraria.Player.npcTypeNoAggro, Terraria.Main.player, Terraria.Main.projectile, Terraria.Player.tankPet, Terraria.NPC.target, Terraria.NPC.targetRect, Terraria.NPC.type, and Terraria.Entity.width.

+ Here is the call graph for this function: