From 21bdfe65d03b68f300ccdd3292c4f589dac40bae Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Tue, 23 Jun 2020 12:42:07 -0500 Subject: [PATCH] 1 - Iron Heart adjustments. 2 - Astral enemies no longer spawn if an event is going on. 3 - Butterfly nerf. --- CalPlayer/CalamityPlayer.cs | 36 ++++++++++++++++------ CalPlayer/CalamityPlayerLifeRegen.cs | 2 +- Items/DifficultyItems/IronHeart.cs | 34 +++++++++----------- NPCs/Astral/Aries.cs | 2 +- NPCs/Astral/AstralProbe.cs | 2 +- NPCs/Astral/AstralSlime.cs | 2 +- NPCs/Astral/AstralachneaGround.cs | 2 +- NPCs/Astral/Atlas.cs | 2 +- NPCs/Astral/BigSightseer.cs | 3 +- NPCs/Astral/EnchantedNightcrawler.cs | 2 +- NPCs/Astral/FusionFeeder.cs | 2 +- NPCs/Astral/Hadarian.cs | 2 +- NPCs/Astral/Hive.cs | 8 +---- NPCs/Astral/Mantis.cs | 27 +++++----------- NPCs/Astral/Nova.cs | 2 +- NPCs/Astral/SmallSightseer.cs | 3 +- NPCs/Astral/StellarCulex.cs | 2 +- NPCs/Astral/Twinkler.cs | 2 +- NPCs/CalamityGlobalNPC.cs | 17 ---------- NPCs/DevourerofGods/DevourerofGodsHead2.cs | 4 +-- NPCs/SupremeCalamitas/SCalWormHead.cs | 6 ++-- Projectiles/Summon/PurpleButterfly.cs | 2 +- Projectiles/Summon/SakuraBullet.cs | 2 +- 23 files changed, 71 insertions(+), 95 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index db804f215d..321eaf30d8 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -4008,7 +4008,7 @@ namespace CalamityMod.CalPlayer { DeathPacket(false); } - if (CalamityWorld.ironHeart && areThereAnyDamnBosses) + if (CalamityWorld.ironHeart) { KillPlayer(); return false; @@ -4047,6 +4047,14 @@ namespace CalamityMod.CalPlayer } #endregion + #region Get Heal Life + public override void GetHealLife(Item item, bool quickHeal, ref int healValue) + { + if (CalamityWorld.ironHeart) + healValue = 0; + } + #endregion + #region Get Weapon Damage And KB public override void ModifyWeaponDamage(Item item, ref float add, ref float mult, ref float flat) { @@ -6940,7 +6948,6 @@ namespace CalamityMod.CalPlayer #endregion #region Frame Effects - public override void FrameEffects() { if (player.Calamity().andromedaState == AndromedaPlayerState.LargeRobot || @@ -7154,6 +7161,20 @@ namespace CalamityMod.CalPlayer damage = (int)newDamage; } + if (CalamityWorld.ironHeart) + { + int damageMin = player.statLifeMax2 / 4; + playSound = false; + hurtSoundTimer = 20; + if (damage < damageMin) + { + damage = damageMin; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/IronHeartHurt"), (int)player.position.X, (int)player.position.Y); + } + else + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/IronHeartBigHurt"), (int)player.position.X, (int)player.position.Y); + } + #region MultiplicativeReductions if (trinketOfChiBuff) { @@ -7870,7 +7891,7 @@ namespace CalamityMod.CalPlayer player.lastDeathPostion = player.Center; player.lastDeathTime = DateTime.Now; player.showLastDeath = true; - bool specialDeath = CalamityWorld.ironHeart && areThereAnyDamnBosses; + bool specialDeath = CalamityWorld.ironHeart; int coinsOwned = (int)Utils.CoinsCount(out bool flag, player.inventory, new int[0]); if (Main.myPlayer == player.whoAmI) { @@ -7884,13 +7905,7 @@ namespace CalamityMod.CalPlayer if (Main.myPlayer == player.whoAmI) { player.trashItem.SetDefaults(0, false); - if (specialDeath) - { - player.difficulty = 2; - player.DropItems(); - player.KillMeForGood(); - } - else if (player.difficulty == 0) + if (player.difficulty == 0) { for (int i = 0; i < 59; i++) { @@ -10381,6 +10396,7 @@ namespace CalamityMod.CalPlayer chatText = "Now is not the time!"; return false; } + return true; } diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index ad9956bef2..5899716584 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -461,7 +461,7 @@ namespace CalamityMod.CalPlayer player.lifeRegen /= 2; } - if (modPlayer.omegaBlueChestplate || modPlayer.godSlayerCooldown || player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + if (CalamityWorld.ironHeart || modPlayer.omegaBlueChestplate || modPlayer.godSlayerCooldown || player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) { if (player.lifeRegen > 0) player.lifeRegen = 0; diff --git a/Items/DifficultyItems/IronHeart.cs b/Items/DifficultyItems/IronHeart.cs index eb3d38a3c2..f8ffeb0442 100644 --- a/Items/DifficultyItems/IronHeart.cs +++ b/Items/DifficultyItems/IronHeart.cs @@ -2,6 +2,7 @@ using CalamityMod.NPCs.SlimeGod; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -13,10 +14,10 @@ namespace CalamityMod.Items.DifficultyItems public override void SetStaticDefaults() { DisplayName.SetDefault("Iron Heart"); - Tooltip.SetDefault("Makes dying while a boss is alive permanently kill you.\n" + + Tooltip.SetDefault("Healing with potions and all life regen is disabled.\n" + + "Enemy damage scales with your max health.\n" + "Can be toggled on and off.\n" + - "Using this while a boss is alive will permanently kill you.\n" + - "Cannot be activated if any boss has been killed."); + "Using this while a boss is alive will instantly kill you and despawn the boss."); } public override void SetDefaults() @@ -32,24 +33,19 @@ namespace CalamityMod.Items.DifficultyItems item.consumable = false; } - public override bool CanUseItem(Player player) - { - return !CalamityWorld.downedBossAny; - } - public override bool UseItem(Player player) { - for (int doom = 0; doom < 200; doom++) - { - if ((Main.npc[doom].active && (Main.npc[doom].boss || Main.npc[doom].type == NPCID.EaterofWorldsHead || Main.npc[doom].type == NPCID.EaterofWorldsTail || Main.npc[doom].type == ModContent.NPCType() || - Main.npc[doom].type == ModContent.NPCType() || Main.npc[doom].type == ModContent.NPCType() || Main.npc[doom].type == ModContent.NPCType())) || CalamityWorld.DoGSecondStageCountdown > 0) - { - player.KillMeForGood(); - Main.npc[doom].active = Main.npc[doom].friendly; - Main.npc[doom].netUpdate = true; - } - } - if (!CalamityWorld.ironHeart) + for (int doom = 0; doom < Main.npc.Length; doom++) + { + if ((Main.npc[doom].active && (Main.npc[doom].boss || Main.npc[doom].type == NPCID.EaterofWorldsHead || Main.npc[doom].type == NPCID.EaterofWorldsTail || Main.npc[doom].type == ModContent.NPCType() || + Main.npc[doom].type == ModContent.NPCType() || Main.npc[doom].type == ModContent.NPCType() || Main.npc[doom].type == ModContent.NPCType())) || CalamityWorld.DoGSecondStageCountdown > 0) + { + player.KillMe(PlayerDeathReason.ByCustomReason(player.name + " tried to change the rules."), 1000.0, 0, false); + Main.npc[doom].active = Main.npc[doom].friendly; + Main.npc[doom].netUpdate = true; + } + } + if (!CalamityWorld.ironHeart) { CalamityWorld.ironHeart = true; string key = "Mods.CalamityMod.IronHeartText"; diff --git a/NPCs/Astral/Aries.cs b/NPCs/Astral/Aries.cs index e27be4a2be..7411eedc31 100644 --- a/NPCs/Astral/Aries.cs +++ b/NPCs/Astral/Aries.cs @@ -102,7 +102,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index a2abc3311a..f3e28b000e 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -293,7 +293,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/AstralSlime.cs b/NPCs/Astral/AstralSlime.cs index 1dd8067b76..823eeb5d01 100644 --- a/NPCs/Astral/AstralSlime.cs +++ b/NPCs/Astral/AstralSlime.cs @@ -62,7 +62,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/AstralachneaGround.cs b/NPCs/Astral/AstralachneaGround.cs index 81fa114674..caf087f35e 100644 --- a/NPCs/Astral/AstralachneaGround.cs +++ b/NPCs/Astral/AstralachneaGround.cs @@ -148,7 +148,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/Atlas.cs b/NPCs/Astral/Atlas.cs index 3ce951f053..ce8c8f0e40 100644 --- a/NPCs/Astral/Atlas.cs +++ b/NPCs/Astral/Atlas.cs @@ -610,7 +610,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/BigSightseer.cs b/NPCs/Astral/BigSightseer.cs index 5c6552fa6c..918c76f0b6 100644 --- a/NPCs/Astral/BigSightseer.cs +++ b/NPCs/Astral/BigSightseer.cs @@ -147,8 +147,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/EnchantedNightcrawler.cs b/NPCs/Astral/EnchantedNightcrawler.cs index 944a68c4a8..99cb60152e 100644 --- a/NPCs/Astral/EnchantedNightcrawler.cs +++ b/NPCs/Astral/EnchantedNightcrawler.cs @@ -38,7 +38,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/FusionFeeder.cs b/NPCs/Astral/FusionFeeder.cs index 1e7216d85b..0e724cb04e 100644 --- a/NPCs/Astral/FusionFeeder.cs +++ b/NPCs/Astral/FusionFeeder.cs @@ -109,7 +109,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/Hadarian.cs b/NPCs/Astral/Hadarian.cs index 2cc7eb6e38..7e5b6ccbb6 100644 --- a/NPCs/Astral/Hadarian.cs +++ b/NPCs/Astral/Hadarian.cs @@ -183,7 +183,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/Hive.cs b/NPCs/Astral/Hive.cs index c5566554ff..23fe7877e6 100644 --- a/NPCs/Astral/Hive.cs +++ b/NPCs/Astral/Hive.cs @@ -121,13 +121,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - //only 1 hive possible. - bool anyHives = NPC.CountNPCS(npc.type) > 0; - if (anyHives) - return 0f; - - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player) || NPC.AnyNPCs(npc.type)) { return 0f; } diff --git a/NPCs/Astral/Mantis.cs b/NPCs/Astral/Mantis.cs index 6a54edbd3c..8f9f7da46d 100644 --- a/NPCs/Astral/Mantis.cs +++ b/NPCs/Astral/Mantis.cs @@ -64,39 +64,31 @@ namespace CalamityMod.NPCs.Astral { npc.velocity.X -= acceleration; if (npc.velocity.X > 0) - { npc.velocity.X -= acceleration; - } if (npc.velocity.X < -maxSpeed) - { npc.velocity.X = -maxSpeed; - } } else { npc.velocity.X += acceleration; if (npc.velocity.X < 0) - { npc.velocity.X += acceleration; - } if (npc.velocity.X > maxSpeed) - { npc.velocity.X = maxSpeed; - } } //if need to jump if (npc.velocity.Y == 0f && (HoleBelow() || (npc.collideX && npc.position.X == npc.oldPosition.X))) { - npc.velocity.Y = (CalamityWorld.death ? -7f : -5f); + npc.velocity.Y = CalamityWorld.death ? -7f : -5f; } //check if we can shoot at target. Vector2 vector = npc.Center - target.Center; - if (Math.Abs(vector.Y) < 64f && Math.Abs(vector.X) < 540f && Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) + if (vector.Length() < 480f && Collision.CanHit(npc.position, npc.width, npc.height, target.position, target.width, target.height)) { - npc.ai[1]++; - if (npc.ai[1] > (CalamityWorld.death ? 60f : 120f)) + npc.ai[1] += 1f; + if (npc.ai[1] >= (CalamityWorld.death ? 60f : 120f)) { //fire projectile npc.ai[0] = 1f; @@ -106,24 +98,19 @@ namespace CalamityMod.NPCs.Astral } } else - { npc.ai[1] -= 0.5f; - } if (npc.justHit) - { npc.ai[1] -= 60f; - } - if (npc.ai[1] < 0f) npc.ai[1] = 0f; } else { - npc.ai[2]++; + npc.ai[2] += 1f; npc.velocity.X *= 0.95f; - if (npc.ai[2] == 25f) + if (npc.ai[2] >= 20f) { Main.PlaySound(SoundID.Item71, npc.position); Vector2 vector = Main.player[npc.target].Center - npc.Center; @@ -230,7 +217,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/Nova.cs b/NPCs/Astral/Nova.cs index 2cd1f5bd17..04ab9247a6 100644 --- a/NPCs/Astral/Nova.cs +++ b/NPCs/Astral/Nova.cs @@ -262,7 +262,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/SmallSightseer.cs b/NPCs/Astral/SmallSightseer.cs index b16d5068ce..e8f6cfc624 100644 --- a/NPCs/Astral/SmallSightseer.cs +++ b/NPCs/Astral/SmallSightseer.cs @@ -114,8 +114,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - Tile tile = Main.tile[spawnInfo.spawnTileX, spawnInfo.spawnTileY]; - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/StellarCulex.cs b/NPCs/Astral/StellarCulex.cs index f0ec674ee5..69e8bc6c7a 100644 --- a/NPCs/Astral/StellarCulex.cs +++ b/NPCs/Astral/StellarCulex.cs @@ -102,7 +102,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/Astral/Twinkler.cs b/NPCs/Astral/Twinkler.cs index 5ab6f2a60c..1cc77dad77 100644 --- a/NPCs/Astral/Twinkler.cs +++ b/NPCs/Astral/Twinkler.cs @@ -56,7 +56,7 @@ namespace CalamityMod.NPCs.Astral public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.player.PillarZone()) + if (CalamityGlobalNPC.AnyEvents(spawnInfo.player)) { return 0f; } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 3d73f2c3a2..23a68cfdde 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -90,9 +90,6 @@ namespace CalamityMod.NPCs public Dictionary flatDRReductions = new Dictionary(); public Dictionary multDRReductions = new Dictionary(); - // Iron Heart (currently unimplemented) - // private int ironHeartDamage = 0; - // Max velocity used in contact damage scaling public float maxVelocity = 0f; @@ -778,11 +775,6 @@ namespace CalamityMod.NPCs } OtherStatChanges(npc); - - if (CalamityWorld.ironHeart) - { - IronHeartChanges(npc); - } } #endregion @@ -1225,15 +1217,6 @@ namespace CalamityMod.NPCs } #endregion - // TODO -- Change Iron Heart damage in here for Iron Heart mode - #region Iron Heart Changes - private void IronHeartChanges(NPC npc) - { - // Iron Heart damage variable will scale with npc.damage - // ironHeartDamage = 0; - } - #endregion - #region Scale Expert Multiplayer Stats public override void ScaleExpertStats(NPC npc, int numPlayers, float bossLifeScale) { diff --git a/NPCs/DevourerofGods/DevourerofGodsHead2.cs b/NPCs/DevourerofGods/DevourerofGodsHead2.cs index 5692d8a2c4..441976927f 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead2.cs @@ -135,10 +135,10 @@ namespace CalamityMod.NPCs.DevourerofGods if (player.dead || CalamityGlobalNPC.DoGHead < 0 || !Main.npc[CalamityGlobalNPC.DoGHead].active) { npc.TargetClosest(false); - npc.velocity.Y = npc.velocity.Y - 3f; + npc.velocity.Y -= 3f; if ((double)npc.position.Y < Main.topWorld + 16f) { - npc.velocity.Y = npc.velocity.Y - 3f; + npc.velocity.Y -= 3f; } if ((double)npc.position.Y < Main.topWorld + 16f) { diff --git a/NPCs/SupremeCalamitas/SCalWormHead.cs b/NPCs/SupremeCalamitas/SCalWormHead.cs index 07ff19638f..1c570f4c68 100644 --- a/NPCs/SupremeCalamitas/SCalWormHead.cs +++ b/NPCs/SupremeCalamitas/SCalWormHead.cs @@ -63,12 +63,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SendExtraAI(BinaryWriter writer) { writer.Write(npc.localAI[0]); - } + writer.Write(npc.alpha); + } public override void ReceiveExtraAI(BinaryReader reader) { npc.localAI[0] = reader.ReadSingle(); - } + npc.alpha = reader.ReadInt32(); + } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { diff --git a/Projectiles/Summon/PurpleButterfly.cs b/Projectiles/Summon/PurpleButterfly.cs index 0927822a9d..69aacc2f67 100644 --- a/Projectiles/Summon/PurpleButterfly.cs +++ b/Projectiles/Summon/PurpleButterfly.cs @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.immune[projectile.owner] = 6; + target.immune[projectile.owner] = 8; } } } diff --git a/Projectiles/Summon/SakuraBullet.cs b/Projectiles/Summon/SakuraBullet.cs index d742786f82..13a6f07c97 100644 --- a/Projectiles/Summon/SakuraBullet.cs +++ b/Projectiles/Summon/SakuraBullet.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Summon for (int i = 0; i < Main.maxNPCs; i++) { NPC npc = Main.npc[i]; - if ((npc.CanBeChasedBy(projectile, false) || npc.type == NPCID.DukeFishron) && npc.active) + if ((npc.CanBeChasedBy(projectile, false) || (npc.type == NPCID.DukeFishron && (!npc.dontTakeDamage || npc.ai[0] > 9f))) && npc.active) { float extraDistance = (npc.width / 2) + (npc.height / 2);