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

◆ UpdateNPC_Inner()

void Terraria.NPC.UpdateNPC_Inner ( int i)
inlineprivate

Definition at line 107078 of file NPC.cs.

107079 {
107080 //IL_000a: Unknown result type (might be due to invalid IL or missing references)
107081 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
107082 //IL_0019: Unknown result type (might be due to invalid IL or missing references)
107083 //IL_002d: Unknown result type (might be due to invalid IL or missing references)
107084 //IL_0037: Unknown result type (might be due to invalid IL or missing references)
107085 //IL_003c: Unknown result type (might be due to invalid IL or missing references)
107086 //IL_006a: Unknown result type (might be due to invalid IL or missing references)
107087 //IL_0079: Unknown result type (might be due to invalid IL or missing references)
107088 //IL_0050: Unknown result type (might be due to invalid IL or missing references)
107089 //IL_005a: Unknown result type (might be due to invalid IL or missing references)
107090 //IL_005f: Unknown result type (might be due to invalid IL or missing references)
107091 //IL_0098: Unknown result type (might be due to invalid IL or missing references)
107092 //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
107093 //IL_00a7: Unknown result type (might be due to invalid IL or missing references)
107094 //IL_013f: Unknown result type (might be due to invalid IL or missing references)
107095 //IL_0144: Unknown result type (might be due to invalid IL or missing references)
107096 //IL_014d: Unknown result type (might be due to invalid IL or missing references)
107097 //IL_0150: Unknown result type (might be due to invalid IL or missing references)
107098 //IL_0155: Unknown result type (might be due to invalid IL or missing references)
107099 //IL_0159: Unknown result type (might be due to invalid IL or missing references)
107100 //IL_015e: Unknown result type (might be due to invalid IL or missing references)
107101 //IL_0160: Unknown result type (might be due to invalid IL or missing references)
107102 //IL_0165: Unknown result type (might be due to invalid IL or missing references)
107103 //IL_011a: Unknown result type (might be due to invalid IL or missing references)
107104 //IL_0120: Unknown result type (might be due to invalid IL or missing references)
107105 //IL_0125: Unknown result type (might be due to invalid IL or missing references)
107106 //IL_017a: Unknown result type (might be due to invalid IL or missing references)
107107 //IL_0184: Unknown result type (might be due to invalid IL or missing references)
107108 //IL_0189: Unknown result type (might be due to invalid IL or missing references)
107109 //IL_00d7: Unknown result type (might be due to invalid IL or missing references)
107110 //IL_00e1: Unknown result type (might be due to invalid IL or missing references)
107111 //IL_00e6: Unknown result type (might be due to invalid IL or missing references)
107112 //IL_0197: Unknown result type (might be due to invalid IL or missing references)
107113 //IL_01c8: Unknown result type (might be due to invalid IL or missing references)
107114 //IL_01db: Unknown result type (might be due to invalid IL or missing references)
107115 //IL_01e5: Unknown result type (might be due to invalid IL or missing references)
107116 //IL_01ea: Unknown result type (might be due to invalid IL or missing references)
107117 //IL_0200: Unknown result type (might be due to invalid IL or missing references)
107118 //IL_020a: Unknown result type (might be due to invalid IL or missing references)
107119 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
107120 //IL_0527: Unknown result type (might be due to invalid IL or missing references)
107121 //IL_052d: Unknown result type (might be due to invalid IL or missing references)
107122 //IL_0532: Unknown result type (might be due to invalid IL or missing references)
107123 //IL_0537: Unknown result type (might be due to invalid IL or missing references)
107124 //IL_053d: Unknown result type (might be due to invalid IL or missing references)
107125 //IL_0561: Unknown result type (might be due to invalid IL or missing references)
107126 //IL_0567: Unknown result type (might be due to invalid IL or missing references)
107127 //IL_057e: Unknown result type (might be due to invalid IL or missing references)
107128 //IL_0588: Unknown result type (might be due to invalid IL or missing references)
107129 //IL_058d: Unknown result type (might be due to invalid IL or missing references)
107130 //IL_0594: Unknown result type (might be due to invalid IL or missing references)
107131 //IL_059a: Unknown result type (might be due to invalid IL or missing references)
107132 //IL_059f: Unknown result type (might be due to invalid IL or missing references)
107133 //IL_05a4: Unknown result type (might be due to invalid IL or missing references)
107134 //IL_078a: Unknown result type (might be due to invalid IL or missing references)
107135 //IL_078f: Unknown result type (might be due to invalid IL or missing references)
107136 //IL_07a2: Unknown result type (might be due to invalid IL or missing references)
107137 //IL_07a8: Unknown result type (might be due to invalid IL or missing references)
107138 //IL_07ad: Unknown result type (might be due to invalid IL or missing references)
107139 //IL_07b2: Unknown result type (might be due to invalid IL or missing references)
107140 //IL_07d0: Unknown result type (might be due to invalid IL or missing references)
107141 //IL_0834: Unknown result type (might be due to invalid IL or missing references)
107142 //IL_0846: Unknown result type (might be due to invalid IL or missing references)
107143 if (offSetDelayTime > 0)
107144 {
107145 netOffset *= 0f;
107146 }
107147 else if (Main.netMode == 2)
107148 {
107149 netOffset *= 0f;
107150 }
107151 else if (Main.multiplayerNPCSmoothingRange <= 0)
107152 {
107153 netOffset *= 0f;
107154 }
107155 else if (netOffset != new Vector2(0f, 0f))
107156 {
107158 {
107159 netOffset *= 0f;
107160 }
107162 {
107163 netOffset *= 0f;
107164 }
107165 else
107166 {
107167 float num = 2f;
107168 float num4 = Main.multiplayerNPCSmoothingRange;
107169 float num5 = ((Vector2)(ref netOffset)).Length();
107170 if (num5 > num4)
107171 {
107172 ((Vector2)(ref netOffset)).Normalize();
107173 netOffset *= num4;
107174 num5 = ((Vector2)(ref netOffset)).Length();
107175 }
107176 num += num5 / num4 * num;
107177 Vector2 vector = netOffset;
107178 ((Vector2)(ref vector)).Normalize();
107179 vector *= num;
107180 netOffset -= vector;
107181 if (((Vector2)(ref netOffset)).Length() < num)
107182 {
107183 netOffset *= 0f;
107184 }
107185 if (townNPC)
107186 {
107187 if (Vector2.Distance(position, new Vector2((float)(homeTileX * 16 + 8 - width / 2), (float)(homeTileY * 16 - height) - 0.1f)) < 1f)
107188 {
107189 netOffset *= 0f;
107190 }
107191 if (ai[0] == 25f)
107192 {
107193 netOffset *= 0f;
107194 }
107195 }
107196 }
107197 }
107199 if (type == 368)
107200 {
107201 travelNPC = true;
107202 }
107203 if (Main.netMode != 2)
107204 {
107206 }
107210 if (aiStyle == 7 && position.Y > Main.bottomWorld - 640f + (float)height && Main.netMode != 1 && !Main.xMas)
107211 {
107212 StrikeNPCNoInteraction(9999, 0f, 0);
107213 if (Main.netMode == 2)
107214 {
107215 NetMessage.SendData(28, -1, -1, null, whoAmI, 9999f);
107216 }
107217 }
107218 if (Main.netMode == 1)
107219 {
107220 int num6 = (int)(position.X + (float)(width / 2)) / 16;
107221 int num7 = (int)(position.Y + (float)(height / 2)) / 16;
107222 if (!Main.sectionManager.TilesLoaded(num6 - 3, num7 - 3, num6 + 3, num7 + 3))
107223 {
107224 return;
107225 }
107226 }
107228 NPCLoader.ResetEffects(this);
107236 if (soundDelay > 0)
107237 {
107238 soundDelay--;
107239 }
107240 if (life <= 0)
107241 {
107242 active = false;
107244 netUpdate = false;
107245 justHit = false;
107246 return;
107247 }
107248 oldTarget = target;
107251 float num8 = 1f + Math.Abs(velocity.X) / 3f;
107252 if (gfxOffY > 0f)
107253 {
107254 gfxOffY -= num8 * stepSpeed;
107255 if (gfxOffY < 0f)
107256 {
107257 gfxOffY = 0f;
107258 }
107259 }
107260 else if (gfxOffY < 0f)
107261 {
107262 gfxOffY += num8 * stepSpeed;
107263 if (gfxOffY > 0f)
107264 {
107265 gfxOffY = 0f;
107266 }
107267 }
107268 if (gfxOffY > 16f)
107269 {
107270 gfxOffY = 16f;
107271 }
107272 if (gfxOffY < -16f)
107273 {
107274 gfxOffY = -16f;
107275 }
107277 IdleSounds();
107278 AI();
107280 if (Main.netMode != 2 && extraValue > 0)
107281 {
107282 int num9 = 244;
107283 float num10 = 30f;
107284 if (extraValue >= 1000000)
107285 {
107286 num9 = 247;
107287 num10 *= 0.25f;
107288 }
107289 else if (extraValue >= 10000)
107290 {
107291 num9 = 246;
107292 num10 *= 0.5f;
107293 }
107294 else if (extraValue >= 100)
107295 {
107296 num9 = 245;
107297 num10 *= 0.75f;
107298 }
107299 if (Main.rand.Next((int)num10) == 0)
107300 {
107301 position += netOffset;
107302 int num11 = Dust.NewDust(position, width, height, num9, 0f, 0f, 254, default(Color), 0.25f);
107303 Dust obj = Main.dust[num11];
107304 obj.velocity *= 0.1f;
107305 position -= netOffset;
107306 }
107307 }
107308 for (int j = 0; j < 256; j++)
107309 {
107310 if (immune[j] > 0)
107311 {
107312 immune[j]--;
107313 }
107314 }
107315 if (!noGravity && !noTileCollide)
107316 {
107317 int num2 = (int)(position.X + (float)(width / 2)) / 16;
107318 int num3 = (int)(position.Y + (float)(height / 2)) / 16;
107319 if (WorldGen.InWorld(num2, num3) && Main.tile[num2, num3] == null)
107320 {
107321 gravity = 0f;
107322 velocity.X = 0f;
107323 velocity.Y = 0f;
107324 }
107325 }
107326 if (!noGravity)
107327 {
107328 velocity.Y += gravity;
107329 if (velocity.Y > maxFallSpeed)
107330 {
107331 velocity.Y = maxFallSpeed;
107332 }
107333 }
107334 if ((double)velocity.X < 0.005 && (double)velocity.X > -0.005)
107335 {
107336 velocity.X = 0f;
107337 }
107338 if (Main.netMode != 1 && type != 37 && (friendly || NPCID.Sets.TakesDamageFromHostilesWithoutBeingFriendly[type]))
107339 {
107340 if (townNPC)
107341 {
107342 CheckDrowning();
107343 }
107344 CheckLifeRegen();
107346 }
107347 if (Main.netMode != 1 && (npcsFoundForCheckActive[210] || npcsFoundForCheckActive[211]) && !NPCID.Sets.HurtingBees[type])
107348 {
107350 }
107351 if (!noTileCollide)
107352 {
107353 UpdateCollision();
107354 }
107355 else
107356 {
107359 position += velocity;
107360 if (onFire && boss && Main.netMode != 1 && Collision.WetCollision(position, width, height))
107361 {
107362 for (int k = 0; k < maxBuffs; k++)
107363 {
107364 if (buffType[k] == 24)
107365 {
107366 DelBuff(k);
107367 }
107368 }
107369 }
107370 }
107371 if (Main.netMode != 1 && !noTileCollide && lifeMax > 1 && Collision.SwitchTiles(position, width, height, oldPosition, 2) && (type == 46 || type == 148 || type == 149 || type == 303 || type == 361 || type == 362 || type == 364 || type == 366 || type == 367 || (type >= 442 && type <= 448) || type == 602 || type == 608 || type == 614 || type == 687))
107372 {
107373 ai[0] = 1f;
107374 ai[1] = 400f;
107375 ai[2] = 0f;
107376 }
107377 FindFrame();
107380 CheckActive();
107381 netUpdate = false;
107382 justHit = false;
107383 }
Vector2 oldPosition
Definition Entity.cs:35
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
int oldDirection
Definition Entity.cs:39
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
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
Definition Entity.cs:21
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static bool[] AllNPCs
An array of length P:Terraria.ModLoader.NPCLoader.NPCCount with only true entries....
Definition NPCID.cs:325
static bool[] TakesDamageFromHostilesWithoutBeingFriendly
If true for a given NPC type (F:Terraria.NPC.type), then that NPC can take damage from hostile NPCs w...
Definition NPCID.cs:319
static bool[] NoMultiplayerSmoothingByType
If true for a given NPC type (F:Terraria.NPC.type), then that NPC will not smooth its visual position...
Definition NPCID.cs:387
static bool[] NoMultiplayerSmoothingByAI
If true for a given T:Terraria.ID.NPCAIStyleID (F:Terraria.NPC.aiStyle), then that AI style will not ...
Definition NPCID.cs:394
static bool[] HurtingBees
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is a bee that will hurt other non-b...
Definition NPCID.cs:331
static void ResetEffects(NPC npc)
Definition NPCLoader.cs:512
This serves as the central class from which NPC-related functions are carried out....
Definition NPCLoader.cs:26
bool boss
Set to true if the NPC is a boss. Prevents off-screen despawn. Bosses also need [AutoloadBossHead] an...
Definition NPC.cs:1141
Vector2 netOffset
Definition NPC.cs:502
void UpdateNPC_CritterSounds()
Definition NPC.cs:109285
int[] immune
This determines if an NPC can be hit by a item or projectile owned by a particular player (it is an a...
Definition NPC.cs:981
void FindFrame()
Definition NPC.cs:72151
void UpdateNPC_BuffApplyDOTs()
Definition NPC.cs:108598
void CheckDrowning()
Definition NPC.cs:112169
void UpdateNPC_BuffSetFlags(bool lowerBuffTime=true)
Definition NPC.cs:109046
int oldTarget
Definition NPC.cs:1114
float maxFallSpeed
The current fall speed cap in velocity applied every frame. Multiply F:Terraria....
Definition NPC.cs:1636
static readonly int maxBuffs
Definition NPC.cs:647
int lifeMax
The maximum life of this NPC.
Definition NPC.cs:1077
float gfxOffY
An offset from the actual position of the npc that will be added to the draw position....
Definition NPC.cs:549
int aiStyle
Selects which vanilla code to use for the AI method. Vanilla NPC AI styles are enumerated in the T:Te...
Definition NPC.cs:1013
void UpdateNPC_BuffApplyVFX()
Definition NPC.cs:108008
float gravity
The current change in velocity due to gravity applied every frame. Multiply F:Terraria....
Definition NPC.cs:1619
static bool travelNPC
Definition NPC.cs:1176
bool noGravity
If true, the npc will not be affected by gravity. Demon Eyes and other floating npc use this....
Definition NPC.cs:1122
void UpdateNPC_CastLights()
Definition NPC.cs:109390
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
Definition NPC.cs:997
int oldDirectionY
Definition NPC.cs:1112
int extraValue
Definition NPC.cs:1158
void UpdateNPC_BuffFlagsReset()
Definition NPC.cs:109181
int homeTileX
Definition NPC.cs:1180
void UpdateNetworkCode(int i)
Definition NPC.cs:107419
bool friendly
Indicates that an NPC is friendly to players. If true, a player won't damage the NPC and the NPC won'...
Definition NPC.cs:1197
float stepSpeed
Has nothing to do with the speed that this NPC travels, that is dictated by AI code adjusting F:Terra...
Definition NPC.cs:554
void CheckActive()
Definition NPC.cs:83487
void UpdateNPC_UpdateTrails()
Definition NPC.cs:107578
bool onFire
Definition NPC.cs:664
void TryPortalJumping()
Definition NPC.cs:112227
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
void DelBuff(int buffIndex)
Removes the buff at the provided index and shuffles the remaining buff indexes down to fill the gap....
Definition NPC.cs:106775
void SubAI_HandleTemporaryCatchableNPCPlayerInvulnerability()
Definition NPC.cs:107385
void IdleSounds()
Definition NPC.cs:106855
bool noTileCollide
If true, the npc does not collide with tiles, making the npc pass through tiles freely....
Definition NPC.cs:1128
static int offSetDelayTime
Definition NPC.cs:1274
void UpdateAltTexture()
Definition NPC.cs:106990
bool justHit
Definition NPC.cs:1015
void UpdateCollision()
Definition NPC.cs:109619
void CheckLifeRegen()
Definition NPC.cs:109586
void TrySyncingUniqueTownNPCData(int npcIndex)
Definition NPC.cs:107410
void GetHurtByOtherNPCs(bool[] acceptableNPCIDs)
Definition NPC.cs:109500
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
Definition NPC.cs:1072
static bool[] npcsFoundForCheckActive
Definition NPC.cs:966
int soundDelay
Definition NPC.cs:974
void UpdateNPC_BloodMoonTransformations()
Definition NPC.cs:108992
void UpdateNPC_BuffClearExpiredBuffs()
Definition NPC.cs:108973
void UpdateNPC_SoulDrainDebuff()
Definition NPC.cs:107819
int[] buffType
Definition NPC.cs:649
int directionY
Definition NPC.cs:983
bool netUpdate
Definition NPC.cs:1130
int StrikeNPCNoInteraction(int Damage, float knockBack, int hitDirection)
Definition NPC.cs:91674
void UpdateNPC_UpdateGravity()
Updates P:Terraria.NPC.maxFallSpeed and P:Terraria.NPC.gravity in line with vanilla behavior and rese...
Definition NPC.cs:107733
int target
Definition NPC.cs:1019
bool townNPC
Definition NPC.cs:1174
void AI()
Definition NPC.cs:14756
int homeTileY
Definition NPC.cs:1182
void UpdateNPC_TeleportVisuals()
Definition NPC.cs:109215

References Terraria.ID.NPCID.Sets.AllNPCs, Terraria.Main.bottomWorld, Terraria.Main.dust, Terraria.ID.NPCID.Sets.HurtingBees, Terraria.WorldGen.InWorld(), Terraria.Main.multiplayerNPCSmoothingRange, Terraria.Main.netMode, Terraria.Dust.NewDust(), Terraria.ID.NPCID.Sets.NoMultiplayerSmoothingByAI, Terraria.ID.NPCID.Sets.NoMultiplayerSmoothingByType, Terraria.ModLoader.NPCLoader.NPCCount, Terraria.Main.rand, Terraria.ModLoader.NPCLoader.ResetEffects(), Terraria.Main.sectionManager, Terraria.NetMessage.SendData(), Terraria.Collision.SwitchTiles(), Terraria.ID.NPCID.Sets.TakesDamageFromHostilesWithoutBeingFriendly, Terraria.Main.tile, Terraria.Collision.WetCollision(), and Terraria.Main.xMas.

+ Here is the call graph for this function: