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

◆ AI_117_BloodNautilus()

void Terraria.NPC.AI_117_BloodNautilus ( )
inlineprivate

Definition at line 40338 of file NPC.cs.

40339 {
40340 float moveSpeed = 0.15f;
40341 float num = 7.5f;
40342 float num2 = 60f;
40343 float num3 = 90f;
40344 float num4 = 180f;
40345 float num5 = 90f;
40346 float num6 = 90f;
40347 int num7 = 3;
40348 float num8 = 180f;
40349 bool flag = false;
40350 if (localAI[0] == 0f)
40351 {
40352 localAI[0] = 1f;
40353 alpha = 255;
40354 if (Main.netMode != 1)
40355 {
40356 ai[0] = -1f;
40357 netUpdate = true;
40358 }
40359 }
40360 if (ai[0] != -1f && Main.rand.Next(4) == 0)
40361 {
40363 Dust dust = Dust.NewDustDirect(position + new Vector2(5f), width - 10, height - 10, 5);
40364 dust.velocity *= 0.5f;
40365 if (dust.velocity.Y < 0f)
40366 {
40367 dust.velocity.Y *= -1f;
40368 }
40369 dust.alpha = 120;
40370 dust.scale = 1f + Main.rand.NextFloat() * 0.4f;
40371 dust.velocity += velocity * 0.3f;
40373 }
40374 if (target == 255)
40375 {
40376 TargetClosest();
40377 ai[2] = direction;
40378 }
40379 if (Main.player[target].dead || Vector2.Distance(Main.player[target].Center, base.Center) > 2000f)
40380 {
40381 TargetClosest();
40382 }
40384 if (Main.dayTime || !Main.bloodMoon)
40385 {
40386 nPCAimedTarget = default(NPCAimedTarget);
40387 }
40388 int num9 = -1;
40389 switch ((int)ai[0])
40390 {
40391 case -1:
40392 {
40393 velocity *= 0.98f;
40394 int num17 = Math.Sign(nPCAimedTarget.Center.X - base.Center.X);
40395 if (num17 != 0)
40396 {
40397 direction = num17;
40399 }
40400 if (localAI[1] == 0f && alpha < 100)
40401 {
40402 localAI[1] = 1f;
40403 int num18 = 36;
40404 for (int l = 0; l < num18; l++)
40405 {
40407 Vector2 vector3 = (Vector2.Normalize(velocity) * new Vector2((float)width / 2f, height) * 0.75f * 0.5f).RotatedBy((float)(l - (num18 / 2 - 1)) * ((float)Math.PI * 2f) / (float)num18) + base.Center;
40408 Vector2 vector4 = vector3 - base.Center;
40409 int num19 = Dust.NewDust(vector3 + vector4, 0, 0, 5, vector4.X * 2f, vector4.Y * 2f, 100, default(Color), 1.4f);
40410 Main.dust[num19].noGravity = true;
40411 Main.dust[num19].velocity = Vector2.Normalize(vector4) * 3f;
40413 }
40414 }
40415 if (ai[2] > 5f)
40416 {
40417 velocity.Y = -2.5f;
40418 alpha -= 10;
40419 if (Collision.SolidCollision(position, width, height))
40420 {
40421 alpha += 15;
40422 if (alpha > 150)
40423 {
40424 alpha = 150;
40425 }
40426 }
40427 if (alpha < 0)
40428 {
40429 alpha = 0;
40430 }
40431 }
40432 ai[2] += 1f;
40433 if (ai[2] >= 50f)
40434 {
40435 ai[0] = 0f;
40436 ai[1] = 0f;
40437 ai[2] = 0f;
40438 ai[3] = 0f;
40439 netUpdate = true;
40440 }
40441 break;
40442 }
40443 case 0:
40444 {
40445 Vector2 destination = nPCAimedTarget.Center + new Vector2((0f - ai[2]) * 300f, -200f);
40446 if (base.Center.Distance(destination) > 50f)
40447 {
40450 }
40451 direction = ((base.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1));
40452 float num15 = base.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 0.47123894f * (float)spriteDirection;
40453 if (spriteDirection == -1)
40454 {
40455 num15 += (float)Math.PI;
40456 }
40458 {
40460 rotation = 0f - rotation;
40461 num15 = 0f - num15;
40462 }
40463 rotation = rotation.AngleTowards(num15, 0.02f);
40464 ai[1] += 1f;
40465 if (ai[1] > num2)
40466 {
40467 num9 = 1;
40468 int num16 = (int)ai[3];
40469 if (num16 % 7 == 3)
40470 {
40471 num9 = 3;
40472 }
40473 else if (num16 % 2 == 0)
40474 {
40476 num9 = 2;
40477 }
40478 else
40479 {
40481 num9 = 1;
40482 }
40483 }
40484 break;
40485 }
40486 case 1:
40487 {
40488 direction = ((!(base.Center.X < nPCAimedTarget.Center.X)) ? 1 : (-1));
40489 float num20 = base.Center.DirectionFrom(nPCAimedTarget.Center).ToRotation() - 0.47123894f * (float)spriteDirection;
40490 if (spriteDirection == -1)
40491 {
40492 num20 += (float)Math.PI;
40493 }
40494 bool flag2 = ai[1] < num3;
40496 {
40498 rotation = 0f - rotation;
40499 num20 = 0f - num20;
40500 }
40501 if (ai[1] < num3)
40502 {
40503 if (ai[1] == num3 - 1f)
40504 {
40506 }
40507 flag = true;
40508 velocity *= 0.95f;
40509 rotation = rotation.AngleLerp(num20, 0.02f);
40512 Dust dust6 = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 60f - new Vector2(40f), 80, 80, 16, 0f, 0f, 150, Color.Transparent, 0.6f);
40513 dust6.fadeIn = 1f;
40514 dust6.velocity = dust6.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * dust6.velocity.Length();
40515 dust6.noGravity = true;
40516 dust6 = Dust.NewDustDirect(mouthPosition4 + mouthDirection4 * 100f - new Vector2(30f), 60, 60, 16, 0f, 0f, 100, Color.Transparent, 0.9f);
40517 dust6.fadeIn = 1.5f;
40518 dust6.velocity = dust6.position.DirectionTo(mouthPosition4 + Main.rand.NextVector2Circular(15f, 15f)) * (dust6.velocity.Length() + 5f);
40519 dust6.noGravity = true;
40521 }
40522 else if (ai[1] < num3 + num4)
40523 {
40525 rotation = rotation.AngleLerp(num20, 0.05f);
40527 if (base.Center.Distance(nPCAimedTarget.Center) > 150f)
40528 {
40529 velocity = mouthDirection5 * -16f + base.Center.DirectionTo(nPCAimedTarget.Center) * 1.5f;
40530 }
40531 for (int m = 0; m < 4; m++)
40532 {
40533 Dust dust7 = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 60f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f);
40534 dust7.velocity = dust7.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(5f, 5f)) * dust7.velocity.Length();
40535 dust7.position -= mouthDirection5 * 60f;
40536 dust7 = Dust.NewDustDirect(mouthPosition5 + mouthDirection5 * 100f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f);
40537 dust7.velocity = dust7.position.DirectionFrom(mouthPosition5 + Main.rand.NextVector2Circular(10f, 10f)) * (dust7.velocity.Length() + 5f);
40538 dust7.position -= mouthDirection5 * 100f;
40539 }
40541 }
40542 ai[1] += 1f;
40543 if (ai[1] >= num3 + num4)
40544 {
40545 num9 = 0;
40546 }
40547 break;
40548 }
40549 case 2:
40550 {
40551 direction = ((base.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1));
40552 float num12 = base.Center.DirectionTo(nPCAimedTarget.Center).ToRotation() - 0.47123894f * (float)spriteDirection;
40553 if (spriteDirection == -1)
40554 {
40555 num12 += (float)Math.PI;
40556 }
40558 {
40560 rotation = 0f - rotation;
40561 num12 = 0f - num12;
40562 }
40563 rotation = rotation.AngleLerp(num12, 0.2f);
40564 if (ai[1] < num5)
40565 {
40567 velocity *= 0.95f;
40569 if (Main.rand.Next(4) != 0)
40570 {
40571 Dust dust3 = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 60f - new Vector2(60f), 120, 120, 16, 0f, 0f, 150, Color.Transparent, 0.6f);
40572 dust3.fadeIn = 1f;
40573 dust3.velocity = dust3.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (dust3.velocity.Length() + 3f);
40574 dust3.noGravity = true;
40575 dust3 = Dust.NewDustDirect(mouthPosition2 + mouthDirection2 * 100f - new Vector2(80f), 160, 160, 16, 0f, 0f, 100, Color.Transparent, 0.9f);
40576 dust3.fadeIn = 1.5f;
40577 dust3.velocity = dust3.position.DirectionTo(mouthPosition2 + Main.rand.NextVector2Circular(15f, 15f)) * (dust3.velocity.Length() + 5f);
40578 dust3.noGravity = true;
40579 }
40581 }
40582 else if (ai[1] < num5 + num6)
40583 {
40585 velocity *= 0.9f;
40586 float num13 = (ai[1] - num5) % (num6 / (float)num7);
40588 if (num13 < num6 / (float)num7 * 0.8f)
40589 {
40590 for (int i = 0; i < 5; i++)
40591 {
40592 Dust dust4 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 50f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f);
40593 dust4.velocity = dust4.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * dust4.velocity.Length();
40594 dust4.position -= mouthDirection3 * 60f;
40595 dust4 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 90f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f);
40596 dust4.velocity = dust4.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (dust4.velocity.Length() + 5f);
40597 dust4.position -= mouthDirection3 * 100f;
40598 }
40599 }
40600 if ((int)num13 == 0)
40601 {
40602 velocity += mouthDirection3 * -8f;
40603 for (int j = 0; j < 20; j++)
40604 {
40605 Dust dust5 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 60f - new Vector2(15f), 30, 30, 5, 0f, 0f, 0, Color.Transparent, 1.5f);
40606 dust5.velocity = dust5.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(5f, 5f)) * dust5.velocity.Length();
40607 dust5.position -= mouthDirection3 * 60f;
40608 dust5 = Dust.NewDustDirect(mouthPosition3 + mouthDirection3 * 100f - new Vector2(20f), 40, 40, 5, 0f, 0f, 100, Color.Transparent, 1.5f);
40609 dust5.velocity = dust5.position.DirectionFrom(mouthPosition3 + Main.rand.NextVector2Circular(10f, 10f)) * (dust5.velocity.Length() + 5f);
40610 dust5.position -= mouthDirection3 * 100f;
40611 }
40612 if (Main.netMode != 1)
40613 {
40614 int num14 = Main.rand.Next(5, 11);
40617 for (int k = 0; k < num14; k++)
40618 {
40619 Vector2 vector2 = vector + Main.rand.NextVector2Square(-6f, 6f);
40620 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), mouthPosition3 - mouthDirection3 * 5f, vector2, 814, attackDamage_ForProjectiles, 0f, Main.myPlayer);
40621 }
40622 }
40623 }
40625 }
40626 ai[1] += 1f;
40627 if (ai[1] >= num5 + num6)
40628 {
40629 num9 = 0;
40630 }
40631 break;
40632 }
40633 case 3:
40634 {
40635 direction = ((base.Center.X < nPCAimedTarget.Center.X) ? 1 : (-1));
40636 float targetAngle = 0f;
40638 if (ai[1] < num8)
40639 {
40641 float num10 = MathHelper.Clamp(1f - ai[1] / num8 * 1.5f, 0f, 1f);
40642 velocity = Vector2.Lerp(value2: new Vector2(0f, num10 * -1.5f), value1: velocity, amount: 0.03f);
40644 rotation = rotation.AngleLerp(targetAngle, 0.02f);
40646 float t = ai[1] / num8;
40647 float num11 = Utils.GetLerpValue(0f, 0.5f, t) * Utils.GetLerpValue(1f, 0.5f, t);
40648 Lighting.AddLight(base.Center, new Vector3(1f, 0.5f, 0.5f) * num11);
40649 if (Main.rand.Next(3) != 0)
40650 {
40651 Dust dust2 = Dust.NewDustDirect(base.Center - new Vector2(6f), 12, 12, 5, 0f, 0f, 60, Color.Transparent, 1.4f);
40652 dust2.position += new Vector2(spriteDirection * 12, 12f);
40653 dust2.velocity *= 0.1f;
40654 }
40656 }
40657 if (ai[1] == 10f || ai[1] == 20f || ai[1] == 30f)
40658 {
40660 }
40661 ai[1] += 1f;
40662 if (ai[1] >= num8)
40663 {
40664 num9 = 0;
40665 }
40666 break;
40667 }
40668 }
40669 if (num9 != -1)
40670 {
40671 ai[0] = num9;
40672 ai[1] = 0f;
40673 ai[2] = 0f;
40674 netUpdate = true;
40675 TargetClosest();
40676 if (num9 == 0)
40677 {
40678 ai[2] = direction;
40679 }
40680 else
40681 {
40682 ai[3] += 1f;
40683 }
40684 }
40685 reflectsProjectiles = flag;
40686 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
static readonly LegacySoundStyle Item170
Definition SoundID.cs:754
static readonly LegacySoundStyle Item172
Definition SoundID.cs:758
Vector2 netOffset
Definition NPC.cs:103
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
bool reflectsProjectiles
Definition NPC.cs:571
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:864
float[] ai
Definition NPC.cs:447
int alpha
Definition NPC.cs:489
float rotation
Definition NPC.cs:501
int GetAttackDamage_ForProjectiles(float normalDamage, float expertDamage)
Definition NPC.cs:1082
void BloodNautilus_CallForHelp()
Definition NPC.cs:40688
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
void BloodNautilus_GetMouthPositionAndRotation(out Vector2 mouthPosition, out Vector2 mouthDirection)
Definition NPC.cs:58795
void SimpleFlyMovement(Vector2 desiredVelocity, float moveSpeed)
Definition NPC.cs:69581
bool netUpdate
Definition NPC.cs:507
int target
Definition NPC.cs:459
static Color Transparent
Definition Color.cs:76
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227

References Terraria.Lighting.AddLight(), Terraria.NPC.ai, Terraria.NPC.alpha, Terraria.Main.bloodMoon, Terraria.NPC.BloodNautilus_CallForHelp(), Terraria.NPC.BloodNautilus_GetMouthPositionAndRotation(), Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.Main.dayTime, System.destination, Terraria.Entity.direction, Terraria.Entity.DirectionTo(), Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Main.dust, Terraria.NPC.GetAttackDamage_ForProjectiles(), Terraria.Utils.GetLerpValue(), Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetTargetData(), Terraria.Entity.height, Terraria.ID.SoundID.Item170, Terraria.ID.SoundID.Item172, Microsoft.Xna.Framework.Vector2.Lerp(), Terraria.NPC.localAI, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netOffset, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), Terraria.Projectile.NewProjectile(), Microsoft.Xna.Framework.Vector2.Normalize(), System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.rand, Terraria.NPC.reflectsProjectiles, Terraria.NPC.rotation, System.Math.Sign(), Terraria.NPC.SimpleFlyMovement(), Terraria.Collision.SolidCollision(), Terraria.NPC.spriteDirection, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Microsoft.Xna.Framework.Color.Transparent, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Dust.velocity, Terraria.Entity.velocity, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().