diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 45b8f04009..bc05a682a5 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -804,7 +804,7 @@ namespace CalamityMod.Items if (item.type == ModContent.ItemType()) tt2.overrideColor = new Color(255 - Main.DiscoG < 80 ? 80 : Main.DiscoG < 50 ? 255 : 255 - Main.DiscoG, Main.DiscoG < 126 ? 126 : Main.DiscoG, 0); //alternates between emerald green and amber (BanditHueh) - // Uniquely colored legendary weapons and Yharim's Crystal + // Uniquely colored legendary weapons and Yharim's Crystal if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) tt2.overrideColor = new Color(255, Main.DiscoG, 53); if (item.type == ModContent.ItemType()) diff --git a/Items/Tools/ClimateChange/AridArtifact.cs b/Items/Tools/ClimateChange/AridArtifact.cs index 7caf3e2094..1e43393ae7 100644 --- a/Items/Tools/ClimateChange/AridArtifact.cs +++ b/Items/Tools/ClimateChange/AridArtifact.cs @@ -26,12 +26,12 @@ namespace CalamityMod.Items.Tools.ClimateChange item.consumable = true; } - // this is extremely ugly and has to be fully qualified because we add an item called Sandstorm public override bool CanUseItem(Player player) { return CalamityWorld.downedDesertScourge; } + // this is extremely ugly and has to be fully qualified because we add an item called Sandstorm public override bool UseItem(Player player) { if (Terraria.GameContent.Events.Sandstorm.Happening) diff --git a/Items/Tools/ClimateChange/TorrentialTear.cs b/Items/Tools/ClimateChange/TorrentialTear.cs index 831347eb52..3f664889a9 100644 --- a/Items/Tools/ClimateChange/TorrentialTear.cs +++ b/Items/Tools/ClimateChange/TorrentialTear.cs @@ -39,53 +39,7 @@ namespace CalamityMod.Items.Tools.ClimateChange { if (!Main.raining) { - int num = 86400; - int num2 = num / 24; - Main.rainTime = Main.rand.Next(num2 * 8, num); - if (Main.rand.NextBool(3)) - { - Main.rainTime += Main.rand.Next(0, num2); - } - if (Main.rand.NextBool(4)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(5)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(6)) - { - Main.rainTime += Main.rand.Next(0, num2 * 3); - } - if (Main.rand.NextBool(7)) - { - Main.rainTime += Main.rand.Next(0, num2 * 4); - } - if (Main.rand.NextBool(8)) - { - Main.rainTime += Main.rand.Next(0, num2 * 5); - } - float num3 = 1f; - if (Main.rand.NextBool(2)) - { - num3 += 0.05f; - } - if (Main.rand.NextBool(3)) - { - num3 += 0.1f; - } - if (Main.rand.NextBool(4)) - { - num3 += 0.15f; - } - if (Main.rand.NextBool(5)) - { - num3 += 0.2f; - } - Main.rainTime = (int)((float)Main.rainTime * num3); - AdjustRainSeverity(false); - Main.raining = true; + CalamityUtils.StartRain(true); } else if (CalamityWorld.death) { @@ -116,7 +70,7 @@ namespace CalamityMod.Items.Tools.ClimateChange return true; } - private void AdjustRainSeverity(bool maxSeverity) + public static void AdjustRainSeverity(bool maxSeverity) { if (maxSeverity) { diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 936084c012..34d0791f70 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -164,7 +164,7 @@ namespace CalamityMod.NPCs.Cryogen if (!Main.raining && !CalamityWorld.bossRushActive) { - RainStart(); + CalamityUtils.StartRain(); } if (!player.active || player.dead) @@ -1044,57 +1044,6 @@ namespace CalamityMod.NPCs.Cryogen } } - private void RainStart() - { - int num = 86400; - int num2 = num / 24; - Main.rainTime = Main.rand.Next(num2 * 8, num); - if (Main.rand.NextBool(3)) - { - Main.rainTime += Main.rand.Next(0, num2); - } - if (Main.rand.NextBool(4)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(5)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(6)) - { - Main.rainTime += Main.rand.Next(0, num2 * 3); - } - if (Main.rand.NextBool(7)) - { - Main.rainTime += Main.rand.Next(0, num2 * 4); - } - if (Main.rand.NextBool(8)) - { - Main.rainTime += Main.rand.Next(0, num2 * 5); - } - float num3 = 1f; - if (Main.rand.NextBool(2)) - { - num3 += 0.05f; - } - if (Main.rand.NextBool(3)) - { - num3 += 0.1f; - } - if (Main.rand.NextBool(4)) - { - num3 += 0.15f; - } - if (Main.rand.NextBool(5)) - { - num3 += 0.2f; - } - Main.rainTime = (int)((float)Main.rainTime * num3); - Main.raining = true; - CalamityMod.UpdateServerBoolean(); - } - public override void BossLoot(ref string name, ref int potionType) { potionType = ItemID.GreaterHealingPotion; diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 9d8cbd5d71..77b5dae334 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -94,7 +94,7 @@ namespace CalamityMod.NPCs.StormWeaver } if (!Main.raining && !CalamityWorld.bossRushActive && CalamityWorld.DoGSecondStageCountdown <= 0) { - RainStart(); + CalamityUtils.StartRain(); } Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (npc.ai[3] > 0f) @@ -463,57 +463,6 @@ namespace CalamityMod.NPCs.StormWeaver npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; } - private void RainStart() - { - int num = 86400; - int num2 = num / 24; - Main.rainTime = Main.rand.Next(num2 * 8, num); - if (Main.rand.NextBool(3)) - { - Main.rainTime += Main.rand.Next(0, num2); - } - if (Main.rand.NextBool(4)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(5)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(6)) - { - Main.rainTime += Main.rand.Next(0, num2 * 3); - } - if (Main.rand.NextBool(7)) - { - Main.rainTime += Main.rand.Next(0, num2 * 4); - } - if (Main.rand.NextBool(8)) - { - Main.rainTime += Main.rand.Next(0, num2 * 5); - } - float num3 = 1f; - if (Main.rand.NextBool(2)) - { - num3 += 0.05f; - } - if (Main.rand.NextBool(3)) - { - num3 += 0.1f; - } - if (Main.rand.NextBool(4)) - { - num3 += 0.15f; - } - if (Main.rand.NextBool(5)) - { - num3 += 0.2f; - } - Main.rainTime = (int)((float)Main.rainTime * num3); - Main.raining = true; - CalamityMod.UpdateServerBoolean(); - } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; diff --git a/NPCs/StormWeaver/StormWeaverHeadNaked.cs b/NPCs/StormWeaver/StormWeaverHeadNaked.cs index 129d06d7a9..2d6353a7af 100644 --- a/NPCs/StormWeaver/StormWeaverHeadNaked.cs +++ b/NPCs/StormWeaver/StormWeaverHeadNaked.cs @@ -106,7 +106,7 @@ namespace CalamityMod.NPCs.StormWeaver } if (!Main.raining && !CalamityWorld.bossRushActive && CalamityWorld.DoGSecondStageCountdown <= 0) { - RainStart(); + CalamityUtils.StartRain(); } double lifeRatio = (double)npc.life / (double)npc.lifeMax; int lifePercentage = (int)(100.0 * lifeRatio); @@ -441,57 +441,6 @@ namespace CalamityMod.NPCs.StormWeaver npc.rotation = (float)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; } - private void RainStart() - { - int num = 86400; - int num2 = num / 24; - Main.rainTime = Main.rand.Next(num2 * 8, num); - if (Main.rand.NextBool(3)) - { - Main.rainTime += Main.rand.Next(0, num2); - } - if (Main.rand.NextBool(4)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(5)) - { - Main.rainTime += Main.rand.Next(0, num2 * 2); - } - if (Main.rand.NextBool(6)) - { - Main.rainTime += Main.rand.Next(0, num2 * 3); - } - if (Main.rand.NextBool(7)) - { - Main.rainTime += Main.rand.Next(0, num2 * 4); - } - if (Main.rand.NextBool(8)) - { - Main.rainTime += Main.rand.Next(0, num2 * 5); - } - float num3 = 1f; - if (Main.rand.NextBool(2)) - { - num3 += 0.05f; - } - if (Main.rand.NextBool(3)) - { - num3 += 0.1f; - } - if (Main.rand.NextBool(4)) - { - num3 += 0.15f; - } - if (Main.rand.NextBool(5)) - { - num3 += 0.2f; - } - Main.rainTime = (int)((float)Main.rainTime * num3); - Main.raining = true; - CalamityMod.UpdateServerBoolean(); - } - public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { SpriteEffects spriteEffects = SpriteEffects.None; diff --git a/Projectiles/Summon/BrimstoneFireSummon.cs b/Projectiles/Summon/BrimstoneFireSummon.cs index 6592783318..56cfa6c715 100644 --- a/Projectiles/Summon/BrimstoneFireSummon.cs +++ b/Projectiles/Summon/BrimstoneFireSummon.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Summon projectile.ignoreWater = true; projectile.minion = true; projectile.minionSlots = 0f; - projectile.penetrate = 2; + projectile.penetrate = 1; projectile.extraUpdates = 3; projectile.timeLeft = 50; } @@ -79,7 +79,6 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.immune[projectile.owner] = 9; } } } diff --git a/Projectiles/Summon/Calamitamini.cs b/Projectiles/Summon/Calamitamini.cs index 2f39fe67d4..3e84416676 100644 --- a/Projectiles/Summon/Calamitamini.cs +++ b/Projectiles/Summon/Calamitamini.cs @@ -202,8 +202,8 @@ namespace CalamityMod.Projectiles.Summon } if (num651 > 2000f) { - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.position.X = player.Center.X - (float)(projectile.width / 2); + projectile.position.Y = player.Center.Y - (float)(projectile.height / 2); projectile.netUpdate = true; } if (num651 > 70f) @@ -240,7 +240,7 @@ namespace CalamityMod.Projectiles.Summon { projectile.ai[1] += (float)Main.rand.Next(1, 4); } - if (projectile.ai[1] > 90f) + if (projectile.ai[1] > 110f) { projectile.ai[1] = 0f; projectile.netUpdate = true; @@ -257,8 +257,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 value19 = vector46 - projectile.Center; value19.Normalize(); value19 *= scaleFactor3; - int num659 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, num658, projectile.damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num659].timeLeft = 300; + int num659 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, num658, projectile.damage, 0f, projectile.owner, 0f, 0f); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/Cataclymini.cs b/Projectiles/Summon/Cataclymini.cs index 0390c49754..ec460fd744 100644 --- a/Projectiles/Summon/Cataclymini.cs +++ b/Projectiles/Summon/Cataclymini.cs @@ -256,8 +256,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 value19 = vector46 - projectile.Center; value19.Normalize(); value19 *= scaleFactor3; - int num659 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, num658, projectile.damage, 0f, Main.myPlayer, 0f, 0f); - Main.projectile[num659].timeLeft = 50; + int num659 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, value19.X, value19.Y, num658, projectile.damage, 0f, projectile.owner, 0f, 0f); projectile.netUpdate = true; } } diff --git a/Projectiles/Summon/Catastromini.cs b/Projectiles/Summon/Catastromini.cs index 52942a9fe4..e9bf6d1068 100644 --- a/Projectiles/Summon/Catastromini.cs +++ b/Projectiles/Summon/Catastromini.cs @@ -292,10 +292,5 @@ namespace CalamityMod.Projectiles.Summon Main.spriteBatch.Draw(texture2D13, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), projectile.GetAlpha(lightColor), projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), projectile.scale, spriteEffects, 0f); return false; } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 9; - } } } diff --git a/Utilities/CalamityUtils.cs b/Utilities/CalamityUtils.cs index c13bbb8a1d..4f4c51476d 100644 --- a/Utilities/CalamityUtils.cs +++ b/Utilities/CalamityUtils.cs @@ -1,5 +1,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Items; +using CalamityMod.Items.Tools.ClimateChange; using CalamityMod.NPCs; using CalamityMod.Projectiles; using CalamityMod.Tiles; @@ -2080,18 +2081,18 @@ namespace CalamityMod Lighting.AddLight(projectile.Center, 0.4f, 0f, 0.4f); Player player = Main.player[projectile.owner]; - if (projectile.bobber && Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].holdStyle > 0) + if (projectile.bobber && player.inventory[player.selectedItem].holdStyle > 0) { float pPosX = player.MountedCenter.X; float pPosY = player.MountedCenter.Y; - pPosY += Main.player[projectile.owner].gfxOffY; - int type = Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].type; - float gravDir = Main.player[projectile.owner].gravDir; + pPosY += player.gfxOffY; + int type = player.inventory[player.selectedItem].type; + float gravDir = player.gravDir; if (type == fishingRodType) { - pPosX += (float)(xPositionAdditive * Main.player[projectile.owner].direction); - if (Main.player[projectile.owner].direction < 0) + pPosX += (float)(xPositionAdditive * player.direction); + if (player.direction < 0) { pPosX -= 13f; } @@ -2103,7 +2104,7 @@ namespace CalamityMod pPosY -= 12f; } Vector2 mountedCenter = new Vector2(pPosX, pPosY); - mountedCenter = Main.player[projectile.owner].RotatedRelativePoint(mountedCenter + new Vector2(8f), true) - new Vector2(8f); + mountedCenter = player.RotatedRelativePoint(mountedCenter + new Vector2(8f), true) - new Vector2(8f); float projPosX = projectile.position.X + (float)projectile.width * 0.5f - mountedCenter.X; float projPosY = projectile.position.Y + (float)projectile.height * 0.5f - mountedCenter.Y; Math.Sqrt((double)(projPosX * projPosX + projPosY * projPosY)); @@ -2382,6 +2383,59 @@ namespace CalamityMod (sfx.Volume, sfx.Pan) = CalculateSoundStats(soundPos, ambient); } + public static void StartRain(bool torrentialTear = false) + { + int num = 86400; + int num2 = num / 24; + Main.rainTime = Main.rand.Next(num2 * 8, num); + if (Main.rand.NextBool(3)) + { + Main.rainTime += Main.rand.Next(0, num2); + } + if (Main.rand.NextBool(4)) + { + Main.rainTime += Main.rand.Next(0, num2 * 2); + } + if (Main.rand.NextBool(5)) + { + Main.rainTime += Main.rand.Next(0, num2 * 2); + } + if (Main.rand.NextBool(6)) + { + Main.rainTime += Main.rand.Next(0, num2 * 3); + } + if (Main.rand.NextBool(7)) + { + Main.rainTime += Main.rand.Next(0, num2 * 4); + } + if (Main.rand.NextBool(8)) + { + Main.rainTime += Main.rand.Next(0, num2 * 5); + } + float num3 = 1f; + if (Main.rand.NextBool(2)) + { + num3 += 0.05f; + } + if (Main.rand.NextBool(3)) + { + num3 += 0.1f; + } + if (Main.rand.NextBool(4)) + { + num3 += 0.15f; + } + if (Main.rand.NextBool(5)) + { + num3 += 0.2f; + } + Main.rainTime = (int)((float)Main.rainTime * num3); + Main.raining = true; + if (torrentialTear) + TorrentialTear.AdjustRainSeverity(false); + CalamityMod.UpdateServerBoolean(); + } + public static void StartSandstorm() { typeof(Terraria.GameContent.Events.Sandstorm).GetMethod("StartSandstorm", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null);