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

◆ AI_109_DarkMage()

void Terraria.NPC.AI_109_DarkMage ( )
inlineprivate

Definition at line 58162 of file NPC.cs.

58163 {
58164 //IL_01c8: Unknown result type (might be due to invalid IL or missing references)
58165 //IL_0661: Unknown result type (might be due to invalid IL or missing references)
58166 //IL_034a: Unknown result type (might be due to invalid IL or missing references)
58167 bool flag = false;
58168 bool flag2 = false;
58169 bool flag3 = true;
58170 bool flag4 = false;
58171 int num = 4;
58172 int num2 = 3;
58173 int num3 = 0;
58174 float num4 = 0.2f;
58175 float num5 = 2f;
58176 float num6 = -0.2f;
58177 float num7 = -4f;
58178 bool flag5 = true;
58179 float num8 = 2f;
58180 float num9 = 0.1f;
58181 float num10 = 1f;
58182 float num11 = 0.04f;
58183 bool flag6 = false;
58184 float num12 = 0.96f;
58185 bool flag7 = true;
58187 if (type == 564 || type == 565)
58188 {
58189 flag5 = false;
58190 rotation = velocity.X * 0.04f;
58191 spriteDirection = ((direction > 0) ? 1 : (-1));
58192 num3 = 2;
58193 num6 = -0.05f;
58194 num7 = -0.4f;
58195 num4 = 0.05f;
58196 num5 = 0.2f;
58197 num10 = 0.5f;
58198 num11 = 0.02f;
58199 num8 = 0.5f;
58200 num9 = 0.1f;
58201 localAI[2] = 0f;
58202 DelegateMethods.v3_1 = new Vector3(0.3f, 0.05f, 0.45f) * 1.5f;
58203 Utils.PlotTileLine(base.Top, base.Bottom, width, DelegateMethods.CastLightOpen);
58204 if (ai[0] < 0f)
58205 {
58206 ai[0] = MathHelper.Min(ai[0] + 1f, 0f);
58207 }
58208 if (ai[0] > 0f)
58209 {
58210 flag7 = false;
58211 flag6 = true;
58212 num12 = 0.9f;
58213 ai[0] -= 1f;
58214 if (ai[0] == 80f && ai[1] == 2f)
58215 {
58217 }
58218 if (ai[1] == 2f && ai[0] == 64f && Main.netMode != 1)
58219 {
58220 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center + new Vector2(direction * 24, -40f), Vector2.Zero, 673, 0, 0f, Main.myPlayer);
58221 DD2Event.RaiseGoblins(this, base.Center);
58222 }
58223 if (ai[1] == 0f && ai[0] == 32f)
58224 {
58225 Vector2 vector = (targetData.Center - (base.Center + new Vector2(direction * 10, -16f))).SafeNormalize(Vector2.UnitY) * 14f;
58226 direction = ((vector.X > 0f) ? 1 : (-1));
58227 if (Main.netMode != 1)
58228 {
58229 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center + new Vector2(direction * 10, -16f), vector, 675, 40, 0f, Main.myPlayer);
58230 }
58231 }
58232 if (ai[0] == 126f && ai[1] == 1f)
58233 {
58235 }
58236 if (ai[1] == 1f && Main.netMode != 1 && (ai[0] == 40f || ai[0] == 48f || ai[0] == 56f) && WorldUtils.Find(new Vector2(base.Center.X + (float)(direction * 240), base.Center.Y).ToTileCoordinates(), Searches.Chain(new Searches.Down(50), new Terraria.WorldBuilding.Conditions.IsSolid()), out var result))
58237 {
58238 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), result.ToWorldCoordinates(8f, 0f), Vector2.Zero, 674, 0, 0f, Main.myPlayer);
58239 }
58240 if (ai[0] <= 0f)
58241 {
58242 float num13 = ai[1];
58243 ai[1] += 1f;
58244 if (ai[1] >= 3f)
58245 {
58246 ai[1] = 0f;
58247 }
58248 ai[0] = -120f;
58249 if (num13 == 0f)
58250 {
58251 ai[0] = -20f;
58252 }
58253 netUpdate = true;
58254 }
58255 }
58256 if (ai[0] == 0f && localAI[3] >= 60f)
58257 {
58258 bool flag8 = false;
58259 Vector2 minimum = base.Center + new Vector2(-600f, -200f);
58260 Vector2 maximum = base.Center + new Vector2(600f, 200f);
58261 int num14 = 0;
58262 for (int i = 0; i < 200; i++)
58263 {
58264 NPC nPC = Main.npc[i];
58265 if (nPC.active && nPC.lifeMax != nPC.life && nPC.Center.Between(minimum, maximum) && ++num14 >= 2)
58266 {
58267 flag8 = true;
58268 break;
58269 }
58270 }
58271 if (!flag8)
58272 {
58273 ai[1] = 2f;
58274 }
58275 if (ai[1] == 2f && !DD2Event.CanRaiseGoblinsHere(base.Center))
58276 {
58277 ai[1] = 0f;
58278 }
58279 bool flag9 = true;
58280 if (ai[1] == 0f && (Distance(targetData.Center) >= 1000f || !Collision.CanHitLine(base.Center, 0, 0, targetData.Center, 0, 0)))
58281 {
58282 flag9 = false;
58283 }
58284 if (flag9)
58285 {
58286 switch ((int)ai[1])
58287 {
58288 case 0:
58289 ai[0] = 97f;
58290 break;
58291 case 1:
58292 ai[0] = 127f;
58293 break;
58294 case 2:
58295 ai[0] = 183f;
58296 break;
58297 }
58298 netUpdate = true;
58299 flag6 = true;
58300 }
58301 }
58302 if (localAI[3] == 0f)
58303 {
58304 alpha = 255;
58305 }
58306 if (localAI[3] == 30f)
58307 {
58309 }
58310 if (localAI[3] < 60f)
58311 {
58312 localAI[3] += 1f;
58313 alpha -= 5;
58314 if (alpha < 0)
58315 {
58316 alpha = 0;
58317 }
58318 int num15 = (int)localAI[3] / 10;
58319 float num16 = base.Size.Length() / 2f;
58320 num16 /= 20f;
58321 int maxValue = 5;
58322 if (type == 576 || type == 577)
58323 {
58324 maxValue = 1;
58325 }
58326 for (int j = 0; j < num15; j++)
58327 {
58328 if (Main.rand.Next(maxValue) == 0)
58329 {
58330 Dust dust = Dust.NewDustDirect(position, width, height, 27, velocity.X * 1f, 0f, 100);
58331 dust.scale = 0.55f;
58332 dust.fadeIn = 0.7f;
58333 dust.velocity *= 0.1f * num16;
58334 dust.velocity += velocity;
58335 }
58336 }
58337 }
58338 }
58339 if (justHit)
58340 {
58341 localAI[2] = 0f;
58342 }
58343 if (!flag2)
58344 {
58345 if (localAI[2] >= 0f)
58346 {
58347 float num17 = 16f;
58348 bool flag10 = false;
58349 bool flag11 = false;
58350 if (position.X > localAI[0] - num17 && position.X < localAI[0] + num17)
58351 {
58352 flag10 = true;
58353 }
58354 else if ((velocity.X < 0f && direction > 0) || (velocity.X > 0f && direction < 0))
58355 {
58356 flag10 = true;
58357 num17 += 24f;
58358 }
58359 if (position.Y > localAI[1] - num17 && position.Y < localAI[1] + num17)
58360 {
58361 flag11 = true;
58362 }
58363 if (flag10 && flag11)
58364 {
58365 localAI[2] += 1f;
58366 if (localAI[2] >= 30f && num17 == 16f)
58367 {
58368 flag = true;
58369 }
58370 if (localAI[2] >= 60f)
58371 {
58372 localAI[2] = -180f;
58373 direction *= -1;
58374 velocity.X *= -1f;
58375 collideX = false;
58376 }
58377 }
58378 else
58379 {
58380 localAI[0] = position.X;
58381 localAI[1] = position.Y;
58382 localAI[2] = 0f;
58383 }
58384 if (flag7)
58385 {
58387 }
58388 }
58389 else
58390 {
58391 localAI[2] += 1f;
58392 direction = ((targetData.Center.X > base.Center.X) ? 1 : (-1));
58393 }
58394 }
58395 int num18 = (int)((position.X + (float)(width / 2)) / 16f) + direction * 2;
58396 int num19 = (int)((position.Y + (float)height) / 16f);
58397 int num20 = (int)base.Bottom.Y / 16;
58398 int num21 = (int)base.Bottom.X / 16;
58399 if (flag6)
58400 {
58401 velocity *= num12;
58402 return;
58403 }
58404 for (int k = num19; k < num19 + num; k++)
58405 {
58406 if (Main.tile[num18, k] == null)
58407 {
58408 Main.tile[num18, k] = new Tile();
58409 }
58410 if ((Main.tile[num18, k].nactive() && Main.tileSolid[Main.tile[num18, k].type]) || Main.tile[num18, k].liquid > 0)
58411 {
58412 if (k <= num19 + 1)
58413 {
58414 flag4 = true;
58415 }
58416 flag3 = false;
58417 break;
58418 }
58419 }
58420 for (int l = num20; l < num20 + num3; l++)
58421 {
58422 if (Main.tile[num21, l] == null)
58423 {
58424 Main.tile[num21, l] = new Tile();
58425 }
58426 if ((Main.tile[num21, l].nactive() && Main.tileSolid[Main.tile[num21, l].type]) || Main.tile[num21, l].liquid > 0)
58427 {
58428 flag4 = true;
58429 flag3 = false;
58430 break;
58431 }
58432 }
58433 if (flag5)
58434 {
58435 for (int m = num19 - num2; m < num19; m++)
58436 {
58437 if (Main.tile[num18, m] == null)
58438 {
58439 Main.tile[num18, m] = new Tile();
58440 }
58441 if ((Main.tile[num18, m].nactive() && Main.tileSolid[Main.tile[num18, m].type]) || Main.tile[num18, m].liquid > 0)
58442 {
58443 flag4 = false;
58444 flag = true;
58445 break;
58446 }
58447 }
58448 }
58449 if (flag)
58450 {
58451 flag4 = false;
58452 flag3 = true;
58453 }
58454 if (flag3)
58455 {
58456 velocity.Y += num4;
58457 if (velocity.Y > num5)
58458 {
58459 velocity.Y = num5;
58460 }
58461 }
58462 else
58463 {
58465 {
58466 velocity.Y += num6;
58467 }
58468 if (velocity.Y < num7)
58469 {
58470 velocity.Y = num7;
58471 }
58472 }
58473 if (collideX)
58474 {
58475 velocity.X = oldVelocity.X * -0.4f;
58476 if (direction == -1 && velocity.X > 0f && velocity.X < 1f)
58477 {
58478 velocity.X = 1f;
58479 }
58480 if (direction == 1 && velocity.X < 0f && velocity.X > -1f)
58481 {
58482 velocity.X = -1f;
58483 }
58484 }
58485 if (collideY)
58486 {
58487 velocity.Y = oldVelocity.Y * -0.25f;
58488 if (velocity.Y > 0f && velocity.Y < 1f)
58489 {
58490 velocity.Y = 1f;
58491 }
58492 if (velocity.Y < 0f && velocity.Y > -1f)
58493 {
58494 velocity.Y = -1f;
58495 }
58496 }
58497 if (direction == -1 && velocity.X > 0f - num8)
58498 {
58499 velocity.X -= num9;
58500 if (velocity.X > num8)
58501 {
58502 velocity.X -= num9;
58503 }
58504 else if (velocity.X > 0f)
58505 {
58506 velocity.X += num9 / 2f;
58507 }
58508 if (velocity.X < 0f - num8)
58509 {
58510 velocity.X = 0f - num8;
58511 }
58512 }
58513 else if (direction == 1 && velocity.X < num8)
58514 {
58515 velocity.X += num9;
58516 if (velocity.X < 0f - num8)
58517 {
58518 velocity.X += num9;
58519 }
58520 else if (velocity.X < 0f)
58521 {
58522 velocity.X -= num9 / 2f;
58523 }
58524 if (velocity.X > num8)
58525 {
58526 velocity.X = num8;
58527 }
58528 }
58529 if (directionY == -1 && velocity.Y > 0f - num10)
58530 {
58531 velocity.Y -= num11;
58532 if (velocity.Y > num10)
58533 {
58534 velocity.Y -= num11 * 1.25f;
58535 }
58536 else if (velocity.Y > 0f)
58537 {
58538 velocity.Y += num11 * 0.75f;
58539 }
58540 if (velocity.Y < 0f - num10)
58541 {
58542 velocity.Y = 0f - num8;
58543 }
58544 }
58545 else if (directionY == 1 && velocity.Y < num10)
58546 {
58547 velocity.Y += num11;
58548 if (velocity.Y < 0f - num10)
58549 {
58550 velocity.Y += num11 * 1.25f;
58551 }
58552 else if (velocity.Y < 0f)
58553 {
58554 velocity.Y -= num11 * 0.75f;
58555 }
58556 if (velocity.Y > num10)
58557 {
58558 velocity.Y = num10;
58559 }
58560 }
58561 }
static float Min(float value1, float value2)
Definition MathHelper.cs:36
static SlotId PlayTrackedSound(SoundStyle style, Vector2 position)
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
static bool CanRaiseGoblinsHere(Vector2 spot)
Definition DD2Event.cs:683
static void RaiseGoblins(NPC caller, Vector2 spot)
Definition DD2Event.cs:700
static readonly LegacySoundStyle DD2_DarkMageCastHeal
Definition SoundID.cs:818
static readonly LegacySoundStyle DD2_DarkMageSummonSkeleton
Definition SoundID.cs:826
static readonly LegacySoundStyle DD2_EtherianPortalSpawnEnemy
Definition SoundID.cs:922
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:864
float[] ai
Definition NPC.cs:447
bool collideX
Definition NPC.cs:511
bool collideY
Definition NPC.cs:513
int type
Definition NPC.cs:445
int alpha
Definition NPC.cs:489
float rotation
Definition NPC.cs:501
bool justHit
Definition NPC.cs:455
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
int directionY
Definition NPC.cs:443
bool netUpdate
Definition NPC.cs:507
static void TargetClosestOldOnesInvasion(NPC searcher, bool faceTarget=true, Vector2? checkPosition=null)
Definition NPCUtils.cs:261
static GenSearch Chain(GenSearch search, params GenCondition[] conditions)
Definition Searches.cs:123
static bool Find(Point origin, GenSearch search, out Point result)
Definition WorldUtils.cs:27

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, Microsoft.Xna.Framework.MathHelper.Min(), 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.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.NPC.type, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Graphics.Vector3, Terraria.Entity.velocity, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().