From cc203e4864ab7e676ade1927cb35a993a07ef90d Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Thu, 26 Mar 2020 18:55:31 -0400 Subject: [PATCH] dungeon spirit like AI's moved to CalamityAI also Gatling Laser tooltip tweak --- Items/Weapons/DraedonsArsenal/GatlingLaser.cs | 2 +- NPCs/CalamityAI.cs | 43 +++++++++++++++++++ NPCs/Leviathan/Parasea.cs | 19 ++------ NPCs/NormalNPCs/PhantomSpirit.cs | 22 +++------- NPCs/NormalNPCs/PhantomSpiritL.cs | 22 +++------- NPCs/NormalNPCs/PhantomSpiritM.cs | 22 +++------- NPCs/NormalNPCs/PhantomSpiritS.cs | 22 +++------- NPCs/Signus/CosmicLantern.cs | 29 +------------ NPCs/Yharon/DetonatingFlare2.cs | 28 +++++------- 9 files changed, 83 insertions(+), 126 deletions(-) diff --git a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs index 930d381eb3..8863904480 100644 --- a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs +++ b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal { DisplayName.SetDefault("Gatling Laser"); Tooltip.SetDefault("Large laser cannon used primarily by Yharim's fleet and base defense force\n" + - "Incredibly accurate, but lacks the power to punch through defensive targets"); + "Somewhat inaccurate, but has the power to punch through defensive targets"); } public override void SetDefaults() diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 07d8e236bc..0eaaac1472 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -5680,5 +5680,48 @@ namespace CalamityMod.NPCs } } #endregion + + #region Dungeon Spirit AI + public static void DungeonSpiritAI(NPC npc, Mod mod, float speed, float rotation, bool lantern = false) + { + npc.TargetClosest(true); + Vector2 vector145 = new Vector2(npc.Center.X, npc.Center.Y); + float num1258 = Main.player[npc.target].Center.X - vector145.X; + float num1259 = Main.player[npc.target].Center.Y - vector145.Y; + float num1260 = (float)Math.Sqrt((double)(num1258 * num1258 + num1259 * num1259)); + float num1261 = speed; + + if (lantern) + { + if (npc.localAI[0] < 85f) + { + num1261 = 0.1f; + num1260 = num1261 / num1260; + num1258 *= num1260; + num1259 *= num1260; + npc.velocity = (npc.velocity * 100f + new Vector2(num1258, num1259)) / 101f; + npc.localAI[0] += 1f; + return; + } + + npc.dontTakeDamage = false; + npc.chaseable = true; + } + + num1260 = num1261 / num1260; + num1258 *= num1260; + num1259 *= num1260; + npc.velocity.X = (npc.velocity.X * 100f + num1258) / 101f; + npc.velocity.Y = (npc.velocity.Y * 100f + num1259) / 101f; + + if (lantern) + { + npc.rotation = npc.velocity.X * 0.08f; + npc.spriteDirection = (npc.direction > 0) ? 1 : -1; + } + else + npc.rotation = (float)Math.Atan2((double)num1259, (double)num1258) + rotation; + } + #endregion } } diff --git a/NPCs/Leviathan/Parasea.cs b/NPCs/Leviathan/Parasea.cs index 3c6ddcc5a3..d4f460208b 100644 --- a/NPCs/Leviathan/Parasea.cs +++ b/NPCs/Leviathan/Parasea.cs @@ -40,22 +40,11 @@ namespace CalamityMod.NPCs.Leviathan public override void AI() { - bool revenge = CalamityWorld.revenge; - npc.TargetClosest(true); - Vector2 vector145 = new Vector2(npc.Center.X, npc.Center.Y); - float num1258 = Main.player[npc.target].Center.X - vector145.X; - float num1259 = Main.player[npc.target].Center.Y - vector145.Y; - float num1260 = (float)Math.Sqrt((double)(num1258 * num1258 + num1259 * num1259)); - float num1261 = revenge ? 16f : 13f; + bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; + float speed = revenge ? 16f : 13f; if (CalamityWorld.bossRushActive) - num1261 = 24f; - - num1260 = num1261 / num1260; - num1258 *= num1260; - num1259 *= num1260; - npc.velocity.X = (npc.velocity.X * 100f + num1258) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + num1259) / 101f; - npc.rotation = (float)Math.Atan2((double)num1259, (double)num1258) + 3.14f; + speed = 24f; + CalamityAI.DungeonSpiritAI(npc, mod, speed, MathHelper.Pi); } public override float SpawnChance(NPCSpawnInfo spawnInfo) diff --git a/NPCs/NormalNPCs/PhantomSpirit.cs b/NPCs/NormalNPCs/PhantomSpirit.cs index bed6330751..1a87bcf443 100644 --- a/NPCs/NormalNPCs/PhantomSpirit.cs +++ b/NPCs/NormalNPCs/PhantomSpirit.cs @@ -39,23 +39,13 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - npc.TargetClosest(true); - Vector2 vector102 = new Vector2(npc.Center.X, npc.Center.Y); - float num818 = Main.player[npc.target].Center.X - vector102.X; - float num819 = Main.player[npc.target].Center.Y - vector102.Y; - float num820 = (float)Math.Sqrt((double)(num818 * num818 + num819 * num819)); - float num821 = CalamityWorld.death ? 22f : 17f; - num820 = num821 / num820; - num818 *= num820; - num819 *= num820; - npc.velocity.X = (npc.velocity.X * 100f + num818) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + num819) / 101f; - npc.rotation = (float)Math.Atan2((double)num819, (double)num818) - 1.57f; + float speed = CalamityWorld.death ? 22f : 17f; + CalamityAI.DungeonSpiritAI(npc, mod, speed, -MathHelper.PiOver2); int num822 = Dust.NewDust(npc.position, npc.width, npc.height, 60, 0f, 0f, 0, default, 1f); Dust dust = Main.dust[num822]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; + dust.scale = 1.3f; + dust.noGravity = true; } public override void OnHitPlayer(Player player, int damage, bool crit) @@ -79,8 +69,8 @@ namespace CalamityMod.NPCs.NormalNPCs int num289 = Dust.NewDust(npc.position, npc.width, npc.height, 60, npc.velocity.X, npc.velocity.Y, 0, default, 1f); Dust dust = Main.dust[num289]; dust.velocity *= 2f; - Main.dust[num289].noGravity = true; - Main.dust[num289].scale = 1.4f; + dust.noGravity = true; + dust.scale = 1.4f; } } } diff --git a/NPCs/NormalNPCs/PhantomSpiritL.cs b/NPCs/NormalNPCs/PhantomSpiritL.cs index 8ade910dd9..aadd91eebb 100644 --- a/NPCs/NormalNPCs/PhantomSpiritL.cs +++ b/NPCs/NormalNPCs/PhantomSpiritL.cs @@ -48,23 +48,13 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - npc.TargetClosest(true); - Vector2 vector102 = new Vector2(npc.Center.X, npc.Center.Y); - float num818 = Main.player[npc.target].Center.X - vector102.X; - float num819 = Main.player[npc.target].Center.Y - vector102.Y; - float num820 = (float)Math.Sqrt((double)(num818 * num818 + num819 * num819)); - float num821 = CalamityWorld.death ? 16f : 12f; - num820 = num821 / num820; - num818 *= num820; - num819 *= num820; - npc.velocity.X = (npc.velocity.X * 100f + num818) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + num819) / 101f; - npc.rotation = (float)Math.Atan2((double)num819, (double)num818) - 1.57f; + float speed = CalamityWorld.death ? 16f : 12f; + CalamityAI.DungeonSpiritAI(npc, mod, speed, -MathHelper.PiOver2); int num822 = Dust.NewDust(npc.position, npc.width, npc.height, 60, 0f, 0f, 0, default, 1f); Dust dust = Main.dust[num822]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; + dust.scale = 1.3f; + dust.noGravity = true; Vector2 vector17 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num147 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector17.X; float num148 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector17.Y; @@ -126,8 +116,8 @@ namespace CalamityMod.NPCs.NormalNPCs int num289 = Dust.NewDust(npc.position, npc.width, npc.height, 60, npc.velocity.X, npc.velocity.Y, 0, default, 1f); Dust dust = Main.dust[num289]; dust.velocity *= 2f; - Main.dust[num289].noGravity = true; - Main.dust[num289].scale = 1.4f; + dust.noGravity = true; + dust.scale = 1.4f; } } } diff --git a/NPCs/NormalNPCs/PhantomSpiritM.cs b/NPCs/NormalNPCs/PhantomSpiritM.cs index 0a93a3ed35..b87a1d4903 100644 --- a/NPCs/NormalNPCs/PhantomSpiritM.cs +++ b/NPCs/NormalNPCs/PhantomSpiritM.cs @@ -47,23 +47,13 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - npc.TargetClosest(true); - Vector2 vector102 = new Vector2(npc.Center.X, npc.Center.Y); - float num818 = Main.player[npc.target].Center.X - vector102.X; - float num819 = Main.player[npc.target].Center.Y - vector102.Y; - float num820 = (float)Math.Sqrt((double)(num818 * num818 + num819 * num819)); - float num821 = CalamityWorld.death ? 18f : 13.5f; - num820 = num821 / num820; - num818 *= num820; - num819 *= num820; - npc.velocity.X = (npc.velocity.X * 100f + num818) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + num819) / 101f; - npc.rotation = (float)Math.Atan2((double)num819, (double)num818) - 1.57f; + float speed = CalamityWorld.death ? 18f : 13.5f; + CalamityAI.DungeonSpiritAI(npc, mod, speed, -MathHelper.PiOver2); int num822 = Dust.NewDust(npc.position, npc.width, npc.height, 60, 0f, 0f, 0, default, 1f); Dust dust = Main.dust[num822]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; + dust.scale = 1.3f; + dust.noGravity = true; return; } @@ -88,8 +78,8 @@ namespace CalamityMod.NPCs.NormalNPCs int num289 = Dust.NewDust(npc.position, npc.width, npc.height, 60, npc.velocity.X, npc.velocity.Y, 0, default, 1f); Dust dust = Main.dust[num289]; dust.velocity *= 2f; - Main.dust[num289].noGravity = true; - Main.dust[num289].scale = 1.4f; + dust.noGravity = true; + dust.scale = 1.4f; } } } diff --git a/NPCs/NormalNPCs/PhantomSpiritS.cs b/NPCs/NormalNPCs/PhantomSpiritS.cs index ef2269ed0c..59fb3ebd52 100644 --- a/NPCs/NormalNPCs/PhantomSpiritS.cs +++ b/NPCs/NormalNPCs/PhantomSpiritS.cs @@ -46,23 +46,13 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - npc.TargetClosest(true); - Vector2 vector102 = new Vector2(npc.Center.X, npc.Center.Y); - float num818 = Main.player[npc.target].Center.X - vector102.X; - float num819 = Main.player[npc.target].Center.Y - vector102.Y; - float num820 = (float)Math.Sqrt((double)(num818 * num818 + num819 * num819)); - float num821 = CalamityWorld.death ? 20f : 15f; - num820 = num821 / num820; - num818 *= num820; - num819 *= num820; - npc.velocity.X = (npc.velocity.X * 100f + num818) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + num819) / 101f; - npc.rotation = (float)Math.Atan2((double)num819, (double)num818) - 1.57f; + float speed = CalamityWorld.death ? 20f : 15f; + CalamityAI.DungeonSpiritAI(npc, mod, speed, -MathHelper.PiOver2); int num822 = Dust.NewDust(npc.position, npc.width, npc.height, 60, 0f, 0f, 0, default, 1f); Dust dust = Main.dust[num822]; dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; + dust.scale = 1.3f; + dust.noGravity = true; } public override void OnHitPlayer(Player player, int damage, bool crit) @@ -86,8 +76,8 @@ namespace CalamityMod.NPCs.NormalNPCs int num289 = Dust.NewDust(npc.position, npc.width, npc.height, 60, npc.velocity.X, npc.velocity.Y, 0, default, 1f); Dust dust = Main.dust[num289]; dust.velocity *= 2f; - Main.dust[num289].noGravity = true; - Main.dust[num289].scale = 1.4f; + dust.noGravity = true; + dust.scale = 1.4f; } } } diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index babbc87b92..14f11d46ba 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -78,38 +78,11 @@ namespace CalamityMod.NPCs.Signus Main.dust[num1262].noGravity = true; } - npc.rotation = npc.velocity.X * 0.08f; - npc.spriteDirection = (npc.direction > 0) ? 1 : -1; - npc.TargetClosest(true); - bool revenge = CalamityWorld.revenge; float playerDistNormMult = revenge ? 24f : 22f; if (CalamityWorld.bossRushActive) playerDistNormMult = 30f; - - Vector2 vector145 = new Vector2(npc.Center.X, npc.Center.Y); - float playerDistX = Main.player[npc.target].Center.X - vector145.X; - float playerDistY = Main.player[npc.target].Center.Y - vector145.Y; - float playerDistMagnitude = (float)Math.Sqrt((double)(playerDistX * playerDistX + playerDistY * playerDistY)); - - if (npc.localAI[0] < 85f) - { - playerDistNormMult = 0.1f; - playerDistMagnitude = playerDistNormMult / playerDistMagnitude; - playerDistX *= playerDistMagnitude; - playerDistY *= playerDistMagnitude; - npc.velocity = (npc.velocity * 100f + new Vector2(playerDistX, playerDistY)) / 101f; - npc.localAI[0] += 1f; - return; - } - - npc.dontTakeDamage = false; - npc.chaseable = true; - - playerDistMagnitude = playerDistNormMult / playerDistMagnitude; - playerDistX *= playerDistMagnitude; - playerDistY *= playerDistMagnitude; - npc.velocity = (npc.velocity * 100f + new Vector2(playerDistX, playerDistY)) / 101f; + CalamityAI.DungeonSpiritAI(npc, mod, playerDistNormMult, 0f, true); } public override void OnHitPlayer(Player player, int damage, bool crit) diff --git a/NPCs/Yharon/DetonatingFlare2.cs b/NPCs/Yharon/DetonatingFlare2.cs index d930629757..8360e9a878 100644 --- a/NPCs/Yharon/DetonatingFlare2.cs +++ b/NPCs/Yharon/DetonatingFlare2.cs @@ -37,45 +37,37 @@ namespace CalamityMod.NPCs.Yharon public override void AI() { - bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; npc.alpha -= 3; - npc.TargetClosest(true); - Vector2 vector98 = new Vector2(npc.Center.X, npc.Center.Y); - float num790 = Main.player[npc.target].Center.X - vector98.X; - float num791 = Main.player[npc.target].Center.Y - vector98.Y; - float num792 = (float)Math.Sqrt((double)(num790 * num790 + num791 * num791)); + bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; + float randomSpeed = 10f; if (npc.localAI[3] == 0f) { switch (Main.rand.Next(6)) { case 0: - speed = 10f; + randomSpeed = 10f; break; case 1: speed = 11.5f; + randomSpeed = 11.5f; break; case 2: - speed = 13f; + randomSpeed = 13f; break; case 3: - speed = 14.5f; + randomSpeed = 14.5f; break; case 4: - speed = 16f; + randomSpeed = 16f; break; case 5: - speed = 17.5f; + randomSpeed = 17.5f; break; } npc.localAI[3] = 1f; } - float num793 = speed + (revenge ? 1f : 0f); - num792 = num793 / num792; - num790 *= num792; - num791 *= num792; - npc.velocity.X = (npc.velocity.X * 100f + num790) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + num791) / 101f; - npc.rotation = (float)Math.Atan2((double)num791, (double)num790) - 1.57f; + float speed = randomSpeed + (revenge ? 1f : 0f); + CalamityAI.DungeonSpiritAI(npc, mod, speed, -MathHelper.PiOver2); } public override Color? GetAlpha(Color drawColor)