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

◆ AI_123_Deerclops()

void Terraria.NPC.AI_123_Deerclops ( )
inlineprivate

Definition at line 37141 of file NPC.cs.

37142 {
37144 int num = 15;
37146 bool haltMovement = false;
37147 bool goHome = false;
37148 bool flag = Distance(targetData.Center) >= 450f;
37149 localAI[3] = MathHelper.Clamp(localAI[3] + (float)flag.ToDirectionInt(), 0f, 30f);
37150 dontTakeDamage = localAI[3] >= 30f;
37151 float lifePercent = (float)life / (float)lifeMax;
37152 bool expertMode = Main.expertMode;
37153 int shadowHandDamage = 10;
37154 float num2 = Utils.Remap(localAI[3], 0f, 30f, 0f, 1f);
37155 if (num2 > 0f)
37156 {
37157 float num3 = Main.rand.NextFloat() * num2 * 3f;
37158 while (num3 > 0f)
37159 {
37160 num3 -= 1f;
37161 Dust.NewDustDirect(position, width, height, 109, 0f, -3f, 0, default(Color), 1.4f).noGravity = true;
37162 }
37163 }
37164 if (homeTileX == -1 && homeTileY == -1)
37165 {
37166 Point point = base.Bottom.ToTileCoordinates();
37167 homeTileX = point.X;
37168 homeTileY = point.Y;
37169 this.ai[2] = homeTileX;
37170 this.ai[3] = homeTileY;
37171 netUpdate = true;
37172 timeLeft = 86400;
37173 }
37174 timeLeft -= Main.dayRate;
37175 if (timeLeft < 0)
37176 {
37177 timeLeft = 0;
37178 }
37179 homeTileX = (int)this.ai[2];
37180 homeTileY = (int)this.ai[3];
37181 if (!expertMode)
37182 {
37183 localAI[2] = 0f;
37184 }
37185 if (expertMode && Main.netMode != 1)
37186 {
37188 }
37189 switch ((int)this.ai[0])
37190 {
37191 case -1:
37192 localAI[3] = -10f;
37193 break;
37194 case 6:
37195 {
37198 if (Main.netMode != 1)
37199 {
37201 {
37202 this.ai[0] = 0f;
37203 this.ai[1] = 0f;
37204 localAI[1] = 0f;
37205 netUpdate = true;
37206 break;
37207 }
37208 if (timeLeft <= 0)
37209 {
37210 this.ai[0] = 8f;
37211 this.ai[1] = 0f;
37212 localAI[1] = 0f;
37213 netUpdate = true;
37214 break;
37215 }
37216 }
37217 if (direction != oldDirection)
37218 {
37219 netUpdate = true;
37220 }
37221 goHome = true;
37222 this.ai[1] += 1f;
37223 Vector2 other = new Vector2(homeTileX * 16, homeTileY * 16);
37224 bool flag2 = base.Top.Y > other.Y + 1600f;
37225 bool num4 = Distance(other) < 1020f;
37226 Distance(targetData.Center);
37227 float num5 = this.ai[1] % 600f;
37228 if (num4 && num5 < 420f)
37229 {
37230 haltMovement = true;
37231 }
37232 bool flag3 = false;
37233 int num6 = 300;
37234 if (flag2 && this.ai[1] >= (float)num6)
37235 {
37236 flag3 = true;
37237 }
37238 int num7 = 1500;
37239 if (!num4 && this.ai[1] >= (float)num7)
37240 {
37241 flag3 = true;
37242 }
37243 if (flag3)
37244 {
37245 this.ai[0] = 7f;
37246 this.ai[1] = 0f;
37247 localAI[1] = 0f;
37248 netUpdate = true;
37249 }
37250 break;
37251 }
37252 case 0:
37253 {
37254 TargetClosest();
37257 {
37258 this.ai[0] = 6f;
37259 this.ai[1] = 0f;
37260 localAI[1] = 0f;
37261 netUpdate = true;
37262 break;
37263 }
37264 this.ai[1] += 1f;
37265 Vector2 vector = base.Bottom + new Vector2(0f, -32f);
37266 Vector2 vector2 = targetData.Hitbox.ClosestPointInRect(vector);
37268 (vector2 - base.Center).Length();
37269 float num15 = 0.6f;
37270 bool flag4 = Math.Abs(vector3.X) >= Math.Abs(vector3.Y) * num15 || vector3.Length() < 48f;
37271 bool flag5 = vector3.Y <= (float)(100 + targetData.Height) && vector3.Y >= -200f;
37272 if (Math.Abs(vector3.X) < 120f && flag5 && velocity.Y == 0f && localAI[1] >= 2f)
37273 {
37274 velocity.X = 0f;
37275 this.ai[0] = 4f;
37276 this.ai[1] = 0f;
37277 localAI[1] = 0f;
37278 netUpdate = true;
37279 break;
37280 }
37281 if (Math.Abs(vector3.X) < 120f && flag5 && velocity.Y == 0f && flag4)
37282 {
37283 velocity.X = 0f;
37284 this.ai[0] = 1f;
37285 this.ai[1] = 0f;
37286 localAI[1] += 1f;
37287 netUpdate = true;
37288 break;
37289 }
37290 bool flag6 = this.ai[1] >= 240f;
37291 if (velocity.Y == 0f && velocity.X != 0f && flag6)
37292 {
37293 velocity.X = 0f;
37294 this.ai[0] = 2f;
37295 this.ai[1] = 0f;
37296 localAI[1] = 0f;
37297 netUpdate = true;
37298 break;
37299 }
37300 bool flag7 = this.ai[1] >= 90f;
37301 if (velocity.Y == 0f && velocity.X == 0f && flag7)
37302 {
37303 velocity.X = 0f;
37304 this.ai[0] = 5f;
37305 this.ai[1] = 0f;
37306 localAI[1] = 0f;
37307 netUpdate = true;
37308 break;
37309 }
37310 bool flag8 = this.ai[1] >= 120f;
37311 int num16 = 32;
37312 bool flag9 = targetData.Type == NPCTargetType.Player && !Main.player[target].buffImmune[num16] && Main.player[target].FindBuffIndex(num16) == -1;
37313 if (velocity.Y == 0f && flag8 && flag9 && Math.Abs(vector3.X) > 100f)
37314 {
37315 velocity.X = 0f;
37316 this.ai[0] = 3f;
37317 this.ai[1] = 0f;
37318 localAI[1] = 0f;
37319 netUpdate = true;
37320 }
37321 break;
37322 }
37323 case 1:
37324 this.ai[1] += 1f;
37325 haltMovement = true;
37327 if (this.ai[1] >= 80f)
37328 {
37329 this.ai[0] = 0f;
37330 this.ai[1] = 0f;
37331 netUpdate = true;
37332 }
37333 break;
37334 case 4:
37335 this.ai[1] += 1f;
37336 haltMovement = true;
37337 TargetClosest();
37339 if (this.ai[1] >= 90f)
37340 {
37341 this.ai[0] = 0f;
37342 this.ai[1] = 0f;
37343 netUpdate = true;
37344 }
37345 break;
37346 case 2:
37347 {
37348 int num8 = 4;
37349 int num9 = 8 * num8;
37350 this.ai[1] += 1f;
37351 if (this.ai[1] == (float)(num9 - 20))
37352 {
37354 }
37355 if (this.ai[1] == (float)num9)
37356 {
37358 }
37359 haltMovement = true;
37360 if (Main.netMode != 1 && this.ai[1] >= (float)num9)
37361 {
37362 Point sourceTileCoords = base.Top.ToTileCoordinates();
37363 int num10 = 20;
37365 float upBiasPerSpike = 200f;
37366 sourceTileCoords.X += direction * 3;
37367 sourceTileCoords.Y -= 10;
37368 int num11 = (int)this.ai[1] - num9;
37369 if (num11 == 0)
37370 {
37371 PunchCameraModifier modifier4 = new PunchCameraModifier(base.Center, new Vector2(0f, -1f), 20f, 6f, 30, 1000f, "Deerclops");
37372 Main.instance.CameraModifiers.Add(modifier4);
37373 }
37374 int num12 = 1;
37375 int num13 = num11 / num12 * num12;
37376 int num14 = num13 + num12;
37377 if (num11 % num12 != 0)
37378 {
37379 num14 = num13;
37380 }
37381 for (int j = num13; j < num14 && j < num10; j++)
37382 {
37384 }
37385 }
37386 if (this.ai[1] >= 60f)
37387 {
37388 this.ai[0] = 0f;
37389 this.ai[1] = 0f;
37390 netUpdate = true;
37391 }
37392 break;
37393 }
37394 case 3:
37395 if (this.ai[1] == 30f)
37396 {
37398 }
37399 this.ai[1] += 1f;
37400 haltMovement = true;
37401 if ((int)this.ai[1] % 4 == 0 && this.ai[1] >= 28f)
37402 {
37403 PunchCameraModifier modifier5 = new PunchCameraModifier(base.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops");
37404 Main.instance.CameraModifiers.Add(modifier5);
37405 if (Main.netMode != 2)
37406 {
37407 Player player = Main.player[Main.myPlayer];
37408 _ = Main.myPlayer;
37409 int num17 = 32;
37410 int timeToAdd = 720;
37411 if (!player.dead && player.active && player.FindBuffIndex(num17) == -1 && (player.Center - base.Center).Length() < 800f && !player.creativeGodMode)
37412 {
37413 player.AddBuff(num17, timeToAdd);
37414 }
37415 }
37416 }
37417 if (this.ai[1] == 30f)
37418 {
37419 TargetClosest();
37420 }
37421 if (this.ai[1] >= 60f)
37422 {
37423 this.ai[0] = 0f;
37424 this.ai[1] = 0f;
37425 netUpdate = true;
37426 }
37427 break;
37428 case 7:
37429 if (this.ai[1] == 30f)
37430 {
37432 }
37433 this.ai[1] += 1f;
37434 haltMovement = true;
37435 if ((int)this.ai[1] % 4 == 0 && this.ai[1] >= 28f)
37436 {
37437 PunchCameraModifier modifier3 = new PunchCameraModifier(base.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops");
37438 Main.instance.CameraModifiers.Add(modifier3);
37439 }
37440 if (this.ai[1] == 40f)
37441 {
37442 TargetClosest();
37443 if (Main.netMode != 1)
37444 {
37445 netUpdate = true;
37446 base.Bottom = new Vector2(homeTileX * 16, homeTileY * 16);
37447 }
37448 }
37449 if (this.ai[1] >= 60f)
37450 {
37451 this.ai[0] = 0f;
37452 this.ai[1] = 0f;
37453 netUpdate = true;
37454 }
37455 break;
37456 case 8:
37457 if (this.ai[1] == 30f)
37458 {
37460 }
37461 this.ai[1] += 1f;
37462 haltMovement = true;
37463 if ((int)this.ai[1] % 4 == 0 && this.ai[1] >= 28f)
37464 {
37465 PunchCameraModifier modifier2 = new PunchCameraModifier(base.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops");
37466 Main.instance.CameraModifiers.Add(modifier2);
37467 }
37468 if (this.ai[1] >= 40f)
37469 {
37470 life = -1;
37471 HitEffect();
37472 active = false;
37473 if (Main.netMode != 1)
37474 {
37475 NetMessage.SendData(28, -1, -1, null, whoAmI, -1f);
37476 }
37477 return;
37478 }
37479 break;
37480 case 5:
37481 if (this.ai[1] == 30f)
37482 {
37484 }
37485 this.ai[1] += 1f;
37486 haltMovement = true;
37487 if ((int)this.ai[1] % 4 == 0 && this.ai[1] >= 28f)
37488 {
37489 PunchCameraModifier modifier = new PunchCameraModifier(base.Center, (Main.rand.NextFloat() * ((float)Math.PI * 2f)).ToRotationVector2(), 20f, 6f, 20, 1000f, "Deerclops");
37490 Main.instance.CameraModifiers.Add(modifier);
37491 }
37492 if (this.ai[1] == 30f)
37493 {
37494 TargetClosest();
37495 if (Main.netMode != 1)
37496 {
37497 for (int i = 0; i < 6; i++)
37498 {
37499 Projectile.RandomizeInsanityShadowFor(Main.player[target], isHostile: true, out var spawnposition, out var spawnvelocity, out var ai, out var ai2);
37500 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), spawnposition, spawnvelocity, 965, num, 0f, Main.myPlayer, ai, ai2);
37501 }
37502 }
37503 }
37504 if (this.ai[1] >= 60f)
37505 {
37506 this.ai[0] = 0f;
37507 this.ai[1] = 0f;
37508 netUpdate = true;
37509 }
37510 break;
37511 }
37513 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static double Abs(double value)
const double PI
Definition Math.cs:16
static void PlaySound(int type, Vector2 position, int style=1)
int oldDirection
Definition Entity.cs:22
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
static readonly LegacySoundStyle DeerclopsRubbleAttack
Definition SoundID.cs:968
static readonly LegacySoundStyle DeerclopsScream
Definition SoundID.cs:964
int timeLeft
Definition NPC.cs:457
float[] localAI
Definition NPC.cs:449
int lifeMax
Definition NPC.cs:479
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
void AI_123_Deerclops_Movement(bool haltMovement, bool goHome)
Definition NPC.cs:37760
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:864
bool noGravity
Definition NPC.cs:503
float[] ai
Definition NPC.cs:447
int homeTileX
Definition NPC.cs:543
bool dontTakeDamage
Definition NPC.cs:527
void SpawnPassiveShadowHands(float lifePercent, int shadowHandDamage)
Definition NPC.cs:37533
static int deerclopsBoss
Definition NPC.cs:167
void HitEffect(int hitDirection=0, double dmg=10.0)
Definition NPC.cs:78386
bool ShouldRunAway(ref NPCAimedTarget targetData, bool isChasing)
Definition NPC.cs:37515
int life
Definition NPC.cs:477
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
void AI_123_Deerclops_MakeSpikesForward(int AISLOT_PhaseCounter, NPCAimedTarget targetData)
Definition NPC.cs:37579
void AI_123_Deerclops_ShootRubbleUp(ref NPCAimedTarget targetData, ref Point sourceTileCoords, int howMany, int distancedByThisManyTiles, float upBiasPerSpike, int whichOne)
Definition NPC.cs:37557
bool netUpdate
Definition NPC.cs:507
void AI_123_Deerclops_MakeSpikesBothSides(int AISLOT_PhaseCounter, NPCAimedTarget targetData)
Definition NPC.cs:37615
int target
Definition NPC.cs:459
int homeTileY
Definition NPC.cs:545

References System.Math.Abs(), Terraria.Entity.active, Terraria.Player.AddBuff(), Terraria.NPC.ai, Terraria.NPC.AI_123_Deerclops_MakeSpikesBothSides(), Terraria.NPC.AI_123_Deerclops_MakeSpikesForward(), Terraria.NPC.AI_123_Deerclops_Movement(), Terraria.NPC.AI_123_Deerclops_ShootRubbleUp(), Terraria.Entity.Center, Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.Player.creativeGodMode, Terraria.Main.dayRate, Terraria.Player.dead, Terraria.NPC.deerclopsBoss, Terraria.ID.SoundID.DeerclopsRubbleAttack, Terraria.ID.SoundID.DeerclopsScream, Terraria.Entity.direction, Terraria.Entity.Distance(), Terraria.NPC.dontTakeDamage, Terraria.Main.expertMode, Terraria.Player.FindBuffIndex(), Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetTargetData(), Terraria.Entity.height, Terraria.NPC.HitEffect(), Terraria.NPC.homeTileX, Terraria.NPC.homeTileY, Terraria.Main.instance, Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.NPC.localAI, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.Dust.NewDustDirect(), Terraria.Projectile.NewProjectile(), Terraria.NPC.noGravity, Terraria.Entity.oldDirection, System.other, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.rand, Terraria.Projectile.RandomizeInsanityShadowFor(), Terraria.Utils.Remap(), Terraria.NetMessage.SendData(), Terraria.NPC.ShouldRunAway(), Terraria.NPC.SpawnPassiveShadowHands(), Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.NPC.timeLeft, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, Terraria.Entity.whoAmI, Terraria.Entity.width, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Point.Y, and Microsoft.Xna.Framework.Vector2.Y.

Referenced by Terraria.NPC.AI().