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

◆ AI_109_DarkMage()

void Terraria.NPC.AI_109_DarkMage ( )
inlineprivate

Definition at line 71045 of file NPC.cs.

71046 {
71047 //IL_0103: Unknown result type (might be due to invalid IL or missing references)
71048 //IL_010d: Unknown result type (might be due to invalid IL or missing references)
71049 //IL_0112: Unknown result type (might be due to invalid IL or missing references)
71050 //IL_0118: Unknown result type (might be due to invalid IL or missing references)
71051 //IL_011e: Unknown result type (might be due to invalid IL or missing references)
71052 //IL_09df: Unknown result type (might be due to invalid IL or missing references)
71053 //IL_09f0: Unknown result type (might be due to invalid IL or missing references)
71054 //IL_0a06: Unknown result type (might be due to invalid IL or missing references)
71055 //IL_0a0d: Unknown result type (might be due to invalid IL or missing references)
71056 //IL_0a12: Unknown result type (might be due to invalid IL or missing references)
71057 //IL_097b: Unknown result type (might be due to invalid IL or missing references)
71058 //IL_0986: Unknown result type (might be due to invalid IL or missing references)
71059 //IL_04d1: Unknown result type (might be due to invalid IL or missing references)
71060 //IL_04e0: Unknown result type (might be due to invalid IL or missing references)
71061 //IL_04e5: Unknown result type (might be due to invalid IL or missing references)
71062 //IL_04ea: Unknown result type (might be due to invalid IL or missing references)
71063 //IL_04ed: Unknown result type (might be due to invalid IL or missing references)
71064 //IL_04fc: Unknown result type (might be due to invalid IL or missing references)
71065 //IL_0501: Unknown result type (might be due to invalid IL or missing references)
71066 //IL_0506: Unknown result type (might be due to invalid IL or missing references)
71067 //IL_01c3: Unknown result type (might be due to invalid IL or missing references)
71068 //IL_0666: Unknown result type (might be due to invalid IL or missing references)
71069 //IL_027a: Unknown result type (might be due to invalid IL or missing references)
71070 //IL_0280: Unknown result type (might be due to invalid IL or missing references)
71071 //IL_0294: Unknown result type (might be due to invalid IL or missing references)
71072 //IL_0299: Unknown result type (might be due to invalid IL or missing references)
71073 //IL_029e: Unknown result type (might be due to invalid IL or missing references)
71074 //IL_02a3: Unknown result type (might be due to invalid IL or missing references)
71075 //IL_02a8: Unknown result type (might be due to invalid IL or missing references)
71076 //IL_02b2: Unknown result type (might be due to invalid IL or missing references)
71077 //IL_02b7: Unknown result type (might be due to invalid IL or missing references)
71078 //IL_02ba: Unknown result type (might be due to invalid IL or missing references)
71079 //IL_0200: Unknown result type (might be due to invalid IL or missing references)
71080 //IL_0214: Unknown result type (might be due to invalid IL or missing references)
71081 //IL_0219: Unknown result type (might be due to invalid IL or missing references)
71082 //IL_021e: Unknown result type (might be due to invalid IL or missing references)
71083 //IL_024a: Unknown result type (might be due to invalid IL or missing references)
71084 //IL_06ca: Unknown result type (might be due to invalid IL or missing references)
71085 //IL_06cf: Unknown result type (might be due to invalid IL or missing references)
71086 //IL_034a: Unknown result type (might be due to invalid IL or missing references)
71087 //IL_0535: Unknown result type (might be due to invalid IL or missing references)
71088 //IL_053a: Unknown result type (might be due to invalid IL or missing references)
71089 //IL_053c: Unknown result type (might be due to invalid IL or missing references)
71090 //IL_0584: Unknown result type (might be due to invalid IL or missing references)
71091 //IL_05b2: Unknown result type (might be due to invalid IL or missing references)
71092 //IL_03a8: Unknown result type (might be due to invalid IL or missing references)
71093 //IL_03c1: Unknown result type (might be due to invalid IL or missing references)
71094 //IL_03cb: Unknown result type (might be due to invalid IL or missing references)
71095 //IL_03d0: Unknown result type (might be due to invalid IL or missing references)
71096 //IL_02e0: Unknown result type (might be due to invalid IL or missing references)
71097 //IL_02f4: Unknown result type (might be due to invalid IL or missing references)
71098 //IL_02f9: Unknown result type (might be due to invalid IL or missing references)
71099 //IL_02fe: Unknown result type (might be due to invalid IL or missing references)
71100 //IL_05c4: Unknown result type (might be due to invalid IL or missing references)
71101 //IL_05cd: Unknown result type (might be due to invalid IL or missing references)
71102 //IL_03fe: Unknown result type (might be due to invalid IL or missing references)
71103 //IL_040a: Unknown result type (might be due to invalid IL or missing references)
71104 //IL_040f: Unknown result type (might be due to invalid IL or missing references)
71105 //IL_0724: Unknown result type (might be due to invalid IL or missing references)
71106 //IL_0751: Unknown result type (might be due to invalid IL or missing references)
71107 //IL_0757: Unknown result type (might be due to invalid IL or missing references)
71108 //IL_077b: Unknown result type (might be due to invalid IL or missing references)
71109 //IL_0788: Unknown result type (might be due to invalid IL or missing references)
71110 //IL_078d: Unknown result type (might be due to invalid IL or missing references)
71111 //IL_0793: Unknown result type (might be due to invalid IL or missing references)
71112 //IL_0799: Unknown result type (might be due to invalid IL or missing references)
71113 //IL_079e: Unknown result type (might be due to invalid IL or missing references)
71114 //IL_07a3: Unknown result type (might be due to invalid IL or missing references)
71115 bool flag = false;
71116 bool flag4 = false;
71117 bool flag5 = true;
71118 bool flag6 = false;
71119 int num = 4;
71120 int num11 = 3;
71121 int num14 = 0;
71122 float num15 = 0.2f;
71123 float num16 = 2f;
71124 float num17 = -0.2f;
71125 float num18 = -4f;
71126 bool flag7 = true;
71127 float num19 = 2f;
71128 float num20 = 0.1f;
71129 float num2 = 1f;
71130 float num3 = 0.04f;
71131 bool flag8 = false;
71132 float num4 = 0.96f;
71133 bool flag9 = true;
71135 if (type == 564 || type == 565)
71136 {
71137 flag7 = false;
71138 rotation = velocity.X * 0.04f;
71139 spriteDirection = ((direction > 0) ? 1 : (-1));
71140 num14 = 2;
71141 num17 = -0.05f;
71142 num18 = -0.4f;
71143 num15 = 0.05f;
71144 num16 = 0.2f;
71145 num2 = 0.5f;
71146 num3 = 0.02f;
71147 num19 = 0.5f;
71148 num20 = 0.1f;
71149 localAI[2] = 0f;
71150 DelegateMethods.v3_1 = new Vector3(0.3f, 0.05f, 0.45f) * 1.5f;
71151 Utils.PlotTileLine(base.Top, base.Bottom, width, DelegateMethods.CastLightOpen);
71152 if (ai[0] < 0f)
71153 {
71154 ai[0] = MathHelper.Min(ai[0] + 1f, 0f);
71155 }
71156 if (ai[0] > 0f)
71157 {
71158 flag9 = false;
71159 flag8 = true;
71160 num4 = 0.9f;
71161 ai[0] -= 1f;
71162 if (ai[0] == 80f && ai[1] == 2f)
71163 {
71165 }
71166 if (ai[1] == 2f && ai[0] == 64f && Main.netMode != 1)
71167 {
71168 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center + new Vector2((float)(direction * 24), -40f), Vector2.Zero, 673, 0, 0f, Main.myPlayer);
71169 DD2Event.RaiseGoblins(this, base.Center);
71170 }
71171 if (ai[1] == 0f && ai[0] == 32f)
71172 {
71173 Vector2 vector = (targetData.Center - (base.Center + new Vector2((float)(direction * 10), -16f))).SafeNormalize(Vector2.UnitY) * 14f;
71174 direction = ((vector.X > 0f) ? 1 : (-1));
71175 if (Main.netMode != 1)
71176 {
71177 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center + new Vector2((float)(direction * 10), -16f), vector, 675, 40, 0f, Main.myPlayer);
71178 }
71179 }
71180 if (ai[0] == 126f && ai[1] == 1f)
71181 {
71183 }
71184 if (ai[1] == 1f && Main.netMode != 1 && (ai[0] == 40f || ai[0] == 48f || ai[0] == 56f) && WorldUtils.Find(Utils.ToTileCoordinates(new Vector2(base.Center.X + (float)(direction * 240), base.Center.Y)), Searches.Chain(new Searches.Down(50), new Terraria.WorldBuilding.Conditions.IsSolid()), out var result))
71185 {
71186 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), result.ToWorldCoordinates(8f, 0f), Vector2.Zero, 674, 0, 0f, Main.myPlayer);
71187 }
71188 if (ai[0] <= 0f)
71189 {
71190 float num21 = ai[1];
71191 ai[1] += 1f;
71192 if (ai[1] >= 3f)
71193 {
71194 ai[1] = 0f;
71195 }
71196 ai[0] = -120f;
71197 if (num21 == 0f)
71198 {
71199 ai[0] = -20f;
71200 }
71201 netUpdate = true;
71202 }
71203 }
71204 if (ai[0] == 0f && localAI[3] >= 60f)
71205 {
71206 bool flag10 = false;
71207 Vector2 minimum = base.Center + new Vector2(-600f, -200f);
71208 Vector2 maximum = base.Center + new Vector2(600f, 200f);
71209 int num5 = 0;
71210 for (int i = 0; i < 200; i++)
71211 {
71212 NPC nPC = Main.npc[i];
71213 if (nPC.active && nPC.lifeMax != nPC.life && nPC.Center.Between(minimum, maximum) && ++num5 >= 2)
71214 {
71215 flag10 = true;
71216 break;
71217 }
71218 }
71219 if (!flag10)
71220 {
71221 ai[1] = 2f;
71222 }
71223 if (ai[1] == 2f && !DD2Event.CanRaiseGoblinsHere(base.Center))
71224 {
71225 ai[1] = 0f;
71226 }
71227 bool flag11 = true;
71228 if (ai[1] == 0f && (Distance(targetData.Center) >= 1000f || !Collision.CanHitLine(base.Center, 0, 0, targetData.Center, 0, 0)))
71229 {
71230 flag11 = false;
71231 }
71232 if (flag11)
71233 {
71234 switch ((int)ai[1])
71235 {
71236 case 0:
71237 ai[0] = 97f;
71238 break;
71239 case 1:
71240 ai[0] = 127f;
71241 break;
71242 case 2:
71243 ai[0] = 183f;
71244 break;
71245 }
71246 netUpdate = true;
71247 flag8 = true;
71248 }
71249 }
71250 if (localAI[3] == 0f)
71251 {
71252 alpha = 255;
71253 }
71254 if (localAI[3] == 30f)
71255 {
71257 }
71258 if (localAI[3] < 60f)
71259 {
71260 localAI[3] += 1f;
71261 alpha -= 5;
71262 if (alpha < 0)
71263 {
71264 alpha = 0;
71265 }
71266 int num6 = (int)localAI[3] / 10;
71267 Vector2 size = base.Size;
71268 float num7 = ((Vector2)(ref size)).Length() / 2f;
71269 num7 /= 20f;
71270 int maxValue = 5;
71271 if (type == 576 || type == 577)
71272 {
71273 maxValue = 1;
71274 }
71275 for (int j = 0; j < num6; j++)
71276 {
71277 if (Main.rand.Next(maxValue) == 0)
71278 {
71279 Dust dust = Dust.NewDustDirect(position, width, height, 27, velocity.X * 1f, 0f, 100);
71280 dust.scale = 0.55f;
71281 dust.fadeIn = 0.7f;
71282 dust.velocity *= 0.1f * num7;
71283 dust.velocity += velocity;
71284 }
71285 }
71286 }
71287 }
71288 if (justHit)
71289 {
71290 localAI[2] = 0f;
71291 }
71292 if (!flag4)
71293 {
71294 if (localAI[2] >= 0f)
71295 {
71296 float num8 = 16f;
71297 bool flag2 = false;
71298 bool flag3 = false;
71299 if (position.X > localAI[0] - num8 && position.X < localAI[0] + num8)
71300 {
71301 flag2 = true;
71302 }
71303 else if ((velocity.X < 0f && direction > 0) || (velocity.X > 0f && direction < 0))
71304 {
71305 flag2 = true;
71306 num8 += 24f;
71307 }
71308 if (position.Y > localAI[1] - num8 && position.Y < localAI[1] + num8)
71309 {
71310 flag3 = true;
71311 }
71312 if (flag2 && flag3)
71313 {
71314 localAI[2] += 1f;
71315 if (localAI[2] >= 30f && num8 == 16f)
71316 {
71317 flag = true;
71318 }
71319 if (localAI[2] >= 60f)
71320 {
71321 localAI[2] = -180f;
71322 direction *= -1;
71323 velocity.X *= -1f;
71324 collideX = false;
71325 }
71326 }
71327 else
71328 {
71329 localAI[0] = position.X;
71330 localAI[1] = position.Y;
71331 localAI[2] = 0f;
71332 }
71333 if (flag9)
71334 {
71336 }
71337 }
71338 else
71339 {
71340 localAI[2] += 1f;
71341 direction = ((targetData.Center.X > base.Center.X) ? 1 : (-1));
71342 }
71343 }
71344 int num9 = (int)((position.X + (float)(width / 2)) / 16f) + direction * 2;
71345 int num10 = (int)((position.Y + (float)height) / 16f);
71346 int num12 = (int)base.Bottom.Y / 16;
71347 int num13 = (int)base.Bottom.X / 16;
71348 if (flag8)
71349 {
71350 velocity *= num4;
71351 return;
71352 }
71353 for (int k = num10; k < num10 + num; k++)
71354 {
71355 if (Main.tile[num9, k] == null)
71356 {
71357 Main.tile[num9, k] = default(Tile);
71358 }
71359 if ((Main.tile[num9, k].nactive() && Main.tileSolid[Main.tile[num9, k].type]) || Main.tile[num9, k].liquid > 0)
71360 {
71361 if (k <= num10 + 1)
71362 {
71363 flag6 = true;
71364 }
71365 flag5 = false;
71366 break;
71367 }
71368 }
71369 for (int l = num12; l < num12 + num14; l++)
71370 {
71371 if (Main.tile[num13, l] == null)
71372 {
71373 Main.tile[num13, l] = default(Tile);
71374 }
71375 if ((Main.tile[num13, l].nactive() && Main.tileSolid[Main.tile[num13, l].type]) || Main.tile[num13, l].liquid > 0)
71376 {
71377 flag6 = true;
71378 flag5 = false;
71379 break;
71380 }
71381 }
71382 if (flag7)
71383 {
71384 for (int m = num10 - num11; m < num10; m++)
71385 {
71386 if (Main.tile[num9, m] == null)
71387 {
71388 Main.tile[num9, m] = default(Tile);
71389 }
71390 if ((Main.tile[num9, m].nactive() && Main.tileSolid[Main.tile[num9, m].type]) || Main.tile[num9, m].liquid > 0)
71391 {
71392 flag6 = false;
71393 flag = true;
71394 break;
71395 }
71396 }
71397 }
71398 if (flag)
71399 {
71400 flag6 = false;
71401 flag5 = true;
71402 }
71403 if (flag5)
71404 {
71405 velocity.Y += num15;
71406 if (velocity.Y > num16)
71407 {
71408 velocity.Y = num16;
71409 }
71410 }
71411 else
71412 {
71414 {
71415 velocity.Y += num17;
71416 }
71417 if (velocity.Y < num18)
71418 {
71419 velocity.Y = num18;
71420 }
71421 }
71422 if (collideX)
71423 {
71424 velocity.X = oldVelocity.X * -0.4f;
71425 if (direction == -1 && velocity.X > 0f && velocity.X < 1f)
71426 {
71427 velocity.X = 1f;
71428 }
71429 if (direction == 1 && velocity.X < 0f && velocity.X > -1f)
71430 {
71431 velocity.X = -1f;
71432 }
71433 }
71434 if (collideY)
71435 {
71436 velocity.Y = oldVelocity.Y * -0.25f;
71437 if (velocity.Y > 0f && velocity.Y < 1f)
71438 {
71439 velocity.Y = 1f;
71440 }
71441 if (velocity.Y < 0f && velocity.Y > -1f)
71442 {
71443 velocity.Y = -1f;
71444 }
71445 }
71446 if (direction == -1 && velocity.X > 0f - num19)
71447 {
71448 velocity.X -= num20;
71449 if (velocity.X > num19)
71450 {
71451 velocity.X -= num20;
71452 }
71453 else if (velocity.X > 0f)
71454 {
71455 velocity.X += num20 / 2f;
71456 }
71457 if (velocity.X < 0f - num19)
71458 {
71459 velocity.X = 0f - num19;
71460 }
71461 }
71462 else if (direction == 1 && velocity.X < num19)
71463 {
71464 velocity.X += num20;
71465 if (velocity.X < 0f - num19)
71466 {
71467 velocity.X += num20;
71468 }
71469 else if (velocity.X < 0f)
71470 {
71471 velocity.X -= num20 / 2f;
71472 }
71473 if (velocity.X > num19)
71474 {
71475 velocity.X = num19;
71476 }
71477 }
71478 if (directionY == -1 && velocity.Y > 0f - num2)
71479 {
71480 velocity.Y -= num3;
71481 if (velocity.Y > num2)
71482 {
71483 velocity.Y -= num3 * 1.25f;
71484 }
71485 else if (velocity.Y > 0f)
71486 {
71487 velocity.Y += num3 * 0.75f;
71488 }
71489 if (velocity.Y < 0f - num2)
71490 {
71491 velocity.Y = 0f - num19;
71492 }
71493 }
71494 else if (directionY == 1 && velocity.Y < num2)
71495 {
71496 velocity.Y += num3;
71497 if (velocity.Y < 0f - num2)
71498 {
71499 velocity.Y += num3 * 1.25f;
71500 }
71501 else if (velocity.Y < 0f)
71502 {
71503 velocity.Y -= num3 * 0.75f;
71504 }
71505 if (velocity.Y > num2)
71506 {
71507 velocity.Y = num2;
71508 }
71509 }
71510 }
static SlotId PlayTrackedSound(in SoundStyle style, Vector2? position=null)
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
float Distance(Vector2 Other)
Definition Entity.cs:275
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
static bool CanRaiseGoblinsHere(Vector2 spot)
Definition DD2Event.cs:699
static void RaiseGoblins(NPC caller, Vector2 spot)
Definition DD2Event.cs:718
static readonly SoundStyle DD2_DarkMageSummonSkeleton
Definition SoundID.cs:97
static readonly SoundStyle DD2_DarkMageCastHeal
Definition SoundID.cs:89
static readonly SoundStyle DD2_EtherianPortalSpawnEnemy
Definition SoundID.cs:193
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
Definition NPC.cs:1003
int spriteDirection
Definition NPC.cs:1143
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:1668
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
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 alpha
0 is opaque, and 255 is transparent. Note that this is the opposite of how alpha is typically express...
Definition NPC.cs:1092
float rotation
Definition NPC.cs:1116
bool justHit
Definition NPC.cs:1015
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:107558
int directionY
Definition NPC.cs:983
bool netUpdate
Definition NPC.cs:1130
static void TargetClosestOldOnesInvasion(NPC searcher, bool faceTarget=true, Vector2? checkPosition=null)
Definition NPCUtils.cs:279
static GenSearch Chain(GenSearch search, params GenCondition[] conditions)
Definition Searches.cs:154
static bool Find(Point origin, GenSearch search, out Point result)
Definition WorldUtils.cs:30

References Terraria.NPC.ai, Terraria.NPC.alpha, Terraria.Collision.CanHitLine(), Terraria.GameContent.Events.DD2Event.CanRaiseGoblinsHere(), Terraria.DelegateMethods.CastLightOpen(), Terraria.WorldBuilding.Searches.Chain(), Terraria.NPC.collideX, Terraria.NPC.collideY, Terraria.ID.SoundID.DD2_DarkMageCastHeal, Terraria.ID.SoundID.DD2_DarkMageSummonSkeleton, Terraria.ID.SoundID.DD2_EtherianPortalSpawnEnemy, Terraria.Entity.direction, Terraria.NPC.directionY, Terraria.Entity.Distance(), Terraria.WorldBuilding.WorldUtils.Find(), Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetTargetData(), Terraria.Entity.height, Terraria.NPC.justHit, Terraria.NPC.localAI, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.Dust.NewDustDirect(), Terraria.Projectile.NewProjectile(), Terraria.Main.npc, Terraria.Audio.SoundEngine.PlayTrackedSound(), Terraria.Utils.PlotTileLine(), Terraria.Entity.position, Terraria.GameContent.Events.DD2Event.RaiseGoblins(), Terraria.Main.rand, Terraria.NPC.rotation, Terraria.NPC.spriteDirection, Terraria.Utilities.NPCUtils.TargetClosestOldOnesInvasion(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Utils.ToTileCoordinates(), Terraria.NPC.type, Terraria.Entity.velocity, and Terraria.Entity.width.

Referenced by Terraria.NPC.VanillaAI_Inner().

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