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

◆ AI_110_Betsy()

void Terraria.NPC.AI_110_Betsy ( )
inlineprivate

Definition at line 54095 of file NPC.cs.

54096 {
54097 //IL_04f4: Unknown result type (might be due to invalid IL or missing references)
54098 //IL_0486: Unknown result type (might be due to invalid IL or missing references)
54099 //IL_0b13: Unknown result type (might be due to invalid IL or missing references)
54100 //IL_0c83: Unknown result type (might be due to invalid IL or missing references)
54101 //IL_1363: Unknown result type (might be due to invalid IL or missing references)
54102 //IL_1376: Unknown result type (might be due to invalid IL or missing references)
54103 //IL_137b: Unknown result type (might be due to invalid IL or missing references)
54104 //IL_0693: Unknown result type (might be due to invalid IL or missing references)
54105 //IL_0698: Unknown result type (might be due to invalid IL or missing references)
54106 //IL_10a7: Unknown result type (might be due to invalid IL or missing references)
54107 //IL_117f: Unknown result type (might be due to invalid IL or missing references)
54110 int num = -1;
54111 float num2 = 1f;
54112 int num3 = 35;
54113 int num4 = 35;
54114 float num5 = 10f;
54115 float num6 = 0.45f;
54116 float num7 = 7.5f;
54117 float num8 = 30f;
54118 float num9 = 30f;
54119 float num10 = 23f;
54120 float num11 = 600f;
54121 float num12 = 12f;
54122 float num13 = 40f;
54123 float num14 = 80f;
54124 float num15 = num13 + num14;
54125 float num16 = 1500f;
54126 float num17 = 60f;
54127 float num18 = 13f;
54128 float amount = 1f / 30f;
54129 float num19 = 12f;
54130 int num20 = 10;
54131 int num21 = 6 * num20;
54132 float num22 = 60f;
54133 float num23 = num17 + (float)num21 + num22;
54134 float num24 = 60f;
54135 float num25 = 1f;
54136 float num26 = (float)Math.PI * 2f * (num25 / num24);
54137 float num27 = 0.1f;
54138 float num28 = 32f;
54139 float num29 = 90f;
54140 float num30 = 20f;
54141 _ = ai[0];
54142 _ = -1f;
54143 SlotId val;
54144 if (ai[0] == 0f)
54145 {
54146 if ((ai[1] += 1f) >= num5)
54147 {
54148 ai[1] = 0f;
54149 ai[0] = 1f;
54150 ai[2] = 0f;
54151 netUpdate = true;
54152 }
54153 }
54154 else if (ai[0] == 1f)
54155 {
54156 if (ai[2] == 0f)
54157 {
54158 ai[2] = ((base.Center.X < targetData.Center.X) ? 1 : (-1));
54159 }
54160 Vector2 destination = targetData.Center + new Vector2((0f - ai[2]) * 300f, -200f);
54163 int num31 = ((base.Center.X < targetData.Center.X) ? 1 : (-1));
54165 if ((ai[1] += 1f) >= num8)
54166 {
54167 int num32 = 1;
54168 if (ai[3] == 5f && Main.rand.Next(3) == 0)
54169 {
54170 ai[3] += 1f;
54171 }
54172 switch ((int)ai[3])
54173 {
54174 case 0:
54175 case 1:
54176 case 3:
54177 num32 = 2;
54178 break;
54179 case 2:
54180 num32 = 3;
54181 break;
54182 case 4:
54183 num32 = 4;
54184 break;
54185 case 5:
54186 num32 = 5;
54187 break;
54188 case 6:
54189 num32 = 3;
54190 break;
54191 case 7:
54192 num32 = 6;
54193 break;
54194 }
54195 ai[0] = num32;
54196 ai[1] = 0f;
54197 ai[2] = 0f;
54198 ai[3] += 1f;
54199 netUpdate = true;
54200 if (ai[3] >= 8f)
54201 {
54202 ai[3] = 0f;
54203 }
54204 switch (num32)
54205 {
54206 case 2:
54207 {
54209 spriteDirection = ((vector2.X > 0f) ? 1 : (-1));
54210 rotation = vector2.ToRotation();
54211 if (spriteDirection == -1)
54212 {
54213 rotation += (float)Math.PI;
54214 }
54216 break;
54217 }
54218 case 3:
54219 {
54220 Vector2 vector3 = new Vector2((targetData.Center.X > base.Center.X) ? 1 : (-1), 0f);
54221 spriteDirection = ((vector3.X > 0f) ? 1 : (-1));
54222 velocity = vector3 * -2f;
54223 break;
54224 }
54225 case 5:
54226 {
54228 spriteDirection = ((vector.X > 0f) ? 1 : (-1));
54229 rotation = vector.ToRotation();
54230 if (spriteDirection == -1)
54231 {
54232 rotation += (float)Math.PI;
54233 }
54234 velocity = vector * num28;
54235 break;
54236 }
54237 }
54238 }
54239 }
54240 else if (ai[0] == 2f)
54241 {
54242 if (ai[1] == 0f)
54243 {
54245 }
54246 if ((ai[1] += 1f) >= num9)
54247 {
54248 ai[0] = 1f;
54249 ai[1] = 0f;
54250 ai[2] = 0f;
54251 }
54252 }
54253 else if (ai[0] == 3f)
54254 {
54256 if (activeSound != null)
54257 {
54258 activeSound.Position = base.Center;
54259 }
54260 ai[1] += 1f;
54261 int num33 = ((base.Center.X < targetData.Center.X) ? 1 : (-1));
54262 ai[2] = num33;
54263 if (ai[1] < num13)
54264 {
54265 Vector2 vector4 = targetData.Center + new Vector2((float)num33 * (0f - num11), -250f);
54267 if (Distance(vector4) < num12)
54268 {
54269 base.Center = vector4;
54270 }
54271 else
54272 {
54273 position += vector5;
54274 }
54275 if (Vector2.Distance(vector4, base.Center) < 16f)
54276 {
54277 ai[1] = num13 - 1f;
54278 }
54279 num2 = 1.5f;
54280 }
54281 if (ai[1] == num13)
54282 {
54283 int num34 = ((targetData.Center.X > base.Center.X) ? 1 : (-1));
54284 velocity = new Vector2(num34, 0f) * 10f;
54286 if (Main.netMode != 1)
54287 {
54288 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center, velocity, 687, num3, 0f, Main.myPlayer, 0f, whoAmI);
54289 }
54290 float[] array = localAI;
54292 array[2] = ((SlotId)(ref val)).ToFloat();
54293 }
54294 if (ai[1] >= num13)
54295 {
54296 num2 = 1.5f;
54297 if (Math.Abs(targetData.Center.X - base.Center.X) > 550f && Math.Abs(velocity.X) < 20f)
54298 {
54299 velocity.X += (float)Math.Sign(velocity.X) * 0.5f;
54300 }
54301 }
54302 if (ai[1] >= num15)
54303 {
54304 ai[0] = 1f;
54305 ai[1] = 0f;
54306 ai[2] = 0f;
54307 }
54308 }
54309 else if (ai[0] == 4f)
54310 {
54311 int num35 = ((base.Center.X < targetData.Center.X) ? 1 : (-1));
54312 ai[2] = num35;
54313 if (ai[1] < num17)
54314 {
54315 Vector2 vector6 = targetData.Center + new Vector2((float)num35 * (0f - num16), -350f);
54318 int num36 = ((base.Center.X < targetData.Center.X) ? 1 : (-1));
54320 if (Vector2.Distance(vector6, base.Center) < 16f)
54321 {
54322 ai[1] = num17 - 1f;
54323 }
54324 num2 = 1.5f;
54325 }
54326 else if (ai[1] == num17)
54327 {
54328 Vector2 v = DirectionTo(targetData.Center);
54329 v.Y *= 0.25f;
54330 v = v.SafeNormalize(Vector2.UnitX * direction);
54331 spriteDirection = ((v.X > 0f) ? 1 : (-1));
54332 rotation = v.ToRotation();
54333 if (spriteDirection == -1)
54334 {
54335 rotation += (float)Math.PI;
54336 }
54337 velocity = v * num19;
54338 }
54339 else
54340 {
54341 position.X += DirectionTo(targetData.Center).X * 7f;
54342 position.Y += DirectionTo(targetData.Center + new Vector2(0f, -400f)).Y * 6f;
54343 if (ai[1] <= num23 - num22)
54344 {
54345 num2 = 1.5f;
54346 }
54347 float num37 = 30f;
54348 Vector2 vector7 = base.Center + new Vector2((110f + num37) * (float)direction, 20f).RotatedBy(rotation);
54349 int num38 = (int)(ai[1] - num17 + 1f);
54350 if (num38 <= num21 && num38 % num20 == 0 && Main.netMode != 1)
54351 {
54352 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector7, velocity, 686, num4, 0f, Main.myPlayer);
54353 }
54354 }
54355 if (ai[1] > num23 - num22)
54356 {
54357 velocity.Y -= 0.1f;
54358 }
54359 ai[1] += 1f;
54360 if (ai[1] >= num23)
54361 {
54362 ai[0] = 1f;
54363 ai[1] = 0f;
54364 ai[2] = 0f;
54365 }
54366 }
54367 else if (ai[0] == 5f)
54368 {
54369 velocity = velocity.RotatedBy((0f - num26) * (float)direction);
54370 position.Y -= num27;
54371 position += DirectionTo(targetData.Center) * 10f;
54372 rotation -= num26 * (float)direction;
54373 num2 *= 0.7f;
54374 if (ai[1] == 1f)
54375 {
54377 }
54378 if ((ai[1] += 1f) >= num24)
54379 {
54380 ai[0] = 1f;
54381 ai[1] = 0f;
54382 ai[2] = 0f;
54383 velocity /= 2f;
54384 }
54385 }
54386 else if (ai[0] == 6f)
54387 {
54388 if (ai[1] == 0f)
54389 {
54390 Vector2 destination2 = targetData.Center + new Vector2(0f, -200f);
54393 int num39 = ((base.Center.X < targetData.Center.X) ? 1 : (-1));
54395 ai[2] += 1f;
54396 if (Distance(targetData.Center) < 350f || ai[2] >= 180f)
54397 {
54398 ai[1] = 1f;
54399 netUpdate = true;
54400 }
54401 }
54402 else
54403 {
54404 if (ai[1] == 1f)
54405 {
54407 }
54408 if (ai[1] < num30)
54409 {
54410 velocity *= 0.95f;
54411 }
54412 else
54413 {
54414 velocity *= 0.98f;
54415 }
54416 if (ai[1] == num30)
54417 {
54418 if (velocity.Y > 0f)
54419 {
54420 velocity.Y /= 3f;
54421 }
54422 velocity.Y -= 3f;
54423 }
54424 num2 *= 0.85f;
54425 if (ai[1] == 20f || ai[1] == 25f || ai[1] == 30f)
54426 {
54427 Point point = base.Center.ToTileCoordinates();
54428 int num40 = 30;
54429 int num41 = 35;
54430 int num42 = 4;
54431 for (int i = point.X - num40; i <= point.X + num40; i++)
54432 {
54433 bool flag = false;
54434 for (int j = point.Y - num41 / 3; j < point.Y + num41; j++)
54435 {
54436 Tile tileSafely = Framing.GetTileSafely(i, j);
54437 bool flag2 = tileSafely.active() && Main.tileSolid[tileSafely.type] && !Main.tileFrameImportant[tileSafely.type];
54438 if (flag && flag2)
54439 {
54440 int num43 = WorldGen.KillTile_GetTileDustAmount(fail: true, tileSafely);
54441 for (int k = 0; k < num43; k++)
54442 {
54443 Dust obj = Main.dust[WorldGen.KillTile_MakeTileDust(i, j, tileSafely)];
54444 obj.velocity.Y -= 3f + (float)num42 * 1.5f;
54445 obj.velocity.Y *= Main.rand.NextFloat();
54446 obj.scale += (float)num42 * 0.03f;
54447 }
54448 for (int l = 0; l < num43 - 1; l++)
54449 {
54450 Dust obj2 = Main.dust[WorldGen.KillTile_MakeTileDust(i, j, tileSafely)];
54451 obj2.velocity.Y -= 1f + (float)num42;
54452 obj2.velocity.Y *= Main.rand.NextFloat();
54453 }
54454 if (num43 > 0 && Main.rand.Next(3) != 0)
54455 {
54456 float num44 = Math.Abs(point.X - i) / (num40 / 2);
54457 Gore gore = Gore.NewGoreDirect(position, Vector2.Zero, 61 + Main.rand.Next(3), 1f - (float)num42 * 0.15f + num44 * 0.5f);
54458 gore.velocity.Y -= 0.1f + (float)num42 * 0.5f + num44 * (float)num42 * 1f;
54459 gore.velocity.Y *= Main.rand.NextFloat();
54460 gore.position = new Vector2(i * 16 + 20, j * 16 + 20);
54461 }
54462 }
54463 flag = !flag2;
54464 }
54465 }
54466 }
54467 bool flag3 = ai[1] == 20f || ai[1] == 45f || ai[1] == 70f;
54468 if (CountNPCS(560) > 4)
54469 {
54470 flag3 = false;
54471 }
54472 if (flag3 && Main.netMode != 1)
54473 {
54474 for (int m = 0; m < 1; m++)
54475 {
54476 Vector2 vector8 = base.Center + ((float)Math.PI * 2f * Main.rand.NextFloat()).ToRotationVector2() * new Vector2(2f, 1f) * 300f * (0.6f + Main.rand.NextFloat() * 0.4f);
54477 if (Vector2.Distance(vector8, targetData.Center) > 100f)
54478 {
54479 Point point2 = vector8.ToPoint();
54482 }
54483 }
54484 List<NPC> list = new List<NPC>();
54485 for (int n = 0; n < 200; n++)
54486 {
54487 NPC nPC = Main.npc[n];
54488 if (nPC.active && nPC.type == 549)
54489 {
54490 list.Add(nPC);
54491 }
54492 }
54493 if (list.Count > 0)
54494 {
54495 for (int num45 = 0; num45 < 3; num45++)
54496 {
54497 NPC nPC2 = list[Main.rand.Next(list.Count)];
54498 Point point3 = nPC2.Center.ToPoint();
54501 }
54502 }
54503 }
54504 ai[1] += 1f;
54505 }
54506 if (ai[1] >= num29)
54507 {
54508 ai[0] = 1f;
54509 ai[1] = 0f;
54510 ai[2] = 0f;
54511 }
54512 }
54513 localAI[0] += num2;
54514 if (localAI[0] >= 36f)
54515 {
54516 localAI[0] = 0f;
54517 }
54518 if (num != -1)
54519 {
54520 localAI[0] = num * 4;
54521 }
54522 if ((localAI[1] += 1f) >= 60f)
54523 {
54524 localAI[1] = 0f;
54525 }
54526 float num46 = DirectionTo(targetData.Center).ToRotation();
54527 float num47 = 0.04f;
54528 switch ((int)ai[0])
54529 {
54530 case 2:
54531 case 5:
54532 num47 = 0f;
54533 break;
54534 case 3:
54535 num47 = 0.01f;
54536 num46 = 0f;
54537 if (spriteDirection == -1)
54538 {
54539 num46 -= (float)Math.PI;
54540 }
54541 if (ai[1] >= num13)
54542 {
54543 num46 += (float)spriteDirection * (float)Math.PI / 12f;
54544 num47 = 0.05f;
54545 }
54546 break;
54547 case 4:
54548 num47 = 0.01f;
54549 num46 = (float)Math.PI;
54550 if (spriteDirection == 1)
54551 {
54552 num46 += (float)Math.PI;
54553 }
54554 break;
54555 case 6:
54556 num47 = 0.02f;
54557 num46 = 0f;
54558 if (spriteDirection == -1)
54559 {
54560 num46 -= (float)Math.PI;
54561 }
54562 break;
54563 }
54564 if (spriteDirection == -1)
54565 {
54566 num46 += (float)Math.PI;
54567 }
54568 if (num47 != 0f)
54569 {
54570 rotation = rotation.AngleTowards(num46, num47);
54571 }
54573 {
54574 float[] array2 = localAI;
54575 val = SlotId.Invalid;
54576 array2[2] = ((SlotId)(ref val)).ToFloat();
54577 }
54578 }
void Add(TKey key, TValue value)
static double Abs(double value)
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static SlotId PlayTrackedSound(SoundStyle style, Vector2 position)
static ActiveSound GetActiveSound(SlotId id)
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
static readonly LegacySoundStyle DD2_BetsyScream
Definition SoundID.cs:810
static readonly LegacySoundStyle DD2_BetsyFlameBreath
Definition SoundID.cs:804
static readonly LegacySoundStyle DD2_BetsyFlyingCircleAttack
Definition SoundID.cs:806
static readonly LegacySoundStyle DD2_BetsyWindAttack
Definition SoundID.cs:814
static readonly LegacySoundStyle DD2_BetsySummon
Definition SoundID.cs:812
static int CountNPCS(int Type)
Definition NPC.cs:86664
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
float value
Definition NPC.cs:523
float rotation
Definition NPC.cs:501
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:87546
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
void SimpleFlyMovement(Vector2 desiredVelocity, float moveSpeed)
Definition NPC.cs:69581
bool netUpdate
Definition NPC.cs:507
static void TargetClosestBetsy(NPC searcher, bool faceTarget=true, Vector2? checkPosition=null)
Definition NPCUtils.cs:308
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227
static readonly SlotId Invalid
Definition SlotId.cs:5
static SlotId FromFloat(float value)
Definition SlotId.cs:80

References System.Math.Abs(), Terraria.NPC.ai, System.array, Terraria.NPC.CountNPCS(), Terraria.ID.SoundID.DD2_BetsyFlameBreath, Terraria.ID.SoundID.DD2_BetsyFlyingCircleAttack, Terraria.ID.SoundID.DD2_BetsyScream, Terraria.ID.SoundID.DD2_BetsySummon, Terraria.ID.SoundID.DD2_BetsyWindAttack, System.destination, Terraria.Entity.direction, Terraria.Entity.DirectionTo(), Terraria.Entity.Distance(), Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Main.dust, ReLogic.Utilities.SlotId.FromFloat(), Terraria.Audio.SoundEngine.GetActiveSound(), Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetSpawnSourceForNPCFromNPCAI(), Terraria.NPC.GetTargetData(), Terraria.Framing.GetTileSafely(), ReLogic.Utilities.SlotId.Invalid, Terraria.WorldGen.KillTile_GetTileDustAmount(), Terraria.WorldGen.KillTile_MakeTileDust(), Microsoft.Xna.Framework.Vector2.Lerp(), System.list, Terraria.NPC.localAI, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.Gore.NewGoreDirect(), Terraria.NPC.NewNPC(), Terraria.Projectile.NewProjectile(), Terraria.Main.npc, System.obj, System.Math.PI, Terraria.Audio.SoundEngine.PlayTrackedSound(), Terraria.Entity.position, Terraria.Main.rand, Terraria.NPC.rotation, System.Math.Sign(), Terraria.NPC.SimpleFlyMovement(), Terraria.NPC.spriteDirection, Terraria.Utilities.NPCUtils.TargetClosestBetsy(), Terraria.Main.tileFrameImportant, Terraria.Main.tileSolid, Microsoft.Xna.Framework.Vector2.UnitX, Terraria.NPC.value, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, Terraria.Entity.whoAmI, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Point.Y, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().